From 50a65223220142cf0b06a7d25ca53dc56811be01 Mon Sep 17 00:00:00 2001 From: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Sun, 10 Mar 2024 18:43:37 -0500 Subject: Change compression tests reference files to use masking for compression ratios (#4083) Rework TEST_FILTER tests to handle slightly different compression ratios --- HDF5Examples/config/cmake/runTest.cmake | 9 +- config/cmake/runTest.cmake | 10 ++- release_docs/USING_HDF5_CMake.txt | 1 - tools/test/h5copy/CMakeTests.cmake | 2 +- tools/test/h5dump/CMakeTests.cmake | 46 +++++++++-- tools/test/h5dump/expected/tallfilters.ddl | 2 +- tools/test/h5dump/expected/tdeflate.ddl | 2 +- tools/test/h5dump/expected/tfletcher32.ddl | 2 +- tools/test/h5dump/expected/tnbit.ddl | 2 +- tools/test/h5dump/expected/tscaleoffset.ddl | 2 +- tools/test/h5dump/expected/tszip.ddl | 2 +- tools/test/h5dump/testh5dump.sh.in | 75 +++++++++++++++-- tools/test/h5repack/CMakeTests.cmake | 95 +++++++++++++++++++--- .../expected/deflate_limit.h5repack_layout.h5.ddl | 14 ++-- .../h5repack_filters.h5-gzip_verbose_filters.tst | 2 +- tools/test/h5repack/h5repack.sh.in | 64 ++++++++++++++- 16 files changed, 287 insertions(+), 43 deletions(-) diff --git a/HDF5Examples/config/cmake/runTest.cmake b/HDF5Examples/config/cmake/runTest.cmake index 3507c34..cc433b1 100644 --- a/HDF5Examples/config/cmake/runTest.cmake +++ b/HDF5Examples/config/cmake/runTest.cmake @@ -167,7 +167,7 @@ if (TEST_FIND_RESULT GREATER -1) endif () # if the output file needs Storage text removed -if (TEST_MASK) +if (TEST_MASK_STORE) file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) string (REGEX REPLACE "Storage:[^\n]+\n" "Storage:
\n" TEST_STREAM "${TEST_STREAM}") file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") @@ -205,6 +205,13 @@ if (TEST_MASK_ERROR) endif () # remove text from the output file +if (TEST_MASK) + file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) + string (REGEX REPLACE "${TEST_MASK}" "" TEST_STREAM "${TEST_STREAM}") + file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") +endif () + +# replace text from the output file if (TEST_FILTER) file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) string (REGEX REPLACE "${TEST_FILTER}" "${TEST_FILTER_REPLACE}" TEST_STREAM "${TEST_STREAM}") diff --git a/config/cmake/runTest.cmake b/config/cmake/runTest.cmake index 4257c44..ff9732e 100644 --- a/config/cmake/runTest.cmake +++ b/config/cmake/runTest.cmake @@ -167,7 +167,7 @@ if (TEST_FIND_RESULT GREATER -1) endif () # if the output file needs Storage text removed -if (TEST_MASK) +if (TEST_MASK_STORE) file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) string (REGEX REPLACE "Storage:[^\n]+\n" "Storage:
\n" TEST_STREAM "${TEST_STREAM}") file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") @@ -205,8 +205,16 @@ if (TEST_MASK_ERROR) endif () # remove text from the output file +if (TEST_MASK) + file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) + string (REGEX REPLACE "${TEST_MASK}" "" TEST_STREAM "${TEST_STREAM}") + file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") +endif () + +# replace text from the output file if (TEST_FILTER) file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) + message (STATUS "TEST_FILTER: ${TEST_FILTER} TEST_FILTER_REPLACE: ${TEST_FILTER_REPLACE}") string (REGEX REPLACE "${TEST_FILTER}" "${TEST_FILTER_REPLACE}" TEST_STREAM "${TEST_STREAM}") file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") endif () diff --git a/release_docs/USING_HDF5_CMake.txt b/release_docs/USING_HDF5_CMake.txt index 0e35a08..8b78e7d 100644 --- a/release_docs/USING_HDF5_CMake.txt +++ b/release_docs/USING_HDF5_CMake.txt @@ -213,7 +213,6 @@ set (LINK_LIBS ${LINK_LIBS} ${HDF5_C_${LIB_TYPE}_LIBRARY}) set (example hdf_example) add_executable (${example} ${PROJECT_SOURCE_DIR}/${example}.c) -TARGET_C_PROPERTIES (${example} PRIVATE ${LIB_TYPE}) target_link_libraries (${example} ${LINK_LIBS}) enable_testing () diff --git a/tools/test/h5copy/CMakeTests.cmake b/tools/test/h5copy/CMakeTests.cmake index 03a783e..2d7f5f7 100644 --- a/tools/test/h5copy/CMakeTests.cmake +++ b/tools/test/h5copy/CMakeTests.cmake @@ -277,7 +277,7 @@ -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=./testfiles/${testname}.out" -D "TEST_ERRREF=${result_errcheck}" - -D "TEST_MASK=true" + -D "TEST_MASK_STORE=true" -P "${HDF_RESOURCES_DIR}/grepTest.cmake" ) endif () diff --git a/tools/test/h5dump/CMakeTests.cmake b/tools/test/h5dump/CMakeTests.cmake index d7f39e1..586957e 100644 --- a/tools/test/h5dump/CMakeTests.cmake +++ b/tools/test/h5dump/CMakeTests.cmake @@ -511,6 +511,40 @@ endif () endmacro () + macro (ADD_H5_COMP_TEST resultfile resultcode resultvalue) + # If using memchecker add tests without using scripts + if (HDF5_USING_ANALYSIS_TOOL) + add_test (NAME H5DUMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN}) + if (${resultcode}) + set_tests_properties (H5DUMP-${resultfile} PROPERTIES WILL_FAIL "true") + endif () + set_tests_properties (H5DUMP-${resultfile} PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std" + ) + else () + add_test ( + NAME H5DUMP-${resultfile} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=${ARGN}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles/std" + -D "TEST_OUTPUT=${resultfile}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}.ddl" + -D "TEST_FILTER:STRING=SIZE [0-9]* \\(${resultvalue}\\\.[0-9][0-9][0-9]:1 COMPRESSION\\)" + -D "TEST_FILTER_REPLACE:STRING=SIZE XXXX (${resultvalue}.XXX:1 COMPRESSION)" + -P "${HDF_RESOURCES_DIR}/runTest.cmake" + ) + endif () + set_tests_properties (H5DUMP-${resultfile} PROPERTIES + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/std" + ) + if ("H5DUMP-${resultfile}" MATCHES "${HDF5_DISABLE_TESTS_REGEX}") + set_tests_properties (H5DUMP-${resultfile} PROPERTIES DISABLED true) + endif () + endmacro () + macro (ADD_H5_TEST_N resultfile resultcode) add_test ( NAME H5DUMP-N-${resultfile}-clear-objects @@ -1235,25 +1269,25 @@ # tests for filters # SZIP - ADD_H5_TEST (tszip 0 --enable-error-stack -H -p -d szip tfilters.h5) + ADD_H5_COMP_TEST (tszip 0 2 --enable-error-stack -H -p -d szip tfilters.h5) # deflate - ADD_H5_TEST (tdeflate 0 --enable-error-stack -H -p -d deflate tfilters.h5) + ADD_H5_COMP_TEST (tdeflate 0 2 --enable-error-stack -H -p -d deflate tfilters.h5) # shuffle ADD_H5_TEST (tshuffle 0 --enable-error-stack -H -p -d shuffle tfilters.h5) # fletcher32 - ADD_H5_TEST (tfletcher32 0 --enable-error-stack -H -p -d fletcher32 tfilters.h5) + ADD_H5_COMP_TEST (tfletcher32 0 0 --enable-error-stack -H -p -d fletcher32 tfilters.h5) # nbit - ADD_H5_TEST (tnbit 0 --enable-error-stack -H -p -d nbit tfilters.h5) + ADD_H5_COMP_TEST (tnbit 0 10 --enable-error-stack -H -p -d nbit tfilters.h5) # scaleoffset - ADD_H5_TEST (tscaleoffset 0 --enable-error-stack -H -p -d scaleoffset tfilters.h5) + ADD_H5_COMP_TEST (tscaleoffset 0 4 --enable-error-stack -H -p -d scaleoffset tfilters.h5) # all - ADD_H5_TEST (tallfilters 0 --enable-error-stack -H -p -d all tfilters.h5) + ADD_H5_COMP_TEST (tallfilters 0 1 --enable-error-stack -H -p -d all tfilters.h5) # user defined ADD_H5_TEST (tuserfilter 0 --enable-error-stack -H -p -d myfilter tfilters.h5) diff --git a/tools/test/h5dump/expected/tallfilters.ddl b/tools/test/h5dump/expected/tallfilters.ddl index ff2454c..43bcf6a 100644 --- a/tools/test/h5dump/expected/tallfilters.ddl +++ b/tools/test/h5dump/expected/tallfilters.ddl @@ -4,7 +4,7 @@ DATASET "all" { DATASPACE SIMPLE { ( 20, 10 ) / ( 20, 10 ) } STORAGE_LAYOUT { CHUNKED ( 10, 5 ) - SIZE 458 (1.747:1 COMPRESSION) + SIZE XXXX (1.XXX:1 COMPRESSION) } FILTERS { PREPROCESSING SHUFFLE diff --git a/tools/test/h5dump/expected/tdeflate.ddl b/tools/test/h5dump/expected/tdeflate.ddl index 9b92d0e..504d4f3 100644 --- a/tools/test/h5dump/expected/tdeflate.ddl +++ b/tools/test/h5dump/expected/tdeflate.ddl @@ -4,7 +4,7 @@ DATASET "deflate" { DATASPACE SIMPLE { ( 20, 10 ) / ( 20, 10 ) } STORAGE_LAYOUT { CHUNKED ( 10, 5 ) - SIZE 385 (2.078:1 COMPRESSION) + SIZE XXXX (2.XXX:1 COMPRESSION) } FILTERS { COMPRESSION DEFLATE { LEVEL 9 } diff --git a/tools/test/h5dump/expected/tfletcher32.ddl b/tools/test/h5dump/expected/tfletcher32.ddl index 01460e2..aafd4d4 100644 --- a/tools/test/h5dump/expected/tfletcher32.ddl +++ b/tools/test/h5dump/expected/tfletcher32.ddl @@ -4,7 +4,7 @@ DATASET "fletcher32" { DATASPACE SIMPLE { ( 20, 10 ) / ( 20, 10 ) } STORAGE_LAYOUT { CHUNKED ( 10, 5 ) - SIZE 816 (0.980:1 COMPRESSION) + SIZE XXXX (0.XXX:1 COMPRESSION) } FILTERS { CHECKSUM FLETCHER32 diff --git a/tools/test/h5dump/expected/tnbit.ddl b/tools/test/h5dump/expected/tnbit.ddl index cf2ac1f..35c111f 100644 --- a/tools/test/h5dump/expected/tnbit.ddl +++ b/tools/test/h5dump/expected/tnbit.ddl @@ -4,7 +4,7 @@ DATASET "nbit" { DATASPACE SIMPLE { ( 20, 10 ) / ( 20, 10 ) } STORAGE_LAYOUT { CHUNKED ( 10, 5 ) - SIZE 76 (10.526:1 COMPRESSION) + SIZE XXXX (10.XXX:1 COMPRESSION) } FILTERS { COMPRESSION NBIT diff --git a/tools/test/h5dump/expected/tscaleoffset.ddl b/tools/test/h5dump/expected/tscaleoffset.ddl index a039736..ebff6c1 100644 --- a/tools/test/h5dump/expected/tscaleoffset.ddl +++ b/tools/test/h5dump/expected/tscaleoffset.ddl @@ -4,7 +4,7 @@ DATASET "scaleoffset" { DATASPACE SIMPLE { ( 20, 10 ) / ( 20, 10 ) } STORAGE_LAYOUT { CHUNKED ( 10, 5 ) - SIZE 188 (4.255:1 COMPRESSION) + SIZE XXXX (4.XXX:1 COMPRESSION) } FILTERS { COMPRESSION SCALEOFFSET { MIN BITS 2 } diff --git a/tools/test/h5dump/expected/tszip.ddl b/tools/test/h5dump/expected/tszip.ddl index 06e2259..3f04cf7 100644 --- a/tools/test/h5dump/expected/tszip.ddl +++ b/tools/test/h5dump/expected/tszip.ddl @@ -4,7 +4,7 @@ DATASET "szip" { DATASPACE SIMPLE { ( 20, 10 ) / ( 20, 10 ) } STORAGE_LAYOUT { CHUNKED ( 10, 5 ) - SIZE 372 (2.151:1 COMPRESSION) + SIZE XXXX (2.XXX:1 COMPRESSION) } FILTERS { COMPRESSION SZIP { diff --git a/tools/test/h5dump/testh5dump.sh.in b/tools/test/h5dump/testh5dump.sh.in index fdeb17d..4734865 100644 --- a/tools/test/h5dump/testh5dump.sh.in +++ b/tools/test/h5dump/testh5dump.sh.in @@ -537,6 +537,69 @@ TOOLTEST() { } +# same as TOOLTEST but masks out the compression values +TOOLTESTC() { + # check if caseless compare and diff requested + if [ "$1" = ignorecase ]; then + caseless="-i" + # replace cmp with diff which runs much longer. + xCMP="$DIFF -i" + shift + else + caseless="" + # stick with faster cmp if ignorecase is not requested. + xCMP="$CMP" + fi + + txttype=$1 + expect="$TESTDIR/$2" + actual="$TESTDIR/`basename $2 .ddl`.out" + actual_err="$TESTDIR/`basename $2 .ddl`.err" + actual_sav=${actual}-sav + actual_err_sav=${actual_err}-sav + shift + shift + + # Run test. + TESTING $DUMPER $@ + ( + cd $TESTDIR + $RUNSERIAL $DUMPER_BIN "$@" + ) >$actual 2>$actual_err + + # save actual and actual_err in case they are needed later. + cp $actual $actual_sav + STDOUT_FILTER $actual + cp $actual_err $actual_err_sav + STDERR_FILTER $actual_err + + tmp_file=/tmp/h5test_tmp_$$ + cp $actual $tmp_file + sed -e 's/SIZE [0-9]* ('"$txttype"'\.[0-9][0-9][0-9]:1 COMPRESSION)/SIZE XXXX ('"$txttype"'.XXX:1 COMPRESSION)/' \ + < $tmp_file > $actual + rm -f $tmp_file + + if [ ! -f $expect ]; then + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect + echo " Expected result (*.ddl) missing" + nerrors="`expr $nerrors + 1`" + elif $xCMP $expect $actual > /dev/null 2>&1 ; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected result (*.ddl) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $caseless $expect $actual |sed 's/^/ /' + fi + + # Clean up output file + if test -z "$HDF5_NOCLEANUP"; then + rm -f $actual $actual_err $actual_sav $actual_err_sav $actual_ext + fi + +} # same as TOOLTEST1 but compares generated file to expected output # and compares the generated data file to the expected data file @@ -1355,19 +1418,19 @@ TOOLTEST texceedsubblock.ddl --enable-error-stack -d 1d -k 1,3 taindices.h5 # tests for filters # SZIP -TOOLTEST tszip.ddl --enable-error-stack -H -p -d szip tfilters.h5 +TOOLTESTC 2 tszip.ddl --enable-error-stack -H -p -d szip tfilters.h5 # deflate -TOOLTEST tdeflate.ddl --enable-error-stack -H -p -d deflate tfilters.h5 +TOOLTESTC 2 tdeflate.ddl --enable-error-stack -H -p -d deflate tfilters.h5 # shuffle TOOLTEST tshuffle.ddl --enable-error-stack -H -p -d shuffle tfilters.h5 # fletcher32 -TOOLTEST tfletcher32.ddl --enable-error-stack -H -p -d fletcher32 tfilters.h5 +TOOLTESTC 0 tfletcher32.ddl --enable-error-stack -H -p -d fletcher32 tfilters.h5 # nbit -TOOLTEST tnbit.ddl --enable-error-stack -H -p -d nbit tfilters.h5 +TOOLTESTC 10 tnbit.ddl --enable-error-stack -H -p -d nbit tfilters.h5 # scaleoffset -TOOLTEST tscaleoffset.ddl --enable-error-stack -H -p -d scaleoffset tfilters.h5 +TOOLTESTC 4 tscaleoffset.ddl --enable-error-stack -H -p -d scaleoffset tfilters.h5 # all -TOOLTEST tallfilters.ddl --enable-error-stack -H -p -d all tfilters.h5 +TOOLTESTC 1 tallfilters.ddl --enable-error-stack -H -p -d all tfilters.h5 # user defined TOOLTEST tuserfilter.ddl --enable-error-stack -H -p -d myfilter tfilters.h5 diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index b4a92e7..0114df8 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/h5repack/CMakeTests.cmake @@ -360,7 +360,7 @@ endif () endmacro () - macro (ADD_H5_FILTER_TEST testname testfilter testtype resultcode resultfile) + macro (ADD_H5_FILTER_TEST testname testfilter replacefilter testtype resultcode resultfile) if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_USING_ANALYSIS_TOOL) add_test ( @@ -393,7 +393,9 @@ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_OUTPUT=${resultfile}-${testname}.out" -D "TEST_EXPECT=${resultcode}" - -D "TEST_FILTER:STRING=${testfilter}" + -D "TEST_MASK:STRING=O?...ing file[^\n]+\n" + -D "TEST_FILTER:STRING=GZIP \\(0\\.[0-9][0-9][0-9]:1\\)" + -D "TEST_FILTER_REPLACE:STRING=GZIP (0.XXX:1)" -D "TEST_REFERENCE=${resultfile}-${testname}.tst" -P "${HDF_RESOURCES_DIR}/runTest.cmake" ) @@ -434,7 +436,7 @@ NAME H5REPACK_MASK-${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile} ) - else (HDF5_USING_ANALYSIS_TOOL) + else () add_test ( NAME H5REPACK_MASK-${testname} COMMAND "${CMAKE_COMMAND}" @@ -528,6 +530,70 @@ endif () endmacro () + macro (ADD_H5_DMP_MASK testname testtype resultcode resultfile) + if ("${testtype}" STREQUAL "SKIP") + if (NOT HDF5_USING_ANALYSIS_TOOL) + add_test ( + NAME H5REPACK_DMP-${testname} + COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile}" + ) + set_property(TEST H5REPACK_DMP-${testname} PROPERTY DISABLED true) + endif () + else () + add_test ( + NAME H5REPACK_DMP-${testname}-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${resultfile} + ) + add_test ( + NAME H5REPACK_DMP-${testname} + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile} + ) + set_tests_properties (H5REPACK_DMP-${testname} PROPERTIES + DEPENDS H5REPACK_DMP-${testname}-clear-objects + ) + if ("H5REPACK_DMP-${testname}" MATCHES "${HDF5_DISABLE_TESTS_REGEX}") + set_tests_properties (H5REPACK_DMP-${testname} PROPERTIES DISABLED true) + endif () + if (NOT HDF5_USING_ANALYSIS_TOOL) + add_test ( + NAME H5REPACK_DMP-h5dump-${testname} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=-q;creation_order;-pH;out-${testname}.${resultfile}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=${resultfile}-${testname}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${testname}.${resultfile}.ddl" + -D "TEST_FILTER:STRING=SIZE [0-9][0-9][0-9][0-9] \\(2\\\.[0-9][0-9][0-9]:1 COMPRESSION\\)" + -D "TEST_FILTER_REPLACE:STRING=SIZE XXXX (2.XXX:1 COMPRESSION)" + -P "${HDF_RESOURCES_DIR}/runTest.cmake" + ) + set_tests_properties (H5REPACK_DMP-h5dump-${testname} PROPERTIES + DEPENDS H5REPACK_DMP-${testname} + ) + if ("H5REPACK_DMP-h5dump-${testname}" MATCHES "${HDF5_DISABLE_TESTS_REGEX}") + set_tests_properties (H5REPACK_DMP-h5dump-${testname} PROPERTIES DISABLED true) + endif () + add_test ( + NAME H5REPACK_DMP-${testname}-clean-objects + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${resultfile} + ) + set_tests_properties (H5REPACK_DMP-${testname}-clean-objects PROPERTIES + DEPENDS H5REPACK_DMP-h5dump-${testname} + ) + else () + add_test ( + NAME H5REPACK_DMP-${testname}-clean-objects + COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${resultfile} + ) + set_tests_properties (H5REPACK_DMP-${testname}-clean-objects PROPERTIES + DEPENDS H5REPACK_DMP-${testname} + ) + endif () + endif () + endmacro () + macro (ADD_H5_DMP_NO_OPT_TEST testname testtype resultcode resultfile) if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_USING_ANALYSIS_TOOL) @@ -1017,7 +1083,7 @@ -D "TEST_ARGS:STRING=${ARGN};${resultfile};out-${testname}.${resultfile}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" -D "TEST_EXPECT=${resultcode}" - -D "TEST_FILTER:STRING=O?...ing file[^\n]+\n" + -D "TEST_MASK:STRING=O?...ing file[^\n]+\n" -D "TEST_OUTPUT=${testname}.${resultfile}.out" -D "TEST_REFERENCE=${testname}.${resultfile}.tst" -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" @@ -1362,7 +1428,7 @@ if (NOT USE_FILTER_DEFLATE) set (TESTTYPE "SKIP") endif () - ADD_H5_FILTER_TEST (gzip_verbose_filters "O?...ing file[^\n]+\n" ${TESTTYPE} 0 ${arg}) + ADD_H5_FILTER_TEST (gzip_verbose_filters "GZIP \(0\.[0-9][0-9][0-9]:1\)" "GZIP (0.XXX:1)" ${TESTTYPE} 0 ${arg}) ########################################################### # the following tests assume the input files have filters @@ -1479,7 +1545,7 @@ if (NOT USE_FILTER_DEFLATE) set (TESTTYPE "SKIP") endif () - ADD_H5_DMP_TEST (deflate_limit ${TESTTYPE} 0 ${arg}) + ADD_H5_DMP_MASK (deflate_limit ${TESTTYPE} 0 ${arg}) #file set (arg ${FILE4} -e ${INFO_FILE}) @@ -1688,14 +1754,19 @@ ADD_H5_TEST (HDFFV-7840 "TEST" h5diff_attr1.h5) # test CVE-2018-17432 fix - set (arg h5repack_CVE-2018-17432.h5 --low=1 --high=2 -f GZIP=8 -l dset1:CHUNK=5x6) - set (TESTTYPE "TEST") - ADD_H5_FILTER_TEST (HDFFV-10590 "" ${TESTTYPE} 1 ${arg}) + set (arg --low=1 --high=2 -f GZIP=8 -l dset1:CHUNK=5x6) + add_test ( + NAME H5REPACK-HDFFV-10590 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${arg} ${PROJECT_BINARY_DIR}/testfiles/h5repack_CVE-2018-17432.h5 ${PROJECT_BINARY_DIR}/testfiles/out-HDFFV-10590.h5repack_CVE-2018-17432.h5 + ) + set_tests_properties (H5REPACK-HDFFV-10590 PROPERTIES WILL_FAIL "true") # test CVE-2018-14460 fix - set (arg h5repack_CVE-2018-14460.h5) - set (TESTTYPE "TEST") - ADD_H5_FILTER_TEST (HDFFV-11223 "" ${TESTTYPE} 1 ${arg}) + add_test ( + NAME H5REPACK-HDFFV-11223 + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${PROJECT_BINARY_DIR}/testfiles/h5repack_CVE-2018-14460.h5 ${PROJECT_BINARY_DIR}/testfiles/out-HDFFV-11223.h5repack_CVE-2018-14460.h5 + ) + set_tests_properties (H5REPACK-HDFFV-11223 PROPERTIES WILL_FAIL "true") # tests for metadata block size option ('-M') ADD_H5_TEST_META (meta_short h5repack_layout.h5 -M 8192) diff --git a/tools/test/h5repack/expected/deflate_limit.h5repack_layout.h5.ddl b/tools/test/h5repack/expected/deflate_limit.h5repack_layout.h5.ddl index 75f54fa..9d4ca9b 100644 --- a/tools/test/h5repack/expected/deflate_limit.h5repack_layout.h5.ddl +++ b/tools/test/h5repack/expected/deflate_limit.h5repack_layout.h5.ddl @@ -5,7 +5,7 @@ GROUP "/" { DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } STORAGE_LAYOUT { CHUNKED ( 40, 20 ) - SIZE 1150 (2.783:1 COMPRESSION) + SIZE XXXX (2.XXX:1 COMPRESSION) } FILTERS { COMPRESSION DEFLATE { LEVEL 1 } @@ -23,7 +23,7 @@ GROUP "/" { DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } STORAGE_LAYOUT { CHUNKED ( 40, 20 ) - SIZE 1150 (2.783:1 COMPRESSION) + SIZE XXXX (2.XXX:1 COMPRESSION) } FILTERS { COMPRESSION DEFLATE { LEVEL 1 } @@ -41,7 +41,7 @@ GROUP "/" { DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } STORAGE_LAYOUT { CHUNKED ( 40, 20 ) - SIZE 1150 (2.783:1 COMPRESSION) + SIZE XXXX (2.XXX:1 COMPRESSION) } FILTERS { COMPRESSION DEFLATE { LEVEL 1 } @@ -59,7 +59,7 @@ GROUP "/" { DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } STORAGE_LAYOUT { CHUNKED ( 40, 20 ) - SIZE 1150 (2.783:1 COMPRESSION) + SIZE XXXX (2.XXX:1 COMPRESSION) } FILTERS { COMPRESSION DEFLATE { LEVEL 1 } @@ -77,7 +77,7 @@ GROUP "/" { DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } STORAGE_LAYOUT { CHUNKED ( 20, 10 ) - SIZE 1283 (2.494:1 COMPRESSION) + SIZE XXXX (2.XXX:1 COMPRESSION) } FILTERS { COMPRESSION DEFLATE { LEVEL 1 } @@ -95,7 +95,7 @@ GROUP "/" { DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } STORAGE_LAYOUT { CHUNKED ( 40, 20 ) - SIZE 1150 (2.783:1 COMPRESSION) + SIZE XXXX (2.XXX:1 COMPRESSION) } FILTERS { COMPRESSION DEFLATE { LEVEL 1 } @@ -113,7 +113,7 @@ GROUP "/" { DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } STORAGE_LAYOUT { CHUNKED ( 40, 20 ) - SIZE 1150 (2.783:1 COMPRESSION) + SIZE XXXX (2.XXX:1 COMPRESSION) } FILTERS { COMPRESSION DEFLATE { LEVEL 1 } diff --git a/tools/test/h5repack/expected/h5repack_filters.h5-gzip_verbose_filters.tst b/tools/test/h5repack/expected/h5repack_filters.h5-gzip_verbose_filters.tst index cb12172..644217a 100644 --- a/tools/test/h5repack/expected/h5repack_filters.h5-gzip_verbose_filters.tst +++ b/tools/test/h5repack/expected/h5repack_filters.h5-gzip_verbose_filters.tst @@ -8,7 +8,7 @@ Making new file ... ----------------------------------------- group / dset /dset_all - dset GZIP (0.995:1) /dset_deflate + dset GZIP (0.XXX:1) /dset_deflate dset /dset_fletcher32 dset /dset_nbit dset /dset_shuffle diff --git a/tools/test/h5repack/h5repack.sh.in b/tools/test/h5repack/h5repack.sh.in index ac213f1..db8e603 100644 --- a/tools/test/h5repack/h5repack.sh.in +++ b/tools/test/h5repack/h5repack.sh.in @@ -858,6 +858,11 @@ TOOLTESTV() # display output compare STDOUT_FILTER $actual + tmp_file=/tmp/h5test_tmp_$$ + cp $actual $tmp_file + sed -e 's/GZIP (0\.[0-9][0-9][0-9]:1)/GZIP (0.XXX:1)/' \ + < $tmp_file > $actual + rm -f $tmp_file cat $actual_err >> $actual VERIFY output from $H5REPACK $@ @@ -1136,6 +1141,63 @@ TOOLTEST_DUMP() rm -f $outfile } +# This is same as TOOLTESTV() with comparing h5dump output +# from -pH option and MASK out compression +# +TOOLTEST_DUMP_MASK() +{ + infile=$2 + outfile=out-$1.$2 + expect="$TESTDIR/$1.$2.ddl" + actual="$TESTDIR/out-$1.$2.out" + actual_err="$TESTDIR/out-$1.$2.err" + + shift + shift + + # Run test. + TESTING $H5REPACK $@ + ( + cd $TESTDIR + $RUNSERIAL $H5REPACK_BIN "$@" $infile $outfile + ) >$actual 2>$actual_err + RET=$? + if [ $RET != 0 ] ; then + echo "*FAILED*" + nerrors="`expr $nerrors + 1`" + else + echo " PASSED" + VERIFY h5dump output $@ + ( + cd $TESTDIR + $RUNSERIAL $H5DUMP_BIN -q creation_order -pH $outfile + ) >$actual 2>$actual_err + cat $actual_err >> $actual + + RET=$? + + fi + + tmp_file=/tmp/h5test_tmp_$$ + cp $actual $tmp_file + sed -e 's/SIZE [0-9][0-9][0-9][0-9] (2\.[0-9][0-9][0-9]:1 COMPRESSION)/SIZE XXXX (2.XXX:1 COMPRESSION)/' \ + < $tmp_file > $actual + rm -f $tmp_file + cat $actual_err >> $actual + + if cmp -s $expect $actual; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected result (*.ddl) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && diff -c $expect $actual |sed 's/^/ /' + fi + + rm -f $actual $actual_err + rm -f $outfile +} + # This is same as TOOLTEST_DUMP() with comparing h5dump output # without any option # @@ -1574,7 +1636,7 @@ arg="h5repack_layout.h5 -f GZIP=1 -m 1024" if test $USE_FILTER_DEFLATE != "yes" ; then SKIP $arg else - TOOLTEST_DUMP deflate_limit $arg + TOOLTEST_DUMP_MASK deflate_limit $arg fi #file -- cgit v0.12