diff options
author | Vailin Choi <vchoi@jam.ad.hdfgroup.org> | 2018-03-12 04:13:43 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@jam.ad.hdfgroup.org> | 2018-03-12 04:13:43 (GMT) |
commit | d1d91213d0813aed366b2d66a9c031c319070f18 (patch) | |
tree | 934e61bd9a893bca75ce82ae16bf4e8dbd53a5a2 | |
parent | 83de2a580b1b6a67e604ae8336eb078741b4d7db (diff) | |
parent | a5d95ec0832d8b24e44277b3bdb90b21ea16ff2d (diff) | |
download | hdf5-d1d91213d0813aed366b2d66a9c031c319070f18.zip hdf5-d1d91213d0813aed366b2d66a9c031c319070f18.tar.gz hdf5-d1d91213d0813aed366b2d66a9c031c319070f18.tar.bz2 |
Merge branch 'hdf5_1_10_merge' of https://bitbucket.hdfgroup.org/scm/~vchoi/my_hdf5_fork into hdf5_1_10_merge
-rw-r--r-- | CMakeInstallation.cmake | 18 | ||||
-rw-r--r-- | MANIFEST | 3 | ||||
-rw-r--r-- | c++/src/CMakeLists.txt | 47 | ||||
-rwxr-xr-x | config/cmake/libh5cc.in | 32 | ||||
-rwxr-xr-x | config/cmake/libhdf5.pc.in | 14 | ||||
-rw-r--r-- | hl/c++/src/CMakeLists.txt | 47 | ||||
-rw-r--r-- | hl/src/CMakeLists.txt | 46 | ||||
-rw-r--r-- | release_docs/RELEASE.txt | 16 | ||||
-rw-r--r-- | src/CMakeLists.txt | 48 | ||||
-rw-r--r-- | src/H5Fquery.c | 8 | ||||
-rw-r--r-- | src/H5Olayout.c | 42 | ||||
-rw-r--r-- | test/dsets.c | 8 | ||||
-rw-r--r-- | test/dtypes.c | 681 | ||||
-rw-r--r-- | test/objcopy.c | 4 | ||||
-rw-r--r-- | test/th5s.c | 17 | ||||
-rw-r--r-- | tools/test/h5repack/CMakeTests.cmake | 69 | ||||
-rw-r--r-- | tools/test/h5repack/h5repack.sh.in | 98 | ||||
-rw-r--r-- | tools/test/h5repack/testfiles/bounds_latest_latest.h5 | bin | 0 -> 82048 bytes |
18 files changed, 1025 insertions, 173 deletions
diff --git a/CMakeInstallation.cmake b/CMakeInstallation.cmake index 0bfb2cc..4a09d2d 100644 --- a/CMakeInstallation.cmake +++ b/CMakeInstallation.cmake @@ -144,24 +144,6 @@ install ( ) #----------------------------------------------------------------------------- -# Create pkgconfig files -#----------------------------------------------------------------------------- -#foreach (libs ${LINK_LIBS}) -# set (LIBS "${LIBS} -l${libs}") -#endforeach () -#foreach (libs ${HDF5_LIBRARIES_TO_EXPORT}) -# set (HDF5LIBS "${HDF5LIBS} -l${libs}") -#endforeach () -#configure_file ( -# ${HDF_RESOURCES_DIR}/libhdf5.pc.in -# ${HDF5_BINARY_DIR}/CMakeFiles/libhdf5.pc @ONLY -#) -#install ( -# FILES ${HDF5_BINARY_DIR}/CMakeFiles/libhdf5.pc -# DESTINATION ${HDF5_INSTALL_LIB_DIR}/pkgconfig -#) - -#----------------------------------------------------------------------------- # Configure the HDF518_Examples.cmake file and the examples #----------------------------------------------------------------------------- option (HDF5_PACK_EXAMPLES "Package the HDF5 Library Examples Compressed File" OFF) @@ -2441,6 +2441,7 @@ #test files for h5repack ./tools/test/h5repack/testfiles/README +./tools/test/h5repack/testfiles/bounds_latest_latest.h5 ./tools/test/h5repack/testfiles/h5repack_aggr.h5 ./tools/test/h5repack/testfiles/h5repack_attr.h5 ./tools/test/h5repack/testfiles/h5repack_attr_refs.h5 @@ -3083,6 +3084,8 @@ ./config/cmake/HDF5Macros.cmake ./config/cmake/HDF5UseFortran.cmake ./config/cmake/jrunTest.cmake +./config/cmake/libh5cc.in +./config/cmake/libhdf5.pc.in ./config/cmake/libhdf5.settings.cmake.in ./config/cmake/mccacheinit.cmake ./config/cmake/patch.xml diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt index 921497f..350bdf7 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -139,3 +139,50 @@ if (HDF5_EXPORTED_TARGETS) INCLUDES DESTINATION include ) endif () + +#----------------------------------------------------------------------------- +# Create pkgconfig files +#----------------------------------------------------------------------------- +set (_PKG_CONFIG_PREFIX ${CMAKE_INSTALL_PREFIX}) +set (_PKG_CONFIG_EXEC_PREFIX \${prefix}) +set (_PKG_CONFIG_LIBDIR \${exec_prefix}/lib) +set (_PKG_CONFIG_INCLUDEDIR \${prefix}/include) +set (_PKG_CONFIG_LIBNAME "${HDF5_CPP_LIB_CORENAME}") +set (_PKG_CONFIG_VERSION "${HDF5_PACKAGE_VERSION}") + +set (_PKG_CONFIG_LIBS_PRIVATE) + +set (_PKG_CONFIG_LIBS "${_PKG_CONFIG_LIBS} -l${HDF5_CPP_LIB_CORENAME}") +if (BUILD_SHARED_LIBS) + set (_PKG_CONFIG_SH_LIBS "${_PKG_CONFIG_SH_LIBS} -l${HDF5_CPP_LIB_CORENAME}") +endif () + +set (_PKG_CONFIG_REQUIRES "${HDF5_LIB_CORENAME}") +set (_PKG_CONFIG_REQUIRES_PRIVATE "${HDF5_LIB_CORENAME}") + +configure_file ( + ${HDF_RESOURCES_DIR}/libhdf5.pc.in + ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_CPP_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}.pc + @ONLY +) +install ( + FILES ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_CPP_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}.pc + DESTINATION ${HDF5_INSTALL_LIB_DIR}/pkgconfig + COMPONENT cpplibraries +) + +if (NOT WIN32) + set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER}) + configure_file ( + ${HDF_RESOURCES_DIR}/libh5cc.in + ${HDF5_BINARY_DIR}/CMakeFiles/h5c++ + @ONLY + ) + install ( + FILES ${HDF5_BINARY_DIR}/CMakeFiles/h5c++ + DESTINATION ${HDF5_INSTALL_BIN_DIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + COMPONENT cpplibraries + ) +endif () + diff --git a/config/cmake/libh5cc.in b/config/cmake/libh5cc.in new file mode 100755 index 0000000..f462d56 --- /dev/null +++ b/config/cmake/libh5cc.in @@ -0,0 +1,32 @@ +#! /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 COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +## + +prg=$0 +if [ ! -e "$prg" ]; then + case $prg in + (*/*) exit 1;; + (*) prg=$(command -v -- "$prg") || exit;; + esac +fi +dir=$( + cd -P -- "$(dirname -- "$prg")/.." && pwd -P +) || exit +prg=$dir/$(basename -- "$prg") || exit + +printf '%s\n' "$prg" +printf 'dir is %s\n' "$dir" + +export PKG_CONFIG_PATH=$dir/lib/pkgconfig + +@_PKG_CONFIG_COMPILER@ `pkg-config --define-variable=prefix=$dir --cflags --libs @_PKG_CONFIG_LIBNAME@-@_PKG_CONFIG_VERSION@` $@ diff --git a/config/cmake/libhdf5.pc.in b/config/cmake/libhdf5.pc.in new file mode 100755 index 0000000..4a2ebaa --- /dev/null +++ b/config/cmake/libhdf5.pc.in @@ -0,0 +1,14 @@ +prefix=@_PKG_CONFIG_PREFIX@ +exec_prefix=@_PKG_CONFIG_EXEC_PREFIX@ +libdir=@_PKG_CONFIG_LIBDIR@ +includedir=@_PKG_CONFIG_INCLUDEDIR@ + +Name: @_PKG_CONFIG_LIBNAME@ +Description: HDF5 (Hierarchical Data Format 5) Software Library +Version: @_PKG_CONFIG_VERSION@ + +Cflags: -I${includedir} +Libs: -L${libdir} @_PKG_CONFIG_SH_LIBS@ +Requires: @_PKG_CONFIG_REQUIRES@ +Libs.private: @_PKG_CONFIG_LIBS_PRIVATE@ @_PKG_CONFIG_LIBS@ +Requires.private: @_PKG_CONFIG_REQUIRES_PRIVATE@ diff --git a/hl/c++/src/CMakeLists.txt b/hl/c++/src/CMakeLists.txt index 0f187c5..28f860f 100644 --- a/hl/c++/src/CMakeLists.txt +++ b/hl/c++/src/CMakeLists.txt @@ -69,3 +69,50 @@ if (HDF5_EXPORTED_TARGETS) INCLUDES DESTINATION include ) endif () + +#----------------------------------------------------------------------------- +# Create pkgconfig files +#----------------------------------------------------------------------------- +set (_PKG_CONFIG_PREFIX ${CMAKE_INSTALL_PREFIX}) +set (_PKG_CONFIG_EXEC_PREFIX \${prefix}) +set (_PKG_CONFIG_LIBDIR \${exec_prefix}/lib) +set (_PKG_CONFIG_INCLUDEDIR \${prefix}/include) +set (_PKG_CONFIG_LIBNAME "${HDF5_HL_CPP_LIB_CORENAME}") +set (_PKG_CONFIG_VERSION "${HDF5_PACKAGE_VERSION}") + +set (_PKG_CONFIG_LIBS_PRIVATE) + +set (_PKG_CONFIG_LIBS "${_PKG_CONFIG_LIBS} -l${HDF5_HL_CPP_LIB_CORENAME}") +if (BUILD_SHARED_LIBS) + set (_PKG_CONFIG_SH_LIBS "${_PKG_CONFIG_SH_LIBS} -l${HDF5_HL_CPP_LIB_CORENAME}") +endif () + +set (_PKG_CONFIG_REQUIRES "${HDF5_HL_LIB_CORENAME}") +set (_PKG_CONFIG_REQUIRES_PRIVATE "${HDF5_HL_LIB_CORENAME}") + +configure_file ( + ${HDF_RESOURCES_DIR}/libhdf5.pc.in + ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_HL_CPP_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}.pc + @ONLY +) +install ( + FILES ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_HL_CPP_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}.pc + DESTINATION ${HDF5_INSTALL_LIB_DIR}/pkgconfig + COMPONENT hlcpplibraries +) + +if (NOT WIN32) + set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER}) + configure_file ( + ${HDF_RESOURCES_DIR}/libh5cc.in + ${HDF5_BINARY_DIR}/CMakeFiles/h5hlc++ + @ONLY + ) + install ( + FILES ${HDF5_BINARY_DIR}/CMakeFiles/h5hlc++ + DESTINATION ${HDF5_INSTALL_BIN_DIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + COMPONENT hlcpplibraries + ) +endif () + diff --git a/hl/src/CMakeLists.txt b/hl/src/CMakeLists.txt index d21a3ea..62e8c21 100644 --- a/hl/src/CMakeLists.txt +++ b/hl/src/CMakeLists.txt @@ -88,3 +88,49 @@ if (HDF5_EXPORTED_TARGETS) INCLUDES DESTINATION include ) endif () + +#----------------------------------------------------------------------------- +# Create pkgconfig files +#----------------------------------------------------------------------------- +set (_PKG_CONFIG_PREFIX ${CMAKE_INSTALL_PREFIX}) +set (_PKG_CONFIG_EXEC_PREFIX \${prefix}) +set (_PKG_CONFIG_LIBDIR \${exec_prefix}/lib) +set (_PKG_CONFIG_INCLUDEDIR \${prefix}/include) +set (_PKG_CONFIG_LIBNAME "${HDF5_HL_LIB_CORENAME}") +set (_PKG_CONFIG_VERSION "${HDF5_PACKAGE_VERSION}") + +set (_PKG_CONFIG_LIBS_PRIVATE) + +set (_PKG_CONFIG_LIBS "${_PKG_CONFIG_LIBS} -l${HDF5_HL_LIB_CORENAME}") +if (BUILD_SHARED_LIBS) + set (_PKG_CONFIG_SH_LIBS "${_PKG_CONFIG_SH_LIBS} -l${HDF5_HL_LIB_CORENAME}") +endif () + +set (_PKG_CONFIG_REQUIRES "${HDF5_LIB_CORENAME}") +set (_PKG_CONFIG_REQUIRES_PRIVATE "${HDF5_LIB_CORENAME}") + +configure_file ( + ${HDF_RESOURCES_DIR}/libhdf5.pc.in + ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_HL_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}.pc + @ONLY +) +install ( + FILES ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_HL_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}.pc + DESTINATION ${HDF5_INSTALL_LIB_DIR}/pkgconfig + COMPONENT hllibraries +) + +if (NOT WIN32) + set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER}) + configure_file ( + ${HDF_RESOURCES_DIR}/libh5cc.in + ${HDF5_BINARY_DIR}/CMakeFiles/h5chl + @ONLY + ) + install ( + FILES ${HDF5_BINARY_DIR}/CMakeFiles/h5chl + DESTINATION ${HDF5_INSTALL_BIN_DIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + COMPONENT hllibraries + ) +endif () diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 4644bcb..740edf5 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -56,6 +56,16 @@ New Features ------------- - CMake + Add pkg-config file generation + + Added pkg-config file generation for the C, C++, HL, and HL C++ libraries. + In addition, builds on linux will create h5cXXX scripts that use the pkg-config + files. This is a limited implementation of a script like autotools h5cc. + + (ADB - 2018/03/08, HDFFV-4359) + + - CMake + Refactor use of CMAKE_BUILD_TYPE for new variable, which understands the type of generator in use. @@ -298,6 +308,12 @@ Bug Fixes since HDF5-1.10.1 release parallel library. (ADB - 2018/03/6, HDFFV-10414) + - Utility function can not handle lowercase Windows drive letters + + Added call to toupper function for drive letter. + + (ADB - 2017/12/18, HDFFV-10307) + - filter plugin handling in H5PL.c and H5Z.c It was discovered that the dynamic loading process used by diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bf7fb07..d10870d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -991,3 +991,51 @@ if (HDF5_EXPORTED_TARGETS) INCLUDES DESTINATION include ) endif () + +#----------------------------------------------------------------------------- +# Create pkgconfig files +#----------------------------------------------------------------------------- +set (_PKG_CONFIG_PREFIX ${CMAKE_INSTALL_PREFIX}) +set (_PKG_CONFIG_EXEC_PREFIX \${prefix}) +set (_PKG_CONFIG_LIBDIR \${exec_prefix}/lib) +set (_PKG_CONFIG_INCLUDEDIR \${prefix}/include) +set (_PKG_CONFIG_LIBNAME "${HDF5_LIB_CORENAME}") +set (_PKG_CONFIG_VERSION "${HDF5_PACKAGE_VERSION}") + +foreach (libs ${LINK_LIBS} ${LINK_COMP_LIBS}) + set (_PKG_CONFIG_LIBS_PRIVATE "${_PKG_CONFIG_LIBS_PRIVATE} -l${libs}") +endforeach () + +set (_PKG_CONFIG_LIBS "${_PKG_CONFIG_LIBS} -l${HDF5_LIB_CORENAME}") +if (BUILD_SHARED_LIBS) + set (_PKG_CONFIG_SH_LIBS "${_PKG_CONFIG_SH_LIBS} -l${HDF5_LIB_CORENAME}") +endif () + +set (_PKG_CONFIG_REQUIRES) +set (_PKG_CONFIG_REQUIRES_PRIVATE) + +configure_file ( + ${HDF_RESOURCES_DIR}/libhdf5.pc.in + ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}.pc + @ONLY +) +install ( + FILES ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}.pc + DESTINATION ${HDF5_INSTALL_LIB_DIR}/pkgconfig + COMPONENT libraries +) + +if (NOT WIN32) + set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER}) + configure_file ( + ${HDF_RESOURCES_DIR}/libh5cc.in + ${HDF5_BINARY_DIR}/CMakeFiles/h5cc + @ONLY + ) + install ( + FILES ${HDF5_BINARY_DIR}/CMakeFiles/h5cc + DESTINATION ${HDF5_INSTALL_BIN_DIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + COMPONENT libraries + ) +endif () diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 6f4febc..f7e222e 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -740,12 +740,12 @@ H5F_gc_ref(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_fc_degree + * Function: H5F_get_fc_degree * - * Purpose: Retrieve the 'file close degree' for the file. + * Purpose: Retrieve the 'file close degree' for the file. * - * Return: Success: Non-negative, the 'file close degree' - * Failure: (can't happen) + * Return: Success: Non-negative, the 'file close degree' + * Failure: (can't happen) *------------------------------------------------------------------------- */ H5F_close_degree_t diff --git a/src/H5Olayout.c b/src/H5Olayout.c index 0994ef8..2c4c4ce 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -47,6 +47,8 @@ static herr_t H5O__layout_reset(void *_mesg); static herr_t H5O__layout_free(void *_mesg); static herr_t H5O__layout_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg); +static herr_t H5O__layout_pre_copy_file(H5F_t *file_src, const void *mesg_src, + hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata); static void *H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, hbool_t *recompute_size, unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata, hid_t dxpl_id); @@ -69,7 +71,7 @@ const H5O_msg_class_t H5O_MSG_LAYOUT[1] = {{ NULL, /* link method */ NULL, /* set share method */ NULL, /* can share method */ - NULL, /* pre copy native value to file */ + H5O__layout_pre_copy_file, /* pre copy native value to file */ H5O__layout_copy_file, /* copy native value to file */ NULL, /* post copy native value to file */ NULL, /* get creation index */ @@ -99,7 +101,7 @@ H5FL_DEFINE(H5O_layout_t); */ static void * H5O__layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *open_oh, - unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, + unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { H5O_layout_t *mesg = NULL; @@ -1057,6 +1059,42 @@ done: /*------------------------------------------------------------------------- + * Function: H5O__layout_pre_copy_file + * + * Purpose: Perform any necessary actions before copying message between + * files. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Vailin Choi; Dec 2017 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O__layout_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, + hbool_t H5_ATTR_UNUSED *deleted, const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata) +{ + const H5O_layout_t *layout_src = (const H5O_layout_t *)mesg_src; /* Source layout */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* check args */ + HDassert(cpy_info); + HDassert(cpy_info->file_dst); + + /* Check to ensure that the version of the message to be copied does not exceed + the message version allowed by the destination file's high bound */ + if(layout_src->version > H5O_layout_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)]) + HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "layout message version out of bounds") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O__layout_pre_copy_file() */ + + +/*------------------------------------------------------------------------- * Function: H5O__layout_copy_file * * Purpose: Copies a message from _MESG to _DEST in file diff --git a/test/dsets.c b/test/dsets.c index 17cf23c..0788bc8 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -750,10 +750,10 @@ test_compact_io(hid_t fapl) hsize_t dims[2]; int wbuf[16][8], rbuf[16][8]; char filename[FILENAME_BUF_SIZE]; - H5F_libver_t low, high; /* File format bounds */ - H5F_t *fp; /* Internal file pointer */ - H5D_t *dsetp; /* Internal dataset pointer */ - int i, j, n; + H5F_libver_t low, high; /* File format bounds */ + H5F_t *fp; /* Internal file pointer */ + H5D_t *dsetp; /* Internal dataset pointer */ + int i, j, n; /* Indices */ herr_t ret; /* Generic return value */ TESTING("compact dataset I/O"); diff --git a/test/dtypes.c b/test/dtypes.c index 7e8047d..1a27634 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -18,7 +18,7 @@ * Purpose: Tests the datatype interface (H5T) */ -#include "h5test.h" +#include "testhdf5.h" #include "H5srcdir.h" #include "H5Iprivate.h" /* For checking that datatype id's don't leak */ @@ -46,6 +46,16 @@ #define H5T_FRIEND /*suppress error about including H5Tpkg */ #include "H5Tpkg.h" #endif + +/* Use in version bound test */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_TESTING +#include "H5Fpkg.h" /* File access */ + +/* Use in version bound test */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#include "H5Opkg.h" /* Object headers */ + #define SET_ALIGNMENT(TYPE,VAL) \ H5T_NATIVE_##TYPE##_ALIGN_g=MAX(H5T_NATIVE_##TYPE##_ALIGN_g, VAL) @@ -92,7 +102,15 @@ typedef enum dtype_t { INT_SCHAR, INT_UCHAR, INT_SHORT, INT_USHORT, INT_INT, INT_UINT, INT_LONG, INT_ULONG, INT_LLONG, INT_ULLONG, FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, OTHER -} dtype_t; +} dtype_t; /* This doesn't seem to be used anywhere... -BMR */ + +typedef enum { + E1_RED, + E1_GREEN, + E1_BLUE, + E1_ORANGE, + E1_YELLOW +} color_t; /* Constant for size of conversion buffer for int <-> float exception test */ #define CONVERT_SIZE 4 @@ -1678,7 +1696,7 @@ test_compound_9(void) { typedef struct cmpd_struct { int i1; - char* str; + const char* str; int i2; } cmpd_struct; @@ -2526,7 +2544,7 @@ test_compound_14(void) typedef struct cmpd_struct_1 { char c1; char c2; - char* str; + const char* str; } cmpd_struct_1; typedef struct cmpd_struct_2 { @@ -3299,7 +3317,7 @@ test_compound_18(void) /* Create compound datatype, but don't insert fields */ tid = H5Tcreate(H5T_COMPOUND, (size_t)8); - assert(tid > 0); + HDassert(tid > 0); /* Attempt to create file with compound datatype that has no fields */ /* Create File */ @@ -3308,7 +3326,7 @@ test_compound_18(void) /* Create a dataspace to use */ sid = H5Screate_simple(1, &dim, NULL); - assert(sid > 0); + HDassert(sid > 0); /* Create a dataset with the bad compound datatype */ H5E_BEGIN_TRY { @@ -3321,7 +3339,7 @@ test_compound_18(void) /* Create a group */ gid = H5Gcreate2(file, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - assert(gid > 0); + HDassert(gid > 0); /* Create an attribute with the bad compound datatype */ H5E_BEGIN_TRY { @@ -4672,7 +4690,7 @@ test_conv_enum_2(void) /* Destination enum type */ dsttype = H5Tenum_create(H5T_NATIVE_INT); - assert(H5Tget_size(dsttype) > H5Tget_size(srctype)); + HDassert(H5Tget_size(dsttype) > H5Tget_size(srctype)); for (i=0; i<8; i++) H5Tenum_insert(dsttype, mname[i], &i); @@ -6682,7 +6700,7 @@ error: } /* end test_named_indirect_reopen() */ static void create_del_obj_named_test_file(const char *filename, hid_t fapl, - hbool_t new_format) + H5F_libver_t low, H5F_libver_t high) { hid_t file; /* File ID */ hid_t type; /* Datatype ID */ @@ -6692,93 +6710,97 @@ static void create_del_obj_named_test_file(const char *filename, hid_t fapl, hid_t fcpl; /* File creation property list ID */ hid_t my_fapl; /* Copy of file access property list ID */ hid_t dcpl; /* Dataset creation property list ID */ + unsigned use_at_least_v18;/* Whether to use old or new format */ herr_t status; /* Generic return value */ /* Make copy of FAPL */ my_fapl = H5Pcopy(fapl); - assert(my_fapl > 0); + HDassert(my_fapl > 0); - if(new_format) { - /* Use latest version of file format */ - status = H5Pset_libver_bounds(my_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); - assert(status >= 0); - } /* end if */ + /* Use low/high version of file format */ + status = H5Pset_libver_bounds(my_fapl, low, high); + HDassert(status >= 0); + + /* Set new format flag. Note: the case high < low should be caught in the caller */ + use_at_least_v18 = 0; + if (low >= H5F_LIBVER_V18) + use_at_least_v18 = 1; /* Create a file creation property list (used for the root group's creation property list) */ fcpl = H5Pcreate(H5P_FILE_CREATE); - assert(fcpl > 0); + HDassert(fcpl > 0); - if(new_format) { + if(use_at_least_v18) { /* Use dense link storage for all links in root group */ status = H5Pset_link_phase_change(fcpl, 0, 0); - assert(status >= 0); + HDassert(status >= 0); } /* end if */ /* Create file with attribute that uses committed datatype */ file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, my_fapl); - assert(file > 0); + HDassert(file > 0); /* Close FCPL */ status = H5Pclose(fcpl); - assert(status >= 0); + HDassert(status >= 0); /* Close FAPL */ status = H5Pclose(my_fapl); - assert(status >= 0); + HDassert(status >= 0); /* Create datatype to commit */ type = H5Tvlen_create(H5T_NATIVE_INT); - assert(type > 0); + HDassert(type > 0); /* Commit datatype */ status = H5Tcommit2(file, DEL_OBJ_NAMED_NAMED_DTYPE, type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - assert(status >= 0); + HDassert(status >= 0); /* Create scalar dataspace */ space = H5Screate(H5S_SCALAR); - assert(space > 0); + HDassert(space > 0); /* Create a dataset creation property list */ dcpl = H5Pcreate(H5P_DATASET_CREATE); - assert(dcpl > 0); + HDassert(dcpl > 0); - if(new_format) { + if(use_at_least_v18) { /* Use dense attribute storage for all attributes on dataset */ status = H5Pset_attr_phase_change(dcpl, 0, 0); - assert(status >= 0); + HDassert(status >= 0); } /* end if */ /* Create dataset */ dset = H5Dcreate2(file, DEL_OBJ_NAMED_DATASET, type, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - assert(dset > 0); + HDassert(dset > 0); /* Close DCPL */ status = H5Pclose(dcpl); - assert(status >= 0); + HDassert(status >= 0); /* Close dataset */ status = H5Dclose(dset); - assert(status >= 0); + HDassert(status >= 0); /* Create attribute */ attr = H5Acreate_by_name(file, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - assert(attr > 0); + HDassert(attr > 0); /* Close dataspace */ status = H5Sclose(space); - assert(status >= 0); + HDassert(status >= 0); /* Close datatype */ status = H5Tclose(type); - assert(status >= 0); + HDassert(status >= 0); /* Close attribute */ status = H5Aclose(attr); - assert(status >= 0); + HDassert(status >= 0); /* Close file */ status = H5Fclose(file); - assert(status >= 0); + HDassert(status >= 0); } /* end create_del_obj_named_test_file() */ @@ -6803,7 +6825,7 @@ test_delete_obj_named(hid_t fapl) hid_t attr = -1; /* Attribute ID */ hid_t dset = -1; /* Dataset ID */ hid_t fapl2 = -1; /* File access property list ID */ - unsigned new_format; /* Whether to use old or new format */ + H5F_libver_t low, high; /* File format bounds */ char filename[1024], filename2[1024]; TESTING("deleting objects that use named datatypes"); @@ -6813,47 +6835,54 @@ test_delete_obj_named(hid_t fapl) h5_fixname(FILENAME[8], fapl, filename, sizeof filename); h5_fixname(FILENAME[9], fapl2, filename2, sizeof filename2); - /* Loop over old & new format files */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { - /* Create test file, with attribute that uses committed datatype */ - create_del_obj_named_test_file(filename, fapl, new_format); + /* Loop through all valid the combinations of low/high library format bounds, + to test delete objects that use named datatypes through different file IDs */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { -/* Test deleting dataset opened through different file ID */ - if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + /* Skip invalid low/high combination */ + if ((high == H5F_LIBVER_EARLIEST) || (low > high)) + continue; - if((dset = H5Dopen2(filea1, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR + /* Create test file, with attribute that uses committed datatype */ + create_del_obj_named_test_file(filename, fapl, low, high); - if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR + /* Test deleting dataset opened through different file ID */ + if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR + if((dset = H5Dopen2(filea1, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - if(H5Ldelete(filea2, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR - if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR - if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR + if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR + if(H5Ldelete(filea2, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT) < 0) FAIL_STACK_ERROR - /* Create test file, with attribute that uses committed datatype */ - create_del_obj_named_test_file(filename, fapl, new_format); + if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR + if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR -/* Test deleting attribute opened through different file ID */ - if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + /* Create test file, with attribute that uses committed datatype */ + create_del_obj_named_test_file(filename, fapl, low, high); - if((attr = H5Aopen_by_name(filea1, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Aclose(attr) < 0) FAIL_STACK_ERROR + /* Test deleting attribute opened through different file ID */ + if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR + if((attr = H5Aopen_by_name(filea1, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Aclose(attr) < 0) FAIL_STACK_ERROR - if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR + if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR - if(H5Adelete_by_name(filea2, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR - if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR - if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR - } /* end for */ + if(H5Adelete_by_name(filea2, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + + if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR + if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR + } /* end high */ + } /* end low */ if(H5Pclose(fapl2) < 0) FAIL_STACK_ERROR @@ -6898,7 +6927,7 @@ test_delete_obj_named_fileid(hid_t fapl) hid_t attr = -1; /* Attribute ID */ hid_t dset = -1; /* Dataset ID */ hid_t fapl2 = -1; /* File access property list ID */ - unsigned new_format; /* Whether to use old or new format */ + H5F_libver_t low, high; /* File format bounds */ char filename[1024], filename2[1024]; TESTING("deleting objects that use named datatypes"); @@ -6908,108 +6937,115 @@ test_delete_obj_named_fileid(hid_t fapl) h5_fixname(FILENAME[8], fapl, filename, sizeof filename); h5_fixname(FILENAME[9], fapl2, filename2, sizeof filename2); - /* Loop over old & new format files */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { - /* Create test file, with attribute that uses committed datatype */ - create_del_obj_named_test_file(filename, fapl, new_format); + /* Loop through all the combinations of low/high library format bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { -/* Test getting file ID for dataset opened through different file ID */ - if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + /* Skip invalid low/high combination */ + if ((high == H5F_LIBVER_EARLIEST) || (low > high)) + continue; - if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + /* Create test file, with attribute that uses committed datatype */ + create_del_obj_named_test_file(filename, fapl, low, high); - if((dset = H5Dopen2(filea1, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + /* Test getting file ID for dataset opened through different file ID */ + if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - /* Verify file ID from dataset matches correct file */ - dset_fid = H5Iget_file_id(dset); - if(dset_fid != filea1) TEST_ERROR - H5Fclose(dset_fid); + if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - /* Verify file ID from datatype (from dataset) matches correct file */ - type = H5Dget_type(dset); - type_fid = H5Iget_file_id(type); - if(type_fid != filea1) TEST_ERROR - H5Fclose(type_fid); - H5Tclose(type); + if((dset = H5Dopen2(filea1, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR + /* Verify file ID from dataset matches correct file */ + dset_fid = H5Iget_file_id(dset); + if(dset_fid != filea1) TEST_ERROR + H5Fclose(dset_fid); - if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR + /* Verify file ID from datatype (from dataset) matches correct file */ + type = H5Dget_type(dset); + type_fid = H5Iget_file_id(type); + if(type_fid != filea1) TEST_ERROR + H5Fclose(type_fid); + H5Tclose(type); - if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR + if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR - if((dset = H5Dopen2(filea1, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR - /* Verify file ID from dataset matches correct file */ - dset_fid = H5Iget_file_id(dset); - if(dset_fid != filea1) TEST_ERROR - H5Fclose(dset_fid); + if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - /* Verify file ID from datatype (from dataset) matches correct file */ - type = H5Dget_type(dset); - type_fid = H5Iget_file_id(type); - if(type_fid != filea1) TEST_ERROR - H5Fclose(type_fid); - H5Tclose(type); + if((dset = H5Dopen2(filea1, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR + /* Verify file ID from dataset matches correct file */ + dset_fid = H5Iget_file_id(dset); + if(dset_fid != filea1) TEST_ERROR + H5Fclose(dset_fid); - if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR - if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR - if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR + /* Verify file ID from datatype (from dataset) matches correct file */ + type = H5Dget_type(dset); + type_fid = H5Iget_file_id(type); + if(type_fid != filea1) TEST_ERROR + H5Fclose(type_fid); + H5Tclose(type); + if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - /* Create test file, with attribute that uses committed datatype */ - create_del_obj_named_test_file(filename, fapl, new_format); + if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR + if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR + if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR -/* Test getting file ID for attribute opened through different file ID */ - if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - if((attr = H5Aopen_by_name(filea1, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + /* Create test file, with attribute that uses committed datatype */ + create_del_obj_named_test_file(filename, fapl, low, high); - /* Verify file ID from dataset matches correct file */ - attr_fid = H5Iget_file_id(attr); - if(attr_fid != filea1) TEST_ERROR - H5Fclose(attr_fid); + /* Test getting file ID for attribute opened through different file ID */ + if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - /* Verify file ID from datatype (from dataset) matches correct file */ - type = H5Aget_type(attr); - type_fid = H5Iget_file_id(type); - if(type_fid != filea1) TEST_ERROR - H5Fclose(type_fid); - H5Tclose(type); + if((attr = H5Aopen_by_name(filea1, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Aclose(attr) < 0) FAIL_STACK_ERROR + /* Verify file ID from dataset matches correct file */ + attr_fid = H5Iget_file_id(attr); + if(attr_fid != filea1) TEST_ERROR + H5Fclose(attr_fid); - if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR + /* Verify file ID from datatype (from dataset) matches correct file */ + type = H5Aget_type(attr); + type_fid = H5Iget_file_id(type); + if(type_fid != filea1) TEST_ERROR + H5Fclose(type_fid); + H5Tclose(type); - if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR + if(H5Aclose(attr) < 0) FAIL_STACK_ERROR - if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR - if((attr = H5Aopen_by_name(filea1, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR - /* Verify file ID from dataset matches correct file */ - attr_fid = H5Iget_file_id(attr); - if(attr_fid != filea1) TEST_ERROR - H5Fclose(attr_fid); + if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - /* Verify file ID from datatype (from dataset) matches correct file */ - type = H5Aget_type(attr); - type_fid = H5Iget_file_id(type); - if(type_fid != filea1) TEST_ERROR - H5Fclose(type_fid); - H5Tclose(type); + if((attr = H5Aopen_by_name(filea1, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Aclose(attr) < 0) FAIL_STACK_ERROR + /* Verify file ID from dataset matches correct file */ + attr_fid = H5Iget_file_id(attr); + if(attr_fid != filea1) TEST_ERROR + H5Fclose(attr_fid); - if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR - if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR - if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR - } /* end for */ + /* Verify file ID from datatype (from dataset) matches correct file */ + type = H5Aget_type(attr); + type_fid = H5Iget_file_id(type); + if(type_fid != filea1) TEST_ERROR + H5Fclose(type_fid); + H5Tclose(type); + + if(H5Aclose(attr) < 0) FAIL_STACK_ERROR + + if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR + if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR + if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR + } /* end high */ + } /* end low */ if(H5Pclose(fapl2) < 0) FAIL_STACK_ERROR @@ -7018,12 +7054,15 @@ test_delete_obj_named_fileid(hid_t fapl) error: H5E_BEGIN_TRY { - H5Tclose(attr); + H5Aclose(attr); + H5Tclose(type); H5Dclose(dset); H5Pclose(fapl2); H5Fclose(filea1); H5Fclose(filea2); H5Fclose(fileb); + H5Fclose(attr_fid); + H5Fclose(type_fid); } H5E_END_TRY; return 1; } /* end test_delete_obj_named_fileid() */ @@ -7388,7 +7427,369 @@ error: return 1; } +/*------------------------------------------------------------------------- + * Function: verify_version + * + * Purpose: Utility function to verify the datatype versions of nested + * datatype. + * + * Description: + * Verify the datatype message version + * --H5T_COMPOUND, H5T_ENUM, H5T_ARRAY: + * the library will set version according to low_bound + * --H5T_ARRAY: + * the earliest version the library will set is 2 + * --H5T_INTEGER, H5T_FLOAT, H5T_TIME, H5T_STRING, H5T_BITFIELD, + * H5T_OPAQUE, H5T_REFERENCE: + * the library will only use basic version + * + *************************************************************************/ +static herr_t verify_version(hid_t dtype, H5F_libver_t low, unsigned *highest_version) +{ + hid_t base_dtype = -1; + hid_t mem_dtype = -1; + H5T_t *dtypep = NULL; /* Internal structure of a datatype */ + H5T_class_t type_cls = H5T_NO_CLASS; /* Temporary var for datatype class */ + int nmembers = 0; + unsigned i; + herr_t ret = SUCCEED; /* Generic return value */ + + dtypep = (H5T_t *)H5I_object(dtype); + if (dtypep == NULL) TEST_ERROR + + /* Carry out the verification according to the class of the datatype. + For compound datatype, its members will be verified, recursively. + For array datatype, its element datatype will be verified, recursively.*/ + type_cls = dtypep->shared->type; + switch (type_cls) + { + case H5T_ARRAY: + { + H5T_t *base_dtypep = NULL; /* Internal structure of a datatype */ + + if (low == H5F_LIBVER_EARLIEST) + VERIFY(dtypep->shared->version, H5O_DTYPE_VERSION_2, "H5O_dtype_ver_bounds"); + else + VERIFY(dtypep->shared->version, H5O_dtype_ver_bounds[low], "H5O_dtype_ver_bounds"); + + /* Get the base datatype of this array type */ + base_dtype = H5Tget_super(dtype); + CHECK(base_dtype, FAIL, "H5Tget_super"); + + /* Get the base type's internal structure for version */ + base_dtypep = (H5T_t *)H5I_object(base_dtype); + if (base_dtypep == NULL) TEST_ERROR + + /* Reset highest version if this datatype has higher version than + its outer type */ + if (*highest_version < base_dtypep->shared->version) + *highest_version = base_dtypep->shared->version; + + /* Verify the base datatype recursively */ + ret = verify_version(base_dtype, low, highest_version); + + /* Close the member datatype before checking for failure */ + if ((H5Tclose(base_dtype)) < 0) TEST_ERROR + + /* Check if verify_version fails */ + if (ret < 0) TEST_ERROR + + break; + } + case H5T_COMPOUND: + { + H5T_t *mem_dtypep = NULL; /* Internal structure of a datatype */ + /* Get the number of members of this compound type */ + if ((nmembers = H5Tget_nmembers(dtype)) < 0) TEST_ERROR + + /* Go through all its member datatypes */ + for (i = 0; i < (unsigned)nmembers; i++) + { + /* Get the member datatype to verify it recursively */ + mem_dtype = H5Tget_member_type(dtype, i); + if (mem_dtype < 0) TEST_ERROR + + /* Get the member type's internal structure for version */ + mem_dtypep = (H5T_t *)H5I_object(mem_dtype); + if (mem_dtypep == NULL) TEST_ERROR + + /* Reset highest version if this datatype has higher version than + its outer type */ + if (*highest_version < mem_dtypep->shared->version) + *highest_version = mem_dtypep->shared->version; + + /* Verify the datatype recursively */ + ret = verify_version(mem_dtype, low, highest_version); + + /* Close the member datatype before checking for failure */ + if ((H5Tclose(mem_dtype)) < 0) TEST_ERROR + + /* Check if verify_version fails */ + if (ret < 0) TEST_ERROR + } + /* If this compound datatype contains a datatype of higher version, it + will be promoted to that version, thus, verify with highest version */ + if (*highest_version > H5O_dtype_ver_bounds[low]) + VERIFY(dtypep->shared->version, *highest_version, "verify_version"); + else + VERIFY(dtypep->shared->version, H5O_dtype_ver_bounds[low], "verify_version"); + break; + } + case H5T_ENUM: + VERIFY(dtypep->shared->version, H5O_dtype_ver_bounds[low], "verify_version"); + break; + case H5T_VLEN: + case H5T_FLOAT: + case H5T_INTEGER: + VERIFY(dtypep->shared->version, H5O_dtype_ver_bounds[H5F_LIBVER_EARLIEST], "verify_version"); + break; + case H5T_NCLASSES: + case H5T_NO_CLASS: + case H5T_TIME: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_REFERENCE: + default: + TEST_ERROR + } /* end switch */ + +error: + H5E_BEGIN_TRY { + H5Tclose(base_dtype); + H5Tclose(mem_dtype); + } H5E_END_TRY; + return ret; +} /* end of verify_version */ + + +/*------------------------------------------------------------------------- + * Function: test_versionbounds + * + * Purpose: Tests version bounds. + * + * Description: + * This function creates a datatype for a dataset as followed: + * outer_arr_type + * outer_cmp_type + * inner_cmp_type + * inner_arr_type + * simple_cmp_type + * H5T_NATIVE_INT + * H5T_ARRAY of H5T_NATIVE_CHAR + * vlen_floattype + * enum_type + * It then loops through all valid combination of the library version + * bounds to verify each datatype's version. + * + * Return: Success: 0 + * Failure: number of errors + * + *------------------------------------------------------------------------- + */ +#define VERFNAME "tverbounds_dtype.h5" +#define VERDSNAME "dataset 1" +#define ARRAY_RANK 1 +#define ARRAY_LEN 10 +static int +test_versionbounds(void) +{ + typedef struct { /* Struct for the simple compound type */ + int single_int; + char char_arr[ARRAY_LEN]; + } simple_cmp_t; + + typedef struct { /* Struct for the inner compound type */ + simple_cmp_t inner_arr[ARRAY_LEN]; + hvl_t vlen_float; + } inner_cmp_t; + + typedef struct { /* Struct for the outer compound type */ + inner_cmp_t inner_cmp; + color_t enum_color; + } outer_cmp_t; + + hid_t file = -1; /* File ID */ + hid_t space = -1; /* Dataspace ID */ + hid_t dset = -1; /* Dataset ID */ + hid_t fcpl = -1; /* File creation property list ID */ + hid_t fapl = -1; /* Copy of file access property list ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t dset_dtype = -1; /* Dataset's datatype */ + hid_t arr_chartype = -1; /* Array of characters datatype */ + hid_t vlen_floattype = -1; /* Vlen of float datatype */ + hid_t enum_type = -1; /* Enumeration datatype */ + hid_t outer_cmp_type = -1; /* Outer compound datatype */ + hid_t inner_cmp_type = -1; /* Inner compound datatype */ + hid_t simple_cmp_type = -1;/* Simple cmpd dtype, contains no other cmpd */ + hid_t outer_arr_type = -1; /* Outermost array datatype */ + hid_t inner_arr_type = -1; /* Inner array datatype */ + H5F_t *filep = NULL; /* Pointer to internal structure of a file */ + H5T_t *dtypep = NULL; /* Pointer to internal structure of a datatype */ + hsize_t arr_dim[] = {ARRAY_LEN}; /* Length of the array */ + H5F_libver_t low, high; /* File format bounds */ + unsigned highest_version; /* Highest version in nested datatypes */ + color_t enum_val; /* Enum type index */ + herr_t ret = 0; /* Generic return value */ + + TESTING("version bounds with nested datatypes"); + + /* Create a file access property list */ + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR + + /* Create a file creation property list */ + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR + + /* Create a scalar dataspace */ + if ((space = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR + + /* Create a dataset creation property list */ + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR + + /* Create an array datatype of chars */ + arr_chartype = H5Tarray_create2(H5T_NATIVE_CHAR, ARRAY_RANK, arr_dim); + if (arr_chartype < 0) TEST_ERROR + + /* Create the simple compound datatype that has an integer and an + array of chars */ + simple_cmp_type = H5Tcreate(H5T_COMPOUND, sizeof(simple_cmp_t)); + if (simple_cmp_type < 0) TEST_ERROR + + /* Insert integer field */ + ret = H5Tinsert(simple_cmp_type, "single_int", HOFFSET(simple_cmp_t, single_int), H5T_NATIVE_INT); + if (ret < 0) TEST_ERROR + /* Insert array field */ + ret = H5Tinsert(simple_cmp_type, "char_arr", HOFFSET(simple_cmp_t, char_arr), arr_chartype); + if (ret < 0) TEST_ERROR + + /* Create an array datatype containing simple compound datatype */ + inner_arr_type = H5Tarray_create2(simple_cmp_type, ARRAY_RANK, arr_dim); + if (inner_arr_type < 0) TEST_ERROR + + /* Create a VL datatype of floats */ + vlen_floattype = H5Tvlen_create(H5T_NATIVE_FLOAT); + if (vlen_floattype < 0) TEST_ERROR + + /* Create the innermost compound datatype that houses inner_arr_type and vlen_floattype */ + inner_cmp_type = H5Tcreate(H5T_COMPOUND, sizeof(inner_cmp_t)); + if (inner_cmp_type < 0) TEST_ERROR + + /* Insert integer field */ + ret = H5Tinsert(inner_cmp_type, "inner_arr", HOFFSET(inner_cmp_t, inner_arr), inner_arr_type); + if (ret < 0) TEST_ERROR + + /* Insert integer field */ + ret = H5Tinsert(inner_cmp_type, "vlen_float", HOFFSET(inner_cmp_t, vlen_float), vlen_floattype); + if (ret < 0) TEST_ERROR + + /* Create a enumerate datatype */ + enum_type = H5Tcreate(H5T_ENUM, sizeof(color_t)); + if (enum_type < 0) TEST_ERROR + + enum_val = E1_RED; + ret = H5Tenum_insert(enum_type, "RED", &enum_val); + if (ret < 0) TEST_ERROR + + enum_val++; + ret = H5Tenum_insert(enum_type, "GREEN", &enum_val); + if (ret < 0) TEST_ERROR + + enum_val++; + ret = H5Tenum_insert(enum_type, "BLUE", &enum_val); + if (ret < 0) TEST_ERROR + + enum_val++; + ret = H5Tenum_insert(enum_type, "ORANGE", &enum_val); + if (ret < 0) TEST_ERROR + + enum_val++; + ret = H5Tenum_insert(enum_type, "YELLOW", &enum_val); + if (ret < 0) TEST_ERROR + + /* Create the outer compound datatype that contains the inner compound datatype and the enum datatype */ + outer_cmp_type = H5Tcreate(H5T_COMPOUND, sizeof(outer_cmp_t)); + if (ret < 0) TEST_ERROR + + /* Insert integer field */ + ret = H5Tinsert(outer_cmp_type, "inner_cmp", HOFFSET(outer_cmp_t, inner_cmp), inner_cmp_type); + if (ret < 0) TEST_ERROR + + /* Insert enum field */ + ret = H5Tinsert(outer_cmp_type, "enum_color", HOFFSET(outer_cmp_t, enum_color), enum_type); + if (ret < 0) TEST_ERROR + + /* Create an array datatype containing the outer compound datatype */ + if ((outer_arr_type = H5Tarray_create2(outer_cmp_type, ARRAY_RANK, arr_dim)) < 0) + TEST_ERROR + + /* Loop through all the combinations of low/high library format bounds, + skipping invalid combinations */ + /* Create the file, create and write to a dataset with compound datatype */ + /* Verify the dataset's datatype and its members */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + + /* Set version bounds */ + H5E_BEGIN_TRY { + ret = H5Pset_libver_bounds(fapl, low, high); + } H5E_END_TRY; + + if (ret < 0) /* Invalid low/high combinations */ + continue; + + /* Create a file */ + file = H5Fcreate(VERFNAME, H5F_ACC_TRUNC, fcpl, fapl); + if (file < 0) TEST_ERROR + + /* Get the internal file pointer if the create succeeds */ + if ((filep = (H5F_t *)H5I_object(file)) == NULL) TEST_ERROR + + /* Create dataset using the array type */ + dset = H5Dcreate2(file, VERDSNAME, outer_arr_type, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + if (dset < 0) TEST_ERROR + + /* Get the dataset's datatype */ + if ((dset_dtype = H5Dget_type(dset)) < 0) TEST_ERROR + + /* Get the version of this datatype */ + dtypep = (H5T_t *)H5I_object(dset_dtype); + if (dtypep == NULL) TEST_ERROR + highest_version = dtypep->shared->version; + + /* Verify version of the datatype recursevily */ + ret = verify_version(dset_dtype, low, &highest_version); + + /* Close the dataset's datatype */ + if (H5Tclose(dset_dtype) < 0) TEST_ERROR + + /* Close dataset and file */ + if (H5Dclose(dset) < 0) TEST_ERROR + if (H5Fclose(file) < 0) TEST_ERROR + + } /* for high */ + } /* for low */ + + /* Close dataspace and property lists */ + if (H5Sclose(space) < 0) TEST_ERROR + if (H5Pclose(fcpl) < 0) TEST_ERROR + if (H5Pclose(fapl) < 0) TEST_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(dset); + H5Sclose(space); + H5Tclose(dset_dtype); + H5Pclose(dcpl); + H5Pclose(fcpl); + H5Pclose(fapl); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* end test_versionbounds() */ /*------------------------------------------------------------------------- @@ -7411,7 +7812,7 @@ int main(void) { long nerrors = 0; - hid_t fapl = -1; + hid_t fapl = -1; /* Set the random # seed */ HDsrandom((unsigned)HDtime(NULL)); @@ -7428,7 +7829,6 @@ main(void) nerrors += test_detect(); nerrors += test_compound_1(); nerrors += test_query(); - nerrors += test_transient(fapl); nerrors += test_named(fapl); nerrors += test_encode(); @@ -7473,6 +7873,7 @@ main(void) nerrors += test_opaque(); nerrors += test_set_order(); nerrors += test_utf_ascii_conv(); + nerrors += test_versionbounds(); if(nerrors) { printf("***** %lu FAILURE%s! *****\n", diff --git a/test/objcopy.c b/test/objcopy.c index 5d9d426..e88d508 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -14271,10 +14271,10 @@ main(void) FALSE, "H5Ocopy(): expand soft link"); nerrors += test_copy_option(fcpl_src, fcpl_dst, src_fapl, dst_fapl, H5O_COPY_EXPAND_EXT_LINK_FLAG, - FALSE, "H5Ocopy: expand external link"); + FALSE, "H5Ocopy(): expand external link"); nerrors += test_copy_option(fcpl_src, fcpl_dst, src_fapl, dst_fapl, H5O_COPY_EXPAND_SOFT_LINK_FLAG | H5O_COPY_EXPAND_EXT_LINK_FLAG, - FALSE, "H5Ocopy: expand soft and external links"); + FALSE, "H5Ocopy(): expand soft and external links"); nerrors += test_copy_option(fcpl_src, fcpl_dst, src_fapl, dst_fapl, H5O_COPY_SHALLOW_HIERARCHY_FLAG, FALSE, "H5Ocopy(): shallow group copy"); diff --git a/test/th5s.c b/test/th5s.c index cd855e9..d23e0ea 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -42,9 +42,24 @@ #include "H5Opkg.h" /* Object header */ #include "H5Bprivate.h" -#include "H5Sprivate.h" +#include "H5Iprivate.h" #include "H5Pprivate.h" +/* + * This file needs to access private information from the H5S package. + * This file also needs to access the dataspace testing code. + */ +#define H5S_FRIEND /*suppress error about including H5Spkg */ +#include "H5Spkg.h" /* Dataspaces */ + +/* + * This file needs to access private information from the H5O package. + * This file also needs to access the dataspace testing code. + */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ +#define H5O_TESTING +#include "H5Opkg.h" /* Object header */ + #define TESTFILE "th5s.h5" #define DATAFILE "th5s1.h5" #define NULLFILE "th5s2.h5" diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index 13ebd17..f40c0b1 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/h5repack/CMakeTests.cmake @@ -53,6 +53,7 @@ # Copy all the HDF5 files from the source directory into the test directory # -------------------------------------------------------------------- set (LIST_HDF5_TEST_FILES + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/bounds_latest_latest.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_attr.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_attr_refs.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_deflate.h5 @@ -582,6 +583,62 @@ endif () endmacro () +# VERIFY_SUPERBLOCK + macro (ADD_H5_VERIFY_SUPERBLOCK testname testfile lowbound highbound superblock) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + add_test ( + NAME H5REPACK_VERIFY_SUPERBLOCK-${testname}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + testfiles/out-${testname}.${testfile} + testfiles/${testfile}-${testname}-v.out + testfiles/${testfile}-${testname}-v.out.err + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5REPACK_VERIFY_SUPERBLOCK-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) + endif () + add_test ( + NAME H5REPACK_VERIFY_SUPERBLOCK-${testname} + COMMAND $<TARGET_FILE:h5repack> -j;${lowbound};-k;${highbound} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + ) + set_tests_properties (H5REPACK_VERIFY_SUPERBLOCK-${testname} PROPERTIES DEPENDS H5REPACK_VERIFY_SUPERBLOCK-${testname}-clear-objects) + add_test ( + NAME H5REPACK_VERIFY_SUPERBLOCK-${testname}_DMP + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" + -D "TEST_ARGS:STRING=-H;-B;out-${testname}.${testfile}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=${testfile}-${testname}-v.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_FILTER:STRING=SUPERBLOCK_VERSION ${superblock}" + -D "TEST_REFERENCE=SUPERBLOCK_VERSION ${superblock}" + -P "${HDF_RESOURCES_EXT_DIR}/grepTest.cmake" + ) + set_tests_properties (H5REPACK_VERIFY_SUPERBLOCK-${testname}_DMP PROPERTIES DEPENDS H5REPACK_VERIFY_SUPERBLOCK-${testname}) + endif () + endmacro () + + macro (ADD_H5_VERIFY_INVALIDBOUNDS testname resultcode lowbound highbound) + add_test ( + NAME ADD_H5_VERIFY_INVALIDBOUNDS-h5repack-${testname}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + testfiles/out-${testname}.${testfile} + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (ADD_H5_VERIFY_INVALIDBOUNDS-h5repack-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) + endif () + add_test ( + NAME ADD_H5_VERIFY_INVALIDBOUNDS-h5repack-${testname} + COMMAND $<TARGET_FILE:h5repack> -j;${lowbound};-k;${highbound} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + ) + set_tests_properties ( + ADD_H5_VERIFY_INVALIDBOUNDS-h5repack-${testname} PROPERTIES + DEPENDS ADD_H5_VERIFY_INVALIDBOUNDS-h5repack-${testname}-clear-objects + WILL_FAIL "true" + ) + endmacro () + macro (ADD_H5_TEST_META testname testfile) # Remove any output file left over from previous test run add_test ( @@ -1371,6 +1428,18 @@ ADD_H5_VERIFY_VDS (vds_conti ${TESTTYPE} 0 ${FILEV4} vds_dset CONTIGUOUS -l vds_dset:CONTI) ############################################################################## +### V E R S I O N B O U N D S T E S T S +############################################################################## +# -j 0 -k 2, superblock will be 0 +ADD_H5_VERIFY_SUPERBLOCK (SB_IS_0 h5repack_layout.h5 0 2 0) +# -j 1 -k 2, superblock will be 2 +ADD_H5_VERIFY_SUPERBLOCK (SB_IS_2 h5repack_layout.h5 1 2 2) +# -j 2 -k 2, superblock will be 3 +ADD_H5_VERIFY_SUPERBLOCK (SB_IS_3 h5repack_layout.h5 2 2 3) +# -j 0 -k 1, file cannot be opened +ADD_H5_VERIFY_INVALIDBOUNDS (latest_latest_invalid bounds_latest_latest.h5 0 1) + +############################################################################## ### P L U G I N T E S T S ############################################################################## ADD_H5_UD_TEST (plugin_version_test 0 h5repack_layout.h5 -v -f UD=260,0,4,9,${H5_VERS_MAJOR},${H5_VERS_MINOR},${H5_VERS_RELEASE}) diff --git a/tools/test/h5repack/h5repack.sh.in b/tools/test/h5repack/h5repack.sh.in index e474bc3..b0a2f99 100644 --- a/tools/test/h5repack/h5repack.sh.in +++ b/tools/test/h5repack/h5repack.sh.in @@ -82,6 +82,7 @@ test -d $TESTDIR || mkdir $TESTDIR # Comment '#' without space can be used. # -------------------------------------------------------------------- LIST_HDF5_TEST_FILES=" +$SRC_H5REPACK_TESTFILES/bounds_latest_latest.h5 $SRC_H5REPACK_TESTFILES/h5repack_attr.h5 $SRC_H5REPACK_TESTFILES/h5repack_attr_refs.h5 $SRC_H5REPACK_TESTFILES/h5repack_deflate.h5 @@ -340,8 +341,8 @@ VERIFY_LAYOUT_DSET() fi # clean up tmp files - rm -f $outfile - rm -f $layoutfile +# rm -f $outfile +# rm -f $layoutfile } #------------------------------------------ @@ -513,6 +514,87 @@ VERIFY_LAYOUT_ALL() rm -f $layoutfile } +#-------------------------------------------------------------- +# Verifying superblock of a file with different version bounds +VERIFY_SUPERBLOCK() +{ + lowbound=$1 + highbound=$2 + superblock=$3 + infile=$4 + layoutfile=verbounds-low$lowbound-high$highbound.$4 + outfile=out-verbounds-low$lowbound-high$highbound.$infile + expectedsuperblock="SUPERBLOCK_VERSION $superblock" + + shift + shift + shift + shift + + TESTING $H5REPACK $@ + ( + cd $TESTDIR + $RUNSERIAL $H5REPACK_BIN -j $lowbound -k $highbound $infile $outfile + ) + RET=$? + if [ $RET != 0 ] ; then + echo "*FAILED*" + nerrors="`expr $nerrors + 1`" + else + echo " PASSED" + DIFFTEST $infile $outfile + fi + + #--------------------------------- + # check the layout from a dataset + VERIFY "superblock" + ( + cd $TESTDIR + $RUNSERIAL $H5DUMP_BIN -H -B $outfile > $layoutfile + ) + $GREP "$expectedsuperblock" $TESTDIR/$layoutfile > /dev/null + if [ $? -eq 0 ]; then + echo " PASSED" + else + echo " FAILED" + nerrors="`expr $nerrors + 1`" + fi + + # clean up tmp files + rm -f $outfile + rm -f $layoutfile + +} # end of VERIFY_SUPERBLOCK + +#------------------------------------------------------------------ +# Verifying that a latest file cannot be opened with earlier bounds +VERIFY_INVALIDBOUNDS() +{ + lowbound=$1 + highbound=$2 + infile=$3 + outfile=out-verbounds-low$lowbound-high$highbound.$infile + + #-------------------------------------- + # check for failure with invalid bounds + TESTING $H5REPACK $@ + ( + cd $TESTDIR + $RUNSERIAL $H5REPACK_BIN -j $lowbound -k $highbound $infile $outfile + ) + RET=$? + if [ $RET != 0 ] ; then + echo " PASSED" + else + echo "*FAILED*" + nerrors="`expr $nerrors + 1`" + fi + + # clean up tmp files + rm -f $outfile + +} # end of VERIFY_INVALIDBOUNDS + # same as TOOLTEST, but it uses the old syntax -i input_file -o output_file # TOOLTEST0() @@ -1365,6 +1447,18 @@ else VERIFY_LAYOUT_VDS vds_conti 4_vds.h5 vds_dset CONTIGUOUS -l vds_dset:CONTI fi +######################################################### +# Testing version bounds +######################################################### +# -j 0 -k 2, superblock will be 0 +VERIFY_SUPERBLOCK 0 2 0 h5repack_layout.h5 -j 0 -k 2 h5repack_layout.h5 +# -j 1 -k 2, superblock will be 2 +VERIFY_SUPERBLOCK 1 2 2 h5repack_layout.h5 -j 1 -k 2 h5repack_layout.h5 +# -j 2 -k 2, superblock will be 3 +VERIFY_SUPERBLOCK 2 2 3 h5repack_layout.h5 -j 2 -k 2 h5repack_layout.h5 +# -j 0 -k 1, file cannot be opened +VERIFY_INVALIDBOUNDS 0 1 bounds_latest_latest.h5 + # Clean up temporary files/directories CLEAN_TESTFILES_AND_TESTDIR diff --git a/tools/test/h5repack/testfiles/bounds_latest_latest.h5 b/tools/test/h5repack/testfiles/bounds_latest_latest.h5 Binary files differnew file mode 100644 index 0000000..6e8bcad --- /dev/null +++ b/tools/test/h5repack/testfiles/bounds_latest_latest.h5 |