1546 def RunProgram(self, program, arguments, context, result):
1547 """Run the 'program'.
1549 'program' -- The path to the program to run.
1551 'arguments' -- A list of the arguments to the program. This
1552 list must contain a first argument corresponding to 'argv[0]'.
1554 'context' -- A 'Context' giving run-time parameters to the
1557 'result' -- A 'Result' object. The outcome will be
1558 'Result.PASS' when this method is called. The 'result' may be
1559 modified by this method to indicate outcomes other than
1560 'Result.PASS' or to add annotations.
1562 @attention: This method has been copied from command.ExecTestBase
1563 (QMTest 2.3.0) and modified to keep stdout and stderr
1564 for tests that have been terminated by a signal.
1565 (Fundamental for debugging in the Application Area)
1569 environment = self.MakeEnvironment(context)
1571 if "slc6" in environment.get(
'CMTCONFIG',
''):
1572 environment[
'TERM'] =
'dumb'
1585 exit_status = e.Run(arguments, environment, path = program)
1587 if e.stack_trace_file
and os.path.exists(e.stack_trace_file):
1588 stack_trace = open(e.stack_trace_file).read()
1589 os.remove(e.stack_trace_file)
1593 result[
"ExecTest.stack_trace"] = result.Quote(stack_trace)
1596 if (sys.platform ==
"win32" or os.WIFEXITED(exit_status)
1597 or self.
signal == os.WTERMSIG(exit_status)):
1602 if self.exit_code
is None:
1604 elif sys.platform ==
"win32":
1605 exit_code = exit_status
1607 exit_code = os.WEXITSTATUS(exit_status)
1612 result[
"ExecTest.exit_code"] = str(exit_code)
1613 result[
"ExecTest.stdout"] = result.Quote(stdout)
1614 result[
"ExecTest.stderr"] = result.Quote(stderr)
1616 if exit_code != self.exit_code:
1617 causes.append(
"exit_code")
1618 result[
"ExecTest.expected_exit_code"] \
1619 = str(self.exit_code)
1624 result.Fail(
"Unexpected %s." % string.join(causes,
", "))
1625 elif os.WIFSIGNALED(exit_status):
1628 signal_number = str(os.WTERMSIG(exit_status))
1630 result.Fail(
"Program terminated by signal.")
1634 result.Fail(
"Exceeded time limit (%ds), terminated." % timeout)
1635 result[
"ExecTest.signal_number"] = signal_number
1636 result[
"ExecTest.stdout"] = result.Quote(e.stdout)
1637 result[
"ExecTest.stderr"] = result.Quote(e.stderr)
1639 result[
"ExecTest.expected_signal_number"] = str(self.
signal)
1640 elif os.WIFSTOPPED(exit_status):
1643 signal_number = str(os.WSTOPSIG(exit_status))
1645 result.Fail(
"Program stopped by signal.")
1649 result.Fail(
"Exceeded time limit (%ds), stopped." % timeout)
1650 result[
"ExecTest.signal_number"] = signal_number
1651 result[
"ExecTest.stdout"] = result.Quote(e.stdout)
1652 result[
"ExecTest.stderr"] = result.Quote(e.stderr)
1656 result.Fail(
"Program did not terminate normally.")
1662 result[
"ExecTest.stdout"] = result[
"ExecTest.stdout"].replace(esc,repr_esc)