Running and testing

Run examples and tests

  • "Learn about running examples."
  • "Learn about running tests."

One of the most important components of writing code is testing. The following section will show you how to run examples in tests in Gaudi; this is also mostly compatible with the packages that are built on top of Gaudi, such as DaVinci and Gauss.

Running an example

The Gaudi examples are available in Gaudi/GaudiExamples. On lxplus, you can grab them and build with a partial checkout:

local:~ $ lb-dev Gaudi v28r1
local:~ $ cd GaudiDev_v28r1
local:GaudiDev_v28r1 $ git lb-use Gaudi
local:GaudiDev_v28r1 $ git lb-checkout Gaudi/v28r1 GaudiExamples
local:GaudiDev_v28r1 $ make

Now, you have Gaudi and just the GaudiExamples subdirectory (project). This is a good place to start looking around to see how Gaudi works; for now we'll try running an example.

local:GaudiDev_v28r1 $ ./run gaudirun.py GaudiExamples/options/AlgSequencer.py

This will run a a few algorithms in sequence, and will output info messages for ten "events" (no data).

Testing

Searching the sourceClick to expand

There are two methods to write tests:

QMT tests

For an old-style QMT test, you add a QMT file in tests/qmtest/gaudiexamples.qms/ that looks like testname.qmt. The file contains xml:

 <?xml version="1.0" ?><!DOCTYPE extension  PUBLIC '-//QM/2.3/Extension//EN'  'http://www. codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'>
 <extension class="GaudiTest.GaudiExeTest" kind="test">
   <argument name="program"><text>gaudirun.py</text></argument>
   <argument name="args"><set><text>$GAUDIEXAMPLESROOT/options/AlgSequencer.py</text></    set></argument>
   <argument name="use_temp_dir"><enumeral>true</enumeral></argument>
   <argument name="reference"><text>refs/AlgSequencer_pyopts.ref</text></argument>
 </extension>

This contains a few important points. The AlgSequencer.ref is a copy of the output that will be used to check the result. It is at tests/refs/AlgSequencer_pyopts.ref. The compare is smart enough to mask out numbers like time and date for you. The opts file to run is also here.

Python tests

Another way to create a test is through a python system; a matching example is at tests/qmtest/newFormat/algsequencer_pyopts_test.py. The contents:

# -*- coding: utf-8 -*-
import BaseTest
from BaseTest import *

class Test(BaseTest):

    def __init__(self):
        BaseTest.__init__(self)
        self.name = os.path.basename(__file__)[:-5]
        self.program="gaudirun.py"
        self.args=["$GAUDIEXAMPLESROOT/options/AlgSequencer.py"]
        self.reference = "refs/AlgSequencer_pyopts.ref"

Running a test

You can run all the tests with make test. This internally runs the ctest command in the build directory. You can pass on arguments to the ctest file through the make command though the ARGS variable. For example, to run a single named test:

local:GaudiDev_v28r1 $ make test ARGS="-R algsequencer_pyopts"

The arguments that can be passed to ctest can be found with ctest --help. Some examples:

  • -N: just print the names of the tests
  • -R <regex>: select tests by regular expression
  • -V: verbose printout (extra details, command line)

Note that gaudirun.py can take read and run a .qmt file directly. This allows you to see the output of the run, as ctest hides the output.

results matching ""

    No results matching ""