Skip to content

Corrected colon behavior and UD with zero elements #5480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion release_docs/RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,14 @@ Bug Fixes since HDF5-2.0.0 release

Tools
-----
-
- h5repack did not properly parse User Defined filters

The h5repack tool did not properly parse user-defined filter command-line
arguments when the number of elements value was 0 (zero).
Also, using a colon without a preceding object was enforced to behave the
same as not using a colon.

Fixes GitHub issue #5132


Performance
Expand Down
11 changes: 7 additions & 4 deletions tools/src/h5repack/h5repack_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, pack_opt_t
n++;

/* Check for missing : */
if (end_obj == -1) {
if (end_obj <= 0) {
/* apply to all objects */
options->all_filter = 1;
*is_glb = 1;
Expand Down Expand Up @@ -236,7 +236,8 @@ parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, pack_opt_t
p = 0;
}
else {
filt->cd_values[j++] = (unsigned)strtoul(stype, NULL, 0);
if (filt->cd_nelmts > 0)
filt->cd_values[j++] = (unsigned)strtoul(stype, NULL, 0);
}
q = 0;
u++; /* skip ',' */
Expand Down Expand Up @@ -279,9 +280,11 @@ parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, pack_opt_t
stype[m] = '\0';
} /*if */

filt->cd_values[j++] = (unsigned)strtoul(stype, NULL, 0);
if (filt->cd_nelmts == 0)
if ((strcmp(scomp, "UD") == 0) && (filt->cd_nelmts == 0))
j = 0;
else
filt->cd_values[j++] = (unsigned)strtoul(stype, NULL, 0);

i += m; /* jump */
}
else if (i == len - 1) { /*no more parameters */
Expand Down
71 changes: 44 additions & 27 deletions tools/test/h5repack/CMakeTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1142,34 +1142,44 @@
if ("H5REPACK_UD-${testname}" MATCHES "${HDF5_DISABLE_TESTS_REGEX}")
set_tests_properties (H5REPACK_UD-${testname} PROPERTIES DISABLED true)
endif ()
add_test (
NAME H5REPACK_UD-${testname}-h5dump
COMMAND "${CMAKE_COMMAND}"
-D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
-D "TEST_PROGRAM=$<TARGET_FILE:h5dump>"
-D "TEST_ARGS:STRING=-pH;out-${testname}.${resultfile}"
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
-D "TEST_OUTPUT=${resultfile}-${testname}.out"
-D "TEST_EXPECT=0"
-D "TEST_REFERENCE=${resultfile}-${testname}.ddl"
-D "TEST_ENV_VAR=HDF5_PLUGIN_PATH"
-D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}/plugins"
-D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}"
-P "${HDF_RESOURCES_DIR}/runTest.cmake"
)
set_tests_properties (H5REPACK_UD-${testname}-h5dump PROPERTIES
DEPENDS H5REPACK_UD-${testname}
)
if ("H5REPACK_UD-${testname}-h5dump" MATCHES "${HDF5_DISABLE_TESTS_REGEX}")
set_tests_properties (H5REPACK_UD-${testname}-h5dump PROPERTIES DISABLED true)
if (NOT ${resultcode})
add_test (
NAME H5REPACK_UD-${testname}-h5dump
COMMAND "${CMAKE_COMMAND}"
-D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
-D "TEST_PROGRAM=$<TARGET_FILE:h5dump>"
-D "TEST_ARGS:STRING=-pH;out-${testname}.${resultfile}"
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
-D "TEST_OUTPUT=${resultfile}-${testname}.out"
-D "TEST_EXPECT=0"
-D "TEST_REFERENCE=${resultfile}-${testname}.ddl"
-D "TEST_ENV_VAR=HDF5_PLUGIN_PATH"
-D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}/plugins"
-D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}"
-P "${HDF_RESOURCES_DIR}/runTest.cmake"
)
set_tests_properties (H5REPACK_UD-${testname}-h5dump PROPERTIES
DEPENDS H5REPACK_UD-${testname}
)
if ("H5REPACK_UD-${testname}-h5dump" MATCHES "${HDF5_DISABLE_TESTS_REGEX}")
set_tests_properties (H5REPACK_UD-${testname}-h5dump PROPERTIES DISABLED true)
endif ()
add_test (
NAME H5REPACK_UD-${testname}-clean-objects
COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${resultfile}
)
set_tests_properties (H5REPACK_UD-${testname}-clean-objects PROPERTIES
DEPENDS H5REPACK_UD-${testname}-h5dump
)
else ()
add_test (
NAME H5REPACK_UD-${testname}-clean-objects
COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${resultfile}
)
set_tests_properties (H5REPACK_UD-${testname}-clean-objects PROPERTIES
DEPENDS H5REPACK_UD-${testname}
)
endif ()
add_test (
NAME H5REPACK_UD-${testname}-clean-objects
COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${resultfile}
)
set_tests_properties (H5REPACK_UD-${testname}-clean-objects PROPERTIES
DEPENDS H5REPACK_UD-${testname}-h5dump
)
endif ()
endmacro ()

Expand Down Expand Up @@ -1933,6 +1943,13 @@ if (BUILD_SHARED_LIBS)
ADD_H5_UD_TEST (plugin_none 0 h5repack_layout.UD.h5 -v -f NONE)
# check for no parameters
ADD_H5_UD_TEST (plugin_zero 0 h5repack_layout.h5 -v -f UD=250,0,0)
# check for less parameters
ADD_H5_UD_TEST (plugin_test_less 1 h5repack_layout.h5 --enable-error-stack -v -f UD=257,0,1)
# check for extra parameters
# could create different macro to grep: h5repack error: incorrect number of compression parameters
ADD_H5_UD_TEST (plugin_test_ex 1 h5repack_layout.h5 --enable-error-stack -v -f UD=257,0,1,9,9,9)
# check for extra parameters, which are ignored when nelms is 0
ADD_H5_UD_TEST (plugin_zero_extra 0 h5repack_layout.h5 --enable-error-stack -v -f UD=250,0,0,1,2)
endif ()

##############################################################################
Expand Down
Loading