diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2016-12-11 19:25:08 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2016-12-11 19:25:08 (GMT) |
commit | 57afb68e465d8a0bc521a68c96c6d67db358e482 (patch) | |
tree | 0761afb1ad3c8a606a9be6b6b93654fbc980de8e /hl | |
parent | cc6eb939f4dec06e234835acbb5b3bc269b228c5 (diff) | |
download | hdf5-57afb68e465d8a0bc521a68c96c6d67db358e482.zip hdf5-57afb68e465d8a0bc521a68c96c6d67db358e482.tar.gz hdf5-57afb68e465d8a0bc521a68c96c6d67db358e482.tar.bz2 |
Bring SWMR-related tools changes from revise_chunks to develop.
Diffstat (limited to 'hl')
45 files changed, 3202 insertions, 1 deletions
diff --git a/hl/tools/CMakeLists.txt b/hl/tools/CMakeLists.txt index 560b1f2..8384b59 100644 --- a/hl/tools/CMakeLists.txt +++ b/hl/tools/CMakeLists.txt @@ -2,3 +2,5 @@ cmake_minimum_required (VERSION 3.1.0) PROJECT (HDF5_HL_TOOLS C CXX) add_subdirectory (${HDF5_HL_TOOLS_SOURCE_DIR}/gif2h5 ${HDF5_HL_TOOLS_BINARY_DIR}/gif2h5) + +add_subdirectory (${HDF5_HL_TOOLS_SOURCE_DIR}/h5watch ${HDF5_HL_TOOLS_BINARY_DIR}/h5watch) diff --git a/hl/tools/Makefile.am b/hl/tools/Makefile.am index 5ef8a96..090c4a6 100644 --- a/hl/tools/Makefile.am +++ b/hl/tools/Makefile.am @@ -22,6 +22,6 @@ include $(top_srcdir)/config/commence.am # All subdirectories -SUBDIRS=gif2h5 +SUBDIRS=gif2h5 h5watch include $(top_srcdir)/config/conclude.am diff --git a/hl/tools/h5watch/CMakeLists.txt b/hl/tools/h5watch/CMakeLists.txt new file mode 100644 index 0000000..e3a7e9d --- /dev/null +++ b/hl/tools/h5watch/CMakeLists.txt @@ -0,0 +1,59 @@ +cmake_minimum_required (VERSION 3.1.0) +PROJECT (HDF5_HL_TOOLS_H5WATCH) + +#----------------------------------------------------------------------------- +# Define Sources +#----------------------------------------------------------------------------- +set (H5WATCH_SOURCES + ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/h5watch +) + +#-- Add h5watch program +INCLUDE_DIRECTORIES (${HDF5_TOOLS_DIR}/lib) +INCLUDE_DIRECTORIES (${HDF5_HL_TOOLS_DIR}/src) +INCLUDE_DIRECTORIES (${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}) + +add_executable (h5watch ${H5WATCH_SOURCES}) +TARGET_NAMING (h5watch STATIC) +TARGET_C_PROPERTIES (h5watch STATIC " " " ") +target_link_libraries (h5watch ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) +set_target_properties (h5watch PROPERTIES FOLDER tools/hl) + +if (BUILD_TESTING) + #-- Add swmr_check_compat_vfd program + set (hl_swmr_check_compat_vfd_SOURCES + ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/swmr_check_compat_vfd.c + ) + add_executable (hl_swmr_check_compat_vfd ${hl_swmr_check_compat_vfd_SOURCES}) + TARGET_NAMING (hl_swmr_check_compat_vfd STATIC) + TARGET_C_PROPERTIES (hl_swmr_check_compat_vfd STATIC " " " ") + target_link_libraries (hl_swmr_check_compat_vfd ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) + set_target_properties (hl_swmr_check_compat_vfd PROPERTIES FOLDER tools/hl) + + #-- Add extend_dset program + set (extend_dset_SOURCES + ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/extend_dset.c + ) + add_executable (extend_dset ${extend_dset_SOURCES}) + TARGET_NAMING (extend_dset STATIC) + TARGET_C_PROPERTIES (extend_dset STATIC " " " ") + target_link_libraries (extend_dset ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) + set_target_properties (extend_dset PROPERTIES FOLDER tools/hl) + + add_executable (h5watchgentest ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/h5watchgentest.c) + TARGET_NAMING (h5watchgentest STATIC) + TARGET_C_PROPERTIES (h5watchgentest STATIC " " " ") + target_link_libraries (h5watchgentest ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET}) + set_target_properties (h5watchgentest PROPERTIES FOLDER generator/tools/hl) + + include (CMakeTests.cmake) +endif (BUILD_TESTING) + +#----------------------------------------------------------------------------- +# Add file(s) to CMake Install +#----------------------------------------------------------------------------- +install ( + TARGETS + h5watch + RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT hltoolsapplications +) diff --git a/hl/tools/h5watch/CMakeTests.cmake b/hl/tools/h5watch/CMakeTests.cmake new file mode 100644 index 0000000..3242a72 --- /dev/null +++ b/hl/tools/h5watch/CMakeTests.cmake @@ -0,0 +1,191 @@ + +############################################################################## +############################################################################## +### T E S T I N G ### +############################################################################## +############################################################################## + +set (H5WATCH_TEST_FILES + w-help1.ddl + w-err-cmpd1.ddl + w-err-cmpd2.ddl + w-err-cmpd3.ddl + w-err-cmpd4.ddl + w-err-cmpd5.ddl + w-err-dset1.ddl + w-err-dset2.ddl + w-err-dset-nomax.ddl + w-err-dset-none.ddl + w-err-file.ddl + w-err-poll.ddl + w-err-poll0.ddl + w-err-width.ddl + w-ext-cmpd.ddl + w-ext-cmpd-esc.ddl + w-ext-cmpd-esc-f1.ddl + w-ext-cmpd-esc-f3.ddl + w-ext-cmpd-esc-ff2.ddl + w-ext-cmpd-f1.ddl + w-ext-cmpd-f2.ddl + w-ext-cmpd-ff3.ddl + w-ext-cmpd-label.ddl + w-ext-cmpd-two.ddl + w-ext-cmpd-two-f1.ddl + w-ext-cmpd-two-f3.ddl + w-ext-cmpd-two-ff2.ddl + w-ext-early.ddl + w-ext-late.ddl + w-ext-one.ddl + w-ext-one-d.ddl + w-ext-one-simple.ddl + w-ext-two.ddl + w-ext-two-d.ddl + w-ext-two-width.ddl +) + +# make test dir +file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") +add_custom_target(h5watch-files ALL COMMENT "Copying files needed by h5watch tests") + +foreach (h5watch_file ${H5WATCH_TEST_FILES}) + set (dest "${PROJECT_BINARY_DIR}/testfiles/${h5watch_file}") + #message (STATUS " Copying ${h5watch_file}") + add_custom_command ( + TARGET h5watch-files + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${HDF5_HL_TOOLS_DIR}/testfiles/${h5watch_file} ${dest} + ) +endforeach (h5watch_file ${H5WATCH_TEST_FILES}) + +############################################################################## +############################################################################## +### T H E T E S T S M A C R O S ### +############################################################################## +############################################################################## + + MACRO (ADD_H5_TEST resultfile resultcode) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + add_test ( + NAME H5WATCH_ARGS-${resultfile}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${resultfile}.out + ${resultfile}.out.err + ) + set_tests_properties (H5WATCH_ARGS-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5WATCH_ARGS-${resultfile}-clear-objects PROPERTIES DEPENDS ${last_test}) + endif (NOT "${last_test}" STREQUAL "") + set (last_test "H5WATCH_ARGS-${resultfile}-clearall-objects") + add_test ( + NAME H5WATCH_ARGS-h5watch-${resultfile} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5watch>" + -D "TEST_ARGS:STRING=${ARGN}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=${resultfile}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}.ddl" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5WATCH_ARGS-h5watch-${resultfile} PROPERTIES DEPENDS H5WATCH_ARGS-${resultfile}-clear-objects) + set (last_test "H5WATCH_ARGS-${resultfile}") + endif (NOT HDF5_ENABLE_USING_MEMCHECKER) + ENDMACRO (ADD_H5_TEST resultfile resultcode resultoption) + + MACRO (ADD_H5_WATCH resultfile resultcode) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + add_test ( + NAME H5WATCH-${resultfile}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${resultfile}.h5 + ${resultfile}.out + ${resultfile}.out.err + ) + set_tests_properties (H5WATCH-${resultfile}-clear-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + add_test ( + NAME H5WATCH-${resultfile} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5watch>" + -D "TEST_ARGS:STRING=${ARGN}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=${resultfile}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}.txt" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5WATCH-${resultfile} PROPERTIES DEPENDS H5WATCH-${resultfile}-clear-objects) + endif (NOTHDF5_ENABLE_USING_MEMCHECKER) + ENDMACRO (ADD_H5_WATCH resultfile resultcode) + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + +# Check to see if the VFD specified by the HDF5_DRIVER environment variable +# supports SWMR. +set (SWMR_INCOMPAT ${hl_swmr_check_compat_vfd}) + +IF (NOT SWMR_INCOMPAT) +# Remove any output file left over from previous test run + add_test ( + NAME H5WATCH-clearall-objects + COMMAND ${CMAKE_COMMAND} + -E remove + WATCH.h5 + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5WATCH-clearall-objects PROPERTIES DEPENDS ${last_test}) + endif (NOT "${last_test}" STREQUAL "") + set (last_test "H5WATCH-clearall-objects") + +################################################################################################# +# # +# 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 # +# # +################################################################################################# +# create the output files to be used. + add_test (NAME H5WATCH-h5watchgentest COMMAND $<TARGET_FILE:h5watchgentest>) + set_tests_properties (H5WATCH-h5watchgentest PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + set_tests_properties (H5WATCH-h5watchgentest PROPERTIES DEPENDS "H5WATCH-clearall-objects") + set (last_test "H5WATCH-h5watchgentest") + +# Test on --help options + ADD_H5_TEST(w-help1 0 --help) +# +# Tests on expected failures + ADD_H5_TEST(w-err-dset1 1 WATCH.h5) + ADD_H5_TEST(w-err-dset2 1 WATCH.h5/group/DSET_CMPD) + ADD_H5_TEST(w-err-dset-none 1 WATCH.h5/DSET_NONE) + ADD_H5_TEST(w-err-dset-nomax 1 WATCH.h5/DSET_NOMAX) + ADD_H5_TEST(w-err-file 1 ../WATCH.h5/DSET_CMPD) + ADD_H5_TEST(w-err-width 1 --width=-8 WATCH.h5/DSET_ONE) + ADD_H5_TEST(w-err-poll 1 --polling=-8 WATCH.h5/DSET_ONE) + ADD_H5_TEST(w-err-poll0 1 --polling=0 WATCH.h5/DSET_ONE) +# +# Tests on invalid field names via --fields option for a compound typed dataset: DSET_CMPD + ADD_H5_TEST(w-err-cmpd1 1 --fields=fieldx WATCH.h5/DSET_CMPD) + ADD_H5_TEST(w-err-cmpd2 1 --fields=field1,field2. WATCH.h5/DSET_CMPD) + ADD_H5_TEST(w-err-cmpd3 1 --fields=field1,field2, WATCH.h5/DSET_CMPD) + ADD_H5_TEST(w-err-cmpd4 1 --fields=field1,field2.b.k WATCH.h5/DSET_CMPD) + ADD_H5_TEST(w-err-cmpd5 1 --fields=field1 --fields=field2.b.k WATCH.h5/DSET_CMPD) +# +ENDIF (NOT SWMR_INCOMPAT) diff --git a/hl/tools/h5watch/Makefile.am b/hl/tools/h5watch/Makefile.am new file mode 100644 index 0000000..a5891ef --- /dev/null +++ b/hl/tools/h5watch/Makefile.am @@ -0,0 +1,44 @@ +# +# 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. +## +## Makefile.am +## Run automake to generate a Makefile.in from this file. +# +# HDF5 Library Makefile(.in) +# + +include $(top_srcdir)/config/commence.am + +# Include src and tools/lib directories +AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib -I$(top_srcdir)/hl/src + +# These are our main targets, the tools +TEST_SCRIPT=testh5watch.sh +check_SCRIPTS=$(TEST_SCRIPT) +SCRIPT_DEPEND=swmr_check_compat_vfd$(EXEEXT) extend_dset$(EXEEXT) h5watch$(EXEEXT) + +bin_PROGRAMS=h5watch +noinst_PROGRAMS=swmr_check_compat_vfd h5watchgentest extend_dset + +# Add h5watch specific linker flags here +h5watch_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) + +# 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/extend_dset.c b/hl/tools/h5watch/extend_dset.c new file mode 100644 index 0000000..023e201 --- /dev/null +++ b/hl/tools/h5watch/extend_dset.c @@ -0,0 +1,518 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include "H5HLprivate2.h" + +/* + * Extending datasets in WATCH.h5 generated by h5watchgentest.c + */ +#define DSET_ONE "DSET_ONE" +#define DSET_TWO "DSET_TWO" +#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 + +/* + * 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); +void send_message(const char *file); +static herr_t wait_message(const char *file); + + +/* Data structures for datasets with compound data type */ +typedef struct sub22_t { + unsigned int a; + unsigned int b; + unsigned int c; +} sub22_t; + +typedef struct sub2_t { + unsigned int a; + sub22_t b; + unsigned int c; +} sub2_t; + +typedef struct sub4_t { + unsigned int a; + unsigned int b; +} sub4_t; + +typedef struct set_t { + unsigned int field1; + sub2_t field2; + double field3; + sub4_t field4; +} set_t; + +/* + * To send a message by creating the file. + */ +void +send_message(const char *file) +{ + FILE *id; + + id = HDfopen(file, "w+"); + HDfclose(id); +} /* end send_message() */ + +/* + * + * Repeatedly check for the message file. + * It will stop when the file exists or exceeds the timeout limit. + */ +static herr_t +wait_message(const char *file) +{ + FILE *id; /* File pointer */ + time_t t0, t1; /* Time info */ + + /* Start timer */ + HDtime(&t0); + + /* Wait for message from test script to start work */ + while((id = HDfopen(file, "r")) == NULL) { + /* Get current time */ + HDtime(&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(HDdifftime(t1, t0) > MESSAGE_TIMEOUT) + goto error; + } /* end while */ + + HDfclose(id); + HDunlink(file); + + return SUCCEED; + +error: + return FAIL; +} /* end wait_message() */ + +/* + *********************************************************************** + * + * 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} + *********************************************************************** + */ +static herr_t +extend_dset_two(const char *file, char *dname) +{ + hid_t fid = -1; /* file id */ + hid_t fapl = -1; /* file access property list id */ + hid_t did = -1; /* dataset id */ + hid_t sid = -1; /* dataspace id */ + hid_t dtid = -1; /* dataset's datatype id */ + int ndims; /* # of dimension sizes */ + unsigned i, j; /* local index variable */ + hsize_t ext_dims[2]; /* new dimension sizes after extension */ + hsize_t cur_dims[2]; /* current dimension sizes */ + size_t dtype_size; /* size of the dataset's datatype */ + unsigned num_elmts; /* number of elements in the dataset */ + int *ibuf = NULL; /* buffer for storing retrieved elements (integer) */ + set_t *cbuf = NULL; /* buffer for storing retrieved elemnets (compound) */ + + /* Allocate memory */ + if(NULL == (ibuf = (int *)HDcalloc(TEST_BUF_SIZE, sizeof(int)))) + goto error; + if(NULL == (cbuf = (set_t *)HDcalloc(TEST_BUF_SIZE, sizeof(set_t)))) + goto error; + + /* Create a copy of file access property list */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + + /* Set to use the latest library format */ + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + goto error; + + /* Open the file and dataset with SWMR write */ + if((fid = H5Fopen(file, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + goto error; + + if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + goto error; + + /* Send message to the test script to start "h5watch" */ + send_message(WRITER_MESSAGE); + + if((sid = H5Dget_space(did)) < 0) + goto error; + + if((ndims = H5Sget_simple_extent_ndims(sid)) < 0) + goto error; + + /* Get the size of the dataset's datatype */ + if((dtype_size = H5LDget_dset_type_size(did, NULL)) == 0) + goto error; + + /* Get the dataset's data type */ + if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + goto error; + + /* Wait for message from the test script to start extending dataset */ + if(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); + + /* 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)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; + + 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 */ + + /* 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) + goto error; + + } /* end for TWO_NTESTS */ + + /* Closing */ + if(H5Tclose(dtid) < 0) goto error; + if(H5Dclose(did) < 0) goto error; + if(H5Pclose(fapl) < 0) goto error; + if(H5Fclose(fid) < 0) goto error; + + HDfree(ibuf); + HDfree(cbuf); + + return SUCCEED; + +error: + H5E_BEGIN_TRY + H5Tclose(dtid); + H5Dclose(did); + H5Pclose(fapl); + H5Fclose(fid); + H5E_END_TRY + + if(ibuf) + HDfree(ibuf); + if(cbuf) + HDfree(cbuf); + + return FAIL; + +} /* end extend_dset_two() */ + +/* + *********************************************************************** + * + * 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 + * + *********************************************************************** + */ +static herr_t +extend_dset_one(const char *file, char *dname) +{ + hid_t fid = -1; /* file id */ + hid_t fapl = -1; /* file access property list id */ + hid_t did = -1; /* dataset id */ + hid_t dtid = -1; /* dataset's datatype id */ + hid_t sid = -1; /* dataspace id */ + hid_t mid = -1; /* memory space id */ + unsigned i, j; /* local index variable */ + hsize_t cur_dims[1]; /* current dimension sizes */ + hsize_t ext_dims[1]; /* new dimension sizes after extension */ + hsize_t offset[1]; /* starting offsets of appended data */ + hsize_t count[1]; /* dimension sizes of appended data */ + size_t dtype_size; /* size of the dataset's datatype */ + int *ibuf = NULL; /* buffer for storing retrieved elements (integer) */ + set_t *cbuf = NULL; /* buffer for storing retrieved elemnets (compound) */ + + /* Allocate memory */ + if(NULL == (ibuf = (int *)HDcalloc(TEST_BUF_SIZE, sizeof(int)))) + goto error; + if(NULL == (cbuf = (set_t *)HDcalloc(TEST_BUF_SIZE, sizeof(set_t)))) + goto error; + + /* Create a copy of file access property list */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + + /* Set to use the latest library format */ + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + goto error; + + /* Open the file and dataset with SWMR write */ + if((fid = H5Fopen(file, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0) + goto error; + + /* Send message to the test script to start "h5watch" */ + send_message(WRITER_MESSAGE); + + if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + goto error; + + /* Get size of the dataset's datatype */ + if((dtype_size = H5LDget_dset_type_size(did, NULL)) == 0) + goto error; + + /* Get dataset's datatype */ + if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) + goto error; + + /* Wait for message from the test script to start extending dataset */ + if(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)one_tests[i]; + + /* Extend the dataset */ + if(H5Dset_extent(did, ext_dims) < 0) + goto error; + + /* Write to the new appended region of the dataset */ + if(one_tests[i] > 0) { + + /* 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) + goto error; + + /* Set up memory space and get dataset's datatype */ + if((mid = H5Screate_simple(1, count, NULL)) < 0) + goto error; + + /* 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; + + } /* end for ONE_NTESTS */ + + /* Closing */ + if(H5Tclose(dtid) < 0) goto error; + if(H5Dclose(did) < 0) goto error; + if(H5Pclose(fapl) < 0) goto error; + if(H5Fclose(fid) < 0) goto error; + + HDfree(ibuf); + HDfree(cbuf); + + return SUCCEED; + +error: + H5E_BEGIN_TRY + H5Sclose(sid); + H5Sclose(mid); + H5Tclose(dtid); + H5Dclose(did); + H5Pclose(fapl); + H5Fclose(fid); + H5E_END_TRY + + if(ibuf) + HDfree(ibuf); + if(cbuf) + HDfree(cbuf); + + return FAIL; +} /* end extend_dset_one() */ + +/* Usage: extend_dset xx.h5 dname */ +int +main(int argc, const char *argv[]) +{ + char *dname = NULL; + char *fname = NULL; + + if(argc != 3) { + HDfprintf(stderr, "Should have file name and dataset name to be extended...\n"); + goto error; + } /* end if */ + + /* Get the dataset name to be extended */ + fname = HDstrdup(argv[1]); + dname = HDstrdup(argv[2]); + + if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { + if(extend_dset_one(fname, dname) < 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) + goto error; + } else if(!HDstrcmp(dname, DSET_TWO) || !HDstrcmp(dname, DSET_CMPD_TWO)) { + if(extend_dset_two(fname, dname) < 0) + goto error; + } else { + HDfprintf(stdout, "Dataset cannot be extended...\n"); + goto error; + } /* end if-else */ + + HDexit(EXIT_SUCCESS); + +error: + if(dname) + HDfree(dname); + if(fname) + HDfree(fname); + HDexit(EXIT_FAILURE); +} /* end main() */ + diff --git a/hl/tools/h5watch/h5watch.c b/hl/tools/h5watch/h5watch.c new file mode 100644 index 0000000..97dca7a --- /dev/null +++ b/hl/tools/h5watch/h5watch.c @@ -0,0 +1,973 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include "h5tools.h" +#include "h5tools_dump.h" +#include "H5LDprivate.h" + +/* + * 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 */ + + +/* + * Note:(see comments in hl/src/H5LDprivate.h) + * 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" */ + +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 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 herr_t 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); +static herr_t monitor_dataset(hid_t fid, char *dsetname); +static herr_t process_cmpd_fields(hid_t fid, char *dsetname); +static herr_t check_dataset(hid_t fid, char *dsetname); +static void leave(int ret); +static void usage(const char *prog); +static void parse_command_line(int argc, const char *argv[]); + + +/* + * Command-line options: The user can only specify long-named parameters. + * The long-named ones can be partially spelled. When + * adding more, make sure that they don't clash with each other. + */ +static const char *s_opts ="?"; +static struct long_options l_opts[] = { + { "help", no_arg, 'h' }, + { "hel", no_arg, 'h' }, + { "dim", no_arg, 'd' }, + { "di", no_arg, 'd' }, + { "label", no_arg, 'l' }, + { "labe", no_arg, 'l' }, + { "lab", no_arg, 'l' }, + { "la", no_arg, 'l' }, + { "simple", no_arg, 'S' }, + { "simpl", no_arg, 'S' }, + { "simp", no_arg, 'S' }, + { "sim", no_arg, 'S' }, + { "si", no_arg, 'S' }, + { "hexdump", no_arg, 'x' }, + { "hexdum", no_arg, 'x' }, + { "hexdu", no_arg, 'x' }, + { "hexd", no_arg, 'x' }, + { "hex", no_arg, 'x' }, + { "width", require_arg, 'w' }, + { "widt", require_arg, 'w' }, + { "wid", require_arg, 'w' }, + { "wi", require_arg, 'w' }, + { "polling", require_arg, 'p' }, + { "pollin", require_arg, 'p' }, + { "polli", require_arg, 'p' }, + { "poll", require_arg, 'p' }, + { "pol", require_arg, 'p' }, + { "po", require_arg, 'p' }, + { "fields", require_arg, 'f' }, + { "field", require_arg, 'f' }, + { "fiel", require_arg, 'f' }, + { "fie", require_arg, 'f' }, + { "fi", require_arg, 'f' }, + { "version", no_arg, 'V' }, + { "versio", no_arg, 'V' }, + { "versi", no_arg, 'V' }, + { "vers", no_arg, 'V' }, + { "ver", no_arg, 'V' }, + { "ve", no_arg, 'V' }, + { NULL, 0, '\0' } +}; + +/*------------------------------------------------------------------------- + * 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). + * + * Return: 0 on success; negative on failure + * + * Programmer: Vailin Choi; August 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +doprint(hid_t did, hsize_t *start, hsize_t *block, int rank) +{ + h5tools_context_t ctx; /* print context */ + h5tool_format_t info; /* Format info for the tools library */ + static char fmt_double[16], fmt_float[16]; /* Format info */ + struct subset_t subset; /* Subsetting info */ + hsize_t ss_start[H5S_MAX_RANK]; /* Info for hyperslab */ + hsize_t ss_stride[H5S_MAX_RANK]; /* Info for hyperslab */ + hsize_t ss_block[H5S_MAX_RANK]; /* Info for hyperslab */ + hsize_t ss_count[H5S_MAX_RANK]; /* Info for hyperslab */ + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + /* Subsetting information for the tools library printing routines */ + subset.start.data = ss_start; + subset.stride.data = ss_stride; + subset.block.data = ss_block; + subset.count.data = ss_count; + + /* Initialize subsetting information */ + for(i = 0; i < rank; i++) { + subset.stride.data[i] = 1; + subset.count.data[i] = 1; + subset.start.data[i] = start[i]; + subset.block.data[i] = block[i]; + } /* end for */ + + HDmemset(&ctx, 0, sizeof(ctx)); + + /* Set to all default values and then override */ + HDmemset(&info, 0, sizeof info); + + if(g_simple_output) { + info.idx_fmt = ""; + info.line_ncols = 65535; /*something big*/ + info.line_per_line = 1; + info.line_multi_new = 0; + info.line_pre = " "; + info.line_cont = " "; + + info.arr_pre = ""; + info.arr_suf = ""; + info.arr_sep = " "; + + info.cmpd_pre = ""; + info.cmpd_suf = ""; + info.cmpd_sep = " "; + + /* The "fields" selected by the user */ + info.cmpd_listv = (const struct H5LD_memb_t * const *)g_listv; + + if(g_label) + info.cmpd_name = "%s="; + + info.elmt_suf1 = " "; + info.str_locale = ESCAPE_HTML; + + } else { + info.idx_fmt = "(%s)"; + if(!g_display_width) { + info.line_ncols = 65535; + info.line_per_line = 1; + } /* end if */ + else + info.line_ncols = (unsigned)g_display_width; + + info.line_multi_new = 1; + + /* The "fields" selected by the user */ + info.cmpd_listv = (const struct H5LD_memb_t * const *)g_listv; + if(g_label) + info.cmpd_name = "%s="; + info.line_pre = " %s "; + info.line_cont = " %s "; + info.str_repeat = 8; + } /* end else */ + + /* Floating point types should display full precision */ + sprintf(fmt_float, "%%1.%dg", FLT_DIG); + info.fmt_float = fmt_float; + sprintf(fmt_double, "%%1.%dg", DBL_DIG); + info.fmt_double = fmt_double; + + info.dset_format = "DSET-%s "; + info.dset_hidefileno = 0; + + info.obj_format = "-%lu:"H5_PRINTF_HADDR_FMT; + info.obj_hidefileno = 0; + + info.dset_blockformat_pre = "%sBlk%lu: "; + info.dset_ptformat_pre = "%sPt%lu: "; + + info.line_indent = ""; + + if(g_display_hex) { + /* Print all data in hexadecimal format if the `-x' or `--hexdump' + * command line switch was given. */ + info.raw = TRUE; + } /* end if */ + + /* Print the values. */ + if((ret_value = h5tools_dump_dset(stdout, &info, &ctx, did, &subset)) < 0) + error_msg("unable to print data\n"); + + HDfprintf(stdout, "\n"); + + return ret_value; + +} /* end doprint() */ + +/*------------------------------------------------------------------------- + * 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 + * + * Programmer: Vailin Choi; August 2010 + * + *------------------------------------------------------------------------- + */ +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 */ + + ind = rank - subrank; + + if((subrank - 1) > 0) { + /* continue onto the next dimension */ + for (i = 0; i < (hssize_t)MIN(prev_dims[ind], cur_dims[ind]); i++){ + start[ind] = (hsize_t)i; + if((ret_value = slicendump(did, prev_dims, cur_dims, start, block, rank, subrank-1)) < 0) + goto done; + } /* end for */ + } /* end if */ + + /* this dimension remains the same or shrinking */ + if(cur_dims[ind] <= prev_dims[ind]) + goto done; + + /* select first the slice for the faster changing dimension */ + /* select later the whole slice for the slower changing dimension */ + start[ind] = prev_dims[ind]; + block[ind] = cur_dims[ind] - prev_dims[ind]; + + for(i = ind + 1; i < rank; i++){ + start[i] = 0; + block[i] = cur_dims[i]; + } /* end for */ + + /* Print the appended data */ + ret_value = doprint(did, start, block, rank); + +done: + return ret_value; +} /* end slicendump() */ + + +/*------------------------------------------------------------------------- + * 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 + * + * Return: Non-negative on success: dataset can be monitored + * Negative on failure: dataset cannot be monitored + * + * Programmer: Vailin Choi; August 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +monitor_dataset(hid_t fid, char *dsetname) +{ + hid_t did; /* dataset id */ + hid_t sid; /* dataspace id */ + int ndims; /* # of dimensions in the dataspace */ + int i, u; /* local index variable */ + hsize_t prev_dims[H5S_MAX_RANK]; /* current dataspace dimensions */ + hsize_t cur_dims[H5S_MAX_RANK]; /* previous dataspace dimensions */ + herr_t ret_value = SUCCEED; /* return value */ + + HDfprintf(stdout, "Monitoring dataset %s...\n", 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; + } + if((sid = H5Dget_space(did)) < 0) { + 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; + } + + while(1) { + + /* 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; + } + + /* 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)); + + /* Sleep before next monitor */ + HDsleep(g_polling_interval); + } /* end while */ + +done: + /* Closing */ + H5E_BEGIN_TRY + H5Dclose(did); + H5E_END_TRY + + return(ret_value); +} /* monitor_dataset() */ + +/*------------------------------------------------------------------------- + * Function: process_cmpd_fields + * + * Purpose: To check whether the fields selected in "g_list_of_fields" + * are valid fields associated with the dataset. + * + * Return: 0 on success; negative on failure + * + * Programmer: Vailin Choi; August 2010 + * + *------------------------------------------------------------------------- + */ +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 */ + + 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; + } + + /* 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"); + 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; + } + + /* 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"); + ret_value = FAIL; + goto done; + } + + /* Estimate the number of comma-separated fields in "g_list of_fields" */ + len = HDstrlen(g_list_of_fields)/2 + 2; + + /* 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"); + ret_value = FAIL; + 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; + goto done; + } + + /* Will free memory for g_listv and g_dup_fields when exiting from h5watch */ +done: + /* Closing */ + H5E_BEGIN_TRY + H5Tclose(dtid); + H5Tclose(tid); + H5Dclose(did); + H5E_END_TRY + return(ret_value); +} /* process_cmpd_fields() */ + + +/*------------------------------------------------------------------------- + * Function: check_dataset + * + * Purpose: To check whether a dataset can be monitored: + 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 + * + * Programmer: Vailin Choi; August 2010 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +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 */ + int ndims; /* # of dimensions in the dataspace */ + unsigned u; /* Local index variable */ + hsize_t cur_dims[H5S_MAX_RANK]; /* size of dataspace dimensions */ + hsize_t max_dims[H5S_MAX_RANK]; /* maximum size of dataspace dimensions */ + hbool_t unlim_max_dims = FALSE; /* whether dataset has unlimited or max. dimension setting */ + void *edata; + H5E_auto2_t func; + H5D_layout_t layout; + herr_t ret_value = SUCCEED; /* Return value */ + + /* Disable error reporting */ + H5Eget_auto2(H5E_DEFAULT, &func, &edata); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + + /* 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; + } + + /* Get dataset's creation property list */ + if((dcp = H5Dget_create_plist(did)) < 0) { + error_msg("unable to get dataset's creation property list \"%s\"\n", dsetname); + ret_value = FAIL; + goto done; + } + + /* Query dataset's layout; the layout should be chunked or virtual */ + if((layout = H5Pget_layout(dcp)) < 0) { + error_msg("unable to get dataset layout \"%s\"\n", dsetname); + ret_value = FAIL; + goto done; + } + if(layout != H5D_CHUNKED && layout != H5D_VIRTUAL) { + error_msg("\"%s\" should be a chunked or virtual dataset\n", dsetname); + ret_value = FAIL; + goto done; + } + + HDmemset(cur_dims, 0, sizeof cur_dims); + HDmemset(max_dims, 0, sizeof max_dims); + + /* 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; + } + + /* 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; + } + + /* 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; + break; + } + + if(!unlim_max_dims) { + error_msg("\"%s\" should have unlimited or max. dimension setting\n", dsetname); + ret_value = FAIL; + } + +done: + H5Eset_auto2(H5E_DEFAULT, func, edata); + + /* Closing */ + H5E_BEGIN_TRY + H5Sclose(sid); + H5Pclose(dcp); + H5Dclose(did); + H5E_END_TRY + + return(ret_value); +} /* check_dataset() */ + + +/*------------------------------------------------------------------------- + * Function: leave + * + * Purpose: Close the H5 Tools library and exit + * + * Return: Does not return + * + * Programmer: Vailin Choi; August 2010 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +leave(int ret) +{ + h5tools_close(); + + exit(ret); +} + + +/*------------------------------------------------------------------------- + * Function: usage + * + * Purpose: Print the usage message about h5watch (only long options) + * + * Return: void + * + * Programmer: Vailin Choi; August 2010 + * + * Modifications: + *------------------------------------------------------------------------- + */ +static void +usage(const char *prog) +{ + HDfflush(stdout); + HDfprintf(stdout, "Usage: %s [OPTIONS] [OBJECT]\n", prog); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, " OPTIONS\n"); + HDfprintf(stdout, " --help Print a usage message and exit.\n"); + HDfprintf(stdout, " --version Print version number and exit.\n"); + HDfprintf(stdout, " --label Label members of compound typed dataset.\n"); + HDfprintf(stdout, " --simple Use a machine-readable output format.\n"); + HDfprintf(stdout, " --dim Monitor changes in size of dataset dimensions only.\n"); + HDfprintf(stdout, " --width=N Set the number of columns to N for output.\n"); + HDfprintf(stdout, " A value of 0 sets the number of columns to the\n"); + HDfprintf(stdout, " maximum (65535). The default width is 80 columns.\n"); + HDfprintf(stdout, " --polling=N Set the polling interval to N (in seconds) when the\n"); + HDfprintf(stdout, " dataset will be checked for appended data. The default\n"); + HDfprintf(stdout, " polling interval is 1.\n"); + HDfprintf(stdout, " --fields=<list_of_fields>\n"); + HDfprintf(stdout, " Display data for the fields specified in <list_of_fields>\n"); + HDfprintf(stdout, " for a compound data type. <list_of_fields> can be\n"); + HDfprintf(stdout, " specified as follows:\n"); + HDfprintf(stdout, " 1) A comma-separated list of field names in a\n"); + HDfprintf(stdout, " compound data type. \",\" is the separator\n"); + HDfprintf(stdout, " for field names while \".\" is the separator\n"); + HDfprintf(stdout, " for a nested field.\n"); + HDfprintf(stdout, " 2) A single field name in a compound data type.\n"); + HDfprintf(stdout, " Can use this option multiple times.\n"); + HDfprintf(stdout, " Note that backslash is the escape character to avoid\n"); + HDfprintf(stdout, " characters in field names that conflict with the tool's\n"); + HDfprintf(stdout, " separators.\n"); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, " OBJECT is specified as [<filename>/<path_to_dataset>/<dsetname>]\n"); + HDfprintf(stdout, " <filename> Name of the HDF5 file. It may be preceded by path\n"); + HDfprintf(stdout, " separated by slashes to the specified HDF5 file.\n"); + HDfprintf(stdout, " <path_to_dataset> Path separated by slashes to the specified dataset\n"); + HDfprintf(stdout, " <dsetname> Name of the dataset\n"); + HDfprintf(stdout, "\n"); + HDfprintf(stdout, " User can end the h5watch process by ctrl-C (SIGINT) or kill the process (SIGTERM).\n"); + +} /* usage() */ + + +/*------------------------------------------------------------------------- + * Function: parse_command_line + * + * Purpose: Parse the command line for h5watch (take only long options) + * + * Return: Success: Set the corresponding command flags and return void + * Failure: Exits program with EXIT_FAILURE value. + * + * Programmer: Vailin Choi; August 2010 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +parse_command_line(int argc, const char *argv[]) +{ + int opt; /* Command line option */ + int tmp; + + /* no arguments */ + if (argc == 1) { + usage(h5tools_getprogname()); + leave(EXIT_FAILURE); + } + + /* parse command line options */ + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { + switch ((char)opt) { + case '?': + case 'h': /* --help */ + usage(h5tools_getprogname()); + leave(EXIT_SUCCESS); + + case 'V': /* --version */ + print_version(progname); + leave(EXIT_SUCCESS); + 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); + } + break; + + case 'd': /* --dim */ + g_monitor_size_only = TRUE; + break; + + case 'S': /* --simple */ + g_simple_output = TRUE; + break; + + 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; + 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); + } + + break; + + default: + usage(h5tools_getprogname()); + leave(EXIT_FAILURE); + } + } + + + /* check for object to be processed */ + if (argc <= opt_ind) { + error_msg("missing dataset name\n"); + usage(h5tools_getprogname()); + leave(EXIT_FAILURE); + } +} /* parse_command_line() */ + + +/*------------------------------------------------------------------------- + * Function: catch_signal + * + * Purpose: The signal handler to catch the signals: + * SIGTERM and SIGINT and exit from h5watch + * + * Return: No return + * + * Programmer: Vailin Choi; November 2014 + * + *------------------------------------------------------------------------- + */ +static void catch_signal(int H5_ATTR_UNUSED signo) +{ + /* Exit from h5watch */ + leave(EXIT_SUCCESS); + +} /* catch_signal() */ + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: h5watch + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Vailin Choi; August 2010 + * + *------------------------------------------------------------------------- + */ +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; + + /* Set up tool name and exit status */ + h5tools_setprogname(PROGRAMNAME); + h5tools_setstatus(EXIT_SUCCESS); + + /* Disable error reporting */ + H5Eget_auto2(H5E_DEFAULT, &func, &edata); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + + /* Initialize h5tools lib */ + h5tools_init(); + + /* 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); + } + + /* 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); + } + + /* parse command line options */ + parse_command_line(argc, argv); + + if(argc <= opt_ind) { + error_msg("missing dataset name\n"); + usage(h5tools_getprogname()); + leave(EXIT_FAILURE); + } + + /* Mostly copied from tools/h5ls coding & modified accordingly */ + /* + * [OBJECT] is specified as + * [<filename>/<path_to_dataset>/<dsetname>] + * + * Example: ../dir1/foo/bar/dset + * \_________/\______/ + * file obj + * + * The dichotomy is determined by calling H5Fopen() repeatedly until it + * succeeds. The first call uses the entire name and each subsequent call + * chops off the last component. If we reach the beginning of the name + * then there must have been something wrong with the file (perhaps it + * 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); + } + + /* 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_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); + } + + if(!dname) { + 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); + } + } + + /* If everything is fine, start monitoring the datset */ + if(h5tools_getstatus() != 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); + } + 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"); + h5tools_setstatus(EXIT_FAILURE); + } + + H5Eset_auto2(H5E_DEFAULT, func, edata); + /* exit */ + leave(h5tools_getstatus()); +} /* main() */ + diff --git a/hl/tools/h5watch/h5watchgentest.c b/hl/tools/h5watch/h5watchgentest.c new file mode 100644 index 0000000..12298ca --- /dev/null +++ b/hl/tools/h5watch/h5watchgentest.c @@ -0,0 +1,350 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include "hdf5.h" +#include "H5HLprivate2.h" + +/* + * 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 and member names with + * 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 + */ +#define ONE_DIMS0 10 +#define MAX_ONE_DIMS0 100 + +#define DSET_ONE "DSET_ONE" +#define DSET_NONE "DSET_NONE" +#define DSET_NOMAX "DSET_NOMAX" +#define DSET_ALLOC_LATE "DSET_ALLOC_LATE" +#define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY" +#define DSET_CMPD "DSET_CMPD" +#define DSET_CMPD_ESC "DSET_CMPD_ESC" + +#define TWO_DIMS0 4 +#define TWO_DIMS1 10 +#define MAX_TWO_DIMS0 60 +#define MAX_TWO_DIMS1 100 + +#define DSET_TWO "DSET_TWO" +#define DSET_CMPD_TWO "DSET_CMPD_TWO" + +#define CHUNK_SIZE 2 + +#define FILE "WATCH.h5" + +/* Data structures for datasets with compound types */ +typedef struct sub22_t { + unsigned int a; + unsigned int b; + unsigned int c; +} sub22_t; + +typedef struct sub2_t { + unsigned int a; + sub22_t b; + unsigned int c; +} sub2_t; + +typedef struct sub4_t { + unsigned int a; + unsigned int b; +} sub4_t; + +typedef struct set_t { + unsigned int field1; + sub2_t field2; + double field3; + sub4_t field4; +} set_t; + +/* + ************************************************************************************** + * + * Create a dataset with the given input parameters + * Write to the dataset with the given "data" + * + ************************************************************************************** + */ +static herr_t +generate_dset(hid_t fid, const char *dname, int ndims, hsize_t *dims, hsize_t *maxdims, hid_t dtid, void *data) +{ + 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 */ + + /* Create the dataspace */ + if((sid = H5Screate_simple(ndims, dims, maxdims)) < 0) + goto done; + + /* Set up dataset's creation properties */ + if(!HDstrcmp(dname, DSET_NONE)) + dcpl = H5P_DEFAULT; + else { + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto done; + for(i = 0; i < ndims; i++) + chunk_dims[i] = CHUNK_SIZE; + if(H5Pset_chunk(dcpl, ndims, chunk_dims) < 0) + goto done; + } /* end else */ + + if(!HDstrcmp(dname, DSET_ALLOC_LATE)) { + if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) + goto done; + } else if(!HDstrcmp(dname, DSET_ALLOC_EARLY)) { + if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0) + goto done; + } /* end if-else */ + + /* Create the dataset */ + if((did = H5Dcreate2(fid, dname, dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + goto done; + + /* Write to the dataset */ + if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + goto done; + + /* Closing */ + if(H5Pclose(dcpl) < 0) goto done; + if(H5Sclose(sid) < 0) goto done; + if(H5Dclose(did) < 0) goto done; + + return SUCCEED; + +done: + H5E_BEGIN_TRY + H5Sclose(sid); + H5Pclose(dcpl); + H5Dclose(did); + H5E_END_TRY + + return FAIL; +} /* end generate_dset() */ + +int +main(void) +{ + 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 */ + + /* Create a copy of file access property list */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + HDexit(EXIT_FAILURE); + /* Set to use the latest library format */ + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + HDexit(EXIT_FAILURE); + + /* Create a file with the latest format */ + if((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + HDexit(EXIT_FAILURE); + + /* Initialization for one-dimensional dataset */ + cur_dims[0] = ONE_DIMS0; + max_dims[0] = MAX_ONE_DIMS0; + for(i = 0; i < ONE_DIMS0; i++) + one_data[i] = i; + + /* Generate DSET_ONE, DSET_NONE, DSET_NOMAX, DSET_ALLOC_LATE, DSET_EARLY */ + if(generate_dset(fid, DSET_ONE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + goto done; + if(generate_dset(fid, DSET_NONE, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) + goto done; + if(generate_dset(fid, DSET_NOMAX, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0) + goto done; + if(generate_dset(fid, DSET_ALLOC_LATE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + goto done; + if(generate_dset(fid, DSET_ALLOC_EARLY, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0) + goto done; + + /* Initialization for two-dimensional dataset */ + cur2_dims[0] = TWO_DIMS0; + cur2_dims[1] = TWO_DIMS1; + max2_dims[0] = MAX_TWO_DIMS0; + max2_dims[1] = MAX_TWO_DIMS1; + + for(i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) + two_data[i] = i; + + /* Generate DSET_TWO */ + if(generate_dset(fid, DSET_TWO, 2, cur2_dims, max2_dims, H5T_NATIVE_INT, two_data) < 0) + goto done; + + /* Initialization for one-dimensional compound typed dataset */ + cur_dims[0] = ONE_DIMS0; + max_dims[0] = MAX_ONE_DIMS0; + + for(i = 0; i < ONE_DIMS0; i++) { + one_cbuf[i].field1 = 1; + one_cbuf[i].field2.a = 2; + one_cbuf[i].field2.c = 4; + one_cbuf[i].field2.b.a = 20; + one_cbuf[i].field2.b.b = 40; + one_cbuf[i].field2.b.c = 80; + one_cbuf[i].field3 = 3.0F; + one_cbuf[i].field4.a = 4; + one_cbuf[i].field4.b = 8; + } /* end for */ + + /* Create the compound type */ + if((sub22_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub22_t))) < 0) + goto done; + if(H5Tinsert(sub22_tid, "a", HOFFSET(sub22_t, a), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(sub22_tid, "b", HOFFSET(sub22_t, b), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(sub22_tid, "c", HOFFSET(sub22_t, c), H5T_NATIVE_INT) < 0) + goto done; + + if((sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) + goto done; + if(H5Tinsert(sub2_tid, "a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(sub2_tid, "b", HOFFSET(sub2_t, b), sub22_tid) < 0) + goto done; + if(H5Tinsert(sub2_tid, "c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) + goto done; + + if((sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) + goto done; + if(H5Tinsert(sub4_tid, "a", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(sub4_tid, "b", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) + goto done; + + if((set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) + goto done; + if(H5Tinsert(set_tid, "field1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(set_tid, "field2", HOFFSET(set_t, field2), sub2_tid) < 0) + goto done; + if(H5Tinsert(set_tid, "field3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) + goto done; + if(H5Tinsert(set_tid, "field4", HOFFSET(set_t, field4), sub4_tid) < 0) + goto done; + + /* Create the compound type with escape/separator characters */ + if((esc_sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0) + goto done; + if(H5Tinsert(esc_sub2_tid, ".a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(esc_sub2_tid, ",b", HOFFSET(sub2_t, b), sub22_tid) < 0) + goto done; + if(H5Tinsert(esc_sub2_tid, "\\K", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0) + goto done; + + if((esc_sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0) + goto done; + if(H5Tinsert(esc_sub4_tid, "a.", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(esc_sub4_tid, "b,", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0) + goto done; + + if((esc_set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0) + goto done; + if(H5Tinsert(esc_set_tid, "field,1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0) + goto done; + if(H5Tinsert(esc_set_tid, "field2.", HOFFSET(set_t, field2), esc_sub2_tid) < 0) + goto done; + if(H5Tinsert(esc_set_tid, "field\\3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0) + goto done; + if(H5Tinsert(esc_set_tid, "field4,", HOFFSET(set_t, field4), esc_sub4_tid) < 0) + goto done; + + /* Generate DSET_CMPD, DSET_CMPD_ESC */ + if(generate_dset(fid, DSET_CMPD, 1, cur_dims, max_dims, set_tid, one_cbuf) < 0) + goto done; + if(generate_dset(fid, DSET_CMPD_ESC, 1, cur_dims, max_dims, esc_set_tid, one_cbuf) < 0) + goto done; + + /* Initialization for two-dimensional compound typed dataset */ + cur2_dims[0] = TWO_DIMS0; + cur2_dims[1] = TWO_DIMS1; + max2_dims[0] = MAX_TWO_DIMS0; + max2_dims[0] = MAX_TWO_DIMS1; + + for(i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) { + two_cbuf[i].field1 = 1; + two_cbuf[i].field2.a = 2; + two_cbuf[i].field2.c = 4; + two_cbuf[i].field2.b.a = 20; + two_cbuf[i].field2.b.b = 40; + two_cbuf[i].field2.b.c = 80; + two_cbuf[i].field3 = 3.0F; + two_cbuf[i].field4.a = 4; + two_cbuf[i].field4.b = 8; + } /* end for */ + + /* Generate DSET_CMPD_TWO */ + if(generate_dset(fid, DSET_CMPD_TWO, 2, cur2_dims, max2_dims, set_tid, two_cbuf) < 0) + goto done; + + /* Closing */ + if(H5Tclose(sub22_tid) < 0) goto done; + if(H5Tclose(sub2_tid) < 0) goto done; + if(H5Tclose(sub4_tid) < 0) goto done; + if(H5Tclose(set_tid) < 0) goto done; + 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; + + HDexit(EXIT_SUCCESS); + +done: + H5E_BEGIN_TRY + H5Tclose(sub22_tid); + H5Tclose(sub2_tid); + H5Tclose(sub4_tid); + H5Tclose(set_tid); + H5Tclose(esc_sub2_tid); + H5Tclose(esc_sub4_tid); + H5Tclose(esc_set_tid); + H5Pclose(fapl); + H5Fclose(fid); + H5E_END_TRY + + HDexit(EXIT_FAILURE); +} /* end main() */ + diff --git a/hl/tools/h5watch/swmr_check_compat_vfd.c b/hl/tools/h5watch/swmr_check_compat_vfd.c new file mode 100644 index 0000000..87b87c4 --- /dev/null +++ b/hl/tools/h5watch/swmr_check_compat_vfd.c @@ -0,0 +1,59 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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: This is a small program that checks if the HDF5_DRIVER + * environment variable is set to a value that supports SWMR. + * + * It is intended for use in shell scripts. + */ + +#include <stdlib.h> + +#include "H5private.h" + +/* This file needs to access the file driver testing code */ +#define H5FD_FRIEND /*suppress error about including H5FDpkg */ +#define H5FD_TESTING +#include "H5FDpkg.h" /* File drivers */ + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Inspects the HDF5_DRIVER environment variable, which + * determines the VFD that the test harness will use with + * the majority of the tests. + * + * Return: VFD supports SWMR: EXIT_SUCCESS + * + * VFD does not support SWMR + * or failure: EXIT_FAILURE + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + char *driver = NULL; + + driver = HDgetenv("HDF5_DRIVER"); + + if(H5FD_supports_swmr_test(driver)) + return EXIT_SUCCESS; + else + return EXIT_FAILURE; + +} /* end main() */ + diff --git a/hl/tools/h5watch/testh5watch.sh.in b/hl/tools/h5watch/testh5watch.sh.in new file mode 100644 index 0000000..89fbf95 --- /dev/null +++ b/hl/tools/h5watch/testh5watch.sh.in @@ -0,0 +1,391 @@ +#! /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 h5watch tool +# + +# Check to see if the VFD specified by the HDF5_DRIVER environment variable +# supports SWMR. +./swmr_check_compat_vfd +rc=$? +if [[ $rc != 0 ]] ; then + echo + echo "The VFD specified by the HDF5_DRIVER environment variable" + echo "does not support SWMR." + echo + echo "h5watch tests skipped" + echo + exit 0 +fi + +H5WATCH=h5watch # The tool name +H5WATCH_BIN=`pwd`/$H5WATCH # The path of H5WATCH +EXTEND_DSET=extend_dset # Routine to extend the dataset when watching +EXTEND_BIN=`pwd`/$EXTEND_DSET # The path of EXTEND_DSET +# +EXIT_SUCCESS=0 +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 +# +CMP='cmp -s' +DIFF='diff -c' +NLINES=20 # Max. lines of output to display if test fails +# +# Mac OS: just to make sure echo "backslash backslash" behaves properly +if test `uname -s` = 'Darwin'; then + ECHO='/bin/echo' +else + ECHO='echo' +fi +# +# Global variables +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 + +# 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' +} + +# +# Overall algorithm: +# +# Run a test and print PASSED or FAILED +# If a test did not return with the expected return code, +# increment the `nerrors' global variable and (if $verbose is set) display up to $NLINES +# lines of the actual output from the test. +# If the test did return the expected code, +# compare the actual output with the expected output; +# If the outputs are the same, print PASSED, +# Otherwise print FAILED and the difference between the two outputs. +# The output files are not removed if $HDF5_NOCLEANUP has a non-zero value. +# +# +# TOOLTEST(): +# +# Arguments: +# +# $1 -- expected output +# $2 -- expected return code +# $3 and on -- arguments for h5watch +TOOLTEST() { + expect="$srcdir/../testfiles/$1" + actual="../testfiles/`basename $1 .ddl`.out" + actual_err="../testfiles/`basename $1 .ddl`.err" + shift + retvalexpect=$1 + shift + # Run test. + # Stderr is included in stdout so that the diff can detect + # any unexpected output from that stream too. + TESTING $H5WATCH $@ + ( + $RUNSERIAL $H5WATCH_BIN "$@" + ) > $actual 2>$actual_err + 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 + + # Clean up output file + if test -z "$HDF5_NOCLEANUP"; then + rm -f $actual $actual_err + fi +} +# +# +# +# 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() { + 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 + # + # 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 + # + $EXTEND_BIN $TESTFILE $1 & # Extend the dataset; put in background + extend_pid=$! # Get "extend" process ID + # + # 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 + $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 + wait $watch_pid # Wait for "h5watch" process to complete + # + 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 +} + +############################################################################## +############################################################################## +### 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 # +# # +################################################################################################# +# +# +################################################################################################# +# # +# 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 +$GEN_TEST_BIN +# Test on --help options +TOOLTEST w-help1.ddl 0 --help +# +# Tests on expected failures +TOOLTEST w-err-dset1.ddl 1 WATCH.h5 +TOOLTEST w-err-dset2.ddl 1 WATCH.h5/group/DSET_CMPD +TOOLTEST w-err-dset-none.ddl 1 WATCH.h5/DSET_NONE +TOOLTEST w-err-dset-nomax.ddl 1 WATCH.h5/DSET_NOMAX +TOOLTEST w-err-file.ddl 1 ../WATCH.h5/DSET_CMPD +TOOLTEST w-err-width.ddl 1 --width=-8 WATCH.h5/DSET_ONE +TOOLTEST w-err-poll.ddl 1 --polling=-8 WATCH.h5/DSET_ONE +TOOLTEST w-err-poll0.ddl 1 --polling=0 WATCH.h5/DSET_ONE +# +# Tests on invalid field names via --fields option for a compound typed dataset: DSET_CMPD +TOOLTEST w-err-cmpd1.ddl 1 --fields=fieldx WATCH.h5/DSET_CMPD +TOOLTEST w-err-cmpd2.ddl 1 --fields=field1,field2. WATCH.h5/DSET_CMPD +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 +# +echo "DONE WITH 1st SET OF TESTS" +# +# +# +################################# +# Tests without options # +################################# +# +# Generate file WATCH.h5 with various types of datasets, +$GEN_TEST_BIN +# +# 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_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.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.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 +# +# +echo "DONE WITH 3rd 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 4th SET OF TESTS" +# +# +# +if test $nerrors -eq 0 ; then + $ECHO "All h5watch tests passed." + exit $EXIT_SUCCESS +else + $ECHO "h5watch tests failed with $nerrors errors." + exit $EXIT_FAILURE +fi diff --git a/hl/tools/testfiles/w-err-cmpd1.ddl b/hl/tools/testfiles/w-err-cmpd1.ddl new file mode 100644 index 0000000..775d6a0 --- /dev/null +++ b/hl/tools/testfiles/w-err-cmpd1.ddl @@ -0,0 +1,2 @@ +Opened "WATCH.h5" with sec2 driver. +h5watch error: error in processing <list_of_fields> diff --git a/hl/tools/testfiles/w-err-cmpd2.ddl b/hl/tools/testfiles/w-err-cmpd2.ddl new file mode 100644 index 0000000..775d6a0 --- /dev/null +++ b/hl/tools/testfiles/w-err-cmpd2.ddl @@ -0,0 +1,2 @@ +Opened "WATCH.h5" with sec2 driver. +h5watch error: error in processing <list_of_fields> diff --git a/hl/tools/testfiles/w-err-cmpd3.ddl b/hl/tools/testfiles/w-err-cmpd3.ddl new file mode 100644 index 0000000..775d6a0 --- /dev/null +++ b/hl/tools/testfiles/w-err-cmpd3.ddl @@ -0,0 +1,2 @@ +Opened "WATCH.h5" with sec2 driver. +h5watch error: error in processing <list_of_fields> diff --git a/hl/tools/testfiles/w-err-cmpd4.ddl b/hl/tools/testfiles/w-err-cmpd4.ddl new file mode 100644 index 0000000..775d6a0 --- /dev/null +++ b/hl/tools/testfiles/w-err-cmpd4.ddl @@ -0,0 +1,2 @@ +Opened "WATCH.h5" with sec2 driver. +h5watch error: error in processing <list_of_fields> diff --git a/hl/tools/testfiles/w-err-cmpd5.ddl b/hl/tools/testfiles/w-err-cmpd5.ddl new file mode 100644 index 0000000..775d6a0 --- /dev/null +++ b/hl/tools/testfiles/w-err-cmpd5.ddl @@ -0,0 +1,2 @@ +Opened "WATCH.h5" with sec2 driver. +h5watch error: error in processing <list_of_fields> diff --git a/hl/tools/testfiles/w-err-dset-nomax.ddl b/hl/tools/testfiles/w-err-dset-nomax.ddl new file mode 100644 index 0000000..b99cf84 --- /dev/null +++ b/hl/tools/testfiles/w-err-dset-nomax.ddl @@ -0,0 +1,2 @@ +Opened "WATCH.h5" with sec2 driver. +h5watch error: "/DSET_NOMAX" should have unlimited or max. dimension setting diff --git a/hl/tools/testfiles/w-err-dset-none.ddl b/hl/tools/testfiles/w-err-dset-none.ddl new file mode 100644 index 0000000..cbf6770 --- /dev/null +++ b/hl/tools/testfiles/w-err-dset-none.ddl @@ -0,0 +1,2 @@ +Opened "WATCH.h5" with sec2 driver. +h5watch error: "/DSET_NONE" should be a chunked or virtual dataset diff --git a/hl/tools/testfiles/w-err-dset1.ddl b/hl/tools/testfiles/w-err-dset1.ddl new file mode 100644 index 0000000..433c4d6 --- /dev/null +++ b/hl/tools/testfiles/w-err-dset1.ddl @@ -0,0 +1,2 @@ +Opened "WATCH.h5" with sec2 driver. +h5watch error: no dataset specified diff --git a/hl/tools/testfiles/w-err-dset2.ddl b/hl/tools/testfiles/w-err-dset2.ddl new file mode 100644 index 0000000..81b52de --- /dev/null +++ b/hl/tools/testfiles/w-err-dset2.ddl @@ -0,0 +1,2 @@ +Opened "WATCH.h5" with sec2 driver. +h5watch error: unable to open dataset "/group/DSET_CMPD" diff --git a/hl/tools/testfiles/w-err-file.ddl b/hl/tools/testfiles/w-err-file.ddl new file mode 100644 index 0000000..015661f --- /dev/null +++ b/hl/tools/testfiles/w-err-file.ddl @@ -0,0 +1 @@ +h5watch error: unable to open file "../WATCH.h5/DSET_CMPD" diff --git a/hl/tools/testfiles/w-err-poll.ddl b/hl/tools/testfiles/w-err-poll.ddl new file mode 100644 index 0000000..e6510f2 --- /dev/null +++ b/hl/tools/testfiles/w-err-poll.ddl @@ -0,0 +1,35 @@ +Usage: h5watch [OPTIONS] [OBJECT] + + OPTIONS + --help Print a usage message and exit. + --version Print version number and exit. + --label Label members of compound typed dataset. + --simple Use a machine-readable output format. + --dim Monitor changes in size of dataset dimensions only. + --width=N Set the number of columns to N for output. + A value of 0 sets the number of columns to the + maximum (65535). The default width is 80 columns. + --polling=N Set the polling interval to N (in seconds) when the + dataset will be checked for appended data. The default + polling interval is 1. + --fields=<list_of_fields> + Display data for the fields specified in <list_of_fields> + for a compound data type. <list_of_fields> can be + specified as follows: + 1) A comma-separated list of field names in a + compound data type. "," is the separator + for field names while "." is the separator + for a nested field. + 2) A single field name in a compound data type. + Can use this option multiple times. + Note that backslash is the escape character to avoid + characters in field names that conflict with the tool's + separators. + + OBJECT is specified as [<filename>/<path_to_dataset>/<dsetname>] + <filename> Name of the HDF5 file. It may be preceded by path + separated by slashes to the specified HDF5 file. + <path_to_dataset> Path separated by slashes to the specified dataset + <dsetname> Name of the dataset + + User can end the h5watch process by ctrl-C (SIGINT) or kill the process (SIGTERM). diff --git a/hl/tools/testfiles/w-err-poll0.ddl b/hl/tools/testfiles/w-err-poll0.ddl new file mode 100644 index 0000000..e6510f2 --- /dev/null +++ b/hl/tools/testfiles/w-err-poll0.ddl @@ -0,0 +1,35 @@ +Usage: h5watch [OPTIONS] [OBJECT] + + OPTIONS + --help Print a usage message and exit. + --version Print version number and exit. + --label Label members of compound typed dataset. + --simple Use a machine-readable output format. + --dim Monitor changes in size of dataset dimensions only. + --width=N Set the number of columns to N for output. + A value of 0 sets the number of columns to the + maximum (65535). The default width is 80 columns. + --polling=N Set the polling interval to N (in seconds) when the + dataset will be checked for appended data. The default + polling interval is 1. + --fields=<list_of_fields> + Display data for the fields specified in <list_of_fields> + for a compound data type. <list_of_fields> can be + specified as follows: + 1) A comma-separated list of field names in a + compound data type. "," is the separator + for field names while "." is the separator + for a nested field. + 2) A single field name in a compound data type. + Can use this option multiple times. + Note that backslash is the escape character to avoid + characters in field names that conflict with the tool's + separators. + + OBJECT is specified as [<filename>/<path_to_dataset>/<dsetname>] + <filename> Name of the HDF5 file. It may be preceded by path + separated by slashes to the specified HDF5 file. + <path_to_dataset> Path separated by slashes to the specified dataset + <dsetname> Name of the dataset + + User can end the h5watch process by ctrl-C (SIGINT) or kill the process (SIGTERM). diff --git a/hl/tools/testfiles/w-err-width.ddl b/hl/tools/testfiles/w-err-width.ddl new file mode 100644 index 0000000..e6510f2 --- /dev/null +++ b/hl/tools/testfiles/w-err-width.ddl @@ -0,0 +1,35 @@ +Usage: h5watch [OPTIONS] [OBJECT] + + OPTIONS + --help Print a usage message and exit. + --version Print version number and exit. + --label Label members of compound typed dataset. + --simple Use a machine-readable output format. + --dim Monitor changes in size of dataset dimensions only. + --width=N Set the number of columns to N for output. + A value of 0 sets the number of columns to the + maximum (65535). The default width is 80 columns. + --polling=N Set the polling interval to N (in seconds) when the + dataset will be checked for appended data. The default + polling interval is 1. + --fields=<list_of_fields> + Display data for the fields specified in <list_of_fields> + for a compound data type. <list_of_fields> can be + specified as follows: + 1) A comma-separated list of field names in a + compound data type. "," is the separator + for field names while "." is the separator + for a nested field. + 2) A single field name in a compound data type. + Can use this option multiple times. + Note that backslash is the escape character to avoid + characters in field names that conflict with the tool's + separators. + + OBJECT is specified as [<filename>/<path_to_dataset>/<dsetname>] + <filename> Name of the HDF5 file. It may be preceded by path + separated by slashes to the specified HDF5 file. + <path_to_dataset> Path separated by slashes to the specified dataset + <dsetname> Name of the dataset + + User can end the h5watch process by ctrl-C (SIGINT) or kill the process (SIGTERM). diff --git a/hl/tools/testfiles/w-ext-cmpd-esc-f1.ddl b/hl/tools/testfiles/w-ext-cmpd-esc-f1.ddl new file mode 100644 index 0000000..d85594d --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-esc-f1.ddl @@ -0,0 +1,11 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_ESC... +dimension 0: 10->13 (increases) + Data: + (10) {1, {2, {2, 2, 2}, 2}}, {2, {3, {3, 3, 3}, 3}}, + (12) {3, {4, {4, 4, 4}, 4}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {1, {2, {2, 2, 2}, 2}}, {2, {3, {3, 3, 3}, 3}} diff --git a/hl/tools/testfiles/w-ext-cmpd-esc-f3.ddl b/hl/tools/testfiles/w-ext-cmpd-esc-f3.ddl new file mode 100644 index 0000000..ab6c294 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-esc-f3.ddl @@ -0,0 +1,10 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_ESC... +dimension 0: 10->13 (increases) + Data: + (10) {{{2}}, {2}}, {{{3}}, {3}}, {{{4}}, {4}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {{{2}}, {2}}, {{{3}}, {3}} diff --git a/hl/tools/testfiles/w-ext-cmpd-esc-ff2.ddl b/hl/tools/testfiles/w-ext-cmpd-esc-ff2.ddl new file mode 100644 index 0000000..039cbf3 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-esc-ff2.ddl @@ -0,0 +1,11 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_ESC... +dimension 0: 10->13 (increases) + Data: + (10) {{{2, 2, 2}}, {4, 4}}, {{{3, 3, 3}}, {5, 5}}, {{{4, 4, 4}}, {6, + (12) 6}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {{{2, 2, 2}}, {4, 4}}, {{{3, 3, 3}}, {5, 5}} diff --git a/hl/tools/testfiles/w-ext-cmpd-esc.ddl b/hl/tools/testfiles/w-ext-cmpd-esc.ddl new file mode 100644 index 0000000..900b3f2 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-esc.ddl @@ -0,0 +1,13 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_ESC... +dimension 0: 10->13 (increases) + Data: + (10) {1, {2, {2, 2, 2}, 2}, 3, {4, 4}}, + (11) {2, {3, {3, 3, 3}, 3}, 4, {5, 5}}, + (12) {3, {4, {4, 4, 4}, 4}, 5, {6, 6}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {1, {2, {2, 2, 2}, 2}, 3, {4, 4}}, {2, {3, {3, 3, 3}, 3}, 4, {5, + (2) 5}} diff --git a/hl/tools/testfiles/w-ext-cmpd-f1.ddl b/hl/tools/testfiles/w-ext-cmpd-f1.ddl new file mode 100644 index 0000000..7e0a066 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-f1.ddl @@ -0,0 +1,11 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD... +dimension 0: 10->13 (increases) + Data: + (10) {1, {2, {2, 2, 2}, 2}}, {2, {3, {3, 3, 3}, 3}}, + (12) {3, {4, {4, 4, 4}, 4}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {1, {2, {2, 2, 2}, 2}}, {2, {3, {3, 3, 3}, 3}} diff --git a/hl/tools/testfiles/w-ext-cmpd-f2.ddl b/hl/tools/testfiles/w-ext-cmpd-f2.ddl new file mode 100644 index 0000000..ea69222 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-f2.ddl @@ -0,0 +1,11 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD... +dimension 0: 10->13 (increases) + Data: + (10) {{{2, 2, 2}}, {4, 4}}, {{{3, 3, 3}}, {5, 5}}, {{{4, 4, 4}}, {6, + (12) 6}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {{{2, 2, 2}}, {4, 4}}, {{{3, 3, 3}}, {5, 5}} diff --git a/hl/tools/testfiles/w-ext-cmpd-ff3.ddl b/hl/tools/testfiles/w-ext-cmpd-ff3.ddl new file mode 100644 index 0000000..84e2919 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-ff3.ddl @@ -0,0 +1,10 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD... +dimension 0: 10->13 (increases) + Data: + (10) {{{2}}, {2}}, {{{3}}, {3}}, {{{4}}, {4}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {{{2}}, {2}}, {{{3}}, {3}} diff --git a/hl/tools/testfiles/w-ext-cmpd-label.ddl b/hl/tools/testfiles/w-ext-cmpd-label.ddl new file mode 100644 index 0000000..84534ea --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-label.ddl @@ -0,0 +1,18 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD... +dimension 0: 10->13 (increases) + Data: + (10) {field1=1, field2={a=2, b={a=2, b=2, c=2}, c=2}, field3=3, + (10) field4={a=4, b=4}}, + (11) {field1=2, field2={a=3, b={a=3, b=3, c=3}, c=3}, field3=4, + (11) field4={a=5, b=5}}, + (12) {field1=3, field2={a=4, b={a=4, b=4, c=4}, c=4}, field3=5, + (12) field4={a=6, b=6}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {field1=1, field2={a=2, b={a=2, b=2, c=2}, c=2}, field3=3, + (1) field4={a=4, b=4}}, + (2) {field1=2, field2={a=3, b={a=3, b=3, c=3}, c=3}, field3=4, + (2) field4={a=5, b=5}} diff --git a/hl/tools/testfiles/w-ext-cmpd-two-f1.ddl b/hl/tools/testfiles/w-ext-cmpd-two-f1.ddl new file mode 100644 index 0000000..49abde9 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-two-f1.ddl @@ -0,0 +1,47 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_TWO... +dimension 0: 4->6 (increases) +dimension 1: 10->12 (increases) + Data: + (0,10) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}} + (1,10) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}} + (2,10) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}} + (3,10) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}} + (4,0) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (4,2) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (4,4) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (4,6) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (4,8) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (4,10) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (5,0) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (5,2) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (5,4) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (5,6) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (5,8) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}}, + (5,10) {1, {1, {1, 1, 1}, 1}}, {1, {1, {1, 1, 1}, 1}} +dimension 0: 6->8 (increases) +dimension 1: 12->1 (decreases) + Data: + (6,0) {2, {2, {2, 2, 2}, 2}}, + (7,0) {2, {2, {2, 2, 2}, 2}} +dimension 0: 8->10 (increases) +dimension 1: 1->1 (unchanged) + Data: + (8,0) {3, {3, {3, 3, 3}, 3}}, + (9,0) {3, {3, {3, 3, 3}, 3}} +dimension 0: 10->3 (decreases) +dimension 1: 1->3 (increases) + Data: + (0,1) {4, {4, {4, 4, 4}, 4}}, {4, {4, {4, 4, 4}, 4}} + (1,1) {4, {4, {4, 4, 4}, 4}}, {4, {4, {4, 4, 4}, 4}} + (2,1) {4, {4, {4, 4, 4}, 4}}, {4, {4, {4, 4, 4}, 4}} +dimension 0: 3->2 (decreases) +dimension 1: 3->2 (decreases) +dimension 0: 2->1 (decreases) +dimension 1: 2->2 (unchanged) +dimension 0: 1->1 (unchanged) +dimension 1: 2->4 (increases) + Data: + (0,2) {7, {7, {7, 7, 7}, 7}}, {7, {7, {7, 7, 7}, 7}} +dimension 0: 1->1 (unchanged) +dimension 1: 4->3 (decreases) diff --git a/hl/tools/testfiles/w-ext-cmpd-two-f3.ddl b/hl/tools/testfiles/w-ext-cmpd-two-f3.ddl new file mode 100644 index 0000000..0878f35 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-two-f3.ddl @@ -0,0 +1,41 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_TWO... +dimension 0: 4->6 (increases) +dimension 1: 10->12 (increases) + Data: + (0,10) {{{1}}, {1}}, {{{1}}, {1}} + (1,10) {{{1}}, {1}}, {{{1}}, {1}} + (2,10) {{{1}}, {1}}, {{{1}}, {1}} + (3,10) {{{1}}, {1}}, {{{1}}, {1}} + (4,0) {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, + (4,4) {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, + (4,8) {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, + (5,0) {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, + (5,4) {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, + (5,8) {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}}, {{{1}}, {1}} +dimension 0: 6->8 (increases) +dimension 1: 12->1 (decreases) + Data: + (6,0) {{{2}}, {2}}, + (7,0) {{{2}}, {2}} +dimension 0: 8->10 (increases) +dimension 1: 1->1 (unchanged) + Data: + (8,0) {{{3}}, {3}}, + (9,0) {{{3}}, {3}} +dimension 0: 10->3 (decreases) +dimension 1: 1->3 (increases) + Data: + (0,1) {{{4}}, {4}}, {{{4}}, {4}} + (1,1) {{{4}}, {4}}, {{{4}}, {4}} + (2,1) {{{4}}, {4}}, {{{4}}, {4}} +dimension 0: 3->2 (decreases) +dimension 1: 3->2 (decreases) +dimension 0: 2->1 (decreases) +dimension 1: 2->2 (unchanged) +dimension 0: 1->1 (unchanged) +dimension 1: 2->4 (increases) + Data: + (0,2) {{{7}}, {7}}, {{{7}}, {7}} +dimension 0: 1->1 (unchanged) +dimension 1: 4->3 (decreases) diff --git a/hl/tools/testfiles/w-ext-cmpd-two-ff2.ddl b/hl/tools/testfiles/w-ext-cmpd-two-ff2.ddl new file mode 100644 index 0000000..669547e --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-two-ff2.ddl @@ -0,0 +1,47 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_TWO... +dimension 0: 4->6 (increases) +dimension 1: 10->12 (increases) + Data: + (0,10) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}} + (1,10) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}} + (2,10) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}} + (3,10) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}} + (4,0) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (4,2) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (4,4) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (4,6) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (4,8) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (4,10) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (5,0) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (5,2) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (5,4) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (5,6) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (5,8) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}}, + (5,10) {{{1, 1, 1}}, {1, 1}}, {{{1, 1, 1}}, {1, 1}} +dimension 0: 6->8 (increases) +dimension 1: 12->1 (decreases) + Data: + (6,0) {{{2, 2, 2}}, {2, 2}}, + (7,0) {{{2, 2, 2}}, {2, 2}} +dimension 0: 8->10 (increases) +dimension 1: 1->1 (unchanged) + Data: + (8,0) {{{3, 3, 3}}, {3, 3}}, + (9,0) {{{3, 3, 3}}, {3, 3}} +dimension 0: 10->3 (decreases) +dimension 1: 1->3 (increases) + Data: + (0,1) {{{4, 4, 4}}, {4, 4}}, {{{4, 4, 4}}, {4, 4}} + (1,1) {{{4, 4, 4}}, {4, 4}}, {{{4, 4, 4}}, {4, 4}} + (2,1) {{{4, 4, 4}}, {4, 4}}, {{{4, 4, 4}}, {4, 4}} +dimension 0: 3->2 (decreases) +dimension 1: 3->2 (decreases) +dimension 0: 2->1 (decreases) +dimension 1: 2->2 (unchanged) +dimension 0: 1->1 (unchanged) +dimension 1: 2->4 (increases) + Data: + (0,2) {{{7, 7, 7}}, {7, 7}}, {{{7, 7, 7}}, {7, 7}} +dimension 0: 1->1 (unchanged) +dimension 1: 4->3 (decreases) diff --git a/hl/tools/testfiles/w-ext-cmpd-two.ddl b/hl/tools/testfiles/w-ext-cmpd-two.ddl new file mode 100644 index 0000000..a461226 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd-two.ddl @@ -0,0 +1,67 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD_TWO... +dimension 0: 4->6 (increases) +dimension 1: 10->12 (increases) + Data: + (0,10) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (0,11) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}} + (1,10) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (1,11) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}} + (2,10) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (2,11) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}} + (3,10) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (3,11) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}} + (4,0) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,1) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,2) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,3) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,4) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,5) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,6) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,7) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,8) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,9) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,10) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (4,11) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,0) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,1) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,2) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,3) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,4) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,5) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,6) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,7) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,8) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,9) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,10) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}}, + (5,11) {1, {1, {1, 1, 1}, 1}, 1, {1, 1}} +dimension 0: 6->8 (increases) +dimension 1: 12->1 (decreases) + Data: + (6,0) {2, {2, {2, 2, 2}, 2}, 2, {2, 2}}, + (7,0) {2, {2, {2, 2, 2}, 2}, 2, {2, 2}} +dimension 0: 8->10 (increases) +dimension 1: 1->1 (unchanged) + Data: + (8,0) {3, {3, {3, 3, 3}, 3}, 3, {3, 3}}, + (9,0) {3, {3, {3, 3, 3}, 3}, 3, {3, 3}} +dimension 0: 10->3 (decreases) +dimension 1: 1->3 (increases) + Data: + (0,1) {4, {4, {4, 4, 4}, 4}, 4, {4, 4}}, + (0,2) {4, {4, {4, 4, 4}, 4}, 4, {4, 4}} + (1,1) {4, {4, {4, 4, 4}, 4}, 4, {4, 4}}, + (1,2) {4, {4, {4, 4, 4}, 4}, 4, {4, 4}} + (2,1) {4, {4, {4, 4, 4}, 4}, 4, {4, 4}}, + (2,2) {4, {4, {4, 4, 4}, 4}, 4, {4, 4}} +dimension 0: 3->2 (decreases) +dimension 1: 3->2 (decreases) +dimension 0: 2->1 (decreases) +dimension 1: 2->2 (unchanged) +dimension 0: 1->1 (unchanged) +dimension 1: 2->4 (increases) + Data: + (0,2) {7, {7, {7, 7, 7}, 7}, 7, {7, 7}}, + (0,3) {7, {7, {7, 7, 7}, 7}, 7, {7, 7}} +dimension 0: 1->1 (unchanged) +dimension 1: 4->3 (decreases) diff --git a/hl/tools/testfiles/w-ext-cmpd.ddl b/hl/tools/testfiles/w-ext-cmpd.ddl new file mode 100644 index 0000000..7e64a14 --- /dev/null +++ b/hl/tools/testfiles/w-ext-cmpd.ddl @@ -0,0 +1,13 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_CMPD... +dimension 0: 10->13 (increases) + Data: + (10) {1, {2, {2, 2, 2}, 2}, 3, {4, 4}}, + (11) {2, {3, {3, 3, 3}, 3}, 4, {5, 5}}, + (12) {3, {4, {4, 4, 4}, 4}, 5, {6, 6}} +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) {1, {2, {2, 2, 2}, 2}, 3, {4, 4}}, {2, {3, {3, 3, 3}, 3}, 4, {5, + (2) 5}} diff --git a/hl/tools/testfiles/w-ext-early.ddl b/hl/tools/testfiles/w-ext-early.ddl new file mode 100644 index 0000000..1d963d7 --- /dev/null +++ b/hl/tools/testfiles/w-ext-early.ddl @@ -0,0 +1,10 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_ALLOC_EARLY... +dimension 0: 10->13 (increases) + Data: + (10) 0, 1, 2 +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) 0, 1 diff --git a/hl/tools/testfiles/w-ext-late.ddl b/hl/tools/testfiles/w-ext-late.ddl new file mode 100644 index 0000000..f3a7cf2 --- /dev/null +++ b/hl/tools/testfiles/w-ext-late.ddl @@ -0,0 +1,10 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_ALLOC_LATE... +dimension 0: 10->13 (increases) + Data: + (10) 0, 1, 2 +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) 0, 1 diff --git a/hl/tools/testfiles/w-ext-one-d.ddl b/hl/tools/testfiles/w-ext-one-d.ddl new file mode 100644 index 0000000..249ff95 --- /dev/null +++ b/hl/tools/testfiles/w-ext-one-d.ddl @@ -0,0 +1,6 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_ONE... +dimension 0: 10->13 (increases) +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) diff --git a/hl/tools/testfiles/w-ext-one-simple.ddl b/hl/tools/testfiles/w-ext-one-simple.ddl new file mode 100644 index 0000000..3bf0ef5 --- /dev/null +++ b/hl/tools/testfiles/w-ext-one-simple.ddl @@ -0,0 +1,13 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_ONE... +dimension 0: 10->13 (increases) + Data: + 0 + 1 + 2 +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + 0 + 1 diff --git a/hl/tools/testfiles/w-ext-one.ddl b/hl/tools/testfiles/w-ext-one.ddl new file mode 100644 index 0000000..c4e75eb --- /dev/null +++ b/hl/tools/testfiles/w-ext-one.ddl @@ -0,0 +1,10 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_ONE... +dimension 0: 10->13 (increases) + Data: + (10) 0, 1, 2 +dimension 0: 13->12 (decreases) +dimension 0: 12->1 (decreases) +dimension 0: 1->3 (increases) + Data: + (1) 0, 1 diff --git a/hl/tools/testfiles/w-ext-two-d.ddl b/hl/tools/testfiles/w-ext-two-d.ddl new file mode 100644 index 0000000..b71a9a6 --- /dev/null +++ b/hl/tools/testfiles/w-ext-two-d.ddl @@ -0,0 +1,18 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_TWO... +dimension 0: 4->6 (increases) +dimension 1: 10->12 (increases) +dimension 0: 6->8 (increases) +dimension 1: 12->1 (decreases) +dimension 0: 8->10 (increases) +dimension 1: 1->1 (unchanged) +dimension 0: 10->3 (decreases) +dimension 1: 1->3 (increases) +dimension 0: 3->2 (decreases) +dimension 1: 3->2 (decreases) +dimension 0: 2->1 (decreases) +dimension 1: 2->2 (unchanged) +dimension 0: 1->1 (unchanged) +dimension 1: 2->4 (increases) +dimension 0: 1->1 (unchanged) +dimension 1: 4->3 (decreases) diff --git a/hl/tools/testfiles/w-ext-two-width.ddl b/hl/tools/testfiles/w-ext-two-width.ddl new file mode 100644 index 0000000..52903de --- /dev/null +++ b/hl/tools/testfiles/w-ext-two-width.ddl @@ -0,0 +1,41 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_TWO... +dimension 0: 4->6 (increases) +dimension 1: 10->12 (increases) + Data: + (0,10) 1, 1 + (1,10) 1, 1 + (2,10) 1, 1 + (3,10) 1, 1 + (4,0) 1, 1, 1, 1, 1, + (4,5) 1, 1, 1, 1, 1, + (4,10) 1, 1, + (5,0) 1, 1, 1, 1, 1, + (5,5) 1, 1, 1, 1, 1, + (5,10) 1, 1 +dimension 0: 6->8 (increases) +dimension 1: 12->1 (decreases) + Data: + (6,0) 2, + (7,0) 2 +dimension 0: 8->10 (increases) +dimension 1: 1->1 (unchanged) + Data: + (8,0) 3, + (9,0) 3 +dimension 0: 10->3 (decreases) +dimension 1: 1->3 (increases) + Data: + (0,1) 4, 4 + (1,1) 4, 4 + (2,1) 4, 4 +dimension 0: 3->2 (decreases) +dimension 1: 3->2 (decreases) +dimension 0: 2->1 (decreases) +dimension 1: 2->2 (unchanged) +dimension 0: 1->1 (unchanged) +dimension 1: 2->4 (increases) + Data: + (0,2) 7, 7 +dimension 0: 1->1 (unchanged) +dimension 1: 4->3 (decreases) diff --git a/hl/tools/testfiles/w-ext-two.ddl b/hl/tools/testfiles/w-ext-two.ddl new file mode 100644 index 0000000..31df8d5 --- /dev/null +++ b/hl/tools/testfiles/w-ext-two.ddl @@ -0,0 +1,37 @@ +Opened "TEST.h5" with sec2 driver. +Monitoring dataset /DSET_TWO... +dimension 0: 4->6 (increases) +dimension 1: 10->12 (increases) + Data: + (0,10) 1, 1 + (1,10) 1, 1 + (2,10) 1, 1 + (3,10) 1, 1 + (4,0) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + (5,0) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +dimension 0: 6->8 (increases) +dimension 1: 12->1 (decreases) + Data: + (6,0) 2, + (7,0) 2 +dimension 0: 8->10 (increases) +dimension 1: 1->1 (unchanged) + Data: + (8,0) 3, + (9,0) 3 +dimension 0: 10->3 (decreases) +dimension 1: 1->3 (increases) + Data: + (0,1) 4, 4 + (1,1) 4, 4 + (2,1) 4, 4 +dimension 0: 3->2 (decreases) +dimension 1: 3->2 (decreases) +dimension 0: 2->1 (decreases) +dimension 1: 2->2 (unchanged) +dimension 0: 1->1 (unchanged) +dimension 1: 2->4 (increases) + Data: + (0,2) 7, 7 +dimension 0: 1->1 (unchanged) +dimension 1: 4->3 (decreases) diff --git a/hl/tools/testfiles/w-help1.ddl b/hl/tools/testfiles/w-help1.ddl new file mode 100644 index 0000000..e6510f2 --- /dev/null +++ b/hl/tools/testfiles/w-help1.ddl @@ -0,0 +1,35 @@ +Usage: h5watch [OPTIONS] [OBJECT] + + OPTIONS + --help Print a usage message and exit. + --version Print version number and exit. + --label Label members of compound typed dataset. + --simple Use a machine-readable output format. + --dim Monitor changes in size of dataset dimensions only. + --width=N Set the number of columns to N for output. + A value of 0 sets the number of columns to the + maximum (65535). The default width is 80 columns. + --polling=N Set the polling interval to N (in seconds) when the + dataset will be checked for appended data. The default + polling interval is 1. + --fields=<list_of_fields> + Display data for the fields specified in <list_of_fields> + for a compound data type. <list_of_fields> can be + specified as follows: + 1) A comma-separated list of field names in a + compound data type. "," is the separator + for field names while "." is the separator + for a nested field. + 2) A single field name in a compound data type. + Can use this option multiple times. + Note that backslash is the escape character to avoid + characters in field names that conflict with the tool's + separators. + + OBJECT is specified as [<filename>/<path_to_dataset>/<dsetname>] + <filename> Name of the HDF5 file. It may be preceded by path + separated by slashes to the specified HDF5 file. + <path_to_dataset> Path separated by slashes to the specified dataset + <dsetname> Name of the dataset + + User can end the h5watch process by ctrl-C (SIGINT) or kill the process (SIGTERM). |