/usr/lib/cmake/vtk-6.3/vtkTestingMacros.cmake is in libvtk6-dev 6.3.0+dfsg1-11build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | # -----------------------------------------------------------------------------
# _vtk_test_parse_name(name)
# INTERNAL: Parse the name of the test and the test file.
#
# The 'name' argument must be of the form
#
# [CustomTestName,]Test
#
# where the CustomTestName followed by comma is optional. For example,
# if 'name' has the value
#
# Test1,Test
#
# this function sets the variable 'test_name' to 'Test1' and
# 'test_file' to 'Test' in the parent scope. Note that the test file
# does not include the file extension. For tests specified without a
# custom name, .e.g.,
#
# Test
#
# both variables 'test_name' and 'test_file' will be set to the variable
# 'name' defined in the caller.
function(_vtk_test_parse_name name)
set(test_name ${name} PARENT_SCOPE)
set(test_file ${name} PARENT_SCOPE)
if(name AND "x${name}" MATCHES "^x([^,]*),(.*)$")
set(test_name "${CMAKE_MATCH_1}" PARENT_SCOPE)
set(test_file "${CMAKE_MATCH_2}" PARENT_SCOPE)
endif()
endfunction()
# -----------------------------------------------------------------------------
# _vtk_test_parse_args(options source_ext args...)
# INTERNAL: Parse arguments for testing functions.
#
# Parses 'options' from the argument list into the 'options' variable in the
# parent, Test instances found with the extension 'source_ext' are parsed
# into the 'names' variable in the parent. Any comma-separated options after
# the test instance is put into a '_${name}_options' variable for the test.
# Any unrecognized arguments are put into the 'args' variable in the parent.
function(_vtk_test_parse_args options source_ext)
set(global_options)
set(names)
set(args)
foreach(arg IN LISTS ARGN)
set(handled 0)
foreach(option IN LISTS options)
if(arg STREQUAL option)
list(APPEND global_options ${option})
set(handled 1)
break()
endif()
endforeach()
if(handled)
# Do nothing.
elseif(source_ext AND "x${arg}" MATCHES "^x([^.]*)\\.${source_ext},?(.*)$")
set(name "${CMAKE_MATCH_1}")
string(REPLACE "," ";" _${name}_options "${CMAKE_MATCH_2}")
list(APPEND names ${name})
else()
list(APPEND args ${arg})
endif()
endforeach()
foreach(name IN LISTS names)
set(_${name}_options "${_${name}_options}"
PARENT_SCOPE)
endforeach()
set(options "${global_options}"
PARENT_SCOPE)
set(names "${names}"
PARENT_SCOPE)
set(args "${args}"
PARENT_SCOPE)
endfunction()
# -----------------------------------------------------------------------------
# _vtk_test_set_options(options prefix args...)
# INTERNAL: Set variables related to options.
#
# Looks in the arguments for options to set. Valid options are listed in the
# 'options' input list and the variables of the same name are set in the
# parent scope to '1' if set, and '0' if they are not found. If 'prefix' is
# non-empty, it is used as a prefix for the variable names to set and the
# no-prefix variable is used as the unset value (rather than '0').
function(_vtk_test_set_options options prefix)
foreach(option IN LISTS options)
set(default 0)
if(prefix)
set(default ${${option}})
endif()
set(${prefix}${option} ${default}
PARENT_SCOPE)
endforeach()
foreach(option IN LISTS ARGN)
set(${prefix}${option} 1
PARENT_SCOPE)
endforeach()
endfunction()
# -----------------------------------------------------------------------------
# vtk_add_test_mpi(exename tests [TESTING_DATA] [test1.cxx...] [args...])
# Adds (C++) tests which require MPI.
#
# Adds tests using the 'exename' (which must be a CMake target) and the name
# of the tests into the variable named by 'tests' in the parent scope. If the
# TESTING_DATA option is specified, -D, -T, and -V flags are passed to the
# test. The number of processes to be used may be set with
# ${exename}_NUMPROCS or ${test}_NUMPROCS to override the default
# ${VTK_MPI_MAX_NUMPROCS} if necessary. Any unrecognized arguments are passed
# to the test as well as the value of '${name}_ARGS. By default, the test
# name will be the part of the source file before the '.cxx'. A custom test name
# can be specified by giving a name followed by a comma before the test file
# name, .e.g.,
#
# CustomTestName,TestSource.cxx
#
# The 'vtk_test_prefix' variable may also be set to create separate tests from a
# single test name (e.g., running with different arguments), but should be
# used only when required.
function(vtk_add_test_mpi exename _tests)
set(mpi_options
TESTING_DATA
CUSTOM_BASELINES
)
_vtk_test_parse_args("${mpi_options}" "cxx" ${ARGN})
_vtk_test_set_options("${mpi_options}" "" ${options})
set(default_numprocs ${VTK_MPI_MAX_NUMPROCS})
if(${exename}_NUMPROCS)
set(default_numprocs ${${exename}_NUMPROCS})
endif()
set(data_dir "${VTK_TEST_DATA_DIR}")
if(${vtk-module}_DATA_DIR)
set(data_dir "${${vtk-module}_DATA_DIR}")
endif()
set(baseline_dir ${${vtk-module}_SOURCE_DIR}/Testing/Data/Baseline)
if(VTK_BASELINE_DIR)
set(baseline_dir ${VTK_BASELINE_DIR})
endif()
set(externaldata_target VTKData)
if(VTK_TEST_DATA_TARGET)
set(externaldata_target ${VTK_TEST_DATA_TARGET})
endif()
foreach(name IN LISTS names)
_vtk_test_set_options("${mpi_options}" "local_" ${_${name}_options})
_vtk_test_parse_name(${name})
set(_D "")
set(_T "")
set(_V "")
if(local_TESTING_DATA)
set(_D -D ${data_dir})
set(_T -T ${VTK_TEST_OUTPUT_DIR})
if(local_CUSTOM_BASELINES)
set(_V -V "${data_dir}/Baseline")
else()
set(_V -V "DATA{${baseline_dir}/${test_name}.png,:}")
endif()
endif()
set(numprocs ${default_numprocs})
if(${name}_NUMPROCS)
set(numprocs ${${name}_NUMPROCS})
endif()
ExternalData_add_test(${externaldata_target}
NAME ${vtk-module}Cxx-MPI-${vtk_test_prefix}${test_name}
COMMAND ${VTK_MPIRUN_EXE}
${VTK_MPI_PRENUMPROC_FLAGS} ${VTK_MPI_NUMPROC_FLAG} ${numprocs}
${VTK_MPI_PREFLAGS}
$<TARGET_FILE:${exename}>
${name}
${_D} ${_T} ${_V}
${args}
${${vtk-module}_ARGS}
${${name}_ARGS}
${VTK_MPI_POSTFLAGS})
set_tests_properties(${vtk-module}Cxx-MPI-${vtk_test_prefix}${test_name}
PROPERTIES
LABELS "${${vtk-module}_TEST_LABELS}"
PROCESSORS ${numprocs}
)
list(APPEND ${_tests} "${test_file}")
endforeach()
set(${_tests} ${${_tests}} PARENT_SCOPE)
endfunction()
# -----------------------------------------------------------------------------
# vtk_test_mpi_executable(exename tests [RENDERING_FACTORY] [extra.cxx...])
# Creates an MPI-aware C++ test executable.
#
# Creates a test executable which uses MPI and contains the tests listed in
# the variable 'tests'. See also 'vtk_test_cxx_executable'.
function(vtk_test_mpi_executable exename _tests)
vtk_test_cxx_executable("${exename}" "${_tests}" ${ARGN})
if(TARGET "${exename}")
vtk_mpi_link("${exename}")
endif()
endfunction()
# -----------------------------------------------------------------------------
# vtk_add_test_cxx(exename tests [NO_DATA] [NO_VALID] [NO_OUTPUT]
# [test1.cxx...] [args...])
# Adds C++ tests.
#
# Adds tests using the 'exename' (which must be a CMake target) and the name
# of the tests into the variable named by 'tests' in the parent scope. If the
# NO_DATA option is specified, the test will not receive a -D argument (input file),
# NO_VALID will suppress the -V argument (path to a baseline image), and
# NO_OUTPUT will suppress the -T argument (output directory). Test-specific
# arguments may be set to _${name}_ARGS. By default, the test name will be the part
# of the source file before the '.cxx'. A custom test name can be specified by
# giving a name followed by a comma before the test file name, .e.g.,
#
# CustomTestName,TestSource.cxx
#
# The 'vtk_test_prefix' variable may be set to create separate tests from a
# single test name (e.g., running with different arguments), but should be
# used only when required.
function(vtk_add_test_cxx exename _tests)
set(cxx_options
NO_DATA
NO_VALID
NO_OUTPUT
CUSTOM_BASELINES
)
_vtk_test_parse_args("${cxx_options}" "cxx" ${ARGN})
_vtk_test_set_options("${cxx_options}" "" ${options})
if(VTK_BASELINE_DIR)
if(vtk-module)
set(prefix ${vtk-module})
elseif(vtk-example)
set(prefix ${vtk-example})
endif()
set(baseline_dir ${VTK_BASELINE_DIR})
elseif(vtk-module)
set(prefix ${vtk-module})
set(baseline_dir ${${vtk-module}_SOURCE_DIR}/Testing/Data/Baseline)
elseif(vtk-example)
set(prefix ${vtk-example})
set(baseline_dir ${CMAKE_CURRENT_SOURCE_DIR}/Baseline)
else()
message(FATAL_ERROR "Neither vtk-module nor vtk-example is set!")
endif()
set(data_dir "${VTK_TEST_DATA_DIR}")
if(${vtk-module}_DATA_DIR)
set(data_dir "${${vtk-module}_DATA_DIR}")
endif()
set(externaldata_target VTKData)
if(VTK_TEST_DATA_TARGET)
set(externaldata_target ${VTK_TEST_DATA_TARGET})
endif()
foreach(name IN LISTS names)
_vtk_test_set_options("${cxx_options}" "local_" ${_${name}_options})
_vtk_test_parse_name(${name})
set(_D "")
if(NOT local_NO_DATA)
set(_D -D ${data_dir})
endif()
set(_T "")
if(NOT local_NO_OUTPUT)
set(_T -T ${VTK_TEST_OUTPUT_DIR})
endif()
set(_V "")
if(NOT local_NO_VALID)
if(local_CUSTOM_BASELINES)
set(_V -V "${data_dir}/Baseline")
else()
set(_V -V "DATA{${baseline_dir}/${test_name}.png,:}")
endif()
endif()
ExternalData_add_test(${externaldata_target}
NAME ${prefix}Cxx-${vtk_test_prefix}${test_name}
COMMAND $<TARGET_FILE:${exename}>
${test_file}
${args}
${${prefix}_ARGS}
${${name}_ARGS}
${_D} ${_T} ${_V})
set_tests_properties(${prefix}Cxx-${vtk_test_prefix}${test_name}
PROPERTIES
LABELS "${${prefix}_TEST_LABELS}"
)
list(APPEND ${_tests} "${test_file}")
endforeach()
set(${_tests} ${${_tests}} PARENT_SCOPE)
endfunction()
# -----------------------------------------------------------------------------
# vtk_test_cxx_executable(exename, tests [RENDERING_FACTORY] [extra.cxx...])
# Build a C++ test executable.
#
# Creates a test executable for running the tests listed in the 'tests'
# variable. If RENDERING_FACTORY is set, the rendering test driver will be
# used instead. Any other sources found will be built into the executable as
# well. Unrecognized arguments are ignored.
function(vtk_test_cxx_executable exename _tests)
set(exe_options
RENDERING_FACTORY
)
_vtk_test_parse_args("${exe_options}" "" ${ARGN})
_vtk_test_set_options("${exe_options}" "" ${options})
if(NOT ${_tests})
# No tests -> no need for an executable.
return()
endif()
set(test_driver vtkTestDriver.h)
if(RENDERING_FACTORY)
include(vtkTestingRenderingDriver)
set(test_driver ${vtkTestingRendering_SOURCE_DIR}/vtkTestingObjectFactory.h)
endif()
set(extra_sources ${args})
if(vtk-module)
set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN
" vtksys::SystemInformation::SetStackTraceOnError(1);\n ${CMAKE_TESTDRIVER_BEFORE_TESTMAIN}")
endif()
create_test_sourcelist(test_sources ${exename}.cxx ${${_tests}}
EXTRA_INCLUDE ${test_driver})
if(vtk-module)
vtk_module_test_executable(${exename} ${test_sources} ${extra_sources})
elseif(vtk-example)
add_executable(${exename} ${test_sources} ${extra_sources})
target_link_libraries(${exename} ${VTK_LIBRARIES})
else()
message(FATAL_ERROR "Neither vtk-module nor vtk-example is set!")
endif()
endfunction()
# -----------------------------------------------------------------------------
# vtk_add_test_python([NO_RT] [NO_DATA] [NO_VALID] [NO_OUTPUT]
# [test1.py...] [args...])
# Adds Python tests.
#
# Adds Python tests to run. If NO_DATA is set, the -D argument to the test
# (input data) will not be passed, NO_OUTPUT suppresses the -T argument
# (output directory), NO_VALID will suppress the -B argument (baseline for
# normal image comparisons (NO_RT)) and the -V and -A arguments (for RT-based
# image comparisons). Test-specific arguments may be set to _${name}_ARGS. By
# default, the test name will be the part of the source file before the '.py'.
# A custom test name can be specified by giving a name followed by a comma
# before the test file name, .e.g.,
#
# CustomTestName,TestSource.py
#
# The 'vtk_test_prefix' variable may be set to create separate tests from a
# single test name (e.g., running with different arguments), but should be
# used only when required.
#
# Before calling this function, you can define VTK_PYTHON_EXE to point the
# executable (or generator expression for the executable) to run for the test.
# If VTK_PYTHON_EXE is not defined, `vtkpython` is assumed i.e.
# ($<TARGET_FILE:vtkpython>)
function(vtk_add_test_python)
if (NOT DEFINED VTK_PYTHON_EXE)
set(VTK_PYTHON_EXE "\$<TARGET_FILE:vtkpython>")
endif()
set(python_options
NO_DATA
NO_VALID
NO_OUTPUT
NO_RT
JUST_VALID
)
_vtk_test_parse_args("${python_options}" "py" ${ARGN})
_vtk_test_set_options("${python_options}" "" ${options})
set(data_dir "${VTK_TEST_DATA_DIR}")
if(${vtk-module}_DATA_DIR)
set(data_dir "${${vtk-module}_DATA_DIR}")
endif()
set(baseline_dir ${${vtk-module}_SOURCE_DIR}/Testing/Data/Baseline)
if(VTK_BASELINE_DIR)
set(baseline_dir ${VTK_BASELINE_DIR})
endif()
set(externaldata_target VTKData)
if(VTK_TEST_DATA_TARGET)
set(externaldata_target ${VTK_TEST_DATA_TARGET})
endif()
foreach(name IN LISTS names)
_vtk_test_set_options("${python_options}" "local_" ${_${name}_options})
_vtk_test_parse_name(${name})
set(_D "")
if(NOT local_NO_DATA)
set(_D -D ${data_dir})
endif()
set(rtImageTest "")
set(_B "")
set(_V "")
set(_A "")
if(NOT local_NO_VALID)
if(local_NO_RT)
set(_B -B "DATA{${baseline_dir}/,REGEX:${test_name}(_[0-9]+)?.png}")
else()
set(_V -V "DATA{${baseline_dir}/${test_name}.png,:}")
if(NOT local_JUST_VALID)
set(rtImageTest ${VTK_BINARY_DIR}/Utilities/vtkTclTest2Py/rtImageTest.py)
set(_A -A ${VTK_BINARY_DIR}/Utilities/vtkTclTest2Py)
endif()
endif()
endif()
set(_T "")
if(NOT local_NO_OUTPUT)
set(_T -T ${VTK_TEST_OUTPUT_DIR})
endif()
ExternalData_add_test(${externaldata_target}
NAME ${vtk-module}Python${_vtk_test_python_suffix}-${vtk_test_prefix}${test_name}
COMMAND ${_vtk_test_python_pre_args}
${VTK_PYTHON_EXE} --enable-bt
${VTK_PYTHON_ARGS}
${rtImageTest}
${CMAKE_CURRENT_SOURCE_DIR}/${test_file}.py
${args}
${${vtk-module}_ARGS}
${${name}_ARGS}
${_D} ${_B} ${_T} ${_V} ${_A})
set_tests_properties(${vtk-module}Python${_vtk_test_python_suffix}-${vtk_test_prefix}${test_name}
PROPERTIES
LABELS "${${vtk-module}_TEST_LABELS}"
)
endforeach()
endfunction()
# Before calling this function, you can define VTK_PYTHON_EXE to point the
# executable (or generator expression for the executable) to run for the test.
# If VTK_PYTHON_EXE is not defined, `vtkpython` is assumed i.e.
# ($<TARGET_FILE:pvtkpython>)
function(vtk_add_test_python_mpi)
set(_vtk_test_python_suffix "-MPI")
set(numprocs ${VTK_MPI_MAX_NUMPROCS})
if(${vtk-module}_NUMPROCS)
set(numprocs ${${vtk-module}_NUMPROCS})
endif()
set(_vtk_test_python_pre_args
${VTK_MPIRUN_EXE}
${VTK_MPI_PRENUMPROC_FLAGS} ${VTK_MPI_NUMPROC_FLAG} ${numprocs}
${VTK_MPI_PREFLAGS})
if (NOT DEFINED VTK_PYTHON_EXE)
set(VTK_PYTHON_EXE "\$<TARGET_FILE:pvtkpython>")
endif()
vtk_add_test_python(${ARGN})
endfunction()
# -----------------------------------------------------------------------------
# vtk_add_test_tcl([NO_RT] [NO_DATA] [NO_VALID] [NO_OUTPUT]
# [test1.tcl...] [args...])
# Adds Tcl tests.
#
# Adds Tcl tests to run. If NO_DATA is set, the -D argument to the test
# (input data) will not be passed, NO_VALID will suppress -V, NO_OUTPUT will
# suppress -T, and NO_RT will suppress the -V and -T arguments
# unconditionally and pass -D to the empty string. Test-specific arguments may
# be set to _${name}_ARGS. By default, the test name will be the part of the
# source file before the '.tcl'. A custom test name can be specified by giving
# a name followed by a comma before the test file name, .e.g.,
#
# CustomTestName,TestSource.tcl
#
# The 'vtk_test_prefix' variable may be set to create separate tests from a
# single test name (e.g., running with different arguments), but should be
# used only when required.
function(vtk_add_test_tcl)
if(NOT VTK_TCL_EXE)
message(FATAL_ERROR "VTK_TCL_EXE not set")
endif()
set(tcl_options
NO_DATA
NO_VALID
NO_OUTPUT
NO_RT
)
_vtk_test_parse_args("${tcl_options}" "tcl" ${ARGN})
_vtk_test_set_options("${tcl_options}" "" ${options})
set(data_dir "${VTK_TEST_DATA_DIR}")
if(${vtk-module}_DATA_DIR)
set(data_dir "${${vtk-module}_DATA_DIR}")
endif()
set(baseline_dir ${${vtk-module}_SOURCE_DIR}/Testing/Data/Baseline)
if(VTK_BASELINE_DIR)
set(baseline_dir ${VTK_BASELINE_DIR})
endif()
set(externaldata_target VTKData)
if(VTK_TEST_DATA_TARGET)
set(externaldata_target ${VTK_TEST_DATA_TARGET})
endif()
foreach(name IN LISTS names)
_vtk_test_set_options("${tcl_options}" "local_" ${_${name}_options})
_vtk_test_parse_name(${name})
if(NOT local_NO_DATA)
set(_D -D ${data_dir})
elseif(local_NO_RT)
set(_D "")
else()
set(_D -D VTK_DATA_ROOT-NOTFOUND)
endif()
set(rtImageTest "")
set(_V "")
set(_T "")
if(NOT local_NO_RT)
set(rtImageTest ${vtkTestingRendering_SOURCE_DIR}/rtImageTest.tcl)
if(NOT local_NO_VALID)
set(_V -V "DATA{${baseline_dir}/${test_name}.png,:}")
endif()
if(NOT local_NO_OUTPUT)
set(_T -T ${VTK_TEST_OUTPUT_DIR})
endif()
endif()
set(_A -A ${VTK_SOURCE_DIR}/Wrapping/Tcl)
ExternalData_add_test(${externaldata_target}
NAME ${vtk-module}Tcl-${vtk_test_prefix}${test_name}
COMMAND ${VTK_TCL_EXE}
${rtImageTest}
${CMAKE_CURRENT_SOURCE_DIR}/${test_file}.tcl
${args}
${${vtk-module}_ARGS}
${${name}_ARGS}
${_D} ${_T} ${_V} ${_A})
set_tests_properties(${vtk-module}Tcl-${vtk_test_prefix}${test_name}
PROPERTIES
LABELS "${${vtk-module}_TEST_LABELS}"
)
endforeach()
endfunction()
|