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