diff options
Diffstat (limited to 'tools/test/h5stat')
-rw-r--r-- | tools/test/h5stat/CMakeLists.txt | 9 | ||||
-rw-r--r-- | tools/test/h5stat/CMakeTests.cmake | 4 | ||||
-rw-r--r-- | tools/test/h5stat/Makefile.am | 2 | ||||
-rw-r--r-- | tools/test/h5stat/Makefile.in | 66 | ||||
-rw-r--r-- | tools/test/h5stat/h5stat_gentest.c | 440 | ||||
-rw-r--r-- | tools/test/h5stat/testh5stat.sh.in | 4 |
6 files changed, 334 insertions, 191 deletions
diff --git a/tools/test/h5stat/CMakeLists.txt b/tools/test/h5stat/CMakeLists.txt index f50a747..a40d196 100644 --- a/tools/test/h5stat/CMakeLists.txt +++ b/tools/test/h5stat/CMakeLists.txt @@ -6,11 +6,18 @@ project (HDF5_TOOLS_TEST_H5STAT C) # -------------------------------------------------------------------- if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) add_executable (h5stat_gentest ${HDF5_TOOLS_TEST_H5STAT_SOURCE_DIR}/h5stat_gentest.c) - target_include_directories (h5stat_gentest PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (h5stat_gentest PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (h5stat_gentest STATIC) target_link_libraries (h5stat_gentest PRIVATE ${HDF5_LIB_TARGET}) set_target_properties (h5stat_gentest PROPERTIES FOLDER generator/tools) + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TOOLS_TEST_H5STAT_FORMAT h5stat_gentest) + endif () + #add_test (NAME h5stat_gentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5stat_gentest>) endif () diff --git a/tools/test/h5stat/CMakeTests.cmake b/tools/test/h5stat/CMakeTests.cmake index 0c07418..d4238b5 100644 --- a/tools/test/h5stat/CMakeTests.cmake +++ b/tools/test/h5stat/CMakeTests.cmake @@ -5,7 +5,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -207,7 +207,7 @@ # -d --di=15 ADD_H5_ERR_TEST (h5stat_err1_dims 1 -d --dims=-1 h5stat_threshold.h5) ADD_H5_TEST (h5stat_dims1 0 -gd -m 5 h5stat_threshold.h5) - ADD_H5_TEST (h5stat_dims2 0 -d --di=15 h5stat_threshold.h5) + ADD_H5_TEST (h5stat_dims2 0 -d --dims=15 h5stat_threshold.h5) # # Tests for -a option on h5stat_threshold.h5 # -a -2 (incorrect threshold value) diff --git a/tools/test/h5stat/Makefile.am b/tools/test/h5stat/Makefile.am index dd251f8..ca1108f 100644 --- a/tools/test/h5stat/Makefile.am +++ b/tools/test/h5stat/Makefile.am @@ -6,7 +6,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. ## diff --git a/tools/test/h5stat/Makefile.in b/tools/test/h5stat/Makefile.in index a3bd057..817996d 100644 --- a/tools/test/h5stat/Makefile.in +++ b/tools/test/h5stat/Makefile.in @@ -22,7 +22,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -114,6 +114,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/aclocal_cxx.m4 \ $(top_srcdir)/m4/ax_check_junit.m4 \ $(top_srcdir)/m4/ax_java_options.m4 \ $(top_srcdir)/m4/ax_jni_include_dir.m4 \ + $(top_srcdir)/m4/ax_prog_doxygen.m4 \ $(top_srcdir)/m4/ax_prog_jar.m4 \ $(top_srcdir)/m4/ax_prog_java.m4 \ $(top_srcdir)/m4/ax_prog_java_works.m4 \ @@ -417,12 +418,12 @@ AMTAR = @AMTAR@ # AM_CFLAGS is an automake construct which should be used by Makefiles # instead of CFLAGS, as CFLAGS is reserved solely for the user to define. # This applies to FCFLAGS, CXXFLAGS, CPPFLAGS, and LDFLAGS as well. -AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ @H5_ECFLAGS@ +AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ # Include src directory AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@ -I$(top_srcdir)/src \ -I$(top_srcdir)/tools/lib -AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ @H5_ECXXFLAGS@ +AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@ AM_JAVACFLAGS = @AM_JAVACFLAGS@ @@ -460,11 +461,56 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DEPRECATED_SYMBOLS = @DEPRECATED_SYMBOLS@ DESIRED_FILE_LOCKING = @DESIRED_FILE_LOCKING@ -DEV_WARNINGS = @DEV_WARNINGS@ +DIAGS = @DIAGS@ DIRECT_VFD = @DIRECT_VFD@ DLLTOOL = @DLLTOOL@ +DOXYGEN_EXAMPLES_DIRECTORY = @DOXYGEN_EXAMPLES_DIRECTORY@ +DOXYGEN_EXTERNAL_SEARCH = @DOXYGEN_EXTERNAL_SEARCH@ +DOXYGEN_HTML_EXTRA_FILES = @DOXYGEN_HTML_EXTRA_FILES@ +DOXYGEN_HTML_EXTRA_STYLESHEET = @DOXYGEN_HTML_EXTRA_STYLESHEET@ +DOXYGEN_HTML_FOOTER = @DOXYGEN_HTML_FOOTER@ +DOXYGEN_HTML_HEADER = @DOXYGEN_HTML_HEADER@ +DOXYGEN_INCLUDE_ALIASES = @DOXYGEN_INCLUDE_ALIASES@ +DOXYGEN_INPUT_DIRECTORY = @DOXYGEN_INPUT_DIRECTORY@ +DOXYGEN_LAYOUT_FILE = @DOXYGEN_LAYOUT_FILE@ +DOXYGEN_MACRO_EXPANSION = @DOXYGEN_MACRO_EXPANSION@ +DOXYGEN_OPTIMIZE_OUTPUT_FOR_C = @DOXYGEN_OPTIMIZE_OUTPUT_FOR_C@ +DOXYGEN_OUTPUT_DIRECTORY = @DOXYGEN_OUTPUT_DIRECTORY@ +DOXYGEN_PACKAGE = @DOXYGEN_PACKAGE@ +DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ +DOXYGEN_PREDEFINED = @DOXYGEN_PREDEFINED@ +DOXYGEN_PROJECT_BRIEF = @DOXYGEN_PROJECT_BRIEF@ +DOXYGEN_PROJECT_LOGO = @DOXYGEN_PROJECT_LOGO@ +DOXYGEN_SEARCHENGINE_URL = @DOXYGEN_SEARCHENGINE_URL@ +DOXYGEN_SERVER_BASED_SEARCH = @DOXYGEN_SERVER_BASED_SEARCH@ +DOXYGEN_STRIP_FROM_PATH = @DOXYGEN_STRIP_FROM_PATH@ +DOXYGEN_TAG_FILE = @DOXYGEN_TAG_FILE@ +DOXYGEN_VERSION_STRING = @DOXYGEN_VERSION_STRING@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ +DX_CONFIG = @DX_CONFIG@ +DX_DOCDIR = @DX_DOCDIR@ +DX_DOT = @DX_DOT@ +DX_DOXYGEN = @DX_DOXYGEN@ +DX_DVIPS = @DX_DVIPS@ +DX_EGREP = @DX_EGREP@ +DX_ENV = @DX_ENV@ +DX_FLAG_chi = @DX_FLAG_chi@ +DX_FLAG_chm = @DX_FLAG_chm@ +DX_FLAG_doc = @DX_FLAG_doc@ +DX_FLAG_dot = @DX_FLAG_dot@ +DX_FLAG_html = @DX_FLAG_html@ +DX_FLAG_man = @DX_FLAG_man@ +DX_FLAG_pdf = @DX_FLAG_pdf@ +DX_FLAG_ps = @DX_FLAG_ps@ +DX_FLAG_rtf = @DX_FLAG_rtf@ +DX_FLAG_xml = @DX_FLAG_xml@ +DX_HHC = @DX_HHC@ +DX_LATEX = @DX_LATEX@ +DX_MAKEINDEX = @DX_MAKEINDEX@ +DX_PDFLATEX = @DX_PDFLATEX@ +DX_PERL = @DX_PERL@ +DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -496,8 +542,6 @@ H5_CFLAGS = @H5_CFLAGS@ H5_CLASSPATH = @H5_CLASSPATH@ H5_CPPFLAGS = @H5_CPPFLAGS@ H5_CXXFLAGS = @H5_CXXFLAGS@ -H5_ECFLAGS = @H5_ECFLAGS@ -H5_ECXXFLAGS = @H5_ECXXFLAGS@ H5_FCFLAGS = @H5_FCFLAGS@ H5_FORTRAN_SHARED = @H5_FORTRAN_SHARED@ H5_IS_DARWIN = @H5_IS_DARWIN@ @@ -511,7 +555,9 @@ HAVE_DMALLOC = @HAVE_DMALLOC@ HAVE_Fortran_INTEGER_SIZEOF_16 = @HAVE_Fortran_INTEGER_SIZEOF_16@ HAVE_LIBHDFS = @HAVE_LIBHDFS@ HAVE_PTHREAD = @HAVE_PTHREAD@ +HDF5_DOXYGEN = @HDF5_DOXYGEN@ HDF5_HL = @HDF5_HL@ +HDF5_HL_TOOLS = @HDF5_HL_TOOLS@ HDF5_INTERFACES = @HDF5_INTERFACES@ HDF5_TESTS = @HDF5_TESTS@ HDF5_TOOLS = @HDF5_TOOLS@ @@ -521,6 +567,7 @@ HDF_JAVA = @HDF_JAVA@ HID_T = @HID_T@ HL = @HL@ HL_FOR = @HL_FOR@ +HL_TOOLS = @HL_TOOLS@ HSIZE_T = @HSIZE_T@ HSSIZE_T = @HSSIZE_T@ IGNORE_DISABLED_FILE_LOCKS = @IGNORE_DISABLED_FILE_LOCKS@ @@ -714,7 +761,7 @@ LIBH5F_HL = $(top_builddir)/hl/fortran/src/libhdf5hl_fortran.la LIBH5CPP_HL = $(top_builddir)/hl/c++/src/libhdf5_hl_cpp.la # Note that in svn revision 19400 the '/' after DESTDIR in H5* variables below -# has been removed. According to the official description of DESTDIR by Gnu at +# has been removed. According to the official description of DESTDIR by GNU at # http://www.gnu.org/prep/standards/html_node/DESTDIR.html, DESTDIR is # prepended to the normal and complete install path that it precedes for the # purpose of installing in a temporary directory which is useful for building @@ -1240,8 +1287,9 @@ uninstall-am: # commands that should be executed even if a file with the same name already # exists. .PHONY: build-check-clean build-check-p build-check-s build-lib build-progs \ - build-tests check-clean check-install check-p check-s check-vfd \ - install-doc lib progs tests uninstall-doc _exec_check-s _test help + build-tests check-clean check-install check-p check-s check-vfd \ + install-doc lib progs tests uninstall-doc \ + _exec_check-s _test help trace doxygen help: @$(top_srcdir)/bin/makehelp diff --git a/tools/test/h5stat/h5stat_gentest.c b/tools/test/h5stat/h5stat_gentest.c index 0bf1001..c775d6a 100644 --- a/tools/test/h5stat/h5stat_gentest.c +++ b/tools/test/h5stat/h5stat_gentest.c @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -24,101 +24,117 @@ #include "H5private.h" /* For gen_newgrat_file() */ -#define NEWGRAT_FILE "h5stat_newgrat.h5" -#define DATASET_NAME "DATASET_NAME" -#define GROUP_NAME "GROUP" +#define NEWGRAT_FILE "h5stat_newgrat.h5" +#define DATASET_NAME "DATASET_NAME" +#define GROUP_NAME "GROUP" #define ATTR_NAME "ATTR" #define NUM_GRPS 35000 #define NUM_ATTRS 100 /* Declarations for gen_idx_file() */ -#define IDX_FILE "h5stat_idx.h5" +#define IDX_FILE "h5stat_idx.h5" #define DSET "dset" -#define DSET_FILTER "dset_filter" +#define DSET_FILTER "dset_filter" /* For gen_threshold_file() */ -#define THRESHOLD_FILE "h5stat_threshold.h5" -#define THRES_ATTR_NAME "attr" -#define THRES_ATTR_GRP_NAME "grp_attr" +#define THRESHOLD_FILE "h5stat_threshold.h5" +#define THRES_ATTR_NAME "attr" +#define THRES_ATTR_GRP_NAME "grp_attr" #define THRES_DSET_NAME "dset" -#define THRES_NUM 10 +#define THRES_NUM 10 #define THRES_NUM_25 25 /* For gen_err_refcount() */ -#define ERR_REFCOUNT_FILE "h5stat_err_refcount.h5" +#define ERR_REFCOUNT_FILE "h5stat_err_refcount.h5" /* * Generate HDF5 file with latest format with * NUM_GRPS groups and NUM_ATTRS attributes for the dataset */ -static void +static herr_t gen_newgrat_file(const char *fname) { - hid_t fcpl = H5I_INVALID_HID; /* File creation property */ - hid_t fapl = H5I_INVALID_HID; /* File access property */ - hid_t fid = H5I_INVALID_HID; /* File id */ - hid_t gid = H5I_INVALID_HID; /* Group id */ - hid_t tid = H5I_INVALID_HID; /* Datatype id */ - hid_t sid = H5I_INVALID_HID; /* Dataspace id */ - hid_t attr_id = H5I_INVALID_HID; /* Attribute id */ - hid_t did = H5I_INVALID_HID; /* Dataset id */ - char name[30]; /* Group name */ - char attrname[30]; /* Attribute name */ - int i; /* Local index variable */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property */ + hid_t fapl = H5I_INVALID_HID; /* File access property */ + hid_t fid = H5I_INVALID_HID; /* File id */ + hid_t gid = H5I_INVALID_HID; /* Group id */ + hid_t tid = H5I_INVALID_HID; /* Datatype id */ + hid_t sid = H5I_INVALID_HID; /* Dataspace id */ + hid_t attr_id = H5I_INVALID_HID; /* Attribute id */ + hid_t did = H5I_INVALID_HID; /* Dataset id */ + char name[30]; /* Group name */ + char attrname[30]; /* Attribute name */ + int i; /* Local index variable */ /* Get a copy file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; /* Set to use latest library format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; /* Get a copy of file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) goto error; /* Set file space handling strategy */ - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, 1, (hsize_t)1) < 0) + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, 1, (hsize_t)1) < 0) goto error; - /* Create file */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + /* Create file */ + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0) goto error; /* Create NUM_GRPS groups in the root group */ - for(i = 1; i <= NUM_GRPS; i++) { - HDsprintf(name, "%s%d", GROUP_NAME,i); - if((gid = H5Gcreate2(fid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 1; i <= NUM_GRPS; i++) { + HDsprintf(name, "%s%d", GROUP_NAME, i); + if ((gid = H5Gcreate2(fid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; } /* end for */ /* Create a datatype to commit and use */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) goto error; /* Create dataspace for dataset */ - if((sid = H5Screate(H5S_SCALAR)) < 0) + if ((sid = H5Screate(H5S_SCALAR)) < 0) goto error; /* Create dataset */ - if((did = H5Dcreate2(fid, DATASET_NAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DATASET_NAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create NUM_ATTRS for the dataset */ - for(i = 1; i <= NUM_ATTRS; i++) { - HDsprintf(attrname, "%s%d", ATTR_NAME,i); - if((attr_id = H5Acreate2(did, attrname, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 1; i <= NUM_ATTRS; i++) { + HDsprintf(attrname, "%s%d", ATTR_NAME, i); + if ((attr_id = H5Acreate2(did, attrname, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto error; } /* end for */ /* Close dataset, dataspace, datatype, file */ + if (H5Pclose(fapl) < 0) + goto error; + if (H5Pclose(fcpl) < 0) + goto error; + if (H5Dclose(did) < 0) + goto error; + if (H5Tclose(tid) < 0) + goto error; + if (H5Sclose(sid) < 0) + goto error; + if (H5Fclose(fid) < 0) + goto error; + + return SUCCEED; + error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Pclose(fcpl); H5Aclose(attr_id); @@ -127,178 +143,202 @@ error: H5Sclose(sid); H5Gclose(gid); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; + + return FAIL; } /* gen_newgrat_file() */ /* * Generate an HDF5 file with groups, datasets, attributes for testing the options: * -l N (--links=N): Set the threshold for # of links when printing information for small groups. - * -m N (--dims=N): Set the threshold for the # of dimension sizes when printing information for small datasets. - * -a N (--numattrs=N): Set the threshold for the # of attributes when printing information for small # of attributes. + * -m N (--dims=N): Set the threshold for the # of dimension sizes when printing information for small + * datasets. -a N (--numattrs=N): Set the threshold for the # of attributes when printing information for + * small # of attributes. */ -static void +static herr_t gen_threshold_file(const char *fname) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t sid0 = H5I_INVALID_HID; /* Dataspace IDs */ - hid_t sid1 = H5I_INVALID_HID; /* Dataspace IDs */ - hid_t sid2 = H5I_INVALID_HID; /* Dataspace IDs */ - hid_t sid3 = H5I_INVALID_HID; /* Dataspace IDs */ - hid_t sid4 = H5I_INVALID_HID; /* Dataspace IDs */ - hid_t did = H5I_INVALID_HID; /* Dataset ID */ - hid_t attr_id = H5I_INVALID_HID; /* Attribute ID */ - hid_t gid = H5I_INVALID_HID; /* Group ID */ - hsize_t two_dims[] = {2, 5}; /* Dimension array */ - hsize_t one_dims[] = {6}; /* Dimension array */ - hsize_t zero_dims[] = {0}; /* Dimension array */ - char name[30]; /* Name */ - unsigned i; /* Local index variable */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t sid0 = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t sid1 = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t sid2 = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t sid3 = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t sid4 = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t did = H5I_INVALID_HID; /* Dataset ID */ + hid_t attr_id = H5I_INVALID_HID; /* Attribute ID */ + hid_t gid = H5I_INVALID_HID; /* Group ID */ + hsize_t two_dims[] = {2, 5}; /* Dimension array */ + hsize_t one_dims[] = {6}; /* Dimension array */ + hsize_t zero_dims[] = {0}; /* Dimension array */ + char name[30]; /* Name */ + unsigned i; /* Local index variable */ /* Create file */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create 1-D dataspace with zero dimension size */ - if((sid0 = H5Screate_simple(1, zero_dims, NULL)) < 0) + if ((sid0 = H5Screate_simple(1, zero_dims, NULL)) < 0) goto error; /* Create 1-D dataspace with non-zero dimension size*/ - if((sid1 = H5Screate_simple(1, one_dims, NULL)) < 0) + if ((sid1 = H5Screate_simple(1, one_dims, NULL)) < 0) goto error; /* Create 2-D dataspace */ - if((sid2 = H5Screate_simple(2, two_dims, NULL)) < 0) + if ((sid2 = H5Screate_simple(2, two_dims, NULL)) < 0) goto error; /* Create scalar dataspace */ - if((sid3 = H5Screate(H5S_SCALAR)) < 0) + if ((sid3 = H5Screate(H5S_SCALAR)) < 0) goto error; /* Create null dataspace */ - if((sid4 = H5Screate(H5S_NULL)) < 0) + if ((sid4 = H5Screate(H5S_NULL)) < 0) goto error; /* Create an attribute for the root group */ - if((attr_id = H5Acreate2(fid, "attr", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(fid, "attr", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto error; /* Create 1-D dataset with zero dimension size for the root group */ - if((did = H5Dcreate2(fid, "zero_dset", H5T_NATIVE_UCHAR, sid0, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "zero_dset", H5T_NATIVE_UCHAR, sid0, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) goto error; /* Create 11 attributes for the dataset */ - for(i = 1; i <= (THRES_NUM+1); i++) { - HDsprintf(name, "%s%d", THRES_ATTR_NAME,i); - if((attr_id = H5Acreate2(did, name, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 1; i <= (THRES_NUM + 1); i++) { + HDsprintf(name, "%s%d", THRES_ATTR_NAME, i); + if ((attr_id = H5Acreate2(did, name, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto error; } - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; /* Create dataset with scalar dataspace for the root group */ - if((did = H5Dcreate2(fid, "scalar_dset", H5T_NATIVE_UCHAR, sid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "scalar_dset", H5T_NATIVE_UCHAR, sid3, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) goto error; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; /* Create dataset with null dataspace for the root group */ - if((did = H5Dcreate2(fid, "null_dset", H5T_NATIVE_UCHAR, sid4, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "null_dset", H5T_NATIVE_UCHAR, sid4, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < + 0) goto error; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; /* Create 2-D dataset for the root group */ - if((did = H5Dcreate2(fid, "dset", H5T_NATIVE_UCHAR, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dset", H5T_NATIVE_UCHAR, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create 10 attributes for the 2-D dataset */ - for(i = 1; i <= THRES_NUM; i++) { - HDsprintf(name, "%s%d", THRES_ATTR_NAME,i); - if((attr_id = H5Acreate2(did, name, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) + for (i = 1; i <= THRES_NUM; i++) { + HDsprintf(name, "%s%d", THRES_ATTR_NAME, i); + if ((attr_id = H5Acreate2(did, name, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto error; } - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; /* Create first group */ - if((gid = H5Gcreate2(fid, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create an attribute for the group */ - if((attr_id = H5Acreate2(gid, "ATTR", H5T_NATIVE_INT, sid3, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(gid, "ATTR", H5T_NATIVE_INT, sid3, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Close attribute */ - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto error; /* Create 10 1-D datasets with non-zero dimension size for the group */ - for(i = 1; i <= THRES_NUM; i++) { + for (i = 1; i <= THRES_NUM; i++) { /* set up dataset name */ - HDsprintf(name, "%s%d", THRES_DSET_NAME,i); + HDsprintf(name, "%s%d", THRES_DSET_NAME, i); /* Create the dataset */ - if((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; } /* Close the group */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; - /* Create second group */ - if((gid = H5Gcreate2(fid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create 25 attributes for the group */ - for(i = 1; i <= THRES_NUM_25; i++) { - /* Set up attribute name */ - HDsprintf(name, "%s%d", THRES_ATTR_GRP_NAME,i); + for (i = 1; i <= THRES_NUM_25; i++) { + /* Set up attribute name */ + HDsprintf(name, "%s%d", THRES_ATTR_GRP_NAME, i); /* Create the attribute */ - if((attr_id = H5Acreate2(gid, name, H5T_NATIVE_INT, sid2, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(gid, name, H5T_NATIVE_INT, sid2, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Close the attribute */ - if(H5Aclose(attr_id) < 0) + if (H5Aclose(attr_id) < 0) goto error; } /* Close the group */ - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; /* Create third group */ - if((gid = H5Gcreate2(fid, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create 9 1-D datasets with non-zero dimension size for the group */ - for(i = 1; i < THRES_NUM; i++) { + for (i = 1; i < THRES_NUM; i++) { /* set up dataset name */ - HDsprintf(name, "%s%d", THRES_DSET_NAME,i); + HDsprintf(name, "%s%d", THRES_DSET_NAME, i); /* Create the dataset */ - if((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Close the dataset */ - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; } + if (H5Gclose(gid) < 0) + goto error; + if (H5Sclose(sid0) < 0) + goto error; + if (H5Sclose(sid1) < 0) + goto error; + if (H5Sclose(sid2) < 0) + goto error; + if (H5Sclose(sid3) < 0) + goto error; + if (H5Sclose(sid4) < 0) + goto error; + if (H5Fclose(fid) < 0) + goto error; + + return SUCCEED; + error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Aclose(attr_id); H5Dclose(did); @@ -308,7 +348,10 @@ error: H5Sclose(sid3); H5Sclose(sid4); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; + + return FAIL; } /* gen_threshold_file() */ @@ -320,80 +363,100 @@ error: * one dataset: fixed dimension, chunked layout, w/ filters * */ -static void +static herr_t gen_idx_file(const char *fname) { - hid_t fapl = H5I_INVALID_HID; /* file access property id */ - hid_t fid = H5I_INVALID_HID; /* file id */ - hid_t sid = H5I_INVALID_HID; /* space id */ - hid_t dcpl = H5I_INVALID_HID; /* dataset creation property id */ - hid_t did = -1, did2 = H5I_INVALID_HID; /* dataset id */ - hsize_t dims[1] = {10}; /* dataset dimension */ - hsize_t c_dims[1] = {2}; /* chunk dimension */ - int i; /* local index variable */ - int buf[10]; /* data buffer */ + hid_t fapl = H5I_INVALID_HID; /* file access property id */ + hid_t fid = H5I_INVALID_HID; /* file id */ + hid_t sid = H5I_INVALID_HID; /* space id */ + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property id */ + hid_t did = H5I_INVALID_HID; /* dataset id */ +#if defined(H5_HAVE_FILTER_DEFLATE) + hid_t did2 = H5I_INVALID_HID; /* dataset id (compressed) */ +#endif + hsize_t dims[1] = {10}; /* dataset dimension */ + hsize_t c_dims[1] = {2}; /* chunk dimension */ + int i; /* local index variable */ + int buf[10]; /* data buffer */ /* Get a copy of the file access property */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; /* Set the "use the latest format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) goto error; /* Create file */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; /* Create data */ - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) buf[i] = i; /* Set chunk */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 1, c_dims) < 0) + if (H5Pset_chunk(dcpl, 1, c_dims) < 0) goto error; /* Create a 1D dataset */ - if((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto error; - if((did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; /* Write to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) /* set deflate data */ - if(H5Pset_deflate(dcpl, 9) < 0) + if (H5Pset_deflate(dcpl, 9) < 0) goto error; /* Create and write the dataset */ - if((did2 = H5Dcreate2(fid, DSET_FILTER, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if ((did2 = H5Dcreate2(fid, DSET_FILTER, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Close the dataset */ - if(H5Dclose(did2) < 0) + if (H5Dclose(did2) < 0) goto error; #endif /* closing: dataspace, dataset, file */ + if (H5Pclose(fapl) < 0) + goto error; + if (H5Pclose(dcpl) < 0) + goto error; + if (H5Sclose(sid) < 0) + goto error; + if (H5Dclose(did) < 0) + goto error; + if (H5Fclose(fid) < 0) + goto error; + + return SUCCEED; + error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Pclose(fapl); H5Pclose(dcpl); H5Sclose(sid); H5Dclose(did); H5Fclose(fid); -#if defined (H5_HAVE_FILTER_DEFLATE) +#if defined(H5_HAVE_FILTER_DEFLATE) H5Dclose(did2); #endif - } H5E_END_TRY; + } + H5E_END_TRY; + + return FAIL; } /* gen_idx_file() */ @@ -410,73 +473,78 @@ error: * H5O_refcount_decode in the jira issue. * */ -static void +static herr_t gen_err_refcount(const char *fname) { - hid_t fid = H5I_INVALID_HID; /* File identifier */ - hid_t sid = H5I_INVALID_HID; /* Dataspace message */ - hid_t did = H5I_INVALID_HID; /* Dataset identifier */ - hid_t gid = H5I_INVALID_HID; /* Group identifier */ - hid_t aid1 = -1, aid2 = H5I_INVALID_HID; /* Attribute identifier */ - hid_t tid = H5I_INVALID_HID; /* Datatype identifier */ - int i, n; /* Local index variables */ - int buf[10]; /* Data buffer */ - hsize_t dims[1]; /* Dimension size */ - int fd = -1; /* File descriptor */ - unsigned short val = 22; /* The refcount message ID */ + hid_t fid = H5I_INVALID_HID; /* File identifier */ + hid_t sid = H5I_INVALID_HID; /* Dataspace message */ + hid_t did = H5I_INVALID_HID; /* Dataset identifier */ + hid_t gid = H5I_INVALID_HID; /* Group identifier */ + hid_t aid1 = H5I_INVALID_HID; /* Attribute identifier */ + hid_t aid2 = H5I_INVALID_HID; /* Attribute identifier */ + hid_t tid = H5I_INVALID_HID; /* Datatype identifier */ + int i, n; /* Local index variables */ + int buf[10]; /* Data buffer */ + hsize_t dims[1]; /* Dimension size */ + int fd = -1; /* File descriptor */ + unsigned short val = 22; /* The refcount message ID */ /* Initialize data buffer */ n = 0; - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) buf[i] = n++; /* Create the file */ - if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create a group */ - if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Create a committed datatype in the group */ - if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) goto error; - if(H5Tcommit2(gid, "dtype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Tcommit2(gid, "dtype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) goto error; /* Create the dataspace */ dims[0] = 10; - if((sid = H5Screate_simple(1, dims, NULL)) < 0) + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) goto error; /* Create a dataset with the committed datatype in the file */ - if((did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Write to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; /* Attach an attribute with the committed datatype to the group */ - if((aid1 = H5Acreate2(gid, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid1 = H5Acreate2(gid, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Attach an attribute with the committed datatype to the dataset */ - if((aid2 = H5Acreate2(did, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid2 = H5Acreate2(did, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* Closing */ - if(H5Aclose(aid1) < 0) + if (H5Aclose(aid1) < 0) goto error; - if(H5Aclose(aid2) < 0) + if (H5Aclose(aid2) < 0) goto error; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) goto error; - if(H5Dclose(did) < 0) + if (H5Dclose(did) < 0) goto error; - if(H5Gclose(gid) < 0) + if (H5Gclose(gid) < 0) goto error; - if(H5Tclose(tid) < 0) + if (H5Tclose(tid) < 0) goto error; - if(H5Fclose(fid) < 0) + + /* Be sure to close this before opening the file again via open(), below, + * or you'll possibly trip over the file locking. + */ + if (H5Fclose(fid) < 0) goto error; /* This section of code will write a refcount message ID to a message in the @@ -486,14 +554,20 @@ gen_err_refcount(const char *fname) with the committed datatype */ /* 24: the offset in the object header containing the version of the attribute message */ - if((fd = HDopen(fname, O_RDWR, 0633)) >= 0) { - HDlseek(fd, 4520+24, SEEK_SET); - HDwrite(fd, &val, 2); - HDclose(fd); - } + if ((fd = HDopen(fname, O_RDWR, 0633)) < 0) + goto error; + if (HDlseek(fd, 4520 + 24, SEEK_SET) < 0) + goto error; + if (HDwrite(fd, &val, 2) < 0) + goto error; + if (HDclose(fd) < 0) + goto error; + + return SUCCEED; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); H5Dclose(did); H5Tclose(tid); @@ -501,7 +575,13 @@ error: H5Aclose(aid1); H5Aclose(aid2); H5Fclose(fid); - } H5E_END_TRY; + } + H5E_END_TRY; + + if (fd >= 0) + HDclose(fd); + + return FAIL; } /* gen_err_refcount() */ /* @@ -528,17 +608,25 @@ error: * jira issue. */ -int main(void) +int +main(void) { - gen_newgrat_file(NEWGRAT_FILE); - gen_threshold_file(THRESHOLD_FILE); + if (gen_newgrat_file(NEWGRAT_FILE) < 0) + goto error; + if (gen_threshold_file(THRESHOLD_FILE) < 0) + goto error; /* Generate an HDF file to test for datasets with Fixed Array indexing */ - gen_idx_file(IDX_FILE); + if (gen_idx_file(IDX_FILE) < 0) + goto error; /* Generate a file with a refcount message ID */ - gen_err_refcount(ERR_REFCOUNT_FILE); + if (gen_err_refcount(ERR_REFCOUNT_FILE) < 0) + goto error; - return 0; -} + return EXIT_SUCCESS; +error: + HDfprintf(stderr, "h5stat test generator FAILED\n"); + return EXIT_FAILURE; +} diff --git a/tools/test/h5stat/testh5stat.sh.in b/tools/test/h5stat/testh5stat.sh.in index 69b856e..647f06a 100644 --- a/tools/test/h5stat/testh5stat.sh.in +++ b/tools/test/h5stat/testh5stat.sh.in @@ -7,7 +7,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -304,7 +304,7 @@ TOOLTEST h5stat_links5.ddl -g -l 40000 h5stat_newgrat.h5 # -d --di=15 TOOLTEST h5stat_err1_dims.ddl -d --dims=-1 h5stat_threshold.h5 TOOLTEST h5stat_dims1.ddl -gd -m 5 h5stat_threshold.h5 -TOOLTEST h5stat_dims2.ddl -d --di=15 h5stat_threshold.h5 +TOOLTEST h5stat_dims2.ddl -d --dims=15 h5stat_threshold.h5 # # Tests for -a option on h5stat_threshold.h5 # -a -2 (incorrect threshold value) |