|
Gaudi Framework, version v22r1 |
| Home | Generated: Mon Feb 28 2011 |


Public Member Functions | |
| def | PlatformIsNotSupported |
| def | GetPlatform |
| def | CheckTTreesSummaries |
| def | CheckHistosSummaries |
| def | ValidateWithReference |
| def | ValidateOutput |
| def | DumpEnvironment |
| def | Run |
| def | RunProgram |
Public Attributes | |
| callable | |
| extra_args | |
| args_order | |
| program | |
| reference | |
| error_reference | |
| use_temp_dir | |
| timeout | |
Static Public Attributes | |
| list | arguments |
Private Member Functions | |
| def | _expandReferenceFileName |
| def | _find_program |
| def | _CreateEclipseLaunch |
Standard Gaudi test.
Definition at line 971 of file GaudiTest.py.
| def GaudiTest::GaudiExeTest::_CreateEclipseLaunch | ( | self, | |
| prog, | |||
| args, | |||
destdir = None |
|||
| ) | [private] |
Definition at line 1558 of file GaudiTest.py.
01559 : 01560 # Find the project name used in ecplise. 01561 # The name is in a file called ".project" in one of the parent directories 01562 projbasedir = os.path.normpath(destdir) 01563 while not os.path.exists(os.path.join(projbasedir, ".project")): 01564 oldprojdir = projbasedir 01565 projbasedir = os.path.normpath(os.path.join(projbasedir, os.pardir)) 01566 # FIXME: the root level is invariant when trying to go up one level, 01567 # but it must be cheched on windows 01568 if oldprojdir == projbasedir: 01569 # If we cannot find a .project, so no point in creating a .launch file 01570 return 01571 # Use ElementTree to parse the XML file 01572 from xml.etree import ElementTree as ET 01573 t = ET.parse(os.path.join(projbasedir, ".project")) 01574 projectName = t.find("name").text 01575 01576 # prepare the name/path of the generated file 01577 destfile = "%s.launch" % self._Runnable__id 01578 if destdir: 01579 destfile = os.path.join(destdir, destfile) 01580 01581 if self.options.strip(): 01582 # this means we have some custom options in the qmt file, so we have 01583 # to copy them from the temporary file at the end of the arguments 01584 # in another file 01585 tempfile = args.pop() 01586 optsfile = destfile + os.path.splitext(tempfile)[1] 01587 shutil.copyfile(tempfile, optsfile) 01588 args.append(optsfile) 01589 01590 # prepare the data to insert in the XML file 01591 from xml.sax.saxutils import quoteattr # useful to quote XML special chars 01592 data = {} 01593 # Note: the "quoteattr(k)" is not needed because special chars cannot be part of a variable name, 01594 # but it doesn't harm. 01595 data["environment"] = "\n".join(['<mapEntry key=%s value=%s/>' % (quoteattr(k), quoteattr(v)) 01596 for k, v in os.environ.iteritems()]) 01597 01598 data["exec"] = which(prog) 01599 if os.path.basename(data["exec"]).lower().startswith("python"): 01600 data["stopAtMain"] = "false" # do not stop at main when debugging Python scripts 01601 else: 01602 data["stopAtMain"] = "true" 01603 01604 data["args"] = " ".join(map(rationalizepath, args)) 01605 01606 if not self.use_temp_dir: 01607 data["workdir"] = os.getcwd() 01608 else: 01609 # If the test is using a tmporary directory, it is better to run it 01610 # in the same directory as the .launch file when debugged in eclipse 01611 data["workdir"] = destdir 01612 01613 data["project"] = projectName.strip() 01614 01615 # Template for the XML file, based on eclipse 3.4 01616 xml = """<?xml version="1.0" encoding="UTF-8" standalone="no"?> 01617 <launchConfiguration type="org.eclipse.cdt.launch.applicationLaunchType"> 01618 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.AUTO_SOLIB" value="true"/> 01619 <listAttribute key="org.eclipse.cdt.debug.mi.core.AUTO_SOLIB_LIST"/> 01620 <stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="gdb"/> 01621 <stringAttribute key="org.eclipse.cdt.debug.mi.core.GDB_INIT" value=".gdbinit"/> 01622 <listAttribute key="org.eclipse.cdt.debug.mi.core.SOLIB_PATH"/> 01623 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.STOP_ON_SOLIB_EVENTS" value="false"/> 01624 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.breakpointsFullPath" value="false"/> 01625 <stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="org.eclipse.cdt.debug.mi.core.standardCommandFactory"/> 01626 <stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/> 01627 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/> 01628 <intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="0"/> 01629 <stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/> 01630 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_ID" value="org.eclipse.cdt.debug.mi.core.CDebuggerNew"/> 01631 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/> 01632 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="run"/> 01633 <booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="%(stopAtMain)s"/> 01634 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/> 01635 <booleanAttribute key="org.eclipse.cdt.launch.ENABLE_REGISTER_BOOKKEEPING" value="false"/> 01636 <booleanAttribute key="org.eclipse.cdt.launch.ENABLE_VARIABLE_BOOKKEEPING" value="false"/> 01637 <stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList/>"/> 01638 <stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/> 01639 <stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/> 01640 <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_ARGUMENTS" value="%(args)s"/> 01641 <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="%(exec)s"/> 01642 <stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="%(project)s"/> 01643 <stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/> 01644 <stringAttribute key="org.eclipse.cdt.launch.WORKING_DIRECTORY" value="%(workdir)s"/> 01645 <booleanAttribute key="org.eclipse.cdt.launch.ui.ApplicationCDebuggerTab.DEFAULTS_SET" value="true"/> 01646 <booleanAttribute key="org.eclipse.cdt.launch.use_terminal" value="true"/> 01647 <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> 01648 <listEntry value="/%(project)s"/> 01649 </listAttribute> 01650 <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> 01651 <listEntry value="4"/> 01652 </listAttribute> 01653 <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="false"/> 01654 <mapAttribute key="org.eclipse.debug.core.environmentVariables"> 01655 %(environment)s 01656 </mapAttribute> 01657 <mapAttribute key="org.eclipse.debug.core.preferred_launchers"> 01658 <mapEntry key="[debug]" value="org.eclipse.cdt.cdi.launch.localCLaunch"/> 01659 </mapAttribute> 01660 <listAttribute key="org.eclipse.debug.ui.favoriteGroups"> 01661 <listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> 01662 </listAttribute> 01663 </launchConfiguration> 01664 """ % data 01665 01666 # Write the output file 01667 open(destfile, "w").write(xml) 01668 #open(destfile + "_copy.xml", "w").write(xml) 01669 01670 try:
| def GaudiTest::GaudiExeTest::_expandReferenceFileName | ( | self, | |
| reffile | |||
| ) | [private] |
Definition at line 1114 of file GaudiTest.py.
01115 : 01116 # if no file is passed, do nothing 01117 if not reffile: 01118 return "" 01119 01120 # function to split an extension in constituents parts 01121 platformSplit = lambda p: set(p.split('-' in p and '-' or '_')) 01122 01123 reference = os.path.normpath(os.path.expandvars(reffile)) 01124 # old-style platform-specific reference name 01125 spec_ref = reference[:-3] + self.GetPlatform()[0:3] + reference[-3:] 01126 if os.path.isfile(spec_ref): 01127 reference = spec_ref 01128 else: # look for new-style platform specific reference files: 01129 # get all the files whose name start with the reference filename 01130 dirname, basename = os.path.split(reference) 01131 if not dirname: dirname = '.' 01132 head = basename + "." 01133 head_len = len(head) 01134 platform = platformSplit(self.GetPlatform()) 01135 candidates = [] 01136 for f in os.listdir(dirname): 01137 if f.startswith(head): 01138 req_plat = platformSplit(f[head_len:]) 01139 if platform.issuperset(req_plat): 01140 candidates.append( (len(req_plat), f) ) 01141 if candidates: # take the one with highest matching 01142 # FIXME: it is not possible to say if x86_64-slc5-gcc43-dbg 01143 # has to use ref.x86_64-gcc43 or ref.slc5-dbg 01144 candidates.sort() 01145 reference = os.path.join(dirname, candidates[-1][1]) 01146 return reference
| def GaudiTest::GaudiExeTest::_find_program | ( | self, | |
| prog | |||
| ) | [private] |
Definition at line 1348 of file GaudiTest.py.
01349 : 01350 # check if it is an absolute path or the file can be found 01351 # from the local directory, otherwise search for it in PATH 01352 if not os.path.isabs(prog) and not os.path.isfile(prog): 01353 for d in os.environ["PATH"].split(os.pathsep): 01354 p = os.path.join(d,prog) 01355 if os.path.isfile(p): 01356 return p 01357 return prog
| def GaudiTest::GaudiExeTest::CheckHistosSummaries | ( | self, | |
| stdout, | |||
| result, | |||
| causes, | |||
dict = None, |
|||
ignore = None |
|||
| ) |
Compare the TTree summaries in stdout with the ones in trees_dict or in the reference file. By default ignore the size, compression and basket fields. The presence of TTree summaries when none is expected is not a failure.
Definition at line 1181 of file GaudiTest.py.
01184 : 01185 """ 01186 Compare the TTree summaries in stdout with the ones in trees_dict or in 01187 the reference file. By default ignore the size, compression and basket 01188 fields. 01189 The presence of TTree summaries when none is expected is not a failure. 01190 """ 01191 if dict is None: 01192 reference = self._expandReferenceFileName(self.reference) 01193 # call the validator if the file exists 01194 if reference and os.path.isfile(reference): 01195 dict = findHistosSummaries(open(reference).read()) 01196 else: 01197 dict = {} 01198 01199 from pprint import PrettyPrinter 01200 pp = PrettyPrinter() 01201 if dict: 01202 result["GaudiTest.Histos.expected"] = result.Quote(pp.pformat(dict)) 01203 if ignore: 01204 result["GaudiTest.Histos.ignore"] = result.Quote(ignore) 01205 01206 histos = findHistosSummaries(stdout) 01207 failed = cmpTreesDicts(dict, histos, ignore) 01208 if failed: 01209 causes.append("histos summaries") 01210 msg = "%s: %s != %s" % getCmpFailingValues(dict, histos, failed) 01211 result["GaudiTest.Histos.failure_on"] = result.Quote(msg) 01212 result["GaudiTest.Histos.found"] = result.Quote(pp.pformat(histos)) 01213 01214 return causes
| def GaudiTest::GaudiExeTest::CheckTTreesSummaries | ( | self, | |
| stdout, | |||
| result, | |||
| causes, | |||
trees_dict = None, |
|||
ignore = r"Basket|.*size|Compression" |
|||
| ) |
Compare the TTree summaries in stdout with the ones in trees_dict or in the reference file. By default ignore the size, compression and basket fields. The presence of TTree summaries when none is expected is not a failure.
Definition at line 1147 of file GaudiTest.py.
01150 : 01151 """ 01152 Compare the TTree summaries in stdout with the ones in trees_dict or in 01153 the reference file. By default ignore the size, compression and basket 01154 fields. 01155 The presence of TTree summaries when none is expected is not a failure. 01156 """ 01157 if trees_dict is None: 01158 reference = self._expandReferenceFileName(self.reference) 01159 # call the validator if the file exists 01160 if reference and os.path.isfile(reference): 01161 trees_dict = findTTreeSummaries(open(reference).read()) 01162 else: 01163 trees_dict = {} 01164 01165 from pprint import PrettyPrinter 01166 pp = PrettyPrinter() 01167 if trees_dict: 01168 result["GaudiTest.TTrees.expected"] = result.Quote(pp.pformat(trees_dict)) 01169 if ignore: 01170 result["GaudiTest.TTrees.ignore"] = result.Quote(ignore) 01171 01172 trees = findTTreeSummaries(stdout) 01173 failed = cmpTreesDicts(trees_dict, trees, ignore) 01174 if failed: 01175 causes.append("trees summaries") 01176 msg = "%s: %s != %s" % getCmpFailingValues(trees_dict, trees, failed) 01177 result["GaudiTest.TTrees.failure_on"] = result.Quote(msg) 01178 result["GaudiTest.TTrees.found"] = result.Quote(pp.pformat(trees)) 01179 01180 return causes
| def GaudiTest::GaudiExeTest::DumpEnvironment | ( | self, | |
| result | |||
| ) |
Add the content of the environment to the result object. Copied from the QMTest class of COOL.
Definition at line 1337 of file GaudiTest.py.
01338 : 01339 """ 01340 Add the content of the environment to the result object. 01341 01342 Copied from the QMTest class of COOL. 01343 """ 01344 vars = os.environ.keys() 01345 vars.sort() 01346 result['GaudiTest.environment'] = \ 01347 result.Quote('\n'.join(["%s=%s"%(v,os.environ[v]) for v in vars]))
| def GaudiTest::GaudiExeTest::GetPlatform | ( | self ) |
Return the platform Id defined in CMTCONFIG or SCRAM_ARCH.
Definition at line 1102 of file GaudiTest.py.
01103 : 01104 """ 01105 Return the platform Id defined in CMTCONFIG or SCRAM_ARCH. 01106 """ 01107 arch = "None" 01108 # check architecture name 01109 if "CMTCONFIG" in os.environ: 01110 arch = os.environ["CMTCONFIG"] 01111 elif "SCRAM_ARCH" in os.environ: 01112 arch = os.environ["SCRAM_ARCH"] 01113 return arch
| def GaudiTest::GaudiExeTest::PlatformIsNotSupported | ( | self, | |
| context, | |||
| result | |||
| ) |
Definition at line 1088 of file GaudiTest.py.
01089 : 01090 platform = self.GetPlatform() 01091 unsupported = [ re.compile(x) 01092 for x in [ str(y).strip() 01093 for y in self.unsupported_platforms ] 01094 if x 01095 ] 01096 for p_re in unsupported: 01097 if p_re.search(platform): 01098 result.SetOutcome(result.UNTESTED) 01099 result[result.CAUSE] = 'Platform not supported.' 01100 return True 01101 return False
| def GaudiTest::GaudiExeTest::Run | ( | self, | |
| context, | |||
| result | |||
| ) |
Run the test. 'context' -- A 'Context' giving run-time parameters to the test. 'result' -- A 'Result' object. The outcome will be 'Result.PASS' when this method is called. The 'result' may be modified by this method to indicate outcomes other than 'Result.PASS' or to add annotations.
Definition at line 1358 of file GaudiTest.py.
01359 : 01360 """Run the test. 01361 01362 'context' -- A 'Context' giving run-time parameters to the 01363 test. 01364 01365 'result' -- A 'Result' object. The outcome will be 01366 'Result.PASS' when this method is called. The 'result' may be 01367 modified by this method to indicate outcomes other than 01368 'Result.PASS' or to add annotations.""" 01369 01370 # Check if the platform is supported 01371 if self.PlatformIsNotSupported(context, result): 01372 return 01373 01374 # Prepare program name and arguments (expanding variables, and converting to absolute) 01375 if self.program: 01376 prog = rationalizepath(self.program) 01377 elif "GAUDIEXE" in os.environ: 01378 prog = os.environ["GAUDIEXE"] 01379 else: 01380 prog = "Gaudi.exe" 01381 self.program = prog 01382 01383 dummy, prog_ext = os.path.splitext(prog) 01384 if prog_ext not in [ ".exe", ".py", ".bat" ] and self.GetPlatform()[0:3] == "win": 01385 prog += ".exe" 01386 prog_ext = ".exe" 01387 01388 prog = self._find_program(prog) 01389 01390 # Convert paths to absolute paths in arguments and reference files 01391 args = map(rationalizepath, self.args) 01392 self.reference = rationalizepath(self.reference) 01393 self.error_reference = rationalizepath(self.error_reference) 01394 01395 01396 # check if the user provided inline options 01397 tmpfile = None 01398 if self.options.strip(): 01399 ext = ".opts" 01400 if re.search(r"from\s*Gaudi.Configuration\s*import\s*\*", self.options): 01401 ext = ".py" 01402 tmpfile = TempFile(ext) 01403 tmpfile.writelines("\n".join(self.options.splitlines())) 01404 tmpfile.flush() 01405 args.append(tmpfile.name) 01406 result["GaudiTest.options"] = result.Quote(self.options) 01407 01408 # if the program is a python file, execute it through python 01409 if prog_ext == ".py": 01410 args.insert(0,prog) 01411 if self.GetPlatform()[0:3] == "win": 01412 prog = self._find_program("python.exe") 01413 else: 01414 prog = self._find_program("python") 01415 01416 # Change to the working directory if specified or to the default temporary 01417 origdir = os.getcwd() 01418 if self.workdir: 01419 os.chdir(str(os.path.normpath(os.path.expandvars(self.workdir)))) 01420 elif self.use_temp_dir == "true": 01421 if "QMTEST_TMPDIR" in os.environ: 01422 os.chdir(os.environ["QMTEST_TMPDIR"]) 01423 elif "qmtest.tmpdir" in context: 01424 os.chdir(context["qmtest.tmpdir"]) 01425 01426 if "QMTEST_IGNORE_TIMEOUT" not in os.environ: 01427 self.timeout = max(self.timeout,600) 01428 else: 01429 self.timeout = -1 01430 01431 try: 01432 # Generate eclipse.org debug launcher for the test 01433 self._CreateEclipseLaunch(prog, args, destdir = origdir) 01434 # Run the test 01435 self.RunProgram(prog, 01436 [ prog ] + args, 01437 context, result) 01438 # Record the content of the enfironment for failing tests 01439 if result.GetOutcome() not in [ result.PASS ]: 01440 self.DumpEnvironment(result) 01441 finally: 01442 # revert to the original directory 01443 os.chdir(origdir)
| def GaudiTest::GaudiExeTest::RunProgram | ( | self, | |
| program, | |||
| arguments, | |||
| context, | |||
| result | |||
| ) |
Run the 'program'.
'program' -- The path to the program to run.
'arguments' -- A list of the arguments to the program. This
list must contain a first argument corresponding to 'argv[0]'.
'context' -- A 'Context' giving run-time parameters to the
test.
'result' -- A 'Result' object. The outcome will be
'Result.PASS' when this method is called. The 'result' may be
modified by this method to indicate outcomes other than
'Result.PASS' or to add annotations.
@attention: This method has been copied from command.ExecTestBase
(QMTest 2.3.0) and modified to keep stdout and stderr
for tests that have been terminated by a signal.
(Fundamental for debugging in the Application Area)
Definition at line 1444 of file GaudiTest.py.
01445 : 01446 """Run the 'program'. 01447 01448 'program' -- The path to the program to run. 01449 01450 'arguments' -- A list of the arguments to the program. This 01451 list must contain a first argument corresponding to 'argv[0]'. 01452 01453 'context' -- A 'Context' giving run-time parameters to the 01454 test. 01455 01456 'result' -- A 'Result' object. The outcome will be 01457 'Result.PASS' when this method is called. The 'result' may be 01458 modified by this method to indicate outcomes other than 01459 'Result.PASS' or to add annotations. 01460 01461 @attention: This method has been copied from command.ExecTestBase 01462 (QMTest 2.3.0) and modified to keep stdout and stderr 01463 for tests that have been terminated by a signal. 01464 (Fundamental for debugging in the Application Area) 01465 """ 01466 01467 # Construct the environment. 01468 environment = self.MakeEnvironment(context) 01469 # Create the executable. 01470 if self.timeout >= 0: 01471 timeout = self.timeout 01472 else: 01473 # If no timeout was specified, we sill run this process in a 01474 # separate process group and kill the entire process group 01475 # when the child is done executing. That means that 01476 # orphaned child processes created by the test will be 01477 # cleaned up. 01478 timeout = -2 01479 e = GaudiFilterExecutable(self.stdin, timeout) 01480 # Run it. 01481 exit_status = e.Run(arguments, environment, path = program) 01482 # Get the stack trace from the temporary file (if present) 01483 if e.stack_trace_file and os.path.exists(e.stack_trace_file): 01484 stack_trace = open(e.stack_trace_file).read() 01485 os.remove(e.stack_trace_file) 01486 else: 01487 stack_trace = None 01488 if stack_trace: 01489 result["ExecTest.stack_trace"] = result.Quote(stack_trace) 01490 01491 # If the process terminated normally, check the outputs. 01492 if sys.platform == "win32" or os.WIFEXITED(exit_status): 01493 # There are no causes of failure yet. 01494 causes = [] 01495 # The target program terminated normally. Extract the 01496 # exit code, if this test checks it. 01497 if self.exit_code is None: 01498 exit_code = None 01499 elif sys.platform == "win32": 01500 exit_code = exit_status 01501 else: 01502 exit_code = os.WEXITSTATUS(exit_status) 01503 # Get the output generated by the program. 01504 stdout = e.stdout 01505 stderr = e.stderr 01506 # Record the results. 01507 result["ExecTest.exit_code"] = str(exit_code) 01508 result["ExecTest.stdout"] = result.Quote(stdout) 01509 result["ExecTest.stderr"] = result.Quote(stderr) 01510 # Check to see if the exit code matches. 01511 if exit_code != self.exit_code: 01512 causes.append("exit_code") 01513 result["ExecTest.expected_exit_code"] \ 01514 = str(self.exit_code) 01515 # Validate the output. 01516 causes += self.ValidateOutput(stdout, stderr, result) 01517 # If anything went wrong, the test failed. 01518 if causes: 01519 result.Fail("Unexpected %s." % string.join(causes, ", ")) 01520 elif os.WIFSIGNALED(exit_status): 01521 # The target program terminated with a signal. Construe 01522 # that as a test failure. 01523 signal_number = str(os.WTERMSIG(exit_status)) 01524 if not stack_trace: 01525 result.Fail("Program terminated by signal.") 01526 else: 01527 # The presence of stack_trace means tha we stopped the job because 01528 # of a time-out 01529 result.Fail("Exceeded time limit (%ds), terminated." % timeout) 01530 result["ExecTest.signal_number"] = signal_number 01531 result["ExecTest.stdout"] = result.Quote(e.stdout) 01532 result["ExecTest.stderr"] = result.Quote(e.stderr) 01533 elif os.WIFSTOPPED(exit_status): 01534 # The target program was stopped. Construe that as a 01535 # test failure. 01536 signal_number = str(os.WSTOPSIG(exit_status)) 01537 if not stack_trace: 01538 result.Fail("Program stopped by signal.") 01539 else: 01540 # The presence of stack_trace means tha we stopped the job because 01541 # of a time-out 01542 result.Fail("Exceeded time limit (%ds), stopped." % timeout) 01543 result["ExecTest.signal_number"] = signal_number 01544 result["ExecTest.stdout"] = result.Quote(e.stdout) 01545 result["ExecTest.stderr"] = result.Quote(e.stderr) 01546 else: 01547 # The target program terminated abnormally in some other 01548 # manner. (This shouldn't normally happen...) 01549 result.Fail("Program did not terminate normally.") 01550 01551 # Marco Cl.: This is a special trick to fix a "problem" with the output 01552 # of gaudi jobs when they use colors 01553 esc = '\x1b' 01554 repr_esc = '\\x1b' 01555 result["ExecTest.stdout"] = result["ExecTest.stdout"].replace(esc,repr_esc) 01556 # TODO: (MCl) improve the hack for colors in standard output 01557 # may be converting them to HTML tags
| def GaudiTest::GaudiExeTest::ValidateOutput | ( | self, | |
| stdout, | |||
| stderr, | |||
| result | |||
| ) |
Definition at line 1272 of file GaudiTest.py.
01273 : 01274 causes = [] 01275 # if the test definition contains a custom validator, use it 01276 if self.validator.strip() != "": 01277 class CallWrapper(object): 01278 """ 01279 Small wrapper class to dynamically bind some default arguments 01280 to a callable. 01281 """ 01282 def __init__(self, callable, extra_args = {}): 01283 self.callable = callable 01284 self.extra_args = extra_args 01285 # get the list of names of positional arguments 01286 from inspect import getargspec 01287 self.args_order = getargspec(callable)[0] 01288 # Remove "self" from the list of positional arguments 01289 # since it is added automatically 01290 if self.args_order[0] == "self": 01291 del self.args_order[0] 01292 def __call__(self, *args, **kwargs): 01293 # Check which positional arguments are used 01294 positional = self.args_order[:len(args)] 01295 01296 kwargs = dict(kwargs) # copy the arguments dictionary 01297 for a in self.extra_args: 01298 # use "extra_args" for the arguments not specified as 01299 # positional or keyword 01300 if a not in positional and a not in kwargs: 01301 kwargs[a] = self.extra_args[a] 01302 return apply(self.callable, args, kwargs) 01303 # local names to be exposed in the script 01304 exported_symbols = {"self":self, 01305 "stdout":stdout, 01306 "stderr":stderr, 01307 "result":result, 01308 "causes":causes, 01309 "findReferenceBlock": 01310 CallWrapper(findReferenceBlock, {"stdout":stdout, 01311 "result":result, 01312 "causes":causes}), 01313 "validateWithReference": 01314 CallWrapper(self.ValidateWithReference, {"stdout":stdout, 01315 "stderr":stderr, 01316 "result":result, 01317 "causes":causes}), 01318 "countErrorLines": 01319 CallWrapper(countErrorLines, {"stdout":stdout, 01320 "result":result, 01321 "causes":causes}), 01322 "checkTTreesSummaries": 01323 CallWrapper(self.CheckTTreesSummaries, {"stdout":stdout, 01324 "result":result, 01325 "causes":causes}), 01326 "checkHistosSummaries": 01327 CallWrapper(self.CheckHistosSummaries, {"stdout":stdout, 01328 "result":result, 01329 "causes":causes}), 01330 01331 } 01332 exec self.validator in globals(), exported_symbols 01333 else: 01334 self.ValidateWithReference(stdout, stderr, result, causes) 01335 01336 return causes
| def GaudiTest::GaudiExeTest::ValidateWithReference | ( | self, | |
| stdout, | |||
| stderr, | |||
| result, | |||
| causes, | |||
preproc = None |
|||
| ) |
Default validation action: compare standard output and error to the reference files.
Definition at line 1215 of file GaudiTest.py.
01216 : 01217 """ 01218 Default validation action: compare standard output and error to the 01219 reference files. 01220 """ 01221 # set the default output preprocessor 01222 if preproc is None: 01223 preproc = normalizeExamples 01224 # check standard output 01225 reference = self._expandReferenceFileName(self.reference) 01226 # call the validator if the file exists 01227 if reference and os.path.isfile(reference): 01228 result["GaudiTest.output_reference"] = reference 01229 causes += ReferenceFileValidator(reference, 01230 "standard output", 01231 "GaudiTest.output_diff", 01232 preproc = preproc)(stdout, result) 01233 01234 # Compare TTree summaries 01235 causes = self.CheckTTreesSummaries(stdout, result, causes) 01236 causes = self.CheckHistosSummaries(stdout, result, causes) 01237 01238 if causes: # Write a new reference file for stdout 01239 try: 01240 newref = open(reference + ".new","w") 01241 # sanitize newlines 01242 for l in stdout.splitlines(): 01243 newref.write(l.rstrip() + '\n') 01244 del newref # flush and close 01245 except IOError: 01246 # Ignore IO errors when trying to update reference files 01247 # because we may be in a read-only filesystem 01248 pass 01249 01250 # check standard error 01251 reference = self._expandReferenceFileName(self.error_reference) 01252 # call the validator if we have a file to use 01253 if reference and os.path.isfile(reference): 01254 result["GaudiTest.error_reference"] = reference 01255 newcauses = ReferenceFileValidator(reference, 01256 "standard error", 01257 "GaudiTest.error_diff", 01258 preproc = preproc)(stderr, result) 01259 causes += newcauses 01260 if newcauses: # Write a new reference file for stdedd 01261 newref = open(reference + ".new","w") 01262 # sanitize newlines 01263 for l in stderr.splitlines(): 01264 newref.write(l.rstrip() + '\n') 01265 del newref # flush and close 01266 else: 01267 causes += BasicOutputValidator(self.stderr, 01268 "standard error", 01269 "ExecTest.expected_stderr")(stderr, result) 01270 01271 return causes
Definition at line 1275 of file GaudiTest.py.
list GaudiTest::GaudiExeTest::arguments [static] |
Definition at line 974 of file GaudiTest.py.
Definition at line 1275 of file GaudiTest.py.
Definition at line 1366 of file GaudiTest.py.
Definition at line 1275 of file GaudiTest.py.
Definition at line 1366 of file GaudiTest.py.
Definition at line 1366 of file GaudiTest.py.
Definition at line 1366 of file GaudiTest.py.
Definition at line 1366 of file GaudiTest.py.