diff options
72 files changed, 4079 insertions, 21 deletions
@@ -1387,6 +1387,7 @@ ./tools/src/misc/Makefile.am ./tools/src/misc/h5cc.in +./tools/src/misc/h5clear.c ./tools/src/misc/h5debug.c ./tools/src/misc/h5mkgrp.c ./tools/src/misc/h5redeploy.in @@ -1412,6 +1413,9 @@ ./tools/test/misc/vds/UC_5.h ./tools/test/misc/vds/UC_5_stride_gen.c ./tools/test/misc/vds/UC_common.h +./tools/test/misc/h5clear_gentest.c +./tools/test/misc/clear_open_chk.c +./tools/test/misc/testh5clear.sh.in # h5stat sources ./tools/src/h5stat/Makefile.am @@ -1583,6 +1587,7 @@ ./tools/testfiles/tdset.h5 ./tools/testfiles/tdset2.h5 ./tools/testfiles/tdset_idx.ls +./tools/testfiles/tdset_idx.ddl ./tools/testfiles/tdset_idx.h5 ./tools/testfiles/tempty.ddl ./tools/testfiles/tempty.h5 @@ -2208,6 +2213,7 @@ ./tools/test/h5diff/testfiles/h5diff_457.txt ./tools/test/h5diff/testfiles/h5diff_458.txt ./tools/test/h5diff/testfiles/h5diff_459.txt +./tools/test/h5diff/testfiles/h5diff_idx.txt ./tools/test/h5diff/testfiles/h5diff_465.txt ./tools/test/h5diff/testfiles/h5diff_466.txt ./tools/test/h5diff/testfiles/h5diff_467.txt @@ -2256,6 +2262,8 @@ ./tools/test/h5diff/testfiles/h5diff_basic2.h5 ./tools/test/h5diff/testfiles/h5diff_dset1.h5 ./tools/test/h5diff/testfiles/h5diff_dset2.h5 +./tools/test/h5diff/testfiles/h5diff_dset_idx1.h5 +./tools/test/h5diff/testfiles/h5diff_dset_idx2.h5 ./tools/test/h5diff/testfiles/h5diff_dtypes.h5 ./tools/test/h5diff/testfiles/h5diff_empty.h5 ./tools/test/h5diff/testfiles/h5diff_hyper1.h5 @@ -2528,6 +2536,51 @@ ./hl/tools/gif2h5/testfiles/ex_image2.h5 ./hl/tools/gif2h5/testfiles/image1.gif ./hl/tools/gif2h5/testfiles/h52giftst.h5 +# +./hl/tools/h5watch/Makefile.am +./hl/tools/h5watch/extend_dset.c +./hl/tools/h5watch/h5watch.c +./hl/tools/h5watch/h5watchgentest.c +./hl/tools/h5watch/swmr_check_compat_vfd.c +./hl/tools/h5watch/testh5watch.sh.in + +# expected test output from testing h5watch +# +./hl/tools/testfiles/w-err-cmpd1.ddl +./hl/tools/testfiles/w-err-cmpd2.ddl +./hl/tools/testfiles/w-err-cmpd3.ddl +./hl/tools/testfiles/w-err-cmpd4.ddl +./hl/tools/testfiles/w-err-cmpd5.ddl +./hl/tools/testfiles/w-err-dset1.ddl +./hl/tools/testfiles/w-err-dset2.ddl +./hl/tools/testfiles/w-err-dset-nomax.ddl +./hl/tools/testfiles/w-err-dset-none.ddl +./hl/tools/testfiles/w-err-file.ddl +./hl/tools/testfiles/w-err-poll0.ddl +./hl/tools/testfiles/w-err-poll.ddl +./hl/tools/testfiles/w-err-width.ddl +./hl/tools/testfiles/w-ext-cmpd.ddl +./hl/tools/testfiles/w-ext-cmpd-esc.ddl +./hl/tools/testfiles/w-ext-cmpd-esc-f1.ddl +./hl/tools/testfiles/w-ext-cmpd-esc-f3.ddl +./hl/tools/testfiles/w-ext-cmpd-esc-ff2.ddl +./hl/tools/testfiles/w-ext-cmpd-f1.ddl +./hl/tools/testfiles/w-ext-cmpd-f2.ddl +./hl/tools/testfiles/w-ext-cmpd-ff3.ddl +./hl/tools/testfiles/w-ext-cmpd-label.ddl +./hl/tools/testfiles/w-ext-cmpd-two.ddl +./hl/tools/testfiles/w-ext-cmpd-two-f1.ddl +./hl/tools/testfiles/w-ext-cmpd-two-f3.ddl +./hl/tools/testfiles/w-ext-cmpd-two-ff2.ddl +./hl/tools/testfiles/w-ext-early.ddl +./hl/tools/testfiles/w-ext-late.ddl +./hl/tools/testfiles/w-ext-one-d.ddl +./hl/tools/testfiles/w-ext-one.ddl +./hl/tools/testfiles/w-ext-one-simple.ddl +./hl/tools/testfiles/w-ext-two-d.ddl +./hl/tools/testfiles/w-ext-two.ddl +./hl/tools/testfiles/w-ext-two-width.ddl +./hl/tools/testfiles/w-help1.ddl # hl fortran ./hl/fortran/COPYING @@ -2963,6 +3016,8 @@ ./hl/tools/CMakeLists.txt ./hl/tools/gif2h5/CMakeLists.txt ./hl/tools/gif2h5/CMakeTests.cmake +./hl/tools/h5watch/CMakeLists.txt +./hl/tools/h5watch/CMakeTests.cmake ./src/CMakeLists.txt ./test/CMakeLists.txt ./test/CMakeTests.cmake @@ -3048,6 +3103,7 @@ ./hl/src/Makefile.in ./hl/test/Makefile.in ./hl/tools/gif2h5/Makefile.in +./hl/tools/h5watch/Makefile.in ./hl/tools/Makefile.in ./m4/libtool.m4 ./m4/lt~obsolete.m4 diff --git a/config/cmake/CTestCustom.cmake b/config/cmake/CTestCustom.cmake index f9431e7..0e1eb2e 100644 --- a/config/cmake/CTestCustom.cmake +++ b/config/cmake/CTestCustom.cmake @@ -40,6 +40,9 @@ set (CTEST_CUSTOM_MEMCHECK_IGNORE HL_FORTRAN_test-clear-objects FORTRAN_testhdf5-clear-objects CPP_testhdf5-clear-objects + ######### tools/h5clear ######### + H5CLEAR-clearall-objects + H5CLEAR-h5clear_gentest # does not close ids by design ######### tools/h5copy ######### H5COPY-clearall-objects ######### tools/h5diff ######### @@ -217,6 +220,8 @@ set (CTEST_CUSTOM_MEMCHECK_IGNORE ######### tools/misc ######### H5REPART-clearall-objects H5MKGRP-clearall-objects + ######### hl/tools/h5watch ######### + H5WATCH-clearall-objects ######### examples ######### EXAMPLES-clear-objects CPP_ex-clear-objects diff --git a/configure.ac b/configure.ac index 27519ab..f8077b7 100644 --- a/configure.ac +++ b/configure.ac @@ -3360,6 +3360,7 @@ AC_CONFIG_FILES([src/libhdf5.settings tools/test/h5copy/Makefile tools/test/h5copy/testh5copy.sh tools/test/misc/Makefile + tools/test/misc/testh5clear.sh tools/test/misc/testh5mkgrp.sh tools/test/misc/testh5repart.sh tools/test/misc/vds/Makefile @@ -3407,6 +3408,8 @@ AC_CONFIG_FILES([src/libhdf5.settings hl/tools/Makefile hl/tools/gif2h5/Makefile hl/tools/gif2h5/h52giftest.sh + hl/tools/h5watch/Makefile + hl/tools/h5watch/testh5watch.sh hl/examples/Makefile hl/examples/run-hlc-ex.sh hl/c++/Makefile 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). diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index ed93a46..38739c8 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -203,6 +203,10 @@ typedef struct h5tools_dump_header_t { } h5tools_dump_header_t; +/* Forward declaration (see declaration in h5tools_str.c) */ +struct H5LD_memb_t; + + /* * Information about how to format output. */ @@ -338,12 +342,16 @@ typedef struct h5tool_format_t { * * end: a string to print after we reach the last element of * each compound type. prints out before the suf. + * + * listv: h5watch: vector containing info about the list of compound fields to be printed. */ const char *cmpd_name; const char *cmpd_sep; const char *cmpd_pre; const char *cmpd_suf; const char *cmpd_end; + const struct H5LD_memb_t * const *cmpd_listv; + /* * Fields associated with vlen data types. @@ -516,6 +524,7 @@ typedef struct h5tools_context_t { hsize_t acc[H5S_MAX_RANK]; /* accumulator position */ hsize_t pos[H5S_MAX_RANK]; /* matrix position */ hsize_t sm_pos; /* current stripmine element position */ + struct H5LD_memb_t **cmpd_listv; /* h5watch: vector containing info about the list of compound fields to be printed */ } h5tools_context_t; typedef struct subset_d { diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index cae3107..67585d1 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -61,6 +61,7 @@ NULL, /*fmt_ullong */ "{", /*cmpd_pre */ "}", /*cmpd_suf */ "\n", /*cmpd_end */ +NULL, /* cmpd_listv */ ", ", /*vlen_sep */ "(", /*vlen_pre */ @@ -1485,6 +1486,9 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_co H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); ctx->size_last_dim = total_size[ctx->ndims - 1]; + /* Set the compound datatype field list for display */ + ctx->cmpd_listv = info->cmpd_listv; + h5tools_display_simple_subset(stream, info, ctx, dset, p_type, sset, f_space, total_size); CATCH diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index a0a78f5..358e993 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -29,6 +29,15 @@ #include "h5tools_ref.h" #include "h5tools_str.h" /*function prototypes */ +/* Copied from hl/src/H5LDprivate.h */ +/* Info about the list of comma-separated compound fields */ +typedef struct H5LD_memb_t { + size_t tot_offset; + size_t last_tsize; + hid_t last_tid; + char **names; +} H5LD_memb_t; + /* * If REPEAT_VERBOSE is defined then character strings will be printed so * that repeated character sequences like "AAAAAAAAAA" are displayed as @@ -730,6 +739,9 @@ h5tools_str_indent(h5tools_str_t *str, const h5tool_format_t *info, * PVN, 28 March 2006 * added H5T_NATIVE_LDOUBLE case * + * Vailin Choi; August 2010 + * Modified to handle printing of selected compound fields for h5watch. + * * Raymond Lu, 2011-09-01 * CLANG compiler complained about the line (about 800): * tempint = (tempint >> packed_data_offset) & packed_data_mask; @@ -1024,7 +1036,57 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai break; case H5T_COMPOUND: - { + if(ctx->cmpd_listv) { /* there is <list_of_fields> */ + int save_indent_level; /* The indentation level */ + size_t curr_field; /* Current field to display */ + int i = 0, x = 0; /* Local index variable */ + H5LD_memb_t **listv; /* Vector of information for <list_of_fields> */ + + listv = ctx->cmpd_listv; + ctx->cmpd_listv = NULL; + + h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); + + /* + * Go through the vector containing info about the comma-separated list of + * compound fields and then members in each field: + * put in "{", "}", ",", member name and value accordingly. + */ + save_indent_level = ctx->indent_level; + for(curr_field = 0; listv[curr_field] != NULL; curr_field++) { + if (curr_field) + h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", "OPTIONAL_LINE_BREAK)); + else + h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); + + if(info->arr_linebreak) + h5tools_str_indent(str, info, ctx); + + /* Process members of each field */ + for(i = 0; listv[curr_field]->names[i] != NULL; i++) { + h5tools_str_append(str, OPT(info->cmpd_name, ""), listv[curr_field]->names[i]); + if(i) { + ctx->indent_level++; + h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); + } + } + h5tools_str_sprint(str, info, container, listv[curr_field]->last_tid, cp_vp + listv[curr_field]->tot_offset, ctx); + if(ctx->indent_level > 0) + for(x = ctx->indent_level; x > 0; x--) + h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); + ctx->indent_level = save_indent_level; + } + + + if(info->arr_linebreak) { + h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); + h5tools_str_indent(str, info, ctx); + } + h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); + + ctx->cmpd_listv = info->cmpd_listv; + + } else { unsigned nmembs; unsigned j; diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c index 41f3914..5290c3d 100644 --- a/tools/src/h5dump/h5dump_xml.c +++ b/tools/src/h5dump/h5dump_xml.c @@ -69,6 +69,7 @@ static h5tool_format_t xml_dataformat = { "", /*cmpd_pre */ "", /*cmpd_suf */ "", /*cmpd_end */ + "", /*cmpd_listv */ " ", /*vlen_sep */ " ", /*vlen_pre */ diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c index a032f08..88bab20 100644 --- a/tools/src/h5ls/h5ls.c +++ b/tools/src/h5ls/h5ls.c @@ -70,6 +70,7 @@ static h5tool_format_t ls_dataformat = { "{", /*cmpd_pre */ "}", /*cmpd_suf */ "", /*cmpd_end */ + NULL, /* cmpd_listv */ ",", /*vlen_sep */ "(", /*vlen_pre */ diff --git a/tools/src/misc/CMakeLists.txt b/tools/src/misc/CMakeLists.txt index 6fcff9c..0bda701 100644 --- a/tools/src/misc/CMakeLists.txt +++ b/tools/src/misc/CMakeLists.txt @@ -31,10 +31,18 @@ target_link_libraries (h5mkgrp ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (h5mkgrp PROPERTIES FOLDER tools) set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5mkgrp") +add_executable (h5clear ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5clear.c) +TARGET_NAMING (h5clear STATIC) +TARGET_C_PROPERTIES (h5clear STATIC " " " ") +target_link_libraries (h5clear ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) +set_target_properties (h5clear PROPERTIES FOLDER tools) +set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5clear") + set (H5_DEP_EXECUTABLES h5debug h5repart h5mkgrp + h5clear ) #----------------------------------------------------------------------------- diff --git a/tools/src/misc/Makefile.am b/tools/src/misc/Makefile.am index c069e9a..ad3dae9b 100644 --- a/tools/src/misc/Makefile.am +++ b/tools/src/misc/Makefile.am @@ -24,13 +24,14 @@ include $(top_srcdir)/config/commence.am AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib # These are our main targets, the tools -bin_PROGRAMS=h5debug h5repart h5mkgrp +bin_PROGRAMS=h5debug h5repart h5mkgrp h5clear bin_SCRIPTS=h5redeploy # Add h5debug, h5repart, and h5mkgrp specific linker flags here h5debug_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) h5repart_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) h5mkgrp_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) +h5clear_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) # Tell automake to clean h5redeploy script CLEANFILES=h5redeploy diff --git a/tools/src/misc/h5clear.c b/tools/src/misc/h5clear.c new file mode 100644 index 0000000..0be4f8f --- /dev/null +++ b/tools/src/misc/h5clear.c @@ -0,0 +1,137 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: + * + * Purpose: + */ + +#include "hdf5.h" +#include "H5private.h" +#include "h5tools.h" +#include "h5tools_utils.h" + +/* Name of tool */ +#define PROGRAMNAME "h5clear" + +/* Make this private property (defined in H5Fprivate.h) available to h5clear. */ +#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags" + +/*------------------------------------------------------------------------- + * Function: leave + * + * Purpose: Close the tools library and exit + * + * Return: Does not return + * + *------------------------------------------------------------------------- + */ +static void +leave(int ret) +{ + h5tools_close(); + HDexit(ret); + +} /* leave() */ + +/*------------------------------------------------------------------------- + * Function: usage + * + * Purpose: Prints a usage message + * + * Return: void + * + *------------------------------------------------------------------------- + */ +static void +usage(void) +{ + HDfprintf(stdout, "usage: h5clear filename\n"); + +} /* usage() */ + + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: + * + * Return: Success: + * Failure: + * + * Programmer: + * + *------------------------------------------------------------------------- + */ +int +main (int argc, char *argv[]) +{ + char *fname; /* File name */ + hbool_t clear = TRUE; /* To clear the status_flags in the file's superblock */ + hid_t fapl = -1; /* File access property list */ + hid_t fid = -1; /* File ID */ + + h5tools_setprogname(PROGRAMNAME); + h5tools_setstatus(EXIT_SUCCESS); + + /* Disable the HDF5 library's error reporting */ + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + + /* initialize h5tools lib */ + h5tools_init(); + + /* Check for the # of arguments */ + if(argc != 2) { + usage(); + leave(EXIT_FAILURE); + } + + /* Duplicate the file name */ + fname = HDstrdup(argv[opt_ind]); + + /* Get a copy of the file access property list */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + error_msg("H5Pcreate\n"); + exit(EXIT_FAILURE); + } + + /* Set to clear the status_flags in the file's superblock */ + /* This is a private property used by h5clear only */ + if(H5Pset(fapl, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear) < 0) { + error_msg("H5Pset\n"); + exit(EXIT_FAILURE); + } + + if((fid = h5tools_fopen(fname, H5F_ACC_RDWR, fapl, NULL, NULL, (size_t)0)) < 0) { + error_msg("h5tools_fopen\n"); + exit(EXIT_FAILURE); + } + + /* Close the file */ + if(H5Fclose(fid) < 0) { + error_msg("H5Fclose\n"); + exit(EXIT_FAILURE); + } + + /* CLose the property list */ + if(H5Pclose(fapl) < 0) { + error_msg("H5Pclose\n"); + exit(EXIT_FAILURE); + } + + return EXIT_SUCCESS; +} /* main() */ diff --git a/tools/test/h5diff/CMakeTests.cmake b/tools/test/h5diff/CMakeTests.cmake index 7bbff61..3687574 100644 --- a/tools/test/h5diff/CMakeTests.cmake +++ b/tools/test/h5diff/CMakeTests.cmake @@ -46,10 +46,15 @@ ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_comp_vl_strs.h5 ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_attr_v_level1.h5 ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_attr_v_level2.h5 + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_enum_invalid_values.h5 ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/compounds_array_vlen1.h5 ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/compounds_array_vlen2.h5 ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/non_comparables1.h5 ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/non_comparables2.h5 + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/tmptest.he5 + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/tmptest2.he5 + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/tmpSingleSiteBethe.reference.h5 + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/tmpSingleSiteBethe.output.h5 # tools/testfiles/vds ${HDF5_TOOLS_DIR}/testfiles/vds/1_a.h5 ${HDF5_TOOLS_DIR}/testfiles/vds/1_b.h5 @@ -115,6 +120,7 @@ ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_26.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_27.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_28.txt + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_30.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_300.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_400.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_401.txt @@ -251,6 +257,8 @@ ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_710.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_80.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_90.txt + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_tmp1.txt + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_tmp2.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_v1.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_v2.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_v3.txt @@ -867,6 +875,15 @@ ADD_H5_TEST (h5diff_27 1 -v ${FILE3} ${FILE3} t1 t2) ADD_H5_TEST (h5diff_28 1 -v ${FILE3} ${FILE3} l1 l2) # ############################################################################## +# # Enum value tests (may become more comprehensive in the future) +# ############################################################################## + +# 3.0 +# test enum types which may have invalid values +ADD_H5_TEST (h5diff_30 1 -v h5diff_enum_invalid_values.h5 h5diff_enum_invalid_values.h5 dset1 dset2) + + +# ############################################################################## # # Dataset datatypes # ############################################################################## @@ -1010,6 +1027,10 @@ ADD_H5_TEST (h5diff_631 0 -v --use-system-epsilon ${FILE1} ${FILE1} g1/fp18 g1/f # 7. attributes # ############################################################################## ADD_H5_TEST (h5diff_70 1 -v ${FILE5} ${FILE6}) +# temporary test to verify HDF5-8625 +ADD_H5_TEST (h5diff_tmp1 0 tmptest2.he5 tmptest.he5) +# temporary test to verify HDF5-8639 +ADD_H5_TEST (h5diff_tmp2 1 tmpSingleSiteBethe.output.h5 tmpSingleSiteBethe.reference.h5) # ################################################## # attrs with verbose option level diff --git a/tools/test/h5diff/testfiles/h5diff_dset_idx1.h5 b/tools/test/h5diff/testfiles/h5diff_dset_idx1.h5 Binary files differnew file mode 100644 index 0000000..3252303 --- /dev/null +++ b/tools/test/h5diff/testfiles/h5diff_dset_idx1.h5 diff --git a/tools/test/h5diff/testfiles/h5diff_dset_idx2.h5 b/tools/test/h5diff/testfiles/h5diff_dset_idx2.h5 Binary files differnew file mode 100644 index 0000000..db7584d --- /dev/null +++ b/tools/test/h5diff/testfiles/h5diff_dset_idx2.h5 diff --git a/tools/test/h5diff/testfiles/h5diff_idx.txt b/tools/test/h5diff/testfiles/h5diff_idx.txt new file mode 100644 index 0000000..754d3ea --- /dev/null +++ b/tools/test/h5diff/testfiles/h5diff_idx.txt @@ -0,0 +1,14 @@ + +file1 file2 +--------------------------------------- + x x / + x x /dset + x x /dset_filter + +group : </> and </> +0 differences found +dataset: </dset> and </dset> +0 differences found +dataset: </dset_filter> and </dset_filter> +0 differences found +EXIT CODE: 0 diff --git a/tools/test/h5format_convert/h5fc_gentest.c b/tools/test/h5format_convert/h5fc_gentest.c index 97def9a..520e5bf 100644 --- a/tools/test/h5format_convert/h5fc_gentest.c +++ b/tools/test/h5format_convert/h5fc_gentest.c @@ -44,6 +44,8 @@ const char *FILENAME[] = { #define GROUP "GROUP" +#define DSET_BT1 "DSET_BT1" +#define DSET_NDATA_BT1 "DSET_NDATA_BT1" #define DSET_COMPACT "DSET_COMPACT" #define DSET_CONTIGUOUS "DSET_CONTIGUOUS" @@ -68,8 +70,7 @@ const char *FILENAME[] = { /* * Function: gen_non() * - * Create empty file with latest-format--this will result in v3 superbock - * Close and re-open file with non-latest-format--v3 superblock will result in latest version support: + * Create a file with SWMR write+non-latest-format--this will result in v3 superbock+latest version support: * 1) 1 chunked dataset with extensible array chunk indexing type (without data) * 2) 1 chunked dataset with version 2 B-tree chunk indexing type (with data) * Re-open the file with write+non-latest-format and create: @@ -82,7 +83,6 @@ gen_non(const char *fname) { hid_t fid = -1; /* file id */ hid_t fcpl = -1; /* file creation property list */ - hid_t fapl = -1; /* file access property list */ hid_t gid = -1; /* group id */ hid_t sid = -1; /* space id */ hid_t dcpl = -1; /* dataset creation property id */ @@ -101,13 +101,8 @@ gen_non(const char *fname) if(H5Pset_istore_k(fcpl, 64) < 0) goto error; - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - goto error; - /* Create an empty file with latest-format */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if((fid = H5Fcreate(fname, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, fcpl, H5P_DEFAULT)) < 0) goto error; /* Create a group */ @@ -172,7 +167,12 @@ gen_non(const char *fname) goto error; if(H5Gclose(gid) < 0) goto error; + if(H5Fclose(fid) < 0) + goto error; + /* Re-open the file with old format */ + if((fid = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + goto error; /* Open the group */ if((gid = H5Gopen2(fid, GROUP, H5P_DEFAULT)) < 0) @@ -285,8 +285,6 @@ gen_non(const char *fname) goto error; if(H5Pclose(fcpl) < 0) goto error; - if(H5Pclose(fapl) < 0) - goto error; if(H5Fclose(fid) < 0) goto error; @@ -773,7 +771,6 @@ error: H5Dclose(did2); H5Gclose(gid); H5Fclose(fid); - H5Pclose(fapl); H5Pclose(fcpl); } H5E_END_TRY; diff --git a/tools/test/h5ls/CMakeTests.cmake b/tools/test/h5ls/CMakeTests.cmake index 816907c..e7a5dd6 100644 --- a/tools/test/h5ls/CMakeTests.cmake +++ b/tools/test/h5ls/CMakeTests.cmake @@ -31,6 +31,7 @@ ${HDF5_TOOLS_DIR}/testfiles/tstr.h5 ${HDF5_TOOLS_DIR}/testfiles/tudlink.h5 ${HDF5_TOOLS_DIR}/testfiles/tvldtypes1.h5 + ${HDF5_TOOLS_DIR}/testfiles/tdset_idx.h5 ) set (LIST_OTHER_TEST_FILES @@ -90,6 +91,7 @@ ${HDF5_TOOLS_DIR}/testfiles/tvldtypes1.ls ${HDF5_TOOLS_DIR}/testfiles/tvldtypes2le.ls ${HDF5_TOOLS_DIR}/testfiles/tvldtypes2be.ls + ${HDF5_TOOLS_DIR}/testfiles/tdset_idx.ls ) file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") @@ -388,3 +390,8 @@ else (H5_WORDS_BIGENDIAN) ADD_H5_TEST (tdataregle 0 -v tdatareg.h5) endif (H5_WORDS_BIGENDIAN) + +# test for file with datasets that use Fixed Array chunk indices +#echo "***skip testing tdset_idx.h5" +ADD_H5_TEST (tdset_idx 0 -w80 -d tdset_idx.h5) + diff --git a/tools/test/h5ls/testh5ls.sh.in b/tools/test/h5ls/testh5ls.sh.in index 0637a74..e2a72ba 100644 --- a/tools/test/h5ls/testh5ls.sh.in +++ b/tools/test/h5ls/testh5ls.sh.in @@ -421,7 +421,7 @@ else fi # test for file with datasets that use Fixed Array chunk indices -#echo "***skip testing tdset_idx.h5" +echo "***skip testing tdset_idx.h5" TOOLTEST tdset_idx.ls 0 -w80 -d tdset_idx.h5 # Clean up temporary files/directories diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index f3ef2a5..576fb58 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/h5repack/CMakeTests.cmake @@ -57,6 +57,8 @@ ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layout3.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layout.UD.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_named_dtypes.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_nested_8bit_enum.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_nested_8bit_enum_deflated.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_nbit.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_objs.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_refs.h5 @@ -764,6 +766,13 @@ ADD_H5_TEST (layout "TEST" ${FILE4}) ADD_H5_TEST (early "TEST" ${FILE5}) +# nested 8bit enum in both deflated and non-deflated datafiles + if (NOT USE_FILTER_DEFLATE) + ADD_H5_TEST (nested_8bit_enum "TEST" h5repack_nested_8bit_enum.h5) + else (NOT USE_FILTER_DEFLATE) + ADD_H5_TEST (nested_8bit_enum "TEST" h5repack_nested_8bit_enum_deflated.h5) + endif (NOT USE_FILTER_DEFLATE) + # use $FILE4 to write some filters (this file has no filters) # gzip with individual object diff --git a/tools/test/h5stat/CMakeTests.cmake b/tools/test/h5stat/CMakeTests.cmake index 201e978..39faca0 100644 --- a/tools/test/h5stat/CMakeTests.cmake +++ b/tools/test/h5stat/CMakeTests.cmake @@ -25,6 +25,7 @@ h5stat_newgrat.ddl h5stat_newgrat-UG.ddl h5stat_newgrat-UA.ddl + h5stat_idx.ddl h5stat_err1_links.ddl h5stat_links1.ddl h5stat_links2.ddl @@ -45,6 +46,7 @@ h5stat_filters.h5 h5stat_tsohm.h5 h5stat_newgrat.h5 + h5stat_idx.h5 h5stat_threshold.h5 ) @@ -194,6 +196,8 @@ ADD_H5_TEST (h5stat_newgrat 0 h5stat_newgrat.h5) ADD_H5_TEST (h5stat_newgrat-UG 0 -G h5stat_newgrat.h5) ADD_H5_TEST (h5stat_newgrat-UA 0 -A h5stat_newgrat.h5) +# h5stat_idx.h5 is generated by h5stat_gentest.c + ADD_H5_TEST (h5stat_idx 0 h5stat_idx.h5) # # Tests for -l (--links) option on h5stat_threshold.h5: # -l 0 (incorrect threshold value) diff --git a/tools/test/misc/CMakeLists.txt b/tools/test/misc/CMakeLists.txt index db68eb1..a53fa73 100644 --- a/tools/test/misc/CMakeLists.txt +++ b/tools/test/misc/CMakeLists.txt @@ -27,4 +27,16 @@ INCLUDE_DIRECTORIES (${HDF5_TOOLS_DIR}/lib) target_link_libraries (h5repart_test ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) set_target_properties (h5repart_test PROPERTIES FOLDER tools) + add_executable (h5clear_gentest ${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/h5clear_gentest.c) + TARGET_NAMING (h5clear_gentest STATIC) + TARGET_C_PROPERTIES (h5clear_gentest STATIC " " " ") + target_link_libraries (h5clear_gentest ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) + set_target_properties (h5clear_gentest PROPERTIES FOLDER tools) + + add_executable (clear_open_chk ${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/clear_open_chk.c) + TARGET_NAMING (clear_open_chk STATIC) + TARGET_C_PROPERTIES (clear_open_chk STATIC " " " ") + target_link_libraries (clear_open_chk ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) + set_target_properties (clear_open_chk PROPERTIES FOLDER tools) + include (CMakeTests.cmake) diff --git a/tools/test/misc/CMakeTests.cmake b/tools/test/misc/CMakeTests.cmake index c041b21..9835e1e 100644 --- a/tools/test/misc/CMakeTests.cmake +++ b/tools/test/misc/CMakeTests.cmake @@ -177,6 +177,93 @@ h5repart_test ) + ###################### H5CLEAR ######################### + # Remove any output file left over from previous test run + add_test ( + NAME H5CLEAR-clearall-objects + COMMAND ${CMAKE_COMMAND} + -E remove + h5clear_log_v3.h5 + h5clear_sec2_v0.h5 + h5clear_sec2_v2.h5 + h5clear_sec2_v3.h5 + latest_h5clear_log_v3.h5 + latest_h5clear_sec2_v3.h5 + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5CLEAR-clearall-objects PROPERTIES DEPENDS ${last_test}) + endif (NOT "${last_test}" STREQUAL "") + set (last_test "H5CLEAR-clearall-objects") + + # create the output files to be used. + add_test (NAME H5CLEAR-h5clear_gentest COMMAND $<TARGET_FILE:h5clear_gentest>) + set_tests_properties (H5CLEAR-h5clear_gentest PROPERTIES DEPENDS "H5CLEAR-clearall-objects") + + # Initial file open fails + add_test (NAME H5CLEAR-clear_open_chk-sec2_v3_F COMMAND $<TARGET_FILE:clear_open_chk> h5clear_sec2_v3.h5) + set_tests_properties (H5CLEAR-clear_open_chk-sec2_v3_F PROPERTIES WILL_FAIL "true") + set_tests_properties (H5CLEAR-clear_open_chk-sec2_v3_F PROPERTIES DEPENDS H5CLEAR-h5clear_gentest) + # After "h5clear" the file, the subsequent file open succeeds + add_test (NAME H5CLEAR-h5clear-sec2_v3 COMMAND $<TARGET_FILE:h5clear> h5clear_sec2_v3.h5) + set_tests_properties (H5CLEAR-h5clear-sec2_v3 PROPERTIES DEPENDS H5CLEAR-clear_open_chk-sec2_v3_F) + add_test (NAME H5CLEAR-clear_open_chk-sec2_v3 COMMAND $<TARGET_FILE:clear_open_chk> h5clear_sec2_v3.h5) + set_tests_properties (H5CLEAR-clear_open_chk-sec2_v3 PROPERTIES DEPENDS H5CLEAR-h5clear-sec2_v3) + + # Initial file open fails + add_test (NAME H5CLEAR-clear_open_chk-log_v3_F COMMAND $<TARGET_FILE:clear_open_chk> h5clear_log_v3.h5) + set_tests_properties (H5CLEAR-clear_open_chk-log_v3_F PROPERTIES WILL_FAIL "true") + set_tests_properties (H5CLEAR-clear_open_chk-log_v3_F PROPERTIES DEPENDS H5CLEAR-h5clear_gentest) + # After "h5clear" the file, the subsequent file open succeeds + add_test (NAME H5CLEAR-h5clear-log_v3 COMMAND $<TARGET_FILE:h5clear> h5clear_log_v3.h5) + set_tests_properties (H5CLEAR-h5clear-log_v3 PROPERTIES DEPENDS H5CLEAR-clear_open_chk-log_v3_F) + add_test (NAME H5CLEAR-clear_open_chk-log_v3 COMMAND $<TARGET_FILE:clear_open_chk> h5clear_log_v3.h5) + set_tests_properties (H5CLEAR-clear_open_chk-log_v3 PROPERTIES DEPENDS H5CLEAR-h5clear-log_v3) + + # Initial file open fails + add_test (NAME H5CLEAR-clear_open_chk-latest_sec2_v3_F COMMAND $<TARGET_FILE:clear_open_chk> latest_h5clear_sec2_v3.h5) + set_tests_properties (H5CLEAR-clear_open_chk-latest_sec2_v3_F PROPERTIES WILL_FAIL "true") + set_tests_properties (H5CLEAR-clear_open_chk-latest_sec2_v3_F PROPERTIES DEPENDS H5CLEAR-h5clear_gentest) + # After "h5clear" the file, the subsequent file open succeeds + add_test (NAME H5CLEAR-h5clear-latest_sec2_v3 COMMAND $<TARGET_FILE:h5clear> latest_h5clear_sec2_v3.h5) + set_tests_properties (H5CLEAR-h5clear-latest_sec2_v3 PROPERTIES DEPENDS H5CLEAR-clear_open_chk-latest_sec2_v3_F) + add_test (NAME H5CLEAR-clear_open_chk-latest_sec2_v3 COMMAND $<TARGET_FILE:clear_open_chk> latest_h5clear_sec2_v3.h5) + set_tests_properties (H5CLEAR-clear_open_chk-latest_sec2_v3 PROPERTIES DEPENDS H5CLEAR-h5clear-latest_sec2_v3) + + # Initial file open fails + add_test (NAME H5CLEAR-clear_open_chk-latest_log_v3_F COMMAND $<TARGET_FILE:clear_open_chk> latest_h5clear_log_v3.h5) + set_tests_properties (H5CLEAR-clear_open_chk-latest_log_v3_F PROPERTIES WILL_FAIL "true") + set_tests_properties (H5CLEAR-clear_open_chk-latest_log_v3_F PROPERTIES DEPENDS H5CLEAR-h5clear_gentest) + # After "h5clear" the file, the subsequent file open succeeds + add_test (NAME H5CLEAR-h5clear-latest_log_v3 COMMAND $<TARGET_FILE:h5clear> latest_h5clear_log_v3.h5) + set_tests_properties (H5CLEAR-h5clear-latest_log_v3 PROPERTIES DEPENDS H5CLEAR-clear_open_chk-latest_log_v3_F) + add_test (NAME H5CLEAR-clear_open_chk-latest_log_v3 COMMAND $<TARGET_FILE:clear_open_chk> latest_h5clear_log_v3.h5) + set_tests_properties (H5CLEAR-clear_open_chk-latest_log_v3 PROPERTIES DEPENDS H5CLEAR-h5clear-latest_log_v3) + + # + # File open succeeds because the library does not check status_flags for file with < v3 superblock + add_test (NAME H5CLEAR-clear_open_chk-sec2_v0_P COMMAND $<TARGET_FILE:clear_open_chk> h5clear_sec2_v0.h5) + set_tests_properties (H5CLEAR-clear_open_chk-sec2_v0_P PROPERTIES DEPENDS H5CLEAR-h5clear_gentest) + # After "h5clear" the file, the subsequent file open succeeds + add_test (NAME H5CLEAR-h5clear-sec2_v0 COMMAND $<TARGET_FILE:h5clear> h5clear_sec2_v0.h5) + set_tests_properties (H5CLEAR-h5clear-sec2_v0 PROPERTIES DEPENDS H5CLEAR-clear_open_chk-sec2_v0_P) + add_test (NAME H5CLEAR-clear_open_chk-sec2_v0 COMMAND $<TARGET_FILE:clear_open_chk> h5clear_sec2_v0.h5) + set_tests_properties (H5CLEAR-clear_open_chk-sec2_v0 PROPERTIES DEPENDS H5CLEAR-h5clear-sec2_v0) + + # + # File open succeeds because the library does not check status_flags for file with < v3 superblock + add_test (NAME H5CLEAR-clear_open_chk-sec2_v2_P COMMAND $<TARGET_FILE:clear_open_chk> h5clear_sec2_v2.h5) + set_tests_properties (H5CLEAR-clear_open_chk-sec2_v2_P PROPERTIES DEPENDS H5CLEAR-h5clear_gentest) + # After "h5clear" the file, the subsequent file open succeeds + add_test (NAME H5CLEAR-h5clear-sec2_v2 COMMAND $<TARGET_FILE:h5clear> h5clear_sec2_v2.h5) + set_tests_properties (H5CLEAR-h5clear-sec2_v2 PROPERTIES DEPENDS H5CLEAR-clear_open_chk-sec2_v2_P) + add_test (NAME H5CLEAR-clear_open_chk-sec2_v2 COMMAND $<TARGET_FILE:clear_open_chk> h5clear_sec2_v2.h5) + set_tests_properties (H5CLEAR-clear_open_chk-sec2_v2 PROPERTIES DEPENDS H5CLEAR-h5clear-sec2_v2) + + set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} + h5clear_gentest + ) + + ###################### H5MKGRP ######################### if (HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5MKGRP-clearall-objects diff --git a/tools/test/misc/Makefile.am b/tools/test/misc/Makefile.am index 4168e8c..1025a8a 100644 --- a/tools/test/misc/Makefile.am +++ b/tools/test/misc/Makefile.am @@ -26,12 +26,12 @@ SUBDIRS=vds AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib #test scripts and programs -TEST_PROG=h5repart_gentest talign -TEST_SCRIPT=testh5repart.sh testh5mkgrp.sh +TEST_PROG=h5repart_gentest h5clear_gentest talign +TEST_SCRIPT=testh5repart.sh testh5mkgrp.sh testh5clear.sh -check_PROGRAMS=$(TEST_PROG) repart_test +check_PROGRAMS=$(TEST_PROG) repart_test clear_open_chk check_SCRIPTS=$(TEST_SCRIPT) -SCRIPT_DEPEND=../../src/misc/h5repart$(EXEEXT) ../../src/misc/h5mkgrp$(EXEEXT) +SCRIPT_DEPEND=../../src/misc/h5repart$(EXEEXT) ../../src/misc/h5mkgrp$(EXEEXT) ../../src/misc/h5clear$(EXEEXT) # Temporary files. *.h5 are generated by h5repart_gentest. They should # copied to the testfiles/ directory if update is required. fst_family*.h5 @@ -39,7 +39,7 @@ SCRIPT_DEPEND=../../src/misc/h5repart$(EXEEXT) ../../src/misc/h5mkgrp$(EXEEXT) CHECK_CLEANFILES+=*.h5 ../testfiles/fst_family*.h5 ../testfiles/scd_family*.h5 # These were generated by configure. Remove them only when distclean. -DISTCLEANFILES=testh5repart.sh +DISTCLEANFILES=testh5repart.sh testh5clear.sh # All programs rely on hdf5 library and h5tools library LDADD=$(LIBH5TOOLS) $(LIBHDF5) diff --git a/tools/test/misc/clear_open_chk.c b/tools/test/misc/clear_open_chk.c new file mode 100644 index 0000000..f3e6ba3 --- /dev/null +++ b/tools/test/misc/clear_open_chk.c @@ -0,0 +1,72 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include "hdf5.h" +#include "H5private.h" +#include "h5tools.h" + +static void usage(void); + +static void +usage(void) +{ + HDfprintf(stdout, "\n"); + HDfprintf(stdout, "Usage error!\n"); + HDfprintf(stdout, "Usage: clear_open_chk filename\n"); +} /* usage() */ + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: To open the file which has zero or nonzero status_flags in + * the superblock. + * + * Return: 0 on success + * 1 on failure + * + * Programmer: Vailin Choi; July 2013 + * + *------------------------------------------------------------------------- + */ +int +main(int argc, char *argv[]) +{ + char *fname; /* The HDF5 file name */ + hid_t fid; /* File ID */ + + /* Check the # of arguments */ + if(argc != 2) { + usage(); + return(EXIT_FAILURE); + } + + /* Get the file name */ + fname = HDstrdup(argv[1]); + + /* Try opening the file */ + if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) { + HDfprintf(stderr, "clear_open_chk: unable to open the file\n"); + return EXIT_FAILURE; + } + + /* Close the file */ + if(H5Fclose(fid) < 0) { + HDfprintf(stderr, "clear_open_chk: cannot close the file\n"); + return EXIT_FAILURE; + } + + /* Return success */ + return EXIT_SUCCESS; + +} /* main() */ diff --git a/tools/test/misc/h5clear_gentest.c b/tools/test/misc/h5clear_gentest.c new file mode 100644 index 0000000..0f20c35 --- /dev/null +++ b/tools/test/misc/h5clear_gentest.c @@ -0,0 +1,174 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include "hdf5.h" +#include "H5private.h" + +/* The HDF5 test files */ +const char *FILENAME[] = { + "h5clear_sec2_v3.h5", /* 0 -- sec2 file with superblock version 3 */ + "h5clear_log_v3.h5", /* 1 -- log file with superblock veresion 3 */ + "h5clear_sec2_v0.h5", /* 2 -- sec2 file with superblock version 0 */ + "h5clear_sec2_v2.h5" /* 3 -- sec2 file with superblock version 2 */ +}; + +#define KB 1024U + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: To create HDF5 files with non-zero status_flags in the superblock + * via flushing and exiting without closing the library. + * + * Due to file locking, status_flags in the superblock will be + * nonzero after H5Fcreate. The library will clear status_flags + * on file closing. This program, after "H5Fcreate" the files, + * exits without going through library closing. Thus, status_flags + * for these files are not cleared. + * The library will check consistency of status_flags when opening + * a file with superblock >= v3 and will return error accordingly. + * The library will not check status_flags when opening a file + * with < v3 superblock. + * + * These files are used by "h5clear" to see if the tool clears + * status_flags properly so users can open the files afterwards. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Vailin Choi; July 2013 + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + hid_t fid; /* File ID */ + hid_t fcpl; /* File creation property list */ + hid_t fapl, new_fapl; /* File access property lists */ + char fname[512]; /* File name */ + unsigned new_format; /* To use latest library format or not */ + + /* Create a copy of the file access property list */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + + /* Copy the file access property list */ + if((new_fapl = H5Pcopy(fapl)) < 0) + goto error; + /* Set to latest library format */ + if(H5Pset_libver_bounds(new_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + goto error; + + /* Files created within this for loop will have v3 superblock and nonzero status_flags */ + for(new_format = FALSE; new_format <= TRUE; new_format++) { + hid_t fapl2, my_fapl; /* File access property lists */ + + /* Set to use the appropriate file access property list */ + if(new_format) + fapl2 = new_fapl; + else + fapl2 = fapl; + /* + * Create a sec2 file + */ + if((my_fapl = H5Pcopy(fapl2)) < 0) + goto error; + /* Create the file */ + sprintf(fname, "%s%s", new_format? "latest_":"", FILENAME[0]); + if((fid = H5Fcreate(fname, H5F_ACC_TRUNC | (new_format ? 0 : H5F_ACC_SWMR_WRITE), H5P_DEFAULT, my_fapl)) < 0) + goto error; + + /* Flush the file */ + if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + goto error; + + /* Close the property list */ + if(H5Pclose(my_fapl) < 0) + goto error; + + /* + * Create a log file + */ + /* Create a copy of file access property list */ + if((my_fapl = H5Pcopy(fapl2)) < 0) + goto error; + + /* Setup the fapl for the log driver */ + if(H5Pset_fapl_log(my_fapl, "append.log", (unsigned long long)H5FD_LOG_ALL, (size_t)(4 * KB)) < 0) + goto error; + + /* Create the file */ + sprintf(fname, "%s%s", new_format? "latest_":"", FILENAME[1]); + if((fid = H5Fcreate(fname, H5F_ACC_TRUNC | (new_format ? 0 : H5F_ACC_SWMR_WRITE), H5P_DEFAULT, my_fapl)) < 0) + goto error; + + /* Flush the file */ + if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + goto error; + + /* Close the property list */ + if(H5Pclose(my_fapl) < 0) + goto error; + + } /* end for */ + + /* + * Create a sec2 file with v0 superblock but nonzero status_flags + */ + if((fid = H5Fcreate(FILENAME[2], H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + goto error; + + /* Flush the file */ + if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + goto error; + + + /* + * Create a sec2 file with v2 superblock but nonzero status_flags + */ + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + goto error; + if(H5Pset_shared_mesg_nindexes(fcpl, 1) < 0) + goto error; + if(H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_DTYPE_FLAG, 50) < 0) + goto error; + + if((fid = H5Fcreate(FILENAME[3], H5F_ACC_TRUNC, fcpl, fapl)) < 0) + goto error; + + /* Flush the file */ + if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) + goto error; + + + /* Close the property lists */ + if(H5Pclose(fapl) < 0) + goto error; + if(H5Pclose(new_fapl) < 0) + goto error; + if(H5Pclose(fcpl) < 0) + goto error; + + fflush(stdout); + fflush(stderr); + + /* Not going through library closing by calling _exit(0) with success */ + HD_exit(0); + +error: + + /* Exit with failure */ + HD_exit(1); +} diff --git a/tools/test/misc/testh5clear.sh.in b/tools/test/misc/testh5clear.sh.in new file mode 100644 index 0000000..a6836d4 --- /dev/null +++ b/tools/test/misc/testh5clear.sh.in @@ -0,0 +1,112 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# +# Tests for the h5clear tool +# +srcdir=@srcdir@ +TESTNAME=h5clear +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + +H5CLEAR=../../src/misc/h5clear +H5CLEAR_BIN=`pwd`/$H5CLEAR # The path of the tool binary + +OPENCHK=clear_open_chk # Try opening the test file +OPENCHK_BIN=`pwd`/$OPENCHK # The path to the binary + +SUCCEED=0 +FAIL=1 + +nerrors=0 +verbose=yes + +# Print a line-line message left justified in a field of 70 characters +# beginning with the word "Testing". +# +TESTING() { + SPACES=" " + echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' +} + + + +# (1)Use "clear_open_chk" to check if the file open succeeds or fails +# $1 is the filename to open +# $2 is the expected return from "clear_open_chk" +# (2) Use "h5clear" to clear the status_flags in the test file +# (3) Open the test file via "clear_open_chk" +TOOLTEST() { + fname=$1 + expected=$2 + # (1) + $OPENCHK_BIN $fname 2>/dev/null + actual=$? + if test $actual -ne $expected; then + echo "Unexpected return from $OPENCHK" + nerrors=`expr $nerrors + 1` + fi + # (2) + TESTING $H5CLEAR $1 + fname=$1 + # Use "h5clear" to clear the status_flags in the test file + $RUNSERIAL $H5CLEAR_BIN $fname + if test $? -ne $SUCCEED; then + echo ".....$H5CLEAR: should succeed" + nerrors=`expr $nerrors + 1` + else + # (3) Open the test file via "clear_open_chk" + $OPENCHK_BIN $fname + if test $? -ne $SUCCEED; then + echo "......$OPENCHK: should succeed" + nerrors=`expr $nerrors + 1` + else + echo "PASSED" + fi + fi +} + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## +# +# Initial file open fails +# After "h5clear" the file, the subsequent file open succeeds +TOOLTEST h5clear_sec2_v3.h5 $FAIL +# +TOOLTEST h5clear_log_v3.h5 $FAIL +# +TOOLTEST latest_h5clear_sec2_v3.h5 $FAIL +# +TOOLTEST latest_h5clear_log_v3.h5 $FAIL +# +# +# File open succeeds because the library does not check status_flags for file with < v3 superblock +TOOLTEST h5clear_sec2_v0.h5 $SUCCEED +TOOLTEST h5clear_sec2_v2.h5 $SUCCEED +# +# Clean up test files +if test -z "$HDF5_NOCLEANUP"; then + rm -f h5clear_*.h5 latest_h5clear*.h5 +fi + +if test $nerrors -eq 0 ; then + echo "All $TESTNAME tests passed." + exit $EXIT_SUCCESS +else + echo "$TESTNAME tests failed with $nerrors error(s)." + exit $EXIT_FAILURE +fi diff --git a/tools/testfiles/tdset_idx.ddl b/tools/testfiles/tdset_idx.ddl new file mode 100644 index 0000000..65d9f44 --- /dev/null +++ b/tools/testfiles/tdset_idx.ddl @@ -0,0 +1,61 @@ +############################# +Expected output for 'h5dump -p -H tdset_idx.h5' +############################# +HDF5 "tdset_idx.h5" { +GROUP "/" { + DATASET "dset_btree" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 20, 10 ) / ( 200, 100 ) } + STORAGE_LAYOUT { + CHUNKED ( 5, 5 ) + SIZE 800 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE 0 + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } + } + DATASET "dset_filter" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 20, 10 ) / ( 20, 10 ) } + STORAGE_LAYOUT { + CHUNKED ( 5, 5 ) + SIZE 200 (4.000:1 COMPRESSION) + } + FILTERS { + COMPRESSION DEFLATE { LEVEL 9 } + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE 0 + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } + } + DATASET "dset_fixed" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 20, 10 ) / ( 20, 10 ) } + STORAGE_LAYOUT { + CHUNKED ( 5, 5 ) + SIZE 800 + } + FILTERS { + NONE + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE 0 + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } + } +} +} |