Skip to content

Commit a43b1f2

Browse files
authored
Corrected colon behavior and UD with zero elements (#5480)
* Add test for nelems different then required
1 parent d9f5f50 commit a43b1f2

File tree

3 files changed

+61
-32
lines changed

3 files changed

+61
-32
lines changed

release_docs/RELEASE.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,15 @@ Bug Fixes since HDF5-2.0.0 release
727727

728728
Tools
729729
-----
730+
- h5repack did not properly parse User Defined filters
731+
732+
The h5repack tool did not properly parse user-defined filter command-line
733+
arguments when the number of elements value was 0 (zero).
734+
Also, using a colon without a preceding object was enforced to behave the
735+
same as not using a colon.
736+
737+
Fixes GitHub issue #5132
738+
730739
- Changed the default value for number of cd_values in filters.
731740

732741
The tools used an arbitrary value 0f 20 for the number of cd_values used in a filter.

tools/src/h5repack/h5repack_parse.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, pack_opt_t
6868
n++;
6969

7070
/* Check for missing : */
71-
if (end_obj == -1) {
71+
if (end_obj <= 0) {
7272
/* apply to all objects */
7373
options->all_filter = 1;
7474
*is_glb = 1;
@@ -236,7 +236,8 @@ parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, pack_opt_t
236236
p = 0;
237237
}
238238
else {
239-
filt->cd_values[j++] = (unsigned)strtoul(stype, NULL, 0);
239+
if (filt->cd_nelmts > 0)
240+
filt->cd_values[j++] = (unsigned)strtoul(stype, NULL, 0);
240241
}
241242
q = 0;
242243
u++; /* skip ',' */
@@ -279,9 +280,11 @@ parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, pack_opt_t
279280
stype[m] = '\0';
280281
} /*if */
281282

282-
filt->cd_values[j++] = (unsigned)strtoul(stype, NULL, 0);
283-
if (filt->cd_nelmts == 0)
283+
if ((strcmp(scomp, "UD") == 0) && (filt->cd_nelmts == 0))
284284
j = 0;
285+
else
286+
filt->cd_values[j++] = (unsigned)strtoul(stype, NULL, 0);
287+
285288
i += m; /* jump */
286289
}
287290
else if (i == len - 1) { /*no more parameters */
@@ -354,7 +357,7 @@ parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, pack_opt_t
354357
else if (strcmp(scomp, "FLET") == 0) {
355358
filt->filtn = H5Z_FILTER_FLETCHER32;
356359
filt->cd_nelmts = 0;
357-
if (m > 0) { /*shuffle does not have parameter */
360+
if (m > 0) { /* fletcher does not have parameter */
358361
if (obj_list)
359362
free(obj_list);
360363
error_msg("extra parameter in FLET <%s>\n", str);

tools/test/h5repack/CMakeTests.cmake

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,34 +1142,44 @@
11421142
if ("H5REPACK_UD-${testname}" MATCHES "${HDF5_DISABLE_TESTS_REGEX}")
11431143
set_tests_properties (H5REPACK_UD-${testname} PROPERTIES DISABLED true)
11441144
endif ()
1145-
add_test (
1146-
NAME H5REPACK_UD-${testname}-h5dump
1147-
COMMAND "${CMAKE_COMMAND}"
1148-
-D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
1149-
-D "TEST_PROGRAM=$<TARGET_FILE:h5dump>"
1150-
-D "TEST_ARGS:STRING=-pH;out-${testname}.${resultfile}"
1151-
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
1152-
-D "TEST_OUTPUT=${resultfile}-${testname}.out"
1153-
-D "TEST_EXPECT=0"
1154-
-D "TEST_REFERENCE=${resultfile}-${testname}.ddl"
1155-
-D "TEST_ENV_VAR=HDF5_PLUGIN_PATH"
1156-
-D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}/plugins"
1157-
-D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}"
1158-
-P "${HDF_RESOURCES_DIR}/runTest.cmake"
1159-
)
1160-
set_tests_properties (H5REPACK_UD-${testname}-h5dump PROPERTIES
1161-
DEPENDS H5REPACK_UD-${testname}
1162-
)
1163-
if ("H5REPACK_UD-${testname}-h5dump" MATCHES "${HDF5_DISABLE_TESTS_REGEX}")
1164-
set_tests_properties (H5REPACK_UD-${testname}-h5dump PROPERTIES DISABLED true)
1145+
if (NOT ${resultcode})
1146+
add_test (
1147+
NAME H5REPACK_UD-${testname}-h5dump
1148+
COMMAND "${CMAKE_COMMAND}"
1149+
-D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
1150+
-D "TEST_PROGRAM=$<TARGET_FILE:h5dump>"
1151+
-D "TEST_ARGS:STRING=-pH;out-${testname}.${resultfile}"
1152+
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
1153+
-D "TEST_OUTPUT=${resultfile}-${testname}.out"
1154+
-D "TEST_EXPECT=0"
1155+
-D "TEST_REFERENCE=${resultfile}-${testname}.ddl"
1156+
-D "TEST_ENV_VAR=HDF5_PLUGIN_PATH"
1157+
-D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}/plugins"
1158+
-D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_OUTPUT_DIRECTORY}"
1159+
-P "${HDF_RESOURCES_DIR}/runTest.cmake"
1160+
)
1161+
set_tests_properties (H5REPACK_UD-${testname}-h5dump PROPERTIES
1162+
DEPENDS H5REPACK_UD-${testname}
1163+
)
1164+
if ("H5REPACK_UD-${testname}-h5dump" MATCHES "${HDF5_DISABLE_TESTS_REGEX}")
1165+
set_tests_properties (H5REPACK_UD-${testname}-h5dump PROPERTIES DISABLED true)
1166+
endif ()
1167+
add_test (
1168+
NAME H5REPACK_UD-${testname}-clean-objects
1169+
COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${resultfile}
1170+
)
1171+
set_tests_properties (H5REPACK_UD-${testname}-clean-objects PROPERTIES
1172+
DEPENDS H5REPACK_UD-${testname}-h5dump
1173+
)
1174+
else ()
1175+
add_test (
1176+
NAME H5REPACK_UD-${testname}-clean-objects
1177+
COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${resultfile}
1178+
)
1179+
set_tests_properties (H5REPACK_UD-${testname}-clean-objects PROPERTIES
1180+
DEPENDS H5REPACK_UD-${testname}
1181+
)
11651182
endif ()
1166-
add_test (
1167-
NAME H5REPACK_UD-${testname}-clean-objects
1168-
COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${resultfile}
1169-
)
1170-
set_tests_properties (H5REPACK_UD-${testname}-clean-objects PROPERTIES
1171-
DEPENDS H5REPACK_UD-${testname}-h5dump
1172-
)
11731183
endif ()
11741184
endmacro ()
11751185

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

19381955
##############################################################################

0 commit comments

Comments
 (0)