summaryrefslogtreecommitdiffstats
path: root/tools/test/misc
diff options
context:
space:
mode:
Diffstat (limited to 'tools/test/misc')
-rw-r--r--tools/test/misc/CMakeLists.txt90
-rw-r--r--tools/test/misc/CMakeTestsClear.cmake491
-rw-r--r--tools/test/misc/CMakeTestsMkgrp.cmake172
-rw-r--r--tools/test/misc/CMakeTestsRepart.cmake137
-rw-r--r--tools/test/misc/Makefile.am44
-rw-r--r--tools/test/misc/clear_open_chk.c70
-rw-r--r--tools/test/misc/h5clear_gentest.c609
-rw-r--r--tools/test/misc/h5perf_gentest.c653
-rw-r--r--tools/test/misc/h5repart_gentest.c113
-rw-r--r--tools/test/misc/repart_test.c151
-rw-r--r--tools/test/misc/talign.c202
-rw-r--r--tools/test/misc/testfiles/h5clear_equal_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_equal_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_equal.h5bin0 -> 2565 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_greater.h5bin0 -> 2565 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_less.h5bin0 -> 2565 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_noclose.h5bin0 -> 2448 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_user_equal.h5bin0 -> 3077 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_user_greater.h5bin0 -> 3077 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_user_less.h5bin0 -> 3077 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_greater_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_greater_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_less_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_less_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_log_v3.h5bin0 -> 2048 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_mdc_image.h5bin0 -> 23467 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_missing_file.ddl28
-rw-r--r--tools/test/misc/testfiles/h5clear_missing_file.err1
-rw-r--r--tools/test/misc/testfiles/h5clear_no_mdc_image.err1
-rw-r--r--tools/test/misc/testfiles/h5clear_noclose_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_noclose_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_open_fail.err1
-rw-r--r--tools/test/misc/testfiles/h5clear_sec2_v0.h5bin0 -> 800 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_sec2_v2.h5bin0 -> 830 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_sec2_v3.h5bin0 -> 195 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_status_noclose.h5bin0 -> 2448 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_status_noclose_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_usage.ddl28
-rw-r--r--tools/test/misc/testfiles/h5clear_user_equal_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_user_equal_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_user_greater_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_user_greater_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_user_less_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_user_less_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5mkgrp_help.txt20
-rw-r--r--tools/test/misc/testfiles/h5mkgrp_version.txt.in1
-rw-r--r--tools/test/misc/testfiles/latest_h5clear_log_v3.h5bin0 -> 2048 bytes
-rw-r--r--tools/test/misc/testfiles/latest_h5clear_sec2_v3.h5bin0 -> 195 bytes
-rw-r--r--tools/test/misc/testfiles/mod_h5clear_mdc_image.h5bin0 -> 22048 bytes
-rw-r--r--tools/test/misc/testh5clear.sh.in459
-rw-r--r--tools/test/misc/testh5mkgrp.sh.in324
-rw-r--r--tools/test/misc/testh5repart.sh.in196
-rw-r--r--tools/test/misc/vds/CMakeLists.txt35
-rw-r--r--tools/test/misc/vds/Makefile.am35
-rw-r--r--tools/test/misc/vds/UC_1.h101
-rw-r--r--tools/test/misc/vds/UC_1_one_dim_gen.c243
-rw-r--r--tools/test/misc/vds/UC_2.h97
-rw-r--r--tools/test/misc/vds/UC_2_two_dims_gen.c245
-rw-r--r--tools/test/misc/vds/UC_3.h69
-rw-r--r--tools/test/misc/vds/UC_3_gaps_gen.c242
-rw-r--r--tools/test/misc/vds/UC_4.h73
-rw-r--r--tools/test/misc/vds/UC_4_printf_gen.c208
-rw-r--r--tools/test/misc/vds/UC_5.h71
-rw-r--r--tools/test/misc/vds/UC_5_stride_gen.c231
-rw-r--r--tools/test/misc/vds/UC_common.h43
65 files changed, 5499 insertions, 0 deletions
diff --git a/tools/test/misc/CMakeLists.txt b/tools/test/misc/CMakeLists.txt
new file mode 100644
index 0000000..6d01d99
--- /dev/null
+++ b/tools/test/misc/CMakeLists.txt
@@ -0,0 +1,90 @@
+cmake_minimum_required (VERSION 3.18)
+project (HDF5_TOOLS_TEST_MISC C)
+
+# --------------------------------------------------------------------
+# Add the misc test executables
+# --------------------------------------------------------------------
+if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS)
+ add_executable (h5repart_gentest ${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/h5repart_gentest.c)
+ target_include_directories (h5repart_gentest PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ if (NOT ONLY_SHARED_LIBS)
+ TARGET_C_PROPERTIES (h5repart_gentest STATIC)
+ target_link_libraries (h5repart_gentest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET})
+ else ()
+ TARGET_C_PROPERTIES (h5repart_gentest SHARED)
+ target_link_libraries (h5repart_gentest PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET})
+ endif ()
+ set_target_properties (h5repart_gentest PROPERTIES FOLDER generator/tools)
+ #add_test (NAME h5repart_gentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repart_gentest>)
+
+ #-----------------------------------------------------------------------------
+ # Add Target to clang-format
+ #-----------------------------------------------------------------------------
+ if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_TOOLS_TEST_MISC_h5repart_gentest_FORMAT h5repart_gentest)
+ endif ()
+
+ add_executable (h5clear_gentest ${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/h5clear_gentest.c)
+ target_include_directories (h5clear_gentest PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_TEST_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ if (NOT ONLY_SHARED_LIBS)
+ TARGET_C_PROPERTIES (h5clear_gentest STATIC)
+ target_link_libraries (h5clear_gentest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET})
+ else ()
+ TARGET_C_PROPERTIES (h5clear_gentest SHARED)
+ target_link_libraries (h5clear_gentest PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET})
+ endif ()
+ set_target_properties (h5clear_gentest PROPERTIES FOLDER tools)
+ #add_test (NAME H5CLEAR-h5clear_gentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear_gentest>)
+
+ #-----------------------------------------------------------------------------
+ # Add Target to clang-format
+ #-----------------------------------------------------------------------------
+ if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_TOOLS_TEST_MISC_h5clear_gentest_FORMAT h5clear_gentest)
+ endif ()
+
+ add_subdirectory (vds)
+
+endif ()
+
+add_executable (h5repart_test ${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/repart_test.c)
+target_include_directories (h5repart_test PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+if (NOT ONLY_SHARED_LIBS)
+ TARGET_C_PROPERTIES (h5repart_test STATIC)
+ target_link_libraries (h5repart_test PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
+else ()
+ TARGET_C_PROPERTIES (h5repart_test SHARED)
+ target_link_libraries (h5repart_test PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
+endif ()
+set_target_properties (h5repart_test PROPERTIES FOLDER tools)
+
+#-----------------------------------------------------------------------------
+# Add Target to clang-format
+#-----------------------------------------------------------------------------
+if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_TOOLS_TEST_MISC_h5repart_test_FORMAT h5repart_test)
+endif ()
+
+add_executable (clear_open_chk ${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/clear_open_chk.c)
+target_include_directories (clear_open_chk PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+if (NOT ONLY_SHARED_LIBS)
+ TARGET_C_PROPERTIES (clear_open_chk STATIC)
+ target_link_libraries (clear_open_chk PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
+else ()
+ TARGET_C_PROPERTIES (clear_open_chk SHARED)
+ target_link_libraries (clear_open_chk PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
+endif ()
+set_target_properties (clear_open_chk PROPERTIES FOLDER tools)
+
+#-----------------------------------------------------------------------------
+# Add Target to clang-format
+#-----------------------------------------------------------------------------
+if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_TOOLS_TEST_MISC_clear_open_chk_FORMAT clear_open_chk)
+endif ()
+
+if (HDF5_TEST_SERIAL)
+ include (CMakeTestsRepart.cmake)
+ include (CMakeTestsClear.cmake)
+ include (CMakeTestsMkgrp.cmake)
+endif ()
diff --git a/tools/test/misc/CMakeTestsClear.cmake b/tools/test/misc/CMakeTestsClear.cmake
new file mode 100644
index 0000000..5e307aa
--- /dev/null
+++ b/tools/test/misc/CMakeTestsClear.cmake
@@ -0,0 +1,491 @@
+#
+# Copyright by The HDF Group.
+# All rights reserved.
+#
+# This file is part of HDF5. The full HDF5 copyright notice, including
+# terms governing use, modification, and redistribution, is contained in
+# the COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://www.hdfgroup.org/licenses.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
+#
+
+##############################################################################
+##############################################################################
+### T E S T I N G ###
+##############################################################################
+##############################################################################
+
+ # --------------------------------------------------------------------
+ # Copy all the HDF5 files from the source directory into the test directory
+ # --------------------------------------------------------------------
+ set (HDF5_TEST_FILES
+ h5clear_fsm_persist_equal.h5
+ h5clear_fsm_persist_greater.h5
+ h5clear_fsm_persist_less.h5
+ h5clear_fsm_persist_noclose.h5
+ h5clear_fsm_persist_user_equal.h5
+ h5clear_fsm_persist_user_greater.h5
+ h5clear_fsm_persist_user_less.h5
+ h5clear_log_v3.h5
+ h5clear_mdc_image.h5
+ h5clear_status_noclose.h5
+ latest_h5clear_log_v3.h5
+ latest_h5clear_sec2_v3.h5
+ mod_h5clear_mdc_image.h5
+ )
+ set (HDF5_SEC2_TEST_FILES
+ h5clear_sec2_v0.h5
+ h5clear_sec2_v2.h5
+ h5clear_sec2_v3.h5
+ )
+ set (HDF5_REFERENCE_TEST_FILES
+ h5clear_equal_after_size.ddl
+ h5clear_equal_before_size.ddl
+ h5clear_greater_after_size.ddl
+ h5clear_greater_before_size.ddl
+ h5clear_less_after_size.ddl
+ h5clear_less_before_size.ddl
+ h5clear_missing_file.ddl
+ h5clear_noclose_after_size.ddl
+ h5clear_noclose_before_size.ddl
+ h5clear_status_noclose_after_size.ddl
+ h5clear_usage.ddl
+ h5clear_user_equal_after_size.ddl
+ h5clear_user_equal_before_size.ddl
+ h5clear_user_greater_after_size.ddl
+ h5clear_user_greater_before_size.ddl
+ h5clear_user_less_after_size.ddl
+ h5clear_user_less_before_size.ddl
+ )
+ set (HDF5_REFERENCE_ERR_FILES
+ h5clear_no_mdc_image.err
+ h5clear_open_fail.err
+ )
+
+ foreach (h5_file ${HDF5_TEST_FILES} ${HDF5_SEC2_TEST_FILES} ${HDF5_REFERENCE_TEST_FILES})
+ HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/testfiles/${h5_file}" "h5clear_files")
+ endforeach ()
+ foreach (h5_file ${HDF5_REFERENCE_ERR_FILES})
+ HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/testfiles/${h5_file}" "h5clear_files")
+ endforeach ()
+ # make second copy of h5clear_sec2.h5
+ foreach (h5_file ${HDF5_SEC2_TEST_FILES})
+ HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/testfiles/orig_${h5_file}" "h5clear_files")
+ endforeach ()
+ # make second copy of mod_h5clear_mdc_image.h5
+ HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/testfiles/mod_h5clear_mdc_image.h5" "${PROJECT_BINARY_DIR}/testfiles/mod_h5clear_mdc_image2.h5" "h5clear_files")
+ add_custom_target(h5clear_files ALL COMMENT "Copying files needed by h5clear tests" DEPENDS ${h5clear_files_list})
+
+##############################################################################
+##############################################################################
+### T H E T E S T S M A C R O S ###
+##############################################################################
+##############################################################################
+
+ # Need special dependencies for tests that use the same reference file
+ # This is an issue on Windows
+ macro (ADD_H5_CMP testname resultfile resultcode)
+ if (NOT HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (
+ NAME H5CLEAR_CMP-${testname}
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_file_ext}>"
+ -D "TEST_ARGS:STRING=${ARGN}"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
+ -D "TEST_OUTPUT=${testname}.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_REFERENCE=${resultfile}.ddl"
+ -P "${HDF_RESOURCES_DIR}/runTest.cmake"
+ )
+ endif ()
+ endmacro ()
+
+ macro (ADD_H5_ERR_CMP testname resultfile resultcode)
+ if (NOT HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (
+ NAME H5CLEAR_CMP-${testname}
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_file_ext}>"
+ -D "TEST_ARGS:STRING=${ARGN}"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
+ -D "TEST_OUTPUT=${testname}.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_REFERENCE=${resultfile}.mty"
+ -D "TEST_ERRREF=${resultfile}.err"
+ -P "${HDF_RESOURCES_DIR}/runTest.cmake"
+ )
+ endif ()
+ endmacro ()
+
+ macro (ADD_H5_CMP_WITH_COPY testname resultcode resultfile testfile)
+ if (NOT HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (
+ NAME H5CLEAR_CMP-${testname}-clear-objects
+ COMMAND ${CMAKE_COMMAND} -E remove testfiles/${testfile}
+ )
+ add_test (
+ NAME H5CLEAR_CMP-copy_${testname}
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ "${PROJECT_SOURCE_DIR}/testfiles/${testfile}" "${PROJECT_BINARY_DIR}/testfiles/${testfile}"
+ )
+ set_tests_properties (H5CLEAR_CMP-copy_${testname} PROPERTIES
+ DEPENDS H5CLEAR_CMP-${testname}-clear-objects
+ )
+ add_test (
+ NAME H5CLEAR_CMP-${testname}
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_file_ext}>"
+ -D "TEST_ARGS:STRING=${ARGN};${testfile}"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
+ -D "TEST_OUTPUT=${testname}.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_REFERENCE=${resultfile}.ddl"
+ -P "${HDF_RESOURCES_DIR}/runTest.cmake"
+ )
+ set_tests_properties (H5CLEAR_CMP-${testname} PROPERTIES
+ DEPENDS H5CLEAR_CMP-copy_${testname}
+ )
+ endif ()
+ endmacro ()
+
+ macro (ADD_H5_ERR_CMP_WITH_COPY testname resultcode resultfile testfile)
+ if (NOT HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (
+ NAME H5CLEAR_CMP-${testname}-clear-objects
+ COMMAND ${CMAKE_COMMAND} -E remove testfiles/${testfile}
+ )
+ add_test (
+ NAME H5CLEAR_CMP-copy_${testname}
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ "${PROJECT_SOURCE_DIR}/testfiles/${testfile}" "${PROJECT_BINARY_DIR}/testfiles/${testfile}"
+ )
+ set_tests_properties (H5CLEAR_CMP-copy_${testname} PROPERTIES
+ DEPENDS H5CLEAR_CMP-${testname}-clear-objects
+ )
+ add_test (
+ NAME H5CLEAR_CMP-${testname}
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_file_ext}>"
+ -D "TEST_ARGS:STRING=${ARGN};${testfile}"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
+ -D "TEST_OUTPUT=${testname}.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_REFERENCE=${resultfile}.mty"
+ -D "TEST_ERRREF=${resultfile}.err"
+ -P "${HDF_RESOURCES_DIR}/runTest.cmake"
+ )
+ set_tests_properties (H5CLEAR_CMP-${testname} PROPERTIES
+ DEPENDS H5CLEAR_CMP-copy_${testname}
+ )
+ endif ()
+ endmacro ()
+
+ macro (ADD_H5_RETTEST testname resultcode)
+ if (NOT HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (
+ NAME H5CLEAR_RET-${testname}
+ COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear${tgt_file_ext}> ${ARGN}
+ )
+ set_tests_properties (H5CLEAR_RET-${testname} PROPERTIES
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles"
+ WILL_FAIL "${resultcode}"
+ )
+ endif ()
+ endmacro ()
+
+ macro (ADD_H5_FILESIZE_TEST testname resultcode resultfile incr_size)
+ if (NOT HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (
+ NAME H5CLEAR_FILESIZE_TEST-${testname}-clear-objects
+ COMMAND ${CMAKE_COMMAND} -E remove testfiles/${testname}.h5
+ )
+ add_test (
+ NAME H5CLEAR_FILESIZE_TEST-copy_${testname}
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ "${PROJECT_SOURCE_DIR}/testfiles/${testname}.h5" "${PROJECT_BINARY_DIR}/testfiles/${testname}.h5"
+ )
+ set_tests_properties (H5CLEAR_FILESIZE_TEST-copy_${testname} PROPERTIES
+ DEPENDS H5CLEAR_FILESIZE_TEST-${testname}-clear-objects
+ )
+ add_test (
+ NAME H5CLEAR_FILESIZE_CMP-${testname}_before_size
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_file_ext}>"
+ -D "TEST_ARGS:STRING=--filesize;${testname}.h5"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
+ -D "TEST_OUTPUT=${testname}_before_size.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_REFERENCE=${resultfile}_before_size.ddl"
+ -P "${HDF_RESOURCES_DIR}/runTest.cmake"
+ )
+ set_tests_properties (H5CLEAR_FILESIZE_CMP-${testname}_before_size PROPERTIES
+ DEPENDS H5CLEAR_FILESIZE_TEST-copy_${testname}
+ )
+ if (NOT ${incr_size} MATCHES "NONE")
+ add_test (
+ NAME H5CLEAR_FILESIZE_INCR-${testname}
+ COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear${tgt_file_ext}> --increment=${incr_size} ${testname}.h5
+ )
+ else ()
+ add_test (
+ NAME H5CLEAR_FILESIZE_INCR-${testname}
+ COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear${tgt_file_ext}> --increment ${testname}.h5
+ )
+ endif ()
+ set_tests_properties (H5CLEAR_FILESIZE_INCR-${testname} PROPERTIES
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles"
+ WILL_FAIL "${resultcode}"
+ DEPENDS H5CLEAR_FILESIZE_CMP-${testname}_before_size
+ )
+ add_test (
+ NAME H5CLEAR_FILESIZE_CMP-${testname}_after_size
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_file_ext}>"
+ -D "TEST_ARGS:STRING=--filesize;${testname}.h5"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
+ -D "TEST_OUTPUT=${testname}_after_size.out"
+ -D "TEST_EXPECT=0"
+ -D "TEST_REFERENCE=${resultfile}_after_size.ddl"
+ -P "${HDF_RESOURCES_DIR}/runTest.cmake"
+ )
+ set_tests_properties (H5CLEAR_FILESIZE_CMP-${testname}_after_size PROPERTIES
+ DEPENDS H5CLEAR_FILESIZE_INCR-${testname}
+ )
+ endif ()
+ endmacro ()
+
+ macro (ADD_H5_FILESIZE_FAIL_TEST testname resultcode resultfile incr_size)
+ if (NOT HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (
+ NAME H5CLEAR_FILESIZE_FAIL_TEST-${testname}-clear-objects
+ COMMAND ${CMAKE_COMMAND} -E remove testfiles/${testname}.h5
+ )
+ add_test (
+ NAME H5CLEAR_FILESIZE_FAIL_TEST-copy_${testname}
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ "${PROJECT_SOURCE_DIR}/testfiles/${testname}.h5" "${PROJECT_BINARY_DIR}/testfiles/${testname}.h5"
+ )
+ set_tests_properties (H5CLEAR_FILESIZE_FAIL_TEST-copy_${testname} PROPERTIES
+ DEPENDS H5CLEAR_FILESIZE_FAIL_TEST-${testname}-clear-objects
+ )
+ add_test (
+ NAME H5CLEAR_FILESIZE_FAIL_CMP-${testname}_before_size
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_file_ext}>"
+ -D "TEST_ARGS:STRING=--filesize;${testname}.h5"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
+ -D "TEST_OUTPUT=${testname}_before_size.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_REFERENCE=${resultfile}.mty"
+ -P "${HDF_RESOURCES_DIR}/runTest.cmake"
+ )
+ set_tests_properties (H5CLEAR_FILESIZE_FAIL_CMP-${testname}_before_size PROPERTIES
+ DEPENDS H5CLEAR_FILESIZE_FAIL_TEST-copy_${testname}
+ )
+ if (NOT ${incr_size} MATCHES "NONE")
+ add_test (
+ NAME H5CLEAR_FILESIZE_FAIL_INCR-${testname}
+ COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear${tgt_file_ext}> -s --increment=${incr_size} ${testname}.h5
+ )
+ else ()
+ add_test (
+ NAME H5CLEAR_FILESIZE_FAIL_INCR-${testname}
+ COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear${tgt_file_ext}> -s --increment ${testname}.h5
+ )
+ endif ()
+ set_tests_properties (H5CLEAR_FILESIZE_FAIL_INCR-${testname} PROPERTIES
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles"
+ DEPENDS H5CLEAR_FILESIZE_FAIL_CMP-${testname}_before_size
+ )
+ add_test (
+ NAME H5CLEAR_FILESIZE_FAIL_CMP-${testname}_after_size
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5clear${tgt_file_ext}>"
+ -D "TEST_ARGS:STRING=--filesize;${testname}.h5"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
+ -D "TEST_OUTPUT=${testname}_after_size.out"
+ -D "TEST_EXPECT=0"
+ -D "TEST_REFERENCE=${resultfile}_after_size.ddl"
+ -P "${HDF_RESOURCES_DIR}/runTest.cmake"
+ )
+ set_tests_properties (H5CLEAR_FILESIZE_FAIL_CMP-${testname}_after_size PROPERTIES
+ DEPENDS H5CLEAR_FILESIZE_FAIL_INCR-${testname}
+ )
+ endif ()
+ endmacro ()
+
+ macro (ADD_H5_TEST testname testfile resultcode)
+ if (NOT HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (
+ NAME H5CLEAR-clr_open_chk-copy_${testname}.h5
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ "${PROJECT_SOURCE_DIR}/testfiles/${testfile}.h5" "${PROJECT_BINARY_DIR}/testfiles/${testfile}.h5"
+ )
+
+ # Initial file open fails OR
+ # File open succeeds because the library does not check status_flags for file with < v3 superblock
+ add_test (
+ NAME H5CLEAR-clr_open_chk-${testname}_${resultcode}
+ COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:clear_open_chk> ${testfile}.h5
+ )
+ set_tests_properties (H5CLEAR-clr_open_chk-${testname}_${resultcode} PROPERTIES
+ WILL_FAIL "${resultcode}"
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles"
+ DEPENDS H5CLEAR-clr_open_chk-copy_${testname}.h5
+ )
+
+ # After "h5clear" the file, the subsequent file open succeeds
+ add_test (
+ NAME H5CLEAR-h5clr-${testname}
+ COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5clear${tgt_file_ext}> -s ${testfile}.h5
+ )
+ set_tests_properties (H5CLEAR-h5clr-${testname} PROPERTIES
+ DEPENDS H5CLEAR-clr_open_chk-${testname}_${resultcode}
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles"
+ )
+ add_test (
+ NAME H5CLEAR-clr_open_chk-${testname}
+ COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:clear_open_chk> ${testfile}.h5
+ )
+ set_tests_properties (H5CLEAR-clr_open_chk-${testname} PROPERTIES
+ DEPENDS H5CLEAR-h5clr-${testname}
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles"
+ )
+ endif ()
+ endmacro ()
+
+##############################################################################
+##############################################################################
+### T H E T E S T S ###
+##############################################################################
+##############################################################################
+#
+#
+#
+# The following are tests to verify the expected output from h5clear
+# "h5clear -h"
+# "h5clear" (no options, no file)
+# "h5clear junk.h5" (no options, nonexisting file)
+# "h5clear orig_h5clear_sec2_v3.h5" (no options, existing file)
+# "h5clear -m" (valid 1 option, no file)
+# "h5clear -s junk.h5" (valid 1 option, nonexisting file)
+# "h5clear -m -s" (valid 2 options, no file)
+# "h5clear -m -s junk.h5" (valid 2 options, nonexisting file)
+# "h5clear -m orig_h5clear_sec2_v2.h5" (valid 1 option, existing file, no cache image)
+# "h5clear -s -m orig_h5clear_sec2_v0.h5" (valid 2 options, existing file, no cache image)
+ ADD_H5_CMP (h5clr_usage_h h5clear_usage 0 "-h")
+ ADD_H5_CMP (h5clr_usage h5clear_usage 1 "")
+ ADD_H5_CMP (h5clr_usage_junk h5clear_usage 1 "" junk.h5)
+ ADD_H5_CMP (h5clr_usage_none h5clear_usage 1 "" orig_h5clear_sec2_v3.h5)
+ ADD_H5_CMP (h5clr_missing_file_m h5clear_missing_file 1 "-m")
+ ADD_H5_ERR_CMP (h5clr_open_fail_s h5clear_open_fail 1 "-s" junk.h5)
+ ADD_H5_CMP (h5clr_missing_file_ms h5clear_missing_file 1 "-m" "-s")
+ ADD_H5_ERR_CMP (h5clr_open_fail_ms h5clear_open_fail 1 "-m" "-s" junk.h5)
+ ADD_H5_ERR_CMP (h5clr_no_mdc_image_m h5clear_no_mdc_image 0 "-m" orig_h5clear_sec2_v2.h5)
+ ADD_H5_ERR_CMP (h5clr_no_mdc_image_ms h5clear_no_mdc_image 0 "-s" "-m" orig_h5clear_sec2_v0.h5)
+#
+#
+#
+# The following are tests to verify the expected exit code from h5clear:
+# "h5clear -m h5clear_mdc_image.h5" (valid option, existing file, succeed exit code)
+# "h5clear --version" (valid option, version #, succeed exit code)
+# "h5clear -k" (invalid 1 option, no file, fail exit code)
+# "h5clear -k junk.h5" (invalid 1 option, nonexisting file, fail exit code)
+# "h5clear -l h5clear_sec2_v2.h5" (invalid 1 option, existing file, fail exit code)
+# "h5clear -m -k" (valid/invalid 2 options, nofile, fail exit code)
+# "h5clear -l -m" (invalid/valid 2 options, nofile, fail exit code)
+# "h5clear -m -l junk.h5" (valid/invalid 2 options, nonexisting file, fail exit code)
+# "h5clear -l -m junk.h5" (invalid/valid 2 options, nonexisting file, fail exit code)
+# "h5clear -m -l h5clear_sec2_v0.h5" (valid/invalid 2 options, existing file, fail exit code)
+# "h5clear -l -m h5clear_sec2_v0.h5" (invalid/valid 2 options, existing file, fail exit code)
+ ADD_H5_RETTEST (h5clr_mdc_image "false" "-m" h5clear_mdc_image.h5)
+ ADD_H5_RETTEST (h5clr_vers "false" "--version")
+ ADD_H5_RETTEST (h5clr_k "true" "-k")
+ ADD_H5_RETTEST (h5clr_k_junk "true" "-k" junk.h5)
+ ADD_H5_RETTEST (h5clr_l_sec2 "true" "-l" h5clear_sec2_v2.h5)
+ ADD_H5_RETTEST (h5clr_mk "true" "-m" "-k")
+ ADD_H5_RETTEST (h5clr_lm "true" "-l" "-m")
+ ADD_H5_RETTEST (h5clr_ml_junk "true" "-m" "-l" junk.h5)
+ ADD_H5_RETTEST (h5clr_lm_junk "true" "-l" "-m" junk.h5)
+ ADD_H5_RETTEST (h5clr_ml_sec2 "true" "-m" "-l" h5clear_sec2_v0.h5)
+ ADD_H5_RETTEST (h5clr_lm_sec2 "true" "-l" "-m" h5clear_sec2_v0.h5)
+#
+#
+#
+# h5clear_mdc_image.h5 already has cache image removed earlier, verify the expected warning from h5clear:
+ ADD_H5_ERR_CMP (h5clr_mdc_image_m h5clear_no_mdc_image 0 "-m" mod_h5clear_mdc_image.h5)
+ ADD_H5_ERR_CMP (h5clr_mdc_image_sm h5clear_no_mdc_image 0 "-s" "-m" mod_h5clear_mdc_image2.h5)
+#
+#
+#
+# The following are tests to verify the status_flags field is cleared properly:
+ ADD_H5_TEST (h5clr_sec2_v3 h5clear_sec2_v3 "true")
+ ADD_H5_TEST (h5clr_log_v3 h5clear_log_v3 "true")
+ ADD_H5_TEST (latest_h5clr_sec2_v3 latest_h5clear_sec2_v3 "true")
+ ADD_H5_TEST (latest_h5clr_log_v3 latest_h5clear_log_v3 "true")
+ ADD_H5_TEST (h5clr_sec2_v0 h5clear_sec2_v0 "false")
+ ADD_H5_TEST (h5clr_sec2_v2 h5clear_sec2_v2 "false")
+#
+#
+#
+# The following tests verify the filesize, increment the filesize, then verify the filesize again.
+#
+# (1) h5clear_status_noclose.h5
+# "h5clear --filesize h5clear_status_noclose.h5" (unable to open the file because status_flags is enabled)
+# "h5clear -s --increment=0 h5clear_status_noclose.h5" (clear status_flag, EOA = MAX(EOA, EOF) + 0)
+# (no output, check exit code)
+# "h5clear --filesize h5clear_status_noclose.h5" (print EOA/EOF after the last action)
+ ADD_H5_FILESIZE_FAIL_TEST (h5clear_status_noclose 1 h5clear_status_noclose 0)
+#
+# (2) h5clear_fsm_persist_noclose.h5
+# "h5clear --filesize h5clear_fsm_persist_noclose.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_noclose.h5" (EOA = MAX(EOA, EOF)) (no output, just check exit code)
+# "h5clear --filesize h5clear_fsm_persist_noclose.h5" (print EOA/EOF after the last action)
+ ADD_H5_FILESIZE_TEST (h5clear_fsm_persist_noclose 0 h5clear_noclose 0)
+#
+# (3) h5clear_fsm_persist_equal.h5
+# "h5clear --filesize h5clear_fsm_persist_equal.h5" (print EOA/EOF before the next action)
+# "h5clear --increment h5clear_fsm_persist_equal.h5" (EOA = MAX(EOA, EOF) + 1M) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_equal.h5" (print EOA/EOF after the last action)
+ ADD_H5_FILESIZE_TEST (h5clear_fsm_persist_equal 0 h5clear_equal NONE)
+#
+# (4) h5clear_fsm_persist_greater.h5
+# "h5clear --filesize h5clear_fsm_persist_greater.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_greater.h5" (print EOA/EOF after the last action)
+ ADD_H5_FILESIZE_TEST (h5clear_fsm_persist_greater 0 h5clear_greater 0)
+#
+# (5) h5clear_fsm_persist_less.h5
+# "h5clear --filesize h5clear_fsm_persist_less.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=200 h5clear_fsm_persist_less.h5" (EOA = MAX(EOA, EOF) + 200) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_less.h5" (print EOA/EOF after the last action)
+ ADD_H5_FILESIZE_TEST (h5clear_fsm_persist_less 0 h5clear_less 200)
+#
+# (6) h5clear_fsm_persist_user_equal.h5
+# "h5clear --filesize h5clear_fsm_persist_user_equal.h5" (print EOA/EOF before the next action)
+# "h5clear --increment h5clear_fsm_persist_user_equal.h5" (EOA = MAX(EOA, EOF) + 1M) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_user_equal.h5" (print EOA/EOF after the last action)
+ ADD_H5_FILESIZE_TEST (h5clear_fsm_persist_user_equal 0 h5clear_user_equal NONE)
+#
+# (7) h5clear_fsm_persist_user_greater.h5
+# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_user_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF after the last action)
+ ADD_H5_FILESIZE_TEST (h5clear_fsm_persist_user_greater 0 h5clear_user_greater 0)
+#
+# (8) h5clear_fsm_persist_user_less.h5
+# "h5clear --filesize h5clear_fsm_persist_user_less.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=200 h5clear_fsm_persist_user_less.h5" (EOA = MAX(EOA, EOF) + 200) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_user_less.h5" (print EOA/EOF after the last action)
+ ADD_H5_FILESIZE_TEST (h5clear_fsm_persist_user_less 0 h5clear_user_less 200)
+#
+#
diff --git a/tools/test/misc/CMakeTestsMkgrp.cmake b/tools/test/misc/CMakeTestsMkgrp.cmake
new file mode 100644
index 0000000..b4d1a56
--- /dev/null
+++ b/tools/test/misc/CMakeTestsMkgrp.cmake
@@ -0,0 +1,172 @@
+#
+# Copyright by The HDF Group.
+# All rights reserved.
+#
+# This file is part of HDF5. The full HDF5 copyright notice, including
+# terms governing use, modification, and redistribution, is contained in
+# the COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://www.hdfgroup.org/licenses.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
+#
+
+##############################################################################
+##############################################################################
+### T E S T I N G ###
+##############################################################################
+##############################################################################
+
+ # --------------------------------------------------------------------
+ # Copy all the HDF5 files from the source directory into the test directory
+ # --------------------------------------------------------------------
+ set (HDF5_MKGRP_TEST_FILES
+ #h5mkgrp_help.txt
+ #h5mkgrp_version
+ h5mkgrp_single.ls
+ h5mkgrp_single_v.ls
+ h5mkgrp_single_p.ls
+ h5mkgrp_single_l.ls
+ h5mkgrp_several.ls
+ h5mkgrp_several_v.ls
+ h5mkgrp_several_p.ls
+ h5mkgrp_several_l.ls
+ h5mkgrp_nested_p.ls
+ h5mkgrp_nested_lp.ls
+ h5mkgrp_nested_mult_p.ls
+ h5mkgrp_nested_mult_lp.ls
+ )
+
+ # make test dir
+ file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles")
+
+ foreach (h5_mkgrp_file ${HDF5_MKGRP_TEST_FILES})
+ HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${h5_mkgrp_file}" "${PROJECT_BINARY_DIR}/testfiles/${h5_mkgrp_file}" "h5mkgrp_files")
+ endforeach ()
+
+ HDFTEST_COPY_FILE("${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/testfiles/h5mkgrp_help.txt" "${PROJECT_BINARY_DIR}/testfiles/h5mkgrp_help.txt" "h5mkgrp_files")
+ add_custom_target(h5mkgrp_files ALL COMMENT "Copying files needed by h5mkgrp tests" DEPENDS ${h5mkgrp_files_list})
+
+ configure_file (${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/testfiles/h5mkgrp_version.txt.in ${PROJECT_BINARY_DIR}/testfiles/h5mkgrp_version.txt @ONLY)
+
+##############################################################################
+##############################################################################
+### T H E T E S T S M A C R O S ###
+##############################################################################
+##############################################################################
+
+ macro (ADD_H5_TEST resultfile resultcode resultoption)
+ if (HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (
+ NAME H5MKGRP-${resultfile}
+ COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5mkgrp${tgt_file_ext}> ${resultoption} ${resultfile}.h5 ${ARGN}
+ )
+ else ()
+ add_test (
+ NAME H5MKGRP-${resultfile}-clear-objects
+ COMMAND ${CMAKE_COMMAND} -E remove ${resultfile}.h5
+ )
+ set_tests_properties (H5MKGRP-${resultfile}-clear-objects PROPERTIES
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles"
+ )
+ add_test (
+ NAME H5MKGRP-${resultfile}
+ COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5mkgrp${tgt_file_ext}> ${resultoption} ${resultfile}.h5 ${ARGN}
+ )
+ set_tests_properties (H5MKGRP-${resultfile} PROPERTIES
+ DEPENDS H5MKGRP-${resultfile}-clear-objects
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles"
+ )
+ add_test (
+ NAME H5MKGRP-${resultfile}-h5ls
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5ls${tgt_file_ext}>"
+ -D "TEST_ARGS:STRING=-v;-r;${resultfile}.h5"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
+ -D "TEST_OUTPUT=${resultfile}.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_MASK_MOD=true"
+ -D "TEST_REFERENCE=${resultfile}.ls"
+ -P "${HDF_RESOURCES_DIR}/runTest.cmake"
+ )
+ set_tests_properties (H5MKGRP-${resultfile}-h5ls PROPERTIES DEPENDS H5MKGRP-${resultfile})
+ endif ()
+ endmacro ()
+
+ macro (ADD_H5_CMP resultfile resultcode)
+ if (HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (NAME H5MKGRP_CMP-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5mkgrp${tgt_file_ext}> ${ARGN})
+ else ()
+ add_test (
+ NAME H5MKGRP_CMP-${resultfile}-clear-objects
+ COMMAND ${CMAKE_COMMAND} -E remove ${resultfile}.h5
+ )
+ set_tests_properties (H5MKGRP_CMP-${resultfile}-clear-objects PROPERTIES
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles"
+ )
+ add_test (
+ NAME H5MKGRP_CMP-${resultfile}
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5mkgrp${tgt_file_ext}>"
+ -D "TEST_ARGS:STRING=${ARGN}"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
+ -D "TEST_OUTPUT=${resultfile}.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_REFERENCE=${resultfile}.txt"
+ -P "${HDF_RESOURCES_DIR}/runTest.cmake"
+ )
+ set_tests_properties (H5MKGRP_CMP-${resultfile} PROPERTIES
+ DEPENDS H5MKGRP_CMP-${resultfile}-clear-objects
+ )
+ endif ()
+ endmacro ()
+
+##############################################################################
+##############################################################################
+### T H E T E S T S ###
+##############################################################################
+##############################################################################
+ if (HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (
+ NAME H5MKGRP-clearall-objects
+ COMMAND ${CMAKE_COMMAND} -E remove
+ h5mkgrp_single.h5
+ h5mkgrp_single_v.h5
+ h5mkgrp_single_p.h5
+ h5mkgrp_single_l.h5
+ h5mkgrp_several.h5
+ h5mkgrp_several_v.h5
+ h5mkgrp_several_p.h5
+ h5mkgrp_several_l.h5
+ h5mkgrp_nested_p.h5
+ h5mkgrp_nested_lp.h5
+ h5mkgrp_nested_mult_p.h5
+ h5mkgrp_nested_mult_lp.h5
+ )
+ set_tests_properties (H5MKGRP-clearall-objects PROPERTIES
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles"
+ )
+ endif ()
+
+ # Check that help & version is displayed properly
+ ADD_H5_CMP (h5mkgrp_help 0 "-h")
+ ADD_H5_CMP (h5mkgrp_version 0 "-V")
+
+ # Create single group at root level
+ ADD_H5_TEST (h5mkgrp_single 0 "" single)
+ ADD_H5_TEST (h5mkgrp_single_v 0 "-v" single)
+ ADD_H5_TEST (h5mkgrp_single_p 0 "-p" single)
+ ADD_H5_TEST (h5mkgrp_single_l 0 "-l" latest)
+
+ # Create several groups at root level
+ ADD_H5_TEST (h5mkgrp_several 0 "" one two)
+ ADD_H5_TEST (h5mkgrp_several_v 0 "-v" one two)
+ ADD_H5_TEST (h5mkgrp_several_p 0 "-p" one two)
+ ADD_H5_TEST (h5mkgrp_several_l 0 "-l" one two)
+
+ # Create various nested groups
+ ADD_H5_TEST (h5mkgrp_nested_p 0 "-p" /one/two)
+ ADD_H5_TEST (h5mkgrp_nested_lp 0 "-lp" /one/two)
+ ADD_H5_TEST (h5mkgrp_nested_mult_p 0 "-p" /one/two /three/four)
+ ADD_H5_TEST (h5mkgrp_nested_mult_lp 0 "-lp" /one/two /three/four)
diff --git a/tools/test/misc/CMakeTestsRepart.cmake b/tools/test/misc/CMakeTestsRepart.cmake
new file mode 100644
index 0000000..04c74ec
--- /dev/null
+++ b/tools/test/misc/CMakeTestsRepart.cmake
@@ -0,0 +1,137 @@
+#
+# Copyright by The HDF Group.
+# All rights reserved.
+#
+# This file is part of HDF5. The full HDF5 copyright notice, including
+# terms governing use, modification, and redistribution, is contained in
+# the COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://www.hdfgroup.org/licenses.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
+#
+
+##############################################################################
+##############################################################################
+### T E S T I N G ###
+##############################################################################
+##############################################################################
+
+ # --------------------------------------------------------------------
+ # Copy all the HDF5 files from the source directory into the test directory
+ # --------------------------------------------------------------------
+ set (HDF5_REFERENCE_TEST_FILES
+ family_file00000.h5
+ family_file00001.h5
+ family_file00002.h5
+ family_file00003.h5
+ family_file00004.h5
+ family_file00005.h5
+ family_file00006.h5
+ family_file00007.h5
+ family_file00008.h5
+ family_file00009.h5
+ family_file00010.h5
+ family_file00011.h5
+ family_file00012.h5
+ family_file00013.h5
+ family_file00014.h5
+ family_file00015.h5
+ family_file00016.h5
+ family_file00017.h5
+ )
+
+ foreach (h5_file ${HDF5_REFERENCE_TEST_FILES})
+ HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/${h5_file}" "h5repart_files")
+ endforeach ()
+ add_custom_target(h5repart_files ALL COMMENT "Copying files needed by h5repart tests" DEPENDS ${h5repart_files_list})
+
+##############################################################################
+##############################################################################
+### T H E T E S T S M A C R O S ###
+##############################################################################
+##############################################################################
+
+
+##############################################################################
+##############################################################################
+### T H E T E S T S ###
+##############################################################################
+##############################################################################
+
+ # Remove any output file left over from previous test run
+ add_test (
+ NAME H5REPART-clearall-objects
+ COMMAND ${CMAKE_COMMAND}
+ -E remove
+ fst_family00000.h5
+ scd_family00000.h5
+ scd_family00001.h5
+ scd_family00002.h5
+ scd_family00003.h5
+ family_to_single.h5
+ family_to_sec2.h5
+ )
+ set_tests_properties (H5REPART-clearall-objects PROPERTIES FIXTURES_SETUP clear_testrepart)
+ add_test (
+ NAME H5REPART-clean-objects
+ COMMAND ${CMAKE_COMMAND}
+ -E remove
+ fst_family00000.h5
+ scd_family00000.h5
+ scd_family00001.h5
+ scd_family00002.h5
+ scd_family00003.h5
+ family_to_single.h5
+ family_to_sec2.h5
+ )
+ set_tests_properties (H5REPART-clean-objects PROPERTIES FIXTURES_CLEANUP clear_testrepart)
+
+ # repartition family member size to 20,000 bytes.
+ add_test (
+ NAME H5REPART-h5repart_20K
+ COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repart${tgt_file_ext}> -m 20000 family_file%05d.h5 fst_family%05d.h5
+ )
+ set_tests_properties (H5REPART-h5repart_20K PROPERTIES
+ FIXTURES_REQUIRED clear_testrepart
+ )
+
+ # repartition family member size to 5 KB.
+ add_test (
+ NAME H5REPART-h5repart_5K
+ COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repart${tgt_file_ext}> -m 5k family_file%05d.h5 scd_family%05d.h5
+ )
+ set_tests_properties (H5REPART-h5repart_5K PROPERTIES
+ FIXTURES_REQUIRED clear_testrepart
+ )
+
+ # convert family file to sec2 file of 20,000 bytes
+ add_test (
+ NAME H5REPART-h5repart_single
+ COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repart${tgt_file_ext}> -m 20000 -family_to_single family_file%05d.h5 family_to_single.h5
+ )
+ set_tests_properties (H5REPART-h5repart_single PROPERTIES
+ FIXTURES_REQUIRED clear_testrepart
+ )
+
+ # convert family file to sec2 file of 20,000 bytes (old argument)
+ add_test (
+ NAME H5REPART-h5repart_sec2
+ COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repart${tgt_file_ext}> -m 20000 -family_to_sec2 family_file%05d.h5 family_to_sec2.h5
+ )
+ set_tests_properties (H5REPART-h5repart_sec2 PROPERTIES
+ FIXTURES_REQUIRED clear_testrepart
+ )
+
+ # test the output files repartitioned above.
+ add_test (
+ NAME H5REPART-h5repart_test
+ COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repart_test>
+ )
+ set_tests_properties (H5REPART-h5repart_test PROPERTIES
+ DEPENDS "H5REPART-h5repart_20K;H5REPART-h5repart_5K;H5REPART-h5repart_single;H5REPART-h5repart_sec2"
+ FIXTURES_REQUIRED clear_testrepart
+ )
+
+ set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES}
+ h5repart_test
+ )
diff --git a/tools/test/misc/Makefile.am b/tools/test/misc/Makefile.am
new file mode 100644
index 0000000..e222af2
--- /dev/null
+++ b/tools/test/misc/Makefile.am
@@ -0,0 +1,44 @@
+#
+# Copyright by The HDF Group.
+# All rights reserved.
+#
+# This file is part of HDF5. The full HDF5 copyright notice, including
+# terms governing use, modification, and redistribution, is contained in
+# the COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://www.hdfgroup.org/licenses.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
+##
+## Makefile.am
+## Run automake to generate a Makefile.in from this file.
+#
+# HDF5 Library Makefile(.in)
+#
+
+include $(top_srcdir)/config/commence.am
+
+SUBDIRS=vds
+
+# Include src directory
+AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib
+
+#test scripts and programs
+TEST_PROG=h5repart_gentest h5clear_gentest talign
+TEST_SCRIPT=testh5repart.sh testh5mkgrp.sh testh5clear.sh
+
+check_PROGRAMS=$(TEST_PROG) repart_test clear_open_chk
+check_SCRIPTS=$(TEST_SCRIPT)
+SCRIPT_DEPEND=../../src/misc/h5repart$(EXEEXT) ../../src/misc/h5mkgrp$(EXEEXT) ../../src/misc/h5clear$(EXEEXT)
+
+# Temporary files. *.h5 are generated by h5repart_gentest. They should
+# copied to the testfiles/ directory if update is required. fst_family*.h5
+# and scd_family*.h5 were created by setting the HDF5_NOCLEANUP variable.
+CHECK_CLEANFILES+=*.h5 ../testfiles/fst_family*.h5 ../testfiles/scd_family*.h5 append.log
+
+# These were generated by configure. Remove them only when distclean.
+DISTCLEANFILES=testh5repart.sh testh5clear.sh
+
+# All programs rely on hdf5 library and h5tools library
+LDADD=$(LIBH5TOOLS) $(LIBHDF5)
+
+include $(top_srcdir)/config/conclude.am
diff --git a/tools/test/misc/clear_open_chk.c b/tools/test/misc/clear_open_chk.c
new file mode 100644
index 0000000..37e7307
--- /dev/null
+++ b/tools/test/misc/clear_open_chk.c
@@ -0,0 +1,70 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+#include "hdf5.h"
+#include "H5private.h"
+#include "h5tools.h"
+
+static void usage(void);
+
+static void
+usage(void)
+{
+ HDfprintf(stdout, "\n");
+ HDfprintf(stdout, "Usage error!\n");
+ HDfprintf(stdout, "Usage: clear_open_chk filename\n");
+} /* usage() */
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose: To open the file which has zero or nonzero status_flags in
+ * the superblock.
+ *
+ * Return: 0 on success
+ * 1 on failure
+ *
+ * Programmer: Vailin Choi; July 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(int argc, char *argv[])
+{
+ char *fname; /* The HDF5 file name */
+ hid_t fid; /* File ID */
+
+ /* Check the # of arguments */
+ if (argc != 2) {
+ usage();
+ HDexit(EXIT_FAILURE);
+ }
+
+ /* Get the file name */
+ fname = HDstrdup(argv[1]);
+
+ /* Try opening the file */
+ if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, FALSE, NULL, (size_t)0)) < 0) {
+ HDfprintf(stderr, "clear_open_chk: unable to open the file\n");
+ HDfree(fname);
+ HDexit(EXIT_FAILURE);
+ }
+ HDfree(fname);
+
+ /* Close the file */
+ if (H5Fclose(fid) < 0) {
+ HDfprintf(stderr, "clear_open_chk: cannot close the file\n");
+ HDexit(EXIT_FAILURE);
+ }
+
+ /* Return success */
+ HDexit(EXIT_SUCCESS);
+} /* main() */
diff --git a/tools/test/misc/h5clear_gentest.c b/tools/test/misc/h5clear_gentest.c
new file mode 100644
index 0000000..666a3f7
--- /dev/null
+++ b/tools/test/misc/h5clear_gentest.c
@@ -0,0 +1,609 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+#include "hdf5.h"
+#include "h5test.h"
+
+/* The HDF5 test files */
+const char *FILENAME[] = {
+ "h5clear_sec2_v3.h5", /* 0 -- sec2 file with superblock version 3 */
+ "h5clear_log_v3.h5", /* 1 -- log file with superblock version 3 */
+ "h5clear_sec2_v0.h5", /* 2 -- sec2 file with superblock version 0 */
+ "h5clear_sec2_v2.h5" /* 3 -- sec2 file with superblock version 2 */
+};
+
+const char *FILENAME_ENHANCE[] = {
+ "h5clear_fsm_persist_equal.h5", /* 0: persisting free-space, stored EOA = actual EOF */
+ "h5clear_fsm_persist_greater.h5", /* 1: persisting free-space, stored EOA > actual EOF */
+ "h5clear_fsm_persist_less.h5", /* 2: persisting free-space, stored EOA < actual EOF */
+ "h5clear_fsm_persist_user_equal.h5", /* 3: user block, persisting free-space, stored EOA = actual EOF */
+ "h5clear_fsm_persist_user_greater.h5", /* 4: user block, persisting free-space, stored EOA > actual EOF */
+ "h5clear_fsm_persist_user_less.h5", /* 5: user block, persisting free-space, stored EOA < actual EOF */
+ "h5clear_status_noclose.h5", /* 6 -- v3 superblock, nonzero status_flags, no flush, exit,
+ stored EOA < actual EOF */
+ "h5clear_fsm_persist_noclose.h5" /* 7 -- persisting free-space, no flush, exit, stored EOA < actual EOF */
+};
+
+#define KB 1024U
+
+#define CACHE_IMAGE_FILE "h5clear_mdc_image.h5"
+#define DSET "DSET"
+#define DATASET "dset"
+#define NUM_ELMTS 100
+#define USERBLOCK 512
+
+/*-------------------------------------------------------------------------
+ * Function: gen_cache_image_file
+ *
+ * Purpose: To create a file with cache image feature enabled.
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Vailin Choi; March 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+gen_cache_image_file(const char *fname)
+{
+ hid_t fid = H5I_INVALID_HID; /* File ID */
+ hid_t did = -1, sid = H5I_INVALID_HID; /* Dataset ID, dataspace ID */
+ hid_t fapl = H5I_INVALID_HID; /* File access property list */
+ hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */
+ hsize_t dims[2]; /* Dimension sizes */
+ hsize_t chunks[2]; /* Chunked dimension sizes */
+ int i, j; /* Local index variables */
+ struct {
+ int arr[50][100];
+ } * buf; /* Buffer for data to write */
+ H5AC_cache_image_config_t cache_image_config = /* Cache image input configuration */
+ {H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, TRUE, FALSE, H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE};
+
+ /* Create and fill array */
+ buf = malloc(sizeof(*buf));
+ if (NULL == buf)
+ goto error;
+ for (i = 0; i < 50; i++)
+ for (j = 0; j < 100; j++)
+ buf->arr[i][j] = i * j;
+
+ /* Create a copy of file access property list */
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ goto error;
+
+ /* Enable latest format in fapl */
+ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ goto error;
+
+ /* Enable metadata cache image in fapl */
+ if (H5Pset_mdc_image_config(fapl, &cache_image_config) < 0)
+ goto error;
+
+ /* Create the file */
+ if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ goto error;
+
+ /* Create dataspace */
+ dims[0] = 50;
+ dims[1] = 100;
+ if ((sid = H5Screate_simple(2, dims, NULL)) < 0)
+ goto error;
+
+ /* Set up to create a chunked dataset */
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ goto error;
+ chunks[0] = 5;
+ chunks[1] = 10;
+ if (H5Pset_chunk(dcpl, 2, chunks) < 0)
+ goto error;
+ if ((did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ goto error;
+
+ /* Write to the dataset */
+ if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ goto error;
+
+ /* Closing */
+ if (H5Dclose(did) < 0)
+ goto error;
+ if (H5Pclose(dcpl) < 0)
+ goto error;
+ if (H5Pclose(fapl) < 0)
+ goto error;
+ if (H5Sclose(sid) < 0)
+ goto error;
+ if (H5Fclose(fid) < 0)
+ goto error;
+
+ HDfree(buf);
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY
+ {
+ H5Pclose(dcpl);
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Fclose(fid);
+ H5Pclose(fapl);
+ H5Pclose(dcpl);
+ }
+ H5E_END_TRY;
+
+ HDfree(buf);
+
+ return 1;
+} /* gen_cache_image_file() */
+
+/*-------------------------------------------------------------------------
+ * Function: gen_enhance_files
+ *
+ * Purpose: To create the first 6 files in FILENAME_ENHANCE[]:
+ * (0) FILENAME_ENHANCE[0]: "h5clear_fsm_persist_equal.h5"
+ * (1) FILENAME_ENHANCE[1]: "h5clear_fsm_persist_greater.h5"
+ * (2) FILENAME_ENHANCE[2]: "h5clear_fsm_persist_less.h5"
+ * (3) FILENAME_ENHANCE[3]: "h5clear_user_fsm_persist_equal.h5"
+ * (4) FILENAME_ENHANCE[4]: "h5clear_user_fsm_persist_greater.h5"
+ * (5) FILENAME_ENHANCE[5]: "h5clear_user_fsm_persist_less.h5"
+ * After creating the files for #1, #2, #4 #5, write invalid EOA
+ * value to the location where the EOA is stored in the superblock.
+ * Also modify the chksum in the superblock due to this change.
+ *
+ * The first call to this routine (without user block) will generate
+ * the first 3 files.
+ * The second call to this routine (with user block) will generate
+ * the last 3 files.
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Vailin Choi; March 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+gen_enhance_files(hbool_t user)
+{
+ hid_t fid = H5I_INVALID_HID; /* File ID */
+ hid_t fcpl = H5I_INVALID_HID; /* File creation property list */
+ hid_t sid = H5I_INVALID_HID; /* Dataspace ID */
+ hid_t did = H5I_INVALID_HID; /* Dataset ID */
+ hsize_t dim[1]; /* Dimension sizes */
+ int data[NUM_ELMTS]; /* Buffer for data */
+ int fd = H5I_INVALID_HID; /* The file descriptor ID */
+ int64_t eoa; /* The EOA value */
+ uint32_t chksum; /* The chksum value */
+ int i = 0, j = 0, u = 0; /* Local index variable */
+
+ /* Get a copy of the default file creation property */
+ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ goto error;
+
+ /* Check to see if user block will be added */
+ if (user) {
+ if (H5Pset_userblock(fcpl, (hsize_t)USERBLOCK) < 0)
+ goto error;
+ u = 3;
+ }
+
+ /* Set file space strategy and persisting free-space */
+ if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0)
+ goto error;
+
+ /*
+ * Create the file, then write invalid EOA to the file.
+ */
+ for (i = 0 + u; i < 3 + u; i++) {
+
+ /* Create the file with the file space strategy and persisting free-space */
+ if ((fid = H5Fcreate(FILENAME_ENHANCE[i], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0)
+ goto error;
+
+ /* Create the dataset */
+ dim[0] = NUM_ELMTS;
+ if ((sid = H5Screate_simple(1, dim, NULL)) < 0)
+ goto error;
+ if ((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+
+ for (j = 0; j < NUM_ELMTS; j++)
+ data[j] = j;
+
+ /* Write the dataset */
+ if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
+ goto error;
+
+ /* Closing */
+ if (H5Dclose(did) < 0)
+ goto error;
+ if (H5Sclose(sid) < 0)
+ goto error;
+ if (H5Fclose(fid) < 0)
+ goto error;
+
+ /*
+ * No further action for:
+ * --FILENAME_ENHANCE[0]: "h5clear_fsm_persist_equal.h5"
+ * --FILENAME_ENHANCE[3]: "h5clear_fsm_persist_user_equal.h5",
+ */
+ if (!(i % 3))
+ continue;
+ /*
+ * For the following files:
+ * --FILENAME_ENHANCE[1]: "h5clear_fsm_persist_greater.h5"
+ * --FILENAME_ENHANCE[2]: "h5clear_fsm_persist_less.h5"
+ * --FILENAME_ENHANCE[4]: "h5clear_fsm_persist_greater.h5"
+ * --FILENAME_ENHANCE[5]: "h5clear_fsm_persist_less.h5"
+ *
+ * Write invalid value to the location for stored eoa and
+ * update the chksum value.
+ */
+ /* Open the file */
+ if ((fd = open(FILENAME_ENHANCE[i], O_RDWR, 0663)) < 0)
+ goto error;
+
+ switch (i) {
+ case 1: /* stored EOA is > EOF */
+ eoa = 3048;
+ chksum = 268376587;
+ break;
+
+ case 2: /* stored EOA is < EOF */
+ eoa = 512;
+ chksum = 372920305;
+ break;
+
+ case 4: /* with userblock, stored EOA > EOF */
+ eoa = 4000;
+ chksum = 4168810027;
+ break;
+
+ case 5: /* with userblock, stored EOA < EOF */
+ eoa = 3000;
+ chksum = 3716054346;
+ break;
+
+ default:
+ break;
+ }
+
+ /* location of "end of file address" */
+ if (lseek(fd, (off_t)(28 + (user ? USERBLOCK : 0)), SEEK_SET) < 0)
+ goto error;
+
+ /* Write the bad eoa value to the file */
+ if (write(fd, &eoa, sizeof(eoa)) < 0)
+ goto error;
+
+ /* location of "superblock checksum" */
+ if (lseek(fd, (off_t)(44 + (user ? USERBLOCK : 0)), SEEK_SET) < 0)
+ goto error;
+
+ /* Write the chksum value to the file */
+ if (write(fd, &chksum, sizeof(chksum)) < 0)
+ goto error;
+
+ /* Close the file */
+ if (close(fd) < 0)
+ goto error;
+
+ } /* end for */
+
+ /* Close the property list */
+ if (H5Pclose(fcpl) < 0)
+ goto error;
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY
+ {
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Fclose(fid);
+ H5Pclose(fcpl);
+ }
+ H5E_END_TRY;
+ return 1;
+} /* gen_enhance_files() */
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose: Generate test files used by h5clear.
+ *
+ * (A) gen_cache_image_file():
+ * --generate a file with cache image feature
+ * --"h5clear_mdc_image.h5"
+ * (B) gen_enhance_files():
+ * --generate the first 6 files in FILENAME_ENHANCE[]:
+ * (0) "h5clear_fsm_persist_equal.h5"
+ * (1) "h5clear_fsm_persist_greater.h5"
+ * (2) "h5clear_fsm_persist_less.h5"
+ * (3) "h5clear_fsm_persist_user_equal.h5"
+ * (4) "h5clear_fsm_persist_user_greater.h5"
+ * (5) "h5clear_fsm_persist_user_less.h5"
+ *
+ * (C) Generate the following FILENAME[] files in main():
+ * (0a) "h5clear_sec2_v3.h5"
+ * (0b) "latest_h5clear_sec2_v3.h5"
+ * (1a) "h5clear_log_v3.h5",
+ * (1b) "latest_h5clear_log_v3.h5"
+ * (2) "h5clear_sec2_v0.h5"
+ * (3) "h5clear_sec2_v2.h5"
+ *
+ * These HDF5 files are created with non-zero status_flags in
+ * the superblock via flushing and exiting without closing the
+ * library.
+ * Due to file locking, status_flags in the superblock will be
+ * nonzero after H5Fcreate. The library will clear status_flags
+ * on file closing.
+ * This program, after "H5Fcreate" the files, exits without
+ * going through library closing. Thus, status_flags for these
+ * files are not cleared.
+ * The library will check consistency of status_flags when
+ * opening a file with superblock >= v3 and will return error
+ * accordingly.
+ * The library will not check status_flags when opening a file
+ * with < v3 superblock.
+ * These files are used by "h5clear" to see if the tool clears
+ * status_flags properly so users can open the files afterwards.
+ *
+ * (D) Generate the last two files in FILENAME_ENHANCE[] in main():
+ * (6) "h5clear_status_noclose.h5",
+ * (7) "h5clear_fsm_persist_noclose.h5"
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Vailin Choi; July 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ hid_t fid = H5I_INVALID_HID; /* File ID */
+ hid_t fcpl = H5I_INVALID_HID; /* File creation property list */
+ hid_t fapl = -1, new_fapl = H5I_INVALID_HID; /* File access property lists */
+ char fname[512]; /* File name */
+ unsigned new_format; /* To use latest library format or not */
+ hid_t sid = H5I_INVALID_HID; /* Dataspace ID */
+ hid_t did = H5I_INVALID_HID; /* Dataset ID */
+ hsize_t dim[1]; /* Dimension sizes */
+ int data[NUM_ELMTS]; /* Buffer for data */
+ int i; /* Local index variables */
+
+ /* Generate a file with cache image feature enabled */
+ if (gen_cache_image_file(CACHE_IMAGE_FILE) < 0)
+ goto error;
+
+ /* Generate the first 6 files in FILENAME_ENHANCE[] */
+ if (gen_enhance_files(FALSE) < 0)
+ goto error;
+ if (gen_enhance_files(TRUE) < 0)
+ goto error;
+
+ /*
+ * Generate files in FILENAME[]
+ */
+ /* Create a copy of the file access property list */
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ goto error;
+
+ /* Copy the file access property list */
+ if ((new_fapl = H5Pcopy(fapl)) < 0)
+ goto error;
+ /* Set to latest library format */
+ if (H5Pset_libver_bounds(new_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ goto error;
+
+ /*
+ * Files created within this for loop will have v3 superblock and nonzero status_flags
+ * --FILENAME[0]: "h5clear_sec2_v3.h5", "latest_h5clear_sec2_v3.h5"
+ * --FILENAME[1]: "h5clear_log_v3.h5", "latest_h5clear_log_v3.h5"
+ */
+ for (new_format = FALSE; new_format <= TRUE; new_format++) {
+ hid_t fapl2, my_fapl; /* File access property lists */
+
+ /* Set to use the appropriate file access property list */
+ if (new_format)
+ fapl2 = new_fapl;
+ else
+ fapl2 = fapl;
+ /*
+ * Create a sec2 file
+ */
+ if ((my_fapl = H5Pcopy(fapl2)) < 0)
+ goto error;
+ /* Create the file */
+ HDsnprintf(fname, sizeof(fname), "%s%s", new_format ? "latest_" : "", FILENAME[0]);
+ if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC | (new_format ? 0 : H5F_ACC_SWMR_WRITE), H5P_DEFAULT,
+ my_fapl)) < 0)
+ goto error;
+
+ /* Flush the file */
+ if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0)
+ goto error;
+
+ /* Close the property list */
+ if (H5Pclose(my_fapl) < 0)
+ goto error;
+
+ /*
+ * Create a log file
+ */
+ /* Create a copy of file access property list */
+ if ((my_fapl = H5Pcopy(fapl2)) < 0)
+ goto error;
+
+ /* Setup the fapl for the log driver */
+ if (H5Pset_fapl_log(my_fapl, "append.log", (unsigned long long)H5FD_LOG_ALL, (size_t)(4 * KB)) < 0)
+ goto error;
+
+ /* Create the file */
+ HDsnprintf(fname, sizeof(fname), "%s%s", new_format ? "latest_" : "", FILENAME[1]);
+ if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC | (new_format ? 0 : H5F_ACC_SWMR_WRITE), H5P_DEFAULT,
+ my_fapl)) < 0)
+ goto error;
+
+ /* Flush the file */
+ if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0)
+ goto error;
+
+ /* Close the property list */
+ if (H5Pclose(my_fapl) < 0)
+ goto error;
+
+ } /* end for */
+
+ /*
+ * Create a sec2 file with v0 superblock but nonzero status_flags:
+ * FILENAME[2]: "h5clear_sec2_v0.h5"
+ */
+ if ((fid = H5Fcreate(FILENAME[2], H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ goto error;
+
+ /* Flush the file */
+ if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0)
+ goto error;
+
+ /*
+ * Create a sec2 file with v2 superblock but nonzero status_flags:
+ * FILENAME[3]: "h5clear_sec2_v2.h5"
+ */
+ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ goto error;
+ if (H5Pset_shared_mesg_nindexes(fcpl, 1) < 0)
+ goto error;
+ if (H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_DTYPE_FLAG, 50) < 0)
+ goto error;
+
+ if ((fid = H5Fcreate(FILENAME[3], H5F_ACC_TRUNC, fcpl, fapl)) < 0)
+ goto error;
+
+ /* Flush the file */
+ if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0)
+ goto error;
+
+ /* Close the property lists */
+ if (H5Pclose(fapl) < 0)
+ goto error;
+ if (H5Pclose(new_fapl) < 0)
+ goto error;
+ if (H5Pclose(fcpl) < 0)
+ goto error;
+
+ /*
+ * Create the last two files in FILENAME_ENHANCE[]:
+ * --FILENAME_ENHANCE[6]: h5clear_status_noclose.h5
+ * --FILENAME_ENHANCE[7]: h5clear_fsm_persist_noclose.h5
+ */
+ /*
+ * FILENAME_ENHANCE[6]: h5clear_status_noclose.h5
+ * --stored EOA < actual EOF
+ * --version 3 superblock
+ * --nonzero status_flags
+ * --does not persist free-space
+ * --does not flush the file, just exit without closing file:
+ * --this file is similar to the user-suppplied test file attached with HDFFV-10347
+ */
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ goto error;
+
+ /* Set to latest format */
+ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ goto error;
+
+ /* Create file with SWMR-write access */
+ if ((fid = H5Fcreate(FILENAME_ENHANCE[6], H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0)
+ goto error;
+
+ /* Create the dataset */
+ dim[0] = NUM_ELMTS;
+ if ((sid = H5Screate_simple(1, dim, NULL)) < 0)
+ goto error;
+ if ((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+
+ for (i = 0; i < NUM_ELMTS; i++)
+ data[i] = i;
+
+ /* Write the dataset */
+ if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
+ goto error;
+
+ /* Closing */
+ if (H5Dclose(did) < 0)
+ goto error;
+ if (H5Sclose(sid) < 0)
+ goto error;
+ if (H5Pclose(fapl) < 0)
+ goto error;
+
+ /* Does not flush and does not close the file */
+
+ /*
+ * FILENAME_ENHANCE[7]: h5clear_fsm_persist_noclose.h5
+ * --stored EOA < actual EOF
+ * --persisting free-space
+ * --undefined fsinfo.eoa_pre_fsm_fsalloc
+ * --undefined fsinfo.fs_addr
+ * --does not flush the file, just exit without closing
+ */
+ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ goto error;
+
+ /* Set file space strategy and persisting free-space */
+ if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0)
+ goto error;
+
+ /* Create the file with the set file space info */
+ if ((fid = H5Fcreate(FILENAME_ENHANCE[7], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0)
+ goto error;
+
+ /* Create the dataset */
+ dim[0] = NUM_ELMTS;
+ if ((sid = H5Screate_simple(1, dim, NULL)) < 0)
+ goto error;
+ if ((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+
+ for (i = 0; i < NUM_ELMTS; i++)
+ data[i] = i;
+
+ /* Write the dataset */
+ if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
+ goto error;
+
+ /* Closing */
+ if (H5Dclose(did) < 0)
+ goto error;
+ if (H5Sclose(sid) < 0)
+ goto error;
+ if (H5Pclose(fcpl) < 0)
+ goto error;
+
+ /* Does not flush and does not close the file */
+
+ fflush(stdout);
+ fflush(stderr);
+
+ /* Not going through library closing by calling _exit(0) with success */
+ HD_exit(0);
+
+error:
+
+ /* Exit with failure */
+ HD_exit(1);
+}
diff --git a/tools/test/misc/h5perf_gentest.c b/tools/test/misc/h5perf_gentest.c
new file mode 100644
index 0000000..5b898db
--- /dev/null
+++ b/tools/test/misc/h5perf_gentest.c
@@ -0,0 +1,653 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/*****************************************************************************
+ This test generates attributes, groups, and datasets of many types. It
+ creates a large number of attributes, groups, and datasets by specifying
+ -a, -g, -d options respectively. Using "-h" option to see details.
+
+ Programmer: Peter Cao, Jan. 2013
+ ****************************************************************************/
+
+#include "hdf5.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+#define FNAME "test_perf.h5"
+#define NGROUPS 20
+#define NDSETS 20
+#define NATTRS 20
+#define DIM0 40
+#define NROWS 100
+#define NTYPES 9
+#define MAXVLEN 10
+#define FIXED_LEN 8
+
+typedef enum { SOLID = 0, LIQUID, GAS, PLASMA } phase_t;
+
+typedef struct {
+ int i;
+ unsigned long long l;
+ float f;
+ double d;
+ char s[FIXED_LEN];
+ phase_t e;
+ float f_array[FIXED_LEN];
+ hvl_t i_vlen;
+ char *s_vlen;
+} test_comp_t;
+
+typedef struct {
+ int zipcode;
+ char *city;
+} zipcode_t;
+
+int add_attrs(hid_t oid, int idx);
+int add_attr(hid_t oid, const char *name, hid_t tid, hid_t sid, void *buf);
+herr_t create_perf_test_file(const char *fname, int ngrps, int ndsets, int nattrs, hsize_t nrows,
+ hsize_t dim0, hsize_t chunk, int vlen, int compressed, int latest);
+
+int
+main(int argc, char *argv[])
+{
+ char fname[32];
+ int i, ngrps = NGROUPS, ndsets = NDSETS, nattrs = NATTRS, dim0 = DIM0, chunk = DIM0 / 10 + 1,
+ nrows = NROWS, vlen = MAXVLEN, l = 0, z = 0;
+
+ memset(fname, 0, 32);
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-f") == 0)
+ strcpy(fname, argv[i + 1]);
+ else if (strcmp(argv[i], "-g") == 0)
+ ngrps = atoi(argv[i + 1]);
+ else if (strcmp(argv[i], "-d") == 0)
+ ndsets = atoi(argv[i + 1]);
+ else if (strcmp(argv[i], "-a") == 0)
+ nattrs = atoi(argv[i + 1]);
+ else if (strcmp(argv[i], "-r") == 0)
+ nrows = atoi(argv[i + 1]);
+ else if (strcmp(argv[i], "-s") == 0)
+ dim0 = atoi(argv[i + 1]);
+ else if (strcmp(argv[i], "-c") == 0)
+ chunk = atoi(argv[i + 1]);
+ else if (strcmp(argv[i], "-v") == 0)
+ vlen = atoi(argv[i + 1]);
+ else if (strcmp(argv[i], "-l") == 0)
+ l = 1;
+ else if (strcmp(argv[i], "-z") == 0)
+ z = 1;
+ else if (strcmp(argv[i], "-h") == 0) {
+ HDprintf("\nOPTONS:\n");
+ HDprintf("\t-f F:\tname of the test file (default: %s).\n", FNAME);
+ HDprintf("\t-g N:\tnumber of top level groups (default: %d).\n", NGROUPS);
+ HDprintf("\t-d N:\tnumber of datasets (default: %d).\n", NDSETS);
+ HDprintf("\t-a N:\tnumber of attributes (default: %d).\n", NATTRS);
+ HDprintf("\t-r N:\tnumber of rows in the large compound dataset (default: %d).\n", NROWS);
+ HDprintf("\t-s N:\tsize of dim0 in datasets (default: %d).\n", DIM0);
+ HDprintf("\t-c N:\tchunk size of dim0 (default: %d).\n", (DIM0 / 10 + 1));
+ HDprintf("\t-v N:\tmax vlen size (default: %d).\n", MAXVLEN);
+ HDprintf("\t-l:\tuse latest format (default: no).\n");
+ HDprintf("\t-z:\tuse gzip compression (default: no).\n");
+ HDprintf("\t-h:\tthis help information.\n");
+ HDprintf("Example:\n");
+ HDprintf("\t./a.out -f test.h5 -g 10000 -d 5000 -a 500 -r 10000 -s 200 -c 20 -v 40 -l -z\n\n");
+ exit(0);
+ }
+ }
+
+ if (strlen(fname) <= 0)
+ HDsnprintf(fname, sizeof(fname), FNAME);
+
+ create_perf_test_file(fname, ngrps, ndsets, nattrs, (hsize_t)nrows, (hsize_t)dim0, (hsize_t)chunk, vlen,
+ z, l);
+
+ return 0;
+}
+
+/*****************************************************************************
+ This function generates attributes, groups, and datasets of many types.
+
+ Parameters:
+ fname: file_name.
+ ngrps: number of top level groups.
+ ndsets: number of datasets.
+ attrs: number of attributes.
+ nrow: number of rows in a dataset.
+ chunk: chunk size (single number).
+ vlen: max vlen size.
+ comp: use latest format.
+ latest: use gzip comnpression.
+
+ Return: Non-negative on success/Negative on failure
+
+ Programmer: Peter Cao, Jan. 2013
+ ****************************************************************************/
+herr_t
+create_perf_test_file(const char *fname, int ngrps, int ndsets, int nattrs, hsize_t nrows, hsize_t dim0,
+ hsize_t chunk, int vlen, int compressed, int latest)
+{
+ int i, j, k;
+ hid_t fid, sid_null, sid_scalar, sid_1d, sid_2d, did, aid, sid_2, sid_large,
+ fapl = H5P_DEFAULT, dcpl = H5P_DEFAULT, gid1, gid2, cmp_tid, tid_str, tid_enum, tid_array_f,
+ tid_vlen_i, tid_vlen_s;
+ char name[32], tmp_name1[32], tmp_name2[32], tmp_name3[32];
+ hsize_t dims[1] = {dim0}, dims2d[2] = {dim0, (dim0 / 4 + 1)}, dims_array[1] = {FIXED_LEN}, dim1[1] = {2};
+ char *enum_names[4] = {"SOLID", "LIQUID", "GAS", "PLASMA"};
+ test_comp_t *buf_comp = NULL, *buf_comp_large = NULL;
+ int *buf_int = NULL;
+ float(*buf_float_a)[FIXED_LEN] = NULL;
+ double **buf_double2d = NULL;
+ hvl_t *buf_vlen_i = NULL;
+ char(*buf_str)[FIXED_LEN];
+ char **buf_vlen_s = NULL;
+ hobj_ref_t buf_ref[2];
+ hdset_reg_ref_t buf_reg_ref[2];
+ size_t offset, len;
+ herr_t status;
+ char *names[NTYPES] = {"int",
+ "ulong",
+ "float",
+ "double",
+ "fixed string",
+ "enum",
+ "fixed float array",
+ "vlen int array",
+ "vlen strings"};
+ hid_t types[NTYPES] = {H5T_NATIVE_INT, H5T_NATIVE_UINT64, H5T_NATIVE_FLOAT, H5T_NATIVE_DOUBLE, tid_str,
+ tid_enum, tid_array_f, tid_vlen_i, tid_vlen_s};
+ hsize_t coords[4][2] = {{0, 1}, {3, 5}, {1, 0}, {2, 4}}, start = 0, stride = 1, count = 1;
+
+ if (nrows < NROWS)
+ nrows = NROWS;
+ if (ngrps < NGROUPS)
+ ngrps = NGROUPS;
+ if (ndsets < NDSETS)
+ ndsets = NDSETS;
+ if (nattrs < NATTRS)
+ nattrs = NATTRS;
+ if (dim0 < DIM0)
+ dim0 = DIM0;
+ if (chunk > dim0)
+ chunk = dim0 / 4;
+ if (chunk < 1)
+ chunk = 1;
+ if (vlen < 1)
+ vlen = MAXVLEN;
+
+ /* create fixed string datatype */
+ types[4] = tid_str = H5Tcopy(H5T_C_S1);
+ H5Tset_size(tid_str, FIXED_LEN);
+
+ /* create enum datatype */
+ types[5] = tid_enum = H5Tenum_create(H5T_NATIVE_INT);
+ for (i = (int)SOLID; i <= (int)PLASMA; i++) {
+ phase_t val = (phase_t)i;
+ status = H5Tenum_insert(tid_enum, enum_names[i], &val);
+ }
+
+ /* create float array datatype */
+ types[6] = tid_array_f = H5Tarray_create(H5T_NATIVE_FLOAT, 1, dims_array);
+
+ /* create variable length integer datatypes */
+ types[7] = tid_vlen_i = H5Tvlen_create(H5T_NATIVE_INT);
+
+ /* create variable length string datatype */
+ types[8] = tid_vlen_s = H5Tcopy(H5T_C_S1);
+ H5Tset_size(tid_vlen_s, H5T_VARIABLE);
+
+ /* create compound datatypes */
+ cmp_tid = H5Tcreate(H5T_COMPOUND, sizeof(test_comp_t));
+ offset = 0;
+ for (i = 0; i < NTYPES - 2; i++) {
+ H5Tinsert(cmp_tid, names[i], offset, types[i]);
+ offset += H5Tget_size(types[i]);
+ }
+
+ H5Tinsert(cmp_tid, names[7], offset, types[7]);
+ offset += sizeof(hvl_t);
+ H5Tinsert(cmp_tid, names[8], offset, types[8]);
+
+ /* create dataspace */
+ sid_1d = H5Screate_simple(1, dims, NULL);
+ sid_2d = H5Screate_simple(2, dims2d, NULL);
+ sid_2 = H5Screate_simple(1, dim1, NULL);
+ sid_large = H5Screate_simple(1, &nrows, NULL);
+ sid_null = H5Screate(H5S_NULL);
+ sid_scalar = H5Screate(H5S_SCALAR);
+
+ /* create fid access property */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
+
+ /* create dataset creation property */
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+
+ /* set dataset chunk */
+ if (chunk > 0) {
+ H5Pset_chunk(dcpl, 1, &chunk);
+ }
+
+ /* set dataset compression */
+ if (compressed) {
+ if (chunk <= 0) {
+ chunk = dim0 / 10 + 1;
+ ;
+ H5Pset_chunk(dcpl, 1, &chunk);
+ }
+ H5Pset_shuffle(dcpl);
+ H5Pset_deflate(dcpl, 6);
+ }
+
+ /* allocate buffers */
+ buf_comp = (test_comp_t *)calloc(dim0, sizeof(test_comp_t));
+ buf_comp_large = (test_comp_t *)calloc(nrows, sizeof(test_comp_t));
+ buf_int = (int *)calloc(dim0, sizeof(int));
+ buf_float_a = malloc(dim0 * sizeof(*buf_float_a));
+ buf_vlen_i = (hvl_t *)calloc(dim0, sizeof(hvl_t));
+ buf_vlen_s = (char **)calloc(dim0, sizeof(char *));
+ buf_str = malloc(dim0 * sizeof(*buf_str));
+
+ /* allocate array of double pointers */
+ buf_double2d = (double **)calloc(dims2d[0], sizeof(double *));
+ /* allocate a contiguous chunk of memory for the data */
+ buf_double2d[0] = (double *)calloc(dims2d[0] * dims2d[1], sizeof(double));
+ /* assign memory city to pointer array */
+ for (i = 1; i < dims2d[0]; i++)
+ buf_double2d[i] = buf_double2d[0] + i * dims2d[1];
+
+ /* fill buffer values */
+ len = 1;
+ for (i = 0; i < dims[0]; i++) {
+ buf_comp[i].i = buf_int[i] = i - 2147483648;
+ buf_comp[i].l = 0xffffffffffffffff - i;
+ buf_comp[i].f = 1.0 / (i + 1.0);
+ buf_comp[i].d = 987654321.0 * i + 1.0 / (i + 1.0);
+ buf_comp[i].e = (phase_t)(i % (int)(PLASMA + 1));
+
+ for (j = 0; j < FIXED_LEN; j++) {
+ buf_comp[i].f_array[j] = buf_float_a[i][j] = i * 100 + j;
+ buf_str[i][j] = 'a' + (i % 26);
+ }
+ buf_str[i][FIXED_LEN - 1] = 0;
+ strcpy(buf_comp[i].s, buf_str[i]);
+
+ len = (1 - cos(i / 8.0)) / 2 * vlen + 1;
+ if (!i)
+ len = vlen;
+ buf_vlen_i[i].len = len;
+ buf_vlen_i[i].p = (int *)calloc(len, sizeof(int));
+ for (j = 0; j < len; j++)
+ ((int *)(buf_vlen_i[i].p))[j] = i * 100 + j;
+ buf_comp[i].i_vlen = buf_vlen_i[i];
+
+ buf_vlen_s[i] = (char *)calloc(len, sizeof(char));
+ for (j = 0; j < len - 1; j++)
+ buf_vlen_s[i][j] = j % 26 + 'A';
+ buf_comp[i].s_vlen = buf_vlen_s[i];
+
+ for (j = 0; j < dims2d[1]; j++)
+ buf_double2d[i][j] = i + j / 10000.0;
+ }
+
+ for (i = 0; i < nrows; i++) {
+ buf_comp_large[i].i = i - 2147483648;
+ buf_comp_large[i].l = 0xffffffffffffffff - i;
+ buf_comp_large[i].f = 1.0 / (i + 1.0);
+ buf_comp_large[i].d = 987654321.0 * i + 1.0 / (i + 1.0);
+ buf_comp_large[i].e = (phase_t)(i % (int)(PLASMA + 1));
+ for (j = 0; j < FIXED_LEN - 1; j++) {
+ buf_comp_large[i].f_array[j] = i * 100 + j;
+ buf_comp_large[i].s[j] = 'a' + (i % 26);
+ }
+ len = i % vlen + 1;
+ buf_comp_large[i].i_vlen.len = len;
+ buf_comp_large[i].i_vlen.p = (int *)calloc(len, sizeof(int));
+ for (j = 0; j < len; j++)
+ ((int *)(buf_comp_large[i].i_vlen.p))[j] = i * 100 + j;
+ buf_comp_large[i].s_vlen = (char *)calloc(i + 2, sizeof(char));
+ for (j = 0; j < i + 1; j++)
+ (buf_comp_large[i].s_vlen)[j] = j % 26 + 'A';
+ }
+
+ /* create file */
+ if (latest)
+ fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
+ else
+ fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ add_attrs(fid, 0);
+
+ HDsnprintf(name, sizeof(name), "a cmp ds of %d rows", nrows);
+ did = H5Dcreate(fid, name, cmp_tid, sid_large, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ H5Dwrite(did, cmp_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_comp_large);
+ add_attrs(did, 0);
+ H5Dclose(did);
+
+ // /* add attributes*/
+ gid1 = H5Gcreate(fid, "attributes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (nattrs < 1)
+ nattrs = 1;
+ i = 0;
+ while (i < nattrs)
+ i += add_attrs(gid1, i);
+ H5Gclose(gid1);
+
+ /* add many sub groups to a group*/
+ gid1 = H5Gcreate(fid, "groups", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ add_attrs(gid1, 0);
+ for (i = 0; i < ngrps; i++) {
+ /* create sub groups */
+ HDsnprintf(name, sizeof(name), "g%02d", i);
+ gid2 = H5Gcreate(gid1, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (i < 10)
+ add_attrs(gid2, 0);
+ H5Gclose(gid2);
+ }
+ H5Gclose(gid1);
+
+ /* add many datasets to a group */
+ gid1 = H5Gcreate(fid, "datasets", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ add_attrs(gid1, 0);
+ for (j = 0; j < ndsets; j += 12) {
+ /* 1 add a null dataset */
+ HDsnprintf(name, sizeof(name), "%05d null dataset", j);
+ did = H5Dcreate(gid1, name, H5T_STD_I32LE, sid_null, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (!j)
+ add_attrs(did, j);
+ H5Dclose(did);
+
+ /* 2 add scalar int point */
+ HDsnprintf(name, sizeof(name), "%05d scalar int point", j);
+ did = H5Dcreate(gid1, name, H5T_NATIVE_INT, sid_scalar, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &j);
+ if (!j)
+ add_attrs(did, j);
+ H5Dclose(did);
+
+ /* 3 scalar vlen string */
+ HDsnprintf(name, sizeof(name), "%05d scalar vlen string", j);
+ did = H5Dcreate(gid1, name, tid_vlen_s, sid_scalar, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ H5Dwrite(did, tid_vlen_s, H5S_ALL, H5S_ALL, H5P_DEFAULT, &buf_vlen_s[0]);
+ if (!j)
+ add_attrs(did, j);
+ H5Dclose(did);
+
+ /* 4 add fixed-length float array */
+ HDsnprintf(name, sizeof(name), "%05d fixed-length float array", j);
+ did = H5Dcreate(gid1, name, tid_array_f, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ H5Dwrite(did, tid_array_f, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_float_a);
+ if (!j)
+ add_attrs(did, j);
+ H5Dclose(did);
+
+ /* 5 add fixed-length strings */
+ HDsnprintf(name, sizeof(name), "%05d fixed-length strings", j);
+ did = H5Dcreate(gid1, name, tid_str, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ H5Dwrite(did, tid_str, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_str);
+ if (!j)
+ add_attrs(did, j);
+ H5Dclose(did);
+
+ /* 6 add compound data */
+ HDsnprintf(name, sizeof(name), "%05d compound data", j);
+ did = H5Dcreate(gid1, name, cmp_tid, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ H5Dwrite(did, cmp_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_comp);
+ if (!j)
+ add_attrs(did, j);
+ H5Dclose(did);
+
+ /* 7 add 2D double */
+ HDsnprintf(name, sizeof(name), "%05d 2D double", j);
+ strcpy(tmp_name1, name);
+ did = H5Dcreate(gid1, name, H5T_NATIVE_DOUBLE, sid_2d, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ H5Dwrite(did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_double2d[0]);
+ if (!j)
+ add_attrs(did, j);
+ H5Dclose(did);
+
+ /* 8 add 1D int array */
+ HDsnprintf(name, sizeof(name), "%05d 1D int array", j);
+ did = H5Dcreate(gid1, name, H5T_NATIVE_INT, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_int);
+ if (!j)
+ add_attrs(did, j);
+ H5Dclose(did);
+
+ /* 9 add vlen int array */
+ HDsnprintf(name, sizeof(name), "%05d vlen int array", j);
+ strcpy(tmp_name2, name);
+ did = H5Dcreate(gid1, name, tid_vlen_i, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ H5Dwrite(did, tid_vlen_i, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_vlen_i);
+ if (!j)
+ add_attrs(did, j);
+ H5Dclose(did);
+
+ /* 10 add vlen strings */
+ HDsnprintf(name, sizeof(name), "%05d vlen strings", j);
+ strcpy(tmp_name3, name);
+ did = H5Dcreate(gid1, name, tid_vlen_s, sid_1d, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ H5Dwrite(did, tid_vlen_s, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_vlen_s);
+ if (!j)
+ add_attrs(did, j);
+ H5Dclose(did);
+
+ /* 11 add object refs */
+ H5Rcreate(&buf_ref[0], gid1, ".", H5R_OBJECT, (hid_t)-1);
+ H5Rcreate(&buf_ref[1], gid1, tmp_name3, H5R_OBJECT, (hid_t)-1);
+ HDsnprintf(name, sizeof(name), "%05d obj refs", j);
+ did = H5Dcreate(gid1, name, H5T_STD_REF_OBJ, sid_2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ H5Dwrite(did, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_ref);
+ if (!j)
+ add_attrs(did, j);
+ H5Dclose(did);
+
+ /* 12 add region refs */
+ H5Sselect_elements(sid_2d, H5S_SELECT_SET, 4, coords[0]);
+ H5Rcreate(&buf_reg_ref[0], gid1, tmp_name1, H5R_DATASET_REGION, sid_2d);
+ H5Sselect_none(sid_2d);
+ count = dims[0] / 2 + 1;
+ H5Sselect_hyperslab(sid_1d, H5S_SELECT_SET, &start, &stride, &count, NULL);
+ H5Rcreate(&buf_reg_ref[1], gid1, tmp_name2, H5R_DATASET_REGION, sid_1d);
+ H5Sselect_none(sid_1d);
+ HDsnprintf(name, sizeof(name), "%05d region refs", j);
+ did = H5Dcreate(gid1, name, H5T_STD_REF_DSETREG, sid_2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ H5Dwrite(did, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_reg_ref);
+ if (!j)
+ add_attrs(did, j);
+ H5Dclose(did);
+ }
+ H5Gclose(gid1);
+
+ H5Tclose(tid_array_f);
+ H5Tclose(tid_vlen_i);
+ H5Tclose(tid_vlen_s);
+ H5Tclose(tid_enum);
+ H5Tclose(tid_str);
+ H5Tclose(cmp_tid);
+ H5Pclose(dcpl);
+ H5Pclose(fapl);
+ H5Sclose(sid_1d);
+ H5Sclose(sid_2d);
+ H5Sclose(sid_2);
+ H5Sclose(sid_large);
+ H5Sclose(sid_null);
+ H5Sclose(sid_scalar);
+ H5Fclose(fid);
+
+ for (i = 0; i < dims[0]; i++) {
+ if (buf_vlen_i[i].p)
+ free(buf_vlen_i[i].p);
+ if (buf_vlen_s[i])
+ free(buf_vlen_s[i]);
+ }
+
+ for (i = 0; i < nrows; i++) {
+ if (buf_comp_large[i].i_vlen.p)
+ free(buf_comp_large[i].i_vlen.p);
+ if (buf_comp_large[i].s_vlen)
+ free(buf_comp_large[i].s_vlen);
+ }
+
+ free(buf_comp);
+ free(buf_comp_large);
+ free(buf_int);
+ free(buf_float_a);
+ free(buf_double2d[0]);
+ free(buf_double2d);
+ free(buf_str);
+ free(buf_vlen_i);
+ free(buf_vlen_s);
+
+ return 0;
+}
+
+/* add a single attribute */
+int
+add_attr(hid_t oid, const char *name, hid_t tid, hid_t sid, void *buf)
+{
+ hid_t aid;
+
+ aid = H5Acreate(oid, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT);
+ if (aid < 0)
+ return 0;
+
+ H5Awrite(aid, tid, buf);
+
+ H5Aclose(aid);
+
+ return 1;
+}
+
+/*
+ adds different types of attributes to an object.
+
+ returns the number of attributes added to the objects.
+ */
+int
+add_attrs(hid_t oid, int idx)
+{
+ char name[32];
+ int i0, i1, i2, j, nattrs = 0;
+ hid_t aid, tid, tid1, sid;
+ hvl_t i_vlen[4];
+ hobj_ref_t ref;
+ zipcode_t cmp_data[4];
+ unsigned int i = 0xffffffff;
+ long long l = -2147483647;
+ float f = 123456789.987654321;
+ double d = 987654321.123456789;
+ char *s[7] = {"Parting", "is such", "sweeter", "sorrow."};
+ float f_array[4] = {1.0, 2.22, 3.333, 4.444};
+ char *s_vlen[4] = {"Parting", "is such", "sweet", "sorrow."};
+ hsize_t dims1[1] = {1}, dims2[1] = {4}, dims3[2] = {3, 5};
+ int int3d[4][3][5];
+ size_t offset = 0;
+
+ for (i0 = 0; i0 < 4; i0++) {
+ i_vlen[i0].len = (i0 + 1);
+ i_vlen[i0].p = (int *)calloc(i_vlen[i0].len, sizeof(int));
+ for (j = 0; j < i_vlen[i0].len; j++)
+ ((int *)i_vlen[i0].p)[j] = i0 * 100 + j;
+ for (i1 = 0; i1 < 3; i1++) {
+ for (i2 = 0; i2 < 5; i2++)
+ int3d[i0][i1][i2] = i0 * i1 - i1 * i2 + i0 * i2;
+ }
+ }
+
+ cmp_data[0].zipcode = 01001;
+ cmp_data[0].city = "Agawam, Massachusetts";
+ cmp_data[1].zipcode = 99950;
+ cmp_data[1].city = "Ketchikan, Alaska";
+ cmp_data[2].zipcode = 00501;
+ cmp_data[2].city = "Holtsville, New York";
+ cmp_data[3].zipcode = 61820;
+ cmp_data[3].city = "Champaign, Illinois";
+
+ /* 1 scalar point */
+ sid = H5Screate(H5S_SCALAR);
+ HDsnprintf(name, sizeof(name), "%05d scalar int", idx);
+ nattrs += add_attr(oid, name, H5T_NATIVE_UINT, sid, &i);
+ HDsnprintf(name, sizeof(name), "%05d scalar ulong", idx);
+ nattrs += add_attr(oid, name, H5T_NATIVE_INT64, sid, &l);
+ HDsnprintf(name, sizeof(name), "%05d scalar str", idx);
+ tid = H5Tcopy(H5T_C_S1);
+ H5Tset_size(tid, H5T_VARIABLE);
+ nattrs += add_attr(oid, name, tid, sid, &s[2]);
+ H5Tclose(tid);
+ H5Sclose(sid);
+
+ /* 4 single point */
+ sid = H5Screate_simple(1, dims1, NULL);
+ H5Rcreate(&ref, oid, ".", H5R_OBJECT, (hid_t)-1);
+ HDsnprintf(name, sizeof(name), "%05d single float", idx);
+ nattrs += add_attr(oid, name, H5T_NATIVE_FLOAT, sid, &f);
+ HDsnprintf(name, sizeof(name), "%05d single double", idx);
+ nattrs += add_attr(oid, name, H5T_NATIVE_DOUBLE, sid, &d);
+ HDsnprintf(name, sizeof(name), "%05d single obj_ref", idx);
+ nattrs += add_attr(oid, name, H5T_STD_REF_OBJ, sid, &ref);
+ H5Sclose(sid);
+
+ /* 7 fixed length 1D array */
+ sid = H5Screate_simple(1, dims1, NULL);
+ tid = H5Tarray_create(H5T_NATIVE_FLOAT, 1, dims2);
+ HDsnprintf(name, sizeof(name), "%05d array float", idx);
+ nattrs += add_attr(oid, name, tid, sid, &f_array[0]);
+ H5Tclose(tid);
+ tid = H5Tcopy(H5T_C_S1);
+ H5Tset_size(tid, strlen(s[0]) + 1);
+ tid1 = H5Tarray_create(tid, 1, dims2);
+ HDsnprintf(name, sizeof(name), "%05d array str", idx);
+ nattrs += add_attr(oid, name, tid1, sid, s);
+ H5Tclose(tid1);
+ H5Tclose(tid);
+ H5Sclose(sid);
+
+ /* 9 fixed length 2D int arrays */
+ sid = H5Screate_simple(1, dims2, NULL);
+ tid = H5Tarray_create(H5T_NATIVE_INT, 2, dims3);
+ HDsnprintf(name, sizeof(name), "%05d array int 2D", idx);
+ nattrs += add_attr(oid, name, tid, sid, int3d[0][0]);
+ H5Tclose(tid);
+ H5Sclose(sid);
+
+ /* 10 variable length arrays */
+ sid = H5Screate_simple(1, dims2, NULL);
+ tid = H5Tcopy(H5T_C_S1);
+ H5Tset_size(tid, H5T_VARIABLE);
+ HDsnprintf(name, sizeof(name), "%05d vlen strings", idx);
+ nattrs += add_attr(oid, name, tid, sid, s_vlen);
+ H5Tclose(tid);
+ tid = H5Tvlen_create(H5T_NATIVE_INT);
+ ;
+ HDsnprintf(name, sizeof(name), "%05d vlen int array", idx);
+ nattrs += add_attr(oid, name, tid, sid, i_vlen);
+ H5Tclose(tid);
+ H5Sclose(sid);
+
+ /* 12 compound data */
+ sid = H5Screate_simple(1, dims2, NULL);
+ tid = H5Tcreate(H5T_COMPOUND, sizeof(zipcode_t));
+ tid1 = H5Tcopy(H5T_C_S1);
+ H5Tset_size(tid1, H5T_VARIABLE);
+ H5Tinsert(tid, "zip code", 0, H5T_NATIVE_INT);
+ offset += sizeof(H5T_NATIVE_INT);
+ H5Tinsert(tid, "City", offset, tid1);
+ offset += sizeof(char *);
+ HDsnprintf(name, sizeof(name), "%05d compound data", idx);
+ nattrs += add_attr(oid, name, tid, sid, cmp_data);
+ H5Tclose(tid1);
+ H5Tclose(tid);
+ H5Sclose(sid);
+
+ for (i0 = 0; i0 < 4; i0++)
+ free(i_vlen[i0].p);
+
+ return nattrs;
+}
diff --git a/tools/test/misc/h5repart_gentest.c b/tools/test/misc/h5repart_gentest.c
new file mode 100644
index 0000000..04ac8e7
--- /dev/null
+++ b/tools/test/misc/h5repart_gentest.c
@@ -0,0 +1,113 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Programmer: Raymond Lu
+ * June 1, 2005
+ *
+ * Purpose: Generate a family file of 1024 bytes for each member
+ * for h5repart test.
+ */
+#include "hdf5.h"
+#include "H5private.h"
+
+#define FAMILY_NUMBER 4
+#define FAMILY_SIZE 1024
+#define FILENAME "family_file%05d.h5"
+
+int **buf = NULL;
+int *buf_data = NULL;
+
+int
+main(void)
+{
+ hid_t file = (-1), fapl, space = (-1), dset = (-1);
+ char dname[] = "dataset";
+ int i, j;
+ hsize_t dims[2] = {FAMILY_NUMBER, FAMILY_SIZE};
+
+ /* Set up data array */
+ if (NULL == (buf_data = (int *)HDcalloc(FAMILY_NUMBER * FAMILY_SIZE, sizeof(int)))) {
+ HDperror("HDcalloc");
+ HDexit(EXIT_FAILURE);
+ }
+ if (NULL == (buf = (int **)HDcalloc(FAMILY_NUMBER, sizeof(buf_data)))) {
+ HDperror("HDcalloc");
+ HDexit(EXIT_FAILURE);
+ }
+ for (i = 0; i < FAMILY_NUMBER; i++)
+ buf[i] = buf_data + (i * FAMILY_SIZE);
+
+ /* Set property list and file name for FAMILY driver */
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ HDperror("H5Pcreate");
+ HDexit(EXIT_FAILURE);
+ }
+
+ if (H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) {
+ HDperror("H5Pset_fapl_family");
+ HDexit(EXIT_FAILURE);
+ }
+
+ if ((file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) {
+ HDperror("H5Fcreate");
+ HDexit(EXIT_FAILURE);
+ }
+
+ /* Create and write dataset */
+ if ((space = H5Screate_simple(2, dims, NULL)) < 0) {
+ HDperror("H5Screate_simple");
+ HDexit(EXIT_FAILURE);
+ }
+
+ if ((dset = H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
+ HDperror("H5Dcreate2");
+ HDexit(EXIT_FAILURE);
+ }
+
+ for (i = 0; i < FAMILY_NUMBER; i++)
+ for (j = 0; j < FAMILY_SIZE; j++)
+ buf[i][j] = i * 10000 + j;
+
+ if (H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) {
+ HDperror("H5Dwrite");
+ HDexit(EXIT_FAILURE);
+ }
+
+ if (H5Sclose(space) < 0) {
+ HDperror("H5Sclose");
+ HDexit(EXIT_FAILURE);
+ }
+
+ if (H5Dclose(dset) < 0) {
+ HDperror("H5Dclose");
+ HDexit(EXIT_FAILURE);
+ }
+
+ if (H5Pclose(fapl) < 0) {
+ HDperror("H5Pclose");
+ HDexit(EXIT_FAILURE);
+ }
+
+ if (H5Fclose(file) < 0) {
+ HDperror("H5Fclose");
+ HDexit(EXIT_FAILURE);
+ }
+
+ HDfree(buf);
+ HDfree(buf_data);
+
+ HDputs(" PASSED");
+ HDfflush(stdout);
+
+ return EXIT_SUCCESS;
+}
diff --git a/tools/test/misc/repart_test.c b/tools/test/misc/repart_test.c
new file mode 100644
index 0000000..5c3ebf2
--- /dev/null
+++ b/tools/test/misc/repart_test.c
@@ -0,0 +1,151 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Purpose: This program tests family files after being repartitioned
+ * by h5repart. It simply tries to reopen the files with
+ * correct family driver and member size.
+ */
+#include "hdf5.h"
+#include "H5private.h"
+
+#define KB 1024
+#define FAMILY_H5REPART_SIZE1 20000
+#define FAMILY_H5REPART_SIZE2 (5 * KB)
+
+const char *FILENAME[] = {"fst_family%05d.h5", "scd_family%05d.h5", "family_to_single.h5",
+ "family_to_sec2.h5", NULL};
+
+herr_t test_family_h5repart_opens(void);
+herr_t test_single_h5repart_opens(void);
+
+/*-------------------------------------------------------------------------
+ * Function: test_family_h5repart_opens
+ *
+ * Purpose: Tries to reopen family files.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+test_family_h5repart_opens(void)
+{
+ hid_t fid = H5I_INVALID_HID;
+ hid_t fapl_id = H5I_INVALID_HID;
+
+ /* open 1st file(single member file) with correct family size(20000 byte) */
+ if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ goto error;
+
+ if (H5Pset_fapl_family(fapl_id, (hsize_t)FAMILY_H5REPART_SIZE1, H5P_DEFAULT) < 0)
+ goto error;
+
+ if ((fid = H5Fopen(FILENAME[0], H5F_ACC_RDWR, fapl_id)) < 0)
+ goto error;
+
+ if (H5Fclose(fid) < 0)
+ goto error;
+
+ /* open 2nd file(multiple member files) with correct family size(5KB) */
+ if (H5Pset_fapl_family(fapl_id, (hsize_t)FAMILY_H5REPART_SIZE2, H5P_DEFAULT) < 0)
+ goto error;
+
+ if ((fid = H5Fopen(FILENAME[1], H5F_ACC_RDWR, fapl_id)) < 0)
+ goto error;
+
+ if (H5Pclose(fapl_id) < 0)
+ goto error;
+
+ if (H5Fclose(fid) < 0)
+ goto error;
+
+ return SUCCEED;
+
+error:
+ H5E_BEGIN_TRY
+ {
+ H5Pclose(fapl_id);
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
+
+ return FAIL;
+
+} /* end test_family_h5repart_opens() */
+
+/*-------------------------------------------------------------------------
+ * Function: test_single_h5repart_opens
+ *
+ * Purpose: Tries to reopen a single file.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+test_single_h5repart_opens(void)
+{
+ hid_t fid = H5I_INVALID_HID;
+
+ /* open the single file */
+ if ((fid = H5Fopen(FILENAME[2], H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ goto error;
+ if (H5Fclose(fid) < 0)
+ goto error;
+
+ /* open the single file (created using the old argument) */
+ if ((fid = H5Fopen(FILENAME[3], H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ goto error;
+ if (H5Fclose(fid) < 0)
+ goto error;
+
+ return SUCCEED;
+
+error:
+ H5E_BEGIN_TRY
+ {
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
+
+ return FAIL;
+
+} /* end test_single_h5repart_opens() */
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose: Tests h5repart-ed family files
+ *
+ * Return: EXIT_SUCCESS/EXIT_FAILURE
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ int nerrors = 0;
+
+ nerrors += test_family_h5repart_opens() < 0 ? 1 : 0;
+ nerrors += test_single_h5repart_opens() < 0 ? 1 : 0;
+
+ if (nerrors)
+ goto error;
+
+ HDexit(EXIT_SUCCESS);
+
+error:
+ nerrors = MAX(1, nerrors);
+ HDprintf("***** %d FAMILY FILE TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S");
+ HDexit(EXIT_FAILURE);
+} /* end main() */
diff --git a/tools/test/misc/talign.c b/tools/test/misc/talign.c
new file mode 100644
index 0000000..7764e34
--- /dev/null
+++ b/tools/test/misc/talign.c
@@ -0,0 +1,202 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Small program to illustrate the "misalignment" of members within a compound
+ * datatype, in a datatype fixed by H5Tget_native_type().
+ */
+
+#include "hdf5.h"
+#include "H5private.h"
+#include "h5tools.h"
+
+const char *fname = "talign.h5";
+const char *setname = "align";
+
+/*
+ * This program assumes that there is no extra space between the members 'Ok'
+ * and 'Not Ok', (there shouldn't be because they are of the same atomic type
+ * H5T_NATIVE_FLOAT, and they are placed within the compound next to one
+ * another per construction)
+ */
+
+int
+main(void)
+{
+ hid_t fil = H5I_INVALID_HID, spc = H5I_INVALID_HID, set = H5I_INVALID_HID;
+ hid_t cs6 = H5I_INVALID_HID, cmp = H5I_INVALID_HID, fix = H5I_INVALID_HID;
+ hid_t cmp1 = H5I_INVALID_HID, cmp2 = H5I_INVALID_HID, cmp3 = H5I_INVALID_HID;
+ hid_t plist = H5I_INVALID_HID;
+ hid_t array_dt = H5I_INVALID_HID;
+
+ hsize_t dim[2];
+ hsize_t cdim[4];
+
+ char string5[5];
+ float fok[2] = {1234.0f, 2341.0f};
+ float fnok[2] = {5678.0f, 6785.0f};
+ float *fptr = NULL;
+
+ char *data = NULL;
+
+ int result = 0;
+ herr_t error = 1;
+
+ HDprintf("%-70s", "Testing alignment in compound datatypes");
+
+ HDstrcpy(string5, "Hi!");
+ HDunlink(fname);
+ fil = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ if (fil < 0) {
+ HDputs("*FAILED*");
+ return 1;
+ }
+
+ H5E_BEGIN_TRY
+ {
+ (void)H5Ldelete(fil, setname, H5P_DEFAULT);
+ }
+ H5E_END_TRY;
+
+ cs6 = H5Tcopy(H5T_C_S1);
+ H5Tset_size(cs6, sizeof(string5));
+ H5Tset_strpad(cs6, H5T_STR_NULLPAD);
+
+ cmp = H5Tcreate(H5T_COMPOUND, sizeof(fok) + sizeof(string5) + sizeof(fnok));
+ H5Tinsert(cmp, "Awkward length", 0, cs6);
+
+ cdim[0] = sizeof(fok) / sizeof(float);
+ array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim);
+ H5Tinsert(cmp, "Ok", sizeof(string5), array_dt);
+ H5Tclose(array_dt);
+
+ cdim[0] = sizeof(fnok) / sizeof(float);
+ array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim);
+ H5Tinsert(cmp, "Not Ok", sizeof(fok) + sizeof(string5), array_dt);
+ H5Tclose(array_dt);
+
+ fix = H5Tget_native_type(cmp, H5T_DIR_DEFAULT);
+ cmp1 = H5Tcreate(H5T_COMPOUND, sizeof(fok));
+
+ cdim[0] = sizeof(fok) / sizeof(float);
+ array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim);
+ H5Tinsert(cmp1, "Ok", 0, array_dt);
+ H5Tclose(array_dt);
+
+ cmp2 = H5Tcreate(H5T_COMPOUND, sizeof(string5));
+ H5Tinsert(cmp2, "Awkward length", 0, cs6);
+
+ cmp3 = H5Tcreate(H5T_COMPOUND, sizeof(fnok));
+
+ cdim[0] = sizeof(fnok) / sizeof(float);
+ array_dt = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, cdim);
+ H5Tinsert(cmp3, "Not Ok", 0, array_dt);
+ H5Tclose(array_dt);
+
+ plist = H5Pcreate(H5P_DATASET_XFER);
+ if ((error = H5Pset_preserve(plist, 1)) < 0)
+ goto out;
+
+ /*
+ * Create a small dataset, and write data into it we write each field
+ * in turn so that we are avoid alignment issues at this point
+ */
+ dim[0] = 1;
+ spc = H5Screate_simple(1, dim, NULL);
+ set = H5Dcreate2(fil, setname, cmp, spc, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+
+ H5Dwrite(set, cmp1, spc, H5S_ALL, plist, fok);
+ H5Dwrite(set, cmp2, spc, H5S_ALL, plist, string5);
+ H5Dwrite(set, cmp3, spc, H5S_ALL, plist, fnok);
+
+ H5Dclose(set);
+
+ /* Now open the set, and read it back in */
+ data = (char *)HDmalloc(H5Tget_size(fix));
+
+ if (!data) {
+ HDperror("malloc() failed");
+ HDabort();
+ }
+
+ set = H5Dopen2(fil, setname, H5P_DEFAULT);
+
+ H5Dread(set, fix, spc, H5S_ALL, H5P_DEFAULT, data);
+ fptr = (float *)((void *)(data + H5Tget_member_offset(fix, 1)));
+ H5Dclose(set);
+
+out:
+ if (error < 0) {
+ result = 1;
+ HDputs("*FAILED - HDF5 library error*");
+ }
+ else if (!(H5_FLT_ABS_EQUAL(fok[0], fptr[0])) || !(H5_FLT_ABS_EQUAL(fok[1], fptr[1])) ||
+ !(H5_FLT_ABS_EQUAL(fnok[0], fptr[2])) || !(H5_FLT_ABS_EQUAL(fnok[1], fptr[3]))) {
+ char *mname;
+
+ result = 1;
+ mname = H5Tget_member_name(fix, 0);
+ HDprintf("%14s (%2d) %6s = %s\n", mname ? mname : "(null)", (int)H5Tget_member_offset(fix, 0),
+ string5, (char *)(data + H5Tget_member_offset(fix, 0)));
+ if (mname)
+ H5free_memory(mname);
+
+ fptr = (float *)((void *)(data + H5Tget_member_offset(fix, 1)));
+ mname = H5Tget_member_name(fix, 1);
+ HDprintf("Data comparison:\n"
+ "%14s (%2d) %6f = %f\n"
+ " %6f = %f\n",
+ mname ? mname : "(null)", (int)H5Tget_member_offset(fix, 1), (double)fok[0], (double)fptr[0],
+ (double)fok[1], (double)fptr[1]);
+ if (mname)
+ H5free_memory(mname);
+
+ fptr = (float *)((void *)(data + H5Tget_member_offset(fix, 2)));
+ mname = H5Tget_member_name(fix, 2);
+ HDprintf("%14s (%2d) %6f = %f\n"
+ " %6f = %6f\n",
+ mname ? mname : "(null)", (int)H5Tget_member_offset(fix, 2), (double)fnok[0],
+ (double)fptr[0], (double)fnok[1], (double)fptr[1]);
+ if (mname)
+ H5free_memory(mname);
+
+ fptr = (float *)((void *)(data + H5Tget_member_offset(fix, 1)));
+ HDprintf("\n"
+ "Short circuit\n"
+ " %6f = %f\n"
+ " %6f = %f\n"
+ " %6f = %f\n"
+ " %6f = %f\n",
+ (double)fok[0], (double)fptr[0], (double)fok[1], (double)fptr[1], (double)fnok[0],
+ (double)fptr[2], (double)fnok[1], (double)fptr[3]);
+ HDputs("*FAILED - compound type alignmnent problem*");
+ }
+ else {
+ HDputs(" PASSED");
+ }
+
+ if (data)
+ HDfree(data);
+ H5Sclose(spc);
+ H5Tclose(cs6);
+ H5Tclose(cmp);
+ H5Tclose(fix);
+ H5Tclose(cmp1);
+ H5Tclose(cmp2);
+ H5Tclose(cmp3);
+ H5Pclose(plist);
+ H5Fclose(fil);
+ HDunlink(fname);
+ HDfflush(stdout);
+ return result;
+}
diff --git a/tools/test/misc/testfiles/h5clear_equal_after_size.ddl b/tools/test/misc/testfiles/h5clear_equal_after_size.ddl
new file mode 100644
index 0000000..1b9a4e4
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_equal_after_size.ddl
@@ -0,0 +1 @@
+EOA is 1051141; EOF is 1051141
diff --git a/tools/test/misc/testfiles/h5clear_equal_before_size.ddl b/tools/test/misc/testfiles/h5clear_equal_before_size.ddl
new file mode 100644
index 0000000..9beed42
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_equal_before_size.ddl
@@ -0,0 +1 @@
+EOA is 2565; EOF is 2565
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_equal.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_equal.h5
new file mode 100644
index 0000000..0577690
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_equal.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_greater.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_greater.h5
new file mode 100644
index 0000000..6358878
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_greater.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_less.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_less.h5
new file mode 100644
index 0000000..c1f3221
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_less.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_noclose.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_noclose.h5
new file mode 100644
index 0000000..57462db
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_noclose.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_user_equal.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_user_equal.h5
new file mode 100644
index 0000000..5389c41
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_user_equal.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_user_greater.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_user_greater.h5
new file mode 100644
index 0000000..f40e760
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_user_greater.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_user_less.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_user_less.h5
new file mode 100644
index 0000000..55d0cc5
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_user_less.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_greater_after_size.ddl b/tools/test/misc/testfiles/h5clear_greater_after_size.ddl
new file mode 100644
index 0000000..74c8f19
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_greater_after_size.ddl
@@ -0,0 +1 @@
+EOA is 3048; EOF is 3048
diff --git a/tools/test/misc/testfiles/h5clear_greater_before_size.ddl b/tools/test/misc/testfiles/h5clear_greater_before_size.ddl
new file mode 100644
index 0000000..03b22fb
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_greater_before_size.ddl
@@ -0,0 +1 @@
+EOA is 3048; EOF is 2565
diff --git a/tools/test/misc/testfiles/h5clear_less_after_size.ddl b/tools/test/misc/testfiles/h5clear_less_after_size.ddl
new file mode 100644
index 0000000..bedf0d2
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_less_after_size.ddl
@@ -0,0 +1 @@
+EOA is 2765; EOF is 2765
diff --git a/tools/test/misc/testfiles/h5clear_less_before_size.ddl b/tools/test/misc/testfiles/h5clear_less_before_size.ddl
new file mode 100644
index 0000000..50ba4c4
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_less_before_size.ddl
@@ -0,0 +1 @@
+EOA is 512; EOF is 2565
diff --git a/tools/test/misc/testfiles/h5clear_log_v3.h5 b/tools/test/misc/testfiles/h5clear_log_v3.h5
new file mode 100644
index 0000000..aed33a4
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_log_v3.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_mdc_image.h5 b/tools/test/misc/testfiles/h5clear_mdc_image.h5
new file mode 100644
index 0000000..6ed8b70
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_mdc_image.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_missing_file.ddl b/tools/test/misc/testfiles/h5clear_missing_file.ddl
new file mode 100644
index 0000000..c4d21c9
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_missing_file.ddl
@@ -0,0 +1,28 @@
+usage: h5clear [OPTIONS] file_name
+ OPTIONS
+ -h, --help Print a usage message and exit
+ -V, --version Print version number and exit
+ -s, --status Clear the status_flags field in the file's superblock
+ -m, --image Remove the metadata cache image from the file
+ --filesize Print the file's EOA and EOF
+ --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for
+ the file <file_name>.
+ C is >= 0; C is optional and will default to 1M when not set.
+ This option helps to repair a crashed file where the stored EOA
+ in the superblock is different from the actual EOF.
+ The file’s EOA and EOF will be the same after applying
+ this option to the file.
+
+Examples of use:
+
+h5clear -s file_name
+ Clear the status_flags field in the superblock of the HDF5 file <file_name>.
+
+h5clear -m file_name
+ Remove the metadata cache image from the HDF5 file <file_name>.
+
+h5clear --increment file_name
+ Set the EOA to the maximum of (EOA, EOF) + 1M for the file <file_name>.
+
+h5clear --increment=512 file_name
+ Set the EOA to the maximum of (EOA, EOF) + 512 for the file <file_name>.
diff --git a/tools/test/misc/testfiles/h5clear_missing_file.err b/tools/test/misc/testfiles/h5clear_missing_file.err
new file mode 100644
index 0000000..ea21b76
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_missing_file.err
@@ -0,0 +1 @@
+h5clear error: missing file name
diff --git a/tools/test/misc/testfiles/h5clear_no_mdc_image.err b/tools/test/misc/testfiles/h5clear_no_mdc_image.err
new file mode 100644
index 0000000..f5acd71
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_no_mdc_image.err
@@ -0,0 +1 @@
+h5clear warning: No cache image in the file
diff --git a/tools/test/misc/testfiles/h5clear_noclose_after_size.ddl b/tools/test/misc/testfiles/h5clear_noclose_after_size.ddl
new file mode 100644
index 0000000..7846b47
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_noclose_after_size.ddl
@@ -0,0 +1 @@
+EOA is 2448; EOF is 2448
diff --git a/tools/test/misc/testfiles/h5clear_noclose_before_size.ddl b/tools/test/misc/testfiles/h5clear_noclose_before_size.ddl
new file mode 100644
index 0000000..f294a6d
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_noclose_before_size.ddl
@@ -0,0 +1 @@
+EOA is 2048; EOF is 2448
diff --git a/tools/test/misc/testfiles/h5clear_open_fail.err b/tools/test/misc/testfiles/h5clear_open_fail.err
new file mode 100644
index 0000000..895ecd4
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_open_fail.err
@@ -0,0 +1 @@
+h5clear error: h5tools_fopen
diff --git a/tools/test/misc/testfiles/h5clear_sec2_v0.h5 b/tools/test/misc/testfiles/h5clear_sec2_v0.h5
new file mode 100644
index 0000000..571fd46
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_sec2_v0.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_sec2_v2.h5 b/tools/test/misc/testfiles/h5clear_sec2_v2.h5
new file mode 100644
index 0000000..92833e6
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_sec2_v2.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_sec2_v3.h5 b/tools/test/misc/testfiles/h5clear_sec2_v3.h5
new file mode 100644
index 0000000..9f1e6ce
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_sec2_v3.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_status_noclose.h5 b/tools/test/misc/testfiles/h5clear_status_noclose.h5
new file mode 100644
index 0000000..94a950d
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_status_noclose.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_status_noclose_after_size.ddl b/tools/test/misc/testfiles/h5clear_status_noclose_after_size.ddl
new file mode 100644
index 0000000..7846b47
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_status_noclose_after_size.ddl
@@ -0,0 +1 @@
+EOA is 2448; EOF is 2448
diff --git a/tools/test/misc/testfiles/h5clear_usage.ddl b/tools/test/misc/testfiles/h5clear_usage.ddl
new file mode 100644
index 0000000..c4d21c9
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_usage.ddl
@@ -0,0 +1,28 @@
+usage: h5clear [OPTIONS] file_name
+ OPTIONS
+ -h, --help Print a usage message and exit
+ -V, --version Print version number and exit
+ -s, --status Clear the status_flags field in the file's superblock
+ -m, --image Remove the metadata cache image from the file
+ --filesize Print the file's EOA and EOF
+ --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for
+ the file <file_name>.
+ C is >= 0; C is optional and will default to 1M when not set.
+ This option helps to repair a crashed file where the stored EOA
+ in the superblock is different from the actual EOF.
+ The file’s EOA and EOF will be the same after applying
+ this option to the file.
+
+Examples of use:
+
+h5clear -s file_name
+ Clear the status_flags field in the superblock of the HDF5 file <file_name>.
+
+h5clear -m file_name
+ Remove the metadata cache image from the HDF5 file <file_name>.
+
+h5clear --increment file_name
+ Set the EOA to the maximum of (EOA, EOF) + 1M for the file <file_name>.
+
+h5clear --increment=512 file_name
+ Set the EOA to the maximum of (EOA, EOF) + 512 for the file <file_name>.
diff --git a/tools/test/misc/testfiles/h5clear_user_equal_after_size.ddl b/tools/test/misc/testfiles/h5clear_user_equal_after_size.ddl
new file mode 100644
index 0000000..028e134
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_user_equal_after_size.ddl
@@ -0,0 +1 @@
+EOA is 1051653; EOF is 1051653
diff --git a/tools/test/misc/testfiles/h5clear_user_equal_before_size.ddl b/tools/test/misc/testfiles/h5clear_user_equal_before_size.ddl
new file mode 100644
index 0000000..ef7c391
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_user_equal_before_size.ddl
@@ -0,0 +1 @@
+EOA is 3077; EOF is 3077
diff --git a/tools/test/misc/testfiles/h5clear_user_greater_after_size.ddl b/tools/test/misc/testfiles/h5clear_user_greater_after_size.ddl
new file mode 100644
index 0000000..9d7de6f
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_user_greater_after_size.ddl
@@ -0,0 +1 @@
+EOA is 4000; EOF is 4000
diff --git a/tools/test/misc/testfiles/h5clear_user_greater_before_size.ddl b/tools/test/misc/testfiles/h5clear_user_greater_before_size.ddl
new file mode 100644
index 0000000..c3fe625
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_user_greater_before_size.ddl
@@ -0,0 +1 @@
+EOA is 4000; EOF is 3077
diff --git a/tools/test/misc/testfiles/h5clear_user_less_after_size.ddl b/tools/test/misc/testfiles/h5clear_user_less_after_size.ddl
new file mode 100644
index 0000000..02c0d2a
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_user_less_after_size.ddl
@@ -0,0 +1 @@
+EOA is 3277; EOF is 3277
diff --git a/tools/test/misc/testfiles/h5clear_user_less_before_size.ddl b/tools/test/misc/testfiles/h5clear_user_less_before_size.ddl
new file mode 100644
index 0000000..0651c2b
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_user_less_before_size.ddl
@@ -0,0 +1 @@
+EOA is 3000; EOF is 3077
diff --git a/tools/test/misc/testfiles/h5mkgrp_help.txt b/tools/test/misc/testfiles/h5mkgrp_help.txt
new file mode 100644
index 0000000..5d81b34
--- /dev/null
+++ b/tools/test/misc/testfiles/h5mkgrp_help.txt
@@ -0,0 +1,20 @@
+usage: h5mkgrp [OPTIONS] FILE GROUP...
+ OPTIONS
+ -h, --help Print a usage message and exit
+ -l, --latest Use latest version of file format to create groups
+ -p, --parents No error if existing, make parent groups as needed
+ -v, --verbose Print information about OBJECTS and OPTIONS
+ -V, --version Print version number and exit
+ --vol-value Value (ID) of the VOL connector to use for opening the
+ HDF5 file specified
+ --vol-name Name of the VOL connector to use for opening the
+ HDF5 file specified
+ --vol-info VOL-specific info to pass to the VOL connector used for
+ opening the HDF5 file specified
+ --vfd-value Value (ID) of the VFL driver to use for opening the
+ HDF5 file specified
+ --vfd-name Name of the VFL driver to use for opening the
+ HDF5 file specified
+ --vfd-info VFD-specific info to pass to the VFL driver used for
+ opening the HDF5 file specified
+
diff --git a/tools/test/misc/testfiles/h5mkgrp_version.txt.in b/tools/test/misc/testfiles/h5mkgrp_version.txt.in
new file mode 100644
index 0000000..37dbabd
--- /dev/null
+++ b/tools/test/misc/testfiles/h5mkgrp_version.txt.in
@@ -0,0 +1 @@
+h5mkgrp: Version @HDF5_RELEASE_VERSION_STRING@
diff --git a/tools/test/misc/testfiles/latest_h5clear_log_v3.h5 b/tools/test/misc/testfiles/latest_h5clear_log_v3.h5
new file mode 100644
index 0000000..da5c426
--- /dev/null
+++ b/tools/test/misc/testfiles/latest_h5clear_log_v3.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/latest_h5clear_sec2_v3.h5 b/tools/test/misc/testfiles/latest_h5clear_sec2_v3.h5
new file mode 100644
index 0000000..e511248
--- /dev/null
+++ b/tools/test/misc/testfiles/latest_h5clear_sec2_v3.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/mod_h5clear_mdc_image.h5 b/tools/test/misc/testfiles/mod_h5clear_mdc_image.h5
new file mode 100644
index 0000000..310134b
--- /dev/null
+++ b/tools/test/misc/testfiles/mod_h5clear_mdc_image.h5
Binary files differ
diff --git a/tools/test/misc/testh5clear.sh.in b/tools/test/misc/testh5clear.sh.in
new file mode 100644
index 0000000..018d1fd
--- /dev/null
+++ b/tools/test/misc/testh5clear.sh.in
@@ -0,0 +1,459 @@
+#! /bin/sh
+#
+# Copyright by The HDF Group.
+# All rights reserved.
+#
+# This file is part of HDF5. The full HDF5 copyright notice, including
+# terms governing use, modification, and redistribution, is contained in
+# the COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://www.hdfgroup.org/licenses.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
+#
+# Tests for the h5clear tool
+#
+srcdir=@srcdir@
+TESTNAME=h5clear
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+
+H5CLEAR=../../src/misc/h5clear # The tool name
+H5CLEAR_BIN=`pwd`/$H5CLEAR # The path of the tool binary
+
+OPENCHK=clear_open_chk # Program to check whether the file can be opened
+OPENCHK_BIN=`pwd`/$OPENCHK # The path to the binary
+
+RM='rm -rf'
+CMP='cmp -s'
+DIFF='diff -c'
+CP='cp'
+DIRNAME='dirname'
+LS='ls'
+AWK='awk'
+
+SUCCEED=0
+FAIL=1
+
+nerrors=0
+verbose=yes
+
+# source dirs
+SRC_TOOLS="$srcdir/../.."
+
+SRC_TOOLS_TESTFILES="$SRC_TOOLS/testfiles"
+# testfiles source dirs for tools
+SRC_H5CLEAR_TESTFILES="$SRC_TOOLS/test/misc/testfiles"
+
+TESTDIR=./testh5clear
+test -d $TESTDIR || mkdir -p $TESTDIR
+
+######################################################################
+# test files
+# --------------------------------------------------------------------
+# All the test files copy from source directory to test directory
+# NOTE: Keep this framework to add/remove test files.
+# Any test files from other tools can be used in this framework.
+# This list are also used for checking exist.
+# Comment '#' without space can be used.
+# --------------------------------------------------------------------
+
+#
+# copy test files and expected output files from source dirs to test dir
+#
+COPY_TESTFILES="
+$SRC_H5CLEAR_TESTFILES/h5clear_open_fail.err
+$SRC_H5CLEAR_TESTFILES/h5clear_no_mdc_image.err
+$SRC_H5CLEAR_TESTFILES/h5clear_usage.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_missing_file.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_status_noclose_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_noclose_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_noclose_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_equal_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_equal_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_greater_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_greater_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_less_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_less_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_user_equal_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_user_equal_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_user_greater_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_user_greater_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_user_less_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_user_less_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_sec2_v0.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_sec2_v2.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_sec2_v3.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_log_v3.h5
+$SRC_H5CLEAR_TESTFILES/latest_h5clear_log_v3.h5
+$SRC_H5CLEAR_TESTFILES/latest_h5clear_sec2_v3.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_mdc_image.h5
+$SRC_H5CLEAR_TESTFILES/mod_h5clear_mdc_image.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_status_noclose.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_noclose.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_equal.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_greater.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_less.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_user_equal.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_user_greater.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_user_less.h5
+"
+
+COPY_TESTFILES_TO_TESTDIR()
+{
+ # copy test files. Used -f to make sure get a new copy
+ for tstfile in $COPY_TESTFILES
+ do
+ # ignore '#' comment
+ echo $tstfile | tr -d ' ' | grep '^#' > /dev/null
+ RET=$?
+ if [ $RET -eq 1 ]; then
+ # skip cp if srcdir is same as destdir
+ # this occurs when build/test performed in source dir and
+ # make cp fail
+ SDIR=`$DIRNAME $tstfile`
+ INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
+ INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
+ if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
+ $CP -f $tstfile $TESTDIR
+ if [ $? -ne 0 ]; then
+ echo "Error: FAILED to copy $tstfile ."
+
+ # Comment out this to CREATE expected file
+ exit $EXIT_FAILURE
+ fi
+ fi
+ fi
+ done
+}
+
+CLEAN_TESTFILES_AND_TESTDIR()
+{
+ # skip rm if srcdir is same as destdir
+ # this occurs when build/test performed in source dir and
+ # make cp fail
+ SDIR=$SRC_H5CLEAR_TESTFILES
+ INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
+ INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
+ if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
+ $RM $TESTDIR
+ fi
+}
+
+#
+#
+# Print a line-line message left justified in a field of 70 characters
+# beginning with the word "Testing".
+#
+TESTING() {
+ SPACES=" "
+ echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012'
+}
+
+# $1 is the expected output
+# $2 is the output from testing
+COMPARE_OUT() {
+ if $CMP $1 $2; then
+ echo "PASSED"
+ else
+ echo "*FAILED*"
+ echo " Expected result (*.ddl) differs from actual result (*.out)"
+ nerrors="`expr $nerrors + 1`"
+ test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /'
+ fi
+}
+
+#
+#
+#
+# Run h5clear and verify the expected output
+# $1: the test file name
+# $2: option 1 passed to the tool
+# $3: option 2 passed to the tool
+# $4: the expected output
+TOOLTEST_OUT() {
+ fname=$1
+ option1=$2
+ option2=$3
+ option3=$4
+ expected=$5
+ # Prepare expected and actual output
+ expect="$TESTDIR/$expected"
+ expect_err="$TESTDIR/`basename $expected .ddl`.err"
+ actual="$TESTDIR/`basename $expected .ddl`.out"
+ actual_err="$TESTDIR/`basename $expected .ddl`.out.err"
+ actual_sav=${actual}-sav
+ actual_err_sav=${actual_err}-sav
+
+ # Run test.
+ TESTING $H5CLEAR $option1 $option2 $option3 $option4 $fname
+ (
+ cd $TESTDIR
+ $RUNSERIAL $H5CLEAR_BIN $option1 $option2 $option3 $option4 $fname
+ ) >$actual 2>$actual_err
+ cp $actual $actual_sav
+ cp $actual_err $actual_err_sav
+
+ # Compare output
+ COMPARE_OUT $expect $actual
+
+ # Clean up output file
+ if test -z "$HDF5_NOCLEANUP"; then
+ $RM $actual $actual_err $actual_sav $actual_err_sav
+ fi
+}
+# same as TOOLTEST_OUT just compare stderr
+TOOLTEST_ERR() {
+ fname=$1
+ option1=$2
+ option2=$3
+ option3=$4
+ expected=$5
+ # Prepare expected and actual output
+ expect_err="$TESTDIR/$expected"
+ expect="$TESTDIR/`basename $expected .err`.ddl"
+ actual="$TESTDIR/`basename $expected .err`.out"
+ actual_err="$TESTDIR/`basename $expected .err`.out.err"
+ actual_sav=${actual}-sav
+ actual_err_sav=${actual_err}-sav
+
+ # Run test.
+ TESTING $H5CLEAR $option1 $option2 $option3 $option4 $fname
+ (
+ cd $TESTDIR
+ $RUNSERIAL $H5CLEAR_BIN $option1 $option2 $option3 $option4 $fname
+ ) >$actual 2>$actual_err
+ cp $actual $actual_sav
+ cp $actual_err $actual_err_sav
+
+ # Compare output
+ COMPARE_OUT $expect_err $actual_err
+
+ # Clean up output file
+ if test -z "$HDF5_NOCLEANUP"; then
+ $RM $actual $actual_err $actual_sav $actual_err_sav
+ fi
+}
+
+# $1 is the filename to open
+# $2 is the expected return from the open/check program
+OPEN_CHK() {
+ fname=$1
+ expected=$2
+ (
+ cd $TESTDIR
+ $OPENCHK_BIN $fname 2>/dev/null
+ )
+ actual=$?
+ if test $actual -ne $expected; then
+ echo "Unexpected return from $OPENCHK"
+ nerrors=`expr $nerrors + 1`
+ fi
+}
+
+# Run h5clear and verify the expected exit code
+# $1 is the filename to open
+# $2 is option 1
+# $3 is option 2
+# $4 is the expected exit code from the tool
+TOOLTEST() {
+ fname=$1
+ option1=$2
+ option2=$3
+ ret_expected=$4
+ #
+ TESTING $H5CLEAR $option1 $option2 $fname
+ # h5clear $option1 $option2 $fname
+ (
+ cd $TESTDIR
+ $RUNSERIAL $H5CLEAR_BIN $option1 $option2 $fname 2>/dev/null 1>/dev/null
+ )
+ if test $? -ne $ret_expected; then
+ echo "*FAILED*"
+ nerrors=`expr $nerrors + 1`
+ else
+ echo "PASSED"
+ fi
+}
+
+##############################################################################
+##############################################################################
+### T H E T E S T S ###
+##############################################################################
+##############################################################################
+# prepare for testing
+COPY_TESTFILES_TO_TESTDIR
+# For Cmake
+$CP -f $TESTDIR/h5clear_sec2_v0.h5 $TESTDIR/orig_h5clear_sec2_v0.h5
+$CP -f $TESTDIR/h5clear_sec2_v2.h5 $TESTDIR/orig_h5clear_sec2_v2.h5
+$CP -f $TESTDIR/h5clear_sec2_v3.h5 $TESTDIR/orig_h5clear_sec2_v3.h5
+#
+#
+#
+# The following are tests to verify the expected output from h5clear
+# "h5clear -h"
+# "h5clear" (no options, no file)
+# "h5clear junk.h5" (no options, nonexisting file)
+# "h5clear orig_h5clear_sec2_v3.h5" (no options, existing file)
+# "h5clear -m" (valid 1 option, no file)
+# "h5clear -s junk.h5" (valid 1 option, nonexisting file)
+# "h5clear -m -s" (valid 2 options, no file)
+# "h5clear -m -s junk.h5" (valid 2 options, nonexisting file)
+# "h5clear -m orig_h5clear_sec2_v2.h5" (valid 1 option, existing file, no cache image)
+# "h5clear -s -m orig_h5clear_sec2_v0.h5" (valid 2 options, existing file, no cache image)
+TOOLTEST_OUT "" -h "" "" h5clear_usage.ddl
+TOOLTEST_OUT "" "" "" "" h5clear_usage.ddl
+TOOLTEST_OUT junk.h5 "" "" "" h5clear_usage.ddl
+TOOLTEST_OUT orig_h5clear_sec2_v3.h5 "" "" "" h5clear_usage.ddl
+TOOLTEST_OUT "" -m "" "" h5clear_missing_file.ddl
+TOOLTEST_ERR junk.h5 -s "" "" h5clear_open_fail.err
+TOOLTEST_OUT "" -m -s "" h5clear_missing_file.ddl
+TOOLTEST_ERR junk.h5 -m -s "" h5clear_open_fail.err
+TOOLTEST_ERR orig_h5clear_sec2_v2.h5 -m "" "" h5clear_no_mdc_image.err
+TOOLTEST_ERR orig_h5clear_sec2_v0.h5 -s -m "" h5clear_no_mdc_image.err
+#
+#
+# The following are tests to verify the expected exit code from h5clear:
+# "h5clear -m h5clear_mdc_image.h5" (valid option, existing file, succeed exit code)
+# "h5clear --version" (valid option, version #, succeed exit code)
+# "h5clear -k" (invalid 1 option, no file, fail exit code)
+# "h5clear -k junk.h5" (invalid 1 option, nonexisting file, fail exit code)
+# "h5clear -l h5clear_sec2_v2.h5" (invalid 1 option, existing file, fail exit code)
+# "h5clear -m -k" (valid/invalid 2 options, nofile, fail exit code)
+# "h5clear -l -m" (invalid/valid 2 options, nofile, fail exit code)
+# "h5clear -m -l junk.h5" (valid/invalid 2 options, nonexisting file, fail exit code)
+# "h5clear -l -m junk.h5" (invalid/valid 2 options, nonexisting file, fail exit code)
+# "h5clear -m -l h5clear_sec2_v0.h5" (valid/invalid 2 options, existing file, fail exit code)
+# "h5clear -l -m h5clear_sec2_v0.h5" (invalid/valid 2 options, existing file, fail exit code)
+TOOLTEST h5clear_mdc_image.h5 -m "" $SUCCEED
+TOOLTEST "" --version "" $SUCCEED
+TOOLTEST "" -k "" $FAIL
+TOOLTEST junk.h5 -k "" $FAIL
+TOOLTEST h5clear_sec2_v2.h5 -l "" $FAIL
+TOOLTEST "" -m -k $FAIL
+TOOLTEST "" -l -m $FAIL
+TOOLTEST junk.h5 -m -l $FAIL
+TOOLTEST junk.h5 -l -m $FAIL
+TOOLTEST h5clear_sec2_v0.h5 -m -l $FAIL
+TOOLTEST h5clear_sec2_v0.h5 -l -m $FAIL
+#
+#
+#
+# h5clear_mdc_image.h5 already has cache image removed earlier, verify the expected warning from h5clear:
+TOOLTEST_ERR mod_h5clear_mdc_image.h5 -m "" "" h5clear_no_mdc_image.err
+TOOLTEST_ERR mod_h5clear_mdc_image.h5 -s -m "" h5clear_no_mdc_image.err
+#
+#
+#
+# The following are tests to verify the status_flags field is cleared properly:
+OPEN_CHK h5clear_sec2_v3.h5 $FAIL
+TOOLTEST h5clear_sec2_v3.h5 -s "" $SUCCEED
+OPEN_CHK h5clear_sec2_v3.h5 $SUCCEED
+#
+OPEN_CHK h5clear_log_v3.h5 $FAIL
+TOOLTEST h5clear_log_v3.h5 -s "" $SUCCEED
+OPEN_CHK h5clear_log_v3.h5 $SUCCEED
+#
+OPEN_CHK latest_h5clear_sec2_v3.h5 $FAIL
+TOOLTEST latest_h5clear_sec2_v3.h5 -s "" $SUCCEED
+OPEN_CHK latest_h5clear_sec2_v3.h5 $SUCCEED
+#
+OPEN_CHK latest_h5clear_log_v3.h5 $FAIL
+TOOLTEST latest_h5clear_log_v3.h5 -s "" $SUCCEED
+OPEN_CHK latest_h5clear_log_v3.h5 $SUCCEED
+#
+# File open succeeds for the following 2 test files because the
+# library does not check status_flags for files with < v3 superblock:
+OPEN_CHK h5clear_sec2_v0.h5 $SUCCEED
+TOOLTEST h5clear_sec2_v0.h5 -s "" $SUCCEED
+OPEN_CHK h5clear_sec2_v0.h5 $SUCCEED
+#
+OPEN_CHK h5clear_sec2_v2.h5 $SUCCEED
+TOOLTEST h5clear_sec2_v2.h5 -s "" $SUCCEED
+OPEN_CHK h5clear_sec2_v2.h5 $SUCCEED
+#
+#
+#
+# (1) h5clear_status_noclose.h5
+# "h5clear --filesize h5clear_status_noclose.h5" (unable to open the file because status_flag is on)
+# "h5clear -s --increment=0 h5clear_status_noclose.h5" (clear status_flag, EOA = MAX(EOA, EOF) + 0)
+# (no output, check exit code)
+# "h5clear --filesize h5clear_status_noclose_user.h5" (print EOA/EOF after the last action)
+TOOLTEST_ERR h5clear_status_noclose.h5 --filesize "" "" h5clear_open_fail.err
+TOOLTEST h5clear_status_noclose.h5 -s --increment=0 $SUCCEED
+TOOLTEST_OUT h5clear_status_noclose.h5 --filesize "" "" h5clear_status_noclose_after_size.ddl
+#
+# (2) h5clear_fsm_persist_noclose.h5
+# "h5clear --filesize h5clear_fsm_persist_noclose.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_noclose.h5" (EOA = MAX(EOA, EOF)) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_noclose.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_noclose.h5 --filesize "" "" h5clear_noclose_before_size.ddl
+TOOLTEST h5clear_fsm_persist_noclose.h5 --increment=0 "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_noclose.h5 --filesize "" "" h5clear_noclose_after_size.ddl
+#
+# (3) h5clear_fsm_persist_equal.h5
+# "h5clear --filesize h5clear_fsm_persist_equal.h5" (print EOA/EOF before the next action)
+# "h5clear --increment h5clear_fsm_persist_equal.h5" (EOA = MAX(EOA, EOF) + 1M) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_equal.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_equal.h5 --filesize "" "" h5clear_equal_before_size.ddl
+TOOLTEST h5clear_fsm_persist_equal.h5 --increment "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_equal.h5 --filesize "" "" h5clear_equal_after_size.ddl
+#
+# (4) h5clear_fsm_persist_greater.h5
+# "h5clear --filesize h5clear_fsm_persist_greater.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_greater.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_greater.h5 --filesize "" "" h5clear_greater_before_size.ddl
+TOOLTEST h5clear_fsm_persist_greater.h5 --increment=0 "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_greater.h5 --filesize "" "" h5clear_greater_after_size.ddl
+#
+# (5) h5clear_fsm_persist_less.h5
+# "h5clear --filesize h5clear_fsm_persist_less.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=200 h5clear_fsm_persist_less.h5" (EOA = MAX(EOA, EOF) + 200) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_less.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_less.h5 --filesize "" "" h5clear_less_before_size.ddl
+TOOLTEST h5clear_fsm_persist_less.h5 --increment=200 "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_less.h5 --filesize "" "" h5clear_less_after_size.ddl
+#
+# (6) h5clear_fsm_persist_user_equal.h5
+# "h5clear --filesize h5clear_fsm_persist_user_equal.h5" (print EOA/EOF before the next action)
+# "h5clear --increment h5clear_fsm_persist_user_equal.h5" (EOA = MAX(EOA, EOF) + 1M) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_user_equal.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_user_equal.h5 --filesize "" "" h5clear_user_equal_before_size.ddl
+TOOLTEST h5clear_fsm_persist_user_equal.h5 --increment "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_user_equal.h5 --filesize "" "" h5clear_user_equal_after_size.ddl
+#
+# (7) h5clear_fsm_persist_user_greater.h5
+# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_user_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_user_greater.h5 --filesize "" "" h5clear_user_greater_before_size.ddl
+TOOLTEST h5clear_fsm_persist_user_greater.h5 --increment=0 "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_user_greater.h5 --filesize "" "" h5clear_user_greater_after_size.ddl
+#
+# (8) h5clear_fsm_persist_user_less.h5
+# "h5clear --filesize h5clear_fsm_persist_user_less.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=200 h5clear_fsm_persist_user_less.h5" (EOA = MAX(EOA, EOF) + 200) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_user_less.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_user_less.h5 --filesize "" "" h5clear_user_less_before_size.ddl
+TOOLTEST h5clear_fsm_persist_user_less.h5 --increment=200 "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_user_less.h5 --filesize "" "" h5clear_user_less_after_size.ddl
+#
+#
+#
+# Clean up test files
+if test -z "$HDF5_NOCLEANUP"; then
+ rm -f h5clear_*.h5 latest_h5clear*.h5
+fi
+#
+#
+#
+# Clean up temporary files/directories
+CLEAN_TESTFILES_AND_TESTDIR
+
+if test $nerrors -eq 0 ; then
+ echo "All $TESTNAME tests passed."
+ exit $EXIT_SUCCESS
+else
+ echo "$TESTNAME tests failed with $nerrors error(s)."
+ exit $EXIT_FAILURE
+fi
diff --git a/tools/test/misc/testh5mkgrp.sh.in b/tools/test/misc/testh5mkgrp.sh.in
new file mode 100644
index 0000000..aae5c3a
--- /dev/null
+++ b/tools/test/misc/testh5mkgrp.sh.in
@@ -0,0 +1,324 @@
+#! /bin/sh
+#
+# Copyright by The HDF Group.
+# All rights reserved.
+#
+# This file is part of HDF5. The full HDF5 copyright notice, including
+# terms governing use, modification, and redistribution, is contained in
+# the COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://www.hdfgroup.org/licenses.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
+#
+# Tests for the h5mkgrp tool
+#
+# Quincey Koziol
+# Tuesday, February 13, 2007
+#
+
+srcdir=@srcdir@
+
+TESTNAME=h5mkgrp
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+
+H5MKGRP=../../src/misc/h5mkgrp # The tool name
+H5MKGRP_BIN=`pwd`/$H5MKGRP # The path of the tool binary
+H5LS=../../src/h5ls/h5ls # The h5ls tool name
+H5LS_ARGS=-vr # Arguments to the h5ls tool
+H5LS_BIN=`pwd`/$H5LS # The path of the h5ls tool binary
+
+RM='rm -rf'
+CMP='cmp -s'
+DIFF='diff -c'
+CP='cp'
+DIRNAME='dirname'
+LS='ls'
+AWK='awk'
+
+nerrors=0
+verbose=yes
+
+# source dirs
+SRC_TOOLS="$srcdir/../.."
+
+SRC_TOOLS_TESTFILES="$SRC_TOOLS/testfiles"
+# testfiles source dirs for tools
+SRC_H5MKGRP_TESTFILES="$SRC_TOOLS/test/misc/testfiles"
+
+TESTDIR=./testgrp
+test -d $TESTDIR || mkdir -p $TESTDIR
+
+######################################################################
+# test files
+# --------------------------------------------------------------------
+# All the test files copy from source directory to test directory
+# NOTE: Keep this framework to add/remove test files.
+# Any test files from other tools can be used in this framework.
+# This list are also used for checking exist.
+# Comment '#' without space can be used.
+# --------------------------------------------------------------------
+
+#
+# copy test files and expected output files from source dirs to test dir
+#
+COPY_TESTFILES="
+$SRC_H5MKGRP_TESTFILES/h5mkgrp_help.txt
+$SRC_TOOLS_TESTFILES/h5mkgrp_single.ls
+$SRC_TOOLS_TESTFILES/h5mkgrp_single_v.ls
+$SRC_TOOLS_TESTFILES/h5mkgrp_single_p.ls
+$SRC_TOOLS_TESTFILES/h5mkgrp_single_l.ls
+$SRC_TOOLS_TESTFILES/h5mkgrp_several.ls
+$SRC_TOOLS_TESTFILES/h5mkgrp_several_v.ls
+$SRC_TOOLS_TESTFILES/h5mkgrp_several_p.ls
+$SRC_TOOLS_TESTFILES/h5mkgrp_several_l.ls
+$SRC_TOOLS_TESTFILES/h5mkgrp_nested_p.ls
+$SRC_TOOLS_TESTFILES/h5mkgrp_nested_lp.ls
+$SRC_TOOLS_TESTFILES/h5mkgrp_nested_mult_p.ls
+$SRC_TOOLS_TESTFILES/h5mkgrp_nested_mult_lp.ls
+"
+
+COPY_TESTFILES_TO_TESTDIR()
+{
+ # copy test files. Used -f to make sure get a new copy
+ for tstfile in $COPY_TESTFILES
+ do
+ # ignore '#' comment
+ echo $tstfile | tr -d ' ' | grep '^#' > /dev/null
+ RET=$?
+ if [ $RET -eq 1 ]; then
+ # skip cp if srcdir is same as destdir
+ # this occurs when build/test performed in source dir and
+ # make cp fail
+ SDIR=`$DIRNAME $tstfile`
+ INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
+ INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
+ if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
+ $CP -f $tstfile $TESTDIR
+ if [ $? -ne 0 ]; then
+ echo "Error: FAILED to copy $tstfile ."
+
+ # Comment out this to CREATE expected file
+ exit $EXIT_FAILURE
+ fi
+ fi
+ fi
+ done
+}
+
+CLEAN_TESTFILES_AND_TESTDIR()
+{
+ # skip rm if srcdir is same as destdir
+ # this occurs when build/test performed in source dir and
+ # make cp fail
+ SDIR=$SRC_H5MKGRP_TESTFILES
+ INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
+ INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
+ if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
+ $RM $TESTDIR
+ fi
+}
+
+# Print a line-line message left justified in a field of 70 characters
+# beginning with the word "Testing".
+TESTING()
+{
+ SPACES=" "
+ echo "Testing $* $SPACES" |cut -c1-70 |tr -d '\012'
+}
+
+# Source in the output filter function definitions.
+. $srcdir/../../../bin/output_filter.sh
+
+# Print a line-line message left justified in a field of 70 characters
+# beginning with the word "Verifying".
+#
+VERIFY_H5LS()
+{
+ SPACES=" "
+ echo "Verifying h5ls file structure $* $SPACES" | cut -c1-70 | tr -d '\012'
+}
+
+# Run a test and print PASS or *FAIL*. If h5mkgrp can complete
+# with exit status 0, consider it pass. If a test fails then increment
+# the `nerrors' global variable.
+# Assumed arguments:
+# $* arguments for h5mkgrp.
+
+TOOLTEST()
+{
+ TESTING $H5MKGRP $@
+ (
+ cd $TESTDIR
+ $RUNSERIAL $H5MKGRP_BIN $@
+ ) > output.out
+ RET=$?
+
+ if [ $RET != 0 ]; then
+ echo "*FAILED*"
+ echo "failed result is:"
+ cat output.out
+ nerrors="`expr $nerrors + 1`"
+ else
+ echo " PASSED"
+
+ # Clean up output file
+ if test -z "$HDF5_NOCLEANUP"; then
+ rm -f output.out
+ fi
+ fi
+}
+
+# Call the h5ls tool to verify the correct output data in the destination file
+#
+H5LSTEST()
+{
+ expect="$TESTDIR/`basename $1 .h5`.ls"
+ actual="$TESTDIR/`basename $1 .h5`.out"
+ actual_sav=${actual}-sav
+
+ # Stderr is included in stdout so that the diff can detect
+ # any unexpected output from that stream too.
+ VERIFY_H5LS $@
+ (
+ cd $TESTDIR
+ $RUNSERIAL $H5LS_BIN $H5LS_ARGS $@
+ ) 2>&1 |sed 's/Modified:.*/Modified: XXXX-XX-XX XX:XX:XX XXX/' >$actual
+
+ # save actual in case it is needed later.
+ cp $actual $actual_sav
+ STDOUT_FILTER $actual
+ STDERR_FILTER $actual
+
+ if [ ! -f $expect ]; then
+ # Create the expect file if it doesn't yet exist.
+ echo " CREATED"
+ cp $actual $expect
+ echo " Expected result (*.ls) missing"
+ nerrors="`expr $nerrors + 1`"
+ elif $CMP $expect $actual; then
+ echo " PASSED"
+ else
+ echo "*FAILED*"
+ echo " Expected result (*.ls) differs from actual result (*.out)"
+ nerrors="`expr $nerrors + 1`"
+ test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /'
+ fi
+
+ # Clean up output file
+ if test -z "$HDF5_NOCLEANUP"; then
+ rm -f $actual $actual_sav
+ fi
+}
+
+# Single run of tool
+#
+# Assumed arguments:
+# $1 is test file name
+# $2 is h5mkgrp options
+# $* are groups to create
+RUNTEST()
+{
+ FILEOUT=$1
+ shift
+ H5MKGRP_ARGS=$1
+ shift
+
+ # Remove any output file left over from previous test run
+ rm -f $FILEOUT
+
+ # Run test
+ TOOLTEST $H5MKGRP_ARGS $FILEOUT $@
+
+ # Verify that the file created above is correct
+ H5LSTEST $FILEOUT
+
+ # Remove output file created, if the "no cleanup" environment variable is
+ # not defined
+ if test -z "$HDF5_NOCLEANUP"; then
+ rm -f $TESTDIR/$FILEOUT
+ fi
+}
+
+# Single run of tool
+#
+# Assumed arguments:
+# $1 is test expected output file
+# $2 is h5mkgrp options
+# $* are groups to create
+CMPTEST()
+{
+ FILEOUT=$1
+ expect="$TESTDIR/`basename $1 .h5`.txt"
+ actual="$TESTDIR/`basename $1 .h5`.out"
+ actual_err="$TESTDIR/`basename $1 .h5`.err"
+ shift
+
+ # Stderr is included in stdout so that the diff can detect
+ # any unexpected output from that stream too.
+ TESTING $H5MKGRP $@
+ (
+ cd $TESTDIR
+ $RUNSERIAL $H5MKGRP_BIN $@
+ ) >$actual 2>$actual_err
+ cat $actual_err >> $actual
+
+ if [ ! -f $expect ]; then
+ # Create the expect file if it doesn't yet exist.
+ echo " CREATED"
+ cp $actual $expect
+ echo " Expected result (*.txt) missing"
+ nerrors="`expr $nerrors + 1`"
+ elif $CMP $expect $actual; then
+ echo " PASSED"
+ else
+ echo "*FAILED*"
+ echo " Expected result (*.txt) differs from actual result (*.out)"
+ nerrors="`expr $nerrors + 1`"
+ test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /'
+ fi
+
+ # Clean up output file
+ if test -z "$HDF5_NOCLEANUP"; then
+ rm -f $actual $actual_err
+ fi
+}
+
+##############################################################################
+### T H E T E S T S ###
+##############################################################################
+# prepare for test
+COPY_TESTFILES_TO_TESTDIR
+
+# Check that help & version is displayed properly
+CMPTEST h5mkgrp_help.h5 "-h"
+#CMPTEST h5mkgrp_version.h5 "-V"
+
+# Create single group at root level
+RUNTEST h5mkgrp_single.h5 " " single
+RUNTEST h5mkgrp_single_v.h5 "-v" single
+RUNTEST h5mkgrp_single_p.h5 "-p" single
+RUNTEST h5mkgrp_single_l.h5 "-l" latest
+
+# Create several groups at root level
+RUNTEST h5mkgrp_several.h5 " " one two
+RUNTEST h5mkgrp_several_v.h5 "-v" one two
+RUNTEST h5mkgrp_several_p.h5 "-p" one two
+RUNTEST h5mkgrp_several_l.h5 "-l" one two
+
+# Create various nested groups
+RUNTEST h5mkgrp_nested_p.h5 "-p" /one/two
+RUNTEST h5mkgrp_nested_lp.h5 "-lp" /one/two
+RUNTEST h5mkgrp_nested_mult_p.h5 "-p" /one/two /three/four
+RUNTEST h5mkgrp_nested_mult_lp.h5 "-lp" /one/two /three/four
+
+# Clean up temporary files/directories
+CLEAN_TESTFILES_AND_TESTDIR
+
+if test $nerrors -eq 0 ; then
+ echo "All $TESTNAME tests passed."
+ exit $EXIT_SUCCESS
+else
+ echo "$TESTNAME tests failed with $nerrors errors."
+ exit $EXIT_FAILURE
+fi
diff --git a/tools/test/misc/testh5repart.sh.in b/tools/test/misc/testh5repart.sh.in
new file mode 100644
index 0000000..b0d52f6
--- /dev/null
+++ b/tools/test/misc/testh5repart.sh.in
@@ -0,0 +1,196 @@
+#! /bin/sh
+#
+# Copyright by The HDF Group.
+# All rights reserved.
+#
+# This file is part of HDF5. The full HDF5 copyright notice, including
+# terms governing use, modification, and redistribution, is contained in
+# the COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://www.hdfgroup.org/licenses.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
+#
+# Tests for the h5repart tool
+
+srcdir=@srcdir@
+
+TESTNAME=h5repart
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+
+REPART=../../src/misc/h5repart # The tool name
+REPART_BIN=`pwd`/$REPART # The path of the tool binary
+
+REPARTED_FAM=repart_test # The test name
+REPARTED_FAM_BIN=`pwd`/$REPARTED_FAM # The path of the test binary
+
+RM='rm -rf'
+CMP='cmp -s'
+DIFF='diff -c'
+CP='cp'
+DIRNAME='dirname'
+LS='ls'
+AWK='awk'
+
+nerrors=0
+verbose=yes
+
+# source dirs
+SRC_TOOLS="$srcdir/../.."
+
+SRC_TOOLS_TESTFILES="$SRC_TOOLS/testfiles"
+
+TESTDIR=./testrepart
+test -d $TESTDIR || mkdir -p $TESTDIR
+
+#
+# copy test files and expected output files from source dirs to test dir
+#
+COPY_TESTFILES="
+$SRC_TOOLS_TESTFILES/family_file00000.h5
+$SRC_TOOLS_TESTFILES/family_file00001.h5
+$SRC_TOOLS_TESTFILES/family_file00002.h5
+$SRC_TOOLS_TESTFILES/family_file00003.h5
+$SRC_TOOLS_TESTFILES/family_file00004.h5
+$SRC_TOOLS_TESTFILES/family_file00005.h5
+$SRC_TOOLS_TESTFILES/family_file00006.h5
+$SRC_TOOLS_TESTFILES/family_file00007.h5
+$SRC_TOOLS_TESTFILES/family_file00008.h5
+$SRC_TOOLS_TESTFILES/family_file00009.h5
+$SRC_TOOLS_TESTFILES/family_file00010.h5
+$SRC_TOOLS_TESTFILES/family_file00011.h5
+$SRC_TOOLS_TESTFILES/family_file00012.h5
+$SRC_TOOLS_TESTFILES/family_file00013.h5
+$SRC_TOOLS_TESTFILES/family_file00014.h5
+$SRC_TOOLS_TESTFILES/family_file00015.h5
+$SRC_TOOLS_TESTFILES/family_file00016.h5
+$SRC_TOOLS_TESTFILES/family_file00017.h5
+"
+
+COPY_TESTFILES_TO_TESTDIR()
+{
+ # copy test files. Used -f to make sure get a new copy
+ for tstfile in $COPY_TESTFILES
+ do
+ # ignore '#' comment
+ echo $tstfile | tr -d ' ' | grep '^#' > /dev/null
+ RET=$?
+ if [ $RET -eq 1 ]; then
+ # skip cp if srcdir is same as destdir
+ # this occurs when build/test performed in source dir and
+ # make cp fail
+ SDIR=`$DIRNAME $tstfile`
+ INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
+ INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
+ if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
+ $CP -f $tstfile $TESTDIR
+ if [ $? -ne 0 ]; then
+ echo "Error: FAILED to copy $tstfile ."
+
+ # Comment out this to CREATE expected file
+ exit $EXIT_FAILURE
+ fi
+ fi
+ fi
+ done
+}
+
+CLEAN_TESTFILES_AND_TESTDIR()
+{
+ # skip rm if srcdir is same as destdir
+ # this occurs when build/test performed in source dir and
+ # make cp fail
+ SDIR=$SRC_TOOLS_TESTFILES
+ INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'`
+ INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'`
+ if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then
+ $RM $TESTDIR
+ fi
+}
+
+# Print a line-line message left justified in a field of 70 characters
+# beginning with the word "Testing".
+#
+TESTING() {
+ SPACES=" "
+ echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012'
+}
+
+# Run a test and print PASS or *FAIL*. If a test fails then increment
+# the `nerrors' global variable.
+#
+TOOLTEST() {
+ # Run tool test.
+ TESTING $REPART $@
+ (
+# echo
+ cd $TESTDIR
+ $RUNSERIAL $REPART_BIN $@
+ )
+
+ if test $? -eq 0; then
+ echo " PASSED"
+ else
+ echo " FAILED"
+ nerrors=`expr $nerrors + 1`
+ fi
+}
+
+OUTPUTTEST() {
+ # Run test program.
+ TESTING $REPARTED_FAM $@
+ (
+ cd $TESTDIR
+ $RUNSERIAL $REPARTED_FAM_BIN $@
+ )
+
+ if test $? -eq 0; then
+ echo " PASSED"
+ else
+ echo " FAILED"
+ nerrors=`expr $nerrors + 1`
+ fi
+}
+
+# Print a "SKIP" message
+SKIP() {
+ TESTING $REPART $@
+ echo " -SKIP-"
+}
+
+##############################################################################
+##############################################################################
+### T H E T E S T S ###
+##############################################################################
+##############################################################################
+# prepare for test
+COPY_TESTFILES_TO_TESTDIR
+
+# repartition family member size to 20,000 bytes.
+TOOLTEST -m 20000 family_file%05d.h5 fst_family%05d.h5
+# repartition family member size to 5 KB.
+TOOLTEST -m 5k family_file%05d.h5 scd_family%05d.h5
+# convert family file to single file of 20,000 bytes
+TOOLTEST -m 20000 -family_to_single family_file%05d.h5 family_to_single.h5
+# convert family file to single file of 20,000 bytes (old argument)
+TOOLTEST -m 20000 -family_to_sec2 family_file%05d.h5 family_to_sec2.h5
+
+# test the output files repartitioned above.
+OUTPUTTEST
+echo
+
+# Clean up output file
+CLEAN_TESTFILES_AND_TESTDIR
+
+if test -z "$HDF5_NOCLEANUP"; then
+ cd $actual_dir
+ rm -f fst_family*.h5 scd_family*.h5 family_to_single.h5 family_to_sec2.h5
+fi
+
+if test $nerrors -eq 0 ; then
+ echo "All $TESTNAME tests passed."
+ exit $EXIT_SUCCESS
+else
+ echo "$TESTNAME tests failed with $nerrors errors."
+ exit $EXIT_FAILURE
+fi
diff --git a/tools/test/misc/vds/CMakeLists.txt b/tools/test/misc/vds/CMakeLists.txt
new file mode 100644
index 0000000..a459098
--- /dev/null
+++ b/tools/test/misc/vds/CMakeLists.txt
@@ -0,0 +1,35 @@
+cmake_minimum_required (VERSION 3.18)
+project (HDF5_TOOLS_TEST_MISC_VDS C)
+
+macro (ADD_H5_GENERATOR genfile)
+ add_executable (${genfile} ${HDF5_TOOLS_TEST_MISC_VDS_SOURCE_DIR}/${genfile}.c)
+ target_include_directories (${genfile} PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ if (NOT ONLY_SHARED_LIBS)
+ TARGET_C_PROPERTIES (${genfile} STATIC)
+ target_link_libraries (${genfile} PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
+ else ()
+ TARGET_C_PROPERTIES (${genfile} SHARED)
+ target_link_libraries (${genfile} PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
+ endif ()
+ set_target_properties (${genfile} PROPERTIES FOLDER generator/tools)
+
+ #-----------------------------------------------------------------------------
+ # Add Target to clang-format
+ #-----------------------------------------------------------------------------
+ if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_TOOLS_TEST_MISC_VDS_${genfile}_FORMAT ${genfile})
+ endif ()
+endmacro ()
+
+# generator executables
+set (H5_GENERATORS
+ UC_1_one_dim_gen
+ UC_2_two_dims_gen
+ UC_3_gaps_gen
+ UC_4_printf_gen
+ UC_5_stride_gen
+)
+
+foreach (gen ${H5_GENERATORS})
+ ADD_H5_GENERATOR (${gen})
+endforeach ()
diff --git a/tools/test/misc/vds/Makefile.am b/tools/test/misc/vds/Makefile.am
new file mode 100644
index 0000000..f2cc259
--- /dev/null
+++ b/tools/test/misc/vds/Makefile.am
@@ -0,0 +1,35 @@
+#
+# Copyright by The HDF Group.
+# All rights reserved.
+#
+# This file is part of HDF5. The full HDF5 copyright notice, including
+# terms governing use, modification, and redistribution, is contained in
+# the COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://www.hdfgroup.org/licenses.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
+##
+## Makefile.am
+## Run automake to generate a Makefile.in from this file.
+#
+# HDF5 Library Makefile(.in)
+#
+
+include $(top_srcdir)/config/commence.am
+
+# Include src directory
+AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib -I$(top_srcdir)/tools/test/misc/vds
+
+#test scripts and programs
+TEST_PROG=UC_1_one_dim_gen UC_2_two_dims_gen UC_3_gaps_gen UC_4_printf_gen \
+ UC_5_stride_gen
+
+check_PROGRAMS=$(TEST_PROG)
+
+# Temporary files.
+CHECK_CLEANFILES+=*.h5
+
+# All programs rely on hdf5 library and h5tools library
+LDADD=$(LIBH5TOOLS) $(LIBHDF5)
+
+include $(top_srcdir)/config/conclude.am
diff --git a/tools/test/misc/vds/UC_1.h b/tools/test/misc/vds/UC_1.h
new file mode 100644
index 0000000..a7046ff
--- /dev/null
+++ b/tools/test/misc/vds/UC_1.h
@@ -0,0 +1,101 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#ifndef UC_1_H
+#define UC_1_H
+
+#include "hdf5.h"
+
+#include "UC_common.h"
+
+/*
+ * Definitions for VDS use case 1
+ *
+ * Datasets have a single unlimited dimension and two fixed dimensions. They
+ * are mapped along a single dimension in the VDS with no gaps between them.
+ */
+
+/* virtual dataset <---> source dataset mapping and sizes
+
+ ***************** --+
+ * A * K
+ ***************** --+
+ * * |
+ * B * N
+ * * |
+ ***************** --+
+ * C *
+ *****************
+ * *
+ * D *
+ * *
+ *****************
+ * E *
+ *****************
+ * *
+ * F *
+ * *
+ *****************
+
+ | |
+ +-------M-------+
+
+
+ dim[0]
+ /
+ /
+ /
+ -----> dim[2]
+ |
+ |
+ |
+ dim[1]
+
+ */
+
+#define UC_1_N_SOURCES 6
+
+/* Dataset dimensions */
+#define UC_1_SM_HEIGHT 2 /* K */
+#define UC_1_LG_HEIGHT 4 /* N */
+#define UC_1_SM_LG_HEIGHT 6 /* SM_HEIGHT + LG_HEIGHT */
+#define UC_1_FULL_HEIGHT 18 /* (3 * K) + (3 * N) */
+#define UC_1_HALF_HEIGHT 9
+#define UC_1_WIDTH 8 /* M */
+#define UC_1_HALF_WIDTH 4
+
+#define UC_1_N_MAX_PLANES H5S_UNLIMITED /* max number of planes */
+#define UC_1_N_TEST_PLANES 5 /* number of planes we write */
+
+/* Dataset datatypes */
+#define UC_1_SOURCE_DATATYPE H5T_STD_I32LE
+#define UC_1_VDS_DATATYPE H5T_STD_I32LE
+
+/* Starting size of datasets, both source and VDS */
+static hsize_t UC_1_DIMS[UC_1_N_SOURCES][RANK] = {
+ {0, UC_1_SM_HEIGHT, UC_1_WIDTH}, {0, UC_1_LG_HEIGHT, UC_1_WIDTH}, {0, UC_1_SM_HEIGHT, UC_1_WIDTH},
+ {0, UC_1_LG_HEIGHT, UC_1_WIDTH}, {0, UC_1_SM_HEIGHT, UC_1_WIDTH}, {0, UC_1_LG_HEIGHT, UC_1_WIDTH}};
+
+/* Maximum size of datasets, both source and VDS */
+static hsize_t UC_1_MAX_DIMS[UC_1_N_SOURCES][RANK] = {
+ {UC_1_N_MAX_PLANES, UC_1_SM_HEIGHT, UC_1_WIDTH}, {UC_1_N_MAX_PLANES, UC_1_LG_HEIGHT, UC_1_WIDTH},
+ {UC_1_N_MAX_PLANES, UC_1_SM_HEIGHT, UC_1_WIDTH}, {UC_1_N_MAX_PLANES, UC_1_LG_HEIGHT, UC_1_WIDTH},
+ {UC_1_N_MAX_PLANES, UC_1_SM_HEIGHT, UC_1_WIDTH}, {UC_1_N_MAX_PLANES, UC_1_LG_HEIGHT, UC_1_WIDTH}};
+
+/* File names for source datasets */
+static char UC_1_FILE_NAMES[UC_1_N_SOURCES][NAME_LEN] = {{"1_a.h5"}, {"1_b.h5"}, {"1_c.h5"},
+ {"1_d.h5"}, {"1_e.h5"}, {"1_f.h5"}};
+
+/* Dataset names */
+static char UC_1_SOURCE_DSET_PATH[NAME_LEN] = "/source_dset";
+
+#endif /* UC_1_H */
diff --git a/tools/test/misc/vds/UC_1_one_dim_gen.c b/tools/test/misc/vds/UC_1_one_dim_gen.c
new file mode 100644
index 0000000..56b257d
--- /dev/null
+++ b/tools/test/misc/vds/UC_1_one_dim_gen.c
@@ -0,0 +1,243 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * File/dataset generator for VDS use case 1
+ *
+ * See the header file for a description.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "hdf5.h"
+
+#include "UC_common.h"
+#include "UC_1.h"
+
+static hsize_t UC_1_VDS_DIMS[RANK] = {0, UC_1_FULL_HEIGHT, UC_1_WIDTH};
+static hsize_t UC_1_VDS_MAX_DIMS[RANK] = {UC_1_N_MAX_PLANES, UC_1_FULL_HEIGHT, UC_1_WIDTH};
+
+/* Planes */
+static hsize_t UC_1_PLANES[UC_1_N_SOURCES][RANK] = {
+ {1, UC_1_SM_HEIGHT, UC_1_WIDTH}, {1, UC_1_LG_HEIGHT, UC_1_WIDTH}, {1, UC_1_SM_HEIGHT, UC_1_WIDTH},
+ {1, UC_1_LG_HEIGHT, UC_1_WIDTH}, {1, UC_1_SM_HEIGHT, UC_1_WIDTH}, {1, UC_1_LG_HEIGHT, UC_1_WIDTH}};
+
+/* VDS file name */
+static char UC_1_VDS_FILE_NAME[NAME_LEN] = "1_vds.h5";
+
+/* Dataset names */
+static char UC_1_SOURCE_DSET_NAME[NAME_LEN] = "source_dset";
+static char UC_1_VDS_DSET_NAME[NAME_LEN] = "vds_dset";
+
+/* Fill values */
+static int UC_1_FILL_VALUES[UC_1_N_SOURCES] = {-1, -2, -3, -4, -5, -6};
+static int UC_1_VDS_FILL_VALUE = -9;
+
+int
+main(void)
+{
+ hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */
+ hid_t src_dcplid = H5I_INVALID_HID; /* source dataset property list ID */
+
+ hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */
+ hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */
+
+ hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */
+ hid_t did = H5I_INVALID_HID; /* dataset ID */
+ hid_t msid = H5I_INVALID_HID; /* memory dataspace ID */
+ hid_t fsid = H5I_INVALID_HID; /* file dataspace ID */
+
+ hsize_t extent[RANK]; /* dataset extents */
+ hsize_t start[RANK]; /* starting point for hyperslab */
+ hsize_t map_start = 0; /* starting point in the VDS map */
+
+ int *buffer = NULL; /* data buffer */
+ hsize_t count = 0; /* number of elements in a plane */
+ int n_planes = -1; /* number of planes to write */
+ int value = -1; /* value written to datasets */
+
+ int i; /* iterator */
+ int j; /* iterator */
+ hsize_t k; /* iterator */
+
+ /* Start by creating the virtual dataset (VDS) dataspace and creation
+ * property list. The individual source datasets are then created
+ * and the VDS map (stored in the VDS property list) is updated.
+ */
+
+ /* Create VDS dcpl */
+ if ((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ UC_ERROR
+ if (H5Pset_fill_value(vds_dcplid, UC_1_VDS_DATATYPE, &UC_1_VDS_FILL_VALUE) < 0)
+ UC_ERROR
+
+ /* Create VDS dataspace */
+ if ((vds_sid = H5Screate_simple(RANK, UC_1_VDS_DIMS, UC_1_VDS_MAX_DIMS)) < 0)
+ UC_ERROR
+
+ /************************************
+ * Create source files and datasets *
+ ************************************/
+
+ start[0] = 0;
+ start[1] = 0;
+ start[2] = 0;
+ map_start = 0;
+
+ for (i = 0; i < UC_1_N_SOURCES; i++) {
+
+ /* Create source dataset dcpl */
+ if ((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ UC_ERROR
+ if (H5Pset_chunk(src_dcplid, RANK, UC_1_PLANES[i]) < 0)
+ UC_ERROR
+ if (H5Pset_fill_value(src_dcplid, UC_1_SOURCE_DATATYPE, &UC_1_FILL_VALUES[i]) < 0)
+ UC_ERROR
+ if (0 != i % 2)
+ if (H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0)
+ UC_ERROR
+
+ /* Create source file, dataspace, and dataset */
+ if ((fid = H5Fcreate(UC_1_FILE_NAMES[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ UC_ERROR
+ if ((src_sid = H5Screate_simple(RANK, UC_1_DIMS[i], UC_1_MAX_DIMS[i])) < 0)
+ UC_ERROR
+ if ((did = H5Dcreate2(fid, UC_1_SOURCE_DSET_NAME, UC_1_SOURCE_DATATYPE, src_sid, H5P_DEFAULT,
+ src_dcplid, H5P_DEFAULT)) < 0)
+ UC_ERROR
+
+ /* Set the dataset's extent (will eventually vary with i) */
+ extent[0] = UC_1_N_TEST_PLANES;
+ extent[1] = UC_1_PLANES[i][1];
+ extent[2] = UC_1_PLANES[i][2];
+ if (H5Dset_extent(did, extent) < 0)
+ UC_ERROR
+
+ /* Create a data buffer that represents a plane */
+ count = UC_1_PLANES[i][1] * UC_1_PLANES[i][2];
+ if (NULL == (buffer = (int *)malloc(count * sizeof(int))))
+ UC_ERROR
+
+ /* Create the memory dataspace */
+ if ((msid = H5Screate_simple(RANK, UC_1_PLANES[i], NULL)) < 0)
+ UC_ERROR
+
+ /* Get the file dataspace */
+ if ((fsid = H5Dget_space(did)) < 0)
+ UC_ERROR
+
+ /* Write planes to the dataset, number will eventually vary with i */
+ n_planes = UC_1_N_TEST_PLANES;
+ for (j = 0; j < n_planes; j++) {
+
+ value = ((i + 1) * 10) + j;
+ for (k = 0; k < count; k++)
+ buffer[k] = value;
+
+ start[0] = (hsize_t)j;
+ start[1] = 0;
+ start[2] = 0;
+ if (H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_1_PLANES[i], NULL) < 0)
+ UC_ERROR
+ if (H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0)
+ UC_ERROR
+
+ } /* end for */
+
+ /* set up hyperslabs for source and destination datasets */
+ start[0] = 0;
+ start[1] = 0;
+ start[2] = 0;
+ if (H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, UC_1_MAX_DIMS[i], NULL) < 0)
+ UC_ERROR
+ start[0] = 0;
+ start[1] = map_start;
+ start[2] = 0;
+ if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, start, NULL, UC_1_MAX_DIMS[i], NULL) < 0)
+ UC_ERROR
+ map_start += UC_1_PLANES[i][1];
+
+ /* Add VDS mapping */
+ if (H5Pset_virtual(vds_dcplid, vds_sid, UC_1_FILE_NAMES[i], UC_1_SOURCE_DSET_PATH, src_sid) < 0)
+ UC_ERROR
+
+ /* close */
+ if (H5Sclose(src_sid) < 0)
+ UC_ERROR
+ if (H5Pclose(src_dcplid) < 0)
+ UC_ERROR
+ if (H5Sclose(msid) < 0)
+ UC_ERROR
+ if (H5Sclose(fsid) < 0)
+ UC_ERROR
+ if (H5Dclose(did) < 0)
+ UC_ERROR
+ if (H5Fclose(fid) < 0)
+ UC_ERROR
+ free(buffer);
+
+ } /* end for */
+
+ /*******************
+ * Create VDS file *
+ *******************/
+
+ /* file */
+ if ((fid = H5Fcreate(UC_1_VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ UC_ERROR
+
+ /* dataset */
+ if ((did = H5Dcreate2(fid, UC_1_VDS_DSET_NAME, UC_1_VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid,
+ H5P_DEFAULT)) < 0)
+ UC_ERROR
+
+ /* close */
+ if (H5Pclose(vds_dcplid) < 0)
+ UC_ERROR
+ if (H5Sclose(vds_sid) < 0)
+ UC_ERROR
+ if (H5Dclose(did) < 0)
+ UC_ERROR
+ if (H5Fclose(fid) < 0)
+ UC_ERROR
+
+ return EXIT_SUCCESS;
+
+error:
+
+ H5E_BEGIN_TRY
+ {
+ if (src_sid >= 0)
+ (void)H5Sclose(src_sid);
+ if (src_dcplid >= 0)
+ (void)H5Pclose(src_dcplid);
+ if (vds_sid >= 0)
+ (void)H5Sclose(vds_sid);
+ if (vds_dcplid >= 0)
+ (void)H5Pclose(vds_dcplid);
+ if (fid >= 0)
+ (void)H5Fclose(fid);
+ if (did >= 0)
+ (void)H5Dclose(did);
+ if (msid >= 0)
+ (void)H5Sclose(msid);
+ if (fsid >= 0)
+ (void)H5Sclose(fsid);
+ if (buffer != NULL)
+ free(buffer);
+ }
+ H5E_END_TRY
+
+ return EXIT_FAILURE;
+
+} /* end main */
diff --git a/tools/test/misc/vds/UC_2.h b/tools/test/misc/vds/UC_2.h
new file mode 100644
index 0000000..bf94a32
--- /dev/null
+++ b/tools/test/misc/vds/UC_2.h
@@ -0,0 +1,97 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#ifndef UC_2_H
+#define UC_2_H
+
+#include "hdf5.h"
+
+/*
+ * Definitions for VDS use case 2
+ *
+ * Datasets have a single unlimited dimension and two fixed dimensions. They
+ * are mapped along two dimensions in the VDS with no gaps between them.
+ */
+
+/* virtual dataset <---> source dataset mapping and sizes
+
+ **********************************
+ * A * *
+ ***************** D *
+ * * *
+ * B * *
+ * ******************
+ ***************** E *
+ * C * *
+ **********************************
+
+
+ dim[0]
+ /
+ /
+ /
+ -----> dim[2]
+ |
+ |
+ |
+ dim[1]
+
+ */
+
+#define UC_2_N_SOURCES 5
+
+/* Dataset dimensions */
+#define UC_2_A_HEIGHT 2
+#define UC_2_B_HEIGHT 4
+#define UC_2_AB_HEIGHT 6 /* For hyperslab start position */
+#define UC_2_C_HEIGHT 2
+#define UC_2_D_HEIGHT 5
+#define UC_2_E_HEIGHT 3
+#define UC_2_FULL_HEIGHT 8 /* A+B+C and D+E */
+#define UC_2_WIDTH 7
+#define UC_2_FULL_WIDTH 14 /* 2*width */
+
+#define UC_2_N_PLANES_IN_SERIES 3 /* number of planes in a series of sub-images */
+#define UC_2_N_MAX_PLANES H5S_UNLIMITED /* max number of planes */
+#define UC_2_N_TEST_PLANES 6 /* number of planes we write */
+
+/* Dataset datatypes */
+#define UC_2_SOURCE_DATATYPE H5T_STD_I32LE
+#define UC_2_VDS_DATATYPE H5T_STD_I32LE
+
+/* Starting size of datasets, both source and VDS */
+static hsize_t UC_2_DIMS[UC_2_N_SOURCES][RANK] = {{0, UC_2_A_HEIGHT, UC_2_WIDTH},
+ {0, UC_2_B_HEIGHT, UC_2_WIDTH},
+ {0, UC_2_C_HEIGHT, UC_2_WIDTH},
+ {0, UC_2_D_HEIGHT, UC_2_WIDTH},
+ {0, UC_2_E_HEIGHT, UC_2_WIDTH}};
+
+/* Maximum size of datasets, both source and VDS */
+static hsize_t UC_2_MAX_DIMS[UC_2_N_SOURCES][RANK] = {{UC_2_N_MAX_PLANES, UC_2_A_HEIGHT, UC_2_WIDTH},
+ {UC_2_N_MAX_PLANES, UC_2_B_HEIGHT, UC_2_WIDTH},
+ {UC_2_N_MAX_PLANES, UC_2_C_HEIGHT, UC_2_WIDTH},
+ {UC_2_N_MAX_PLANES, UC_2_D_HEIGHT, UC_2_WIDTH},
+ {UC_2_N_MAX_PLANES, UC_2_E_HEIGHT, UC_2_WIDTH}};
+
+/* File names for source datasets */
+static char UC_2_FILE_NAMES[UC_2_N_SOURCES][NAME_LEN] = {
+ {"2_a.h5"}, {"2_b.h5"}, {"2_c.h5"}, {"2_d.h5"}, {"2_e.h5"}};
+
+/* VDS file name */
+#define UC_2_VDS_FILE_NAME "2_vds.h5"
+
+/* Dataset names */
+#define UC_2_SOURCE_DSET_NAME "source_dset"
+#define UC_2_SOURCE_DSET_PATH "/source_dset"
+#define UC_2_VDS_DSET_NAME "vds_dset"
+
+#endif /* UC_2_H */
diff --git a/tools/test/misc/vds/UC_2_two_dims_gen.c b/tools/test/misc/vds/UC_2_two_dims_gen.c
new file mode 100644
index 0000000..05488c4
--- /dev/null
+++ b/tools/test/misc/vds/UC_2_two_dims_gen.c
@@ -0,0 +1,245 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * File/dataset generator for VDS use case 2
+ *
+ * See the header file for a description.
+ */
+
+#include <stdlib.h>
+
+#include "hdf5.h"
+
+#include "UC_common.h"
+#include "UC_2.h"
+
+static hsize_t UC_2_VDS_DIMS[RANK] = {0, UC_2_FULL_HEIGHT, UC_2_FULL_WIDTH};
+static hsize_t UC_2_VDS_MAX_DIMS[RANK] = {UC_2_N_MAX_PLANES, UC_2_FULL_HEIGHT, UC_2_FULL_WIDTH};
+
+/* Positions of source datasets in the VDS */
+static hsize_t UC_2_POSITIONS[UC_2_N_SOURCES][RANK] = {
+ /* A */ {0, 0, 0},
+ /* B */ {0, UC_2_A_HEIGHT, 0},
+ /* C */ {0, UC_2_AB_HEIGHT, 0},
+ /* D */ {0, 0, UC_2_WIDTH},
+ /* E */ {0, UC_2_D_HEIGHT, UC_2_WIDTH}};
+
+/* Planes */
+static hsize_t UC_2_PLANES[UC_2_N_SOURCES][RANK] = {{1, UC_2_A_HEIGHT, UC_2_WIDTH},
+ {1, UC_2_B_HEIGHT, UC_2_WIDTH},
+ {1, UC_2_C_HEIGHT, UC_2_WIDTH},
+ {1, UC_2_D_HEIGHT, UC_2_WIDTH},
+ {1, UC_2_E_HEIGHT, UC_2_WIDTH}};
+
+/* Chunk dimensions */
+static hsize_t UC_2_CHUNK_DIMS[UC_2_N_SOURCES][RANK] = {{UC_2_N_PLANES_IN_SERIES, UC_2_A_HEIGHT, UC_2_WIDTH},
+ {UC_2_N_PLANES_IN_SERIES, UC_2_B_HEIGHT, UC_2_WIDTH},
+ {UC_2_N_PLANES_IN_SERIES, UC_2_C_HEIGHT, UC_2_WIDTH},
+ {UC_2_N_PLANES_IN_SERIES, UC_2_D_HEIGHT, UC_2_WIDTH},
+ {UC_2_N_PLANES_IN_SERIES, UC_2_E_HEIGHT, UC_2_WIDTH}};
+
+/* Fill values */
+static int UC_2_FILL_VALUES[UC_2_N_SOURCES] = {-1, -2, -3, -4, -5};
+static int UC_2_VDS_FILL_VALUE = -9;
+
+int
+main(void)
+{
+ hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */
+ hid_t src_dcplid = H5I_INVALID_HID; /* source dataset property list ID */
+
+ hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */
+ hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */
+
+ hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */
+ hid_t did = H5I_INVALID_HID; /* dataset ID */
+ hid_t msid = H5I_INVALID_HID; /* memory dataspace ID */
+ hid_t fsid = H5I_INVALID_HID; /* file dataspace ID */
+
+ hsize_t start[RANK]; /* starting point for hyperslab */
+ hsize_t extent[RANK]; /* dataset extents */
+
+ int *buffer = NULL; /* data buffer */
+ int value = -1; /* value written to datasets */
+ hsize_t count = 0; /* number of elements in a plane */
+ int n_planes = -1; /* number of planes to write */
+
+ int i; /* iterator */
+ int j; /* iterator */
+ hsize_t k; /* iterator */
+
+ /* Start by creating the virtual dataset (VDS) dataspace and creation
+ * property list. The individual source datasets are then created
+ * and the VDS map (stored in the VDS property list) is updated.
+ */
+
+ /* Create VDS dcpl */
+ if ((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ UC_ERROR
+ if (H5Pset_fill_value(vds_dcplid, UC_2_VDS_DATATYPE, &UC_2_VDS_FILL_VALUE) < 0)
+ UC_ERROR
+
+ /* Create VDS dataspace */
+ if ((vds_sid = H5Screate_simple(RANK, UC_2_VDS_DIMS, UC_2_VDS_MAX_DIMS)) < 0)
+ UC_ERROR
+
+ /************************************
+ * Create source files and datasets *
+ ************************************/
+
+ start[0] = 0;
+ start[1] = 0;
+ start[2] = 0;
+
+ for (i = 0; i < UC_2_N_SOURCES; i++) {
+
+ /* source dataset dcpl */
+ if ((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ UC_ERROR
+ if (H5Pset_chunk(src_dcplid, RANK, UC_2_CHUNK_DIMS[i]) < 0)
+ UC_ERROR
+ if (H5Pset_fill_value(src_dcplid, UC_2_SOURCE_DATATYPE, &UC_2_FILL_VALUES[i]) < 0)
+ UC_ERROR
+ if (H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0)
+ UC_ERROR
+
+ /* Create source file, dataspace, and dataset */
+ if ((fid = H5Fcreate(UC_2_FILE_NAMES[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ UC_ERROR
+ if ((src_sid = H5Screate_simple(RANK, UC_2_DIMS[i], UC_2_MAX_DIMS[i])) < 0)
+ UC_ERROR
+ if ((did = H5Dcreate2(fid, UC_2_SOURCE_DSET_NAME, UC_2_SOURCE_DATATYPE, src_sid, H5P_DEFAULT,
+ src_dcplid, H5P_DEFAULT)) < 0)
+ UC_ERROR
+
+ /* Set the dataset's extent (will eventually vary with i) */
+ extent[0] = UC_2_N_TEST_PLANES;
+ extent[1] = UC_2_PLANES[i][1];
+ extent[2] = UC_2_PLANES[i][2];
+ if (H5Dset_extent(did, extent) < 0)
+ UC_ERROR
+
+ /* Create a data buffer that represents a plane */
+ count = UC_2_PLANES[i][1] * UC_2_PLANES[i][2];
+ if (NULL == (buffer = (int *)malloc(count * sizeof(int))))
+ UC_ERROR
+
+ /* Create the memory dataspace */
+ if ((msid = H5Screate_simple(RANK, UC_2_PLANES[i], NULL)) < 0)
+ UC_ERROR
+
+ /* Get the file dataspace */
+ if ((fsid = H5Dget_space(did)) < 0)
+ UC_ERROR
+
+ /* Write planes to the dataset, number will eventually vary with i */
+ n_planes = UC_2_N_TEST_PLANES;
+ for (j = 0; j < n_planes; j++) {
+
+ value = ((i + 1) * 10) + j;
+ for (k = 0; k < count; k++)
+ buffer[k] = value;
+
+ start[0] = (hsize_t)j;
+ start[1] = 0;
+ start[2] = 0;
+ if (H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_2_PLANES[i], NULL) < 0)
+ UC_ERROR
+ if (H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0)
+ UC_ERROR
+
+ } /* end for */
+
+ /* set up hyperslabs for source and destination datasets */
+ start[0] = 0;
+ start[1] = 0;
+ start[2] = 0;
+ if (H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, UC_2_MAX_DIMS[i], NULL) < 0)
+ UC_ERROR
+ if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, UC_2_POSITIONS[i], NULL, UC_2_MAX_DIMS[i], NULL) < 0)
+ UC_ERROR
+
+ /* Add VDS mapping */
+ if (H5Pset_virtual(vds_dcplid, vds_sid, UC_2_FILE_NAMES[i], UC_2_SOURCE_DSET_PATH, src_sid) < 0)
+ UC_ERROR
+
+ /* close */
+ if (H5Sclose(msid) < 0)
+ UC_ERROR
+ if (H5Sclose(fsid) < 0)
+ UC_ERROR
+ if (H5Sclose(src_sid) < 0)
+ UC_ERROR
+ if (H5Pclose(src_dcplid) < 0)
+ UC_ERROR
+ if (H5Dclose(did) < 0)
+ UC_ERROR
+ if (H5Fclose(fid) < 0)
+ UC_ERROR
+ free(buffer);
+
+ } /* end for */
+
+ /*******************************
+ * Create VDS file and dataset *
+ *******************************/
+
+ /* file */
+ if ((fid = H5Fcreate(UC_2_VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ UC_ERROR
+
+ /* dataset */
+ if ((did = H5Dcreate2(fid, UC_2_VDS_DSET_NAME, UC_2_VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid,
+ H5P_DEFAULT)) < 0)
+ UC_ERROR
+
+ /* close */
+ if (H5Pclose(vds_dcplid) < 0)
+ UC_ERROR
+ if (H5Sclose(vds_sid) < 0)
+ UC_ERROR
+ if (H5Dclose(did) < 0)
+ UC_ERROR
+ if (H5Fclose(fid) < 0)
+ UC_ERROR
+
+ return EXIT_SUCCESS;
+
+error:
+
+ H5E_BEGIN_TRY
+ {
+ if (src_sid >= 0)
+ (void)H5Sclose(src_sid);
+ if (src_dcplid >= 0)
+ (void)H5Pclose(src_dcplid);
+ if (vds_sid >= 0)
+ (void)H5Sclose(vds_sid);
+ if (vds_dcplid >= 0)
+ (void)H5Pclose(vds_dcplid);
+ if (fid >= 0)
+ (void)H5Fclose(fid);
+ if (did >= 0)
+ (void)H5Dclose(did);
+ if (msid >= 0)
+ (void)H5Sclose(msid);
+ if (fsid >= 0)
+ (void)H5Sclose(fsid);
+ if (buffer != NULL)
+ free(buffer);
+ }
+ H5E_END_TRY
+
+ return EXIT_FAILURE;
+
+} /* end main() */
diff --git a/tools/test/misc/vds/UC_3.h b/tools/test/misc/vds/UC_3.h
new file mode 100644
index 0000000..ea3df96
--- /dev/null
+++ b/tools/test/misc/vds/UC_3.h
@@ -0,0 +1,69 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#ifndef UC_3_H
+#define UC_3_H
+
+#include "hdf5.h"
+
+#include "UC_1.h"
+#include "UC_2.h"
+
+/*
+ * Definitions for VDS use case 3
+ *
+ * Datasets have a single unlimited dimension and one or two fixed
+ * dimensions (they are reused from use cases 1 and 2). In this use case,
+ * the datasets are mapped in the VDS with gaps between them.
+ */
+
+/* VDS dimensions
+ * Height and width are large enough to encompass the
+ * mapped source datasets with gaps.
+ */
+#define UC_31_VDS_HEIGHT 25 /* full height + 7 (gaps of 1) */
+#define UC_31_VDS_WIDTH 8 /* full width + 0 (no gaps) */
+#define UC_32_VDS_HEIGHT 13 /* full height + 5 */
+#define UC_32_VDS_WIDTH 19 /* full width + 5 */
+#define UC_31_GAP 1
+
+/* VDS datatypes */
+#define UC_31_VDS_DATATYPE H5T_STD_I32LE
+#define UC_32_VDS_DATATYPE H5T_STD_I32LE
+
+/* Starting size of virtual datasets */
+static hsize_t UC_31_VDS_DIMS[RANK] = {0, UC_31_VDS_HEIGHT, UC_31_VDS_WIDTH};
+static hsize_t UC_32_VDS_DIMS[RANK] = {0, UC_32_VDS_HEIGHT, UC_32_VDS_WIDTH};
+
+/* Maximum size of virtual datasets */
+static hsize_t UC_31_VDS_MAX_DIMS[RANK] = {UC_1_N_MAX_PLANES, UC_31_VDS_HEIGHT, UC_31_VDS_WIDTH};
+static hsize_t UC_32_VDS_MAX_DIMS[RANK] = {UC_2_N_MAX_PLANES, UC_32_VDS_HEIGHT, UC_32_VDS_WIDTH};
+
+/* Positions of mapped source datasets */
+static hsize_t UC_32_POSITIONS[UC_2_N_SOURCES][RANK] = {
+ /* A */ {0, 1, 1},
+ /* B */ {0, 4, 0},
+ /* C */ {0, 11, 4},
+ /* D */ {0, 1, 9},
+ /* E */ {0, 8, 12}};
+
+/* VDS file names */
+#define UC_31_VDS_FILE_NAME "3_1_vds.h5"
+#define UC_32_VDS_FILE_NAME "3_2_vds.h5"
+
+/* Dataset name */
+#define UC_3_VDS_DSET_NAME "vds_dset"
+
+/* Fill value */
+static int UC_3_VDS_FILL_VALUE = -9;
+
+#endif /* UC_3_H */
diff --git a/tools/test/misc/vds/UC_3_gaps_gen.c b/tools/test/misc/vds/UC_3_gaps_gen.c
new file mode 100644
index 0000000..33840dc
--- /dev/null
+++ b/tools/test/misc/vds/UC_3_gaps_gen.c
@@ -0,0 +1,242 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * File/dataset generator for VDS use case 3
+ *
+ * See the header file for a description.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <hdf5.h>
+
+#include "UC_common.h"
+#include "UC_3.h"
+
+/* Create the VDS that uses use case 1 files */
+static herr_t
+create_3_1_vds(void)
+{
+ hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */
+ hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */
+ hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */
+
+ hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */
+ hid_t did = H5I_INVALID_HID; /* dataset ID */
+
+ hsize_t start[RANK]; /* source starting point for hyperslab */
+ hsize_t position[RANK]; /* vds mapping positions */
+
+ int i; /* iterator */
+
+ /* Create VDS dcpl */
+ if ((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ UC_ERROR
+ if (H5Pset_fill_value(vds_dcplid, UC_31_VDS_DATATYPE, &UC_3_VDS_FILL_VALUE) < 0)
+ UC_ERROR
+
+ /* Create VDS dataspace */
+ if ((vds_sid = H5Screate_simple(RANK, UC_31_VDS_DIMS, UC_31_VDS_MAX_DIMS)) < 0)
+ UC_ERROR
+
+ /* Set starting positions */
+ start[0] = 0;
+ start[1] = 0;
+ start[2] = 0;
+
+ position[0] = 0;
+ position[1] = UC_31_GAP;
+ position[2] = 0;
+
+ /******************************
+ * Create source-VDS mappings *
+ ******************************/
+ for (i = 0; i < UC_1_N_SOURCES; i++) {
+
+ if ((src_sid = H5Screate_simple(RANK, UC_1_DIMS[i], UC_1_MAX_DIMS[i])) < 0)
+ UC_ERROR
+
+ /* set up hyperslabs for source and destination datasets */
+ if (H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, UC_1_MAX_DIMS[i], NULL) < 0)
+ UC_ERROR
+ if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, position, NULL, UC_1_MAX_DIMS[i], NULL) < 0)
+ UC_ERROR
+ position[1] += UC_1_DIMS[i][1] + UC_31_GAP;
+
+ /* Add VDS mapping */
+ if (H5Pset_virtual(vds_dcplid, vds_sid, UC_1_FILE_NAMES[i], UC_1_SOURCE_DSET_PATH, src_sid) < 0)
+ UC_ERROR
+ if (H5Sclose(src_sid) < 0)
+ UC_ERROR
+
+ } /* end for */
+
+ /*******************************
+ * Create VDS file and dataset *
+ *******************************/
+
+ /* file */
+ if ((fid = H5Fcreate(UC_31_VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ UC_ERROR
+
+ /* dataset */
+ if ((did = H5Dcreate2(fid, UC_3_VDS_DSET_NAME, UC_31_VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid,
+ H5P_DEFAULT)) < 0)
+ UC_ERROR
+
+ /* close */
+ if (H5Pclose(vds_dcplid) < 0)
+ UC_ERROR
+ if (H5Sclose(vds_sid) < 0)
+ UC_ERROR
+ if (H5Dclose(did) < 0)
+ UC_ERROR
+ if (H5Fclose(fid) < 0)
+ UC_ERROR
+
+ return 0;
+
+error:
+
+ H5E_BEGIN_TRY
+ {
+ if (vds_sid >= 0)
+ (void)H5Sclose(vds_sid);
+ if (vds_dcplid >= 0)
+ (void)H5Pclose(vds_dcplid);
+ if (fid >= 0)
+ (void)H5Fclose(fid);
+ if (did >= 0)
+ (void)H5Dclose(did);
+ }
+ H5E_END_TRY
+
+ return -1;
+
+} /* end create_3_1_vds() */
+
+/* Create the VDS that uses use case 2 files */
+static herr_t
+create_3_2_vds(void)
+{
+ hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */
+ hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */
+ hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */
+
+ hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */
+ hid_t did = H5I_INVALID_HID; /* dataset ID */
+
+ hsize_t start[RANK]; /* source starting point for hyperslab */
+
+ int i; /* iterator */
+
+ /* Create VDS dcpl */
+ if ((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ UC_ERROR
+ if (H5Pset_fill_value(vds_dcplid, UC_32_VDS_DATATYPE, &UC_3_VDS_FILL_VALUE) < 0)
+ UC_ERROR
+
+ /* Create VDS dataspace */
+ if ((vds_sid = H5Screate_simple(RANK, UC_32_VDS_DIMS, UC_32_VDS_MAX_DIMS)) < 0)
+ UC_ERROR
+
+ /* Set starting positions */
+ start[0] = 0;
+ start[1] = 0;
+ start[2] = 0;
+
+ /******************************
+ * Create source-VDS mappings *
+ ******************************/
+ for (i = 0; i < UC_2_N_SOURCES; i++) {
+
+ if ((src_sid = H5Screate_simple(RANK, UC_2_DIMS[i], UC_2_MAX_DIMS[i])) < 0)
+ UC_ERROR
+
+ /* set up hyperslabs for source and destination datasets */
+ if (H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, UC_2_MAX_DIMS[i], NULL) < 0)
+ UC_ERROR
+ if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, UC_32_POSITIONS[i], NULL, UC_2_MAX_DIMS[i], NULL) <
+ 0)
+ UC_ERROR
+
+ /* Add VDS mapping */
+ if (H5Pset_virtual(vds_dcplid, vds_sid, UC_2_FILE_NAMES[i], UC_2_SOURCE_DSET_PATH, src_sid) < 0)
+ UC_ERROR
+ if (H5Sclose(src_sid) < 0)
+ UC_ERROR
+
+ } /* end for */
+
+ /*******************************
+ * Create VDS file and dataset *
+ *******************************/
+
+ /* file */
+ if ((fid = H5Fcreate(UC_32_VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ UC_ERROR
+
+ /* dataset */
+ if ((did = H5Dcreate2(fid, UC_3_VDS_DSET_NAME, UC_32_VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid,
+ H5P_DEFAULT)) < 0)
+ UC_ERROR
+
+ /* close */
+ if (H5Pclose(vds_dcplid) < 0)
+ UC_ERROR
+ if (H5Sclose(vds_sid) < 0)
+ UC_ERROR
+ if (H5Dclose(did) < 0)
+ UC_ERROR
+ if (H5Fclose(fid) < 0)
+ UC_ERROR
+
+ return 0;
+
+error:
+
+ H5E_BEGIN_TRY
+ {
+ if (vds_sid >= 0)
+ (void)H5Sclose(vds_sid);
+ if (vds_dcplid >= 0)
+ (void)H5Pclose(vds_dcplid);
+ if (fid >= 0)
+ (void)H5Fclose(fid);
+ if (did >= 0)
+ (void)H5Dclose(did);
+ }
+ H5E_END_TRY
+
+ return -1;
+
+} /* end create_3_2_vds() */
+
+int
+main(void)
+{
+
+ if (create_3_1_vds() < 0)
+ UC_ERROR
+
+ if (create_3_2_vds() < 0)
+ UC_ERROR
+
+ return EXIT_SUCCESS;
+
+error:
+
+ return EXIT_FAILURE;
+
+} /* end main() */
diff --git a/tools/test/misc/vds/UC_4.h b/tools/test/misc/vds/UC_4.h
new file mode 100644
index 0000000..c469891
--- /dev/null
+++ b/tools/test/misc/vds/UC_4.h
@@ -0,0 +1,73 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#ifndef UC_4_H
+#define UC_4_H
+
+#include "hdf5.h"
+
+#include "UC_common.h"
+
+/*
+ * Definitions for VDS use case 4
+ *
+ * Source datasets have three fixed dimensions. In this use case, the
+ * datasets are mapped consecutively in the VDS along a single dimension with
+ * no gaps between them. Datasets are automatically loaded using a
+ * printf-like format string for the file name.
+ */
+
+/* virtual dataset <---> source dataset mapping and sizes */
+
+#define UC_4_N_SOURCES 3
+
+/* Dataset dimensions */
+#define UC_4_SRC_PLANES 3
+#define UC_4_HEIGHT 4
+#define UC_4_WIDTH 4
+
+/* max number of planes for VDS (sources are finite) */
+#define UC_4_VDS_MAX_PLANES H5S_UNLIMITED
+#define UC_4_N_TEST_PLANES 9 /* number of planes in the VDS */
+
+/* Dataset datatypes */
+#define UC_4_SOURCE_DATATYPE H5T_STD_I32LE
+#define UC_4_VDS_DATATYPE H5T_STD_I32LE
+
+/* Starting size of datasets, both source and VDS */
+static hsize_t UC_4_SOURCE_DIMS[RANK] = {0, UC_4_HEIGHT, UC_4_WIDTH};
+static hsize_t UC_4_VDS_DIMS[RANK] = {0, UC_4_HEIGHT, UC_4_WIDTH};
+
+/* Max size of datasets, both source and VDS */
+static hsize_t UC_4_SOURCE_MAX_DIMS[RANK] = {UC_4_SRC_PLANES, UC_4_HEIGHT, UC_4_WIDTH};
+static hsize_t UC_4_VDS_MAX_DIMS[RANK] = {UC_4_VDS_MAX_PLANES, UC_4_HEIGHT, UC_4_WIDTH};
+
+/* Planes (both source and VDS) */
+static hsize_t UC_4_PLANE[RANK] = {1, UC_4_HEIGHT, UC_4_WIDTH};
+
+/* File names for source datasets */
+static char UC_4_FILE_NAMES[UC_4_N_SOURCES][NAME_LEN] = {{"4_0.h5"}, {"4_1.h5"}, {"4_2.h5"}};
+static char UC_4_MAPPING_FILE_NAME[NAME_LEN] = "4_%b.h5";
+
+/* VDS file name */
+static char UC_4_VDS_FILE_NAME[NAME_LEN] = "4_vds.h5";
+
+/* Dataset names */
+static char UC_4_SOURCE_DSET_NAME[NAME_LEN] = "source_dset";
+static char UC_4_SOURCE_DSET_PATH[NAME_LEN] = "/source_dset";
+static char UC_4_VDS_DSET_NAME[NAME_LEN] = "vds_dset";
+
+/* Fill values */
+static int UC_4_FILL_VALUES[UC_4_N_SOURCES] = {-1, -2, -3};
+static int UC_4_VDS_FILL_VALUE = -9;
+
+#endif /* UC_4_H */
diff --git a/tools/test/misc/vds/UC_4_printf_gen.c b/tools/test/misc/vds/UC_4_printf_gen.c
new file mode 100644
index 0000000..45de2ac
--- /dev/null
+++ b/tools/test/misc/vds/UC_4_printf_gen.c
@@ -0,0 +1,208 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * File/dataset generator for VDS use case 4
+ *
+ * See the header file for a description.
+ */
+
+#include <stdlib.h>
+
+#include <hdf5.h>
+
+#include "UC_common.h"
+#include "UC_4.h"
+
+int
+main(void)
+{
+ hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */
+ hid_t src_dcplid = H5I_INVALID_HID; /* source dataset property list ID */
+
+ hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */
+ hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */
+
+ hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */
+ hid_t did = H5I_INVALID_HID; /* dataset ID */
+ hid_t msid = H5I_INVALID_HID; /* memory dataspace ID */
+ hid_t fsid = H5I_INVALID_HID; /* file dataspace ID */
+
+ /* Hyperslab arrays */
+ hsize_t start[RANK] = {0, 0, 0};
+ hsize_t count[RANK] = {H5S_UNLIMITED, 1, 1};
+
+ int *buffer = NULL; /* data buffer */
+ int value = -1; /* value written to datasets */
+
+ hsize_t n = 0; /* number of elements in a plane */
+
+ int i; /* iterator */
+ int j; /* iterator */
+ hsize_t k; /* iterator */
+
+ /************************************
+ * Create source files and datasets *
+ ************************************/
+
+ /* Create source dataspace ID */
+ if ((src_sid = H5Screate_simple(RANK, UC_4_SOURCE_DIMS, UC_4_SOURCE_MAX_DIMS)) < 0)
+ UC_ERROR
+ if (H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, UC_4_SOURCE_MAX_DIMS, NULL) < 0)
+ UC_ERROR
+
+ /* Create source files and datasets */
+ for (i = 0; i < UC_4_N_SOURCES; i++) {
+
+ /* source dataset dcpl */
+ if ((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ UC_ERROR
+ if (H5Pset_chunk(src_dcplid, RANK, UC_4_PLANE) < 0)
+ UC_ERROR
+ if (H5Pset_fill_value(src_dcplid, UC_4_SOURCE_DATATYPE, &UC_4_FILL_VALUES[i]) < 0)
+ UC_ERROR
+ if (H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0)
+ UC_ERROR
+
+ /* Create source file and dataset */
+ if ((fid = H5Fcreate(UC_4_FILE_NAMES[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ UC_ERROR
+ if ((did = H5Dcreate2(fid, UC_4_SOURCE_DSET_NAME, UC_4_SOURCE_DATATYPE, src_sid, H5P_DEFAULT,
+ src_dcplid, H5P_DEFAULT)) < 0)
+ UC_ERROR
+
+ /* Set the dataset's extent */
+ if (H5Dset_extent(did, UC_4_SOURCE_MAX_DIMS) < 0)
+ UC_ERROR
+
+ /* Create a data buffer that represents a plane */
+ n = UC_4_PLANE[1] * UC_4_PLANE[2];
+ if (NULL == (buffer = (int *)malloc(n * sizeof(int))))
+ UC_ERROR
+
+ /* Create the memory dataspace */
+ if ((msid = H5Screate_simple(RANK, UC_4_PLANE, NULL)) < 0)
+ UC_ERROR
+
+ /* Get the file dataspace */
+ if ((fsid = H5Dget_space(did)) < 0)
+ UC_ERROR
+
+ /* Write planes to the dataset */
+ for (j = 0; j < UC_4_SRC_PLANES; j++) {
+
+ value = ((i + 1) * 10) + j;
+ for (k = 0; k < n; k++)
+ buffer[k] = value;
+
+ start[0] = (hsize_t)j;
+ start[1] = 0;
+ start[2] = 0;
+ if (H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_4_PLANE, NULL) < 0)
+ UC_ERROR
+ if (H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0)
+ UC_ERROR
+
+ } /* end for */
+
+ /* close */
+ if (H5Sclose(msid) < 0)
+ UC_ERROR
+ if (H5Sclose(fsid) < 0)
+ UC_ERROR
+ if (H5Pclose(src_dcplid) < 0)
+ UC_ERROR
+ if (H5Dclose(did) < 0)
+ UC_ERROR
+ if (H5Fclose(fid) < 0)
+ UC_ERROR
+ free(buffer);
+
+ } /* end for */
+
+ /*******************
+ * Create VDS file *
+ *******************/
+
+ /* Create file */
+ if ((fid = H5Fcreate(UC_4_VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ UC_ERROR
+
+ /* Create VDS dcpl */
+ if ((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ UC_ERROR
+ if (H5Pset_fill_value(vds_dcplid, UC_4_VDS_DATATYPE, &UC_4_VDS_FILL_VALUE) < 0)
+ UC_ERROR
+
+ /* Create VDS dataspace */
+ if ((vds_sid = H5Screate_simple(RANK, UC_4_VDS_DIMS, UC_4_VDS_MAX_DIMS)) < 0)
+ UC_ERROR
+ start[0] = 0;
+ start[1] = 0;
+ start[2] = 0;
+ if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, start, UC_4_SOURCE_MAX_DIMS, count,
+ UC_4_SOURCE_MAX_DIMS) < 0)
+ UC_ERROR
+
+ /* Add VDS mapping - The mapped file name uses a printf-like
+ * naming scheme that automatically maps new files.
+ */
+ if (H5Pset_virtual(vds_dcplid, vds_sid, UC_4_MAPPING_FILE_NAME, UC_4_SOURCE_DSET_PATH, src_sid) < 0)
+ UC_ERROR
+
+ /* Create dataset */
+ if ((did = H5Dcreate2(fid, UC_4_VDS_DSET_NAME, UC_4_VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid,
+ H5P_DEFAULT)) < 0)
+ UC_ERROR
+
+ /* close */
+ if (H5Sclose(src_sid) < 0)
+ UC_ERROR
+ if (H5Pclose(vds_dcplid) < 0)
+ UC_ERROR
+ if (H5Sclose(vds_sid) < 0)
+ UC_ERROR
+ if (H5Dclose(did) < 0)
+ UC_ERROR
+ if (H5Fclose(fid) < 0)
+ UC_ERROR
+
+ return EXIT_SUCCESS;
+
+error:
+
+ H5E_BEGIN_TRY
+ {
+ if (src_sid >= 0)
+ (void)H5Sclose(src_sid);
+ if (src_dcplid >= 0)
+ (void)H5Pclose(src_dcplid);
+ if (vds_sid >= 0)
+ (void)H5Sclose(vds_sid);
+ if (vds_dcplid >= 0)
+ (void)H5Pclose(vds_dcplid);
+ if (fid >= 0)
+ (void)H5Fclose(fid);
+ if (did >= 0)
+ (void)H5Dclose(did);
+ if (msid >= 0)
+ (void)H5Sclose(msid);
+ if (fsid >= 0)
+ (void)H5Sclose(fsid);
+ if (buffer != NULL)
+ free(buffer);
+ }
+ H5E_END_TRY
+
+ return EXIT_FAILURE;
+
+} /* end main() */
diff --git a/tools/test/misc/vds/UC_5.h b/tools/test/misc/vds/UC_5.h
new file mode 100644
index 0000000..5654455
--- /dev/null
+++ b/tools/test/misc/vds/UC_5.h
@@ -0,0 +1,71 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#ifndef UC_5_H
+#define UC_5_H
+
+#include <hdf5.h>
+
+#include "UC_common.h"
+
+/*
+ * Definitions for VDS use case 5
+ *
+ * Source datasets have one unlimited dimension and two fixed dimensions. In
+ * this use case, the datasets are mapped in the VDS so that alternating
+ * planes in the source are interleaved in the VDS.
+ */
+
+/* virtual dataset <---> source dataset mapping and sizes */
+
+#define UC_5_N_SOURCES 3
+
+/* Dataset dimensions */
+#define UC_5_SRC_PLANES 3
+#define UC_5_HEIGHT 4
+#define UC_5_WIDTH 4
+
+/* max number of planes for datasets */
+#define UC_5_MAX_PLANES H5S_UNLIMITED
+#define UC_5_N_TEST_PLANES 9 /* number of planes in VDS */
+
+/* Dataset datatypes */
+#define UC_5_SOURCE_DATATYPE H5T_STD_I32LE
+#define UC_5_VDS_DATATYPE H5T_STD_I32LE
+
+/* Starting size of datasets, both source and VDS */
+static hsize_t UC_5_SOURCE_DIMS[RANK] = {0, UC_5_HEIGHT, UC_5_WIDTH};
+static hsize_t UC_5_VDS_DIMS[RANK] = {0, UC_5_HEIGHT, UC_5_WIDTH};
+
+/* Max size of datasets, both source and VDS */
+static hsize_t UC_5_SOURCE_MAX_DIMS[RANK] = {UC_5_MAX_PLANES, UC_5_HEIGHT, UC_5_WIDTH};
+static hsize_t UC_5_VDS_MAX_DIMS[RANK] = {UC_5_MAX_PLANES, UC_5_HEIGHT, UC_5_WIDTH};
+
+/* Planes (both source and VDS) */
+static hsize_t UC_5_PLANE[RANK] = {1, UC_5_HEIGHT, UC_5_WIDTH};
+
+/* File names for source datasets */
+static char UC_5_FILE_NAMES[UC_5_N_SOURCES][NAME_LEN] = {{"5_a.h5"}, {"5_b.h5"}, {"5_c.h5"}};
+
+/* VDS file name */
+static char UC_5_VDS_FILE_NAME[NAME_LEN] = "5_vds.h5";
+
+/* Dataset names */
+static char UC_5_SOURCE_DSET_NAME[NAME_LEN] = "source_dset";
+static char UC_5_SOURCE_DSET_PATH[NAME_LEN] = "/source_dset";
+static char UC_5_VDS_DSET_NAME[NAME_LEN] = "vds_dset";
+
+/* Fill values */
+static int UC_5_FILL_VALUES[UC_5_N_SOURCES] = {-1, -2, -3};
+static int UC_5_VDS_FILL_VALUE = -9;
+
+#endif /* UC_5_H */
diff --git a/tools/test/misc/vds/UC_5_stride_gen.c b/tools/test/misc/vds/UC_5_stride_gen.c
new file mode 100644
index 0000000..f1e93e1
--- /dev/null
+++ b/tools/test/misc/vds/UC_5_stride_gen.c
@@ -0,0 +1,231 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * File/dataset generator for VDS use case 5
+ *
+ * See the header file for a description.
+ */
+
+#include <stdlib.h>
+
+#include <hdf5.h>
+
+#include "UC_common.h"
+#include "UC_5.h"
+
+int
+main(void)
+{
+ hid_t src_sid = H5I_INVALID_HID; /* source dataset's dataspace ID */
+ hid_t src_dcplid = H5I_INVALID_HID; /* source dataset property list ID */
+
+ hid_t vds_sid = H5I_INVALID_HID; /* VDS dataspace ID */
+ hid_t vds_dcplid = H5I_INVALID_HID; /* VDS dataset property list ID */
+
+ hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */
+ hid_t did = H5I_INVALID_HID; /* dataset ID */
+ hid_t msid = H5I_INVALID_HID; /* memory dataspace ID */
+ hid_t fsid = H5I_INVALID_HID; /* file dataspace ID */
+
+ hsize_t extent[RANK]; /* source dataset extents */
+ hsize_t start[RANK]; /* starting point for hyperslab */
+ hsize_t stride[RANK]; /* hypserslab stride */
+ hsize_t count[RANK]; /* hypserslab count */
+ hsize_t map_start = 0; /* starting point in the VDS map */
+
+ int *buffer = NULL; /* data buffer */
+ int value = -1; /* value written to datasets */
+
+ hsize_t n = 0; /* number of elements in a plane */
+
+ int i; /* iterator */
+ int j; /* iterator */
+ hsize_t k; /* iterator */
+
+ /* Start by creating the virtual dataset (VDS) dataspace and creation
+ * property list. The individual source datasets are then created
+ * and the VDS map (stored in the VDS property list) is updated.
+ */
+
+ /* Create VDS dcpl */
+ if ((vds_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ UC_ERROR
+ if (H5Pset_fill_value(vds_dcplid, UC_5_VDS_DATATYPE, &UC_5_VDS_FILL_VALUE) < 0)
+ UC_ERROR
+
+ /* Create VDS dataspace */
+ if ((vds_sid = H5Screate_simple(RANK, UC_5_VDS_DIMS, UC_5_VDS_MAX_DIMS)) < 0)
+ UC_ERROR
+
+ /*********************************
+ * Map source files and datasets *
+ *********************************/
+
+ /* Hyperslab array setup */
+ start[0] = 0;
+ start[1] = 0;
+ start[2] = 0;
+ map_start = 0;
+
+ stride[0] = UC_5_N_SOURCES;
+ stride[1] = 1;
+ stride[2] = 1;
+
+ count[0] = H5S_UNLIMITED;
+ count[1] = 1;
+ count[2] = 1;
+
+ extent[0] = UC_5_SRC_PLANES;
+ extent[1] = UC_5_HEIGHT;
+ extent[2] = UC_5_WIDTH;
+
+ for (i = 0; i < UC_5_N_SOURCES; i++) {
+
+ /* source dataset dcpl */
+ if ((src_dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ UC_ERROR
+ if (H5Pset_chunk(src_dcplid, RANK, UC_5_PLANE) < 0)
+ UC_ERROR
+ if (H5Pset_fill_value(src_dcplid, UC_5_SOURCE_DATATYPE, &UC_5_FILL_VALUES[i]) < 0)
+ UC_ERROR
+ if (H5Pset_deflate(src_dcplid, COMPRESSION_LEVEL) < 0)
+ UC_ERROR
+
+ /* Create source file, dataspace, and dataset */
+ if ((fid = H5Fcreate(UC_5_FILE_NAMES[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ UC_ERROR
+ if ((src_sid = H5Screate_simple(RANK, UC_5_SOURCE_DIMS, UC_5_SOURCE_MAX_DIMS)) < 0)
+ UC_ERROR
+ if ((did = H5Dcreate2(fid, UC_5_SOURCE_DSET_NAME, UC_5_SOURCE_DATATYPE, src_sid, H5P_DEFAULT,
+ src_dcplid, H5P_DEFAULT)) < 0)
+ UC_ERROR
+
+ /* Set the dataset's extent */
+ if (H5Dset_extent(did, extent) < 0)
+ UC_ERROR
+
+ /* Create a data buffer that represents a plane */
+ n = UC_5_PLANE[1] * UC_5_PLANE[2];
+ if (NULL == (buffer = (int *)malloc(n * sizeof(int))))
+ UC_ERROR
+
+ /* Create the memory dataspace */
+ if ((msid = H5Screate_simple(RANK, UC_5_PLANE, NULL)) < 0)
+ UC_ERROR
+
+ /* Get the file dataspace */
+ if ((fsid = H5Dget_space(did)) < 0)
+ UC_ERROR
+
+ /* Write planes to the dataset */
+ for (j = 0; j < UC_5_SRC_PLANES; j++) {
+
+ value = ((i + 1) * 10) + j;
+ for (k = 0; k < n; k++)
+ buffer[k] = value;
+
+ start[0] = (hsize_t)j;
+ start[1] = 0;
+ start[2] = 0;
+ if (H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_5_PLANE, NULL) < 0)
+ UC_ERROR
+ if (H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0)
+ UC_ERROR
+
+ } /* end for */
+
+ /* set up hyperslabs for source and destination datasets */
+ start[0] = 0;
+ start[1] = 0;
+ start[2] = 0;
+ if (H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, UC_5_SOURCE_MAX_DIMS, NULL) < 0)
+ UC_ERROR
+ start[0] = map_start;
+ if (H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, start, stride, count, UC_5_PLANE) < 0)
+ UC_ERROR
+ map_start += 1;
+
+ /* Add VDS mapping */
+ if (H5Pset_virtual(vds_dcplid, vds_sid, UC_5_FILE_NAMES[i], UC_5_SOURCE_DSET_PATH, src_sid) < 0)
+ UC_ERROR
+
+ /* close */
+ if (H5Sclose(msid) < 0)
+ UC_ERROR
+ if (H5Sclose(fsid) < 0)
+ UC_ERROR
+ if (H5Sclose(src_sid) < 0)
+ UC_ERROR
+ if (H5Pclose(src_dcplid) < 0)
+ UC_ERROR
+ if (H5Dclose(did) < 0)
+ UC_ERROR
+ if (H5Fclose(fid) < 0)
+ UC_ERROR
+ free(buffer);
+
+ } /* end for */
+
+ /*******************
+ * Create VDS file *
+ *******************/
+
+ /* file */
+ if ((fid = H5Fcreate(UC_5_VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ UC_ERROR
+
+ /* dataset */
+ if ((did = H5Dcreate2(fid, UC_5_VDS_DSET_NAME, UC_5_VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid,
+ H5P_DEFAULT)) < 0)
+ UC_ERROR
+
+ /* close */
+ if (H5Pclose(vds_dcplid) < 0)
+ UC_ERROR
+ if (H5Sclose(vds_sid) < 0)
+ UC_ERROR
+ if (H5Dclose(did) < 0)
+ UC_ERROR
+ if (H5Fclose(fid) < 0)
+ UC_ERROR
+
+ return EXIT_SUCCESS;
+
+error:
+
+ H5E_BEGIN_TRY
+ {
+ if (src_sid >= 0)
+ (void)H5Sclose(src_sid);
+ if (src_dcplid >= 0)
+ (void)H5Pclose(src_dcplid);
+ if (vds_sid >= 0)
+ (void)H5Sclose(vds_sid);
+ if (vds_dcplid >= 0)
+ (void)H5Pclose(vds_dcplid);
+ if (fid >= 0)
+ (void)H5Fclose(fid);
+ if (did >= 0)
+ (void)H5Dclose(did);
+ if (msid >= 0)
+ (void)H5Sclose(msid);
+ if (fsid >= 0)
+ (void)H5Sclose(fsid);
+ if (buffer != NULL)
+ free(buffer);
+ }
+ H5E_END_TRY
+
+ return EXIT_FAILURE;
+
+} /* end main() */
diff --git a/tools/test/misc/vds/UC_common.h b/tools/test/misc/vds/UC_common.h
new file mode 100644
index 0000000..234ec87
--- /dev/null
+++ b/tools/test/misc/vds/UC_common.h
@@ -0,0 +1,43 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#ifndef USE_CASE_COMMON_H
+#define USE_CASE_COMMON_H
+
+/******************************************
+ * Symbols used across multiple use cases *
+ ******************************************/
+
+/* All datasets are 3D */
+#define RANK 3
+
+/* Lengths of string identifiers (file, dataset names, etc.) */
+#define NAME_LEN 32
+
+/* Compression level */
+#define COMPRESSION_LEVEL 7
+
+/* Booleans */
+#define TRUE 1
+#define FALSE 0
+
+/* Testing macros */
+#define AT() printf(" at %s:%d in %s()...\n", __FILE__, __LINE__, __func__);
+#define UC_ERROR \
+ { \
+ puts("*ERROR*"); \
+ fflush(stdout); \
+ AT(); \
+ goto error; \
+ }
+
+#endif /* USE_CASE_COMMON_H */