62 #ifndef _BASIS_TESTDRIVER_H 63 #define _BASIS_TESTDRIVER_H 79 using namespace basis;
92 "",
"add-before-libpath",
93 "Add a path to the library path environment. This option takes" 94 " care of choosing the right environment variable for your system.",
99 "Add an environment variable named <name> with the given value." 100 " The seperator used is the default one on the system.",
101 false,
"<name> <value>", 2);
104 "",
"add-before-env-with-sep",
105 "Add an environment variable named <name> with the given value.",
106 false,
"<name> <value> <sep>", 3);
167 "Compare the <test> file to the <baseline> file byte by byte." 168 " Can by used to compare any files including text files." 169 " For images, the --compare option should be used instead.",
170 false,
"<test> <baseline>", 2,
false, &diff_visitor);
174 "Compare the <test> file to the <baseline> file line by line." 175 " Can by used to compare text files. The current --max-number-of-differences" 176 " setting determines the number of lines which may differ between the files." 177 " For binary files, consider the --diff option instead.",
178 false,
"<test> <baseline>", 2,
false, &diff_lines_visitor);
182 "Compare the <test> image to the <baseline> image using the" 183 " current tolerances. If the test image should be compared to" 184 " to more than one baseline image, specify the file name of" 185 " the main baseline image and name the other baseline images" 186 " similarly with only a numerical suffix appended to the" 187 " basename of the image file path using a dot (.) as separator." 188 " For example, name your baseline images baseline.nii," 189 " baseline.1.nii, baseline.2.nii,..., and specify baseline.nii" 190 " second argument value.",
191 false,
"<test> <baseline>", 2,
false, &compare_visitor);
194 "",
"intensity-tolerance",
195 "The accepted maximum difference between image intensities" 196 " to use for the following regression tests." 199 false, 2.0,
"<float>",
true);
202 "",
"max-number-of-differences",
203 "When comparing images specified with the following --compare option(s)," 204 " allow the given number of image elements to differ.",
205 false, 0,
"<n>",
true);
208 "",
"tolerance-radius",
209 "At most one image element in the neighborhood specified by the" 210 " given radius has to fulfill the criteria of the following" 212 false, 0,
"<int>",
true);
215 "",
"orientation-insensitive",
216 "Allow the test and baseline images to have different orientation." 217 " When this option is given, the orientation of both images is made" 218 " identical before they are compared. It is suitable if the test" 219 " and baseline images are simply stored with different orientation," 220 " but with proper orientation information in the file header.");
225 "",
"redirect-output",
226 "Redirects the test output to the specified file.",
227 false,
"",
"<file>");
230 "",
"max-number-of-threads",
231 "Use at most <n> threads. Set explicitly to n=1 to disable" 232 " multi-threading. Note that the test itself still may use" 233 " more threads, but the regression tests will not.",
238 "Causes the full output of the test to be passed to CDash.",
243 "Increase verbosity of output messages.",
249 "",
"clean-cwd-before",
250 "Request the removal of all files and directories from the current" 251 " working directory before the execution of the test. This option is" 252 " in particular useful if the test writes any results to the current" 253 " working directory.",
257 "",
"clean-cwd-after",
258 "Request the removal of all files and directories from the current" 259 " working directory after the successful execution of the test." 260 " This option is in particular useful if the test writes any results" 261 " to the current working directory.",
264 #ifdef BASIS_STANDALONE_TESTDRIVER 268 "The external test command and its command-line arguments." 269 " This command is executed by the test driver after altering the" 270 " environment as subprocess. After the subprocess finished, the" 271 " requested regression tests are performed by the test driver." 272 " Note that if the -- option is not given before the test command," 273 " labeled arguments following the test command will be considered" 274 " to be options of the test driver if known by the test driver.",
275 true,
"[--] <test command> <arg>...");
279 "Do not run any test subprocess but only perform the regression tests.",
282 #else // defined(BASIS_STANDALONE_TESTDRIVER) 286 "The name of the test to run and optional arguments." 287 " Displays a list of available tests if this argument is omitted" 288 " and waits for the user to input the number of the test to run." 289 " Exist with error if an invalid test was specified." 290 " Note that if the -- option is not given before the test name," 291 " labeled arguments following the test name will be considered" 292 " to be options of the test driver if known by the test driver." 293 " Otherwise, if the option is unknown to the test driver or the" 294 " -- option has been given before the test name, the remaining" 295 " arguments are passed on to the test.",
296 false,
"",
"[--] [<test name> [<arg>...]]");
298 #endif // defined(BASIS_STANDALONE_TESTDRIVER) 328 int binary_diff(
const char* testfile,
const char* baseline);
394 const char* baseline,
406 #endif // _BASIS_TESTDRIVER_H 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>...]]")
SwitchArg orientation_insensitive("", "orientation-insensitive", "Allow the test and baseline images to have different orientation." " When this option is given, the orientation of both images is made" " identical before they are compared. It is suitable if the test" " and baseline images are simply stored with different orientation," " but with proper orientation information in the file header.")
MultiStringArg diff("", "diff", "Compare the <test> file to the <baseline> file byte by byte." " Can by used to compare any files including text files." " For images, the --compare option should be used instead.", false, "<test> <baseline>", 2, false, &diff_visitor)
unsigned int tolerance_radius
int text_diff_lines(const char *testfile, const char *baseline, unsigned int max_number_of_differences=0)
Compare two text files line by line.
SwitchArg full_output("", "full-output", "Causes the full output of the test to be passed to CDash.", false)
An argument that allows multiple values of type T to be specified.
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)
Default test driver implementation.
TCLAP::SwitchArg SwitchArg
Switch to enable/disable option.
TCLAP::UnlabeledMultiArg< std::string > PositionalArgs
Positional arguments.
BinaryDiffVisitor diff_visitor
BASIS utilities of BASIS project of BASIS package.
Visitor used to handle –diff option.
Visitor used to handle –compare option.
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)
void testdriversetup(int *argc, char **argv[])
Parse command-line arguments and initialize test driver.
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>")
unsigned int max_number_of_differences
MultiStringArg diff_lines("", "diff-lines", "Compare the <test> file to the <baseline> file line by line." " Can by used to compare text files. The current --max-number-of-differences" " setting determines the number of lines which may differ between the files." " For binary files, consider the --diff option instead.", false, "<test> <baseline>", 2, false, &diff_lines_visitor)
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)
LineDiffVisitor diff_lines_visitor
CompareVisitor compare_visitor
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)
Structure holding arguments to regression test options and currently set tolerances to be used for th...
StringArg redirect_output("", "redirect-output", "Redirects the test output to the specified file.", false, "", "<file>")
MultiSwitchArg verbose("v", "verbose", "Increase verbosity of output messages.", false)
const unsigned int BASIS_MAX_TEST_IMAGE_DIMENSION
Maximum dimension of images used for testing.
Visitor used to handle –diff-lines option.
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>")
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)
int binary_diff(const char *testfile, const char *baseline)
Compare two files byte by byte.
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, bool orientation_insensitive=false, int report=0)
Compare output image to baseline image.
TCLAP::MultiSwitchArg MultiSwitchArg
Counts occurrences of option switch.
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)
bool orientation_insensitive
double intensity_tolerance
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)
An argument that allows multiple values of type T to be specified.
vector< string > get_baseline_filenames(string filename_template)
Generate list of names of baseline files from a given template filename.
vector< RegressionTest > regression_tests
Container storing added regression tests.