1479 def RunProgram(self, program, arguments, context, result):
1480 """Run the 'program'.
1482 'program' -- The path to the program to run.
1484 'arguments' -- A list of the arguments to the program. This
1485 list must contain a first argument corresponding to 'argv[0]'.
1487 'context' -- A 'Context' giving run-time parameters to the
1490 'result' -- A 'Result' object. The outcome will be
1491 'Result.PASS' when this method is called. The 'result' may be
1492 modified by this method to indicate outcomes other than
1493 'Result.PASS' or to add annotations.
1495 @attention: This method has been copied from command.ExecTestBase
1496 (QMTest 2.3.0) and modified to keep stdout and stderr
1497 for tests that have been terminated by a signal.
1498 (Fundamental for debugging in the Application Area)
1502 environment = self.MakeEnvironment(context)
1504 if "slc6" in environment.get(
'CMTCONFIG',
''):
1505 environment[
'TERM'] =
'dumb'
1518 exit_status = e.Run(arguments, environment, path = program)
1520 if e.stack_trace_file
and os.path.exists(e.stack_trace_file):
1521 stack_trace = open(e.stack_trace_file).read()
1522 os.remove(e.stack_trace_file)
1526 result[
"ExecTest.stack_trace"] = result.Quote(stack_trace)
1529 if (sys.platform ==
"win32" or os.WIFEXITED(exit_status)
1530 or self.
signal == os.WTERMSIG(exit_status)):
1535 if self.exit_code
is None:
1537 elif sys.platform ==
"win32":
1538 exit_code = exit_status
1540 exit_code = os.WEXITSTATUS(exit_status)
1545 result[
"ExecTest.exit_code"] = str(exit_code)
1546 result[
"ExecTest.stdout"] = result.Quote(stdout)
1547 result[
"ExecTest.stderr"] = result.Quote(stderr)
1549 if exit_code != self.exit_code:
1550 causes.append(
"exit_code")
1551 result[
"ExecTest.expected_exit_code"] \
1552 = str(self.exit_code)
1557 result.Fail(
"Unexpected %s." % string.join(causes,
", "))
1558 elif os.WIFSIGNALED(exit_status):
1561 signal_number = str(os.WTERMSIG(exit_status))
1563 result.Fail(
"Program terminated by signal.")
1567 result.Fail(
"Exceeded time limit (%ds), terminated." % timeout)
1568 result[
"ExecTest.signal_number"] = signal_number
1569 result[
"ExecTest.stdout"] = result.Quote(e.stdout)
1570 result[
"ExecTest.stderr"] = result.Quote(e.stderr)
1572 result[
"ExecTest.expected_signal_number"] = str(self.
signal)
1573 elif os.WIFSTOPPED(exit_status):
1576 signal_number = str(os.WSTOPSIG(exit_status))
1578 result.Fail(
"Program stopped by signal.")
1582 result.Fail(
"Exceeded time limit (%ds), stopped." % timeout)
1583 result[
"ExecTest.signal_number"] = signal_number
1584 result[
"ExecTest.stdout"] = result.Quote(e.stdout)
1585 result[
"ExecTest.stderr"] = result.Quote(e.stderr)
1589 result.Fail(
"Program did not terminate normally.")
1595 result[
"ExecTest.stdout"] = result[
"ExecTest.stdout"].replace(esc,repr_esc)