| # Gaudi Framework, version v21r9 |

Home |  | Generated: 3 May 2010

# GaudiTest::GaudiExeTest Class Reference

Inheritance diagram for GaudiTest::GaudiExeTest:

[legend]
Collaboration diagram for GaudiTest::GaudiExeTest:

[legend]

List of all members.

## 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

## Detailed Description

    Standard Gaudi test.

Definition at line 971 of file GaudiTest.py.

## Member Function Documentation

def GaudiTest::GaudiExeTest::PlatformIsNotSupported | ( |  | self,
|  |  | context,
|  |  | result |
| ) |  |  |

Definition at line 1088 of file GaudiTest.py.

    01088                                                      :
    01089         platform = self.GetPlatform()
    01090         unsupported = [ re.compile(x)
    01091                         for x in [ str(y).strip()
    01092                                    for y in self.unsupported_platforms ]
    01093                         if x
    01094                        ]
    01095         for p_re in unsupported:
    01096             if p_re.search(platform):
    01097                 result.SetOutcome(result.UNTESTED)
    01098                 result[result.CAUSE] = 'Platform not supported.'
    01099                 return True
    01100         return False
    01101
        def GetPlatform(self):

def GaudiTest::GaudiExeTest::GetPlatform | ( |  | self | ) |

    Return the platform Id defined in CMTCONFIG or SCRAM_ARCH.

Definition at line 1102 of file GaudiTest.py.

    01102                          :
    01103         """
    01104         Return the platform Id defined in CMTCONFIG or SCRAM_ARCH.
    01105         """
    01106         arch = "None"
    01107         # check architecture name
    01108         if "CMTCONFIG" in os.environ:
    01109             arch = os.environ["CMTCONFIG"]
    01110         elif "SCRAM_ARCH" in os.environ:
    01111             arch = os.environ["SCRAM_ARCH"]
    01112         return arch
    01113
        def _expandReferenceFileName(self, reffile):

def GaudiTest::GaudiExeTest::_expandReferenceFileName | ( |  | self,
|  |  | reffile |
| ) |  |  | `[private]`

Definition at line 1114 of file GaudiTest.py.

    01114                                                :
    01115         # if no file is passed, do nothing
    01116         if not reffile:
    01117             return ""
    01118
    01119         reference = os.path.normpath(os.path.expandvars(reffile))
    01120         # old-style platform-specific reference name
    01121         spec_ref = reference[:-3] + self.GetPlatform()[0:3] + reference[-3:]
    01122         if os.path.isfile(spec_ref):
    01123             reference = spec_ref
    01124         else: # look for new-style platform specific reference files:
    01125             # get all the files whose name start with the reference filename
    01126             dirname, basename = os.path.split(reference)
    01127             if not dirname: dirname = '.'
    01128             head = basename + "."
    01129             head_len = len(head)
    01130             platform = self.GetPlatform()
    01131             candidates = []
    01132             for f in os.listdir(dirname):
    01133                 if f.startswith(head) and platform.startswith(f[head_len:]):
    01134                     candidates.append( (len(f) - head_len, f) )
    01135             if candidates: # take the one with highest matching
    01136                 candidates.sort()
    01137                 reference = os.path.join(dirname, candidates[-1][1])
    01138         return reference
    01139
        def CheckTTreesSummaries(self, stdout, result, 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.

    01142                                                                    :
    01143         """
    01144         Compare the TTree summaries in stdout with the ones in trees_dict or in
    01145         the reference file. By default ignore the size, compression and basket
    01146         fields.
    01147         The presence of TTree summaries when none is expected is not a failure.
    01148         """
    01149         if trees_dict is None:
    01150             reference = self._expandReferenceFileName(self.reference)
    01151             # call the validator if the file exists
    01152             if reference and os.path.isfile(reference):
    01153                 trees_dict = findTTreeSummaries(open(reference).read())
    01154             else:
    01155                 trees_dict = {}
    01156
    01157         from pprint import PrettyPrinter
    01158         pp = PrettyPrinter()
    01159         if trees_dict:
    01160             result["GaudiTest.TTrees.expected"] = result.Quote(pp.pformat(trees_dict))
    01161             if ignore:
    01162                 result["GaudiTest.TTrees.ignore"] = result.Quote(ignore)
    01163
    01164         trees = findTTreeSummaries(stdout)
    01165         failed = cmpTreesDicts(trees_dict, trees, ignore)
    01166         if failed:
    01167             causes.append("trees summaries")
    01168             msg = "%s: %s != %s" % getCmpFailingValues(trees_dict, trees, failed)
    01169             result["GaudiTest.TTrees.failure_on"] = result.Quote(msg)
    01170             result["GaudiTest.TTrees.found"] = result.Quote(pp.pformat(trees))
    01171
    01172         return causes
    01173
        def CheckHistosSummaries(self, stdout, result, causes,

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.

    01176                                            :
    01177         """
    01178         Compare the TTree summaries in stdout with the ones in trees_dict or in
    01179         the reference file. By default ignore the size, compression and basket
    01180         fields.
    01181         The presence of TTree summaries when none is expected is not a failure.
    01182         """
    01183         if dict is None:
    01184             reference = self._expandReferenceFileName(self.reference)
    01185             # call the validator if the file exists
    01186             if reference and os.path.isfile(reference):
    01187                 dict = findHistosSummaries(open(reference).read())
    01188             else:
    01189                 dict = {}
    01190
    01191         from pprint import PrettyPrinter
    01192         pp = PrettyPrinter()
    01193         if dict:
    01194             result["GaudiTest.Histos.expected"] = result.Quote(pp.pformat(dict))
    01195             if ignore:
    01196                 result["GaudiTest.Histos.ignore"] = result.Quote(ignore)
    01197
    01198         histos = findHistosSummaries(stdout)
    01199         failed = cmpTreesDicts(dict, histos, ignore)
    01200         if failed:
    01201             causes.append("histos summaries")
    01202             msg = "%s: %s != %s" % getCmpFailingValues(dict, histos, failed)
    01203             result["GaudiTest.Histos.failure_on"] = result.Quote(msg)
    01204             result["GaudiTest.Histos.found"] = result.Quote(pp.pformat(histos))
    01205
    01206         return causes
    01207
        def ValidateWithReference(self, stdout, stderr, result, causes, preproc = None):

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.

    01208                                                                                    :
    01209         """
    01210         Default validation action: compare standard output and error to the
    01211         reference files.
    01212         """
    01213         # set the default output preprocessor
    01214         if preproc is None:
    01215             preproc = normalizeExamples
    01216         # check standard output
    01217         reference = self._expandReferenceFileName(self.reference)
    01218         # call the validator if the file exists
    01219         if reference and os.path.isfile(reference):
    01220             result["GaudiTest.output_reference"] = reference
    01221             causes += ReferenceFileValidator(reference,
    01222                                              "standard output",
    01223                                              "GaudiTest.output_diff",
    01224                                              preproc = preproc)(stdout, result)
    01225
    01226         # Compare TTree summaries
    01227         causes = self.CheckTTreesSummaries(stdout, result, causes)
    01228         causes = self.CheckHistosSummaries(stdout, result, causes)
    01229
    01230         if causes: # Write a new reference file for stdout
    01231             try:
    01232                 newref = open(reference + ".new","w")
    01233                 # sanitize newlines
    01234                 for l in stdout.splitlines():
    01235                     newref.write(l.rstrip() + '\n')
    01236                 del newref # flush and close
    01237             except IOError:
    01238                 # Ignore IO errors when trying to update reference files
    01239                 # because we may be in a read-only filesystem
    01240                 pass
    01241
    01242         # check standard error
    01243         reference = self._expandReferenceFileName(self.error_reference)
    01244         # call the validator if we have a file to use
    01245         if reference and os.path.isfile(reference):
    01246             result["GaudiTest.error_reference"] = reference
    01247             newcauses = ReferenceFileValidator(reference,
    01248                                                "standard error",
    01249                                                "GaudiTest.error_diff",
    01250                                                preproc = preproc)(stderr, result)
    01251             causes += newcauses
    01252             if newcauses: # Write a new reference file for stdedd
    01253                 newref = open(reference + ".new","w")
    01254                 # sanitize newlines
    01255                 for l in stderr.splitlines():
    01256                     newref.write(l.rstrip() + '\n')
    01257                 del newref # flush and close
    01258         else:
    01259             causes += BasicOutputValidator(self.stderr,
    01260                                            "standard error",
    01261                                            "ExecTest.expected_stderr")(stderr, result)
    01262
    01263         return causes
    01264
        def ValidateOutput(self, stdout, stderr, result):

def GaudiTest::GaudiExeTest::ValidateOutput | ( |  | self,
|  |  | stdout,
|  |  | stderr,
|  |  | result |
| ) |  |  |

Definition at line 1265 of file GaudiTest.py.

    01265                                                     :
    01266         causes = []
    01267         # if the test definition contains a custom validator, use it
    01268         if self.validator.strip() != "":
    01269             class CallWrapper(object):
    01270                 """
    01271                 Small wrapper class to dynamically bind some default arguments
    01272                 to a callable.
    01273                 """
    01274                 def __init__(self, callable, extra_args = {}):
    01275                     self.callable = callable
    01276                     self.extra_args = extra_args
    01277                     # get the list of names of positional arguments
    01278                     from inspect import getargspec
    01279                     self.args_order = getargspec(callable)[0]
    01280                     # Remove "self" from the list of positional arguments
    01281                     # since it is added automatically
    01282                     if self.args_order[0] == "self":
    01283                         del self.args_order[0]
    01284                 def __call__(self, *args, **kwargs):
    01285                     # Check which positional arguments are used
    01286                     positional = self.args_order[:len(args)]
    01287
    01288                     kwargs = dict(kwargs) # copy the arguments dictionary
    01289                     for a in self.extra_args:
    01290                         # use "extra_args" for the arguments not specified as
    01291                         # positional or keyword
    01292                         if a not in positional and a not in kwargs:
    01293                             kwargs[a] = self.extra_args[a]
    01294                     return apply(self.callable, args, kwargs)
    01295             # local names to be exposed in the script
    01296             exported_symbols = {"self":self,
    01297                                 "stdout":stdout,
    01298                                 "stderr":stderr,
    01299                                 "result":result,
    01300                                 "causes":causes,
    01301                                 "findReferenceBlock":
    01302                                     CallWrapper(findReferenceBlock, {"stdout":stdout,
    01303                                                                      "result":result,
    01304                                                                      "causes":causes}),
    01305                                 "validateWithReference":
    01306                                     CallWrapper(self.ValidateWithReference, {"stdout":stdout,
    01307                                                                              "stderr":stderr,
    01308                                                                              "result":result,
    01309                                                                              "causes":causes}),
    01310                                 "countErrorLines":
    01311                                     CallWrapper(countErrorLines, {"stdout":stdout,
    01312                                                                   "result":result,
    01313                                                                   "causes":causes}),
    01314                                 "checkTTreesSummaries":
    01315                                     CallWrapper(self.CheckTTreesSummaries, {"stdout":stdout,
    01316                                                                             "result":result,
    01317                                                                             "causes":causes}),
    01318                                 "checkHistosSummaries":
    01319                                     CallWrapper(self.CheckHistosSummaries, {"stdout":stdout,
    01320                                                                             "result":result,
    01321                                                                             "causes":causes}),
    01322
    01323                                 }
    01324             exec self.validator in globals(), exported_symbols
    01325         else:
    01326             self.ValidateWithReference(stdout, stderr, result, causes)
    01327
    01328         return causes
    01329
        def DumpEnvironment(self, result):

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.

    01330                                      :
    01331         """
    01332         Add the content of the environment to the result object.
    01333
    01334         Copied from the QMTest class of COOL.
    01335         """
    01336         vars = os.environ.keys()
    01337         vars.sort()
    01338         result['GaudiTest.environment'] = \
    01339             result.Quote('\n'.join(["%s=%s"%(v,os.environ[v]) for v in vars]))
    01340
        def _find_program(self,prog):

def GaudiTest::GaudiExeTest::_find_program | ( |  | self,
|  |  | prog |
| ) |  |  | `[private]`

Definition at line 1341 of file GaudiTest.py.

    01341                                 :
    01342         # check if it is an absolute path or the file can be found
    01343         # from the local directory, otherwise search for it in PATH
    01344         if not os.path.isabs(prog) and not os.path.isfile(prog):
    01345             for d in os.environ["PATH"].split(os.pathsep):
    01346                 p = os.path.join(d,prog)
    01347                 if os.path.isfile(p):
    01348                     return p
    01349         return prog
    01350
        def Run(self, context, result):

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.

    01351                                   :
    01352         """Run the test.
    01353
    01354         'context' -- A 'Context' giving run-time parameters to the
    01355         test.
    01356
    01357         'result' -- A 'Result' object.  The outcome will be
    01358         'Result.PASS' when this method is called.  The 'result' may be
    01359         modified by this method to indicate outcomes other than
    01360         'Result.PASS' or to add annotations."""
    01361
    01362         # Check if the platform is supported
    01363         if self.PlatformIsNotSupported(context, result):
    01364             return
    01365
    01366         # Prepare program name and arguments (expanding variables, and converting to absolute)
    01367         if self.program:
    01368             prog = rationalizepath(self.program)
    01369         elif "GAUDIEXE" in os.environ:
    01370             prog = os.environ["GAUDIEXE"]
    01371         else:
    01372             prog = "Gaudi.exe"
    01373         self.program = prog
    01374
    01375         dummy, prog_ext = os.path.splitext(prog)
    01376         if prog_ext not in [ ".exe", ".py", ".bat" ] and self.GetPlatform()[0:3] == "win":
    01377             prog += ".exe"
    01378             prog_ext = ".exe"
    01379
    01380         prog = self._find_program(prog)
    01381
    01382         # Convert paths to absolute paths in arguments and reference files
    01383         args = map(rationalizepath, self.args)
    01384         self.reference = rationalizepath(self.reference)
    01385         self.error_reference = rationalizepath(self.error_reference)
    01386
    01387
    01388         # check if the user provided inline options
    01389         tmpfile = None
    01390         if self.options.strip():
    01391             ext = ".opts"
    01392             if re.search(r"from\s*Gaudi.Configuration\s*import\s*\*", self.options):
    01393                 ext = ".py"
    01394             tmpfile = TempFile(ext)
    01395             tmpfile.writelines("\n".join(self.options.splitlines()))
    01396             tmpfile.flush()
    01397             args.append(tmpfile.name)
    01398             result["GaudiTest.options"] = result.Quote(self.options)
    01399
    01400         # if the program is a python file, execute it through python
    01401         if prog_ext == ".py":
    01402             args.insert(0,prog)
    01403             if self.GetPlatform()[0:3] == "win":
    01404                 prog = self._find_program("python.exe")
    01405             else:
    01406                 prog = self._find_program("python")
    01407
    01408         # Change to the working directory if specified or to the default temporary
    01409         origdir = os.getcwd()
    01410         if self.workdir:
    01411             os.chdir(str(os.path.normpath(os.path.expandvars(self.workdir))))
    01412         elif self.use_temp_dir == "true":
    01413             if "QMTEST_TMPDIR" in os.environ:
    01414                 os.chdir(os.environ["QMTEST_TMPDIR"])
    01415             elif "qmtest.tmpdir" in context:
    01416                 os.chdir(context["qmtest.tmpdir"])
    01417
    01418         if "QMTEST_IGNORE_TIMEOUT" not in os.environ:
    01419             self.timeout = max(self.timeout,600)
    01420         else:
    01421             self.timeout = -1
    01422
    01423         try:
    01424             # Generate eclipse.org debug launcher for the test
    01425             self._CreateEclipseLaunch(prog, args, destdir = origdir)
    01426             # Run the test
    01427             self.RunProgram(prog,
    01428                             [ prog ] + args,
    01429                             context, result)
    01430             # Record the content of the enfironment for failing tests
    01431             if result.GetOutcome() not in [ result.PASS ]:
    01432                 self.DumpEnvironment(result)
    01433         finally:
    01434             # revert to the original directory
    01435             os.chdir(origdir)
    01436
        def RunProgram(self, program, arguments, context, result):

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.

    01437                                                              :
    01438         """Run the 'program'.
    01439
    01440         'program' -- The path to the program to run.
    01441
    01442         'arguments' -- A list of the arguments to the program.  This
    01443         list must contain a first argument corresponding to 'argv[0]'.
    01444
    01445         'context' -- A 'Context' giving run-time parameters to the
    01446         test.
    01447
    01448         'result' -- A 'Result' object.  The outcome will be
    01449         'Result.PASS' when this method is called.  The 'result' may be
    01450         modified by this method to indicate outcomes other than
    01451         'Result.PASS' or to add annotations.
    01452
    01453         @attention: This method has been copied from command.ExecTestBase
    01454                     (QMTest 2.3.0) and modified to keep stdout and stderr
    01455                     for tests that have been terminated by a signal.
    01456                     (Fundamental for debugging in the Application Area)
    01457         """
    01458
    01459         # Construct the environment.
    01460         environment = self.MakeEnvironment(context)
    01461         # Create the executable.
    01462         if self.timeout >= 0:
    01463             timeout = self.timeout
    01464         else:
    01465             # If no timeout was specified, we sill run this process in a
    01466             # separate process group and kill the entire process group
    01467             # when the child is done executing.  That means that
    01468             # orphaned child processes created by the test will be
    01469             # cleaned up.
    01470             timeout = -2
    01471         e = GaudiFilterExecutable(self.stdin, timeout)
    01472         # Run it.
    01473         exit_status = e.Run(arguments, environment, path = program)
    01474         # Get the stack trace from the temporary file (if present)
    01475         if e.stack_trace_file and os.path.exists(e.stack_trace_file):
    01476             stack_trace = open(e.stack_trace_file).read()
    01477             os.remove(e.stack_trace_file)
    01478         else:
    01479             stack_trace = None
    01480         if stack_trace:
    01481             result["ExecTest.stack_trace"] = result.Quote(stack_trace)
    01482
    01483         # If the process terminated normally, check the outputs.
    01484         if sys.platform == "win32" or os.WIFEXITED(exit_status):
    01485             # There are no causes of failure yet.
    01486             causes = []
    01487             # The target program terminated normally.  Extract the
    01488             # exit code, if this test checks it.
    01489             if self.exit_code is None:
    01490                 exit_code = None
    01491             elif sys.platform == "win32":
    01492                 exit_code = exit_status
    01493             else:
    01494                 exit_code = os.WEXITSTATUS(exit_status)
    01495             # Get the output generated by the program.
    01496             stdout = e.stdout
    01497             stderr = e.stderr
    01498             # Record the results.
    01499             result["ExecTest.exit_code"] = str(exit_code)
    01500             result["ExecTest.stdout"] = result.Quote(stdout)
    01501             result["ExecTest.stderr"] = result.Quote(stderr)
    01502             # Check to see if the exit code matches.
    01503             if exit_code != self.exit_code:
    01504                 causes.append("exit_code")
    01505                 result["ExecTest.expected_exit_code"] \
    01506                     = str(self.exit_code)
    01507             # Validate the output.
    01508             causes += self.ValidateOutput(stdout, stderr, result)
    01509             # If anything went wrong, the test failed.
    01510             if causes:
    01511                 result.Fail("Unexpected %s." % string.join(causes, ", "))
    01512         elif os.WIFSIGNALED(exit_status):
    01513             # The target program terminated with a signal.  Construe
    01514             # that as a test failure.
    01515             signal_number = str(os.WTERMSIG(exit_status))
    01516             if not stack_trace:
    01517                 result.Fail("Program terminated by signal.")
    01518             else:
    01519                 # The presence of stack_trace means tha we stopped the job because
    01520                 # of a time-out
    01521                 result.Fail("Exceeded time limit (%ds), terminated." % timeout)
    01522             result["ExecTest.signal_number"] = signal_number
    01523             result["ExecTest.stdout"] = result.Quote(e.stdout)
    01524             result["ExecTest.stderr"] = result.Quote(e.stderr)
    01525         elif os.WIFSTOPPED(exit_status):
    01526             # The target program was stopped.  Construe that as a
    01527             # test failure.
    01528             signal_number = str(os.WSTOPSIG(exit_status))
    01529             if not stack_trace:
    01530                 result.Fail("Program stopped by signal.")
    01531             else:
    01532                 # The presence of stack_trace means tha we stopped the job because
    01533                 # of a time-out
    01534                 result.Fail("Exceeded time limit (%ds), stopped." % timeout)
    01535             result["ExecTest.signal_number"] = signal_number
    01536             result["ExecTest.stdout"] = result.Quote(e.stdout)
    01537             result["ExecTest.stderr"] = result.Quote(e.stderr)
    01538         else:
    01539             # The target program terminated abnormally in some other
    01540             # manner.  (This shouldn't normally happen...)
    01541             result.Fail("Program did not terminate normally.")
    01542
    01543         # Marco Cl.: This is a special trick to fix a "problem" with the output
    01544         # of gaudi jobs when they use colors
    01545         esc = '\x1b'
    01546         repr_esc = '\\x1b'
    01547         result["ExecTest.stdout"] = result["ExecTest.stdout"].replace(esc,repr_esc)
    01548         # TODO: (MCl) improve the hack for colors in standard output
    01549         #             may be converting them to HTML tags
    01550
        def _CreateEclipseLaunch(self, prog, args, destdir = None):

def GaudiTest::GaudiExeTest::_CreateEclipseLaunch | ( |  | self,
|  |  | prog,
|  |  | args,
|  |  | destdir = `None` |
| ) |  |  | `[private]`

Definition at line 1551 of file GaudiTest.py.

    01551                                                               :
    01552         # Find the project name used in ecplise.
    01553         # The name is in a file called ".project" in one of the parent directories
    01554         projbasedir = os.path.normpath(destdir)
    01555         while not os.path.exists(os.path.join(projbasedir, ".project")):
    01556             oldprojdir = projbasedir
    01557             projbasedir = os.path.normpath(os.path.join(projbasedir, os.pardir))
    01558             # FIXME: the root level is invariant when trying to go up one level,
    01559             #        but it must be cheched on windows
    01560             if oldprojdir == projbasedir:
    01561                 # If we cannot find a .project, so no point in creating a .launch file
    01562                 return
    01563         # Use ElementTree to parse the XML file
    01564         from xml.etree import ElementTree as ET
    01565         t = ET.parse(os.path.join(projbasedir, ".project"))
    01566         projectName = t.find("name").text
    01567
    01568         # prepare the name/path of the generated file
    01569         destfile = "%s.launch" % self._Runnable__id
    01570         if destdir:
    01571             destfile = os.path.join(destdir, destfile)
    01572
    01573         if self.options.strip():
    01574             # this means we have some custom options in the qmt file, so we have
    01575             # to copy them from the temporary file at the end of the arguments
    01576             # in another file
    01577             tempfile = args.pop()
    01578             optsfile = destfile + os.path.splitext(tempfile)[1]
    01579             shutil.copyfile(tempfile, optsfile)
    01580             args.append(optsfile)
    01581
    01582         # prepare the data to insert in the XML file
    01583         from xml.sax.saxutils import quoteattr # useful to quote XML special chars
    01584         data = {}
    01585         # Note: the "quoteattr(k)" is not needed because special chars cannot be part of a variable name,
    01586         # but it doesn't harm.
    01587         data["environment"] = "\n".join(['<mapEntry key=%s value=%s/>' % (quoteattr(k), quoteattr(v))
    01588                                          for k, v in os.environ.iteritems()])
    01589
    01590         data["exec"] = which(prog)
    01591
    01592         data["args"] = "&#10;".join(map(rationalizepath, args))
    01593
    01594         if not self.use_temp_dir:
    01595             data["workdir"] = os.getcwd()
    01596         else:
    01597             # If the test is using a tmporary directory, it is better to run it
    01598             # in the same directory as the .launch file when debugged in eclipse
    01599             data["workdir"] = destdir
    01600
    01601         data["project"] = projectName.strip()
    01602
    01603         # Template for the XML file, based on eclipse 3.4
    01604         xml = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
    01605 <launchConfiguration type="org.eclipse.cdt.launch.applicationLaunchType">
    01606 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.AUTO_SOLIB" value="true"/>
    01607 <listAttribute key="org.eclipse.cdt.debug.mi.core.AUTO_SOLIB_LIST"/>
    01608 <stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="gdb"/>
    01609 <stringAttribute key="org.eclipse.cdt.debug.mi.core.GDB_INIT" value=".gdbinit"/>
    01610 <listAttribute key="org.eclipse.cdt.debug.mi.core.SOLIB_PATH"/>
    01611 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.STOP_ON_SOLIB_EVENTS" value="false"/>
    01612 <stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/>
    01613 <stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
    01614 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_ID" value="org.eclipse.cdt.debug.mi.core.CDebugger"/>
    01615 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
    01616 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="run"/>
    01617 <booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
    01618 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
    01619 <booleanAttribute key="org.eclipse.cdt.launch.ENABLE_REGISTER_BOOKKEEPING" value="false"/>
    01620 <booleanAttribute key="org.eclipse.cdt.launch.ENABLE_VARIABLE_BOOKKEEPING" value="false"/>
    01621 <stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList/&gt;"/>
    01622 <stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;globalVariableList/&gt;&#10;"/>
    01623 <stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;memoryBlockExpressionList/&gt;&#10;"/>
    01624 <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_ARGUMENTS" value="%(args)s"/>
    01625 <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="%(exec)s"/>
    01626 <stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="%(project)s"/>
    01627 <stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
    01628 <stringAttribute key="org.eclipse.cdt.launch.WORKING_DIRECTORY" value="%(workdir)s"/>
    01629 <booleanAttribute key="org.eclipse.cdt.launch.use_terminal" value="true"/>
    01630 <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
    01631 <listEntry value="/%(project)s"/>
    01632 </listAttribute>
    01633 <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
    01634 <listEntry value="4"/>
    01635 </listAttribute>
    01636 <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="false"/>
    01637 <mapAttribute key="org.eclipse.debug.core.environmentVariables">
    01638 %(environment)s
    01639 </mapAttribute>
    01640 <mapAttribute key="org.eclipse.debug.core.preferred_launchers">
    01641 <mapEntry key="[debug]" value="org.eclipse.cdt.cdi.launch.localCLaunch"/>
    01642 </mapAttribute>
    01643 <listAttribute key="org.eclipse.debug.ui.favoriteGroups">
    01644 <listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
    01645 </listAttribute>
    01646 </launchConfiguration>
    01647 """ % data
    01648
    01649         # Write the output file
    01650         open(destfile, "w").write(xml)
    01651         #open(destfile + "_copy.xml", "w").write(xml)
    01652
    01653
    01654 try:
        import json

## Member Data Documentation

list GaudiTest::GaudiExeTest::arguments`[static]`

Definition at line 974 of file GaudiTest.py.

GaudiTest::GaudiExeTest::callable

Definition at line 1275 of file GaudiTest.py.

GaudiTest::GaudiExeTest::extra_args

Definition at line 1276 of file GaudiTest.py.

GaudiTest::GaudiExeTest::args_order

Definition at line 1279 of file GaudiTest.py.

GaudiTest::GaudiExeTest::program

Definition at line 1373 of file GaudiTest.py.

GaudiTest::GaudiExeTest::reference

Definition at line 1384 of file GaudiTest.py.

GaudiTest::GaudiExeTest::error_reference

Definition at line 1385 of file GaudiTest.py.

GaudiTest::GaudiExeTest::use_temp_dir

Definition at line 1412 of file GaudiTest.py.

GaudiTest::GaudiExeTest::timeout

Definition at line 1419 of file GaudiTest.py.

The documentation for this class was generated from the following file:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r9/GaudiPolicy/qmtest_classes/GaudiTest.py