summaryrefslogtreecommitdiffstats
path: root/tools/misc
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2015-12-15 09:48:59 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2015-12-15 09:48:59 (GMT)
commit4fe9d56f786f1f43e06655fa238ac7b11a194ba1 (patch)
tree7b1d0a0d729a2fe508efb0c46360d5204edec7b1 /tools/misc
parente9da1c3460abdb32496f9271edf2a2dbbaa4e72b (diff)
downloadhdf5-4fe9d56f786f1f43e06655fa238ac7b11a194ba1.zip
hdf5-4fe9d56f786f1f43e06655fa238ac7b11a194ba1.tar.gz
hdf5-4fe9d56f786f1f43e06655fa238ac7b11a194ba1.tar.bz2
[svn-r28658] Manual merge of revise_chunks and alpha branch.
Tested on: Unbuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 Autotools serial (C++ Fortran) Autotools parallel (MPICH 3.1.4, Fortran) CMake serial (CMake 3.3.2)
Diffstat (limited to 'tools/misc')
-rw-r--r--tools/misc/Makefile.am14
-rw-r--r--tools/misc/clear_open_chk.c72
-rw-r--r--tools/misc/h5clear.c137
-rw-r--r--tools/misc/h5clear_gentest.c174
-rw-r--r--tools/misc/h5debug.c52
-rw-r--r--tools/misc/testh5clear.sh.in130
6 files changed, 572 insertions, 7 deletions
diff --git a/tools/misc/Makefile.am b/tools/misc/Makefile.am
index fdfe8f7..bde6805 100644
--- a/tools/misc/Makefile.am
+++ b/tools/misc/Makefile.am
@@ -27,20 +27,24 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib
#test scripts and programs
TEST_PROG=h5repart_gentest talign
-TEST_SCRIPT=testh5repart.sh testh5mkgrp.sh
+TEST_SCRIPT=testh5repart.sh testh5mkgrp.sh testh5clear.sh
-check_PROGRAMS=$(TEST_PROG) repart_test
+
+check_PROGRAMS=$(TEST_PROG) repart_test clear_open_chk
check_SCRIPTS=$(TEST_SCRIPT)
-SCRIPT_DEPEND=h5repart$(EXEEXT) h5mkgrp$(EXEEXT)
+SCRIPT_DEPEND=h5repart$(EXEEXT) h5mkgrp$(EXEEXT) h5clear$(EXEEXT)
+
# These are our main targets, the tools
-bin_PROGRAMS=h5debug h5repart h5mkgrp
+bin_PROGRAMS=h5debug h5repart h5mkgrp h5clear
bin_SCRIPTS=h5redeploy
+noinst_PROGRAMS=h5clear_gentest
# Add h5debug, h5repart, and h5mkgrp specific linker flags here
h5debug_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
h5repart_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
h5mkgrp_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
+h5clear_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
# Tell automake to clean h5redeploy script
CLEANFILES=h5redeploy
@@ -51,7 +55,7 @@ CLEANFILES=h5redeploy
CHECK_CLEANFILES+=*.h5 ../testfiles/fst_family*.h5 ../testfiles/scd_family*.h5
# These were generated by configure. Remove them only when distclean.
-DISTCLEANFILES=h5cc testh5repart.sh
+DISTCLEANFILES=h5cc testh5repart.sh testh5clear.sh
# All programs rely on hdf5 library and h5tools library
LDADD=$(LIBH5TOOLS) $(LIBHDF5)
diff --git a/tools/misc/clear_open_chk.c b/tools/misc/clear_open_chk.c
new file mode 100644
index 0000000..f3e6ba3
--- /dev/null
+++ b/tools/misc/clear_open_chk.c
@@ -0,0 +1,72 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * 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 files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. 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();
+ return(EXIT_FAILURE);
+ }
+
+ /* Get the file name */
+ fname = HDstrdup(argv[1]);
+
+ /* Try opening the file */
+ if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) {
+ HDfprintf(stderr, "clear_open_chk: unable to open the file\n");
+ return EXIT_FAILURE;
+ }
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0) {
+ HDfprintf(stderr, "clear_open_chk: cannot close the file\n");
+ return EXIT_FAILURE;
+ }
+
+ /* Return success */
+ return EXIT_SUCCESS;
+
+} /* main() */
diff --git a/tools/misc/h5clear.c b/tools/misc/h5clear.c
new file mode 100644
index 0000000..0be4f8f
--- /dev/null
+++ b/tools/misc/h5clear.c
@@ -0,0 +1,137 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * 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 files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Programmer:
+ *
+ * Purpose:
+ */
+
+#include "hdf5.h"
+#include "H5private.h"
+#include "h5tools.h"
+#include "h5tools_utils.h"
+
+/* 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"
+
+/*-------------------------------------------------------------------------
+ * Function: leave
+ *
+ * Purpose: Close the tools library and exit
+ *
+ * Return: Does not return
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+leave(int ret)
+{
+ h5tools_close();
+ HDexit(ret);
+
+} /* leave() */
+
+/*-------------------------------------------------------------------------
+ * Function: usage
+ *
+ * Purpose: Prints a usage message
+ *
+ * Return: void
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+usage(void)
+{
+ HDfprintf(stdout, "usage: h5clear filename\n");
+
+} /* usage() */
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose:
+ *
+ * Return: Success:
+ * Failure:
+ *
+ * Programmer:
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main (int argc, char *argv[])
+{
+ char *fname; /* File name */
+ hbool_t clear = TRUE; /* To clear the status_flags in the file's superblock */
+ hid_t fapl = -1; /* File access property list */
+ hid_t fid = -1; /* File ID */
+
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+
+ /* Disable the HDF5 library's error reporting */
+ H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
+
+ /* initialize h5tools lib */
+ h5tools_init();
+
+ /* Check for the # of arguments */
+ if(argc != 2) {
+ usage();
+ leave(EXIT_FAILURE);
+ }
+
+ /* Duplicate the file name */
+ fname = HDstrdup(argv[opt_ind]);
+
+ /* Get a copy of the file access property list */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ error_msg("H5Pcreate\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* Set to clear the status_flags in the file's superblock */
+ /* This is a private property used by h5clear only */
+ if(H5Pset(fapl, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear) < 0) {
+ error_msg("H5Pset\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if((fid = h5tools_fopen(fname, H5F_ACC_RDWR, fapl, NULL, NULL, (size_t)0)) < 0) {
+ error_msg("h5tools_fopen\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0) {
+ error_msg("H5Fclose\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* CLose the property list */
+ if(H5Pclose(fapl) < 0) {
+ error_msg("H5Pclose\n");
+ exit(EXIT_FAILURE);
+ }
+
+ return EXIT_SUCCESS;
+} /* main() */
diff --git a/tools/misc/h5clear_gentest.c b/tools/misc/h5clear_gentest.c
new file mode 100644
index 0000000..0f20c35
--- /dev/null
+++ b/tools/misc/h5clear_gentest.c
@@ -0,0 +1,174 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * 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 files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+#include "hdf5.h"
+#include "H5private.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 veresion 3 */
+ "h5clear_sec2_v0.h5", /* 2 -- sec2 file with superblock version 0 */
+ "h5clear_sec2_v2.h5" /* 3 -- sec2 file with superblock version 2 */
+};
+
+#define KB 1024U
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose: To create HDF5 files 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.
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Vailin Choi; July 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ hid_t fid; /* File ID */
+ hid_t fcpl; /* File creation property list */
+ hid_t fapl, new_fapl; /* File access property lists */
+ char fname[512]; /* File name */
+ unsigned new_format; /* To use latest library format or not */
+
+ /* 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 */
+ 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 */
+ sprintf(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 */
+ sprintf(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
+ */
+ 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
+ */
+ 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;
+
+ 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/misc/h5debug.c b/tools/misc/h5debug.c
index 480450d..aac14db 100644
--- a/tools/misc/h5debug.c
+++ b/tools/misc/h5debug.c
@@ -121,6 +121,14 @@ get_H5B2_class(const uint8_t *sig)
cls = H5A_BT2_CORDER;
break;
+ case H5B2_CDSET_ID:
+ cls = H5D_BT2;
+ break;
+
+ case H5B2_CDSET_FILT_ID:
+ cls = H5D_BT2_FILT;
+ break;
+
case H5B2_NUM_BTREE_ID:
default:
HDfprintf(stderr, "Unknown v2 B-tree subtype %u\n", (unsigned)(subtype));
@@ -157,6 +165,14 @@ get_H5EA_class(const uint8_t *sig)
cls = H5EA_CLS_TEST;
break;
+ case H5EA_CLS_CHUNK_ID:
+ cls = H5EA_CLS_CHUNK;
+ break;
+
+ case H5EA_CLS_FILT_CHUNK_ID:
+ cls = H5EA_CLS_FILT_CHUNK;
+ break;
+
case H5EA_NUM_CLS_ID:
default:
HDfprintf(stderr, "Unknown extensible array class %u\n", (unsigned)(clsid));
@@ -193,6 +209,14 @@ get_H5FA_class(const uint8_t *sig)
cls = H5FA_CLS_TEST;
break;
+ case H5FA_CLS_CHUNK_ID:
+ cls = H5FA_CLS_CHUNK;
+ break;
+
+ case H5FA_CLS_FILT_CHUNK_ID:
+ cls = H5FA_CLS_FILT_CHUNK;
+ break;
+
case H5FA_NUM_CLS_ID:
default:
HDfprintf(stderr, "Unknown fixed array class %u\n", (unsigned)(clsid));
@@ -398,6 +422,13 @@ main(int argc, char *argv[])
const H5B2_class_t *cls = get_H5B2_class(sig);
HDassert(cls);
+ if((cls == H5D_BT2 || cls == H5D_BT2_FILT) && extra == 0) {
+ fprintf(stderr, "ERROR: Need v2 B-tree header address and object header address containing the layout message in order to dump header\n");
+ fprintf(stderr, "v2 B-tree hdr usage:\n");
+ fprintf(stderr, "\th5debug <filename> <v2 B-tree header address> <object header address>\n");
+ HDexit(4);
+ }
+
status = H5B2__hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, cls, (haddr_t)extra);
} else if(!HDmemcmp(sig, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
@@ -408,7 +439,16 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0 || extra3 == 0) {
+ if((cls == H5D_BT2 || cls == H5D_BT2_FILT) &&
+ (extra == 0 || extra2 == 0 || extra3 == 0 || extra4 == 0)) {
+
+ fprintf(stderr, "ERROR: Need v2 B-tree header address, the node's number of records, depth, and object header address containing the layout message in order to dump internal node\n");
+ fprintf(stderr, "NOTE: Leaf nodes are depth 0, the internal nodes above them are depth 1, etc.\n");
+ fprintf(stderr, "v2 B-tree internal node usage:\n");
+ fprintf(stderr, "\th5debug <filename> <internal node address> <v2 B-tree header address> <number of records> <depth> <object header address>\n");
+ HDexit(4);
+
+ } else if(extra == 0 || extra2 == 0 || extra3 == 0) {
HDfprintf(stderr, "ERROR: Need v2 B-tree header address and the node's number of records and depth in order to dump internal node\n");
HDfprintf(stderr, "NOTE: Leaf nodes are depth 0, the internal nodes above them are depth 1, etc.\n");
HDfprintf(stderr, "v2 B-tree internal node usage:\n");
@@ -426,7 +466,15 @@ main(int argc, char *argv[])
HDassert(cls);
/* Check for enough valid parameters */
- if(extra == 0 || extra2 == 0) {
+ if((cls == H5D_BT2 || cls == H5D_BT2_FILT) &&
+ (extra == 0 || extra2 == 0 || extra3 == 0 )) {
+
+ fprintf(stderr, "ERROR: Need v2 B-tree header address, number of records, and object header address containing the layout message in order to dump leaf node\n");
+ fprintf(stderr, "v2 B-tree leaf node usage:\n");
+ fprintf(stderr, "\th5debug <filename> <leaf node address> <v2 B-tree header address> <number of records> <object header address>\n");
+ HDexit(4);
+
+ } else if(extra == 0 || extra2 == 0) {
HDfprintf(stderr, "ERROR: Need v2 B-tree header address and number of records in order to dump leaf node\n");
HDfprintf(stderr, "v2 B-tree leaf node usage:\n");
HDfprintf(stderr, "\th5debug <filename> <leaf node address> <v2 B-tree header address> <number of records>\n");
diff --git a/tools/misc/testh5clear.sh.in b/tools/misc/testh5clear.sh.in
new file mode 100644
index 0000000..aeac03e
--- /dev/null
+++ b/tools/misc/testh5clear.sh.in
@@ -0,0 +1,130 @@
+#! /bin/sh
+#
+# Copyright by The HDF Group.
+# Copyright by the Board of Trustees of the University of Illinois.
+# 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 files COPYING and Copyright.html. COPYING can be found at the root
+# of the source code distribution tree; Copyright.html can be found at the
+# root level of an installed copy of the electronic HDF5 document set and
+# is linked from the top-level documents page. It can also be found at
+# http://hdfgroup.org/HDF5/doc/Copyright.html. 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=h5clear
+H5CLEAR_BIN=`pwd`/$H5CLEAR # The path of the tool binary
+
+GENTEST=h5clear_gentest # Generate test files
+GENTEST_BIN=`pwd`/$GENTEST # The path to the binary
+
+OPENCHK=clear_open_chk # Try opening the test file
+OPENCHK_BIN=`pwd`/$OPENCHK # The path to the binary
+
+SUCCEED=0
+FAIL=1
+
+nerrors=0
+verbose=yes
+
+# 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) Use "h5clear" to clear the status_flags in the test file
+# (2) Open the test file via "clear_open_chk"
+# $1 is the filename for testing
+TOOLTEST() {
+ TESTING $H5CLEAR $1
+ fname=$1
+ # Use "h5clear" to clear the status_flags in the test file
+ $RUNSERIAL $H5CLEAR_BIN $fname
+ if test $? -ne $SUCCEED; then
+ echo ".....$H5CLEAR: should succeed"
+ nerrors=`expr $nerrors + 1`
+ else
+ # Open the test file via "clear_open_chk"
+ $OPENCHK_BIN $fname
+ if test $? -ne $SUCCEED; then
+ echo "......$OPENCHK: should succeed"
+ nerrors=`expr $nerrors + 1`
+ else
+ echo "PASSED"
+ fi
+ fi
+}
+
+
+
+# Use "clear_open_chk" to check if the file open succeeds or fails
+# $1 is the filename to open
+# $2 is the expected return from "clear_open_chk"
+OPENCHK() {
+ fname=$1
+ expected=$2
+ #
+ $OPENCHK_BIN $fname 2>/dev/null
+ actual=$?
+ if test $actual -ne $expected; then
+ echo "Unexpected return from $OPENCHK"
+ nerrors=`expr $nerrors + 1`
+ fi
+}
+
+##############################################################################
+##############################################################################
+### T H E T E S T S ###
+##############################################################################
+##############################################################################
+#
+$GENTEST_BIN # Create HDF5 test files
+if test $? -ne 0; then # Error returned from generating test files
+ echo "$GENTEST: .....fail in generating test files"
+ nerrors=`expr $nerrors + 1`
+else
+ # Initial file open fails
+ # After "h5clear" the file, the subsequent file open succeeds
+ OPENCHK h5clear_sec2_v3.h5 $FAIL
+ TOOLTEST h5clear_sec2_v3.h5
+ #
+ OPENCHK h5clear_log_v3.h5 $FAIL
+ TOOLTEST h5clear_log_v3.h5
+ #
+ OPENCHK latest_h5clear_sec2_v3.h5 $FAIL
+ TOOLTEST latest_h5clear_sec2_v3.h5
+ #
+ OPENCHK latest_h5clear_log_v3.h5 $FAIL
+ TOOLTEST latest_h5clear_log_v3.h5
+fi
+#
+#
+# File open succeeds because the library does not check status_flags for file with < v3 superblock
+OPENCHK h5clear_sec2_v0.h5 $SUCCEED
+TOOLTEST h5clear_sec2_v0.h5
+OPENCHK h5clear_sec2_v2.h5 $SUCCEED
+TOOLTEST h5clear_sec2_v2.h5
+#
+# Clean up test files
+if test -z "$HDF5_NOCLEANUP"; then
+ rm -f h5clear_*.h5 latest_h5clear*.h5
+fi
+
+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