diff options
author | Allen Byrne <50328838+byrnHDF@users.noreply.github.com> | 2024-03-10 23:43:37 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-10 23:43:37 (GMT) |
commit | 50a65223220142cf0b06a7d25ca53dc56811be01 (patch) | |
tree | 52d42dec08d723ee8949e50b7501dd7fbc1d21d5 /tools/test/h5repack | |
parent | 9bc6c201666aa7fcd7937db7241d4074b67824c9 (diff) | |
download | hdf5-50a65223220142cf0b06a7d25ca53dc56811be01.zip hdf5-50a65223220142cf0b06a7d25ca53dc56811be01.tar.gz hdf5-50a65223220142cf0b06a7d25ca53dc56811be01.tar.bz2 |
Change compression tests reference files to use masking for compression ratios (#4083)
Rework TEST_FILTER tests to handle slightly different compression ratios
Diffstat (limited to 'tools/test/h5repack')
4 files changed, 154 insertions, 21 deletions
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} $<TARGET_FILE:h5repack> ${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} $<TARGET_FILE:h5repack> ${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=$<TARGET_FILE:h5dump>" + -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} $<TARGET_FILE:h5repack> ${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} $<TARGET_FILE:h5repack> ${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 |