]> Creatis software - gdcm.git/blob - Testing/CMakeLists.txt
Add TestLoadAllDocumentsNoPrivNoSeq, to improve test coverage
[gdcm.git] / Testing / CMakeLists.txt
1 # CMakeLists for Testing purpose
2 # Cxx file that need a file to run should be place aproprietly
3
4 SET(CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
5
6 SET(GDCM_TESTS ${CXX_TEST_PATH}/gdcmTests)
7
8 # add test that does not require data:
9 # They usally return if no argument is given
10 SET(TEST_SOURCES
11   TestUtil.cxx
12   TestBug.cxx
13   TestHash.cxx
14   TestTS.cxx
15   TestVR.cxx
16   TestDictGroupName.cxx
17   TestDict.cxx
18   TestWriteSimple.cxx
19   TestImageSet.cxx
20   TestDicomDirElement.cxx
21   TestDicomString.cxx
22   #TestValidate.cxx
23 )
24
25 # add tests that require data
26 IF (GDCM_DATA_ROOT)
27   SET(TEST_SOURCES ${TEST_SOURCES}
28     TestFileAccessors.cxx
29     TestMakeIcon.cxx
30     TestLoadAllDocumentsNoPrivNoSeq.cxx # includes generated gdcmDataImages.h
31     TestPrintAllDocument.cxx         # includes generated gdcmDataImages.h
32     #TestAllEntryVerify.cxx           # includes generated gdcmDataImages.h
33     TestAllReadCompareDicom.cxx      # includes generated gdcmDataImages.h
34     TestReadWriteReadCompare.cxx     # includes generated gdcmDataImages.h 
35     #TestCopyDicom.cxx                # includes generated gdcmDataImages.h 
36     #    TestCopyRescaleDicom.cxx         # includes generated gdcmDataImages.h 
37     #TestChangeHeader.cxx
38     #    TestAnonymize.cxx
39     TestDirList.cxx
40     TestDicomDir.cxx                 # require DICOMDIR
41     TestBuildUpDicomDir.cxx          # writes a file named "NewDICOMDIR"
42     TestMakeDicomDir.cxx             # writes a file named "NewDICOMDIR"
43     TestSerieHelper.cxx              # uses gdcmData as a default root directory    
44   )
45   # add test that require VTK:
46   IF(GDCM_VTK)
47     IF("${VTK_MAJOR_VERSION}" LESS 4)
48       MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !")
49     ELSE("${VTK_MAJOR_VERSION}" LESS 4)
50       IF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 2)
51         MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !"
52                              "Although gdcm should compile fine. You just need to turn BUILD_TESTING:=OFF")
53       ENDIF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 2)
54       IF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 4 AND "${VTK_BUILD_VERSION}" LESS 3)
55         MESSAGE(FATAL_ERROR "This VTK version is not supported, you are on your own !"
56                              "Although gdcm should compile fine. You just need to turn BUILD_TESTING:=OFF")
57       ENDIF("${VTK_MAJOR_VERSION}" EQUAL 4 AND "${VTK_MINOR_VERSION}" EQUAL 4 AND "${VTK_BUILD_VERSION}" LESS 3)
58       # Include the VTK library since we know this is going to work
59       INCLUDE(${VTK_USE_FILE})
60
61       INCLUDE_DIRECTORIES(
62         ${GDCM_SOURCE_DIR}/vtk/
63       )
64       SET(TEST_SOURCES ${TEST_SOURCES}
65         VTKTestRead.cxx
66         VTKTestReadSeq.cxx
67         VTKTestWrite.cxx
68         VTKTestWriteSeq.cxx
69       )
70     ENDIF("${VTK_MAJOR_VERSION}" LESS 4)
71   ENDIF(GDCM_VTK)
72 ENDIF (GDCM_DATA_ROOT)
73
74
75
76 # include stuff
77 INCLUDE_DIRECTORIES(
78   ${GDCM_SOURCE_DIR}/src/
79   ${GDCM_BINARY_DIR}/
80 )
81
82 CREATE_TEST_SOURCELIST(Tests gdcmTests.cxx ${TEST_SOURCES})
83 ADD_EXECUTABLE(gdcmTests ${Tests})
84 IF(GDCM_VTK)
85   TARGET_LINK_LIBRARIES(gdcmTests vtkgdcm vtkRendering)
86 ELSE(GDCM_VTK)
87   TARGET_LINK_LIBRARIES(gdcmTests gdcm)
88 ENDIF(GDCM_VTK)
89
90 SET (TestsToRun ${Tests})
91 REMOVE (TestsToRun gdcmTests.cxx)
92
93 # Loop over files and create executables
94 FOREACH(file ${TEST_SOURCES})
95   GET_FILENAME_COMPONENT(name ${file} NAME_WE)
96   ADD_TEST(${name} ${GDCM_TESTS} ${name})
97 ENDFOREACH(file ${TEST_SOURCES})
98
99 #-----------------------------------------------------------------------------
100
101 # We need to test the reading of all dicom images in the gdcmData directory
102 # First parse this directory and extract all images
103
104 FILE(GLOB GDCM_DATA_IMAGES_GLOB
105   "${GDCM_DATA_ROOT}/*.acr"
106   "${GDCM_DATA_ROOT}/*.dcm"
107   "${GDCM_DATA_ROOT}/*.nema"
108   "${GDCM_DATA_ROOT}/*.ima"
109   )
110
111 # Black list of images known to break lots of readers (efilm, xmedcon ...):
112 SET(BLACK_LIST
113   # Multiframe Papyrus format image
114   # Just to remember this format exists, and is gdcm::File compliant
115   # (NOT gdcm::FileHelper ...)
116   # any contribution is welcome
117   "PET-cardio-Multiframe-Papyrus.dcm"
118   # From David Clunie's Compresion Dataset  
119   "D_CLUNIE_CT1_JLSN.dcm"
120   "D_CLUNIE_CT1_JLSL.dcm"
121   #Not a Dicom Image, but a RT Object
122   "RS2.16.124.113534.2.3.5.0.120040728.21342.353.12747_anonimized.dcm" 
123   #Dicom MPEG image
124   "ETIAM_video_002.dcm"
125   #Something stupid occured in the code for LibIDO images.
126   #I Black list them for a while. JP
127   "gdcm-ACR-LibIDO.acr"
128   "LIBIDO-24-ACR_NEMA-Rectangle.dcm"
129   #16 Bits per pixel images with LUT 16 Bits.
130   #I wait to be 100% sure before releasing them. JP
131   "rle16sti.dcm"
132   "rle16loo.dcm"   
133   # Jasper cannot handle this image, only kakadu so far, unless you patch jasper
134   # but then it breaks other images...
135   "CT_Phillips_JPEG2K_Decompr_Problem.dcm"
136   #
137   # ------------
138   #
139   # I probabely messed up smething with the .png, .tst of
140   # the images I recently added to the Test Suite
141   # I Black list them, untill I find where is the pb.
142   "US-RGB-8-esopecho.dcm"
143   "MR_Philips_Intera_No_PrivateSequenceImplicitVR.dcm"
144   "MR_Philips_Intera_PrivateSequenceImplicitVR.dcm"
145   "MR_SIEMENS_forceLoad29-1010_29-1020.dcm"
146   )
147
148 # Create a specific list of dicom files that we know are part of a sequence
149 SET(SEQ_LIST
150   "SIEMENS_MAGNETOM-12-MONO2-FileSeq[0-9].dcm"
151   )
152
153 # Add a special test that requires dciodvfy from dicom3tools
154 INCLUDE(${GDCM_SOURCE_DIR}/CMake/FindDicom3Tools.cmake)
155
156 # This is a GLOB expression, change it into a list separated with a comma and \n
157 SET(GDCM_DATA_IMAGES)
158 SET(GDCM_DATA_SEQ_IMAGES)
159 FOREACH(filename ${GDCM_DATA_IMAGES_GLOB})
160   GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
161   IF(DCIODVFY_FOUND)
162     ADD_TEST("DCIODVFY-INPUT-${filename_temp}" "${DCIODVFY_EXECUTABLE}" "${filename}")
163     ADD_TEST("DCIODVFY-OUTPUT-${filename_temp}" "${DCIODVFY_EXECUTABLE}" "${GDCM_DATA_ROOT}/BaselineDicom/${filename_temp}")
164   ENDIF(DCIODVFY_FOUND)
165   STRING(REGEX MATCH ${filename_temp} bad_dicom ${BLACK_LIST})
166   IF(NOT bad_dicom)
167     SET(GDCM_DATA_IMAGES "${GDCM_DATA_IMAGES}\n\"${filename_temp}\",")
168     # SEQ_LIST is a regular expression:
169     STRING(REGEX MATCH ${SEQ_LIST} is_seq ${filename_temp})
170     IF(is_seq)
171       SET(GDCM_DATA_SEQ_IMAGES "${GDCM_DATA_SEQ_IMAGES}\n\"${filename_temp}\",")
172     ENDIF(is_seq)
173   ENDIF(NOT bad_dicom)
174 ENDFOREACH(filename)
175
176 # Populate GDCM_DATA_IMAGES:
177 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataImages.h"
178   "const char * const gdcmDataImages[] = { ${GDCM_DATA_IMAGES}\n0 };\n" 
179 )
180
181 # Populate GDCM_DATA_SEQ_IMAGES:
182 FILE(WRITE "${GDCM_BINARY_DIR}/gdcmDataSeqImages.h"
183   "const char * const gdcmDataSeqImages[] = { ${GDCM_DATA_SEQ_IMAGES}\n0 };\n" 
184 )
185
186 #-----------------------------------------------------------------------------
187 # Trying to solve a bizarre problem when loading shared lib if gdcm is static
188 # Therefore I disable the test when building SHAREDLIBS
189 IF(UNIX AND NOT GDCM_BUILD_SHARED_LIBS)
190   ADD_LIBRARY(dynmodule MODULE dynmodule.cxx)
191   TARGET_LINK_LIBRARIES(dynmodule gdcm)
192   ADD_EXECUTABLE(loadmodule loadmodule.cxx )
193   TARGET_LINK_LIBRARIES(loadmodule gdcm -ldl)
194   ADD_TEST(loadmodule ${CXX_TEST_PATH}/loadmodule)
195 ENDIF(UNIX AND NOT GDCM_BUILD_SHARED_LIBS)
196
197
198