summaryrefslogtreecommitdiffstats
path: root/hl/tools/h5watch
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2013-11-21 16:45:39 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2013-11-21 16:45:39 (GMT)
commit10d221961cd178734d674cb7d20465374ac37afd (patch)
tree000d00478c76f25f0e04f1aa78719d8e4a4dba08 /hl/tools/h5watch
parent819a5d610b9f1cf6ce454b66b836ec6be678028a (diff)
downloadhdf5-10d221961cd178734d674cb7d20465374ac37afd.zip
hdf5-10d221961cd178734d674cb7d20465374ac37afd.tar.gz
hdf5-10d221961cd178734d674cb7d20465374ac37afd.tar.bz2
[svn-r24459] Checkin for bug fix SWMR-11: used message file to coordinate test runs for h5watch.
The changes were initially done as part of the file locking implementation. This is a merge from the revise_chunks #24454. In addition, a bug fix when enable-production in test/tfile.c-- --test_swmr_write(): use latest format in creating the test files
Diffstat (limited to 'hl/tools/h5watch')
-rw-r--r--hl/tools/h5watch/Makefile.am8
-rw-r--r--hl/tools/h5watch/Makefile.in9
-rw-r--r--hl/tools/h5watch/extend_dset.c109
-rw-r--r--hl/tools/h5watch/h5watch.c35
-rw-r--r--hl/tools/h5watch/h5watchgentest.c40
-rw-r--r--hl/tools/h5watch/testh5watch.sh.in370
6 files changed, 356 insertions, 215 deletions
diff --git a/hl/tools/h5watch/Makefile.am b/hl/tools/h5watch/Makefile.am
index 16dfe23..2f4b163 100644
--- a/hl/tools/h5watch/Makefile.am
+++ b/hl/tools/h5watch/Makefile.am
@@ -24,9 +24,7 @@ include $(top_srcdir)/config/commence.am
INCLUDES=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib -I$(top_srcdir)/hl/src
# These are our main targets, the tools
-#TEST_PROG=h5watchgentest
TEST_SCRIPT=testh5watch.sh
-#check_PROGRAMS=h5watchgentest
check_SCRIPTS=$(TEST_SCRIPT)
SCRIPT_DEPEND=h5watch$(EXEEXT)
@@ -38,16 +36,14 @@ h5watch_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
h5watch_SOURCES=h5watch.c
-#gen_onetwo_test_SOURCES=gen_onetwo_test.c
h5watchgentest_SOURCES=h5watchgentest.c
extend_dset_SOURCES=extend_dset.c
-#extend_one_SOURCES=extend_one.c
-#extend_two_SOURCES=extend_two.c
# Programs all depend on the hdf5 library, the tools library, and the HL
# library.
LDADD=$(LIBH5_HL) $(LIBH5TOOLS) $(LIBHDF5)
-
+#
+CHECK_CLEANFILES+=*.h5
DISTCLEANFILES=testh5watch.sh
include $(top_srcdir)/config/conclude.am
diff --git a/hl/tools/h5watch/Makefile.in b/hl/tools/h5watch/Makefile.in
index 1725cd0..0e2400b 100644
--- a/hl/tools/h5watch/Makefile.in
+++ b/hl/tools/h5watch/Makefile.in
@@ -433,27 +433,22 @@ TRACE = perl $(top_srcdir)/bin/trace
# .chkexe files are used to mark tests that have run successfully.
# .chklog files are output from those tests.
# *.clog are from the MPE option.
-CHECK_CLEANFILES = *.chkexe *.chklog *.clog
+#
+CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.h5
# Include src and tools/lib directories
INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/tools/lib -I$(top_srcdir)/hl/src
# These are our main targets, the tools
-#TEST_PROG=h5watchgentest
TEST_SCRIPT = testh5watch.sh
-#check_PROGRAMS=h5watchgentest
check_SCRIPTS = $(TEST_SCRIPT)
SCRIPT_DEPEND = h5watch$(EXEEXT)
# Add h5watch specific linker flags here
h5watch_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
h5watch_SOURCES = h5watch.c
-
-#gen_onetwo_test_SOURCES=gen_onetwo_test.c
h5watchgentest_SOURCES = h5watchgentest.c
extend_dset_SOURCES = extend_dset.c
-#extend_one_SOURCES=extend_one.c
-#extend_two_SOURCES=extend_two.c
# Programs all depend on the hdf5 library, the tools library, and the HL
# library.
diff --git a/hl/tools/h5watch/extend_dset.c b/hl/tools/h5watch/extend_dset.c
index b58dce8..79b06a0 100644
--- a/hl/tools/h5watch/extend_dset.c
+++ b/hl/tools/h5watch/extend_dset.c
@@ -4,6 +4,7 @@
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
+#include <time.h>
/*
* Extending datasets in WATCH.h5 generated by h5watchgentest.c
@@ -13,10 +14,16 @@
#define DSET_CMPD "DSET_CMPD"
#define DSET_CMPD_ESC "DSET_CMPD_ESC"
#define DSET_CMPD_TWO "DSET_CMPD_TWO"
-
#define DSET_ALLOC_LATE "DSET_ALLOC_LATE"
#define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY"
+/* The message sent by this process (extend_dset) to the test script to start "h5watch" */
+#define WRITER_MESSAGE "writer_message"
+/* The message received from the test script to start extending dataset */
+#define READER_MESSAGE "reader_message"
+/* Message timeout in seconds */
+#define MESSAGE_TIMEOUT 300
+
/* Size of data buffer */
#define TEST_BUF_SIZE 100
@@ -41,6 +48,9 @@ int two_tests[TWO_NTESTS][2] = { {2, 2}, {2, -11}, {2, 0},
static int extend_dset_two(const char *file, char *dname);
static int extend_dset_one(const char *file, char *dname);
+void send_message(const char *file);
+static int wait_message(const char *file);
+
/* Data structures for datasets with compound data type */
typedef struct sub22_t {
@@ -68,6 +78,54 @@ typedef struct set_t {
} set_t;
/*
+ * To send a message by creating the file.
+ */
+void
+send_message(const char *file)
+{
+ FILE *id;
+
+ id = fopen(file, "w+");
+ fclose(id);
+} /* send_message() */
+
+/*
+ *
+ * Repeatedly check for the message file.
+ * It will stop when the file exists or exceeds the timeout limit.
+ */
+static int
+wait_message(const char *file)
+{
+ FILE *id; /* File pointer */
+ time_t t0, t1; /* Time info */
+
+ /* Start timer */
+ time(&t0);
+
+ /* Wait for message from test script to start work */
+ while((id = fopen(file, "r")) == NULL) {
+ /* Get current time */
+ time(&t1);
+ /*
+ * Determine time difference--
+ * if waiting too long for the message, then it is
+ * unlikely the message will get sent, then fail rather
+ * than loop forever.
+ */
+ if(difftime(t1, t0) > MESSAGE_TIMEOUT)
+ goto done;
+ }
+
+ fclose(id);
+ unlink(file);
+ return(SUCCEED);
+
+done:
+ return(FAIL);
+} /* wait_message() */
+
+/*
***********************************************************************
*
* Extending a two-dimensional dataset:
@@ -94,7 +152,8 @@ typedef struct set_t {
static int
extend_dset_two(const char *file, char *dname)
{
- hid_t fid; /* file id */
+ hid_t fid = -1; /* file id */
+ hid_t fapl = -1; /* file access property list id */
hid_t did; /* dataset id */
hid_t sid; /* dataspace id */
hid_t dtid; /* dataset's datatype id */
@@ -107,13 +166,24 @@ extend_dset_two(const char *file, char *dname)
int ibuf[TEST_BUF_SIZE]; /* buffer for storing retrieved elements (integer) */
set_t cbuf[TEST_BUF_SIZE]; /* buffer for storing retrieved elemnets (compound) */
- /* Open the file and dataset */
- if((fid = H5Fopen(file, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ /* Create a copy of file access property list */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ return -1;
+
+ /* Set to use the latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ return -1;
+
+ /* Open the file and dataset with SWMR write */
+ if((fid = H5Fopen(file, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0)
goto done;
if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
goto done;
+ /* Send message to the test script to start "h5watch" */
+ send_message(WRITER_MESSAGE);
+
if((sid = H5Dget_space(did)) < 0)
goto done;
@@ -128,6 +198,10 @@ extend_dset_two(const char *file, char *dname)
if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
goto done;
+ /* Wait for message from the test script to start extending dataset */
+ if(wait_message(READER_MESSAGE) < 0)
+ goto done;
+
/* Loop through different variations of extending the dataset */
for(i = 0; i < TWO_NTESTS; i++) {
@@ -187,6 +261,7 @@ extend_dset_two(const char *file, char *dname)
/* Closing */
if(H5Tclose(dtid) < 0) goto done;
if(H5Dclose(did) < 0) goto done;
+ if(H5Pclose(fapl) < 0) goto done;
if(H5Fclose(fid) < 0) goto done;
return(SUCCEED);
@@ -195,6 +270,7 @@ done:
H5E_BEGIN_TRY
H5Tclose(dtid);
H5Dclose(did);
+ H5Pclose(fapl);
H5Fclose(fid);
H5E_END_TRY
@@ -221,7 +297,8 @@ done:
static int
extend_dset_one(const char *file, char *dname)
{
- hid_t fid; /* file id */
+ hid_t fid = -1; /* file id */
+ hid_t fapl = -1; /* file access property list id */
hid_t did; /* dataset id */
hid_t dtid; /* dataset's datatype id */
hid_t sid; /* dataspace id */
@@ -235,10 +312,20 @@ extend_dset_one(const char *file, char *dname)
hsize_t count[1]; /* dimension sizes of appended data */
size_t dtype_size; /* size of the dataset's datatype */
- /* Open the file and dataset */
- if((fid = H5Fopen(file, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ /* Create a copy of file access property list */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ return -1;
+ /* Set to use the latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ return -1;
+
+ /* Open the file and dataset with SWMR write */
+ if((fid = H5Fopen(file, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0)
goto done;
+ /* Send message to the test script to start "h5watch" */
+ send_message(WRITER_MESSAGE);
+
if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
goto done;
@@ -250,6 +337,9 @@ extend_dset_one(const char *file, char *dname)
if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
goto done;
+ /* Wait for message from the test script to start extending dataset */
+ wait_message(READER_MESSAGE);
+
/* Loop through different variations of extending the dataset */
for(i = 0; i < ONE_NTESTS; i++) {
@@ -325,6 +415,7 @@ extend_dset_one(const char *file, char *dname)
/* Closing */
if(H5Tclose(dtid) < 0) goto done;
if(H5Dclose(did) < 0) goto done;
+ if(H5Pclose(fapl) < 0) goto done;
if(H5Fclose(fid) < 0) goto done;
return(SUCCEED);
@@ -335,6 +426,7 @@ done:
H5Sclose(mid);
H5Tclose(dtid);
H5Dclose(did);
+ H5Pclose(fapl);
H5Fclose(fid);
H5E_END_TRY
@@ -358,7 +450,8 @@ main(int argc, const char *argv[])
dname = strdup(argv[2]);
if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) {
- if(extend_dset_one(fname, dname) < 0) goto done;
+ if(extend_dset_one(fname, dname) < 0)
+ goto done;
} else if(!HDstrcmp(dname, DSET_ONE) ||
!HDstrcmp(dname, DSET_ALLOC_LATE) ||
!HDstrcmp(dname, DSET_ALLOC_EARLY)) {
diff --git a/hl/tools/h5watch/h5watch.c b/hl/tools/h5watch/h5watch.c
index 8b33fa3..d2a117d 100644
--- a/hl/tools/h5watch/h5watch.c
+++ b/hl/tools/h5watch/h5watch.c
@@ -21,9 +21,6 @@
#include "h5tools.h"
#include "h5tools_dump.h"
-#include "h5tools_utils.h"
-#include "h5tools_ref.h"
-#include "h5trav.h"
#include "H5LDprivate.h"
/*
@@ -367,7 +364,7 @@ monitor_dataset(hid_t fid, char *dsetname)
if(i != ndims) {
/* Printing changes in dimension sizes */
for(u = 0; u < ndims; u++) {
- HDfprintf(stdout, "dimension %u: %Hu->%Hu", u, prev_dims[u], cur_dims[u]);
+ HDfprintf(stdout, "dimension %u: %Hu->%Hu", (unsigned)u, prev_dims[u], cur_dims[u]);
if(cur_dims[u] > prev_dims[u])
HDfprintf(stdout, " (increases)\n");
else if(cur_dims[u] < prev_dims[u])
@@ -434,8 +431,8 @@ done:
static herr_t
process_cmpd_fields(hid_t fid, char *dsetname)
{
- hid_t did; /* dataset id */
- hid_t dtid, tid; /* dataset's data type id */
+ hid_t did=-1; /* dataset id */
+ hid_t dtid=-1, tid=-1; /* dataset's data type id */
size_t len; /* number of comma-separated fields in "g_list_of_fields" */
herr_t ret_value = SUCCEED; /* Return value */
@@ -516,9 +513,9 @@ done:
static herr_t
check_dataset(hid_t fid, char *dsetname)
{
- hid_t did=-1; /* Dataset id */
- hid_t dcp=-1; /* Dataset creation property */
- hid_t sid=-1; /* Dataset's dataspace id */
+ hid_t did=-1; /* Dataset id */
+ hid_t dcp=-1; /* Dataset creation property */
+ hid_t sid=-1; /* Dataset's dataspace id */
int ndims; /* # of dimensions in the dataspace */
unsigned u; /* Local index variable */
hsize_t cur_dims[H5S_MAX_RANK]; /* size of dataspace dimensions */
@@ -804,6 +801,7 @@ main(int argc, const char *argv[])
H5E_auto2_t func;
char *x;
hid_t fid = -1;
+ hid_t fapl = -1;
/* Set up tool name and exit status */
h5tools_setprogname(PROGRAMNAME);
@@ -846,9 +844,17 @@ main(int argc, const char *argv[])
h5tools_setstatus(EXIT_FAILURE);
}
+ /* Create a copy of file access property list */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ return -1;
+
+ /* Set to use the latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ return -1;
+
do {
while(fname && *fname) {
- fid = h5tools_fopen(fname, H5F_ACC_SWMR_READ, H5P_DEFAULT, NULL, drivername, sizeof drivername);
+ fid = h5tools_fopen(fname, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl, NULL, drivername, sizeof drivername);
if(fid >= 0) {
HDfprintf(stdout, "Opened \"%s\" with %s driver.\n", fname, drivername);
@@ -869,7 +875,8 @@ main(int argc, const char *argv[])
if(fid < 0) {
error_msg("unable to open file \"%s\"\n", fname);
- HDfree(fname);
+ if(fname) HDfree(fname);
+ if(fapl >= 0) H5Pclose(fapl);
leave(EXIT_FAILURE);
}
@@ -910,6 +917,12 @@ main(int argc, const char *argv[])
}
if(g_dup_fields) HDfree(g_dup_fields);
+ /* Close the file access property list */
+ if(fapl >= 0 && H5Pclose(fapl) < 0) {
+ error_msg("unable to close file access property list\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ }
+
/* Close the file */
if(H5Fclose(fid) < 0) {
error_msg("unable to close file\n");
diff --git a/hl/tools/h5watch/h5watchgentest.c b/hl/tools/h5watch/h5watchgentest.c
index 19c73b5..c4bb7d7 100644
--- a/hl/tools/h5watch/h5watchgentest.c
+++ b/hl/tools/h5watch/h5watchgentest.c
@@ -100,9 +100,9 @@ typedef struct set_t {
static int
generate_dset(hid_t fid, const char *dname, int ndims, hsize_t *dims, hsize_t *maxdims, hid_t dtid, void *data)
{
- hid_t dcpl; /* Dataset creation property */
- hid_t did; /* Dataset id */
- hid_t sid; /* Dataspace id */
+ hid_t dcpl=-1; /* Dataset creation property */
+ hid_t did=-1; /* Dataset id */
+ hid_t sid=-1; /* Dataspace id */
int i; /* Local index variable */
hsize_t chunk_dims[H5S_MAX_RANK]; /* Dimension sizes for chunks */
@@ -158,23 +158,31 @@ done:
int
main(void)
{
- hid_t fid; /* File id */
- hsize_t cur_dims[1]; /* Dimension sizes */
- hsize_t max_dims[1]; /* Maximum dimension sizes */
- hsize_t cur2_dims[2]; /* Current dimension sizes */
- hsize_t max2_dims[2]; /* Maximum dimension sizes */
- hid_t set_tid, esc_set_tid; /* Compound type id */
- hid_t sub22_tid; /* Compound type id */
- hid_t sub2_tid, esc_sub2_tid; /* Compound type id */
- hid_t sub4_tid, esc_sub4_tid; /* Compound type id */
+ hid_t fid=-1; /* File id */
+ hid_t fapl=-1; /* File access property list id */
+ hsize_t cur_dims[1]; /* Dimension sizes */
+ hsize_t max_dims[1]; /* Maximum dimension sizes */
+ hsize_t cur2_dims[2]; /* Current dimension sizes */
+ hsize_t max2_dims[2]; /* Maximum dimension sizes */
+ hid_t set_tid=-1, esc_set_tid=-1; /* Compound type id */
+ hid_t sub22_tid=-1; /* Compound type id */
+ hid_t sub2_tid=-1, esc_sub2_tid=-1; /* Compound type id */
+ hid_t sub4_tid=-1, esc_sub4_tid=-1; /* Compound type id */
int one_data[ONE_DIMS0]; /* Buffer for data */
int two_data[TWO_DIMS0*TWO_DIMS1]; /* Buffer for data */
set_t one_cbuf[ONE_DIMS0]; /* Buffer for data with compound type */
set_t two_cbuf[TWO_DIMS0*TWO_DIMS1]; /* Buffer for data with compound type */
- int i; /* Local index variable */
+ int i; /* Local index variable */
- /* Create a file */
- if((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ /* Create a copy of file access property list */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ return -1;
+ /* Set to use the latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ return -1;
+
+ /* Create a file with the latest format */
+ if((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
goto done;
/* Initialization for one-dimensional dataset */
@@ -325,6 +333,7 @@ main(void)
if(H5Tclose(esc_sub2_tid) < 0) goto done;
if(H5Tclose(esc_sub4_tid) < 0) goto done;
if(H5Tclose(esc_set_tid) < 0) goto done;
+ if(H5Pclose(fapl) < 0) goto done;
if(H5Fclose(fid) < 0) goto done;
exit(EXIT_SUCCESS);
@@ -338,6 +347,7 @@ done:
H5Tclose(esc_sub2_tid);
H5Tclose(esc_sub4_tid);
H5Tclose(esc_set_tid);
+ H5Pclose(fapl);
H5Fclose(fid);
H5E_END_TRY
diff --git a/hl/tools/h5watch/testh5watch.sh.in b/hl/tools/h5watch/testh5watch.sh.in
index 8451151..377dd89 100644
--- a/hl/tools/h5watch/testh5watch.sh.in
+++ b/hl/tools/h5watch/testh5watch.sh.in
@@ -17,7 +17,7 @@
#
H5WATCH=h5watch # The tool name
H5WATCH_BIN=`pwd`/$H5WATCH # The path of H5WATCH
-EXTEND_DSET=extend_dset # Helper to extend the dataset when watching
+EXTEND_DSET=extend_dset # Routine to extend the dataset when watching
EXTEND_BIN=`pwd`/$EXTEND_DSET # The path of EXTEND_DSET
#
EXIT_SUCCESS=0
@@ -25,13 +25,16 @@ EXIT_FAILURE=1
#
GEN_TEST=h5watchgentest # Generate HDF5 file with various datasets
GEN_TEST_BIN=`pwd`/$GEN_TEST # Path of the binary GEN_TEST
+WATCHFILE=`pwd`/WATCH.h5 # The HDF5 file generated to test h5watch
+TESTFILE=TEST.h5 # The temporary file (a copy of WATCH.h5) used by tests
+#
+# These 3 defines should be the same as the defines in ./extend_dset.c
+WRITER_MESSAGE=writer_message # The message file created by the "extend" process
+READER_MESSAGE=reader_message # The message file created by the "watch" process
+MESSAGE_TIMEOUT=300 # Message timeout length in secs
#
-
-CP='cp'
CMP='cmp -s'
DIFF='diff -c'
-KILL='kill'
-SLEEP='sleep'
NLINES=20 # Max. lines of output to display if test fails
#
# Mac OS: just to make sure echo "backslash backslash" behaves properly
@@ -40,7 +43,7 @@ if test `uname -s` = 'Darwin'; then
else
ECHO='echo'
fi
-
+#
# Global variables
nerrors=0
verbose=yes
@@ -122,111 +125,101 @@ TOOLTEST() {
rm -f $actual $actual_err
fi
}
-
#
-# TEST_WATCH(): TEST_WATCH $1 $2 $3 $4 $5 ...
-#
-# Arguments:
-# $1 -- number of objects to watch and to extend
-# $2 -- the specified file to watch and to extend
-# (filename varies with $1 suffix)
-# $3 -- the specified dataset to watch and to extend
-# $4 -- the options to h5watch (can be NULL)
-# $5 -- expected output from watching the object
-# ($3, $4, $5) can be repeated for $1 times
#
-# This is done to reduce the sleeping time for testing
+#
+# TEST_WATCH():
+#
+# Arguments:
+# $1 -- the specified dataset to watch and to extend
+# $2 -- the options to h5watch (can be NULL)
+# $3 -- expected output from watching the object
#
TEST_WATCH() {
- plist="" # plist: the list of h5watch process IDs
- dlist="" # dlist: the list of dataset names to watch/extend
- outlist="" # outlist: the list of expected output files with suffix ".ddl" stripped
- xlist="" # xlist: the list of exit codes from extending the dataset
- NUM=$1 # number of objects to watch/extend
- shift
- NFNAME="`basename $1 .h5`" #the file to watch and to extend stripped of suffix ".h5"
- shift
- ctr=1 #counter for tracking the # of objects to test
- while [ $ctr -le $NUM ] ; #loop till end of all objects to test
- do
- actual="../testfiles/`basename $3 .ddl`.out" #the actual output
- outlist="$outlist`basename $3 .ddl` " #store to the list of output names
- dlist="$dlist$1 " #store to the list of datasets
- #
- $CP "$NFNAME.h5" "$NFNAME$ctr.h5" #copy the file to a temporary file
- #
- if test -z "$2"; then #compile options & object to h5watch
- OBJ="$NFNAME$ctr.h5/$1" #no options, just object
- else
- OBJ="$2 $NFNAME$ctr.h5/$1" #option and object
- fi
- #
- # Run h5watch and put in background, output to a file
- #
- TESTING $H5WATCH $OBJ
- $ECHO ""
- $ECHO "#############################" > $actual
- $ECHO " output for '$H5WATCH $OBJ'" >>$actual
- $ECHO "#############################" >>$actual
- $RUNSERIAL $H5WATCH_BIN $2 "$NFNAME$ctr.h5/$1" >> $actual &
- WATCH_PID=$! #get h5watch process ID
- plist="$plist$! " #store to the list of process IDs
- shift; shift; shift
- ctr=`expr $ctr + 1`
- done;
+ cp $WATCHFILE $TESTFILE # Copy the file being watched/extended to a temporary file
+ actual="../testfiles/`basename $3 .ddl`.out" # The actual output
+ expect="$srcdir/../testfiles/$3" # The expected output
#
- # Extend the list of datasets corresponding to the list of files
- n=1;
- for d in $dlist; do
- $EXTEND_BIN "$NFNAME$n.h5" $d
- xlist="$xlist$? " #store to the list of exit codes from extending the dataset
- n=`expr $n + 1`
- done;
- #
- # Sleep to make sure output is flushed out before stopping h5watch
- $ECHO "Sleeping for 4 seconds..."
- $SLEEP 4
+ # Set up options and object to h5watch
+ if test -z "$2"; then
+ OBJ="$TESTFILE/$1" # Empty options, just object to h5watch
+ else
+ OBJ="$2 $TESTFILE/$1" # Options + object to h5watch
+ fi
+ rm -f $WRITER_MESSAGE # Remove the file just to be sure
+ rm -f $READER_MESSAGE # Remove the file just to be sure
#
- # Kill the list of h5watch processes
- $ECHO "Killing h5watch processes..."
- for p in $plist; do #kill the list of h5watch processes
- $KILL $p
- done
+ $EXTEND_BIN $TESTFILE $1 & # Extend the dataset; put in background
+ extend_pid=$! # Get "extend" process ID
#
- # Check the list of return codes from extending the dataset
- # Compare the list of actual output from h5watch with the corresponding expected output
- n=1
- for x in $xlist; do
- outname=`$ECHO $outlist|cut -d' ' -f$n`
- actual="../testfiles/$outname.out"
- expect="$srcdir/../testfiles/$outname.ddl"
- if [ $x -ne 0 ]; then
- $ECHO "*FAILED*"
- nerrors="`expr $nerrors + 1`"
- if [ yes = "$verbose" ]; then
- $ECHO "test returned with exit code $exitcode"
- $ECHO "test output: (up to $NLINES lines)"
-
- head -$NLINES $actual
- $ECHO "***end of test output***"
- $ECHO ""
- fi
- elif $CMP $expect $actual; then
- $ECHO " PASSED"
- else
- $ECHO "*FAILED*"
- $ECHO " Expected result differs from actual result"
- nerrors="`expr $nerrors + 1`"
- test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /'
- fi
- #
- # Cleaning
- rm -f "$NFNAME$n.h5"
- if test -z "$HDF5_NOCLEANUP"; then
- rm -f $actual
- fi
- n="`expr $n + 1`"
+ # Wait for message from "extend_dset" process to start h5watch--
+ # To wait for the writer message file or till the maximum # of seconds is reached
+ # This performs similar function as the routine h5_wait_message() in test/h5test.c
+ mexist=0 # Indicate whether the message file is found
+ t0=`date +%s` # Get current time in seconds
+ difft=0 # Initialize the time difference
+ while [ $difft -lt $MESSAGE_TIMEOUT ] ; # Loop till message times out
+ do
+ t1=`date +%s` # Get current time in seconds
+ difft=`expr $t1 - $t0` # Calculate the time difference
+ if [ -e $WRITER_MESSAGE ]; then # If message file is found:
+ mexist=1 # indicate the message file is found
+ rm $WRITER_MESSAGE # remove the message file
+ break # get out of the while loop
+ fi
done;
+ #
+ # If message file from "extend" process is found--
+ # start h5watch
+ # send message to "extend" process to start work
+ # wait for "extend" process to complete, then kill h5watch
+ # determine test result
+ # If message file from "extend" process is not found--
+ # there is some problem; the test fails
+ #
+ if test $mexist -eq 0; then
+ $ECHO "*FAILED*"
+ $ECHO "Problem with extend_dset...this test failed."
+ else
+ #
+ # Run h5watch; put in background; collect output to a file
+ TESTING $H5WATCH $OBJ
+ head -n 3 $expect > $actual # copy the first 3 lines from $expect (just the command line)
+ $RUNSERIAL $H5WATCH_BIN $2 "$TESTFILE/$1" >> $actual &
+ watch_pid=$! # Get h5watch process ID
+ cp /dev/null $READER_MESSAGE # Send message to "extend" process to start work
+ wait $extend_pid # Wait for "extend" process to complete
+ extend_exit=$? # Collect "extend" process' exit code
+ sleep 1 # Sleep to make sure output is flushed
+ kill $watch_pid # Kill h5watch
+ #
+ if [ $extend_exit -ne 0 ]; then # Error returned from "extend" process
+ $ECHO "*FAILED*"
+ nerrors="`expr $nerrors + 1`"
+ if [ yes = "$verbose" ]; then
+ $ECHO "extend test returned with exit code $extend_exit"
+ $ECHO "test output: (up to $NLINES lines)"
+ head -$NLINES $actual
+ $ECHO "***end of test output***"
+ $ECHO ""
+ fi
+ elif $CMP $expect $actual; then # Compare actual output with expected output
+ $ECHO " PASSED"
+ else
+ $ECHO "*FAILED*" # Actual and expected outputs are different
+ $ECHO " Expected result differs from actual result"
+ nerrors="`expr $nerrors + 1`"
+ if test yes = "$verbose"; then
+ $DIFF $expect $actual |sed 's/^/ /'
+ fi
+ fi
+ #
+ # Cleaning
+ rm -f $TESTFILE
+ if test -z "$HDF5_NOCLEANUP"; then
+ rm -f $actual
+ fi
+ fi
}
##############################################################################
@@ -290,76 +283,117 @@ TOOLTEST w-err-cmpd3.ddl 1 --fields=field1,field2, WATCH.h5/DSET_CMPD
TOOLTEST w-err-cmpd4.ddl 1 --fields=field1,field2.b.k WATCH.h5/DSET_CMPD
TOOLTEST w-err-cmpd5.ddl 1 --fields=field1 --fields=field2.b.k WATCH.h5/DSET_CMPD
#
-#
-#################################################################################################
-# #
-# Tests on extending datasets-- #
-# DSET_ONE, DSET_CMPD, DSET_CMPD_ESC #
-# DSET_ALLOC_EARLY, DSET_ALLOC_LATE #
-# DSET_TWO, DSET_CMPD_TWO #
-# #
-#################################################################################################
-#
-# Generate file with various types of datasets
-$GEN_TEST_BIN
-#
-# Watching and extending: WATCH1.h5/DSET_ONE, WATCH2.h5/DSET_ALLOC_EARLY, WATCH3.h5/DSET_ALLOC_LATE WATCH4.h5/DSET_CMPD
-# : WATCH5.h5/DSET_TWO, WATCH6.h5/DSET_CMPD_TWO, WATCH7.h5/DDSET_CMPD_ESC
-TEST_WATCH 7 WATCH.h5 DSET_ONE '' w-ext-one.ddl DSET_ALLOC_EARLY '' w-ext-early.ddl DSET_ALLOC_LATE '' w-ext-late.ddl DSET_CMPD '' w-ext-cmpd.ddl DSET_TWO '' w-ext-two.ddl DSET_CMPD_TWO '' w-ext-cmpd-two.ddl DSET_CMPD_ESC '' w-ext-cmpd-esc.ddl
-#
-############################
-# Tests on --fields option #
-############################
-#
-# Watching and extending:
-# WATCH1.h5/DSET_CMPD with --fields=field1,field2
-# WATCH2.h5/DSET_CMP_TWO with --fields=field1,field2
-# WATCH3.h5/DSET_CMPD_ESC with --fields=field\,1,field2\.
-# WATCH4.h5/DSET_CMPD with --fields=field1 --fields=field2
-# WATCH5.h5/DSET_CMPD_ESC with --fields=field\,1 --fields=field2\.
-# WATCH6.h5/DSET_CMPD_TWO with --fields=field1 --fields=field2
-#
-TEST_WATCH 6 WATCH.h5 DSET_CMPD --fields=field1,field2 w-ext-cmpd-f1.ddl DSET_CMPD_TWO --fields=field1,field2 w-ext-cmpd-two-f1.ddl DSET_CMPD_ESC '--fields=field\,1,field2\.' w-ext-cmpd-esc-f1.ddl DSET_CMPD '--fields=field1 --fields=field2' w-ext-cmpd-ff1.ddl DSET_CMPD_ESC '--fields=field\,1 --fields=field2\.' w-ext-cmpd-esc-ff1.ddl DSET_CMPD_TWO '--fields=field1 --fields=field2' w-ext-cmpd-two-ff1.ddl
+echo "DONE WITH 1st SET OF TESTS"
#
#
#
-# Watching and extending:
-# WATCH1.h5/DSET_CMPD with --fields=field2.b,field4
-# WATCH2.h5/DSET_CMPD_ESC with --fields=field2\..\,b,field4\
-# WATCH3.h5/DSET_CMPD_TWO with --fields=field2.b,field4
-# WATCH4.h5/DSET_CMPD with --fields=field2.b --fields=field4
-# WATCH5.h5/DSET_CMPD_ESC with --fields=field2\..\,b --fields=field4\,
-# WATCH6.h5/DSET_CMPD_TWO with --fields=field2.b --fields=field4
-TEST_WATCH 6 WATCH.h5 DSET_CMPD --fields=field2.b,field4 w-ext-cmpd-f2.ddl DSET_CMPD_ESC '--fields=field2\..\,b,field4\,' w-ext-cmpd-esc-f2.ddl DSET_CMPD_TWO --fields=field2.b,field4 w-ext-cmpd-two-f2.ddl DSET_CMPD '--fields=field2.b --fields=field4' w-ext-cmpd-ff2.ddl DSET_CMPD_ESC '--fields=field2\..\,b --fields=field4\,' w-ext-cmpd-esc-ff2.ddl DSET_CMPD_TWO '--fields=field2.b --fields=field4' w-ext-cmpd-two-ff2.ddl
+#################################
+# Tests without options #
+#################################
#
+# Generate file WATCH.h5 with various types of datasets,
+$GEN_TEST_BIN
#
-#
-# Watching and extending:
-# WATCH1.h5/DSET_CMPD with --fields=field2.b.a,field2.c
-# WATCH2.h5/DSET_CMPD_ESC with --fields=field2\..\,b.a,field2\..\\K
-# WATCH3.h5/DSET_CMPD_TWO with --fields=field2.b.a,field2.c
-# WATCH4.h5/DSET_CMPD with --fields=field2.b.a --fields=field2.c
-# WATCH5.h5/DSET_CMPD_ESC with --fields=field2\..\,b.a --fields=field2\..\\K
-# WATCH6.h5/DSET_CMPD_TWO with --fields=field2.b.a --fields=field2.c
-TEST_WATCH 6 WATCH.h5 DSET_CMPD --fields=field2.b.a,field2.c w-ext-cmpd-f3.ddl DSET_CMPD_ESC '--fields=field2\..\,b.a,field2\..\\K' w-ext-cmpd-esc-f3.ddl DSET_CMPD_TWO --fields=field2.b.a,field2.c w-ext-cmpd-two-f3.ddl DSET_CMPD '--fields=field2.b.a --fields=field2.c' w-ext-cmpd-ff3.ddl DSET_CMPD_ESC '--fields=field2\..\,b.a --fields=field2\..\\K' w-ext-cmpd-esc-ff3.ddl DSET_CMPD_TWO '--fields=field2.b.a --fields=field2.c' w-ext-cmpd-two-ff3.ddl
-#
-#
-#
-#########################################################
-# #
-# Tests on options: #
-# --dim #
-# --width, --label, --simple, --help #
-# #
-#########################################################
-#
-# Watching and extending:
-# WATCH1.h5/DSET_ONE with -d option
-# WATCH2.h5/DSET_TWO with --dim option
-# WATCH3.h5/DSET_TWO with --width=60 option
-# WATCH4.h5/DSET_CMPD with --label option
-# WATCH5.h5/DSET_ONE with --simple option
-TEST_WATCH 5 WATCH.h5 DSET_ONE --dim w-ext-one-d.ddl DSET_TWO --dim w-ext-two-d.ddl DSET_TWO --width=30 w-ext-two-width.ddl DSET_CMPD --label w-ext-cmpd-label.ddl DSET_ONE --simple w-ext-one-simple.ddl
+# Watching and extending: (TEST.h5 is a copy of WATCH.h5)
+# TEST.h5/DSET_ONE
+# TEST.h5/DSET_ALLOC_EARLY
+# TEST.h5/DSET_ALLOC_LATE
+# TEST.h5/DSET_CMPD
+# TEST.h5/DSET_TWO
+# TEST.h5/DSET_CMPD_TWO
+# TEST.h5/DSET_CMPD_ESC
+#
+TEST_WATCH DSET_ONE '' w-ext-one.ddl
+TEST_WATCH DSET_ALLOC_EARLY '' w-ext-early.ddl
+TEST_WATCH DSET_ALLOC_LATE '' w-ext-late.ddl
+TEST_WATCH DSET_CMPD '' w-ext-cmpd.ddl
+TEST_WATCH DSET_TWO '' w-ext-two.ddl
+TEST_WATCH DSET_CMPD_TWO '' w-ext-cmpd-two.ddl
+TEST_WATCH DSET_CMPD_ESC '' w-ext-cmpd-esc.ddl
+#
+echo "DONE WITH 2nd SET OF TESTS"
+#
+#
+#
+#################################
+# Tests on --fields option #
+#################################
+#
+# Watching and extending: (TEST.h5 is a copy of WATCH.h5)
+# TEST.h5/DSET_CMPD with --fields=field1,field2
+# TEST.h5/DSET_CMP_TWO with --fields=field1,field2
+# TEST.h5/DSET_CMPD_ESC with --fields=field\,1,field2\.
+# TEST.h5/DSET_CMPD with --fields=field1 --fields=field2
+# TEST.h5/DSET_CMPD_ESC with --fields=field\,1 --fields=field2\.
+# TEST.h5/DSET_CMPD_TWO with --fields=field1 --fields=field2
+#
+TEST_WATCH DSET_CMPD --fields=field1,field2 w-ext-cmpd-f1.ddl
+TEST_WATCH DSET_CMPD_TWO --fields=field1,field2 w-ext-cmpd-two-f1.ddl
+TEST_WATCH DSET_CMPD_ESC '--fields=field\,1,field2\.' w-ext-cmpd-esc-f1.ddl
+TEST_WATCH DSET_CMPD '--fields=field1 --fields=field2' w-ext-cmpd-ff1.ddl
+TEST_WATCH DSET_CMPD_ESC '--fields=field\,1 --fields=field2\.' w-ext-cmpd-esc-ff1.ddl
+TEST_WATCH DSET_CMPD_TWO '--fields=field1 --fields=field2' w-ext-cmpd-two-ff1.ddl
+#
+echo "DONE WITH 3rd SET OF TESTS"
+#
+#
+#
+# Watching and extending: (TEST.h5 is a copy of WATCH.h5)
+# TEST.h5/DSET_CMPD with --fields=field2.b,field4
+# TEST.h5/DSET_CMPD_ESC with --fields=field2\..\,b,field4\
+# TEST.h5/DSET_CMPD_TWO with --fields=field2.b,field4
+# TEST.h5/DSET_CMPD with --fields=field2.b --fields=field4
+# TEST.h5/DSET_CMPD_ESC with --fields=field2\..\,b --fields=field4\,
+# TEST.h5/DSET_CMPD_TWO with --fields=field2.b --fields=field4
+#
+TEST_WATCH DSET_CMPD --fields=field2.b,field4 w-ext-cmpd-f2.ddl
+TEST_WATCH DSET_CMPD_ESC '--fields=field2\..\,b,field4\,' w-ext-cmpd-esc-f2.ddl
+TEST_WATCH DSET_CMPD_TWO --fields=field2.b,field4 w-ext-cmpd-two-f2.ddl
+TEST_WATCH DSET_CMPD '--fields=field2.b --fields=field4' w-ext-cmpd-ff2.ddl
+TEST_WATCH DSET_CMPD_ESC '--fields=field2\..\,b --fields=field4\,' w-ext-cmpd-esc-ff2.ddl
+TEST_WATCH DSET_CMPD_TWO '--fields=field2.b --fields=field4' w-ext-cmpd-two-ff2.ddl
+#
+echo "DONE WITH 4th SET OF TESTS"
+#
+#
+#
+# Watching and extending: (TEST.h5 is a copy of WATCH.h5)
+# TEST.h5/DSET_CMPD with --fields=field2.b.a,field2.c
+# TEST.h5/DSET_CMPD_ESC with --fields=field2\..\,b.a,field2\..\\K
+# TEST.h5/DSET_CMPD_TWO with --fields=field2.b.a,field2.c
+# TEST.h5/DSET_CMPD with --fields=field2.b.a --fields=field2.c
+# TEST.h5/DSET_CMPD_ESC with --fields=field2\..\,b.a --fields=field2\..\\K
+# TEST.h5/DSET_CMPD_TWO with --fields=field2.b.a --fields=field2.c
+TEST_WATCH DSET_CMPD --fields=field2.b.a,field2.c w-ext-cmpd-f3.ddl
+TEST_WATCH DSET_CMPD_ESC '--fields=field2\..\,b.a,field2\..\\K' w-ext-cmpd-esc-f3.ddl
+TEST_WATCH DSET_CMPD_TWO --fields=field2.b.a,field2.c w-ext-cmpd-two-f3.ddl
+TEST_WATCH DSET_CMPD '--fields=field2.b.a --fields=field2.c' w-ext-cmpd-ff3.ddl
+TEST_WATCH DSET_CMPD_ESC '--fields=field2\..\,b.a --fields=field2\..\\K' w-ext-cmpd-esc-ff3.ddl
+TEST_WATCH DSET_CMPD_TWO '--fields=field2.b.a --fields=field2.c' w-ext-cmpd-two-ff3.ddl
+#
+echo "DONE WITH 5th SET OF TESTS"
+#
+#
+#
+#################################################
+# Tests on options: #
+# --dim #
+# --width, --label, --simple, --help #
+#################################################
+#
+# Watching and extending: (TEST.h5 is a copy of WATCH.h5)
+# TEST.h5/DSET_ONE with -d option
+# TEST.h5/DSET_TWO with --dim option
+# TEST.h5/DSET_TWO with --width=60 option
+# TEST.h5/DSET_CMPD with --label option
+# TEST.h5/DSET_ONE with --simple option
+TEST_WATCH DSET_ONE --dim w-ext-one-d.ddl
+TEST_WATCH DSET_TWO --dim w-ext-two-d.ddl
+TEST_WATCH DSET_TWO --width=30 w-ext-two-width.ddl
+TEST_WATCH DSET_CMPD --label w-ext-cmpd-label.ddl
+TEST_WATCH DSET_ONE --simple w-ext-one-simple.ddl
+#
+echo "DONE WITH 6th SET OF TESTS"
#
#
#