Using the test script g4test
Name
g4test - a script that aids testing
Synopsis
g4test [switches] test_specification
Description
g4test is the script mentioned in the GEANT4
testing framework document. See the framework for the "philosophy"
of testing. It is mainly useful for regression testing. Each test in the
code repository should have reference inputs and outputs (created by g4test).
The main usage of g4test is building and running tests
and comparing the output to the reference.
Anything that specifies the test name and the test case (there can
be multiple test cases for a test).
Tests are always searched for in the current directory.
-
"" (nothing)
Legal when there is only one source file (.cc) with the default test
case.
-
test_name e.g. example1
The default test case is selected.
-
test_name.extension e.g. example1.cc
In other words, the name of a file associated with the test. The default
test case is selected.
-
test_name.test_case
-
test_name test_case
-
test_name.test_case.extension
The name of a file associated with the test name and case.
They specify which function g4test should perform. The default choice
is --repeat if no options are present.
-
-r, --repeat
Run the test with the reference input, log the output and error (into
the .newout and .newerr files), and compare them to the
reference (a diff is done). If the outputs or the errors differ,
the test fails. The test also fails if the execution returns non-zero exit
code.
-
-u, --update
The output and error most recently obtained (with --repeat)
becomes the reference.
-
-o, --show-old
Shows the reference output and error.
-
-n, --show-new
Shows the most recent output and error (obtained with --repeat).
-
-c, --create
Creates the reference input, output and error.
-
-x, --execute
Executes the test with the reference input, showing the results.
-
-i, --interactive
Executes the test interactively. Same as running the executable.
-
-d, --delete
Specifies that the test executable should be deleted after the test
was run (e.g. because it would take up too much disk space). This option
can be combined with all others.
Examples
-
The author of the test creates a test case:
g4test -c example2 field
-
Someone checks later on if the test still works:
g4test example2.field
-
The most frequent usage: checking if a test still works (no test cases):
g4test mytest
-
It doesn't. He checks the new output:
g4test -n example2.field
-
The author modifies his code so that the test gives some different output.
He makes the new output the reference, thereby deleting the executable:
g4test -r example2 field
g4test -u -d example2 field
Files
-
test_name.cc
The source file for the test test_name.
-
test_name.in
The reference input for the default test case.
-
test_name.out
The reference output for the default test case.
-
test_name.err
The reference error (what is written to cerr) for the default test
case.
-
test_name.newout, test_name.newerr
The output and the error of the repeated test. They only appear if
they differ from the reference.
-
test_name.test_case.in, test_name.test_case.out,
test_name.test_case.err, test_name.test_case.newout,
test_name.test_case.newerr
The same files for a specific test case.
Setup
Follow the generic instructions on the Installation
of development tools page.
Bugs
Find and report them, please!
Last modified on 13 Feb 1998
PU, Peter.Urban@cern.ch