summaryrefslogtreecommitdiffstats
path: root/hl/tools/h5watch
diff options
context:
space:
mode:
Diffstat (limited to 'hl/tools/h5watch')
-rw-r--r--hl/tools/h5watch/extend_dset.c307
-rw-r--r--hl/tools/h5watch/h5watch.c494
-rw-r--r--hl/tools/h5watch/testh5watch.sh.in163
3 files changed, 469 insertions, 495 deletions
diff --git a/hl/tools/h5watch/extend_dset.c b/hl/tools/h5watch/extend_dset.c
index f6b4161..ab086f6 100644
--- a/hl/tools/h5watch/extend_dset.c
+++ b/hl/tools/h5watch/extend_dset.c
@@ -34,27 +34,8 @@
/* Size of data buffer */
#define TEST_BUF_SIZE 100
-/*
- * Test variations (incremental) for one-dimensional dataset:
- * Varies from 10->13->12->12->1->3
- */
-#define ONE_NTESTS 5
-int one_tests[ONE_NTESTS] = {3, -1, 0, -11, 2};
-
-/*
- * Test variations (incremental) for two-dimensional dataset:
- * Varies from {4,10}->{6,12}->{8,1}->{10,1}->
- * {3,3}->{2,2}->{1,2}->
- * {1,4}->{1,3}->{1,3}
- */
-#define TWO_NTESTS 9
-int two_tests[TWO_NTESTS][2] = { {2, 2}, {2, -11}, {2, 0},
- {-7, 2}, {-1, -1}, {-1, 0},
- {0, 2}, {0, -1}, {0, 0}
- };
-
-static herr_t extend_dset_two(const char *file, char *dname);
-static herr_t extend_dset_one(const char *file, char *dname);
+static herr_t extend_dset_two(const char *file, char *dname, int action1, int action2);
+static herr_t extend_dset_one(const char *file, char *dname, int action);
/* Data structures for datasets with compound data type */
@@ -85,29 +66,13 @@ typedef struct set_t {
/*
***********************************************************************
*
- * Extending a two-dimensional dataset:
- * dims[0] dims[1]
- * ------- -------
- * case #1: increase increase
- * case #2: increase decrease
- * case #3: increase same
- * case #4: decrease increase
- * case #5: decrease decrease (no action)
- * case #6: decrease same (no action)
- * case #7: same increase
- * case #8: same decrease (no action)
- * case #9: same same (no action)
- *
- * two_tests[TWO_NTESTS][2] = { {2,2}, {2,-11}, {2,0},
- * {-7,2}, {-1,-1}, {-1,0},
- * {0,2}, {0,-1}, {0,0} }
- * varies from {4,10}->{6,12}->{8,1}->{10,1}->
- * {3,3}->{2,2}->{1,2}->
- * {1,4}->{1,3}->{1,3}
+ * Extending a two-dimensional dataset by action1 and action2.
+ * --action1 and action2 can be a positive # or negative # or 0.
+ *
***********************************************************************
*/
static herr_t
-extend_dset_two(const char *file, char *dname)
+extend_dset_two(const char *file, char *dname, int action1, int action2)
{
hid_t fid = -1; /* file id */
hid_t fapl = -1; /* file access property list id */
@@ -165,61 +130,57 @@ extend_dset_two(const char *file, char *dname)
if(h5_wait_message(READER_MESSAGE) < 0)
goto error;
- /* Loop through different variations of extending the dataset */
- for(i = 0; i < TWO_NTESTS; i++) {
+ /* sleep to emulate about 2 seconds of application operation */
+ HDsleep(2);
- /* sleep to emulate about 2 seconds of application operation */
- HDsleep(2);
+ /* Get current dimension sizes */
+ if(H5LDget_dset_dims(did, cur_dims) < 0)
+ goto error;
- /* Get current dimension sizes */
- if(H5LDget_dset_dims(did, cur_dims) < 0)
- goto error;
+ /* Set up the new extended dimension sizes */
+ ext_dims[0] = cur_dims[0] + (hsize_t)action1;
+ ext_dims[1] = cur_dims[1] + (hsize_t)action2;
- /* Set up the new extended dimension sizes */
- ext_dims[0] = cur_dims[0] + (hsize_t)two_tests[i][0];
- ext_dims[1] = cur_dims[1] + (hsize_t)two_tests[i][1];
+ /* Extend the dataset */
+ if(H5Dset_extent(did, ext_dims) < 0)
+ goto error;
- /* Extend the dataset */
- if(H5Dset_extent(did, ext_dims) < 0)
+ num_elmts = 1;
+ for(j = 0; j < (unsigned)ndims; j++)
+ num_elmts *= (unsigned)ext_dims[j];
+
+ /* Compound type */
+ if(!HDstrcmp(dname, DSET_CMPD_TWO)) {
+
+ HDmemset(cbuf, 0, TEST_BUF_SIZE * sizeof(set_t));
+ for(j = 0; j < num_elmts; j++) {
+ cbuf[j].field1 = action1;
+ cbuf[j].field2.a = action1;
+ cbuf[j].field2.c = action1;
+ cbuf[j].field2.b.a = action1;
+ cbuf[j].field2.b.b = action1;
+ cbuf[j].field2.b.c = action1;
+ cbuf[j].field3 = action1;
+ cbuf[j].field4.a = action1;
+ cbuf[j].field4.b = action1;
+ } /* end for */
+
+ /* Write to the dataset */
+ if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0)
goto error;
- num_elmts = 1;
- for(j = 0; j < (unsigned)ndims; j++)
- num_elmts *= (unsigned)ext_dims[j];
-
- /* Compound type */
- if(!HDstrcmp(dname, DSET_CMPD_TWO)) {
-
- HDmemset(cbuf, 0, TEST_BUF_SIZE * sizeof(set_t));
- for(j = 0; j < num_elmts; j++) {
- cbuf[j].field1 = i + 1;
- cbuf[j].field2.a = i + 1;
- cbuf[j].field2.c = i + 1;
- cbuf[j].field2.b.a = i + 1;
- cbuf[j].field2.b.b = i + 1;
- cbuf[j].field2.b.c = i + 1;
- cbuf[j].field3 = i + 1;
- cbuf[j].field4.a = i + 1;
- cbuf[j].field4.b = i + 1;
- } /* end for */
+ } else { /* Integer type */
+ HDmemset(ibuf, 0, TEST_BUF_SIZE * sizeof(int));
+ for(j = 0; j < num_elmts; j++)
+ ibuf[j] = action1;
- /* Write to the dataset */
- if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0)
- goto error;
- } else { /* Integer type */
- HDmemset(ibuf, 0, TEST_BUF_SIZE * sizeof(int));
- for(j = 0; j < num_elmts; j++)
- ibuf[j] = (int)(i + 1);
-
- /* Write to the dataset */
- if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0)
- goto error;
- } /* end if-else */
-
- if(H5Dflush(did) < 0)
+ /* Write to the dataset */
+ if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0)
goto error;
+ } /* end if-else */
- } /* end for TWO_NTESTS */
+ if(H5Dflush(did) < 0)
+ goto error;
/* Closing */
if(H5Tclose(dtid) < 0) goto error;
@@ -227,8 +188,8 @@ extend_dset_two(const char *file, char *dname)
if(H5Pclose(fapl) < 0) goto error;
if(H5Fclose(fid) < 0) goto error;
- HDfree(ibuf);
- HDfree(cbuf);
+ if(ibuf) HDfree(ibuf);
+ if(cbuf) HDfree(cbuf);
return SUCCEED;
@@ -252,21 +213,13 @@ error:
/*
***********************************************************************
*
- * Extending a one-dimensional dataset
- * Test cases:
- * #1: increase
- * #2: decrease
- * #3: same
- * #4: decrease
- * #5: increase
- *
- * one_tests[ONE_NTESTS] = {3, -1, 0, -11, 2}
- * varies from 10->13->12->12->1->3
+ * Extending a one-dimensional dataset by action:
+ * --action can be a positive # or negative # or 0.
*
***********************************************************************
*/
static herr_t
-extend_dset_one(const char *file, char *dname)
+extend_dset_one(const char *file, char *dname, int action)
{
hid_t fid = -1; /* file id */
hid_t fapl = -1; /* file access property list id */
@@ -319,80 +272,75 @@ extend_dset_one(const char *file, char *dname)
if(h5_wait_message(READER_MESSAGE) < 0)
goto error;
- /* Loop through different variations of extending the dataset */
- for(i = 0; i < ONE_NTESTS; i++) {
+ /* sleep to emulate about 2 seconds of application operation */
+ HDsleep(2);
+
+ /* Get current dimension sizes */
+ if(H5LDget_dset_dims(did, cur_dims) < 0)
+ goto error;
+
+ /* Set up the new extended dimension sizes */
+ ext_dims[0] = cur_dims[0] + (hsize_t)action;
- /* sleep to emulate about 2 seconds of application operation */
- HDsleep(2);
+ /* Extend the dataset */
+ if(H5Dset_extent(did, ext_dims) < 0)
+ goto error;
- /* Get current dimension sizes */
- if(H5LDget_dset_dims(did, cur_dims) < 0)
- goto error;
+ /* Write to the new appended region of the dataset */
+ if(action > 0) {
- /* Set up the new extended dimension sizes */
- ext_dims[0] = cur_dims[0] + (hsize_t)one_tests[i];
+ /* Select the extended region */
+ offset[0] = cur_dims[0];
+ count[0] = (hsize_t)action;
+ if((sid = H5Dget_space(did)) < 0)
+ goto error;
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
+ goto error;
- /* Extend the dataset */
- if(H5Dset_extent(did, ext_dims) < 0)
+ /* Set up memory space and get dataset's datatype */
+ if((mid = H5Screate_simple(1, count, NULL)) < 0)
goto error;
- /* Write to the new appended region of the dataset */
- if(one_tests[i] > 0) {
+ /* Initialize data for the extended region of the dataset */
+ /* Compound type */
+ if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) {
- /* Select the extended region */
- offset[0] = cur_dims[0];
- count[0] = (hsize_t)one_tests[i];
- if((sid = H5Dget_space(did)) < 0)
- goto error;
- if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
+ HDmemset(cbuf, 0, TEST_BUF_SIZE * sizeof(set_t));
+ for(j = 0; j < (unsigned)action; j++) {
+ cbuf[j].field1 = j + 1;
+ cbuf[j].field2.a = j + 2;
+ cbuf[j].field2.b.a = j + 2;
+ cbuf[j].field2.b.b = j + 2;
+ cbuf[j].field2.b.c = j + 2;
+ cbuf[j].field2.c = j + 2;
+
+ cbuf[j].field3 = j + 3;
+
+ cbuf[j].field4.a = j + 4;
+ cbuf[j].field4.b = j + 4;
+ } /* end for */
+
+ /* Write to the extended region of the dataset */
+ if(H5Dwrite(did, dtid, mid, sid, H5P_DEFAULT, cbuf) < 0)
goto error;
+ } else { /* Integer type */
+
+ HDmemset(ibuf, 0, TEST_BUF_SIZE * sizeof(int));
+ for(j = 0; j < (unsigned)action; j++)
+ ibuf[j] = (int)j;
- /* Set up memory space and get dataset's datatype */
- if((mid = H5Screate_simple(1, count, NULL)) < 0)
+ /* Write to the extended region of the dataset */
+ if(H5Dwrite(did, dtid, mid, sid, H5P_DEFAULT, ibuf) < 0)
goto error;
+ } /* end if-else */
- /* Initialize data for the extended region of the dataset */
- /* Compound type */
- if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) {
-
- HDmemset(cbuf, 0, TEST_BUF_SIZE * sizeof(set_t));
- for(j = 0; j < (unsigned)one_tests[i]; j++) {
- cbuf[j].field1 = j + 1;
- cbuf[j].field2.a = j + 2;
- cbuf[j].field2.b.a = j + 2;
- cbuf[j].field2.b.b = j + 2;
- cbuf[j].field2.b.c = j + 2;
- cbuf[j].field2.c = j + 2;
-
- cbuf[j].field3 = j + 3;
-
- cbuf[j].field4.a = j + 4;
- cbuf[j].field4.b = j + 4;
- } /* end for */
-
- /* Write to the extended region of the dataset */
- if(H5Dwrite(did, dtid, mid, sid, H5P_DEFAULT, cbuf) < 0)
- goto error;
- } else { /* Integer type */
-
- HDmemset(ibuf, 0, TEST_BUF_SIZE * sizeof(int));
- for(j = 0; j < (unsigned)one_tests[i]; j++)
- ibuf[j] = (int)j;
-
- /* Write to the extended region of the dataset */
- if(H5Dwrite(did, dtid, mid, sid, H5P_DEFAULT, ibuf) < 0)
- goto error;
- } /* end if-else */
-
- /* Closing */
- if(H5Sclose(sid) < 0) goto error;
- if(H5Sclose(mid) < 0) goto error;
- } /* end if */
-
- if(H5Dflush(did) < 0)
- goto error;
+ /* Closing */
+ if(H5Sclose(sid) < 0) goto error;
+ if(H5Sclose(mid) < 0) goto error;
+ } /* end if */
- } /* end for ONE_NTESTS */
+ if(H5Dflush(did) < 0)
+ goto error;
/* Closing */
if(H5Tclose(dtid) < 0) goto error;
@@ -400,8 +348,8 @@ extend_dset_one(const char *file, char *dname)
if(H5Pclose(fapl) < 0) goto error;
if(H5Fclose(fid) < 0) goto error;
- HDfree(ibuf);
- HDfree(cbuf);
+ if(ibuf) HDfree(ibuf);
+ if(cbuf) HDfree(cbuf);
return SUCCEED;
@@ -423,30 +371,44 @@ error:
return FAIL;
} /* end extend_dset_one() */
-/* Usage: extend_dset xx.h5 dname */
+
+/*
+ ***********************************************************************
+ *
+ * Usage: extend_dset xx.h5 dname action1 action2
+ * --action1 and action2 can be a positive # or negative # or 0.
+ *
+ ***********************************************************************
+ */
int
main(int argc, const char *argv[])
{
char *dname = NULL;
char *fname = NULL;
+ int action1, action2;
- if(argc != 3) {
- HDfprintf(stderr, "Should have file name and dataset name to be extended...\n");
+ if(argc != 5) {
+ HDfprintf(stderr, "Should have file name, dataset name, and the extended amount...\n");
goto error;
} /* end if */
/* Get the dataset name to be extended */
fname = HDstrdup(argv[1]);
dname = HDstrdup(argv[2]);
+ action1 = HDatoi(argv[3]);
+ action2 = HDatoi(argv[4]);
if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) {
- if(extend_dset_one(fname, dname) < 0)
+ if(extend_dset_one(fname, dname, action1) < 0)
goto error;
- } else if(!HDstrcmp(dname, DSET_ONE) || !HDstrcmp(dname, DSET_ALLOC_LATE) || !HDstrcmp(dname, DSET_ALLOC_EARLY)) {
- if(extend_dset_one(fname, dname) < 0)
+ } else if(!HDstrcmp(dname, DSET_ONE) ||
+ !HDstrcmp(dname, DSET_ALLOC_LATE) ||
+ !HDstrcmp(dname, DSET_ALLOC_EARLY)) {
+ if(extend_dset_one(fname, dname, action1) < 0)
goto error;
- } else if(!HDstrcmp(dname, DSET_TWO) || !HDstrcmp(dname, DSET_CMPD_TWO)) {
- if(extend_dset_two(fname, dname) < 0)
+ } else if(!HDstrcmp(dname, DSET_TWO) ||
+ !HDstrcmp(dname, DSET_CMPD_TWO)) {
+ if(extend_dset_two(fname, dname, action1, action2) < 0)
goto error;
} else {
HDfprintf(stdout, "Dataset cannot be extended...\n");
@@ -462,4 +424,3 @@ error:
HDfree(fname);
HDexit(EXIT_FAILURE);
} /* end main() */
-
diff --git a/hl/tools/h5watch/h5watch.c b/hl/tools/h5watch/h5watch.c
index f37b2b4..7289c58 100644
--- a/hl/tools/h5watch/h5watch.c
+++ b/hl/tools/h5watch/h5watch.c
@@ -20,29 +20,30 @@
/*
* Note: This tool used private routine
*/
-#define PROGRAMNAME "h5watch" /* Name of tool */
-#define FIELD_SEP "," /* nested field separator */
-#define DEFAULT_RETRY 50 /* number of times to try opening the file */
+#define PROGRAMNAME "h5watch" /* Name of tool */
+#define FIELD_SEP "," /* nested field separator */
+#define DEFAULT_RETRY 50 /* number of times to try opening the file */
/*
* Note:(see comments in hl/src/H5LDprivate.h)
- * This tool uses private routines H5LD_construct_vector()and H5LD_clean_vector()
+ * This tool uses private routines H5LD_construct_vector()and H5LD_clean_vector()
* This tool uses H5LD_memb_t data structure declared in H5LDprivate.h
*/
-const char *progname = "h5watch"; /* tool name */
-static char *g_list_of_fields = NULL; /* command line input for "list_of_fields" */
-static char *g_dup_fields = NULL; /* copy of "list_of_fields" */
-static H5LD_memb_t **g_listv = NULL; /* vector info for "list_of_fields" */
+const char *progname = "h5watch"; /* tool name */
+static char *g_list_of_fields = NULL; /* command line input for "list_of_fields" */
+static char *g_dup_fields = NULL; /* copy of "list_of_fields" */
+static H5LD_memb_t **g_listv = NULL; /* vector info for "list_of_fields" */
static hbool_t g_monitor_size_only = FALSE; /* monitor changes in dataset dimension sizes */
static unsigned g_polling_interval = 1; /* polling interval to check appended data */
+
static hbool_t g_label = FALSE; /* label compound values */
-static int g_display_width = 80; /* output width in characters */
+static int g_display_width = 80; /* output width in characters */
static hbool_t g_simple_output = FALSE; /* make output more machine-readable */
static unsigned g_retry = DEFAULT_RETRY; /* # of times to try opening the file if somehow file is unstable */
-static hbool_t g_display_hex = FALSE; /* display data in hexadecimal format : LATER */
+static hbool_t g_display_hex = FALSE; /* display data in hexadecimal format : LATER */
static hbool_t g_user_interrupt = FALSE; /* Flag to indicate that user interrupted execution */
static herr_t doprint(hid_t did, hsize_t *start, hsize_t *block, int rank);
@@ -109,9 +110,9 @@ static struct long_options l_opts[] = {
* Function: doprint()
*
* Purpose: Prepare to print the dataset's appended data.
- * Call the tools library routine h5tools_dump_dset() to do the printing.
- * (This routine is mostly copied from dump_dataset_values() in tools/h5ls/h5ls.c
- * and modified accordingly).
+ * Call the tools library routine h5tools_dump_dset() to do the printing.
+ * (This routine is mostly copied from dump_dataset_values() in tools/h5ls/h5ls.c
+ * and modified accordingly).
*
* Return: 0 on success; negative on failure
*
@@ -234,17 +235,17 @@ doprint(hid_t did, hsize_t *start, hsize_t *block, int rank)
* Function: slicendump
*
* Purpose: To dump the slice for each dimension
- * For example: prev_dims[2] = {5, 4}; cur_dims[2] = {7, 8}
- * This routine will dump data as follows:
- * {0, 3} to {0, 7} (1x4 elements)
- * {1, 3} to {0, 7} (1x4 elements)
- * {2, 3} to {0, 7} (1x4 elements)
- * {3, 3} to {0, 7} (1x4 elements)
- * {4, 3} to {0, 7} (1x4 elements)
- * {5, 0} to {6, 7} (2x8 elements)
- *
- * Return: Non-negative on success
- * Negative on failure
+ * For example: prev_dims[2] = {5, 4}; cur_dims[2] = {7, 8}
+ * This routine will dump data as follows:
+ * {0, 3} to {0, 7} (1x4 elements)
+ * {1, 3} to {0, 7} (1x4 elements)
+ * {2, 3} to {0, 7} (1x4 elements)
+ * {3, 3} to {0, 7} (1x4 elements)
+ * {4, 3} to {0, 7} (1x4 elements)
+ * {5, 0} to {6, 7} (2x8 elements)
+ *
+ * Return: Non-negative on success
+ * Negative on failure
*
* Programmer: Vailin Choi; August 2010
*
@@ -253,9 +254,9 @@ doprint(hid_t did, hsize_t *start, hsize_t *block, int rank)
static herr_t
slicendump(hid_t did, hsize_t *prev_dims, hsize_t *cur_dims, hsize_t *start, hsize_t *block, int rank, int subrank)
{
- int i; /* Local index variable */
- int ind; /* Index for the current rank */
- herr_t ret_value = SUCCEED; /* Return value */
+ int i; /* Local index variable */
+ int ind; /* Index for the current rank */
+ herr_t ret_value = SUCCEED; /* Return value */
ind = rank - subrank;
@@ -294,13 +295,13 @@ done:
* Function: monitor_dataset
*
* Purpose: To poll a dataset periodically for changes in dimension sizes.
- * For dataset with unchanged and/or decreased dimension sizes:
- * it just prints the dimension size changes
- * For dataset with increase in at least one of its dimension sizes:
- * it will print the new appended data to the dataset
+ * For dataset with unchanged and/or decreased dimension sizes:
+ * it just prints the dimension size changes
+ * For dataset with increase in at least one of its dimension sizes:
+ * it will print the new appended data to the dataset
*
* Return: Non-negative on success: dataset can be monitored
- * Negative on failure: dataset cannot be monitored
+ * Negative on failure: dataset cannot be monitored
*
* Programmer: Vailin Choi; August 2010
*
@@ -321,95 +322,98 @@ monitor_dataset(hid_t fid, char *dsetname)
/* Open the dataset for minitoring */
if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) {
- error_msg("error in opening dataset \"%s\"\n", dsetname);
- ret_value = FAIL;
- goto done;
+ error_msg("error in opening dataset \"%s\"\n", dsetname);
+ ret_value = FAIL;
+ goto done;
}
if((sid = H5Dget_space(did)) < 0) {
- error_msg("error in getting dataspace id for dataset \"%s\"\n", dsetname);
- ret_value = FAIL;
- goto done;
+ error_msg("error in getting dataspace id for dataset \"%s\"\n", dsetname);
+ ret_value = FAIL;
+ goto done;
}
/* Get the dataset's dimension sizes */
if((ndims = H5Sget_simple_extent_dims(sid, prev_dims, NULL)) < 0) {
- error_msg("unable to get dimensions sizes for \"%s\"\n", dsetname);
- ret_value = FAIL;
- goto done;
+ error_msg("unable to get dimensions sizes for \"%s\"\n", dsetname);
+ ret_value = FAIL;
+ goto done;
}
+ HDfflush(stdout);
/* Loop until an error occurs or the user interrupts execution */
while(!g_user_interrupt) {
- /* Refreshes the dataset */
- if(H5Drefresh(did) < 0) {
- ret_value = FAIL;
- goto done;
- }
+ /* Refreshes the dataset */
+ if(H5Drefresh(did) < 0) {
+ ret_value = FAIL;
+ goto done;
+ }
- /* Get the dataset's current dimension sizes */
- if(H5LDget_dset_dims(did, cur_dims) < 0) {
- error_msg("unable to get dimension sizes for \"%s\"\n", dsetname);
- ret_value = FAIL;
- goto done;
- }
+ /* Get the dataset's current dimension sizes */
+ if(H5LDget_dset_dims(did, cur_dims) < 0) {
+ error_msg("unable to get dimension sizes for \"%s\"\n", dsetname);
+ ret_value = FAIL;
+ goto done;
+ }
- /* Check the dimension sizes */
- for(i = 0; i < ndims; i++)
- if(cur_dims[i] != prev_dims[i])
- break;
-
- /* at least one dimension has changed */
- if(i != ndims) {
- /* Printing changes in dimension sizes */
- for(u = 0; u < ndims; 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])
- HDfprintf(stdout, " (decreases)\n");
- else
- HDfprintf(stdout, " (unchanged)\n");
- }
-
- /* Printing elements appended to the dataset if there is */
- if(!g_monitor_size_only) {
-
- /* See if at least one dimension size has increased */
- for(u = 0; u < ndims; u++) {
- int j;
- hsize_t start[H5S_MAX_RANK];
- hsize_t block[H5S_MAX_RANK];
-
- /* Print the new appended data to the dataset */
- if(cur_dims[u] > prev_dims[u]) {
- HDfprintf(stdout, " Data:\n");
-
- for(j = 0; j < ndims; j++) {
- start[j] = 0;
- block[j] = 1;
- }
-
- if((ret_value = slicendump(did, prev_dims, cur_dims, start, block, ndims, ndims)) < 0)
- goto done;
- break;
- }
- } /* end for */
- }
- HDfflush(stdout);
- }
+ /* Check the dimension sizes */
+ for(i = 0; i < ndims; i++)
+ if(cur_dims[i] != prev_dims[i])
+ break;
+
+ /* at least one dimension has changed */
+ if(i != ndims) {
+ /* Printing changes in dimension sizes */
+ for(u = 0; u < ndims; 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])
+ HDfprintf(stdout, " (decreases)\n");
+ else
+ HDfprintf(stdout, " (unchanged)\n");
+ }
+
+ /* Printing elements appended to the dataset if there is */
+ if(!g_monitor_size_only) {
+
+ /* See if at least one dimension size has increased */
+ for(u = 0; u < ndims; u++) {
+ int j;
+ hsize_t start[H5S_MAX_RANK];
+ hsize_t block[H5S_MAX_RANK];
+
+ /* Print the new appended data to the dataset */
+ if(cur_dims[u] > prev_dims[u]) {
+ HDfprintf(stdout, " Data:\n");
+
+ for(j = 0; j < ndims; j++) {
+ start[j] = 0;
+ block[j] = 1;
+ }
+
+ if((ret_value = slicendump(did, prev_dims, cur_dims, start, block, ndims, ndims)) < 0)
+ goto done;
+ break;
+ }
+ } /* end for */
+ }
+ HDfflush(stdout);
+ }
- /* Save the current dimension sizes */
- HDmemcpy(prev_dims, cur_dims, (size_t)ndims * sizeof(hsize_t));
+ /* Save the current dimension sizes */
+ HDmemcpy(prev_dims, cur_dims, (size_t)ndims * sizeof(hsize_t));
- /* Sleep before next monitor */
+ /* Sleep before next monitor */
HDsleep(g_polling_interval);
} /* end while */
+ HDfflush(stdout);
+
done:
/* Closing */
H5E_BEGIN_TRY
- H5Dclose(did);
+ H5Dclose(did);
H5E_END_TRY
return(ret_value);
@@ -419,7 +423,7 @@ done:
* Function: process_cmpd_fields
*
* Purpose: To check whether the fields selected in "g_list_of_fields"
- * are valid fields associated with the dataset.
+ * are valid fields associated with the dataset.
*
* Return: 0 on success; negative on failure
*
@@ -430,39 +434,39 @@ done:
static herr_t
process_cmpd_fields(hid_t fid, char *dsetname)
{
- 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 */
+ 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 */
HDassert(g_list_of_fields && *g_list_of_fields);
/* Open the dataset */
if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) {
- error_msg("error in opening dataset \"%s\"\n", dsetname);
- ret_value = FAIL;
- goto done;
+ error_msg("error in opening dataset \"%s\"\n", dsetname);
+ ret_value = FAIL;
+ goto done;
}
/* Get the dataset's datatype */
if(((dtid = H5Dget_type(did)) < 0) || (tid = H5Tget_native_type(dtid, H5T_DIR_DEFAULT)) < 0) {
- error_msg("error in getting dataset's datatype\n");
+ error_msg("error in getting dataset's datatype\n");
ret_value = FAIL;
goto done;
}
/* Check to make sure that the dataset's datatype is compound type */
if(H5Tget_class(dtid) != H5T_COMPOUND) {
- error_msg("dataset should be compound type for <list_of_fields>\n");
- ret_value = FAIL;
- goto done;
+ error_msg("dataset should be compound type for <list_of_fields>\n");
+ ret_value = FAIL;
+ goto done;
}
/* Make a copy of "g_list_of_fields" */
if((g_dup_fields = HDstrdup(g_list_of_fields)) == NULL) {
- error_msg("error in duplicating g_list_of_fields\n");
+ error_msg("error in duplicating g_list_of_fields\n");
ret_value = FAIL;
- goto done;
+ goto done;
}
/* Estimate the number of comma-separated fields in "g_list of_fields" */
@@ -470,15 +474,15 @@ process_cmpd_fields(hid_t fid, char *dsetname)
/* Allocate memory for a list vector of H5LD_memb_t structures to store "g_list_of_fields" info */
if((g_listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *))) == NULL) {
- error_msg("error in allocating memory for H5LD_memb_t\n");
+ error_msg("error in allocating memory for H5LD_memb_t\n");
ret_value = FAIL;
- goto done;
+ goto done;
}
/* Process and store info for "g_listv" */
if(H5LD_construct_vector(g_dup_fields, g_listv, tid) < 0) {
- error_msg("error in processing <list_of_fields>\n");
- ret_value = FAIL;
+ error_msg("error in processing <list_of_fields>\n");
+ ret_value = FAIL;
goto done;
}
@@ -486,9 +490,9 @@ process_cmpd_fields(hid_t fid, char *dsetname)
done:
/* Closing */
H5E_BEGIN_TRY
- H5Tclose(dtid);
- H5Tclose(tid);
- H5Dclose(did);
+ H5Tclose(dtid);
+ H5Tclose(tid);
+ H5Dclose(did);
H5E_END_TRY
return(ret_value);
} /* process_cmpd_fields() */
@@ -498,15 +502,13 @@ done:
* Function: check_dataset
*
* Purpose: To check whether a dataset can be monitored:
- A chunked dataset with unlimited or max. dimension setting
+ * A chunked dataset with unlimited or max. dimension setting
*
* Return: Non-negative on success: dataset can be monitored
- * Negative on failure: dataset cannot be monitored
+ * Negative on failure: dataset cannot be monitored
*
* Programmer: Vailin Choi; August 2010
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -531,9 +533,9 @@ check_dataset(hid_t fid, char *dsetname)
/* Open the dataset */
if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) {
- error_msg("unable to open dataset \"%s\"\n", dsetname);
- ret_value = FAIL;
- goto done;
+ error_msg("unable to open dataset \"%s\"\n", dsetname);
+ ret_value = FAIL;
+ goto done;
}
/* Get dataset's creation property list */
@@ -560,28 +562,28 @@ check_dataset(hid_t fid, char *dsetname)
/* Get dataset's dataspace */
if((sid = H5Dget_space(did)) < 0) {
- error_msg("can't get dataset's dataspace\"%s\"\n", dsetname);
- ret_value = FAIL;
- goto done;
+ error_msg("can't get dataset's dataspace\"%s\"\n", dsetname);
+ ret_value = FAIL;
+ goto done;
}
/* Get dimension size of dataset's dataspace */
if((ndims = H5Sget_simple_extent_dims(sid, cur_dims, max_dims)) < 0) {
- error_msg("can't get dataspace dimensions for dataset \"%s\"\n", dsetname);
- ret_value = FAIL;
- goto done;
+ error_msg("can't get dataspace dimensions for dataset \"%s\"\n", dsetname);
+ ret_value = FAIL;
+ goto done;
}
/* Check whether dataset has unlimited dimension or max. dimension setting */
for(u = 0; u < (unsigned)ndims; u++)
if(max_dims[u] == H5S_UNLIMITED || cur_dims[u] != max_dims[u]) {
- unlim_max_dims = TRUE;
+ unlim_max_dims = TRUE;
break;
}
if(!unlim_max_dims) {
- error_msg("\"%s\" should have unlimited or max. dimension setting\n", dsetname);
- ret_value = FAIL;
+ error_msg("\"%s\" should have unlimited or max. dimension setting\n", dsetname);
+ ret_value = FAIL;
}
done:
@@ -589,9 +591,9 @@ done:
/* Closing */
H5E_BEGIN_TRY
- H5Sclose(sid);
- H5Pclose(dcp);
- H5Dclose(did);
+ H5Sclose(sid);
+ H5Pclose(dcp);
+ H5Dclose(did);
H5E_END_TRY
return(ret_value);
@@ -607,7 +609,6 @@ done:
*
* Programmer: Vailin Choi; August 2010
*
- * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -629,7 +630,6 @@ leave(int ret)
*
* Programmer: Vailin Choi; August 2010
*
- * Modifications:
*-------------------------------------------------------------------------
*/
static void
@@ -685,8 +685,6 @@ usage(const char *prog)
*
* Programmer: Vailin Choi; August 2010
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void
@@ -706,7 +704,7 @@ parse_command_line(int argc, const char *argv[])
switch ((char)opt) {
case '?':
case 'h': /* --help */
- usage(h5tools_getprogname());
+ usage(h5tools_getprogname());
leave(EXIT_SUCCESS);
case 'V': /* --version */
@@ -715,63 +713,63 @@ parse_command_line(int argc, const char *argv[])
break;
case 'w': /* --width=N */
- g_display_width = (int)HDstrtol(opt_arg, NULL, 0);
- if(g_display_width < 0) {
- usage(h5tools_getprogname());
- leave(EXIT_FAILURE);
- }
+ g_display_width = (int)HDstrtol(opt_arg, NULL, 0);
+ if(g_display_width < 0) {
+ usage(h5tools_getprogname());
+ leave(EXIT_FAILURE);
+ }
break;
case 'd': /* --dim */
- g_monitor_size_only = TRUE;
+ g_monitor_size_only = TRUE;
break;
case 'S': /* --simple */
- g_simple_output = TRUE;
+ g_simple_output = TRUE;
break;
- case 'l': /* --label */
- g_label = TRUE;
+ case 'l': /* --label */
+ g_label = TRUE;
break;
case 'p': /* --polling=N */
- /* g_polling_interval = HDstrtod(opt_arg, NULL); */
- if((tmp = (int)HDstrtol(opt_arg, NULL, 10)) <= 0) {
- usage(h5tools_getprogname());
- leave(EXIT_FAILURE);
- }
- g_polling_interval = (unsigned)tmp;
+ /* g_polling_interval = HDstrtod(opt_arg, NULL); */
+ if((tmp = (int)HDstrtol(opt_arg, NULL, 10)) <= 0) {
+ usage(h5tools_getprogname());
+ leave(EXIT_FAILURE);
+ }
+ g_polling_interval = (unsigned)tmp;
break;
case 'f': /* --fields=<list_of_fields> */
- if(g_list_of_fields == NULL) {
- if((g_list_of_fields = HDstrdup(opt_arg)) == NULL) {
- error_msg("memory allocation failed (file %s:line %d)\n",
- __FILE__, __LINE__);
- leave(EXIT_FAILURE);
- }
- } else {
- char *str;
-
- if((str = HDstrdup(opt_arg)) == NULL) {
- error_msg("memory allocation failed (file %s:line %d)\n",
- __FILE__, __LINE__);
- leave(EXIT_FAILURE);
- }
- if((g_list_of_fields = (char *)HDrealloc(g_list_of_fields, HDstrlen(g_list_of_fields) + HDstrlen(str) + 2)) == NULL) {
- error_msg("memory allocation failed (file %s:line %d)\n",
- __FILE__, __LINE__);
- leave(EXIT_FAILURE);
-
- }
- HDstrcat(g_list_of_fields, FIELD_SEP);
- HDstrcat(g_list_of_fields, str);
- }
+ if(g_list_of_fields == NULL) {
+ if((g_list_of_fields = HDstrdup(opt_arg)) == NULL) {
+ error_msg("memory allocation failed (file %s:line %d)\n",
+ __FILE__, __LINE__);
+ leave(EXIT_FAILURE);
+ }
+ } else {
+ char *str;
+
+ if((str = HDstrdup(opt_arg)) == NULL) {
+ error_msg("memory allocation failed (file %s:line %d)\n",
+ __FILE__, __LINE__);
+ leave(EXIT_FAILURE);
+ }
+ if((g_list_of_fields = (char *)HDrealloc(g_list_of_fields, HDstrlen(g_list_of_fields) + HDstrlen(str) + 2)) == NULL) {
+ error_msg("memory allocation failed (file %s:line %d)\n",
+ __FILE__, __LINE__);
+ leave(EXIT_FAILURE);
+
+ }
+ HDstrcat(g_list_of_fields, FIELD_SEP);
+ HDstrcat(g_list_of_fields, str);
+ }
break;
default:
- usage(h5tools_getprogname());
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
}
@@ -780,7 +778,7 @@ parse_command_line(int argc, const char *argv[])
/* check for object to be processed */
if (argc <= opt_ind) {
error_msg("missing dataset name\n");
- usage(h5tools_getprogname());
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
} /* parse_command_line() */
@@ -790,7 +788,7 @@ parse_command_line(int argc, const char *argv[])
* Function: catch_signal
*
* Purpose: The signal handler to catch the signals:
- * SIGTERM and SIGINT and exit from h5watch
+ * SIGTERM and SIGINT and set flag to get out of the main loop
*
* Return: No return
*
@@ -820,14 +818,14 @@ static void catch_signal(int H5_ATTR_UNUSED signo)
int
main(int argc, const char *argv[])
{
- char drivername[50];
- char *fname = NULL;
- char *dname = NULL;
- void *edata;
- H5E_auto2_t func;
- char *x;
- hid_t fid = -1;
- hid_t fapl = -1;
+ char drivername[50]; /* VFD name */
+ char *fname = NULL; /* File name */
+ char *dname = NULL; /* Dataset name */
+ void *edata; /* Error reporting */
+ H5E_auto2_t func; /* Error reporting */
+ char *x; /* Temporary string pointer */
+ hid_t fid = -1; /* File ID */
+ hid_t fapl = -1; /* File access property list */
/* Set up tool name and exit status */
h5tools_setprogname(PROGRAMNAME);
@@ -842,14 +840,14 @@ main(int argc, const char *argv[])
/* To exit from h5watch for SIGTERM signal */
if(HDsignal(SIGTERM, catch_signal) == SIG_ERR) {
- error_msg("An error occurred while setting a signal handler.\n");
- leave(EXIT_FAILURE);
+ error_msg("An error occurred while setting a signal handler.\n");
+ leave(EXIT_FAILURE);
}
/* To exit from h5watch for SIGINT signal */
if(HDsignal(SIGINT, catch_signal) == SIG_ERR) {
error_msg("An error occurred while setting a signal handler.\n");
- leave(EXIT_FAILURE);
+ leave(EXIT_FAILURE);
}
/* parse command line options */
@@ -857,7 +855,7 @@ main(int argc, const char *argv[])
if(argc <= opt_ind) {
error_msg("missing dataset name\n");
- usage(h5tools_getprogname());
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
@@ -877,9 +875,9 @@ main(int argc, const char *argv[])
* doesn't exist).
*/
if((fname = HDstrdup(argv[opt_ind])) == NULL) {
- error_msg("memory allocation failed (file %s:line %d)\n",
- __FILE__, __LINE__);
- h5tools_setstatus(EXIT_FAILURE);
+ error_msg("memory allocation failed (file %s:line %d)\n",
+ __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
}
/* Create a copy of file access property list */
@@ -891,80 +889,80 @@ main(int argc, const char *argv[])
return -1;
do {
- while(fname && *fname) {
- 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);
- break; /*success*/
- } /* end if */
-
- /* Shorten the file name; lengthen the object name */
- x = dname;
- dname = HDstrrchr(fname, '/');
- if(x)
- *x = '/';
- if(!dname)
- break;
- *dname = '\0';
- } /* end while */
+ while(fname && *fname) {
+ 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);
+ break; /*success*/
+ } /* end if */
+
+ /* Shorten the file name; lengthen the object name */
+ x = dname;
+ dname = HDstrrchr(fname, '/');
+ if(x)
+ *x = '/';
+ if(!dname)
+ break;
+ *dname = '\0';
+ } /* end while */
/* Try opening the file again if somehow unstable */
} while(g_retry-- > 0 && fid == FAIL);
if(fid < 0) {
- error_msg("unable to open file \"%s\"\n", fname);
- if(fname) HDfree(fname);
- if(fapl >= 0) H5Pclose(fapl);
- leave(EXIT_FAILURE);
+ error_msg("unable to open file \"%s\"\n", fname);
+ if(fname) HDfree(fname);
+ if(fapl >= 0) H5Pclose(fapl);
+ leave(EXIT_FAILURE);
}
if(!dname) {
- error_msg("no dataset specified\n");
- h5tools_setstatus(EXIT_FAILURE);
+ error_msg("no dataset specified\n");
+ h5tools_setstatus(EXIT_FAILURE);
} else {
- *dname = '/';
- x = dname;
- if((dname = HDstrdup(dname)) == NULL) {
- error_msg("memory allocation failed (file %s:line %d)\n",
- __FILE__, __LINE__);
- h5tools_setstatus(EXIT_FAILURE);
- } else {
- *x = '\0';
- /* Validate dataset */
- if(check_dataset(fid, dname) < 0)
- h5tools_setstatus(EXIT_FAILURE);
- /* Validate input "fields" */
- else if(g_list_of_fields && *g_list_of_fields)
- if(process_cmpd_fields(fid, dname) < 0)
- h5tools_setstatus(EXIT_FAILURE);
- }
+ *dname = '/';
+ x = dname;
+ if((dname = HDstrdup(dname)) == NULL) {
+ error_msg("memory allocation failed (file %s:line %d)\n",
+ __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
+ } else {
+ *x = '\0';
+ /* Validate dataset */
+ if(check_dataset(fid, dname) < 0)
+ h5tools_setstatus(EXIT_FAILURE);
+ /* Validate input "fields" */
+ else if(g_list_of_fields && *g_list_of_fields)
+ if(process_cmpd_fields(fid, dname) < 0)
+ h5tools_setstatus(EXIT_FAILURE);
+ }
}
/* If everything is fine, start monitoring the datset */
if(h5tools_getstatus() != EXIT_FAILURE)
- if(monitor_dataset(fid, dname) < 0)
- h5tools_setstatus(EXIT_FAILURE);
+ if(monitor_dataset(fid, dname) < 0)
+ h5tools_setstatus(EXIT_FAILURE);
/* Free spaces */
if(fname) HDfree(fname);
if(dname) HDfree(dname);
if(g_list_of_fields) HDfree(g_list_of_fields);
if(g_listv) {
- H5LD_clean_vector(g_listv);
- HDfree(g_listv);
+ H5LD_clean_vector(g_listv);
+ HDfree(g_listv);
}
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);
+ 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");
- h5tools_setstatus(EXIT_FAILURE);
+ error_msg("unable to close file\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
H5Eset_auto2(H5E_DEFAULT, func, edata);
diff --git a/hl/tools/h5watch/testh5watch.sh.in b/hl/tools/h5watch/testh5watch.sh.in
index 02f155f..33660b4 100644
--- a/hl/tools/h5watch/testh5watch.sh.in
+++ b/hl/tools/h5watch/testh5watch.sh.in
@@ -46,6 +46,7 @@ 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
+TRY_MAX=10 # Try running the test again
#
# 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
@@ -118,29 +119,30 @@ TOOLTEST() {
exitcode=$?
cat $actual_err >> $actual
if [ $exitcode -ne $retvalexpect ]; 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
+ 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
# Clean up output file
if test -z "$HDF5_NOCLEANUP"; then
rm -f $actual $actual_err
fi
}
+
#
#
#
@@ -150,8 +152,13 @@ TOOLTEST() {
# $1 -- the specified dataset to watch and to extend
# $2 -- the options to h5watch (can be NULL)
# $3 -- expected output from watching the object
+# $4 -- action 1
+# $5 -- action 2
#
TEST_WATCH() {
+try=0
+while [ $try -lt $TRY_MAX ] ;
+do
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
@@ -165,7 +172,7 @@ TEST_WATCH() {
rm -f $WRITER_MESSAGE # Remove the file just to be sure
rm -f $READER_MESSAGE # Remove the file just to be sure
#
- $EXTEND_BIN $TESTFILE $1 & # Extend the dataset; put in background
+ $EXTEND_BIN $TESTFILE $1 $4 $5& # Extend the dataset; put in background
extend_pid=$! # Get "extend" process ID
#
# Wait for message from "extend_dset" process to start h5watch--
@@ -178,10 +185,10 @@ TEST_WATCH() {
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:
+ 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
+ rm $WRITER_MESSAGE # remove the message file
+ break # get out of the while loop
fi
done;
#
@@ -207,7 +214,7 @@ TEST_WATCH() {
extend_exit=$? # Collect "extend" process' exit code
sleep 1 # Sleep to make sure output is flushed
kill $watch_pid # Kill h5watch
- wait $watch_pid # Wait for "h5watch" process to complete
+ wait $watch_pid # Wait for "h5watch" process to complete
#
if [ $extend_exit -ne 0 ]; then # Error returned from "extend" process
$ECHO "*FAILED*"
@@ -220,13 +227,21 @@ TEST_WATCH() {
$ECHO ""
fi
elif $CMP $expect $actual; then # Compare actual output with expected output
+ try=$TRY_MAX
$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/^/ /'
+ try="`expr $try + 1`"
+ if [ $try -lt $TRY_MAX ]; then
+ $ECHO "*RETRY"
+ rm -f $actual
+ rm -f $TESTFILE
+ 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
fi
#
@@ -236,45 +251,45 @@ TEST_WATCH() {
rm -f $actual
fi
fi
+done;
}
-
##############################################################################
##############################################################################
-### T H E T E S T S ###
+### T H E T E S T S ###
##############################################################################
##############################################################################
#
#
#################################################################################################
-# #
-# WATCH.h5: file with various types of datasets for testing-- #
-# The following datasets are chunked, H5D_ALLOC_TIME_INCR, max. dimensional setting: #
-# DSET_ONE: one-dimensional dataset #
-# DSET_TWO: two-dimensional dataset #
-# DSET_CMPD: one-dimensional dataset with compound type #
-# DSET_CMPD_ESC: one-dimensional dataset with compound type & escape/separator characters #
-# DSET_CMPD_TWO: two-dimensional dataset with compound type #
-# #
-# The following datasets are one-dimensional, chunked, max. dimension setting: #
-# DSET_ALLOC_EARLY: dataset with H5D_ALLOC_TIME_EARLY #
-# DSET_ALLOC_LATE: dataset H5D_ALLOC_TIME_LATE #
-# #
-# The following datasets are one-dimensional: #
-# DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE #
-# DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR #
-# #
+# #
+# WATCH.h5: file with various types of datasets for testing-- #
+# The following datasets are chunked, H5D_ALLOC_TIME_INCR, max. dimensional setting: #
+# DSET_ONE: one-dimensional dataset #
+# DSET_TWO: two-dimensional dataset #
+# DSET_CMPD: one-dimensional dataset with compound type #
+# DSET_CMPD_ESC: one-dimensional dataset with compound type & escape/separator characters #
+# DSET_CMPD_TWO: two-dimensional dataset with compound type #
+# #
+# The following datasets are one-dimensional, chunked, max. dimension setting: #
+# DSET_ALLOC_EARLY: dataset with H5D_ALLOC_TIME_EARLY #
+# DSET_ALLOC_LATE: dataset H5D_ALLOC_TIME_LATE #
+# #
+# The following datasets are one-dimensional: #
+# DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE #
+# DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR #
+# #
#################################################################################################
#
#
#################################################################################################
-# #
-# Tests on expected failures: #
-# Invalid file name #
-# Unable to find dataset, invalid dataset #
-# DSET_NONE and DSET_NOMAX #
-# Invalid input to options --width and --polling #
-# Invalid field names for -f option #
-# #
+# #
+# Tests on expected failures: #
+# Invalid file name #
+# Unable to find dataset, invalid dataset #
+# DSET_NONE and DSET_NOMAX #
+# Invalid input to options --width and --polling #
+# Invalid field names for -f option #
+# #
#################################################################################################
#
# Generate file with various types of datasets
@@ -319,13 +334,13 @@ $GEN_TEST_BIN
# 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
+TEST_WATCH DSET_ONE '' w-ext-one.ddl 3 0 #Increase
+TEST_WATCH DSET_ALLOC_EARLY '' w-ext-early.ddl -1 0 #Decrease
+TEST_WATCH DSET_ALLOC_LATE '' w-ext-late.ddl 0 0 #Same
+TEST_WATCH DSET_CMPD '' w-ext-cmpd.ddl 3 0 #Increase
+TEST_WATCH DSET_CMPD_ESC '' w-ext-cmpd-esc.ddl -1 0 #Decrease
+TEST_WATCH DSET_TWO '' w-ext-two.ddl 2 2 #Increase, Increase
+TEST_WATCH DSET_CMPD_TWO '' w-ext-cmpd-two.ddl 2 -9 #Increase, Decrease
#
echo "DONE WITH 2nd SET OF TESTS"
#
@@ -339,25 +354,25 @@ echo "DONE WITH 2nd SET OF TESTS"
# TEST.h5/DSET_CMPD with --fields=field1,field2
# TEST.h5/DSET_CMPD with --fields=field2.b,field4
# TEST.h5/DSET_CMPD with --fields=field2.b.a --fields=field2.c
-TEST_WATCH DSET_CMPD --fields=field1,field2 w-ext-cmpd-f1.ddl
-TEST_WATCH DSET_CMPD --fields=field2.b,field4 w-ext-cmpd-f2.ddl
-TEST_WATCH DSET_CMPD '--fields=field2.b.a --fields=field2.c' w-ext-cmpd-ff3.ddl
+TEST_WATCH DSET_CMPD --fields=field1,field2 w-ext-cmpd-f1.ddl -9 0 #Decrease
+TEST_WATCH DSET_CMPD --fields=field2.b,field4 w-ext-cmpd-f2.ddl 3 0 #Increase
+TEST_WATCH DSET_CMPD '--fields=field2.b.a --fields=field2.c' w-ext-cmpd-ff3.ddl 0 0 #Same
#
#
# TEST.h5/DSET_CMP_TWO with --fields=field1,field2
# TEST.h5/DSET_CMPD_TWO with --fields=field2.b --fields=field4
# TEST.h5/DSET_CMPD_TWO with --fields=field2.b.a,field2.c
-TEST_WATCH DSET_CMPD_TWO --fields=field1,field2 w-ext-cmpd-two-f1.ddl
-TEST_WATCH DSET_CMPD_TWO '--fields=field2.b --fields=field4' w-ext-cmpd-two-ff2.ddl
-TEST_WATCH DSET_CMPD_TWO --fields=field2.b.a,field2.c w-ext-cmpd-two-f3.ddl
+TEST_WATCH DSET_CMPD_TWO --fields=field1,field2 w-ext-cmpd-two-f1.ddl 2 0 #Increase, Same
+TEST_WATCH DSET_CMPD_TWO '--fields=field2.b --fields=field4' w-ext-cmpd-two-ff2.ddl -1 2 #Decrease, Increase
+TEST_WATCH DSET_CMPD_TWO --fields=field2.b.a,field2.c w-ext-cmpd-two-f3.ddl -1 -3 #Decrease, Decrease
#
#
# TEST.h5/DSET_CMPD_ESC with --fields=field\,1,field2\.
# TEST.h5/DSET_CMPD_ESC with --fields=field2\..\,b --fields=field4\,
# TEST.h5/DSET_CMPD_ESC with --fields=field2\..\,b.a,field2\..\\K
-TEST_WATCH DSET_CMPD_ESC '--fields=field\,1,field2\.' w-ext-cmpd-esc-f1.ddl
-TEST_WATCH DSET_CMPD_ESC '--fields=field2\..\,b --fields=field4\,' w-ext-cmpd-esc-ff2.ddl
-TEST_WATCH DSET_CMPD_ESC '--fields=field2\..\,b.a,field2\..\\K' w-ext-cmpd-esc-f3.ddl
+TEST_WATCH DSET_CMPD_ESC '--fields=field\,1,field2\.' w-ext-cmpd-esc-f1.ddl 3 0 #Increase
+TEST_WATCH DSET_CMPD_ESC '--fields=field2\..\,b --fields=field4\,' w-ext-cmpd-esc-ff2.ddl -1 0 #Decrease
+TEST_WATCH DSET_CMPD_ESC '--fields=field2\..\,b.a,field2\..\\K' w-ext-cmpd-esc-f3.ddl 3 0 #Increase
#
#
echo "DONE WITH 3rd SET OF TESTS"
@@ -376,11 +391,11 @@ echo "DONE WITH 3rd SET OF TESTS"
# 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
+TEST_WATCH DSET_ONE --dim w-ext-one-d.ddl 3 0 #Increase
+TEST_WATCH DSET_TWO --dim w-ext-two-d.ddl -2 0 #Decrease, Same
+TEST_WATCH DSET_TWO --width=30 w-ext-two-width.ddl 0 2 #Same, Increase
+TEST_WATCH DSET_CMPD --label w-ext-cmpd-label.ddl 3 0 #Increase
+TEST_WATCH DSET_ONE --simple w-ext-one-simple.ddl 2 0 #I
#
echo "DONE WITH 4th SET OF TESTS"
#