summaryrefslogtreecommitdiffstats
path: root/tools/misc
diff options
context:
space:
mode:
Diffstat (limited to 'tools/misc')
-rw-r--r--tools/misc/CMakeLists.txt24
-rw-r--r--tools/misc/Makefile.am11
-rw-r--r--tools/misc/h5extend.c288
-rw-r--r--tools/misc/h5extend_gentest.c98
-rw-r--r--tools/misc/testh5extend.sh.in137
5 files changed, 551 insertions, 7 deletions
diff --git a/tools/misc/CMakeLists.txt b/tools/misc/CMakeLists.txt
index 088dbdf..798a31d 100644
--- a/tools/misc/CMakeLists.txt
+++ b/tools/misc/CMakeLists.txt
@@ -28,10 +28,17 @@ TARGET_C_PROPERTIES (h5mkgrp STATIC " " " ")
target_link_libraries (h5mkgrp ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5mkgrp PROPERTIES FOLDER tools)
+add_executable (h5extend ${HDF5_TOOLS_MISC_SOURCE_DIR}/h5extend.c)
+TARGET_NAMING (h5extend ${LIB_TYPE})
+TARGET_C_PROPERTIES (h5extend " " " ")
+target_link_libraries (h5extend ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET})
+set_target_properties (h5extend PROPERTIES FOLDER tools)
+
set (H5_DEP_EXECUTABLES
h5debug
h5repart
h5mkgrp
+ h5extend
)
#-----------------------------------------------------------------------------
@@ -53,8 +60,14 @@ if (BUILD_TESTING)
set_target_properties (h5repart_gentest PROPERTIES FOLDER generator/tools)
#add_test (NAME h5repart_gentest COMMAND $<TARGET_FILE:h5repart_gentest>)
- add_subdirectory (${HDF5_TOOLS_MISC_SOURCE_DIR}/vds)
+ add_executable (h5extend_gentest ${HDF5_TOOLS_MISC_SOURCE_DIR}/h5extend_gentest.c)
+ TARGET_NAMING (h5extend_gentest STATIC)
+ TARGET_C_PROPERTIES (h5extend_gentest STATIC " " " ")
+ target_link_libraries (h5extend_gentest ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET})
+ set_target_properties (h5extend_gentest PROPERTIES FOLDER generator/tools)
+ #add_test (NAME h5extend_gentest COMMAND $<TARGET_FILE:h5extend_gentest>)
+ add_subdirectory (${HDF5_TOOLS_MISC_SOURCE_DIR}/vds)
endif (HDF5_BUILD_GENERATORS)
add_executable (h5repart_test ${HDF5_TOOLS_MISC_SOURCE_DIR}/repart_test.c)
@@ -63,6 +76,12 @@ if (BUILD_TESTING)
target_link_libraries (h5repart_test ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET})
set_target_properties (h5repart_test PROPERTIES FOLDER tools)
+ add_executable (h5extend_test ${HDF5_TOOLS_MISC_SOURCE_DIR}/repart_test.c)
+ TARGET_NAMING (h5extend_test ${LIB_TYPE})
+ TARGET_C_PROPERTIES (h5extend_test " " " ")
+ target_link_libraries (h5extend_test ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET})
+ set_target_properties (h5extend_test PROPERTIES FOLDER tools)
+
include (CMakeTests.cmake)
endif (BUILD_TESTING)
@@ -78,10 +97,11 @@ endif (BUILD_TESTING)
#INSTALL_PROGRAM_PDB (h5debug ${HDF5_INSTALL_BIN_DIR} toolsapplications)
#INSTALL_PROGRAM_PDB (h5repart ${HDF5_INSTALL_BIN_DIR} toolsapplications)
+#INSTALL_PROGRAM_PDB (h5extend ${HDF5_INSTALL_BIN_DIR} toolsapplications)
#INSTALL_PROGRAM_PDB (h5mkgrp ${HDF5_INSTALL_BIN_DIR} toolsapplications)
install (
TARGETS
- h5debug h5repart h5mkgrp
+ h5debug h5repart h5mkgrp h5extend
RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT toolsapplications
)
diff --git a/tools/misc/Makefile.am b/tools/misc/Makefile.am
index fdfe8f7..eb785a5 100644
--- a/tools/misc/Makefile.am
+++ b/tools/misc/Makefile.am
@@ -26,21 +26,22 @@ SUBDIRS=vds
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_PROG=h5repart_gentest h5extend_gentest talign
+TEST_SCRIPT=testh5repart.sh testh5mkgrp.sh testh5extend.sh
check_PROGRAMS=$(TEST_PROG) repart_test
check_SCRIPTS=$(TEST_SCRIPT)
-SCRIPT_DEPEND=h5repart$(EXEEXT) h5mkgrp$(EXEEXT)
+SCRIPT_DEPEND=h5repart$(EXEEXT) h5mkgrp$(EXEEXT) h5extend$(EXEEXT)
# These are our main targets, the tools
-bin_PROGRAMS=h5debug h5repart h5mkgrp
+bin_PROGRAMS=h5debug h5repart h5mkgrp h5extend
bin_SCRIPTS=h5redeploy
# 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)
+h5extend_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
# Tell automake to clean h5redeploy script
CLEANFILES=h5redeploy
@@ -51,7 +52,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 testh5extend.sh
# All programs rely on hdf5 library and h5tools library
LDADD=$(LIBH5TOOLS) $(LIBHDF5)
diff --git a/tools/misc/h5extend.c b/tools/misc/h5extend.c
new file mode 100644
index 0000000..6993efb
--- /dev/null
+++ b/tools/misc/h5extend.c
@@ -0,0 +1,288 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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: Mike McGreevy
+ * March 2, 2011
+ *
+ * Purpose: Reads the 'EOA' message stored in the superblock
+ * extension of a file, and extends the file via a truncate
+ * call to this size. The 'EOA' message is then either updated
+ * with the new value, or removed entirely. (based on user input).
+ *
+ */
+
+#include "hdf5.h"
+#include "h5tools.h"
+#include "h5tools_utils.h"
+#include "H5Iprivate.h"
+#define H5F_FRIEND /*suppress error about including H5Fpkg */
+#include "H5Fpkg.h"
+
+/* Name of tool */
+#define PROGRAMNAME "h5extend"
+
+
+/*-------------------------------------------------------------------------
+ * Function: usage
+ *
+ * Purpose: Prints a usage message.
+ *
+ * Return: void
+ *
+ * Programmer: Mike McGreevy
+ * March 2, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+usage(FILE * outputfile)
+{
+ HDfprintf(outputfile, "%s [OPTIONS] SRC\n", h5tools_getprogname());
+ HDfprintf(outputfile, " OPTIONS:\n");
+ HDfprintf(outputfile, " -h, --help Display this help message.\n");
+ HDfprintf(outputfile, " -r, --remove Remove 'EOA' message from superblock extension.\n");
+ HDfprintf(outputfile, " -e, --extend Extend the file to match its 'EOA' value.\n");
+ HDfprintf(outputfile, " -q, --quiet Work without displaying standard output.\n");
+} /* usage */
+
+
+/*-------------------------------------------------------------------------
+ * Function: leave
+ *
+ * Purpose: Shutdown MPI and/or HDF5 and call exit()
+ *
+ * Return: Does not return
+ *
+ * Programmer: Quincey Koziol, 2/13/2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+leave(int ret)
+{
+ h5tools_close();
+ exit(ret);
+} /* end leave() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose: Main 'h5extend' tool.
+ *
+ * Return: Success: EXIT_SUCCESS
+ * Failure: EXIT_FAILURE
+ *
+ * Programmer: Mike McGreevy
+ * March 2, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(int argc, const char *argv[])
+{
+ hbool_t should_truncate = FALSE; /* Flag indicating if EOA and EOF are not equal */
+ hbool_t quiet = FALSE; /* Flag indicating 'quiet' output */
+ hbool_t rm_msg = FALSE; /* Flag indicating EOA message should be removed */
+ hbool_t extend = FALSE; /* Flag indicating file should be extended */
+ const char *filename; /* Source file name */
+ int argno = 1; /* Program argument number */
+ hid_t fid = -1; /* HDF5 file ID for file to operate on */
+ H5F_t * f = NULL; /* Internal file pointer for HDF5 file */
+ FILE * outputfile = stdout; /* File handle for normal output */
+ FILE * errorfile = stderr; /* File handle for error output */
+
+ /* Disable the HDF5 library's error reporting */
+ H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
+
+ /* Initialize h5tools lib */
+ h5tools_init();
+
+ /* Set program name */
+ h5tools_setprogname(PROGRAMNAME);
+
+ /* Parse Switches */
+ while(argno < argc && '-' == argv[argno][0]) {
+ if((!HDstrcmp(argv[argno], "-e")) || (!HDstrcmp(argv[argno], "--extend"))) {
+ extend = TRUE;
+ argno++;
+ } /* end if */
+ else if((!HDstrcmp(argv[argno], "-r")) || (!HDstrcmp(argv[argno], "--remove"))) {
+ rm_msg = TRUE;
+ argno++;
+ } /* end else if */
+ else if((!HDstrcmp(argv[argno], "-q")) || (!HDstrcmp(argv[argno], "--quiet"))) {
+ quiet = TRUE;
+ argno++;
+ } /* end else if */
+ else if((!HDstrcmp(argv[argno], "-h")) || (!HDstrcmp(argv[argno], "--help"))) {
+ usage(outputfile);
+ leave(EXIT_SUCCESS);
+ } /* end else if */
+ else {
+ error_msg("Unrecognized option '%s' provided.\n", argv[argno]);
+ usage(errorfile);
+ leave(EXIT_FAILURE);
+ } /* end else */
+ } /* end while */
+
+ /* Print usage if file name is missing */
+ if(argno >= argc) {
+ error_msg("No file provided.\n");
+ usage(errorfile);
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Get the name of the source file */
+ filename = argv[argno++];
+
+ /* Open File */
+ if((fid = h5tools_fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT, NULL, NULL, 0)) < 0) {
+ error_msg("Unable to open source file '%s'.\n", filename);
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Get internal file pointer */
+ if((f = (H5F_t *)H5I_object(fid)) == NULL) {
+ error_msg("Unable to get internal file pointer.\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* If a SB extension exists check for EOA message */
+ if(f->shared->sblock->ext_addr != HADDR_UNDEF) {
+ H5O_loc_t ext_loc; /* "Object location" for superblock extension */
+ H5O_eoa_t eoa_msg; /* 'EOA' Message' */
+ haddr_t filesize; /* 'Actual' size of the file (max of EOA & EOF) */
+ haddr_t eof; /* EOF value for the file */
+ H5FD_mem_t mt;
+
+ /* Open the superblock extension */
+ if(H5F_super_ext_open(f, f->shared->sblock->ext_addr, &ext_loc) < 0) {
+ error_msg("Unable to open superblock extension.\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Check to see if there is an 'EOA' message */
+ if(H5O_msg_exists(&ext_loc, H5O_EOA_ID, H5AC_dxpl_id)) {
+ /* Retrieve 'EOA' message */
+ if(H5O_msg_read(&ext_loc, H5O_EOA_ID, &eoa_msg, H5AC_dxpl_id) == NULL) {
+ error_msg("Unable to read 'EOA' message in superblock extension.\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ if(!quiet)
+ HDfprintf(outputfile, " Superblock extension contains 'EOA' message\n");
+
+ if(f->shared->feature_flags & H5FD_FEAT_MULTIPLE_MEM_TYPE_BACKENDS) {
+ for(mt = H5FD_MEM_SUPER; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) {
+ if((eof = H5FDget_eof(f->shared->lf, mt)) == HADDR_UNDEF) {
+ error_msg("Unable to determine 'EOF' message from file driver.\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ if(!quiet)
+ HDfprintf(outputfile, " %d: EOA = %a EOF = %a\n", mt, eoa_msg.memb_eoa[mt-1], eof);
+
+ if(eof != eoa_msg.memb_eoa[mt-1])
+ should_truncate = TRUE;
+ } /* end for */
+ } /* end if */
+ else {
+ if((eof = H5FDget_eof(f->shared->lf, H5FD_MEM_SUPER)) == HADDR_UNDEF) {
+ error_msg("Unable to determine 'EOF' message from file driver.\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ if(!quiet)
+ HDfprintf(outputfile, " EOA = %a EOF = %a\n", eoa_msg.memb_eoa[0], eof);
+
+ /* Get file size */
+ if(H5Fget_filesize(fid, &filesize) < 0) {
+ error_msg("Unable to retrieve file size.\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+ if(!quiet)
+ HDfprintf(outputfile, " File size = %a\n", filesize);
+
+ if(eoa_msg.memb_eoa[0] != eof)
+ should_truncate = TRUE;
+ } /* end else */
+
+ /* If requested, remove the 'EOA' message from the superblock extension */
+ if(rm_msg) {
+ if(H5O_msg_remove(&ext_loc, H5O_EOA_ID, H5O_ALL, TRUE, H5AC_dxpl_id) < 0) {
+ error_msg("Unable to remove 'EOA' message.\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+ if(!quiet)
+ HDfprintf(outputfile, " Removed 'EOA' message from superblock extension.\n");
+ } /* end if */
+ } /* end if */
+ else {
+ if(!quiet)
+ HDfprintf(outputfile, " No 'EOA' message contained in this file.\n");
+ } /* end else */
+
+ /* Close superblock extension */
+ if(H5F_super_ext_close(f, &ext_loc, H5AC_dxpl_id, FALSE) < 0) {
+ error_msg("Unable to close superblock extension.\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+ } /* end if */
+
+ /* Extend the file, if requested */
+ if(extend) {
+ /* truncate file to match 'EOA' value */
+ if(should_truncate) {
+ if(!quiet) {
+ HDfprintf(outputfile, " Truncating file to match EOA\n");
+ } /* end if */
+
+ if(H5FDtruncate(f->shared->lf, H5AC_dxpl_id, 0) < 0) {
+ error_msg("Unable to truncate file.\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Mark superblock dirty, so on file close it is re-written with new filesize value */
+ if(H5F_super_dirty(f) < 0) {
+ error_msg("Unable to mark file superblock dirty.\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+ } /* end if */
+ else {
+ if(!quiet)
+ HDfprintf(outputfile," EOA and EOF are already the same. Taking no action to extend the file.\n");
+ } /* end else */
+ } /* end if */
+ else {
+ /* Suggest extending the file if EOA/EOF do not match (and request to remove/extend not already made) */
+ if(!rm_msg && should_truncate)
+ if(!quiet)
+ HDfprintf(outputfile, " EOA and EOF do not match! Suggest extending the file for backward compatibility.\n");
+ } /* end else */
+
+ /* Close File */
+ if(H5Fclose(fid) < 0) {
+ error_msg("Failed while closing file.\n");
+ leave(EXIT_FAILURE);
+ } /* end if */
+
+ /* Shut down h5tools lib */
+ h5tools_close();
+
+ return EXIT_SUCCESS;
+} /* main */
+
diff --git a/tools/misc/h5extend_gentest.c b/tools/misc/h5extend_gentest.c
new file mode 100644
index 0000000..b4d98fe
--- /dev/null
+++ b/tools/misc/h5extend_gentest.c
@@ -0,0 +1,98 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * 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. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*********************************************************************
+*
+* Purpose: Create testfile for use with the h5extend tests.
+*
+* Developer: Mike McGreevy
+* March 3, 2011
+*
+*********************************************************************/
+
+#include "hdf5.h"
+#include "H5private.h"
+
+#define TESTFILE "h5extend_tfile.h5"
+#define TESTFILE_MULTI "h5extend_multifile.h5"
+
+static int create_file (hid_t fapl, const char* filename);
+
+int main(void)
+{
+ hid_t fapl;
+
+ if(create_file(H5P_DEFAULT, TESTFILE) < 0)
+ return -1;
+
+ /* create a multi file driver */
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS))<0)
+ return -1;
+
+ if (H5Pset_fapl_multi(fapl, NULL, NULL, NULL, NULL, TRUE) < 0)
+ return -1;
+
+ if(create_file(fapl, TESTFILE_MULTI) < 0)
+ return -1;
+
+ if(H5Pclose(fapl) < 0)
+ return -1;
+
+ /* Return */
+ return 0;
+} /* main */
+
+static int create_file (hid_t fapl, const char* filename)
+{
+ /* Variables */
+ hid_t fcpl,fid,sid,did = -1; /* Object Descriptors */
+
+ /* Create a file creation property list */
+ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) return -1;
+
+ /* Enable 'avoid truncate' feature */
+ if (H5Pset_avoid_truncate(fcpl, H5F_AVOID_TRUNCATE_ALL) < 0) return -1;
+
+ /* Create a file that avoids truncation */
+ if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
+ return -1;
+
+ /* Close the fcpl */
+ if (H5Pclose(fcpl) < 0) return -1;
+
+ /* Create dataspace for dataset */
+ if ((sid = H5Screate(H5S_SCALAR)) < 0) return -1;
+
+ /* Create dataset */
+ if ((did = H5Dcreate2(fid, "Dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT,
+ H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1;
+
+ /* Close the file, dataspace, and dataset */
+ if(H5Sclose(sid) < 0) return -1;
+ if(H5Dclose(did) < 0) return -1;
+
+ if(H5Fclose(fid) < 0) return -1;
+
+ /* Re-open file */
+ if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) return -1;
+
+ /* Unlink the dataset, reducing the 'EOA' value (but not EOF) */
+ if (H5Ldelete(fid, "Dataset", H5P_DEFAULT) < 0) return -1;
+
+ /* Close file */
+ if (H5Fclose(fid) < 0) return -1;
+
+ return 0;
+}
diff --git a/tools/misc/testh5extend.sh.in b/tools/misc/testh5extend.sh.in
new file mode 100644
index 0000000..35523f2
--- /dev/null
+++ b/tools/misc/testh5extend.sh.in
@@ -0,0 +1,137 @@
+#! /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 h5extend tool
+
+TESTNAME=h5extend
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+
+EXTEND=h5extend # The tool name
+EXTEND_BIN=`pwd`/$EXTEND # The path of the tool binary
+
+EXTENDED_TEST=extend_test # The test name
+EXTENDED_TEST_BIN=`pwd`/$EXTENDED_TEST # The path of the test binary
+
+CMP='cmp -s'
+DIFF='diff -c'
+
+nerrors=0
+verbose=yes
+
+# The build (current) directory might be different than the source directory.
+if test -z "$srcdir"; then
+ srcdir=.
+fi
+
+test -d ../testfiles || mkdir ../testfiles
+
+actual_dir=`pwd`/../testfiles
+
+# 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() {
+
+ expect="$srcdir/../testfiles/$1"
+ actual="../testfiles/`basename $1 .ddl`.out"
+ actual_err="../testfiles/`basename $1 .ddl`.err"
+ shift
+
+ # Run tool test.
+ TESTING $EXTEND $@
+ (
+ echo "#############################"
+ echo "Expected output for '$EXTEND $@'"
+ echo "#############################"
+ #cd $srcdir/../testfiles
+ $RUNSERIAL $EXTEND_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
+ elif $CMP $expect $actual; 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
+
+ # Clean up output file
+ if test -z "$HDF5_NOCLEANUP"; then
+ rm -f $actual $actual_err
+ fi
+}
+
+OUTPUTTEST() {
+ # Run test program.
+ TESTING $EXTENDED_TEST $@
+ (
+ cd $actual_dir
+ $RUNSERIAL $EXTENDED_TEST_BIN $@
+ )
+
+ if test $? -eq 0; then
+ echo " PASSED"
+ else
+ echo " FAILED"
+ nerrors=`expr $nerrors + 1`
+ fi
+}
+
+# Print a "SKIP" message
+SKIP() {
+ TESTING $EXTEND $@
+ echo " -SKIP-"
+}
+
+##############################################################################
+##############################################################################
+### T H E T E S T S ###
+##############################################################################
+##############################################################################
+
+TOOLTEST h5extend_exp1.ddl h5extend_tfile.h5
+TOOLTEST h5extend_exp2.ddl -e h5extend_tfile.h5
+TOOLTEST h5extend_exp3.ddl h5extend_tfile.h5
+TOOLTEST h5extend_exp4.ddl -r h5extend_tfile.h5
+TOOLTEST h5extend_exp5.ddl h5extend_tfile.h5
+
+TOOLTEST h5extend_multiexp1.ddl h5extend_multifile.h5
+TOOLTEST h5extend_multiexp2.ddl -e h5extend_multifile.h5
+TOOLTEST h5extend_multiexp3.ddl h5extend_multifile.h5
+TOOLTEST h5extend_multiexp4.ddl -r h5extend_multifile.h5
+TOOLTEST h5extend_multiexp5.ddl h5extend_multifile.h5
+
+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