diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2010-09-16 20:31:46 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2010-09-16 20:31:46 (GMT) |
commit | 607c97c175fdfb14494fe804dd65066ded7f7a98 (patch) | |
tree | 9ff47d7d777f6d2bae8b47c67bc2073fe36bd11b | |
parent | a9a3f22e786983ec4e946bd1a8cdd42ec8058c53 (diff) | |
download | hdf5-607c97c175fdfb14494fe804dd65066ded7f7a98.zip hdf5-607c97c175fdfb14494fe804dd65066ded7f7a98.tar.gz hdf5-607c97c175fdfb14494fe804dd65066ded7f7a98.tar.bz2 |
[svn-r19404] Update to H5REPACK tests for layout info required a grep script like runTest.cmake.
Update CMakeLists.txt for new h5repack layout tests.
Tested: local linux
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | config/cmake/grepTest.cmake | 61 | ||||
-rw-r--r-- | tools/h5repack/CMakeLists.txt | 77 |
4 files changed, 139 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ac143f4..47f529f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -524,11 +524,11 @@ ENDIF (WIN32) # Note: Currently CMake only allows configuring of threadsafe on WINDOWS. #----------------------------------------------------------------------------- IF (WIN32) -OPTION (HDF5_ENABLE_THREADSAFE "Enable Threadsafety" OFF) -IF (HDF5_ENABLE_THREADSAFE) + OPTION (HDF5_ENABLE_THREADSAFE "Enable Threadsafety" OFF) + IF (HDF5_ENABLE_THREADSAFE) SET (H5_HAVE_WIN_THREADS 1) SET (H5_HAVE_THREADSAFE 1) -ENDIF (HDF5_ENABLE_THREADSAFE) + ENDIF (HDF5_ENABLE_THREADSAFE) ENDIF (WIN32) #----------------------------------------------------------------------------- @@ -1903,6 +1903,7 @@ ./config/cmake/HDF5Macros.cmake ./config/cmake/libhdf5.settings.cmake.in ./config/cmake/cacheinit.cmake +./config/cmake/grepTest.cmake ./config/cmake/runTest.cmake ./config/cmake/CTestCustom.ctest ./config/cmake/ConfigureChecks.cmake diff --git a/config/cmake/grepTest.cmake b/config/cmake/grepTest.cmake new file mode 100644 index 0000000..cc3a9b4 --- /dev/null +++ b/config/cmake/grepTest.cmake @@ -0,0 +1,61 @@ +# runTest.cmake executes a command and captures the output in a file. File is then compared +# against a reference file. Exit status of command can also be compared. + +# arguments checking +IF (NOT TEST_PROGRAM) + MESSAGE (FATAL_ERROR "Require TEST_PROGRAM to be defined") +ENDIF (NOT TEST_PROGRAM) +#IF (NOT TEST_ARGS) +# MESSAGE (STATUS "Require TEST_ARGS to be defined") +#ENDIF (NOT TEST_ARGS) +IF (NOT TEST_FOLDER) + MESSAGE ( FATAL_ERROR "Require TEST_FOLDER to be defined") +ENDIF (NOT TEST_FOLDER) +IF (NOT TEST_OUTPUT) + MESSAGE (FATAL_ERROR "Require TEST_OUTPUT to be defined") +ENDIF (NOT TEST_OUTPUT) +#IF (NOT TEST_EXPECT) +# MESSAGE (STATUS "Require TEST_EXPECT to be defined") +#ENDIF (NOT TEST_EXPECT) +IF (NOT TEST_FILTER) + MESSAGE (STATUS "Require TEST_FILTER to be defined") +ENDIF (NOT TEST_FILTER) +IF (NOT TEST_REFERENCE) + MESSAGE (FATAL_ERROR "Require TEST_REFERENCE to be defined") +ENDIF (NOT TEST_REFERENCE) + +MESSAGE (STATUS "COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}") + +# run the test program, capture the stdout/stderr and the result var +EXECUTE_PROCESS ( + COMMAND ${TEST_PROGRAM} ${TEST_ARGS} + WORKING_DIRECTORY ${TEST_FOLDER} + RESULT_VARIABLE TEST_RESULT + OUTPUT_FILE ${TEST_OUTPUT} + ERROR_FILE ${TEST_OUTPUT}.err + OUTPUT_VARIABLE TEST_ERROR + ERROR_VARIABLE TEST_ERROR +) + +MESSAGE (STATUS "COMMAND Result: ${TEST_RESULT}") +MESSAGE (STATUS "COMMAND Error: ${TEST_ERROR}") + +# now grep the output with the reference +FILE (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) + +STRING(REGEX MATCH "${TEST_FILTER}" TEST_MATCH ${TEST_STREAM}) +IF (${TEST_EXPECT}) + STRING(LENGTH "${TEST_MATCH}" TEST_RESULT) + IF (NOT ${TEST_RESULT} STREQUAL "0") + MESSAGE (FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did contain ${TEST_REFERENCE}") + ENDIF (NOT ${TEST_RESULT} STREQUAL "0") +ELSE (${TEST_EXPECT}) + STRING(COMPARE EQUAL "${TEST_REFERENCE}" "${TEST_MATCH}" TEST_RESULT) + IF (${TEST_RESULT} STREQUAL "0") + MESSAGE (FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did not contain ${TEST_REFERENCE}") + ENDIF (${TEST_RESULT} STREQUAL "0") +ENDIF (${TEST_EXPECT}) + +# everything went fine... +MESSAGE ("Passed: The output of ${TEST_PROGRAM} matched") + diff --git a/tools/h5repack/CMakeLists.txt b/tools/h5repack/CMakeLists.txt index f7ae58e..0a58b8a 100644 --- a/tools/h5repack/CMakeLists.txt +++ b/tools/h5repack/CMakeLists.txt @@ -80,6 +80,7 @@ IF (BUILD_TESTING) h5repack_hlink.h5 h5repack_layout.h5 h5repack_layouto.h5 + h5repack_layout2.h5 h5repack_named_dtypes.h5 h5repack_nbit.h5 h5repack_objs.h5 @@ -147,7 +148,7 @@ IF (BUILD_TESTING) COMMAND $<TARGET_FILE:h5diff> ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out.${testfile} ) ENDIF (${testtype} STREQUAL "SKIP") - ENDMACRO (ADD_H5_TEST testname testfile testtype) + ENDMACRO (ADD_H5_TEST) MACRO (ADD_H5_CMP_TEST testname testfilter testtype resultcode resultfile) IF (${testtype} STREQUAL "SKIP") @@ -169,7 +170,53 @@ IF (BUILD_TESTING) -P "${HDF5_RESOURCES_DIR}/runTest.cmake" ) ENDIF (${testtype} STREQUAL "SKIP") - ENDMACRO (ADD_H5_CMP_TEST file) + ENDMACRO (ADD_H5_CMP_TEST) + + MACRO (ADD_H5_VERIFY_TEST testname testtype resultcode testfile testdset testfilter) + IF (${testtype} STREQUAL "SKIP") + ADD_TEST ( + NAME H5REPACK_VERIFY_LAYOUT-${testname} + COMMAND ${CMAKE_COMMAND} -E echo "SKIP -d ${testdset} -pH ${PROJECT_BINARY_DIR}/testfiles/out.${resultfile}" + ) + ELSE (${testtype} STREQUAL "SKIP") + IF (${resultcode} STREQUAL "0") + ADD_TEST ( + NAME H5REPACK_VERIFY_LAYOUT-${testname} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" + -D "TEST_ARGS:STRING=-d;${testdset};-pH;testfiles/out.${testfile}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=${testfile}-v.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_FILTER:STRING=${testfilter}" + -D "TEST_REFERENCE=${testfilter}" + -P "${HDF5_RESOURCES_DIR}/grepTest.cmake" + ) + ELSE (${resultcode} STREQUAL "0") + IF (${testfilter} STREQUAL "CHUNKED") + SET (nottestfilter "(CONTIGUOUS|COMPACT)") + ENDIF (${testfilter} STREQUAL "CHUNKED") + IF (${testfilter} STREQUAL "CONTIGUOUS") + SET (nottestfilter "(CHUNK|COMPACT)") + ENDIF (${testfilter} STREQUAL "CONTIGUOUS") + IF (${testfilter} STREQUAL "COMPACT") + SET (nottestfilter "(CONTIGUOUS|CHUNK)") + ENDIF (${testfilter} STREQUAL "COMPACT") + ADD_TEST ( + NAME H5REPACK_VERIFY_LAYOUT_ALL-${testname} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" + -D "TEST_ARGS:STRING=-pH;testfiles/out.${testfile}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=${testfile}-v.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_FILTER:STRING=${nottestfilter}" + -D "TEST_REFERENCE=${testfilter}" + -P "${HDF5_RESOURCES_DIR}/grepTest.cmake" + ) + ENDIF (${resultcode} STREQUAL "0") + ENDIF (${testtype} STREQUAL "SKIP") + ENDMACRO (ADD_H5_VERIFY_TEST) ############################################################################## ############################################################################## @@ -198,6 +245,7 @@ IF (BUILD_TESTING) SET (FILE14 h5repack_layouto.h5 ) # A file with an older version of the layout message (copy of test/tlayouto.h5) SET (FILE15 h5repack_named_dtypes.h5) SET (FILE16 tfamily%05d.h5) # located in common testfiles folder + SET (FILE18 h5repack_layout2.h5) SET (FILE_REF h5repack_refs.h5) # @@ -494,26 +542,47 @@ ADD_H5_TEST (deflate_file ${TESTTYPE} ${arg}) ######################################################### ADD_H5_TEST (dset2_chunk_20x10 "TEST" ${FILE4} --layout=dset2:CHUNK=20x10) +ADD_H5_VERIFY_TEST (dset2_chunk_20x10 "TEST" 0 ${FILE4} dset2 CHUNKED) ADD_H5_TEST (chunk_20x10 "TEST" ${FILE4} -l CHUNK=20x10) +ADD_H5_VERIFY_TEST (chunk_20x10 "TEST" 1 ${FILE4} null CHUNKED) ADD_H5_TEST (dset2_conti "TEST" ${FILE4} -l dset2:CONTI) +ADD_H5_VERIFY_TEST (dset2_conti "TEST" 0 ${FILE4} dset2 CONTIGUOUS) ADD_H5_TEST (conti "TEST" ${FILE4} -l CONTI) +ADD_H5_VERIFY_TEST (conti "TEST" 1 ${FILE4} null CONTIGUOUS) ADD_H5_TEST (dset2_compa "TEST" ${FILE4} -l dset2:COMPA) +ADD_H5_VERIFY_TEST (dset2_compa "TEST" 0 ${FILE4} dset2 COMPACT) ADD_H5_TEST (compa "TEST" ${FILE4} -l COMPA) - +ADD_H5_VERIFY_TEST (compa "TEST" 1 ${FILE4} null COMPACT) ################################################################ # layout conversions (file has no filters) ############################################################### ADD_H5_TEST (dset_compa_conti "TEST" ${FILE4} -l dset_compact:CONTI) +ADD_H5_VERIFY_TEST (dset_compa_conti "TEST" 0 ${FILE4} dset_compact CONTIGUOUS) ADD_H5_TEST (dset_compa_chunk "TEST" ${FILE4} -l dset_compact:CHUNK=2x5) +ADD_H5_VERIFY_TEST (dset_compa_chunk "TEST" 0 ${FILE4} dset_compact CHUNKED) ADD_H5_TEST (dset_compa_compa "TEST" ${FILE4} -l dset_compact:COMPA) +ADD_H5_VERIFY_TEST (dset_compa_compa "TEST" 0 ${FILE4} dset_compact COMPACT) ADD_H5_TEST (dset_conti_compa "TEST" ${FILE4} -l dset_contiguous:COMPA) +ADD_H5_VERIFY_TEST (dset_conti_compa "TEST" 0 ${FILE4} dset_contiguous COMPACT) ADD_H5_TEST (dset_conti_chunk "TEST" ${FILE4} -l dset_contiguous:CHUNK=3x6) +ADD_H5_VERIFY_TEST (dset_conti_chunk "TEST" 0 ${FILE4} dset_contiguous CHUNKED) ADD_H5_TEST (dset_conti_conti "TEST" ${FILE4} -l dset_contiguous:CONTI) +ADD_H5_VERIFY_TEST (dset_conti_conti "TEST" 0 ${FILE4} dset_contiguous CONTIGUOUS) ADD_H5_TEST (chunk_compa "TEST" ${FILE4} -l dset_chunk:COMPA) +ADD_H5_VERIFY_TEST (chunk_compa "TEST" 0 ${FILE4} dset_chunk COMPACT) ADD_H5_TEST (chunk_conti "TEST" ${FILE4} -l dset_chunk:CONTI) +ADD_H5_VERIFY_TEST (chunk_conti "TEST" 0 ${FILE4} dset_chunk CONTIGUOUS) ADD_H5_TEST (chunk_18x13 "TEST" ${FILE4} -l dset_chunk:CHUNK=18x13) +ADD_H5_VERIFY_TEST (chunk_18x13 "TEST" 0 ${FILE4} dset_chunk CHUNKED) + +# test convert small size dataset ( < 1k) to compact layout without -m +ADD_H5_TEST (contig_small_compa "TEST" ${FILE18} -l contig_small:COMPA) +ADD_H5_VERIFY_TEST (contig_small_compa "TEST" 0 ${FILE18} contig_small COMPACT) + +ADD_H5_TEST (contig_small_fixed_compa "TEST" ${FILE18} -l chunked_small_fixed:COMPA) +ADD_H5_VERIFY_TEST (contig_small_fixed_compa "TEST" 0 ${FILE18} chunked_small_fixed COMPACT) # Native option # Do not use FILE1, as the named dtype will be converted to native, and h5diff will @@ -529,6 +598,7 @@ IF (NOT USE_FILTER_DEFLATE) SET (TESTTYPE "SKIP") ENDIF (NOT USE_FILTER_DEFLATE) ADD_H5_TEST (layout_long_switches ${TESTTYPE} ${arg}) +ADD_H5_VERIFY_TEST (layout_long_switches ${TESTTYPE} 1 ${FILE4} null CHUNKED) # latest file format with short switches. use FILE4=h5repack_layout.h5 (no filters) SET (arg ${FILE4} -l CHUNK=20x10 -f GZIP=1 -m 10 -n -L -c 8 -d 6 -s 8[:dtype]) @@ -537,6 +607,7 @@ IF (NOT USE_FILTER_DEFLATE) SET (TESTTYPE "SKIP") ENDIF (NOT USE_FILTER_DEFLATE) ADD_H5_TEST (layout_short_switches ${TESTTYPE} ${arg}) +ADD_H5_VERIFY_TEST (layout_short_switches ${TESTTYPE} 1 ${FILE4} null CHUNKED) # several global filters SET (arg ${FILE4} --filter GZIP=1 --filter SHUF) |