diff options
author | David Young <dyoung@hdfgroup.org> | 2019-12-09 16:30:58 (GMT) |
---|---|---|
committer | David Young <dyoung@hdfgroup.org> | 2019-12-09 16:30:58 (GMT) |
commit | c8f533cfc33ac743227cbed8eba361c715a2976f (patch) | |
tree | bcae5320f80bac774647cacbbd8493604f9384d2 /tools/test/h5stat | |
parent | adcf8a315e82c0848d126e7e46b662930c081896 (diff) | |
download | hdf5-c8f533cfc33ac743227cbed8eba361c715a2976f.zip hdf5-c8f533cfc33ac743227cbed8eba361c715a2976f.tar.gz hdf5-c8f533cfc33ac743227cbed8eba361c715a2976f.tar.bz2 |
Merge all of my changes from merge-back-to-feature-vfd_swmr-attempt-1,
including the merge of `hdffv/hdf5/develop`, back to the branch that Vailin and
I share.
Now I need to put this branch on a fork with a less confusing name than
vchoi_fork!
Diffstat (limited to 'tools/test/h5stat')
20 files changed, 255 insertions, 234 deletions
diff --git a/tools/test/h5stat/CMakeLists.txt b/tools/test/h5stat/CMakeLists.txt index e65c76f..5c17fd5 100644 --- a/tools/test/h5stat/CMakeLists.txt +++ b/tools/test/h5stat/CMakeLists.txt @@ -4,14 +4,14 @@ project (HDF5_TOOLS_TEST_H5STAT C) # -------------------------------------------------------------------- # Add the h5stat test executables # -------------------------------------------------------------------- -if (HDF5_BUILD_GENERATORS) +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_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_test (NAME h5stat_gentest COMMAND $<TARGET_FILE:h5stat_gentest>) + #add_test (NAME h5stat_gentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5stat_gentest>) endif () include (CMakeTests.cmake) diff --git a/tools/test/h5stat/CMakeTests.cmake b/tools/test/h5stat/CMakeTests.cmake index bd55ac1..9674a77 100644 --- a/tools/test/h5stat/CMakeTests.cmake +++ b/tools/test/h5stat/CMakeTests.cmake @@ -39,23 +39,30 @@ h5stat_newgrat h5stat_newgrat-UG h5stat_newgrat-UA - h5stat_err1_links h5stat_idx h5stat_links1 h5stat_links2 h5stat_links3 h5stat_links4 h5stat_links5 - h5stat_err1_dims h5stat_dims1 h5stat_dims2 - h5stat_err1_numattrs - h5stat_err2_numattrs h5stat_numattrs1 h5stat_numattrs2 h5stat_numattrs3 h5stat_numattrs4 ) + set (HDF5_REFERENCE_ERR_FILES + h5stat_err_refcount + h5stat_err_old_layout + h5stat_err_old_fill + h5stat_err1_dims + h5stat_err1_links + h5stat_err1_numattrs + h5stat_err2_numattrs + h5stat_notexist + h5stat_nofile + ) set (HDF5_REFERENCE_TEST_FILES h5stat_err_refcount.h5 h5stat_err_old_layout.h5 @@ -71,6 +78,10 @@ HDFTEST_COPY_FILE("${HDF5_TOOLS_TEST_H5STAT_SOURCE_DIR}/testfiles/${ddl_file}.ddl" "${PROJECT_BINARY_DIR}/${ddl_file}.ddl" "h5stat_files") endforeach () + foreach (h5_file ${HDF5_REFERENCE_ERR_FILES}) + HDFTEST_COPY_FILE("${HDF5_TOOLS_TEST_H5STAT_SOURCE_DIR}/testfiles/${h5_file}.err" "${PROJECT_BINARY_DIR}/${h5_file}.err" "h5stat_files") + endforeach () + foreach (h5_file ${HDF5_REFERENCE_TEST_FILES}) HDFTEST_COPY_FILE("${HDF5_TOOLS_TEST_H5STAT_SOURCE_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/${h5_file}" "h5stat_files") endforeach () @@ -82,39 +93,56 @@ ############################################################################## ############################################################################## + if (NOT BUILD_SHARED_LIBS) + set (tgt_ext "") + else () + set (tgt_ext "-shared") + endif () + macro (ADD_H5_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5STAT-${resultfile} COMMAND $<TARGET_FILE:h5stat> ${ARGN}) - if (NOT "${resultcode}" STREQUAL "0") + add_test (NAME H5STAT-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5stat${tgt_ext}> ${ARGN}) + if (${resultcode}) set_tests_properties (H5STAT-${resultfile} PROPERTIES WILL_FAIL "true") endif () - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5STAT-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif () else (HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5STAT-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${resultfile}.out - ${resultfile}.out.err + NAME H5STAT-${resultfile} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5stat${tgt_ext}>" + -D "TEST_ARGS=${ARGN}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=${resultfile}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}.ddl" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5STAT-${resultfile}-clear-objects PROPERTIES DEPENDS ${last_test}) + endif () + endmacro () + + macro (ADD_H5_ERR_TEST resultfile resultcode) + # If using memchecker add tests without using scripts + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME H5STAT-${resultfile} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5stat${tgt_ext}> ${ARGN}) + if (${resultcode}) + set_tests_properties (H5STAT-${resultfile} PROPERTIES WILL_FAIL "true") endif () + else (HDF5_ENABLE_USING_MEMCHECKER) add_test ( NAME H5STAT-${resultfile} COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5stat>" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5stat${tgt_ext}>" -D "TEST_ARGS=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=${resultfile}.out" -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}.ddl" + -D "TEST_REFERENCE=${resultfile}.mty" + -D "TEST_ERRREF=${resultfile}.err" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (H5STAT-${resultfile} PROPERTIES DEPENDS H5STAT-${resultfile}-clear-objects) endif () endmacro () @@ -131,13 +159,8 @@ endforeach () add_test ( NAME H5STAT-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove ${CLEAR_LIST} + COMMAND ${CMAKE_COMMAND} -E remove ${CLEAR_LIST} ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5STAT-clearall-objects PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5STAT-clearall-objects") endif () # Test for help flag @@ -173,7 +196,7 @@ # -g -l 8 # --links=8 # --links=20 -g - ADD_H5_TEST (h5stat_err1_links 1 -l 0 h5stat_threshold.h5) + ADD_H5_ERR_TEST (h5stat_err1_links 1 -l 0 h5stat_threshold.h5) ADD_H5_TEST (h5stat_links1 0 -g -l 8 h5stat_threshold.h5) ADD_H5_TEST (h5stat_links2 0 --links=8 h5stat_threshold.h5) ADD_H5_TEST (h5stat_links3 0 --links=20 -g h5stat_threshold.h5) @@ -188,7 +211,7 @@ # -d --dims=-1 (incorrect threshold value) # -gd -m 5 # -d --di=15 - ADD_H5_TEST (h5stat_err1_dims 1 -d --dims=-1 h5stat_threshold.h5) + 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) # @@ -198,8 +221,8 @@ # -AS -a 10 # -a 1 # -A --numattrs=25 - ADD_H5_TEST (h5stat_err1_numattrs 1 -a -2 h5stat_threshold.h5) - ADD_H5_TEST (h5stat_err2_numattrs 1 --numattrs h5stat_threshold.h5) + ADD_H5_ERR_TEST (h5stat_err1_numattrs 1 -a -2 h5stat_threshold.h5) + ADD_H5_ERR_TEST (h5stat_err2_numattrs 1 --numattrs h5stat_threshold.h5) ADD_H5_TEST (h5stat_numattrs1 0 -AS -a 10 h5stat_threshold.h5) ADD_H5_TEST (h5stat_numattrs2 0 -a 1 h5stat_threshold.h5) ADD_H5_TEST (h5stat_numattrs3 0 -A --numattrs=25 h5stat_threshold.h5) diff --git a/tools/test/h5stat/h5stat_gentest.c b/tools/test/h5stat/h5stat_gentest.c index 2daf24b..2edfcf6 100644 --- a/tools/test/h5stat/h5stat_gentest.c +++ b/tools/test/h5stat/h5stat_gentest.c @@ -14,7 +14,7 @@ /* * Generate the binary hdf5 files for the h5stat tests. * Usage: just execute the program without any arguments will - * generate all the binary hdf5 files + * generate all the binary hdf5 files * * If you regenerate the test files (e.g., changing some code, * trying it on a new platform, ...), you need to verify the correctness @@ -24,25 +24,25 @@ #include "H5private.h" /* For gen_newgrat_file() */ -#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 +#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 DSET "dset" -#define DSET_FILTER "dset_filter" +#define IDX_FILE "h5stat_idx.h5" +#define DSET "dset" +#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 THRES_DSET_NAME "dset" -#define THRES_NUM 10 -#define THRES_NUM_25 25 +#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_25 25 /* For gen_err_refcount() */ #define ERR_REFCOUNT_FILE "h5stat_err_refcount.h5" @@ -51,7 +51,7 @@ * Generate HDF5 file with latest format with * NUM_GRPS groups and NUM_ATTRS attributes for the dataset */ -static void +static void gen_newgrat_file(const char *fname) { hid_t fcpl = -1; /* File creation property */ @@ -62,79 +62,66 @@ gen_newgrat_file(const char *fname) hid_t sid = -1; /* Dataspace id */ hid_t attr_id = -1; /* Attribute id */ hid_t did = -1; /* Dataset id */ - char name[30]; /* Group name */ - char attrname[30]; /* Attribute name */ - int i; /* Local index variable */ + 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) - goto error; + goto error; /* Set to use latest library format */ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - goto error; + goto error; /* Get a copy of file creation property list */ if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - goto error; + goto error; /* Set file space handling strategy */ if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, 1, (hsize_t)1) < 0) - goto error; + goto error; /* Create file */ if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0) - goto error; + goto error; /* Create NUM_GRPS groups in the root group */ for(i = 1; i <= NUM_GRPS; i++) { - sprintf(name, "%s%d", GROUP_NAME,i); + HDsprintf(name, "%s%d", GROUP_NAME,i); if((gid = H5Gcreate2(fid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; if(H5Gclose(gid) < 0) - goto error; + goto error; } /* end for */ /* Create a datatype to commit and use */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) - goto error; + goto error; /* Create dataspace for dataset */ if((sid = H5Screate(H5S_SCALAR)) < 0) - goto error; + goto error; /* Create dataset */ if((did = H5Dcreate2(fid, DATASET_NAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; /* Create NUM_ATTRS for the dataset */ for(i = 1; i <= NUM_ATTRS; i++) { - sprintf(attrname, "%s%d", ATTR_NAME,i); + HDsprintf(attrname, "%s%d", ATTR_NAME,i); if((attr_id = H5Acreate2(did, attrname, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; if(H5Aclose(attr_id) < 0) - goto error; + 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(H5Sclose(sid) < 0) - goto error; - if(H5Tclose(tid) < 0) - goto error; - if(H5Fclose(fid) < 0) - goto error; - error: H5E_BEGIN_TRY { - H5Pclose(fapl); - H5Pclose(fcpl); - H5Aclose(attr_id); + H5Pclose(fapl); + H5Pclose(fcpl); + H5Aclose(attr_id); H5Dclose(did); H5Tclose(tid); H5Sclose(sid); @@ -145,192 +132,175 @@ error: /* * 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. + * -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. */ static void gen_threshold_file(const char *fname) { - hid_t fid; /* File ID */ - hid_t sid0, sid1, sid2, sid3, sid4; /* Dataspace IDs */ - hid_t did; /* Dataset ID */ - hid_t attr_id; /* Attribute ID */ - hid_t gid; /* 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 = -1; /* File ID */ + hid_t sid0 = -1; /* Dataspace IDs */ + hid_t sid1 = -1; /* Dataspace IDs */ + hid_t sid2 = -1; /* Dataspace IDs */ + hid_t sid3 = -1; /* Dataspace IDs */ + hid_t sid4 = -1; /* Dataspace IDs */ + hid_t did = -1; /* Dataset ID */ + hid_t attr_id = -1; /* Attribute ID */ + hid_t gid = -1; /* 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) - goto error; + goto error; /* Create 1-D dataspace with zero dimension size */ if((sid0 = H5Screate_simple(1, zero_dims, NULL)) < 0) - goto error; + goto error; /* Create 1-D dataspace with non-zero dimension size*/ if((sid1 = H5Screate_simple(1, one_dims, NULL)) < 0) - goto error; + goto error; /* Create 2-D dataspace */ if((sid2 = H5Screate_simple(2, two_dims, NULL)) < 0) - goto error; + goto error; /* Create scalar dataspace */ if((sid3 = H5Screate(H5S_SCALAR)) < 0) - goto error; + goto error; /* Create null dataspace */ if((sid4 = H5Screate(H5S_NULL)) < 0) - goto error; + goto error; /* Create an attribute for the root group */ if((attr_id = H5Acreate2(fid, "attr", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; if(H5Aclose(attr_id) < 0) - goto error; + 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) - goto error; + goto error; /* Create 11 attributes for the dataset */ for(i = 1; i <= (THRES_NUM+1); i++) { - sprintf(name, "%s%d", THRES_ATTR_NAME,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; + goto error; if(H5Aclose(attr_id) < 0) - goto error; + goto error; } if(H5Dclose(did) < 0) - goto error; + 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) - goto error; + goto error; if(H5Dclose(did) < 0) - goto error; + 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) - goto error; + goto error; if(H5Dclose(did) < 0) - goto error; + 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) - goto error; + goto error; /* Create 10 attributes for the 2-D dataset */ for(i = 1; i <= THRES_NUM; i++) { - sprintf(name, "%s%d", THRES_ATTR_NAME,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; + goto error; if(H5Aclose(attr_id) < 0) - goto error; + goto error; } if(H5Dclose(did) < 0) - goto error; + goto error; /* Create first group */ if((gid = H5Gcreate2(fid, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; /* Create an attribute for the group */ if((attr_id = H5Acreate2(gid, "ATTR", H5T_NATIVE_INT, sid3, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; /* Close attribute */ if(H5Aclose(attr_id) < 0) - goto error; + goto error; /* Create 10 1-D datasets with non-zero dimension size for the group */ for(i = 1; i <= THRES_NUM; i++) { - /* set up dataset name */ - sprintf(name, "%s%d", THRES_DSET_NAME,i); + /* set up dataset name */ + 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) - goto error; + /* Create the dataset */ + if((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; - /* Close the dataset */ + /* Close the dataset */ if(H5Dclose(did) < 0) - goto error; + goto error; } /* Close the group */ if(H5Gclose(gid) < 0) - goto error; + goto error; /* Create second group */ if((gid = H5Gcreate2(fid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; /* Create 25 attributes for the group */ for(i = 1; i <= THRES_NUM_25; i++) { - /* Set up attribute name */ - sprintf(name, "%s%d", THRES_ATTR_GRP_NAME,i); + /* Set up attribute name */ + HDsprintf(name, "%s%d", THRES_ATTR_GRP_NAME,i); - /* Create the attribute */ + /* Create the attribute */ if((attr_id = H5Acreate2(gid, name, H5T_NATIVE_INT, sid2, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; - /* Close the attribute */ + /* Close the attribute */ if(H5Aclose(attr_id) < 0) - goto error; + goto error; } /* Close the group */ if(H5Gclose(gid) < 0) - goto error; + goto error; /* Create third group */ if((gid = H5Gcreate2(fid, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; /* Create 9 1-D datasets with non-zero dimension size for the group */ for(i = 1; i < THRES_NUM; i++) { - /* set up dataset name */ - sprintf(name, "%s%d", THRES_DSET_NAME,i); + /* set up dataset name */ + 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) - goto error; + /* Create the dataset */ + if((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; - /* Close the dataset */ + /* Close the dataset */ if(H5Dclose(did) < 0) - goto error; + goto error; } - /* Close the group */ - if(H5Gclose(gid) < 0) - goto error; - - - /* Close dataspaces */ - 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; - - /* Close file */ - if(H5Fclose(fid) < 0) - goto error; - error: H5E_BEGIN_TRY { H5Gclose(gid); - H5Aclose(attr_id); + H5Aclose(attr_id); H5Dclose(did); H5Sclose(sid0); H5Sclose(sid1); @@ -346,84 +316,73 @@ error: * Function: gen_idx_file * * Purpose: Create a file with datasets that use Fixed Array indexing: - * one dataset: fixed dimension, chunked layout, w/o filters - * one dataset: fixed dimension, chunked layout, w/ filters + * one dataset: fixed dimension, chunked layout, w/o filters + * one dataset: fixed dimension, chunked layout, w/ filters * */ -static void +static void gen_idx_file(const char *fname) { - hid_t fapl = -1; /* file access property id */ - hid_t fid = -1; /* file id */ - hid_t sid = -1; /* space id */ - hid_t dcpl = -1; /* dataset creation property id */ - hid_t did = -1, did2 = -1; /* 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 = -1; /* file access property id */ + hid_t fid = -1; /* file id */ + hid_t sid = -1; /* space id */ + hid_t dcpl = -1; /* dataset creation property id */ + hid_t did = -1, did2 = -1; /* 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 */ /* Get a copy of the file access property */ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; + 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) - goto error; + goto error; /* Create file */ if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - goto error; + goto error; /* Create data */ for(i = 0; i < 10; i++) - buf[i] = i; + buf[i] = i; /* Set chunk */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto error; + goto error; if(H5Pset_chunk(dcpl, 1, c_dims) < 0) - goto error; + goto error; /* Create a 1D dataset */ if((sid = H5Screate_simple(1, dims, NULL)) < 0) - goto error; + goto error; if((did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto error; - + goto error; + /* Write to the dataset */ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto error; + goto error; #if defined (H5_HAVE_FILTER_DEFLATE) /* set deflate data */ if(H5Pset_deflate(dcpl, 9) < 0) - goto error; + goto error; /* Create and write the dataset */ if((did2 = H5Dcreate2(fid, DSET_FILTER, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - goto error; + goto error; if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto error; + goto error; /* Close the dataset */ if(H5Dclose(did2) < 0) - goto error; + 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; - error: H5E_BEGIN_TRY { H5Pclose(fapl); @@ -451,7 +410,7 @@ error: * H5O_refcount_decode in the jira issue. * */ -static void +static void gen_err_refcount(const char *fname) { hid_t fid = -1; /* File identifier */ @@ -525,16 +484,13 @@ gen_err_refcount(const char *fname) /* Offset of the message ID to modify is as follows: */ /* 4520: the offset of the object header containing the attribute message with the committed datatype */ - /* 24: the offset in the object header containing the version of the + /* 24: the offset in the object header containing the version of the attribute message */ - 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; + if((fd = HDopen(fname, O_RDWR, 0633)) >= 0) { + HDlseek(fd, 4520+24, SEEK_SET); + HDwrite(fd, &val, 2); + HDclose(fd); + } error: H5E_BEGIN_TRY { @@ -548,8 +504,8 @@ error: } H5E_END_TRY; } /* gen_err_refcount() */ -/* - * The following two test files are generated with older versions +/* + * The following two test files are generated with older versions * of the library for HDFFV-10333. They are used for testing in * testh5stat.sh.in. * @@ -559,7 +515,7 @@ error: * Then a "0" is written to the "dimension" field in the layout * message to trigger the error. * This is to verify HDFFV-10333 that h5stat will exit gracefully - * when encountered error similar to H5O__layout_decode in the + * when encountered error similar to H5O__layout_decode in the * jira issue. * * (2) h5stat_err_old_fill.h5 @@ -568,7 +524,7 @@ error: * Then an illegal size is written to the "size" fild in the * fill value message to trigger the error. * This is to verify HDFFV-10333 that h5stat will exit gracefully - * when encountered error similar to H5O_fill_old_decode in the + * when encountered error similar to H5O_fill_old_decode in the * jira issue. */ diff --git a/tools/test/h5stat/testfiles/h5stat_err1_dims.ddl b/tools/test/h5stat/testfiles/h5stat_err1_dims.err index 86d375b..86d375b 100644 --- a/tools/test/h5stat/testfiles/h5stat_err1_dims.ddl +++ b/tools/test/h5stat/testfiles/h5stat_err1_dims.err diff --git a/tools/test/h5stat/testfiles/h5stat_err1_links.ddl b/tools/test/h5stat/testfiles/h5stat_err1_links.err index d43207c..d43207c 100644 --- a/tools/test/h5stat/testfiles/h5stat_err1_links.ddl +++ b/tools/test/h5stat/testfiles/h5stat_err1_links.err diff --git a/tools/test/h5stat/testfiles/h5stat_err2_numattrs.ddl b/tools/test/h5stat/testfiles/h5stat_err1_numattrs.err index 01b6c18..01b6c18 100644 --- a/tools/test/h5stat/testfiles/h5stat_err2_numattrs.ddl +++ b/tools/test/h5stat/testfiles/h5stat_err1_numattrs.err diff --git a/tools/test/h5stat/testfiles/h5stat_err1_numattrs.ddl b/tools/test/h5stat/testfiles/h5stat_err2_numattrs.err index 01b6c18..01b6c18 100644 --- a/tools/test/h5stat/testfiles/h5stat_err1_numattrs.ddl +++ b/tools/test/h5stat/testfiles/h5stat_err2_numattrs.err diff --git a/tools/test/h5stat/testfiles/h5stat_err_old_fill.ddl b/tools/test/h5stat/testfiles/h5stat_err_old_fill.ddl index e751b7f..5cc1e32 100644 --- a/tools/test/h5stat/testfiles/h5stat_err_old_fill.ddl +++ b/tools/test/h5stat/testfiles/h5stat_err_old_fill.ddl @@ -1,2 +1 @@ Filename: h5stat_err_old_fill.h5 -h5stat error: unable to traverse objects/links in file "h5stat_err_old_fill.h5" diff --git a/tools/test/h5stat/testfiles/h5stat_err_old_fill.err b/tools/test/h5stat/testfiles/h5stat_err_old_fill.err new file mode 100644 index 0000000..8b886d2 --- /dev/null +++ b/tools/test/h5stat/testfiles/h5stat_err_old_fill.err @@ -0,0 +1 @@ +h5stat error: unable to traverse objects/links in file "h5stat_err_old_fill.h5" diff --git a/tools/test/h5stat/testfiles/h5stat_err_old_layout.ddl b/tools/test/h5stat/testfiles/h5stat_err_old_layout.ddl index a3e27e2..112190c 100644 --- a/tools/test/h5stat/testfiles/h5stat_err_old_layout.ddl +++ b/tools/test/h5stat/testfiles/h5stat_err_old_layout.ddl @@ -1,2 +1 @@ Filename: h5stat_err_old_layout.h5 -h5stat error: unable to traverse objects/links in file "h5stat_err_old_layout.h5" diff --git a/tools/test/h5stat/testfiles/h5stat_err_old_layout.err b/tools/test/h5stat/testfiles/h5stat_err_old_layout.err new file mode 100644 index 0000000..7aa2fa7 --- /dev/null +++ b/tools/test/h5stat/testfiles/h5stat_err_old_layout.err @@ -0,0 +1 @@ +h5stat error: unable to traverse objects/links in file "h5stat_err_old_layout.h5" diff --git a/tools/test/h5stat/testfiles/h5stat_err_refcount.ddl b/tools/test/h5stat/testfiles/h5stat_err_refcount.ddl index 1f1b491..41e533e 100644 --- a/tools/test/h5stat/testfiles/h5stat_err_refcount.ddl +++ b/tools/test/h5stat/testfiles/h5stat_err_refcount.ddl @@ -1,2 +1 @@ Filename: h5stat_err_refcount.h5 -h5stat error: unable to traverse objects/links in file "h5stat_err_refcount.h5" diff --git a/tools/test/h5stat/testfiles/h5stat_err_refcount.err b/tools/test/h5stat/testfiles/h5stat_err_refcount.err new file mode 100644 index 0000000..d176996 --- /dev/null +++ b/tools/test/h5stat/testfiles/h5stat_err_refcount.err @@ -0,0 +1 @@ +h5stat error: unable to traverse objects/links in file "h5stat_err_refcount.h5" diff --git a/tools/test/h5stat/testfiles/h5stat_help1.ddl b/tools/test/h5stat/testfiles/h5stat_help1.ddl index 01e39af..2ba7772 100644 --- a/tools/test/h5stat/testfiles/h5stat_help1.ddl +++ b/tools/test/h5stat/testfiles/h5stat_help1.ddl @@ -23,3 +23,13 @@ Usage: h5stat [OPTIONS] file -s, --freespace Print free space information -S, --summary Print summary of file space information --enable-error-stack Prints messages from the HDF5 error stack as they occur + --s3-cred=<cred> Access file on S3, using provided credential + <cred> :: (region,id,key) + If <cred> == "(,,)", no authentication is used. + --hdfs-attrs=<attrs> Access a file on HDFS with given configuration + attributes. + <attrs> :: (<namenode name>,<namenode port>, + <kerberos cache path>,<username>, + <buffer size>) + If an attribute is empty, a default value will be + used. diff --git a/tools/test/h5stat/testfiles/h5stat_help2.ddl b/tools/test/h5stat/testfiles/h5stat_help2.ddl index 01e39af..2ba7772 100644 --- a/tools/test/h5stat/testfiles/h5stat_help2.ddl +++ b/tools/test/h5stat/testfiles/h5stat_help2.ddl @@ -23,3 +23,13 @@ Usage: h5stat [OPTIONS] file -s, --freespace Print free space information -S, --summary Print summary of file space information --enable-error-stack Prints messages from the HDF5 error stack as they occur + --s3-cred=<cred> Access file on S3, using provided credential + <cred> :: (region,id,key) + If <cred> == "(,,)", no authentication is used. + --hdfs-attrs=<attrs> Access a file on HDFS with given configuration + attributes. + <attrs> :: (<namenode name>,<namenode port>, + <kerberos cache path>,<username>, + <buffer size>) + If an attribute is empty, a default value will be + used. diff --git a/tools/test/h5stat/testfiles/h5stat_nofile.ddl b/tools/test/h5stat/testfiles/h5stat_nofile.ddl index 7171320..2ba7772 100644 --- a/tools/test/h5stat/testfiles/h5stat_nofile.ddl +++ b/tools/test/h5stat/testfiles/h5stat_nofile.ddl @@ -23,4 +23,13 @@ Usage: h5stat [OPTIONS] file -s, --freespace Print free space information -S, --summary Print summary of file space information --enable-error-stack Prints messages from the HDF5 error stack as they occur -h5stat error: missing file name + --s3-cred=<cred> Access file on S3, using provided credential + <cred> :: (region,id,key) + If <cred> == "(,,)", no authentication is used. + --hdfs-attrs=<attrs> Access a file on HDFS with given configuration + attributes. + <attrs> :: (<namenode name>,<namenode port>, + <kerberos cache path>,<username>, + <buffer size>) + If an attribute is empty, a default value will be + used. diff --git a/tools/test/h5stat/testfiles/h5stat_nofile.err b/tools/test/h5stat/testfiles/h5stat_nofile.err new file mode 100644 index 0000000..3b7e979 --- /dev/null +++ b/tools/test/h5stat/testfiles/h5stat_nofile.err @@ -0,0 +1 @@ +h5stat error: missing file name diff --git a/tools/test/h5stat/testfiles/h5stat_notexist.ddl b/tools/test/h5stat/testfiles/h5stat_notexist.ddl index cc25e43..7f71941 100644 --- a/tools/test/h5stat/testfiles/h5stat_notexist.ddl +++ b/tools/test/h5stat/testfiles/h5stat_notexist.ddl @@ -1,2 +1 @@ Filename: notexist.h5 -h5stat error: unable to open file "notexist.h5" diff --git a/tools/test/h5stat/testfiles/h5stat_notexist.err b/tools/test/h5stat/testfiles/h5stat_notexist.err new file mode 100644 index 0000000..c1d9e54 --- /dev/null +++ b/tools/test/h5stat/testfiles/h5stat_notexist.err @@ -0,0 +1 @@ +h5stat error: unable to open file "notexist.h5" diff --git a/tools/test/h5stat/testh5stat.sh.in b/tools/test/h5stat/testh5stat.sh.in index 0a5127f..69b856e 100644 --- a/tools/test/h5stat/testh5stat.sh.in +++ b/tools/test/h5stat/testh5stat.sh.in @@ -79,6 +79,18 @@ $SRC_H5STAT_TESTFILES/h5stat_idx.h5 $SRC_H5STAT_TESTFILES/h5stat_threshold.h5 " +LIST_ERR_TEST_FILES=" +$SRC_H5STAT_TESTFILES/h5stat_err_refcount.err +$SRC_H5STAT_TESTFILES/h5stat_err_old_layout.err +$SRC_H5STAT_TESTFILES/h5stat_err_old_fill.err +$SRC_H5STAT_TESTFILES/h5stat_err1_links.err +$SRC_H5STAT_TESTFILES/h5stat_err1_dims.err +$SRC_H5STAT_TESTFILES/h5stat_err1_numattrs.err +$SRC_H5STAT_TESTFILES/h5stat_err2_numattrs.err +$SRC_H5STAT_TESTFILES/h5stat_notexist.err +$SRC_H5STAT_TESTFILES/h5stat_nofile.err +" + LIST_OTHER_TEST_FILES=" $SRC_H5STAT_TESTFILES/h5stat_err_refcount.ddl $SRC_H5STAT_TESTFILES/h5stat_err_old_layout.ddl @@ -100,17 +112,13 @@ $SRC_H5STAT_TESTFILES/h5stat_newgrat.ddl $SRC_H5STAT_TESTFILES/h5stat_newgrat-UG.ddl $SRC_H5STAT_TESTFILES/h5stat_newgrat-UA.ddl $SRC_H5STAT_TESTFILES/h5stat_idx.ddl -$SRC_H5STAT_TESTFILES/h5stat_err1_links.ddl $SRC_H5STAT_TESTFILES/h5stat_links1.ddl $SRC_H5STAT_TESTFILES/h5stat_links2.ddl $SRC_H5STAT_TESTFILES/h5stat_links3.ddl $SRC_H5STAT_TESTFILES/h5stat_links4.ddl $SRC_H5STAT_TESTFILES/h5stat_links5.ddl -$SRC_H5STAT_TESTFILES/h5stat_err1_dims.ddl $SRC_H5STAT_TESTFILES/h5stat_dims1.ddl $SRC_H5STAT_TESTFILES/h5stat_dims2.ddl -$SRC_H5STAT_TESTFILES/h5stat_err1_numattrs.ddl -$SRC_H5STAT_TESTFILES/h5stat_err2_numattrs.ddl $SRC_H5STAT_TESTFILES/h5stat_numattrs1.ddl $SRC_H5STAT_TESTFILES/h5stat_numattrs2.ddl $SRC_H5STAT_TESTFILES/h5stat_numattrs3.ddl @@ -120,7 +128,7 @@ $SRC_H5STAT_TESTFILES/h5stat_numattrs4.ddl # # copy test files and expected output files from source dirs to test dir # -COPY_TESTFILES="$LIST_HDF5_TEST_FILES $LIST_OTHER_TEST_FILES" +COPY_TESTFILES="$LIST_HDF5_TEST_FILES $LIST_ERR_TEST_FILES $LIST_OTHER_TEST_FILES" COPY_TESTFILES_TO_TESTDIR() { @@ -184,8 +192,9 @@ TESTING() { # TOOLTEST() { expect="$TESTDIR/$1" + expect_err="$TESTDIR/`basename $1 .ddl`.err" actual="$TESTDIR/`basename $1 .ddl`.out" - actual_err="$TESTDIR/`basename $1 .ddl`.err" + actual_err="$TESTDIR/`basename $1 .ddl`.out.err" actual_sav=${actual}-sav actual_err_sav=${actual_err}-sav shift @@ -202,14 +211,17 @@ TOOLTEST() { STDOUT_FILTER $actual cp $actual_err $actual_err_sav STDERR_FILTER $actual_err - cat $actual_err >> $actual if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.ddl) missing" - nerrors="`expr $nerrors + 1`" + # Compare error files if the expect file doesn't exist. + if $CMP $expect_err $actual_err; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected result (*.err) differs from actual result (*.out.err)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect_err $actual_err |sed 's/^/ /' + fi elif $CMP $expect $actual; then echo " PASSED" else |