1698 """Run the 'program'. 1700 'program' -- The path to the program to run. 1702 'arguments' -- A list of the arguments to the program. This 1703 list must contain a first argument corresponding to 'argv[0]'. 1705 'context' -- A 'Context' giving run-time parameters to the 1708 'result' -- A 'Result' object. The outcome will be 1709 'Result.PASS' when this method is called. The 'result' may be 1710 modified by this method to indicate outcomes other than 1711 'Result.PASS' or to add annotations. 1713 @attention: This method has been copied from command.ExecTestBase 1714 (QMTest 2.3.0) and modified to keep stdout and stderr 1715 for tests that have been terminated by a signal. 1716 (Fundamental for debugging in the Application Area) 1720 environment = self.MakeEnvironment(context)
1722 if "slc6" in environment.get(
'CMTCONFIG',
''):
1723 environment[
'TERM'] =
'dumb' 1736 exit_status = e.Run(arguments, environment, path=program)
1738 if e.stack_trace_file
and os.path.exists(e.stack_trace_file):
1739 stack_trace = open(e.stack_trace_file).
read()
1740 os.remove(e.stack_trace_file)
1744 result[
"ExecTest.stack_trace"] = result.Quote(stack_trace)
1747 if (sys.platform ==
"win32" or os.WIFEXITED(exit_status)
1753 if self.exit_code
is None:
1755 elif sys.platform ==
"win32":
1756 exit_code = exit_status
1758 exit_code = os.WEXITSTATUS(exit_status)
1763 result[
"ExecTest.exit_code"] = str(exit_code)
1764 result[
"ExecTest.stdout"] = result.Quote(stdout)
1765 result[
"ExecTest.stderr"] = result.Quote(stderr)
1767 if exit_code != self.exit_code:
1768 causes.append(
"exit_code")
1769 result[
"ExecTest.expected_exit_code"] \
1770 = str(self.exit_code)
1775 result.Fail(
"Unexpected %s." % string.join(causes,
", "))
1776 elif os.WIFSIGNALED(exit_status):
1779 signal_number = str(os.WTERMSIG(exit_status))
1781 result.Fail(
"Program terminated by signal.")
1785 result.Fail(
"Exceeded time limit (%ds), terminated." % timeout)
1786 result[
"ExecTest.signal_number"] = signal_number
1787 result[
"ExecTest.stdout"] = result.Quote(e.stdout)
1788 result[
"ExecTest.stderr"] = result.Quote(e.stderr)
1790 result[
"ExecTest.expected_signal_number"] = str(self.
signal)
1791 elif os.WIFSTOPPED(exit_status):
1794 signal_number = str(os.WSTOPSIG(exit_status))
1796 result.Fail(
"Program stopped by signal.")
1800 result.Fail(
"Exceeded time limit (%ds), stopped." % timeout)
1801 result[
"ExecTest.signal_number"] = signal_number
1802 result[
"ExecTest.stdout"] = result.Quote(e.stdout)
1803 result[
"ExecTest.stderr"] = result.Quote(e.stderr)
1807 result.Fail(
"Program did not terminate normally.")
1813 result[
"ExecTest.stdout"] = result[
"ExecTest.stdout"].replace(
def read(f, regex='.*', skipevents=0)
def RunProgram(self, program, arguments, context, result)
def ValidateOutput(self, stdout, stderr, result)