Skip to content
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

Adjust h5repack userblock option to allow reserve size #4544

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 4 additions & 1 deletion release_docs/RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,10 @@ New Features

Tools:
------
-
- Allow h5repack to reserve space for a user block without a file

This is useful for users who want to reserve space
in the file for future use without requiring a file to copy.


High-Level APIs:
Expand Down
8 changes: 6 additions & 2 deletions tools/src/h5repack/h5repack.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,8 +746,12 @@ check_options(pack_opt_t *options)
}
}

if (options->ublock_filename == NULL && options->ublock_size != 0)
H5TOOLS_GOTO_ERROR((-1), "file name missing for user block");
if (options->ublock_filename == NULL && options->ublock_size != 0) {
if (options->verbose > 0) {
printf("Warning: user block file name missing. Reserving a size of %ld...\n",
options->ublock_size);
}
}

/*------------------------------------------------------------------------
* Verify alignment options; threshold is zero default but alignment not
Expand Down
2 changes: 1 addition & 1 deletion tools/src/h5repack/h5repack_copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ copy_objects(const char *fnamein, const char *fnameout, pack_opt_t *options)
*-------------------------------------------------------------------------
*/

if (options->ublock_size > 0) {
if (options->ublock_filename != NULL && options->ublock_size > 0) {
if (copy_user_block(options->ublock_filename, fnameout, options->ublock_size) < 0)
H5TOOLS_GOTO_ERROR((-1), "Could not copy user block. Exiting...");
}
Expand Down
48 changes: 48 additions & 0 deletions tools/test/h5repack/CMakeTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,51 @@
)
endmacro ()

macro (ADD_H5_VERIFY_USERBLOCK testname userblocksize testfile)
if (NOT HDF5_USING_ANALYSIS_TOOL)
add_test (
NAME H5REPACK_VERIFY_USERBLOCK-${testname}-clear-objects
COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${testfile}
)
add_test (
NAME H5REPACK_VERIFY_USERBLOCK-${testname}
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repack> --enable-error-stack ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile}
)
set_tests_properties (H5REPACK_VERIFY_USERBLOCK-${testname} PROPERTIES
DEPENDS H5REPACK_VERIFY_USERBLOCK-${testname}-clear-objects
)
if ("H5REPACK_VERIFY_USERBLOCK-${testname}" MATCHES "${HDF5_DISABLE_TESTS_REGEX}")
set_tests_properties (H5REPACK_VERIFY_USERBLOCK-${testname} PROPERTIES DISABLED true)
endif ()
add_test (
NAME H5REPACK_VERIFY_USERBLOCK-${testname}_DMP
COMMAND "${CMAKE_COMMAND}"
-D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
-D "TEST_PROGRAM=$<TARGET_FILE:h5dump>"
-D "TEST_ARGS:STRING=-H;-B;out-${testname}.${testfile}"
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
-D "TEST_OUTPUT=${testfile}-${testname}-v.out"
-D "TEST_EXPECT=${resultcode}"
-D "TEST_FILTER:STRING=USERBLOCK_SIZE ${userblocksize}"
-D "TEST_REFERENCE=USERBLOCK_SIZE ${userblocksize}"
-P "${HDF_RESOURCES_DIR}/grepTest.cmake"
)
set_tests_properties (H5REPACK_VERIFY_USERBLOCK-${testname}_DMP PROPERTIES
DEPENDS H5REPACK_VERIFY_USERBLOCK-${testname}
)
if ("H5REPACK_VERIFY_USERBLOCK-${testname}_DMP" MATCHES "${HDF5_DISABLE_TESTS_REGEX}")
set_tests_properties (H5REPACK_VERIFY_USERBLOCK-${testname}_DMP PROPERTIES DISABLED true)
endif ()
add_test (
NAME H5REPACK_VERIFY_USERBLOCK-${testname}-clean-objects
COMMAND ${CMAKE_COMMAND} -E remove testfiles/out-${testname}.${testfile}
)
set_tests_properties (H5REPACK_VERIFY_USERBLOCK-${testname}-clean-objects PROPERTIES
DEPENDS H5REPACK_VERIFY_USERBLOCK-${testname}_DMP
)
endif ()
endmacro ()

macro (ADD_H5_TEST_META testname testfile)
# Remove any output file left over from previous test run
add_test (
Expand Down Expand Up @@ -1719,6 +1764,9 @@
set (arg ${FILE1} -u ${PROJECT_BINARY_DIR}/testfiles/ublock.bin -b 2048)
ADD_H5_TEST (add_userblock "TEST" ${arg})

# add a userblock reserve to file
ADD_H5_VERIFY_USERBLOCK (reserve_userblock 2048 ${FILE1} -b 2048)

# add alignment
set (arg ${FILE1} -t 1 -a 1)
ADD_H5_TEST (add_alignment "TEST" ${arg})
Expand Down
4 changes: 4 additions & 0 deletions tools/test/h5repack/h5repack.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -1805,6 +1805,10 @@ fi
arg="h5repack_objs.h5 -u ublock.bin -b 2048"
TOOLTEST add_userblock $arg

# reserve a userblock to file
arg="h5repack_objs.h5 -b 2048"
TOOLTEST reserve_userblock $arg

# add alignment
arg="h5repack_objs.h5 -t 1 -a 1 "
TOOLTEST add_alignment $arg
Expand Down
Loading