From e61f20b8e5d4bb528728223194403e6e37808628 Mon Sep 17 00:00:00 2001 From: dsarrut Date: Tue, 12 Apr 2011 11:49:19 +0000 Subject: [PATCH] Romulo: - Changed CMakeLists.txt for tests + $CLITKDIR/tests mirrors $CLITKDIR, but contains only test code + CLITK_DATA_PATH must be specified if BUILD_TESTING is on * test code can directly access the variable (macro) + Test executables generated in $CLITKDIR/build/tests/bin --- CMakeLists.txt | 7 +++--- tests/CMakeLists.txt | 29 +++++++++++++---------- tests/tools/CMakeLists.txt | 17 +++++++++++++ tests/tools/clitkImageInfoTest.cxx | 13 ++++++---- tests/tools/clitkWriteDicomSeriesTest.cxx | 4 ++-- 5 files changed, 47 insertions(+), 23 deletions(-) create mode 100755 tests/tools/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f3a808..3bb462c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,7 +93,7 @@ OPTION(CLITK_BUILD_REGISTRATION "Build command-line registration tools" OFF) OPTION(CLITK_BUILD_VV "Build vv the 4D visualizer (requires VTK and QT)" ON) IF (CLITK_BUILD_VV) - add_subdirectory(vv) + ADD_SUBDIRECTORY(vv) ENDIF(CLITK_BUILD_VV) @@ -101,8 +101,9 @@ ENDIF(CLITK_BUILD_VV) #Support for the CTest dashboard testing system INCLUDE(CTest) #========================================================= -add_subdirectory(tests) -add_subdirectory(tests/tools) +IF (BUILD_TESTING) + ADD_SUBDIRECTORY(tests) +ENDIF(BUILD_TESTING) #========================================================= diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 822aada..2ca6877 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,17 +1,20 @@ -# Add test apps and test executions to this part -# Test apps are compiled as any other app in the -# project. Test executions are run using "make test" -# +# Tests are organized to mirror the clitk directory tree. +# Eacho subdirectory has its own CMakeLists.txt with the compiling directives + IF (BUILD_TESTING) - # clitkImageInfo - ADD_EXECUTABLE(clitkImageInfoTest tools/clitkImageInfoTest.cxx) - TARGET_LINK_LIBRARIES(clitkImageInfoTest ITKIO) - ADD_TEST(NAME clitkImageInfoTest COMMAND clitkImageInfoTest) + set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/tests/bin) + + FIND_PATH(CLITK_DATA_PATH data) + IF (CLITK_DATA_PATH STREQUAL "CLITK_DATA_PATH-NOTFOUND") + MESSAGE(FATAL_ERROR "Data path must be given when tests are enabled.") + ENDIF (CLITK_DATA_PATH STREQUAL "CLITK_DATA_PATH-NOTFOUND") + + ADD_DEFINITIONS(-DCLITK_DATA_PATH='"${CLITK_DATA_PATH}"') - # clitkWriteDicomSeries - ADD_EXECUTABLE(clitkWriteDicomSeriesTest tools/clitkWriteDicomSeriesTest.cxx) - TARGET_LINK_LIBRARIES(clitkWriteDicomSeriesTest ITKIO) - ADD_TEST(NAME clitkWriteDicomSeriesTest COMMAND clitkWriteDicomSeriesTest) + ADD_SUBDIRECTORY(tools) + #ADD_SUBDIRECTORY(segmentation) + #ADD_SUBDIRECTORY(registration) + #ADD_SUBDIRECTORY(common) -ENDIF(BUILD_TESTING) \ No newline at end of file +ENDIF(BUILD_TESTING) diff --git a/tests/tools/CMakeLists.txt b/tests/tools/CMakeLists.txt new file mode 100755 index 0000000..f915a5b --- /dev/null +++ b/tests/tools/CMakeLists.txt @@ -0,0 +1,17 @@ +# Add test apps and test executions to this part +# Test apps are compiled as any other app in the +# project. Test executions are run using "make test" +# +IF(BUILD_TESTING) + + # clitkImageInfo + ADD_EXECUTABLE(clitkImageInfoTest clitkImageInfoTest.cxx) + TARGET_LINK_LIBRARIES(clitkImageInfoTest ITKIO) + ADD_TEST(NAME clitkImageInfoTest COMMAND clitkImageInfoTest) + + # clitkWriteDicomSeries + ADD_EXECUTABLE(clitkWriteDicomSeriesTest clitkWriteDicomSeriesTest.cxx) + TARGET_LINK_LIBRARIES(clitkWriteDicomSeriesTest ITKIO) + ADD_TEST(NAME clitkWriteDicomSeriesTest COMMAND clitkWriteDicomSeriesTest) + +ENDIF(BUILD_TESTING) diff --git a/tests/tools/clitkImageInfoTest.cxx b/tests/tools/clitkImageInfoTest.cxx index 7642d08..149e0c7 100755 --- a/tests/tools/clitkImageInfoTest.cxx +++ b/tests/tools/clitkImageInfoTest.cxx @@ -3,28 +3,31 @@ #include #include -#include +#include #include + const size_t NUMTESTS=2; // test files const char mhd_files[NUMTESTS][128] = { - "data/4d/mhd/00.mhd", - "data/4d/mhd/bh.mhd" + CLITK_DATA_PATH"/4d/mhd/00.mhd", + CLITK_DATA_PATH"/4d/mhd/bh.mhd" }; // pre-written validation files. the idea // is that the output generated from the test // files match the verification files const char validation_files[NUMTESTS][128] = { - "data/tools/clitkImageInfoTestValidate3D.out", - "data/tools/clitkImageInfoTestValidate4D.out" + CLITK_DATA_PATH"/tools/clitkImageInfoTestValidate3D.out", + CLITK_DATA_PATH"/tools/clitkImageInfoTestValidate4D.out" }; int main(int argc, char** argv) { + system("pwd"); + bool failed = false; for (size_t i = 0; i < NUMTESTS; i++) { std::ostringstream cmd_line; diff --git a/tests/tools/clitkWriteDicomSeriesTest.cxx b/tests/tools/clitkWriteDicomSeriesTest.cxx index 0d00592..ab27545 100755 --- a/tests/tools/clitkWriteDicomSeriesTest.cxx +++ b/tests/tools/clitkWriteDicomSeriesTest.cxx @@ -10,11 +10,11 @@ const size_t NUMTESTS=1; const char mhd_files[NUMTESTS][128] = { - "data/3d/mhd/CT_UNTAGGED2MM_0.mhd" + CLITK_DATA_PATH"/3d/mhd/CT_UNTAGGED2MM_0.mhd" }; const char dcm_dirs[NUMTESTS][128] = { - "data/3d/dcm/1.2.840.113704.1.111.5556.1240990904.26" + CLITK_DATA_PATH"/3d/dcm/1.2.840.113704.1.111.5556.1240990904.26" }; int main(int argc, char** argv) -- 2.47.1