@@ -34,6 +34,17 @@ foreach (example ${dyn_examples})
3434endforeach ()
3535
3636if (H5PL_BUILD_TESTING)
37+ # h5repack test input generator. Target name is plugin-suffixed because the
38+ # BITROUND and BITGROOM trees share the same CMake project and source file
39+ # basename (issue #240).
40+ add_executable (h5repack_floats_bitgroom ${PROJECT_SOURCE_DIR } /h5repack_floats.c )
41+ target_include_directories (h5repack_floats_bitgroom PRIVATE ${H5PL_HDF5_INCLUDE_DIRS} )
42+ TARGET_C_PROPERTIES (h5repack_floats_bitgroom ${LIB_TYPE} )
43+ target_link_libraries (h5repack_floats_bitgroom PRIVATE ${H5PL_HDF5_LINK_LIBS} )
44+ if (NOT WIN32 )
45+ target_link_libraries (h5repack_floats_bitgroom PRIVATE ${CMAKE_DL_LIBS } )
46+ endif ()
47+
3748 macro (ADD_H5_TEST testname )
3849 add_test (
3950 NAME ${testname} -clearall
@@ -121,21 +132,47 @@ if (H5PL_BUILD_TESTING)
121132 NAME H5BITGROOM_UD-${testname}-clearall-objects
122133 COMMAND ${CMAKE_COMMAND }
123134 -E remove
135+ ${resultfile}
124136 out-${testname}.${resultfile}
125137 ${testname} .${resultfile}.out
126138 ${testname} .${resultfile}.out.err
127139 ${resultfile} -${testname}.out
128140 ${resultfile} -${testname}.out.err
141+ ${resultfile} -${testname}-data.out
142+ ${resultfile} -${testname}-data.out.err
129143 )
130144 if (NOT "${last_test} " STREQUAL "" )
131145 set_tests_properties (H5BITGROOM_UD-${testname} -clearall-objects PROPERTIES DEPENDS ${last_test} )
132146 endif ()
133147 set (last_test "H5BITGROOM_UD-${testname} -clearall-objects" )
134148 if (WIN32 )
135- set (${ TESTLIBDIR} "${HDF5_TOOLS_DIR} " )
149+ set (TESTLIBDIR "${HDF5_TOOLS_DIR} " )
136150 else ()
137- set (${ TESTLIBDIR} "${HDF5_LIBRARY_PATH} " )
151+ set (TESTLIBDIR "${HDF5_LIBRARY_PATH} " )
138152 endif ()
153+ # Generate the float-data input file for h5repack. The BitGroom filter's
154+ # set_local() callback removes the filter from the pipeline on non-float
155+ # datasets, so the input must contain float data for the test to actually
156+ # exercise the filter (issue #240). Routed through runTest.cmake so
157+ # PATH/DYLD_LIBRARY_PATH/LD_LIBRARY_PATH are set up for the helper to find
158+ # the HDF5 runtime library on every platform (Windows in particular has
159+ # no rpath equivalent and reports STATUS_DLL_NOT_FOUND if the HDF5 DLL is
160+ # not on PATH).
161+ add_test (
162+ NAME H5BITGROOM_UD-${testname}-gen-input
163+ COMMAND "${CMAKE_COMMAND } "
164+ -D "TEST_PROGRAM=$<TARGET_FILE :h5repack_floats_bitgroom >"
165+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR } "
166+ -D "TEST_EXPECT=0"
167+ -D "TEST_OUTPUT=h5repack_floats_bitgroom.out"
168+ -D "TEST_SKIP_COMPARE=1"
169+ -D "TEST_LIBRARY_DIRECTORY=${TESTLIBDIR} "
170+ -P "${H5PL_RESOURCES_DIR} /runTest.cmake"
171+ )
172+ set_tests_properties (H5BITGROOM_UD-${testname} -gen-input PROPERTIES
173+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR } "
174+ DEPENDS H5BITGROOM_UD-${testname} -clearall-objects)
175+ set (last_test "H5BITGROOM_UD-${testname} -gen-input" )
139176 if (HDF5_BUILD_TOOLS OR HDF5_PROVIDES_TOOLS)
140177 add_test (
141178 NAME H5BITGROOM_UD-${testname}
@@ -150,7 +187,7 @@ if (H5PL_BUILD_TESTING)
150187 -D "TEST_LIBRARY_DIRECTORY=${TESTLIBDIR} "
151188 -P "${H5PL_RESOURCES_DIR} /runTest.cmake"
152189 )
153- set_tests_properties (H5BITGROOM_UD-${testname} PROPERTIES DEPENDS H5BITGROOM_UD-${testname} -clearall-objects )
190+ set_tests_properties (H5BITGROOM_UD-${testname} PROPERTIES DEPENDS H5BITGROOM_UD-${testname} -gen-input )
154191 add_test (
155192 NAME H5BITGROOM_UD-h5dump-${testname}
156193 COMMAND "${CMAKE_COMMAND } "
@@ -167,23 +204,43 @@ if (H5PL_BUILD_TESTING)
167204 WORKING_DIRECTORY "${PROJECT_BINARY_DIR } "
168205 DEPENDS H5BITGROOM_UD-${testname} )
169206 set (last_test "H5BITGROOM_UD-h5dump-${testname} " )
207+ # Verify that the filter actually modifies the dataset values: dump the
208+ # data (no -pH) and compare against a captured reference of the
209+ # quantized output. BitGroom's encoding is bit-deterministic across
210+ # platforms (its inner loop is pure integer bit ops, with the bit-zero
211+ # count derived once per call from NSD via ceil() of a constant
212+ # expression), so the captured reference is portable.
213+ add_test (
214+ NAME H5BITGROOM_UD-h5dump-data-${testname}
215+ COMMAND "${CMAKE_COMMAND } "
216+ -D "TEST_PROGRAM=${H5PL_HDF5_DUMP_EXECUTABLE} "
217+ -D "TEST_ARGS:STRING=out-${testname} .${resultfile} "
218+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR } "
219+ -D "TEST_OUTPUT=${resultfile} -${testname} -data.out"
220+ -D "TEST_EXPECT=${resultcode} "
221+ -D "TEST_REFERENCE=${resultfile} -${testname} -data.ddl"
222+ -D "TEST_LIBRARY_DIRECTORY=${TESTLIBDIR} "
223+ -P "${H5PL_RESOURCES_DIR} /runTest.cmake"
224+ )
225+ set_tests_properties (H5BITGROOM_UD-h5dump-data-${testname} PROPERTIES
226+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR } "
227+ DEPENDS H5BITGROOM_UD-h5dump-${testname} )
228+ set (last_test "H5BITGROOM_UD-h5dump-data-${testname} " )
170229 endif ()
171230 endmacro ()
172231
173232 # --------------------------------------------------------------------
174233 # Copy all the HDF5 files from the source directory into the test directory
175234 # --------------------------------------------------------------------
176- set (LIST_HDF5_TEST_FILES
177- h5repack_layout.h5
178- )
179235 set (LIST_OTHER_TEST_FILES
180236 h5ex_d_bitgroom.ddl
181237 h5ex_d_bitgroom.tst
182- h5repack_layout.h5-ud_convert.ddl
183- ud_convert.h5repack_layout.h5.tst
238+ h5repack_floats.h5-ud_convert.ddl
239+ h5repack_floats.h5-ud_convert-data.ddl
240+ ud_convert.h5repack_floats.h5.tst
184241 )
185242
186- foreach (h5_file ${LIST_HDF5_TEST_FILES} ${ LIST_OTHER_TEST_FILES} )
243+ foreach (h5_file ${LIST_OTHER_TEST_FILES} )
187244 HDFTEST_COPY_FILE ("${PROJECT_SOURCE_DIR } /testfiles/${h5_file} " "${PROJECT_BINARY_DIR } /${h5_file} " "example_files" )
188245 endforeach ()
189246 add_custom_target (example_files ALL COMMENT "Copying files needed by example tests" DEPENDS ${example_files_list} )
@@ -192,7 +249,7 @@ if (H5PL_BUILD_TESTING)
192249
193250 if (NOT DISABLE_H5PL_ENCODER)
194251 #UD BITGROOM
195- ADD_H5_UD_TEST (ud_convert 0 h5repack_layout .h5 --enable-error-stack -v -f UD=32022,0,5,3,4,0,0,0 -l CHUNK=4x8 )
252+ ADD_H5_UD_TEST (ud_convert 0 h5repack_floats .h5 --enable-error-stack -v -f UD=32022,0,5,3,4,0,0,0 -l CHUNK=4x8 )
196253 endif ()
197254
198255endif ()
0 commit comments