File: CMakeTests.cmake

package info (click to toggle)
libhdf4 4.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 30,288 kB
  • sloc: ansic: 128,699; sh: 15,015; fortran: 12,444; java: 5,863; xml: 1,205; makefile: 790; yacc: 678; pascal: 418; perl: 360; javascript: 203; lex: 163; csh: 41
file content (380 lines) | stat: -rw-r--r-- 13,755 bytes parent folder | download | duplicates (3)
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

##############################################################################
##############################################################################
###           T E S T I N G                                                ###
##############################################################################
##############################################################################

##############################################################################
# --------------------------------------------------------------------
# Copy all the files from the test directory into the source directory
# --------------------------------------------------------------------
##############################################################################

if (HDF4_BUILD_TOOLS)
  #-- Copy all the hdfls data files from the source directory into the test directory
  set (HDF4_LS_TEST_FILES
      hdfcomp.out1.1
      hdfcomp.out1.2
      hdfed.input1
#      hdfed.out1
      hdfpack.out1.1
      hdfpack.out1.2
      hdftor8.out1
      jpeg2hdf.out1
      ristosds.input1
      ristosds.out1
  )

  #-- Copy all the hdfed data files from the source directory into the test directory
  set (HDF4_HDFED_TEST_FILES
      storm110.hdf
      ntcheck.hdf
  )

  foreach (h4_file ${HDF4_LS_TEST_FILES})
    HDFTEST_COPY_FILE("${HDF4_HDF_UTIL_SOURCE_DIR}/${h4_file}" "${PROJECT_BINARY_DIR}/${h4_file}" "hdf_util_files")
  endforeach ()

  if (WIN32 AND MSVC_VERSION LESS 1900)
    HDFTEST_COPY_FILE("${HDF4_HDF_UTIL_SOURCE_DIR}/hdfed-w.out1" "${PROJECT_BINARY_DIR}/hdfed.out1" "hdf_util_files")
  else ()
    HDFTEST_COPY_FILE("${HDF4_HDF_UTIL_SOURCE_DIR}/hdfed.out1" "${PROJECT_BINARY_DIR}/hdfed.out1" "hdf_util_files")
  endif ()

  foreach (h4_file ${HDF4_HDFED_TEST_FILES})
    HDFTEST_COPY_FILE("${HDF4_HDF_UTIL_SOURCE_DIR}/testfiles/${h4_file}" "${PROJECT_BINARY_DIR}/${h4_file}" "hdf_util_files")
  endforeach ()
endif ()

#-- Copy all the hdf2gif data files from the source directory into the test directory
set (HDF4_HDF2GIF_TEST_FILES
    skull.hdf
)

#-- Copy all the gif2hdf data files from the source directory into the test directory
set (HDF4_GIF2HDF_TEST_FILES
    SunWheel.gif
    bttrfly.gif
)

#-- Copy all the hdftor8 data files from the source directory into the test directory
set (HDF4_HDFTOR8_TEST_FILES
    head.r24
    head.r8
)

#-- Copy all the ristosds data files from the source directory into the test directory
set (HDF4_RISTOSDS_TEST_FILES
    storm110.hdf
    storm120.hdf
    storm130.hdf
)

#-- Copy all the hdfpack data files from the source directory into the test directory
set (HDF4_HDFPACK_TEST_FILES
    test.hdf
)

#-- Copy all the paltohdf data files from the source directory into the test directory
set (HDF4_PALTOHDF_TEST_FILES
    palette.raw
)

#-- Copy all the r8tohdf data files from the source directory into the test directory
set (HDF4_R8TOHDF_TEST_FILES
    storm110.raw
    storm120.raw
    storm130.raw
    storm140.raw
)

#-- Copy all the hdfcomp data files from the source directory into the test directory
set (HDF4_HDFCOMP_TEST_FILES
    storm110.hdf
    storm120.hdf
    storm130.hdf
)

#-- Copy all the jpeg2hdf data files from the source directory into the test directory
set (HDF4_JPEG2HDF_TEST_FILES
    jpeg_img.jpg
)

foreach (h4_file
      ${HDF4_HDF2GIF_TEST_FILES}
      ${HDF4_GIF2HDF_TEST_FILES}
      ${HDF4_HDFTOR8_TEST_FILES}
      ${HDF4_RISTOSDS_TEST_FILES}
      ${HDF4_HDFPACK_TEST_FILES}
      ${HDF4_PALTOHDF_TEST_FILES}
      ${HDF4_R8TOHDF_TEST_FILES}
      ${HDF4_HDFCOMP_TEST_FILES}
      ${HDF4_JPEG2HDF_TEST_FILES}
)
  HDFTEST_COPY_FILE("${HDF4_HDF_UTIL_SOURCE_DIR}/testfiles/${h4_file}" "${PROJECT_BINARY_DIR}/${h4_file}" "hdf_util_files")
endforeach ()

add_custom_target(hdf_util_files ALL COMMENT "Copying files needed by hdf_util tests" DEPENDS ${hdf_util_files_list})

##############################################################################
##############################################################################
###           T H E   T E S T S  M A C R O S                               ###
##############################################################################
##############################################################################

if (HDF4_BUILD_TOOLS)
  macro (ADD_LS_TEST_NOL testfile resultfile resultcode)
    if (HDF4_USING_ANALYSIS_TOOL)
      add_test (NAME HDFLS_NOL-${testfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:hdfls> ${testfile})
    else ()
      add_test (
          NAME HDFLS_NOL-${testfile}
          COMMAND "${CMAKE_COMMAND}"
              -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
              -D "TEST_PROGRAM=$<TARGET_FILE:hdfls>"
              -D "TEST_ARGS:STRING=${testfile}"
              -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
              -D "TEST_OUTPUT=${testfile}.tmp"
              -D "TEST_EXPECT=${resultcode}"
              -D "TEST_FILTER:STRING=(File library|String)[^\n]+\n"
              -D "TEST_REFERENCE=${resultfile}"
              -P "${HDF_RESOURCES_DIR}/runTest.cmake"
      )
    endif ()
    if (NOT "${last_test}" STREQUAL "")
      set_tests_properties (HDFLS_NOL-${testfile} PROPERTIES DEPENDS ${last_test} LABELS ${PROJECT_NAME})
    else ()
      set_tests_properties (HDFLS_NOL-${testfile} PROPERTIES LABELS ${PROJECT_NAME})
    endif ()
    set (last_test "HDFLS_NOL-${testfile}")
  endmacro ()

  macro (ADD_LS_TEST testfile resultfile resultcode)
    if (HDF4_USING_ANALYSIS_TOOL)
      add_test (NAME HDFLS-${testfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:hdfls> -l ${testfile})
    else ()
      add_test (
          NAME HDFLS-${testfile}
          COMMAND "${CMAKE_COMMAND}"
              -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
              -D "TEST_PROGRAM=$<TARGET_FILE:hdfls>"
              -D "TEST_ARGS:STRING=-l;${testfile}"
              -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
              -D "TEST_OUTPUT=${testfile}.tmp"
              -D "TEST_EXPECT=${resultcode}"
              -D "TEST_FILTER:STRING=(File library|String)[^\n]+\n"
              -D "TEST_REFERENCE=${resultfile}"
              -P "${HDF_RESOURCES_DIR}/runTest.cmake"
      )
    endif ()
    if (NOT "${last_test}" STREQUAL "")
      set_tests_properties (HDFLS-${testfile} PROPERTIES DEPENDS ${last_test} LABELS ${PROJECT_NAME})
    else ()
      set_tests_properties (HDFLS-${testfile} PROPERTIES LABELS ${PROJECT_NAME})
    endif ()
    set (last_test "HDFLS-${testfile}")
  endmacro ()

  macro (ADD_H4_TEST_ED testfile resultfile resultcode)
    if (HDF4_USING_ANALYSIS_TOOL)
      add_test (NAME HEDIT-${testfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:hdfed> -batch)
    else ()
      add_test (
          NAME HEDIT-${testfile}
          COMMAND "${CMAKE_COMMAND}"
              -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
              -D "TEST_PROGRAM=$<TARGET_FILE:hdfed>"
              -D "TEST_ARGS:STRING=-batch"
              -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
              -D "TEST_INPUT=${testfile}"
              -D "TEST_OUTPUT=${testfile}.tmp"
              -D "TEST_EXPECT=${resultcode}"
              -D "TEST_REFERENCE=${resultfile}"
              -P "${HDF_RESOURCES_DIR}/runTest.cmake"
      )
    endif ()
    if (NOT "${last_test}" STREQUAL "")
      set_tests_properties (HEDIT-${testfile} PROPERTIES DEPENDS ${last_test} LABELS ${PROJECT_NAME})
    else ()
      set_tests_properties (HEDIT-${testfile} PROPERTIES LABELS ${PROJECT_NAME})
    endif ()
    set (last_test "HEDIT-${testfile}")
  endmacro ()
endif ()

macro (ADD_H4_TEST testname testfile)
  add_test (NAME ${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:${testfile}> ${ARGN})
  if (NOT "${last_test}" STREQUAL "")
    set_tests_properties (${testname} PROPERTIES DEPENDS ${last_test} LABELS ${PROJECT_NAME})
  else ()
    set_tests_properties (${testname} PROPERTIES LABELS ${PROJECT_NAME})
  endif ()
  set (last_test "${testname}")
endmacro ()

macro (ADD_CMP_TEST testname reffile testfile)
  add_test (NAME ${testname} COMMAND ${CMAKE_COMMAND} -E compare_files ${reffile} ${testfile})
  if (NOT "${last_test}" STREQUAL "")
    set_tests_properties (${testname} PROPERTIES DEPENDS ${last_test} LABELS ${PROJECT_NAME})
  else ()
    set_tests_properties (${testname} PROPERTIES LABELS ${PROJECT_NAME})
  endif ()
  set (last_test "${testname}")
endmacro ()

macro (ADD_H4Q_TEST testname testfile)
  add_test (NAME ${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:${testfile}> ${ARGN} > /dev/null 2>&1)
  if (NOT "${last_test}" STREQUAL "")
    set_tests_properties (${testname} PROPERTIES DEPENDS ${last_test} LABELS ${PROJECT_NAME})
  else ()
    set_tests_properties (${testname} PROPERTIES LABELS ${PROJECT_NAME})
  endif ()
  set (last_test "${testname}")
endmacro ()

##############################################################################
##############################################################################
###           T H E   T E S T S                                            ###
##############################################################################
##############################################################################

# Remove any output file left over from previous test run
add_test (
    NAME hdfgif-clear-refs
    COMMAND ${CMAKE_COMMAND} -E remove
        skull.gif
        SunWheel.hdf
        bttrfly.hdf
        head8.hdf
        img001-263.328
        storm.hdf
)
if (NOT "${last_test}" STREQUAL "")
  set_tests_properties (hdfgif-clear-refs PROPERTIES DEPENDS ${last_test} LABELS ${PROJECT_NAME})
else ()
  set_tests_properties (hdfgif-clear-refs PROPERTIES LABELS ${PROJECT_NAME})
endif ()
set (last_test "hdfgif-clear-refs")

ADD_H4_TEST (testhdf2gif hdf2gif skull.hdf skull.gif)
ADD_H4_TEST (testgif2hdf-sunwheel gif2hdf SunWheel.gif SunWheel.hdf)
ADD_H4_TEST (testgif2hdf-butterfly gif2hdf bttrfly.gif bttrfly.hdf)

ADD_H4_TEST (testhdf24to8 hdf24to8 head.r24 head8.hdf)
ADD_H4_TEST (testhdftor8 hdftor8 head8.hdf)
ADD_CMP_TEST (hdfr8comp img001-263.328 head.r8)

if (HDF4_BUILD_TOOLS)
  ADD_H4_TEST_ED (hdfed.input1 hdfed.out1 0)
endif ()

ADD_H4Q_TEST (testristosds ristosds storm110.hdf storm120.hdf storm130.hdf -o storm.hdf)
if (HDF4_BUILD_TOOLS)
  ADD_H4_TEST_ED (ristosds.input1 ristosds.out1 0)
endif ()

# Remove any output file left over from previous test run
add_test (
    NAME hdfpack-clear-refs
    COMMAND ${CMAKE_COMMAND} -E remove
        test.pck
        test.blk
)
if (NOT "${last_test}" STREQUAL "")
  set_tests_properties (hdfpack-clear-refs PROPERTIES DEPENDS ${last_test} LABELS ${PROJECT_NAME})
else ()
  set_tests_properties (hdfpack-clear-refs PROPERTIES LABELS ${PROJECT_NAME})
endif ()
set (last_test "hdfpack-clear-refs")

ADD_H4_TEST (testhdfpack hdfpack test.hdf test.pck)
ADD_H4_TEST (testhdfpack-block hdfpack -b test.hdf test.blk)
if (HDF4_BUILD_TOOLS)
  ADD_LS_TEST_NOL (test.hdf hdfpack.out1.1 0)
  ADD_LS_TEST_NOL (test.pck hdfpack.out1.2 0)
endif ()

# Remove any output file left over from previous test run
add_test (
    NAME hdfpalette-clear-refs
    COMMAND ${CMAKE_COMMAND} -E remove
        pal001
        pal005
        palette.hdf
        palette.raw.new
        storm.hdf
        storm.hdf.tmp
        storm.hdf.tmp.err
        img001-057.057
        img002-057.057
        img003-057.057
        img004-057.057
        img005-057.057
        allstorms.hdf
        allstorms.hdf.tmp
        allstorms.hdf.tmp.err
        allcomp.hdf
        allcomp.hdf.tmp
        allcomp.hdf.tmp.err
)
if (NOT "${last_test}" STREQUAL "")
  set_tests_properties (hdfpalette-clear-refs PROPERTIES DEPENDS ${last_test} LABELS ${PROJECT_NAME})
else ()
  set_tests_properties (hdfpalette-clear-refs PROPERTIES LABELS ${PROJECT_NAME})
endif ()
set (last_test "hdfpalette-clear-refs")

ADD_H4_TEST (testpaltohdf paltohdf palette.raw palette.hdf)
ADD_H4_TEST (testhdftopal hdftopal palette.hdf palette.raw.new)
ADD_CMP_TEST (palettecomp palette.raw palette.raw.new)

ADD_H4_TEST (testr8tohdf-storm r8tohdf 57 57 storm.hdf storm110.raw storm120.raw storm130.raw storm140.raw)
ADD_H4_TEST (testr8tohdf-palette r8tohdf 57 57 storm.hdf -p palette.raw -i storm110.raw)
ADD_H4_TEST (testhdftor8-storm hdftor8 storm.hdf)
if (HDF4_BUILD_TOOLS)
  ADD_LS_TEST (storm.hdf hdftor8.out1 0)
endif ()

ADD_CMP_TEST (storm110comp img001-057.057  storm110.raw)
ADD_CMP_TEST (storm120comp img002-057.057  storm120.raw)
ADD_CMP_TEST (storm130comp img003-057.057  storm130.raw)
ADD_CMP_TEST (storm140comp img004-057.057  storm140.raw)

ADD_H4_TEST (testhdfcomp-storms hdfcomp allstorms.hdf storm110.hdf storm120.hdf storm130.hdf)
ADD_H4_TEST (testhdfcomp hdfcomp allcomp.hdf -c storm110.hdf storm120.hdf storm130.hdf)
if (HDF4_BUILD_TOOLS)
  ADD_LS_TEST (allstorms.hdf hdfcomp.out1.1 0)
  ADD_LS_TEST (allcomp.hdf hdfcomp.out1.2 0)
endif ()

# Remove any output file left over from previous test run
add_test (
    NAME hdfjpeg-clear-refs
    COMMAND ${CMAKE_COMMAND} -E remove
        jpeg.hdf
        jpeg.hdf.tmp
        jpeg.hdf.tmp.err
        jpeg2.jpg
)
if (NOT "${last_test}" STREQUAL "")
  set_tests_properties (hdfjpeg-clear-refs PROPERTIES DEPENDS ${last_test} LABELS ${PROJECT_NAME})
else ()
  set_tests_properties (hdfjpeg-clear-refs PROPERTIES LABELS ${PROJECT_NAME})
endif ()
set (last_test "hdfjpeg-clear-refs")

ADD_H4_TEST (testjpeg2hdf jpeg2hdf jpeg_img.jpg jpeg.hdf)
ADD_H4_TEST (testhdf2jpeg hdf2jpeg jpeg.hdf jpeg2.jpg)
if (HDF4_BUILD_TOOLS)
  ADD_LS_TEST (jpeg.hdf jpeg2hdf.out1 0)
endif ()
ADD_CMP_TEST (jpeg2comp jpeg_img.jpg jpeg2.jpg)

#ADD_H4_TEST (hdf8to24 hdf8to24)

#ADD_H4_TEST (hdfunpac hdfunpac)

#ADD_H4_TEST (vmake vmake)

#ADD_H4_TEST (vshow vshow)