summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLarry Knox <lrknox@hdfgroup.org>2018-03-13 18:04:03 (GMT)
committerLarry Knox <lrknox@hdfgroup.org>2018-03-13 18:04:03 (GMT)
commitf30873136be7cb444166d019c57d3508ff79fc76 (patch)
tree559406eb3860a27fe1bfc6fcc7b5febe8454cba7 /tools
parent8a77c7a3e4cd49cc0de824476b04b4926582e1ed (diff)
parent9247388c3d14510341ea3f07847ce2cbb6e44a8e (diff)
downloadhdf5-f30873136be7cb444166d019c57d3508ff79fc76.zip
hdf5-f30873136be7cb444166d019c57d3508ff79fc76.tar.gz
hdf5-f30873136be7cb444166d019c57d3508ff79fc76.tar.bz2
Merge pull request #943 in HDFFV/hdf5 from develop to hdf5_1_10
* commit '9247388c3d14510341ea3f07847ce2cbb6e44a8e': Rework new tests into one macro Added a "won't fix" RELEASE.txt entry for HDFFV-10356. Fix CMake test names Fixed typo Add release note for HDFFFV-10397. Added a fix for HDFFV-10358. Fixed documentation Description: - Updated the description of copy constructor for clarification. - Removed unnecessary comments. Platforms tested: Linux/64 (jelly) Enhancement to the tool h5clear (HDFFV-10360) Fix for HDFFV-10209 VDS SWMR test failure Free the object header when there are chksum retries.
Diffstat (limited to 'tools')
-rw-r--r--tools/src/misc/h5clear.c158
-rw-r--r--tools/test/misc/CMakeTestsClear.cmake187
-rw-r--r--tools/test/misc/h5clear_gentest.c369
-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_missing_file.ddl10
-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_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.ddl10
-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/testh5clear.sh.in122
29 files changed, 811 insertions, 60 deletions
diff --git a/tools/src/misc/h5clear.c b/tools/src/misc/h5clear.c
index e3b989d..5724e1b 100644
--- a/tools/src/misc/h5clear.c
+++ b/tools/src/misc/h5clear.c
@@ -12,9 +12,11 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Purpose: A tool to clear the status_flags field from the file's superblock via -s option.
- * A tool to remove cache image from the file via -m option.
- *
+ * Purpose: A tool used to do the following:
+ * (1) -s, --status: clear the status_flags field from the file's superblock
+ * (2) -m, --image: remove the metadata cache image from the file
+ * (3) --increment=C: set the file's EOA to the maximum of (EOA, EOF) + C
+ * (4) --filesize: print the file's EOA and EOF
*/
#include "hdf5.h"
#include "H5private.h"
@@ -24,18 +26,25 @@
/* Name of tool */
#define PROGRAMNAME "h5clear"
-/* Make this private property (defined in H5Fprivate.h) available to h5clear. */
-#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags"
+/* Make these private properties (defined in H5Fprivate.h) available to h5clear. */
+#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags"
+#define H5F_ACS_NULL_FSM_ADDR_NAME "null_fsm_addr"
+#define H5F_ACS_SKIP_EOF_CHECK_NAME "skip_eof_check"
+
+/* Default increment is 1 megabytes for the --increment option */
+#define DEFAULT_INCREMENT 1024*1024
static char *fname_g = NULL;
static hbool_t clear_status_flags = FALSE;
static hbool_t remove_cache_image = FALSE;
+static hbool_t print_filesize = FALSE;
+static hbool_t increment_eoa_eof = FALSE;
+static hsize_t increment = DEFAULT_INCREMENT;
/*
- * Command-line options: The user can specify short or long-named
- * parameters.
+ * Command-line options: only publicize long options
*/
-static const char *s_opts = "hVsm";
+static const char *s_opts = "hVsmzi*";
static struct long_options l_opts[] = {
{ "help", no_arg, 'h' },
{ "hel", no_arg, 'h'},
@@ -54,6 +63,21 @@ static struct long_options l_opts[] = {
{ "imag", no_arg, 'm' },
{ "ima", no_arg, 'm' },
{ "im", no_arg, 'm' },
+ { "filesize", no_arg, 'z' },
+ { "filesiz", no_arg, 'z' },
+ { "filesi", no_arg, 'z' },
+ { "files", no_arg, 'z' },
+ { "file", no_arg, 'z' },
+ { "fil", no_arg, 'z' },
+ { "fi", no_arg, 'z' },
+ { "increment", optional_arg, 'i' },
+ { "incremen", optional_arg, 'i' },
+ { "increme", optional_arg, 'i' },
+ { "increm", optional_arg, 'i' },
+ { "incre", optional_arg, 'i' },
+ { "incr", optional_arg, 'i' },
+ { "inc", optional_arg, 'i' },
+ { "in", optional_arg, 'i' },
{ NULL, 0, '\0' }
};
@@ -76,6 +100,9 @@ static void usage(const char *prog)
HDfprintf(stdout, " -V, --version Print version number and exit\n");
HDfprintf(stdout, " -s, --status Clear the status_flags field in the file's superblock\n");
HDfprintf(stdout, " -m, --image Remove the metadata cache image from the file\n");
+ HDfprintf(stdout, " --filesize Print the file's EOA and EOF\n");
+ HDfprintf(stdout, " --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for the file <file_name>\n");
+ HDfprintf(stdout, " C is >= 0; C is optional and will default to 1M when not set");
HDfprintf(stdout, "\n");
HDfprintf(stdout, "Examples of use:\n");
HDfprintf(stdout, "\n");
@@ -84,6 +111,12 @@ static void usage(const char *prog)
HDfprintf(stdout, "\n");
HDfprintf(stdout, "h5clear -m file_name\n");
HDfprintf(stdout, " Remove the metadata cache image from the HDF5 file <file_name>.\n");
+ HDfprintf(stdout, "\n");
+ HDfprintf(stdout, "h5clear --increment file_name\n");
+ HDfprintf(stdout, " Set the EOA to the maximum of (EOA, EOF) + 1M for the file <file_name>.\n");
+ HDfprintf(stdout, "\n");
+ HDfprintf(stdout, "h5clear --increment=512 file_name\n");
+ HDfprintf(stdout, " Set the EOA to the maximum of (EOA, EOF) + 512 for the file <file_name>.\n");
} /* usage() */
@@ -131,6 +164,18 @@ parse_command_line(int argc, const char **argv)
remove_cache_image = TRUE;
break;
+ case 'z':
+ print_filesize = TRUE;
+ break;
+
+ case 'i':
+ increment_eoa_eof = TRUE;
+ if(opt_arg != NULL && (increment = HDatoi(opt_arg)) < 0) {
+ usage(h5tools_getprogname());
+ goto done;
+ }
+ break;
+
default:
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_FAILURE);
@@ -176,8 +221,24 @@ leave(int ret)
/*-------------------------------------------------------------------------
* Function: main
*
- * Purpose: To clear the status_flags field in the file's superblock (-s option).
- * To remove the cache image from the file (-m option).
+ * Purpose: The options are:
+ * (1) -s, --status: clear the status_flags field from the file's superblock
+ * (2) -m, --image: remove the metadata cache image from the file
+ * (3) --increment=C: set the file's EOA to the maximum of (EOA, EOF) + C
+ * (4) --filesize: print the file's EOA and EOF
+ *
+ * The three options: -s, -m, and --increment will modify the file
+ * so the file is opened with write access.
+ * The --filesize option just prints the EOA and EOF, so the file
+ * is opened with read access.
+ *
+ * The -s option will activate the private property:
+ * --H5F_ACS_CLEAR_STATUS_FLAGS_NAME
+ * The --increment option will active these two private properties:
+ * --H5F_ACS_NULL_FSM_ADDR_NAME
+ * --H5F_ACS_SKIP_EOF_CHECK_NAME
+ * The --filesize will activate the private property:
+ * --H5F_ACS_SKIP_EOF_CHECK_NAME
*
* Return: Success: 0
* Failure: 1
@@ -187,11 +248,12 @@ leave(int ret)
int
main (int argc, const char *argv[])
{
- char *fname = NULL; /* File name */
- hid_t fapl = -1; /* File access property list */
- hid_t fid = -1; /* File ID */
+ char *fname = NULL; /* File name */
+ hid_t fapl = -1; /* File access property list */
+ hid_t fid = -1; /* File ID */
haddr_t image_addr;
hsize_t image_len;
+ unsigned flags = H5F_ACC_RDWR; /* file access flags */
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
@@ -209,12 +271,22 @@ main (int argc, const char *argv[])
if(fname_g == NULL)
goto done;
- if(!clear_status_flags && !remove_cache_image) {
+ /* Print usage/exit if not using at least one of the options */
+ if(!clear_status_flags && !remove_cache_image &&
+ !increment_eoa_eof && !print_filesize) {
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
+ /* Cannot combine the --filesize option with other options */
+ if(print_filesize &&
+ (clear_status_flags || remove_cache_image || increment_eoa_eof)) {
+ error_msg("Cannot combine --filesize with other options\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+
/* Duplicate the file name */
fname = HDstrdup(fname_g);
@@ -228,7 +300,7 @@ main (int argc, const char *argv[])
/* -s option */
if(clear_status_flags) {
/* Set to clear the status_flags in the file's superblock */
- /* This is a private property used by h5clear only */
+ /* Activate this private property */
if(H5Pset(fapl, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear_status_flags) < 0) {
error_msg("H5Pset\n");
h5tools_setstatus(EXIT_FAILURE);
@@ -236,12 +308,64 @@ main (int argc, const char *argv[])
}
}
- if((fid = h5tools_fopen(fname, H5F_ACC_RDWR, fapl, NULL, NULL, (size_t)0)) < 0) {
+ /* --increment option */
+ if(increment_eoa_eof) {
+ /* Activate this private property */
+ if(H5Pset(fapl, H5F_ACS_SKIP_EOF_CHECK_NAME, &increment_eoa_eof) < 0) {
+ error_msg("H5Pset\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ /* Activate this private property */
+ if(H5Pset(fapl, H5F_ACS_NULL_FSM_ADDR_NAME, &increment_eoa_eof) < 0) {
+ error_msg("H5Pset\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ }
+
+ /* --filesize option; open the file read-only */
+ if(print_filesize) {
+ /* Activate this private property */
+ if(H5Pset(fapl, H5F_ACS_SKIP_EOF_CHECK_NAME, &print_filesize) < 0) {
+ error_msg("H5Pset\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ flags = H5F_ACC_RDONLY;
+ }
+
+ /* Open the file */
+ if((fid = h5tools_fopen(fname, flags, fapl, NULL, NULL, (size_t)0)) < 0) {
error_msg("h5tools_fopen\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
+ /* --filesize option */
+ if(print_filesize) {
+ h5_stat_t st; /* Stat info call */
+ haddr_t eoa; /* The EOA value */
+
+ /* Get the file's EOA and EOF */
+ if(H5Fget_eoa(fid, &eoa) < 0 || HDstat(fname, &st) < 0) {
+ error_msg("H5Fget_eoa or HDstat\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ HDfprintf(stdout, "EOA is %a; EOF is %a \n", eoa, st.st_size);
+ }
+
+ /* --increment option */
+ if(increment_eoa_eof) {
+ /* Set the file's EOA to the maximum of (EOA, EOF) + increment */
+ if(H5Fincrement_filesize(fid, increment) < 0) {
+ error_msg("H5Fset_eoa\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ }
+
/* -m option */
if(remove_cache_image) {
if(H5Fget_mdc_image_info(fid, &image_addr, &image_len) < 0) {
@@ -253,7 +377,9 @@ main (int argc, const char *argv[])
warn_msg("No cache image in the file\n");
}
+
h5tools_setstatus(EXIT_SUCCESS);
+
done:
if(fname)
HDfree(fname);
diff --git a/tools/test/misc/CMakeTestsClear.cmake b/tools/test/misc/CMakeTestsClear.cmake
index 942ae7a..a51d0e9 100644
--- a/tools/test/misc/CMakeTestsClear.cmake
+++ b/tools/test/misc/CMakeTestsClear.cmake
@@ -20,11 +20,19 @@
# 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
- mod_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
@@ -32,10 +40,25 @@
h5clear_sec2_v3.h5
)
set (HDF5_REFERENCE_TEST_FILES
- h5clear_usage.ddl
- h5clear_open_fail.ddl
+ 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_no_mdc_image.ddl
+ h5clear_open_fail.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
)
foreach (h5_file ${HDF5_TEST_FILES} ${HDF5_SEC2_TEST_FILES} ${HDF5_REFERENCE_TEST_FILES})
@@ -85,6 +108,42 @@
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/${testname}.out
+ testfiles/${testname}.out.err
+ testfiles/${testfile}
+ )
+ if (NOT "${last_test}" STREQUAL "")
+ set_tests_properties (H5CLEAR_CMP-${testname}-clear-objects PROPERTIES DEPENDS ${last_test})
+ endif ()
+ 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_PROGRAM=$<TARGET_FILE:h5clear>"
+ -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_EXT_DIR}/runTest.cmake"
+ )
+ set_tests_properties (H5CLEAR_CMP-${testname} PROPERTIES DEPENDS H5CLEAR_CMP-copy_${testname})
+ set (last_test "H5CLEAR_CMP-${testname}")
+ endif ()
+ endmacro ()
+
macro (ADD_H5_RETTEST testname resultcode)
if (NOT HDF5_ENABLE_USING_MEMCHECKER)
add_test (
@@ -100,6 +159,70 @@
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}_before_size.out
+ testfiles/${testname}_before_size.out.err
+ testfiles/${testname}_after_size.out
+ testfiles/${testname}_after_size.out.err
+ testfiles/${testname}.h5
+ )
+ if (NOT "${last_test}" STREQUAL "")
+ set_tests_properties (H5CLEAR_FILESIZE_TEST-${testname}-clear-objects PROPERTIES DEPENDS ${last_test})
+ endif ()
+ 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_PROGRAM=$<TARGET_FILE:h5clear>"
+ -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_EXT_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 $<TARGET_FILE:h5clear> --increment=${incr_size} ${testname}.h5
+ )
+ else ()
+ add_test (
+ NAME H5CLEAR_FILESIZE_INCR-${testname}
+ COMMAND $<TARGET_FILE:h5clear> --increment ${testname}.h5
+ )
+ endif ()
+ set_tests_properties (H5CLEAR_FILESIZE_INCR-${testname} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles")
+ set_tests_properties (H5CLEAR_FILESIZE_INCR-${testname} PROPERTIES WILL_FAIL "${resultcode}")
+ set_tests_properties (H5CLEAR_FILESIZE_INCR-${testname} PROPERTIES DEPENDS H5CLEAR_FILESIZE_CMP-${testname}_before_size)
+ add_test (
+ NAME H5CLEAR_FILESIZE_CMP-${testname}_after_size
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5clear>"
+ -D "TEST_ARGS:STRING=--filesize;${testname}.h5"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
+ -D "TEST_OUTPUT=${testname}_after_size.out"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_REFERENCE=${resultfile}_after_size.ddl"
+ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
+ )
+ set_tests_properties (H5CLEAR_FILESIZE_CMP-${testname}_after_size PROPERTIES DEPENDS H5CLEAR_FILESIZE_INCR-${testname})
+ set (last_test "H5CLEAR_FILESIZE_CMP-${testname}_after_size")
+ endif ()
+ endmacro ()
+
macro (ADD_H5_TEST testname testfile resultcode)
if (NOT HDF5_ENABLE_USING_MEMCHECKER)
add_test (
@@ -160,6 +283,7 @@ if (HDF5_ENABLE_USING_MEMCHECKER)
latest_h5clear_sec2_v3.h5
mod_h5clear_mdc_image.h5
mod_h5clear_mdc_image2.h5
+ ${HDF5_TEST_FILES}
)
if (NOT "${last_test}" STREQUAL "")
set_tests_properties (H5CLEAR-clearall-objects PROPERTIES DEPENDS ${last_test})
@@ -270,3 +394,60 @@ endif()
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_CMP_WITH_COPY (h5clr_open_fail_nc_s 1 h5clear_open_fail h5clear_status_noclose.h5 "--filesize")
+ ADD_H5_RETTEST (h5clr_mdc_image_nc "false" "-s" "--increment=0" h5clear_status_noclose.h5)
+ ADD_H5_CMP (h5clr_no_mdc_image_nc_m h5clear_status_noclose_after_size 0 "--filesize" h5clear_status_noclose.h5)
+#
+# (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/h5clear_gentest.c b/tools/test/misc/h5clear_gentest.c
index 326109c..ccb510f 100644
--- a/tools/test/misc/h5clear_gentest.c
+++ b/tools/test/misc/h5clear_gentest.c
@@ -21,10 +21,25 @@ const char *FILENAME[] = {
"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
@@ -118,26 +133,224 @@ error:
H5Pclose(dcpl);
} H5E_END_TRY;
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 = -1; /* File ID */
+ hid_t fcpl = -1; /* File creation property list */
+ hid_t fapl = -1; /* File access property list */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1; /* Dataset ID */
+ hsize_t dim[1]; /* Dimension sizes */
+ int data[NUM_ELMTS]; /* Buffer for data */
+ int fd = -1; /* The file descriptor ID */
+ int64_t eoa; /* The EOA value */
+ int32_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: To create HDF5 files with non-zero status_flags in the superblock
- * via flushing and exiting without closing the library.
+ * Purpose: Generate test files used by h5clear.
*
- * 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.
+ * (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"
*
- * These files are used by "h5clear" to see if the tool clears
- * status_flags properly so users can open the files afterwards.
+ * (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
@@ -149,20 +362,30 @@ error:
int
main(void)
{
- hid_t fid; /* File ID */
- hid_t fcpl; /* File creation property list */
- hid_t fapl, new_fapl; /* File access property lists */
+ hid_t fid = -1; /* File ID */
+ hid_t fcpl = -1; /* File creation property list */
+ hid_t fapl = -1, new_fapl = -1; /* File access property lists */
char fname[512]; /* File name */
- unsigned new_format; /* To use latest library format or not */
+ unsigned new_format; /* To use latest library format or not */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1; /* 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 with invalid status_flags
+ * Generate files in FILENAME[]
*/
-
/* Create a copy of the file access property list */
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
goto error;
@@ -174,7 +397,11 @@ main(void)
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 */
+ /*
+ * 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 */
@@ -228,7 +455,8 @@ main(void)
} /* end for */
/*
- * Create a sec2 file with v0 superblock but nonzero status_flags
+ * 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;
@@ -239,7 +467,8 @@ main(void)
/*
- * Create a sec2 file with v2 superblock but nonzero status_flags
+ * 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;
@@ -264,6 +493,100 @@ main(void)
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);
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_missing_file.ddl b/tools/test/misc/testfiles/h5clear_missing_file.ddl
index 1e5150c..13eb2c9 100644
--- a/tools/test/misc/testfiles/h5clear_missing_file.ddl
+++ b/tools/test/misc/testfiles/h5clear_missing_file.ddl
@@ -4,7 +4,9 @@ usage: h5clear [OPTIONS] file_name
-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
Examples of use:
h5clear -s file_name
@@ -12,4 +14,10 @@ h5clear -s 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>.
h5clear error: missing file name
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_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
index a399ae7..32dd549 100644
--- a/tools/test/misc/testfiles/h5clear_usage.ddl
+++ b/tools/test/misc/testfiles/h5clear_usage.ddl
@@ -4,7 +4,9 @@ usage: h5clear [OPTIONS] file_name
-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
Examples of use:
h5clear -s file_name
@@ -12,3 +14,9 @@ h5clear -s 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/testh5clear.sh.in b/tools/test/misc/testh5clear.sh.in
index 2966b2c..11c2ff9 100644
--- a/tools/test/misc/testh5clear.sh.in
+++ b/tools/test/misc/testh5clear.sh.in
@@ -66,6 +66,21 @@ $SRC_H5CLEAR_TESTFILES/h5clear_usage.ddl
$SRC_H5CLEAR_TESTFILES/h5clear_open_fail.ddl
$SRC_H5CLEAR_TESTFILES/h5clear_missing_file.ddl
$SRC_H5CLEAR_TESTFILES/h5clear_no_mdc_image.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
@@ -74,6 +89,14 @@ $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()
@@ -152,7 +175,8 @@ TOOLTEST_OUT() {
fname=$1
option1=$2
option2=$3
- expected=$4
+ option3=$4
+ expected=$5
# Prepare expected and actual output
expect="$TESTDIR/$expected"
actual="$TESTDIR/`basename $expected .ddl`.out"
@@ -161,10 +185,10 @@ TOOLTEST_OUT() {
actual_err_sav=${actual_err}-sav
# Run test.
- TESTING $H5CLEAR $option1 $option2 $fname
+ TESTING $H5CLEAR $option1 $option2 $option3 $option4 $fname
(
cd $TESTDIR
- $RUNSERIAL $H5CLEAR_BIN $option1 $option2 $fname
+ $RUNSERIAL $H5CLEAR_BIN $option1 $option2 $option3 $option4 $fname
) >$actual 2>$actual_err
cp $actual $actual_sav
cp $actual_err $actual_err_sav
@@ -245,17 +269,16 @@ $CP -f $TESTDIR/h5clear_sec2_v3.h5 $TESTDIR/orig_h5clear_sec2_v3.h5
# "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_OUT junk.h5 -s "" h5clear_open_fail.ddl
-TOOLTEST_OUT "" -m -s h5clear_missing_file.ddl
-TOOLTEST_OUT junk.h5 -m -s h5clear_open_fail.ddl
-TOOLTEST_OUT orig_h5clear_sec2_v2.h5 -m "" h5clear_no_mdc_image.ddl
-TOOLTEST_OUT orig_h5clear_sec2_v0.h5 -s -m h5clear_no_mdc_image.ddl
-#
+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_OUT junk.h5 -s "" "" h5clear_open_fail.ddl
+TOOLTEST_OUT "" -m -s "" h5clear_missing_file.ddl
+TOOLTEST_OUT junk.h5 -m -s "" h5clear_open_fail.ddl
+TOOLTEST_OUT orig_h5clear_sec2_v2.h5 -m "" "" h5clear_no_mdc_image.ddl
+TOOLTEST_OUT orig_h5clear_sec2_v0.h5 -s -m "" h5clear_no_mdc_image.ddl
#
#
# The following are tests to verify the expected exit code from h5clear:
@@ -285,8 +308,8 @@ 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_OUT mod_h5clear_mdc_image.h5 -m "" h5clear_no_mdc_image.ddl
-TOOLTEST_OUT mod_h5clear_mdc_image.h5 -s -m h5clear_no_mdc_image.ddl
+TOOLTEST_OUT mod_h5clear_mdc_image.h5 -m "" "" h5clear_no_mdc_image.ddl
+TOOLTEST_OUT mod_h5clear_mdc_image.h5 -s -m "" h5clear_no_mdc_image.ddl
#
#
#
@@ -319,6 +342,73 @@ 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_OUT h5clear_status_noclose.h5 --filesize "" "" h5clear_open_fail.ddl
+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