]> Creatis software - clitk.git/commitdiff
Romulo:
authordsarrut <dsarrut>
Tue, 12 Apr 2011 11:49:19 +0000 (11:49 +0000)
committerdsarrut <dsarrut>
Tue, 12 Apr 2011 11:49:19 +0000 (11:49 +0000)
- 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
tests/CMakeLists.txt
tests/tools/CMakeLists.txt [new file with mode: 0755]
tests/tools/clitkImageInfoTest.cxx
tests/tools/clitkWriteDicomSeriesTest.cxx

index 6f3a808b32ac68a1442317950512230e03110907..3bb462c26acc90387183a7e32ac844e5bc32f87d 100644 (file)
@@ -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)
 #=========================================================
 
 
index 822aada61d2280047caca361b42c0488ed58cf78..2ca6877f13737980c2923226fc343b92b1ff5e35 100755 (executable)
@@ -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 (executable)
index 0000000..f915a5b
--- /dev/null
@@ -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)
index 7642d08aff39ed170e19181e50629b276c25eff1..149e0c7f9c5e0a3980bdb8010ccb82f7275b7730 100755 (executable)
@@ -3,28 +3,31 @@
 
 #include <iostream>
 #include <sstream>
-#include <cassert>
+#include <string>
 
 #include <itksys/SystemTools.hxx>
 
+
 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;
index 0d0059231abdc400f247b9e20749706668da97a6..ab275453c204fdefade48a2c84ffca7f4c034633 100755 (executable)
 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)