1474 def RunProgram(self, program, arguments, context, result):
1475 """Run the 'program'.
1477 'program' -- The path to the program to run.
1479 'arguments' -- A list of the arguments to the program. This
1480 list must contain a first argument corresponding to 'argv[0]'.
1482 'context' -- A 'Context' giving run-time parameters to the
1485 'result' -- A 'Result' object. The outcome will be
1486 'Result.PASS' when this method is called. The 'result' may be
1487 modified by this method to indicate outcomes other than
1488 'Result.PASS' or to add annotations.
1490 @attention: This method has been copied from command.ExecTestBase
1491 (QMTest 2.3.0) and modified to keep stdout and stderr
1492 for tests that have been terminated by a signal.
1493 (Fundamental for debugging in the Application Area)
1497 environment = self.MakeEnvironment(context)
1499 if "slc6" in environment.get(
'CMTCONFIG',
''):
1500 environment[
'TERM'] =
'dumb'
1513 exit_status = e.Run(arguments, environment, path = program)
1515 if e.stack_trace_file
and os.path.exists(e.stack_trace_file):
1516 stack_trace = open(e.stack_trace_file).read()
1517 os.remove(e.stack_trace_file)
1521 result[
"ExecTest.stack_trace"] = result.Quote(stack_trace)
1523 print "===================", exit_status, os.WIFEXITED(exit_status)
1525 if (sys.platform ==
"win32" or os.WIFEXITED(exit_status)
1526 or self.
signal == os.WTERMSIG(exit_status)):
1531 if self.exit_code
is None:
1533 elif sys.platform ==
"win32":
1534 exit_code = exit_status
1536 exit_code = os.WEXITSTATUS(exit_status)
1541 result[
"ExecTest.exit_code"] = str(exit_code)
1542 result[
"ExecTest.stdout"] = result.Quote(stdout)
1543 result[
"ExecTest.stderr"] = result.Quote(stderr)
1545 if exit_code != self.exit_code:
1546 causes.append(
"exit_code")
1547 result[
"ExecTest.expected_exit_code"] \
1548 = str(self.exit_code)
1553 result.Fail(
"Unexpected %s." % string.join(causes,
", "))
1554 elif os.WIFSIGNALED(exit_status):
1557 signal_number = str(os.WTERMSIG(exit_status))
1559 result.Fail(
"Program terminated by signal.")
1563 result.Fail(
"Exceeded time limit (%ds), terminated." % timeout)
1564 result[
"ExecTest.signal_number"] = signal_number
1565 result[
"ExecTest.stdout"] = result.Quote(e.stdout)
1566 result[
"ExecTest.stderr"] = result.Quote(e.stderr)
1568 result[
"ExecTest.expected_signal_number"] = str(self.
signal)
1569 elif os.WIFSTOPPED(exit_status):
1572 signal_number = str(os.WSTOPSIG(exit_status))
1574 result.Fail(
"Program stopped by signal.")
1578 result.Fail(
"Exceeded time limit (%ds), stopped." % timeout)
1579 result[
"ExecTest.signal_number"] = signal_number
1580 result[
"ExecTest.stdout"] = result.Quote(e.stdout)
1581 result[
"ExecTest.stderr"] = result.Quote(e.stderr)
1585 result.Fail(
"Program did not terminate normally.")
1591 result[
"ExecTest.stdout"] = result[
"ExecTest.stdout"].replace(esc,repr_esc)