Default test driver include file. More...
#include <string>
#include <map>
#include <vector>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <limits>
#include <sbia/basis/config.h>
#include <sbia/basis/except.h>
#include <sbia/basis/assert.h>
#include <sbia/basis/path.h>
#include <sbia/basis/CmdLine.h>
#include "testdriver.hxx"
Go to the source code of this file.
Classes | |
class | CompareVisitor |
Visitor used to handle --compare option. More... | |
struct | RegressionTest |
Structure holding arguments to --compare option and currently set tolerances to be used for the regression test. More... | |
Functions | |
MultiStringArg | add_before_env ("","add-before-env","Add an environment variable named <name> with the given value."" The seperator used is the default one on the system.", false,"<name> <value>", 2) |
MultiStringArg | add_before_env_with_sep ("","add-before-env-with-sep","Add an environment variable named <name> with the given value.", false,"<name> <value> <sep>", 3) |
MultiStringArg | add_before_libpath ("","add-before-libpath","Add a path to the library path environment. This option takes"" care of choosing the right environment variable for your system.", false,"<dir>") |
SwitchArg | clean_cwd_after_test ("","clean-cwd-after","Request the removal of all files and directories from the current"" working directory after the successful execution of the test."" This option is in particular useful if the test writes any results"" to the current working directory.", false) |
SwitchArg | clean_cwd_before_test ("","clean-cwd-before","Request the removal of all files and directories from the current"" working directory before the execution of the test. This option is"" in particular useful if the test writes any results to the current"" working directory.", false) |
MultiStringArg | compare ("","compare","Compare the <test> image to the <baseline> image using the"" current tolerances. If the test image should be compared to"" to more than one baseline image, specify the file name of"" the main baseline image and name the other baseline images"" similarly with only a numerical suffix appended to the"" basename of the image file path using a dot (.) as separator."" For example, name your baseline images baseline.nii,"" baseline.1.nii, baseline.2.nii,..., and specify baseline.nii"" second argument value.", false,"<test> <baseline>", 2, false,&compare_visitor) |
SwitchArg | full_output ("","full-output","Causes the full output of the test to be passed to CDash.", false) |
vector< string > | get_baseline_filenames (string filename_template) |
Generate list of names of baseline files from a given template filename. | |
int | image_regression_test (const char *imagefile, const char *baseline, double intensity_tolerance=2.0, unsigned int max_number_of_differences=0, unsigned int tolerance_radius=0, int report=0) |
Compare output image to baseline image. | |
DoubleArg | intensity_tolerance ("","intensity-tolerance","The accepted maximum difference between image intensities"" to use for the following regression tests."" (default: 2.0)", false, 2.0,"<float>", true) |
UIntArg | max_number_of_differences ("","max-number-of-differences","When comparing images specified with the following --compare option(s),"" allow the given number of image elements to differ.", false, 0,"<n>", true) |
UIntArg | max_number_of_threads ("","max-number-of-threads","Use at most <n> threads. Set explicitly to n=1 to disable"" multi-threading. Note that the test itself still may use"" more threads, but the regression tests will not.", false, 0,"<n>") |
StringArg | redirect_output ("","redirect-output","Redirects the test output to the specified file.", false,"","<file>") |
PositionalArgs | testcmd ("testcmd","The name of the test to run and optional arguments."" Displays a list of available tests if this argument is omitted"" and waits for the user to input the number of the test to run."" Exist with error if an invalid test was specified."" Note that if the -- option is not given before the test name,"" labeled arguments following the test name will be considered"" to be options of the test driver if known by the test driver."" Otherwise, if the option is unknown to the test driver or the"" -- option has been given before the test name, the remaining"" arguments are passed on to the test.", false,"","[--] [<test name> [<arg>...]]") |
void | testdriversetup (int *argc, char **argv[]) |
Parse command-line arguments and initialize test driver. | |
UIntArg | tolerance_radius ("","tolerance-radius","At most one image element in the neighborhood specified by the"" given radius has to fulfill the criteria of the following"" regression tests", false, 0,"<int>", true) |
MultiSwitchArg | verbose ("v","verbose","Increase verbosity of output messages.", false) |
Variables | |
const unsigned int | BASIS_MAX_TEST_IMAGE_DIMENSION = 6 |
Maximum dimension of images used for testing. | |
CompareVisitor | compare_visitor |
vector< RegressionTest > | regression_tests |
Container storing added regression tests, one for each occurrence of the --compare option. |
Default test driver include file.
This file is specified as INCLUDE argument to the create_test_sourcelist() command of CMake which generates the code of the test driver. Such test driver is used, in particular, to run a test which generates an output image. The resulting image can then be compared by the test driver to one or more baseline images. Note the difference to plain non-image processing based unit tests. These shall make use of the unit testing frameworks included with BASIS instead (see test.h for a C++ unit testing framework).
This file in particular declares the functions which are used to parse the command-line arguments of the test driver and those which are used by the code fragments defined in the files testdriver-before-test.inc and testdriver-after-test.inc.
Currently available test driver implementations included by this file are:
This file is in parts a modified version of the itkTestDriverInclude.h file which is part of the TestKernel module of the ITK 4 project.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
Copyright Insight Software Consortium.
Copyright (c) 2011 University of Pennsylvania.
Portions of this file are subject to the VTK Toolkit Version 3 copyright.
For complete copyright, license and disclaimer of warranty information please refer to the COPYRIGHT file.
Contact: SBIA Group <sbia-software at uphs.upenn.edu>
Definition in file testdriver.h.
vector<string> get_baseline_filenames | ( | string | filename_template | ) |
Generate list of names of baseline files from a given template filename.
The list of baseline file names is generated from the template filename using the following algorithm:
Additionally, if a file filename_template
exists, it is the first element in the resulting list.
[in] | filename_template | File path template. |
int image_regression_test | ( | const char * | imagefile, |
const char * | baseline, | ||
double | intensity_tolerance = 2.0 , |
||
unsigned int | max_number_of_differences = 0 , |
||
unsigned int | tolerance_radius = 0 , |
||
int | report = 0 |
||
) |
Compare output image to baseline image.
This function compares a given image to a baseline image and returns a regression test result depending on how well the output image matches the baseline image given the provided tolerance arguments.
[in] | imagefile | Output image file of test run. |
[in] | baseline | Baseline image file. |
[in] | intensity_tolerance | Maximum tolerable intensity difference. |
[in] | max_number_of_differences | Maximum number of differing pixels. |
[in] | tolerance_radius | Tolerance radius. |
[in] | report | Level of test report to generate. If zero, no report is generated. If greater than zero, a report is generated. Similar to the verbosity of a program, is this parameter used to set the verbosity of the report. Most implementations yet only either generate a (full) report or none. |
Definition at line 211 of file testdriver.hxx.
void testdriversetup | ( | int * | argc, |
char ** | argv[] | ||
) |
Parse command-line arguments and initialize test driver.
[in] | argc | Number of arguments. |
[in] | argv | Command-line arguments. |
Definition at line 40 of file testdriver.hxx.