From 1975bbad41dc08c0b8c68c4855c8d03e161dd329 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 6 Mar 2024 16:26:50 -0600 Subject: [PATCH 01/11] Rework TEST_FILTER tests for compression --- 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/h5repack/CMakeTests.cmake | 29 ++++++++++++------- ...repack_filters.h5-gzip_verbose_filters.tst | 2 +- tools/test/h5repack/h5repack.sh.in | 4 +++ 7 files changed, 41 insertions(+), 16 deletions(-) diff --git a/HDF5Examples/config/cmake/runTest.cmake b/HDF5Examples/config/cmake/runTest.cmake index 3507c3482d5..cc433b1e518 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 4257c442c6a..ff9732e0821 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 0e35a089353..8b78e7d2db8 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 03a783e8666..2d7f5f7b04d 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/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index b4a92e77ef2..9a997eb0c27 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}" @@ -1017,7 +1019,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 +1364,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 @@ -1688,14 +1690,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-17432.h5 ${PROJECT_BINARY_DIR}/testfiles/out-HDFFV-11223.h5repack_CVE-2018-17432.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/h5repack_filters.h5-gzip_verbose_filters.tst b/tools/test/h5repack/expected/h5repack_filters.h5-gzip_verbose_filters.tst index cb121726c64..644217a3b02 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 ac213f1f4ba..b56788d8021 100644 --- a/tools/test/h5repack/h5repack.sh.in +++ b/tools/test/h5repack/h5repack.sh.in @@ -858,6 +858,10 @@ TOOLTESTV() # display output compare STDOUT_FILTER $actual + 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 $@ From 9918edf08d0a1c7148ec057ed579f080022261ea Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 7 Mar 2024 07:25:02 -0600 Subject: [PATCH 02/11] specify name of temp file --- tools/test/h5repack/h5repack.sh.in | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/test/h5repack/h5repack.sh.in b/tools/test/h5repack/h5repack.sh.in index b56788d8021..a7371fdcf06 100644 --- a/tools/test/h5repack/h5repack.sh.in +++ b/tools/test/h5repack/h5repack.sh.in @@ -858,6 +858,7 @@ 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 From 045cee33e28e32cc31127da8b62195f4902e81d8 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 7 Mar 2024 08:50:55 -0600 Subject: [PATCH 03/11] do not escape parens in sed --- tools/test/h5repack/h5repack.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test/h5repack/h5repack.sh.in b/tools/test/h5repack/h5repack.sh.in index a7371fdcf06..c541c0cd6e1 100644 --- a/tools/test/h5repack/h5repack.sh.in +++ b/tools/test/h5repack/h5repack.sh.in @@ -860,7 +860,7 @@ TOOLTESTV() 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)/' \ + 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 From 12db9cab7721c132962125becf5ca1f6d822f1b9 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 7 Mar 2024 09:34:31 -0600 Subject: [PATCH 04/11] Mask compression in repack dump test --- tools/test/h5repack/CMakeTests.cmake | 66 ++++++++++++++++++- .../deflate_limit.h5repack_layout.h5.ddl | 14 ++-- tools/test/h5repack/h5repack.sh.in | 59 ++++++++++++++++- 3 files changed, 130 insertions(+), 9 deletions(-) diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index 9a997eb0c27..d0a1bf012cc 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/h5repack/CMakeTests.cmake @@ -530,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) @@ -1481,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}) 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 75f54faa7ad..9d4ca9b65e8 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/h5repack.sh.in b/tools/test/h5repack/h5repack.sh.in index c541c0cd6e1..db8e603a88d 100644 --- a/tools/test/h5repack/h5repack.sh.in +++ b/tools/test/h5repack/h5repack.sh.in @@ -1141,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 # @@ -1579,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 From e6e9279bb8947a89bfb003670cd3975e4a546c56 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 7 Mar 2024 11:36:54 -0600 Subject: [PATCH 05/11] Add compression mask for scaleoffset --- tools/test/h5dump/CMakeTests.cmake | 36 +++++++++++- tools/test/h5dump/expected/tscaleoffset.ddl | 2 +- tools/test/h5dump/testh5dump.sh.in | 65 ++++++++++++++++++++- 3 files changed, 100 insertions(+), 3 deletions(-) diff --git a/tools/test/h5dump/CMakeTests.cmake b/tools/test/h5dump/CMakeTests.cmake index d7f39e1bb56..c1a1b641059 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 @@ -1250,7 +1284,7 @@ ADD_H5_TEST (tnbit 0 --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) diff --git a/tools/test/h5dump/expected/tscaleoffset.ddl b/tools/test/h5dump/expected/tscaleoffset.ddl index a039736d1c1..ebff6c1eddf 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/testh5dump.sh.in b/tools/test/h5dump/testh5dump.sh.in index fdeb17d29aa..b911f3c5a15 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 @@ -1365,7 +1428,7 @@ TOOLTEST tfletcher32.ddl --enable-error-stack -H -p -d fletcher32 tfilters.h5 # nbit TOOLTEST 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 # user defined From bcde44b906e7cf8d57e74554add6b2fff89575c4 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 7 Mar 2024 12:24:22 -0600 Subject: [PATCH 06/11] quote variable --- tools/test/h5dump/testh5dump.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test/h5dump/testh5dump.sh.in b/tools/test/h5dump/testh5dump.sh.in index b911f3c5a15..d50cacbd772 100644 --- a/tools/test/h5dump/testh5dump.sh.in +++ b/tools/test/h5dump/testh5dump.sh.in @@ -575,7 +575,7 @@ TOOLTESTC() { 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)/' \ + 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 From 544042f1260eda17f1aa2a9e214a68136ad9a24b Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 7 Mar 2024 13:48:52 -0600 Subject: [PATCH 07/11] try extra quotes --- tools/test/h5dump/testh5dump.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test/h5dump/testh5dump.sh.in b/tools/test/h5dump/testh5dump.sh.in index d50cacbd772..f81a24cd199 100644 --- a/tools/test/h5dump/testh5dump.sh.in +++ b/tools/test/h5dump/testh5dump.sh.in @@ -575,7 +575,7 @@ TOOLTESTC() { 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)/' \ + 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 From 126a8d93583f881454c8f31b5bcab20066a1db6b Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 7 Mar 2024 15:02:48 -0600 Subject: [PATCH 08/11] Update all h5dump Compression tests for masking --- tools/test/h5dump/CMakeTests.cmake | 10 +++++----- 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/testh5dump.sh.in | 10 +++++----- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tools/test/h5dump/CMakeTests.cmake b/tools/test/h5dump/CMakeTests.cmake index c1a1b641059..586957e7c20 100644 --- a/tools/test/h5dump/CMakeTests.cmake +++ b/tools/test/h5dump/CMakeTests.cmake @@ -1269,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_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 ff2454cef78..43bcf6a0eb9 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 9b92d0e1664..504d4f32042 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 01460e2cad4..aafd4d4abba 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 cf2ac1fdb91..35c111fb5b3 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/testh5dump.sh.in b/tools/test/h5dump/testh5dump.sh.in index f81a24cd199..47348659e1d 100644 --- a/tools/test/h5dump/testh5dump.sh.in +++ b/tools/test/h5dump/testh5dump.sh.in @@ -1418,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 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 From 7b4641873f44477fb106bbc6185f08b400808604 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 7 Mar 2024 15:28:18 -0600 Subject: [PATCH 09/11] fix ref file --- tools/test/h5dump/expected/tszip.ddl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test/h5dump/expected/tszip.ddl b/tools/test/h5dump/expected/tszip.ddl index 06e22593317..035119fde63 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 (1.XXX:1 COMPRESSION) } FILTERS { COMPRESSION SZIP { From b7db7fcfbd5fd8dfa83c1886dbf70ce2d754ee91 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 7 Mar 2024 15:45:23 -0600 Subject: [PATCH 10/11] Correct typo --- tools/test/h5dump/expected/tszip.ddl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test/h5dump/expected/tszip.ddl b/tools/test/h5dump/expected/tszip.ddl index 035119fde63..3f04cf7a048 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 XXXX (1.XXX:1 COMPRESSION) + SIZE XXXX (2.XXX:1 COMPRESSION) } FILTERS { COMPRESSION SZIP { From d06a12c54b9449d1e8c55ee6d1b4617db0fc41c8 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Sat, 9 Mar 2024 09:22:38 -0600 Subject: [PATCH 11/11] Correct filenames used in test --- tools/test/h5repack/CMakeTests.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index d0a1bf012cc..0114df863f0 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/h5repack/CMakeTests.cmake @@ -1764,7 +1764,7 @@ # test CVE-2018-14460 fix add_test ( NAME H5REPACK-HDFFV-11223 - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${PROJECT_BINARY_DIR}/testfiles/h5repack_CVE-2018-17432.h5 ${PROJECT_BINARY_DIR}/testfiles/out-HDFFV-11223.h5repack_CVE-2018-17432.h5 + 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")