cmake_minimum_required(VERSION 3.2.2) PROJECT (H4H5_UTILS_TEST C CXX) #-- Copy all the data files from the test directory into the source directory set (H4H5_TEST_FILES vg_all_test.hdf tstr2.h5 tall.h5 ) # Test script for the h4toh5 tests. # # Using the h4toh5 convert to convert a pre-created hdf file to an hdf5 # file (output file), then compare it with a pre-created corresponding # hdf5 file (expected file). If the same, that particular test passes. # If not the same, the output file and expected file are processed by # the h5dump tool to see if they produce the same results. If the same, # the test passes. If not, show the difference of the two results and # report the test failed. # set (H5SZIP HDF_ENABLE_SZIP_SUPPORT) set (H5SZIP_ENCODE HDF_ENABLE_SZIP_ENCODING) set (H5ZLIB HDF_ENABLE_Z_LIB_SUPPORT) set (H4SZIP HDF_ENABLE_SZIP_SUPPORT) # The converter assumes all hdf4 files has the .hdf suffix as in the form # of foo.hdf. It creates the corresponding hdf5 files with the .h5 suffix # as in the form of foo.h5. One exception is that if exactly two file # names are given, it treats the first argument as an hdf4 file and creates # the corresponding hdf5 file with the name as the second argument, WITOUT # any consideration of the suffix. (For this test script, in order to # match the output hdf5 file with the expected hdf5 file, it expects the # second file of the two-files tests has the .h5 suffix too.) # MACRO (ADD_H4H5_TEST testfile) add_test ( NAME H4H5convert_CLEAR-${testfile} COMMAND ${CMAKE_COMMAND} -E remove ${PROJECT_BINARY_DIR}/${testfile}.h5 ) if (NOT "${last_test}" STREQUAL "") set_tests_properties (H4H5convert_CLEAR-${testfile} PROPERTIES DEPENDS ${last_test}) endif () add_test ( NAME H4H5convert_COPY-${testfile} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${H4H5_UTILS_TEST_SOURCE_DIR}/${testfile}.hdf ${PROJECT_BINARY_DIR}/${testfile}.hdf ) set_tests_properties (H4H5convert_COPY-${testfile} PROPERTIES DEPENDS H4H5convert_CLEAR-${testfile}) add_test ( NAME H4H5convert-${testfile} COMMAND ${H4H5_45CONVERT_EXECUTABLE} ${ARGN} ${H4H5_UTILS_TEST_SOURCE_DIR}/${testfile}.hdf ${PROJECT_BINARY_DIR}/${testfile}.h5 ) set_tests_properties (H4H5convert-${testfile} PROPERTIES DEPENDS H4H5convert_COPY-${testfile}) set (last_test "H4H5convert-${testfile}") ENDMACRO () # The converter assumes all hdf5 files has the .h5 suffix as in the form # of foo.h5. It creates the corresponding hdf4 files with the .hdf suffix # as in the form of foo.hdf. One exception is that if exactly two file # names are given, it treats the first argument as an hdf5 file and creates # the corresponding hdf4 file with the name as the second argument, WITOUT # any consideration of the suffix. (For this test script, in order to # match the output hdf4 file with the expected hdf4 file, it expects the # second file of the two-files tests has the .hdf suffix too.) MACRO (ADD_H5H4_TEST testfile) add_test ( NAME H5H4convert_CLEAR-${testfile} COMMAND ${CMAKE_COMMAND} -E remove ${PROJECT_BINARY_DIR}/${testfile}.hdf ) if (NOT "${last_test}" STREQUAL "") set_tests_properties (H5H4convert_CLEAR-${testfile} PROPERTIES DEPENDS ${last_test}) endif () add_test ( NAME H5H4convert_COPY-${testfile} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${H4H5_UTILS_TEST_SOURCE_DIR}/${testfile}.h5 ${PROJECT_BINARY_DIR}/${testfile}.h5 ) set_tests_properties (H5H4convert_COPY-${testfile} PROPERTIES DEPENDS H5H4convert_CLEAR-${testfile}) add_test ( NAME H5H4convert-${testfile} COMMAND ${H4H5_54CONVERT_EXECUTABLE} ${H4H5_UTILS_TEST_SOURCE_DIR}/${testfile}.h5 ${PROJECT_BINARY_DIR}/${testfile}.hdf ) set_tests_properties (H5H4convert-${testfile} PROPERTIES DEPENDS H5H4convert_COPY-${testfile}) set (last_test "H5H4convert-${testfile}") ENDMACRO () MACRO (ADD_H5H4_ROOT_TEST testfile) add_test ( NAME H5H4convert-r_CLEAR-${testfile} COMMAND ${CMAKE_COMMAND} -E remove ${PROJECT_BINARY_DIR}/${testfile}-r.hdf ) if (NOT "${last_test}" STREQUAL "") set_tests_properties (H5H4convert-r_CLEAR-${testfile} PROPERTIES DEPENDS ${last_test}) endif () add_test ( NAME H5H4convert-r_COPY-${testfile} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${H4H5_UTILS_TEST_SOURCE_DIR}/${testfile}.h5 ${PROJECT_BINARY_DIR}/${testfile}.h5 ) set_tests_properties (H5H4convert-r_COPY-${testfile} PROPERTIES DEPENDS H5H4convert-r_CLEAR-${testfile}) add_test ( NAME H5H4convert-r-${testfile} COMMAND ${H4H5_54CONVERT_EXECUTABLE} ${H4H5_UTILS_TEST_SOURCE_DIR}/${testfile}.h5 -r ${PROJECT_BINARY_DIR}/${testfile}-r.hdf ) set_tests_properties (H5H4convert-r-${testfile} PROPERTIES DEPENDS H5H4convert-r_COPY-${testfile}) set (last_test "H5H4convert-r-${testfile}") ENDMACRO () ############################################################################## ############################################################################## ### T H E T E S T S ### ############################################################################## ############################################################################## # Remove any output file left over from previous test run add_test ( NAME H4H5convert-clearall-objects COMMAND ${CMAKE_COMMAND} -E remove vg_all_test.h5 tstr2.hdf tall.hdf ) if (NOT "${last_test}" STREQUAL "") set_tests_properties (H4H5convert-clearall-objects PROPERTIES DEPENDS ${last_test}) endif () set (last_test "H4H5convert-clearall-objects") # # The HDF5 filenames are created based upon the HDF4 filenames # without the extension. # ADD_H4H5_TEST (vg_all_test) ADD_H5H4_TEST (tstr2) ADD_H5H4_ROOT_TEST (tall)