summaryrefslogtreecommitdiffstats
path: root/tools/h5import/CMakeTests.cmake
blob: d1f1681536043a21a9cecea94f5c6f4f9a7b4047 (plain)
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

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

  set (HDF5_REFERENCE_CONF_FILES
      binfp64.conf
      binin8.conf
      binin8w.conf
      binin16.conf
      binin32.conf
      binuin16.conf
      binuin32.conf
      txtfp32.conf
      txtfp64.conf
      txtin8.conf
      txtin16.conf
      txtin32.conf
      txtuin16.conf
      txtuin32.conf
      textpfe.conf
      txtstr.conf
  )
  set (HDF5_REFERENCE_TXT_FILES
      txtfp32.txt
      txtfp64.txt
      txtuin16.txt
      txtuin32.txt
      txtin8.txt
      txtin16.txt
      txtin32.txt
      textpfe64.txt
      txtstr.txt
      dbinfp64.h5.txt
      dbinin8.h5.txt
      dbinin8w.h5.txt
      dbinin16.h5.txt
      dbinin32.h5.txt
      dbinuin16.h5.txt
      dbinuin32.h5.txt
      dtxtstr.h5.txt
  )
  set (HDF5_REFERENCE_TEST_FILES
      binfp64.h5
      binin8.h5
      binin8w.h5
      binin16.h5
      binin32.h5
      binuin16.h5
      binuin32.h5
      txtfp32.h5
      txtfp64.h5
      txtin8.h5
      txtin16.h5
      txtin32.h5
      txtuin16.h5
      txtuin32.h5
      txtstr.h5
      textpfe.h5
  )

  file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles")
  foreach (conf_file ${HDF5_REFERENCE_CONF_FILES})
    HDFTEST_COPY_FILE("${HDF5_TOOLS_H5IMPORT_SOURCE_DIR}/testfiles/${conf_file}" "${PROJECT_BINARY_DIR}/testfiles/${conf_file}" "h5import_files")
  endforeach ()

  foreach (txt_file ${HDF5_REFERENCE_TXT_FILES})
    HDFTEST_COPY_FILE("${HDF5_TOOLS_H5IMPORT_SOURCE_DIR}/testfiles/${txt_file}" "${PROJECT_BINARY_DIR}/testfiles/${txt_file}" "h5import_files")
  endforeach ()

  foreach (h5_file ${HDF5_REFERENCE_TEST_FILES})
    HDFTEST_COPY_FILE("${HDF5_TOOLS_H5IMPORT_SOURCE_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/testfiles/${h5_file}" "h5import_files")
  endforeach ()
  add_custom_target(h5import_files ALL COMMENT "Copying files needed by h5import tests" DEPENDS ${h5import_files_list})

##############################################################################
##############################################################################
###           T H E   T E S T S  M A C R O S                               ###
##############################################################################
##############################################################################
  MACRO (ADD_H5_TEST testname importfile conffile testfile)
    # If using memchecker skip macro based tests
    if (HDF5_ENABLE_USING_MEMCHECKER)
      add_test (NAME H5IMPORT-${testname} COMMAND $<TARGET_FILE:h5import> ${importfile} -c ${conffile} -o ${testfile})
      if (NOT "${last_test}" STREQUAL "")
        set_tests_properties (H5IMPORT-${testname} PROPERTIES DEPENDS H5IMPORT-h5importtest)
      endif ()
    else ()
      add_test (
          NAME H5IMPORT-${testname}-clear-objects
          COMMAND    ${CMAKE_COMMAND}
              -E remove
              ${testfile}
              ${testfile}.new
              ${testfile}.new.err
              ${testfile}.out
              ${testfile}.out.err
      )
      set_tests_properties (H5IMPORT-${testname}-clear-objects PROPERTIES DEPENDS H5IMPORT-h5importtest)

      add_test (NAME H5IMPORT-${testname} COMMAND $<TARGET_FILE:h5import> ${importfile} -c ${conffile} -o ${testfile})
      set_tests_properties (H5IMPORT-${testname} PROPERTIES DEPENDS H5IMPORT-${testname}-clear-objects)

      add_test (
          NAME H5IMPORT-${testname}-H5DMP
          COMMAND "${CMAKE_COMMAND}"
              -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>"
              -D "TEST_ARGS:STRING=${testfile}"
              -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
              -D "TEST_OUTPUT=${testfile}.new"
              -D "TEST_EXPECT=0"
              -D "TEST_FILTER=(^(HDF5)[^\n]*)"
              -D "TEST_SKIP_COMPARE=TRUE"
              -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
      )
      set_tests_properties (H5IMPORT-${testname}-H5DMP PROPERTIES DEPENDS H5IMPORT-${testname})
      add_test (
          NAME H5IMPORT-${testname}-H5DMP_CMP
          COMMAND "${CMAKE_COMMAND}"
              -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>"
              -D "TEST_ARGS:STRING=testfiles/${testfile}"
              -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
              -D "TEST_OUTPUT=${testfile}.out"
              -D "TEST_EXPECT=0"
              -D "TEST_FILTER=(^(HDF5)[^\n]*)"
              -D "TEST_REFERENCE=${testfile}.new"
              -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
      )
      set_tests_properties (H5IMPORT-${testname}-H5DMP_CMP PROPERTIES DEPENDS H5IMPORT-${testname}-H5DMP)
    endif ()
  ENDMACRO ()

  MACRO (ADD_H5_DUMPTEST testname datasetname testfile)
    # If using memchecker skip tests
    if (NOT HDF5_ENABLE_USING_MEMCHECKER)
      add_test (
          NAME H5IMPORT-DUMP-${testname}-clear-objects
          COMMAND    ${CMAKE_COMMAND}
              -E remove
              d${testfile}
              d${testfile}.bin
              d${testfile}.imp
              d${testfile}.imp.err
              d${testfile}.dmp
              d${testfile}.dmp.err
              d${testfile}.dff
              d${testfile}.dff.err
      )
      set_tests_properties (H5IMPORT-DUMP-${testname}-clear-objects PROPERTIES DEPENDS H5IMPORT-h5importtest)

      if ("${ARGN}" STREQUAL "BINARY")
        add_test (
            NAME H5IMPORT-DUMP-${testname}-H5DMP
            COMMAND "${CMAKE_COMMAND}"
                -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>"
                -D "TEST_ARGS:STRING=-p;-d;${datasetname};-o;d${testfile}.bin;-b;testfiles/${testfile}"
                -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
                -D "TEST_OUTPUT=d${testfile}.dmp"
                -D "TEST_EXPECT=0"
                -D "TEST_SKIP_COMPARE=TRUE"
                -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
        )
      else ()
        add_test (
            NAME H5IMPORT-DUMP-${testname}-H5DMP
            COMMAND "${CMAKE_COMMAND}"
                -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>"
                -D "TEST_ARGS:STRING=-p;-d;${datasetname};-o;d${testfile}.bin;-y;--width=1;testfiles/${testfile}"
                -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
                -D "TEST_OUTPUT=d${testfile}.dmp"
                -D "TEST_EXPECT=0"
                -D "TEST_SKIP_COMPARE=TRUE"
                -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
        )
      endif ()
      set_tests_properties (H5IMPORT-DUMP-${testname}-H5DMP PROPERTIES DEPENDS "H5IMPORT-DUMP-${testname}-clear-objects")

      add_test (
          NAME H5IMPORT-DUMP-${testname}
          COMMAND "${CMAKE_COMMAND}"
              -D "TEST_PROGRAM=$<TARGET_FILE:h5import>"
              -D "TEST_ARGS:STRING=d${testfile}.bin;-c;d${testfile}.dmp;-o;d${testfile}"
              -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
              -D "TEST_OUTPUT=d${testfile}.imp"
              -D "TEST_EXPECT=0"
              -D "TEST_SKIP_COMPARE=TRUE"
              -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
      )
      set_tests_properties (H5IMPORT-DUMP-${testname} PROPERTIES DEPENDS "H5IMPORT-DUMP-${testname}-H5DMP")

      add_test (
          NAME H5IMPORT-DUMP-${testname}-H5DFF
          COMMAND "${CMAKE_COMMAND}"
              -D "TEST_PROGRAM=$<TARGET_FILE:h5diff>"
              -D "TEST_ARGS:STRING=-r;d${testfile};testfiles/${testfile};${datasetname};${datasetname}"
              -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
              -D "TEST_OUTPUT=d${testfile}.dff"
              -D "TEST_EXPECT=0"
              -D "TEST_FILTER=(^(Warning)[^\n]*)"
              -D "TEST_REFERENCE=testfiles/d${testfile}.txt"
              -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
      )
      set_tests_properties (H5IMPORT-DUMP-${testname}-H5DFF PROPERTIES DEPENDS "H5IMPORT-DUMP-${testname}")
    endif ()
  ENDMACRO ()

  MACRO (ADD_H5_SKIP_DUMPTEST testname datasetname testfile)
    if (NOT HDF5_ENABLE_USING_MEMCHECKER)
      add_test (
          NAME H5IMPORT-DUMP-${testname}-SKIPPED
          COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${testname} ${datasetname} ${testfile} --- DEFLATE filter not available"
      )
    endif ()
  ENDMACRO ()

  # --------------------------------------------------------------------
  # Determine if filter is available for h5diff
  # --------------------------------------------------------------------
  if (H5_HAVE_FILTER_DEFLATE)
    set (USE_FILTER_DEFLATE "true")
  endif ()

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

  if (HDF5_ENABLE_USING_MEMCHECKER)
    # Remove any output file left over from previous test run
    add_test (
        NAME H5IMPORT-clear-objects
        COMMAND    ${CMAKE_COMMAND}
            -E remove
            binfp64.bin
            binin8.bin
            binin8w.bin
            binin16.bin
            binin32.bin
            binuin16.bin
            binuin32.bin
            txtin32.h5
            txtin32.h5.new
            txtin32.h5.new.err
            txtin32.h5.out
            txtin32.h5.out.err
            txtin16.h5
            txtin16.h5.new
            txtin16.h5.new.err
            txtin16.h5.out
            txtin16.h5.out.err
            txtin8.h5
            txtin8.h5.new
            txtin8.h5.new.err
            txtin8.h5.out
            txtin8.h5.out.err
            txtuin16.h5
            txtuin16.h5.new
            txtuin16.h5.new.err
            txtuin16.h5.out
            txtuin16.h5.out.err
            txtuin32.h5
            txtuin32.h5.new
            txtuin32.h5.new.err
            txtuin32.h5.out
            txtuin32.h5.out.err
            txtfp32.h5
            txtfp32.h5.new
            txtfp32.h5.new.err
            txtfp32.h5.out
            txtfp32.h5.out.err
            txtfp64.h5
            txtfp64.h5.new
            txtfp64.h5.new.err
            txtfp64.h5.out
            txtfp64.h5.out.err
            binfp64.h5
            binfp64.h5.new
            binfp64.h5.new.err
            binfp64.h5.out
            binfp64.h5.out.err
            binin8.h5
            binin8.h5.new
            binin8.h5.new.err
            binin8.h5.out
            binin8.h5.out.err
            binin8w.h5
            binin8w.h5.new
            binin8w.h5.new.err
            binin8w.h5.out
            binin8w.h5.out.err
            binin16.h5
            binin16.h5.new
            binin16.h5.new.err
            binin16.h5.out
            binin16.h5.out.err
            binin32.h5
            binin32.h5.new
            binin32.h5.new.err
            binin32.h5.out
            binin32.h5.out.err
            binuin16.h5
            binuin16.h5.new
            binuin16.h5.new.err
            binuin16.h5.out
            binuin16.h5.out.err
            binuin32.h5
            binuin32.h5.new
            binuin32.h5.new.err
            binuin32.h5.out
            binuin32.h5.out.err
            txtstr.h5
            txtstr.h5.new
            txtstr.h5.new.err
            txtstr.h5.out
            txtstr.h5.out.err
            textpfe.h5
            textpfe.h5.new
            textpfe.h5.new.err
            textpfe.h5.out
            textpfe.h5.out.err
            dbinfp64.h5
            dbinfp64.h5.bin
            dbinfp64.h5.imp
            dbinfp64.h5.imp.err
            dbinfp64.h5.dmp
            dbinfp64.h5.dmp.err
            dbinfp64.h5.dff
            dbinfp64.h5.dff.err
            dbinin8.h5
            dbinin8.h5.bin
            dbinin8.h5.imp
            dbinin8.h5.imp.err
            dbinin8.h5.dmp
            dbinin8.h5.dmp.err
            dbinin8.h5.dff
            dbinin8.h5.dff.err
            dbinin8w.h5
            dbinin8w.h5.bin
            dbinin8w.h5.imp
            dbinin8w.h5.imp.err
            dbinin8w.h5.dmp
            dbinin8w.h5.dmp.err
            dbinin8w.h5.dff
            dbinin8w.h5.dff.err
            dbinin16.h5
            dbinin16.h5.bin
            dbinin16.h5.imp
            dbinin16.h5.imp.err
            dbinin16.h5.dmp
            dbinin16.h5.dmp.err
            dbinin16.h5.dff
            dbinin16.h5.dff.err
            dbinin32.h5
            dbinin32.h5.bin
            dbinin32.h5.imp
            dbinin32.h5.imp.err
            dbinin32.h5.dmp
            dbinin32.h5.dmp.err
            dbinin32.h5.dff
            dbinin32.h5.dff.err
            dbinuin16.h5
            dbinuin16.h5.bin
            dbinuin16.h5.imp
            dbinuin16.h5.imp.err
            dbinuin16.h5.dmp
            dbinuin16.h5.dmp.err
            dbinuin16.h5.dff
            dbinuin16.h5.dff.err
            dbinuin32.h5
            dbinuin32.h5.bin
            dbinuin32.h5.imp
            dbinuin32.h5.imp.err
            dbinuin32.h5.dmp
            dbinuin32.h5.dmp.err
            dbinuin32.h5.dff
            dbinuin32.h5.dff.err
            dtxtstr.h5
            dtxtstr.h5.bin
            dtxtstr.h5.imp
            dtxtstr.h5.imp.err
            dtxtstr.h5.dmp
            dtxtstr.h5.dmp.err
            dtxtstr.h5.dff
            dtxtstr.h5.dff.err
    )
    set (last_test "H5IMPORT-clear-objects")
  endif ()

  add_test (
      NAME H5IMPORT-h5importtest-clear-objects
      COMMAND    ${CMAKE_COMMAND}
          -E remove
          binfp64.bin
          binin8.bin
          binin8w.bin
          binin16.bin
          binin32.bin
          binuin16.bin
          binuin32.bin
  )
  if (NOT "${last_test}" STREQUAL "")
    set_tests_properties (H5IMPORT-h5importtest-clear-objects PROPERTIES DEPENDS ${last_test})
  endif ()
  set (last_test "H5IMPORT-clear-objects")

  add_test (NAME H5IMPORT-h5importtest COMMAND $<TARGET_FILE:h5importtest>)
  set_tests_properties (H5IMPORT-h5importtest PROPERTIES DEPENDS H5IMPORT-h5importtest-clear-objects)

  # ----- TESTING "ASCII I32 rank 3 - Output BE " ;
  ADD_H5_TEST (ASCII_I32 testfiles/txtin32.txt testfiles/txtin32.conf txtin32.h5)

  # ----- TESTING "ASCII I16 rank 3 - Output LE - CHUNKED - extended"
  ADD_H5_TEST (ASCII_I16 testfiles/txtin16.txt testfiles/txtin16.conf txtin16.h5)

  # ----- TESTING "ASCII I8 - rank 3 - Output I8 LE-Chunked+Extended+Compressed "
  ADD_H5_TEST (ASCII_I8 testfiles/txtin8.txt testfiles/txtin8.conf txtin8.h5)

  # ----- TESTING "ASCII UI16 - rank 2 - Output LE+Chunked+Compressed "
  ADD_H5_TEST (ASCII_UI16 testfiles/txtuin16.txt testfiles/txtuin16.conf txtuin16.h5)

  # ----- TESTING "ASCII UI32 - rank 3 - Output BE"
  ADD_H5_TEST (ASCII_UI32 testfiles/txtuin32.txt testfiles/txtuin32.conf txtuin32.h5)

  # ----- TESTING "ASCII F32 - rank 3 - Output LE "
  ADD_H5_TEST (ASCII_F32 testfiles/txtfp32.txt testfiles/txtfp32.conf txtfp32.h5)

  # ----- TESTING "ASCII F64 - rank 3 - Output BE + CHUNKED+Extended+Compressed "
  ADD_H5_TEST (ASCII_F64 testfiles/txtfp64.txt testfiles/txtfp64.conf txtfp64.h5)

  # ----- TESTING "BINARY F64 - rank 3 - Output LE+CHUNKED+Extended+Compressed "
  ADD_H5_TEST (BINARY_F64 binfp64.bin testfiles/binfp64.conf binfp64.h5)
  if (NOT USE_FILTER_DEFLATE)
    ADD_H5_SKIP_DUMPTEST (BINARY_F64 "/fp/bin/64-bit" binfp64.h5 BINARY)
  else (NOT USE_FILTER_DEFLATE)
    ADD_H5_DUMPTEST (BINARY_F64 "/fp/bin/64-bit" binfp64.h5 BINARY)
  endif (NOT USE_FILTER_DEFLATE)

  # ----- TESTING "BINARY I8 - rank 3 - Output I16LE + Chunked+Extended+Compressed "
  ADD_H5_TEST (BINARY_I8 binin8.bin testfiles/binin8.conf binin8.h5)
  if (NOT USE_FILTER_DEFLATE)
    ADD_H5_SKIP_DUMPTEST (BINARY_I8 "/int/bin/8-bit" binin8.h5 BINARY)
  else (NOT USE_FILTER_DEFLATE)
    ADD_H5_DUMPTEST (BINARY_I8 "/int/bin/8-bit" binin8.h5 BINARY)
  endif (NOT USE_FILTER_DEFLATE)

  # ----- TESTING "BINARY I16 - rank 3 - Output order LE + CHUNKED + extended "
  ADD_H5_TEST (BINARY_I16 binin16.bin testfiles/binin16.conf binin16.h5)
  ADD_H5_DUMPTEST (BINARY_I16 "/int/bin/16-bit" binin16.h5 BINARY)

  # ----- TESTING "BINARY I32 - rank 3 - Output BE + CHUNKED "
  ADD_H5_TEST (BINARY_I32 binin32.bin testfiles/binin32.conf binin32.h5)
  ADD_H5_DUMPTEST (BINARY_I32 "/int/bin/32-bit" binin32.h5 BINARY)

  # ----- TESTING "BINARY UI16 - rank 3 - Output byte BE + CHUNKED "
  ADD_H5_TEST (BINARY_UI16 binuin16.bin testfiles/binuin16.conf binuin16.h5)
  ADD_H5_DUMPTEST (BINARY_UI16 "/int/buin/16-bit" binuin16.h5 BINARY)

  # ----- TESTING "BINARY UI32 - rank 3 - Output LE "
  ADD_H5_TEST (BINARY_UI32 binuin32.bin testfiles/binuin32.conf binuin32.h5)
  ADD_H5_DUMPTEST (BINARY_UI32 "/int/buin/32-bit" binuin32.h5 BINARY)

  # ----- TESTING "STR"
  ADD_H5_TEST (STR testfiles/txtstr.txt testfiles/txtstr.conf txtstr.h5)
  ADD_H5_DUMPTEST (STR "/mytext/data" txtstr.h5)

  # ----- TESTING "BINARY I8 CR LF EOF"
  ADD_H5_TEST (BINARY_I8_EOF binin8w.bin testfiles/binin8w.conf binin8w.h5)
  ADD_H5_DUMPTEST (BINARY_I8_EOF "/dataset0" binin8w.h5 BINARY)

  # ----- TESTING "ASCII F64 - rank 1 - INPUT-CLASS TEXTFPE "
  ADD_H5_TEST (ASCII_F64_R1 testfiles/textpfe64.txt testfiles/textpfe.conf textpfe.h5)