From fbf13515ba3f29198e94e012b9346035f567fa8c Mon Sep 17 00:00:00 2001 From: Jordan Henderson Date: Tue, 8 Jun 2021 12:59:31 -0500 Subject: [PATCH] Enable dynamic loading of VFDs with HDF5_DRIVER environment variable --- .gitattributes | 8 +- MANIFEST | 8 +- c++/test/CMakeVFDTests.cmake | 18 + config/conclude.am | 19 +- src/H5.c | 4 +- src/H5FDcore.c | 42 +- src/H5FDdirect.c | 81 +- src/H5FDfamily.c | 231 ++++- src/H5FDhdfs.c | 2 +- src/H5FDint.c | 92 +- src/H5FDlog.c | 20 +- src/H5FDmirror.c | 2 +- src/H5FDmpio.c | 63 +- src/H5FDmulti.c | 431 ++++++--- src/H5FDprivate.h | 11 +- src/H5FDpublic.h | 8 - src/H5FDros3.c | 2 +- src/H5FDsec2.c | 2 +- src/H5FDsplitter.c | 346 +++++-- src/H5FDwindows.c | 2 +- src/H5Fint.c | 7 +- src/H5Fprivate.h | 11 +- src/H5Pfapl.c | 657 ++++++++----- src/H5Pint.c | 74 +- src/H5Ppkg.h | 3 + src/H5Pprivate.h | 13 +- src/H5VLcallback.c | 2 +- test/CMakeTests.cmake | 10 +- test/CMakeVFDTests.cmake | 19 + test/Makefile.am | 4 +- test/app_ref.c | 24 +- test/btree2.c | 8 +- test/cache.c | 5 + test/cache_api.c | 47 +- test/cache_image.c | 3 +- test/cache_tagging.c | 6 + test/cork.c | 17 + test/dangle.c | 16 +- test/dsets.c | 23 +- test/dtransform.c | 2 + test/dtypes.c | 86 +- test/error_test.c | 20 +- ...mily_v16_00000.h5 => family_v16-000000.h5} | Bin ...mily_v16_00001.h5 => family_v16-000001.h5} | Bin ...mily_v16_00002.h5 => family_v16-000002.h5} | Bin ...mily_v16_00003.h5 => family_v16-000003.h5} | Bin test/file_image.c | 5 +- test/fillval.c | 5 +- test/freespace.c | 28 +- test/getname.c | 8 +- test/h5test.c | 389 ++++---- test/h5test.h | 12 +- test/lheap.c | 40 +- test/links.c | 173 ++-- test/links_env.c | 16 +- test/mf.c | 201 ++-- test/mtime.c | 101 +- test/ntypes.c | 16 +- test/null_vfd_plugin.c | 20 +- test/objcopy.c | 41 +- test/ohdr.c | 24 +- test/set_extent.c | 41 +- test/stab.c | 14 +- test/tarray.c | 6 +- test/tattr.c | 108 ++- test/tfile.c | 884 ++++++++++-------- test/th5o.c | 117 ++- test/th5s.c | 2 +- test/titerate.c | 6 +- test/tmisc.c | 94 +- test/trefer.c | 14 +- test/tselect.c | 33 +- test/tsohm.c | 44 +- test/vds.c | 17 +- test/vds_env.c | 17 +- test/vfd.c | 17 +- test/vfd_plugin.c | 35 +- test/vol.c | 59 +- testpar/CMakeVFDTests.cmake | 17 + testpar/t_pflush1.c | 2 + testpar/t_pflush2.c | 2 +- tools/src/h5repack/h5repack_main.c | 2 +- tools/test/h5repack/CMakeVFDTests.cmake | 17 + tools/test/h5repack/h5repacktst.c | 807 +++++++++------- 84 files changed, 3785 insertions(+), 2098 deletions(-) rename test/{family_v16_00000.h5 => family_v16-000000.h5} (100%) rename test/{family_v16_00001.h5 => family_v16-000001.h5} (100%) rename test/{family_v16_00002.h5 => family_v16-000002.h5} (100%) rename test/{family_v16_00003.h5 => family_v16-000003.h5} (100%) diff --git a/.gitattributes b/.gitattributes index e01442aa84e..385f805fafc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -393,10 +393,10 @@ test/cork.c -text test/corrupt_stab_msg.h5 -text test/deflate.h5 -text test/dynlib4.c -text -test/family_v16_00000.h5 -text -test/family_v16_00001.h5 -text -test/family_v16_00002.h5 -text -test/family_v16_00003.h5 -text +test/family_v16-000000.h5 -text +test/family_v16-000001.h5 -text +test/family_v16-000002.h5 -text +test/family_v16-000003.h5 -text test/file_image_core_test.h5 -text test/filespace_1_6.h5 -text test/filespace_1_8.h5 -text diff --git a/MANIFEST b/MANIFEST index d7177a22f03..f9d06f3114c 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1191,10 +1191,10 @@ ./test/external_common.h ./test/external_env.c ./test/external_fname.h -./test/family_v16_00000.h5 -./test/family_v16_00001.h5 -./test/family_v16_00002.h5 -./test/family_v16_00003.h5 +./test/family_v16-000000.h5 +./test/family_v16-000001.h5 +./test/family_v16-000002.h5 +./test/family_v16-000003.h5 ./test/farray.c ./test/fheap.c ./test/file_image.c diff --git a/c++/test/CMakeVFDTests.cmake b/c++/test/CMakeVFDTests.cmake index 360d14e3351..6a742446a8f 100644 --- a/c++/test/CMakeVFDTests.cmake +++ b/c++/test/CMakeVFDTests.cmake @@ -24,11 +24,29 @@ set (VFD_LIST split multi family + splitter + #log - log VFD currently has file space allocation bugs ) if (H5_HAVE_DIRECT) set (VFD_LIST ${VFD_LIST} direct) endif () +if (H5_HAVE_PARALLEL) + # MPI I/O VFD is currently incompatible with too many tests in the VFD test set + # set (VFD_LIST ${VFD_LIST} mpio) +endif () +if (H5_HAVE_MIRROR_VFD) + set (VFD_LIST ${VFD_LIST} mirror) +endif () +if (H5_HAVE_ROS3_VFD) + set (VFD_LIST ${VFD_LIST} ros3) +endif () +if (H5_HAVE_LIBHDFS) + set (VFD_LIST ${VFD_LIST} hdfs) +endif () +if (H5_HAVE_WINDOWS) + set (VFD_LIST ${VFD_LIST} windows) +endif () ############################################################################## ############################################################################## diff --git a/config/conclude.am b/config/conclude.am index 7d190828ebe..e798d8d7242 100644 --- a/config/conclude.am +++ b/config/conclude.am @@ -270,10 +270,27 @@ build-check-p: $(LIB) $(PROGS) $(chk_TESTS) echo "===Parallel tests in `echo ${PWD} | sed -e s:.*/::` ended `date`===";\ fi -VFD_LIST = sec2 stdio core core_paged split multi family +VFD_LIST = sec2 stdio core core_paged split multi family splitter + +# log VFD currently has file space allocation bugs +# VFD_LIST += log + if DIRECT_VFD_CONDITIONAL VFD_LIST += direct endif +if BUILD_PARALLEL_CONDITIONAL + # MPI I/O VFD is currently incompatible with too many tests in the VFD test set + # VFD_LIST += mpio +endif +if MIRROR_VFD_CONDITIONAL + VFD_LIST += mirror +endif +if ROS3_VFD_CONDITIONAL + VFD_LIST += ros3 +endif +if HDFS_VFD_CONDITIONAL + VFD_LIST += hdfs +endif # Run test with different Virtual File Driver check-vfd: $(LIB) $(PROGS) $(chk_TESTS) diff --git a/src/H5.c b/src/H5.c index 3ceaecd02d9..731f15abcb5 100644 --- a/src/H5.c +++ b/src/H5.c @@ -261,7 +261,7 @@ H5_init_library(void) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize error interface") if (H5VL_init_phase1() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize vol interface") - if (H5P_init() < 0) + if (H5P_init_phase1() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize property list interface") if (H5AC_init() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize metadata caching interface") @@ -273,6 +273,8 @@ H5_init_library(void) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize dataspace interface") /* Finish initializing interfaces that depend on the interfaces above */ + if (H5P_init_phase2() < 0) + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize property list interface") if (H5VL_init_phase2() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize vol interface") diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 9f0ed0c0ccd..81dee4e9756 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -149,6 +149,7 @@ static herr_t H5FD__core_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing static herr_t H5FD__core_lock(H5FD_t *_file, hbool_t rw); static herr_t H5FD__core_unlock(H5FD_t *_file); static herr_t H5FD__core_delete(const char *filename, hid_t fapl_id); +static inline const H5FD_core_fapl_t *H5FD__core_get_default_config(void); static const H5FD_class_t H5FD_core_g = { H5FD_CORE_VALUE, /* value */ @@ -187,6 +188,11 @@ static const H5FD_class_t H5FD_core_g = { H5FD_FLMAP_DICHOTOMY /* fl_map */ }; +/* Default configurations, if none provided */ +static const H5FD_core_fapl_t H5FD_core_default_config_g = {H5_MB, TRUE, H5FD_CORE_WRITE_TRACKING_FLAG, + H5FD_CORE_WRITE_TRACKING_PAGE_SIZE}; +static const H5FD_core_fapl_t H5FD_core_default_paged_config_g = {H5_MB, TRUE, TRUE, (size_t)4096}; + /* Define a free list to manage the region type */ H5FL_DEFINE(H5FD_core_region_t); @@ -408,6 +414,32 @@ H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__core_write_to_bstore() */ +/*------------------------------------------------------------------------- + * Function: H5FD__core_get_default_config + * + * Purpose: Retrieves a default configuration for this VFD when no + * configuration information has been provided. + * + * Return: Valid Core VFD configuration information pointer (can't + * fail) + * + *------------------------------------------------------------------------- + */ +static inline const H5FD_core_fapl_t * +H5FD__core_get_default_config(void) +{ + char *driver = HDgetenv("HDF5_DRIVER"); + + if (driver) { + if (!HDstrcmp(driver, "core")) + return &H5FD_core_default_config_g; + else if (!HDstrcmp(driver, "core_paged")) + return &H5FD_core_default_paged_config_g; + } + + return &H5FD_core_default_config_g; +} /* end H5FD__core_get_default_config() */ + /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -529,7 +561,7 @@ H5Pset_core_write_tracking(hid_t plist_id, hbool_t is_enabled, size_t page_size) if (H5FD_CORE != H5P_peek_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") if (NULL == (old_fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") + old_fa = H5FD__core_get_default_config(); /* Set VFD info values */ HDmemset(&fa, 0, sizeof(H5FD_core_fapl_t)); @@ -539,7 +571,7 @@ H5Pset_core_write_tracking(hid_t plist_id, hbool_t is_enabled, size_t page_size) fa.page_size = page_size; /* Set the property values & the driver for the FAPL */ - if (H5P_set_driver(plist, H5FD_CORE, &fa) < 0) + if (H5P_set_driver(plist, H5FD_CORE, &fa, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD as driver") done: @@ -623,7 +655,7 @@ H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store) fa.page_size = H5FD_CORE_WRITE_TRACKING_PAGE_SIZE; /* Set the property values & the driver for the FAPL */ - if (H5P_set_driver(plist, H5FD_CORE, &fa) < 0) + if (H5P_set_driver(plist, H5FD_CORE, &fa, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD as driver") done: @@ -748,7 +780,7 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") if (NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") + fa = H5FD__core_get_default_config(); /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; @@ -1735,7 +1767,7 @@ H5FD__core_delete(const char *filename, hid_t fapl_id) if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") if (NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") + fa = H5FD__core_get_default_config(); if (fa->backing_store) if (HDremove(filename) < 0) diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index e6614bd4726..42a8a4ba944 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -120,6 +120,8 @@ typedef struct H5FD_direct_t { /* Prototypes */ static herr_t H5FD__direct_term(void); +static herr_t H5FD__direct_populate_config(size_t boundary, size_t block_size, size_t cbuf_size, + H5FD_direct_fapl_t *fa_out); static void * H5FD__direct_fapl_get(H5FD_t *file); static void * H5FD__direct_fapl_copy(const void *_old_fa); static H5FD_t *H5FD__direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); @@ -296,28 +298,10 @@ H5Pset_fapl_direct(hid_t fapl_id, size_t boundary, size_t block_size, size_t cbu if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - HDmemset(&fa, 0, sizeof(H5FD_direct_fapl_t)); - if (boundary != 0) - fa.mboundary = boundary; - else - fa.mboundary = MBOUNDARY_DEF; - if (block_size != 0) - fa.fbsize = block_size; - else - fa.fbsize = FBSIZE_DEF; - if (cbuf_size != 0) - fa.cbsize = cbuf_size; - else - fa.cbsize = CBSIZE_DEF; - - /* Set the default to be true for data alignment */ - fa.must_align = TRUE; - - /* Copy buffer size must be a multiple of file block size */ - if (fa.cbsize % fa.fbsize != 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "copy buffer size must be a multiple of block size") + if (H5FD__direct_populate_config(boundary, block_size, cbuf_size, &fa) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't initialize driver configuration info") - ret_value = H5P_set_driver(plist, H5FD_DIRECT, &fa); + ret_value = H5P_set_driver(plist, H5FD_DIRECT, &fa, NULL); done: FUNC_LEAVE_API(ret_value) @@ -366,6 +350,53 @@ H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary /*out*/, size_t *block_size / FUNC_LEAVE_API(ret_value) } /* end H5Pget_fapl_direct() */ +/*------------------------------------------------------------------------- + * Function: H5FD__direct_populate_config + * + * Purpose: Populates a H5FD_direct_fapl_t structure with the provided + * values, supplying defaults where values are not provided. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD__direct_populate_config(size_t boundary, size_t block_size, size_t cbuf_size, H5FD_direct_fapl_t *fa_out) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(fa_out); + + HDmemset(fa_out, 0, sizeof(H5FD_direct_fapl_t)); + + if (boundary != 0) + fa_out->mboundary = boundary; + else + fa_out->mboundary = MBOUNDARY_DEF; + + if (block_size != 0) + fa_out->fbsize = block_size; + else + fa_out->fbsize = FBSIZE_DEF; + + if (cbuf_size != 0) + fa_out->cbsize = cbuf_size; + else + fa_out->cbsize = CBSIZE_DEF; + + /* Set the default to be true for data alignment */ + fa_out->must_align = TRUE; + + /* Copy buffer size must be a multiple of file block size */ + if (fa_out->cbsize % fa_out->fbsize != 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "copy buffer size must be a multiple of block size") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD__direct_get_default_config() */ + /*------------------------------------------------------------------------- * Function: H5FD__direct_fapl_get * @@ -450,6 +481,7 @@ H5FD__direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad int fd = (-1); H5FD_direct_t * file = NULL; const H5FD_direct_fapl_t *fa; + H5FD_direct_fapl_t default_fa; #ifdef H5_HAVE_WIN32_API HFILE filehandle; struct _BY_HANDLE_FILE_INFORMATION fileinfo; @@ -498,8 +530,11 @@ H5FD__direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad /* Get the driver specific information */ if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if (NULL == (fa = (const H5FD_direct_fapl_t *)H5P_peek_driver_info(plist))) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") + if (NULL == (fa = (const H5FD_direct_fapl_t *)H5P_peek_driver_info(plist))) { + if (H5FD__direct_populate_config(0, 0, 0, &default_fa) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, NULL, "can't initialize driver configuration info") + fa = &default_fa; + } file->fd = fd; H5_CHECKED_ASSIGN(file->eof, haddr_t, sb.st_size, h5_stat_size_t); diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index fe9a2c7526e..358f45920b7 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -47,6 +47,9 @@ /* The size of the member name buffers */ #define H5FD_FAM_MEMB_NAME_BUF_SIZE 4096 +/* Default member size - 100 MiB */ +#define H5FD_FAM_DEF_MEM_SIZE ((hsize_t)(100 * H5_MB)) + /* The driver identification number, initialized at runtime */ static hid_t H5FD_FAMILY_g = 0; @@ -77,6 +80,10 @@ typedef struct H5FD_family_fapl_t { hid_t memb_fapl_id; /*file access property list of each memb*/ } H5FD_family_fapl_t; +/* Private routines */ +static herr_t H5FD__family_get_default_config(H5FD_family_fapl_t *fa_out); +static char * H5FD__family_get_default_printf_filename(const char *old_filename); + /* Callback prototypes */ static herr_t H5FD__family_term(void); static void * H5FD__family_fapl_get(H5FD_t *_file); @@ -141,6 +148,122 @@ static const H5FD_class_t H5FD_family_g = { H5FD_FLMAP_DICHOTOMY /* fl_map */ }; +/*------------------------------------------------------------------------- + * Function: H5FD__family_get_default_config + * + * Purpose: Populates a H5FD_family_fapl_t structure with default + * values. + * + * Return: Non-negative on Success/Negative on Failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD__family_get_default_config(H5FD_family_fapl_t *fa_out) +{ + H5P_genplist_t *def_plist; + H5P_genplist_t *plist; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(fa_out); + + fa_out->memb_size = H5FD_FAM_DEF_MEM_SIZE; + + /* Use copy of default file access property list for member FAPL ID. + * The Sec2 driver is explicitly set on the member FAPL ID, as the + * default driver might have been replaced with the Family VFD, which + * would cause recursion badness in the child members. + */ + if (NULL == (def_plist = (H5P_genplist_t *)H5I_object(H5P_FILE_ACCESS_DEFAULT))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + if ((fa_out->memb_fapl_id = H5P_copy_plist(def_plist, FALSE)) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTCOPY, FAIL, "can't copy property list") + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fa_out->memb_fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + if (H5P_set_driver_by_value(plist, H5_VFD_SEC2, NULL, TRUE) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't set default driver on member FAPL") + +done: + if (ret_value < 0 && fa_out->memb_fapl_id >= 0) { + if (H5I_dec_ref(fa_out->memb_fapl_id) < 0) + HDONE_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't decrement ref. count on member FAPL ID") + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD__family_get_default_config() */ + +/*------------------------------------------------------------------------- + * Function: H5FD__family_get_default_printf_filename + * + * Purpose: Given a filename, allocates and returns a new filename + * buffer that contains the given filename modified into this + * VFD's printf-style format. For example, the filename + * "file1.h5" would be modified to "file1-%06d.h5". This would + * allow for member filenames such as "file1-000000.h5", + * "file1-000001.h5", etc. The caller is responsible for + * freeing the returned buffer. + * + * Return: Non-negative on Success/Negative on Failure + * + *------------------------------------------------------------------------- + */ +static char * +H5FD__family_get_default_printf_filename(const char *old_filename) +{ + const char *suffix = "-%06d"; + size_t old_filename_len = 0; + size_t new_filename_len = 0; + char * file_extension = NULL; + char * tmp_buffer = NULL; + char * ret_value = NULL; + + FUNC_ENTER_STATIC + + HDassert(old_filename); + + old_filename_len = HDstrlen(old_filename); + if (0 == old_filename_len) + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "invalid filename") + + new_filename_len = old_filename_len + HDstrlen(suffix) + 1; + if (NULL == (tmp_buffer = H5MM_malloc(new_filename_len))) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "can't allocate new filename buffer") + + /* Determine if filename contains a ".h5" extension. */ + if ((file_extension = strstr(old_filename, ".h5"))) { + /* Insert the printf format between the filename and ".h5" extension. */ + HDstrcpy(tmp_buffer, old_filename); + file_extension = strstr(tmp_buffer, ".h5"); + HDsprintf(file_extension, "%s%s", suffix, ".h5"); + } + else if ((file_extension = strrchr(old_filename, '.'))) { + char *new_extension_loc = NULL; + + /* If the filename doesn't contain a ".h5" extension, but contains + * AN extension, just insert the printf format before that extension. + */ + HDstrcpy(tmp_buffer, old_filename); + new_extension_loc = strrchr(tmp_buffer, '.'); + HDsprintf(new_extension_loc, "%s%s", suffix, file_extension); + } + else { + /* If the filename doesn't contain an extension at all, just insert + * the printf format at the end of the filename. + */ + HDsnprintf(tmp_buffer, new_filename_len, "%s%s", old_filename, suffix); + } + + ret_value = tmp_buffer; + +done: + if (!ret_value) + H5MM_xfree(tmp_buffer); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD__family_get_default_printf_filename() */ + /*-------------------------------------------------------------------------- NAME H5FD__init_package -- Initialize interface-specific information @@ -243,7 +366,7 @@ herr_t H5Pset_fapl_family(hid_t fapl_id, hsize_t msize, hid_t memb_fapl_id) { herr_t ret_value; - H5FD_family_fapl_t fa = {0, -1}; + H5FD_family_fapl_t fa = {0, H5I_INVALID_HID}; H5P_genplist_t * plist; /* Property list pointer */ FUNC_ENTER_API(FAIL) @@ -252,18 +375,22 @@ H5Pset_fapl_family(hid_t fapl_id, hsize_t msize, hid_t memb_fapl_id) /* Check arguments */ if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - if (H5P_DEFAULT == memb_fapl_id) - memb_fapl_id = H5P_FILE_ACCESS_DEFAULT; + if (H5P_DEFAULT == memb_fapl_id) { + /* Get default configuration for member FAPL */ + if (H5FD__family_get_default_config(&fa) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get default driver configuration info") + } else if (TRUE != H5P_isa_class(memb_fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") /* Initialize driver specific information. */ - fa.memb_size = msize; - fa.memb_fapl_id = memb_fapl_id; + fa.memb_size = msize; + if (H5P_DEFAULT != memb_fapl_id) + fa.memb_fapl_id = memb_fapl_id; if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - ret_value = H5P_set_driver(plist, H5FD_FAMILY, &fa); + ret_value = H5P_set_driver(plist, H5FD_FAMILY, &fa, NULL); done: FUNC_LEAVE_API(ret_value) @@ -589,9 +716,10 @@ H5FD__family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad { H5FD_family_t *file = NULL; char * memb_name = NULL, *temp = NULL; - hsize_t eof = HADDR_UNDEF; - unsigned t_flags = flags & ~H5F_ACC_CREAT; - H5FD_t * ret_value = NULL; + hsize_t eof = HADDR_UNDEF; + hbool_t default_config = FALSE; + unsigned t_flags = flags & ~H5F_ACC_CREAT; + H5FD_t * ret_value = NULL; FUNC_ENTER_STATIC @@ -605,21 +733,32 @@ H5FD__family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad if (NULL == (file = (H5FD_family_t *)H5MM_calloc(sizeof(H5FD_family_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") if (H5P_FILE_ACCESS_DEFAULT == fapl_id) { - file->memb_fapl_id = H5P_FILE_ACCESS_DEFAULT; - if (H5I_inc_ref(file->memb_fapl_id, FALSE) < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") - file->memb_size = 1024 * 1024 * 1024; /*1GB. Actual member size to be updated later */ - file->pmem_size = 1024 * 1024 * 1024; /*1GB. Member size passed in through property */ - file->mem_newsize = 0; /*New member size used by h5repart only */ - } /* end if */ + H5FD_family_fapl_t default_fa; + + /* Get default configuration */ + if (H5FD__family_get_default_config(&default_fa) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get default driver configuration info") + + file->memb_fapl_id = default_fa.memb_fapl_id; + file->memb_size = H5FD_FAM_DEF_MEM_SIZE; /* Actual member size to be updated later */ + file->pmem_size = H5FD_FAM_DEF_MEM_SIZE; /* Member size passed in through property */ + file->mem_newsize = 0; /*New member size used by h5repart only */ + + default_config = TRUE; + } /* end if */ else { H5P_genplist_t * plist; /* Property list pointer */ const H5FD_family_fapl_t *fa; + H5FD_family_fapl_t default_fa; if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if (NULL == (fa = (const H5FD_family_fapl_t *)H5P_peek_driver_info(plist))) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") + if (NULL == (fa = (const H5FD_family_fapl_t *)H5P_peek_driver_info(plist))) { + if (H5FD__family_get_default_config(&default_fa) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get default family VFD configuration") + fa = &default_fa; + default_config = TRUE; + } /* Check for new family file size. It's used by h5repart only. */ if (H5P_exist_plist(plist, H5F_ACS_FAMILY_NEWSIZE_NAME) > 0) { @@ -643,7 +782,10 @@ H5FD__family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad } /* end else */ file->memb_size = fa->memb_size; /* Actual member size to be updated later */ file->pmem_size = fa->memb_size; /* Member size passed in through property */ - } /* end else */ + + if (default_config && H5I_dec_ref(fa->memb_fapl_id) < 0) + HGOTO_ERROR(H5E_ID, H5E_CANTDEC, NULL, "can't decrement ref. count on member FAPL") + } /* end else */ file->name = H5MM_strdup(name); file->flags = flags; @@ -656,8 +798,16 @@ H5FD__family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad /* Check that names are unique */ HDsnprintf(memb_name, H5FD_FAM_MEMB_NAME_BUF_SIZE, name, 0); HDsnprintf(temp, H5FD_FAM_MEMB_NAME_BUF_SIZE, name, 1); - if (!HDstrcmp(memb_name, temp)) - HGOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL, "file names not unique") + if (!HDstrcmp(memb_name, temp)) { + if (default_config) { + temp = H5MM_xfree(temp); + if (NULL == (temp = H5FD__family_get_default_printf_filename(name))) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get default printf-style filename") + name = temp; + } + else + HGOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL, "file names not unique") + } /* Open all the family members */ while (1) { @@ -1361,7 +1511,9 @@ H5FD__family_delete(const char *filename, hid_t fapl_id) { H5P_genplist_t * plist; const H5FD_family_fapl_t *fa; - hid_t memb_fapl_id = H5I_INVALID_HID; + H5FD_family_fapl_t default_fa = {0, H5I_INVALID_HID}; + hbool_t default_config = FALSE; + hid_t memb_fapl_id = H5I_INVALID_HID; unsigned current_member; char * member_name = NULL; char * temp = NULL; @@ -1375,13 +1527,21 @@ H5FD__family_delete(const char *filename, hid_t fapl_id) /* Get the driver info (for the member fapl) * The family_open call accepts H5P_DEFAULT, so we'll accept that here, too. */ - if (H5P_FILE_ACCESS_DEFAULT == fapl_id) - memb_fapl_id = H5P_FILE_ACCESS_DEFAULT; + if (H5P_FILE_ACCESS_DEFAULT == fapl_id) { + if (H5FD__family_get_default_config(&default_fa) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get default family VFD configuration") + memb_fapl_id = default_fa.memb_fapl_id; + default_config = TRUE; + } else { if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - if (NULL == (fa = (const H5FD_family_fapl_t *)H5P_peek_driver_info(plist))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad family VFD driver info") + if (NULL == (fa = (const H5FD_family_fapl_t *)H5P_peek_driver_info(plist))) { + if (H5FD__family_get_default_config(&default_fa) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get default family VFD configuration") + fa = &default_fa; + default_config = TRUE; + } memb_fapl_id = fa->memb_fapl_id; } @@ -1394,8 +1554,17 @@ H5FD__family_delete(const char *filename, hid_t fapl_id) /* Sanity check to make sure that generated names are unique */ HDsnprintf(member_name, H5FD_FAM_MEMB_NAME_BUF_SIZE, filename, 0); HDsnprintf(temp, H5FD_FAM_MEMB_NAME_BUF_SIZE, filename, 1); - if (!HDstrcmp(member_name, temp)) - HGOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "provided file name cannot generate unique sub-files") + if (!HDstrcmp(member_name, temp)) { + if (default_config) { + temp = H5MM_xfree(temp); + if (NULL == (temp = H5FD__family_get_default_printf_filename(filename))) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get default printf-style filename") + filename = temp; + } + else + HGOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, + "provided file name cannot generate unique sub-files") + } /* Delete all the family members */ current_member = 0; @@ -1431,9 +1600,9 @@ H5FD__family_delete(const char *filename, hid_t fapl_id) if (temp) H5MM_xfree(temp); - /* Don't close memb_fapl_id - We didn't bump its reference count since we're - * only using it in this call. - */ + /* Only close memb_fapl_id if we created one from the default configuration */ + if (default_fa.memb_fapl_id >= 0 && H5I_dec_ref(default_fa.memb_fapl_id) < 0) + HDONE_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't decrement ref. count on member FAPL ID") FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__family_delete() */ diff --git a/src/H5FDhdfs.c b/src/H5FDhdfs.c index 3eadc81555f..252c546c1d2 100644 --- a/src/H5FDhdfs.c +++ b/src/H5FDhdfs.c @@ -626,7 +626,7 @@ H5Pset_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa) if (FAIL == H5FD__hdfs_validate_config(fa)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid hdfs config") - ret_value = H5P_set_driver(plist, H5FD_HDFS, (void *)fa); + ret_value = H5P_set_driver(plist, H5FD_HDFS, (void *)fa, NULL); done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5FDint.c b/src/H5FDint.c index a03797ca466..c567499d69a 100644 --- a/src/H5FDint.c +++ b/src/H5FDint.c @@ -485,11 +485,7 @@ H5FD_check_plugin_load(const H5FD_class_t *cls, const H5PL_key_t *key, hbool_t * if (cls->value == key->vfd.u.value) *success = TRUE; } /* end else */ -#if 0 - /* Driver is a match, but might not be a compatible version */ - if (*success && cls->version != H5FD_VERSION) - *success = FALSE; -#endif + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_check_plugin_load() */ @@ -548,8 +544,8 @@ hid_t H5FD_register_driver_by_name(const char *name, hbool_t app_ref) { htri_t driver_is_registered = FALSE; - hid_t driver_id = H5I_INVALID_HID; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t driver_id = H5I_INVALID_HID; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) @@ -602,8 +598,8 @@ hid_t H5FD_register_driver_by_value(H5FD_class_value_t value, hbool_t app_ref) { htri_t driver_is_registered = FALSE; - hid_t driver_id = H5I_INVALID_HID; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t driver_id = H5I_INVALID_HID; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) @@ -722,3 +718,81 @@ H5FD_is_driver_registered_by_value(H5FD_class_value_t driver_value, hid_t *regis done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_is_driver_registered_by_value() */ + +/*------------------------------------------------------------------------- + * Function: H5FD_get_driver_id_by_name + * + * Purpose: Retrieves the ID for a registered VFL driver. + * + * Return: Positive if the VFL driver has been registered + * Negative on error (if the driver is not a valid driver or + * is not registered) + * + *------------------------------------------------------------------------- + */ +hid_t +H5FD_get_driver_id_by_name(const char *name, hbool_t is_api) +{ + H5FD_get_driver_ud_t op_data; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_NOAPI(H5I_INVALID_HID) + + /* Set up op data for iteration */ + op_data.key.kind = H5FD_GET_DRIVER_BY_NAME; + op_data.key.u.name = name; + op_data.found_id = H5I_INVALID_HID; + + /* Find driver with specified name */ + if (H5I_iterate(H5I_VFL, H5FD__get_driver_cb, &op_data, FALSE) < 0) + HGOTO_ERROR(H5E_VFL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VFL drivers") + + /* Found a driver with that name */ + if (op_data.found_id != H5I_INVALID_HID) { + ret_value = op_data.found_id; + if (H5I_inc_ref(ret_value, is_api) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VFL driver") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_get_driver_id_by_name() */ + +/*------------------------------------------------------------------------- + * Function: H5FD_get_driver_id_by_value + * + * Purpose: Retrieves the ID for a registered VFL driver. + * + * Return: Positive if the VFL driver has been registered + * Negative on error (if the driver is not a valid driver or + * is not registered) + * + *------------------------------------------------------------------------- + */ +hid_t +H5FD_get_driver_id_by_value(H5FD_class_value_t value, hbool_t is_api) +{ + H5FD_get_driver_ud_t op_data; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_NOAPI(H5I_INVALID_HID) + + /* Set up op data for iteration */ + op_data.key.kind = H5FD_GET_DRIVER_BY_VALUE; + op_data.key.u.value = value; + op_data.found_id = H5I_INVALID_HID; + + /* Find driver with specified value */ + if (H5I_iterate(H5I_VFL, H5FD__get_driver_cb, &op_data, FALSE) < 0) + HGOTO_ERROR(H5E_VFL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VFL drivers") + + /* Found a driver with that value */ + if (op_data.found_id != H5I_INVALID_HID) { + ret_value = op_data.found_id; + if (H5I_inc_ref(ret_value, is_api) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VFL driver") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_get_driver_id_by_value() */ diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 0bd9974fc99..86aee8b52e9 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -216,6 +216,9 @@ static const H5FD_class_t H5FD_log_g = { H5FD_FLMAP_DICHOTOMY /* fl_map */ }; +/* Default configuration, if none provided */ +static const H5FD_log_fapl_t H5FD_log_default_config_g = {NULL, H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC, 4096}; + /* Declare a free list to manage the H5FD_log_t struct */ H5FL_DEFINE_STATIC(H5FD_log_t); @@ -348,7 +351,7 @@ H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long long flags, si fa.flags = flags; fa.buf_size = buf_size; - ret_value = H5P_set_driver(plist, H5FD_LOG, &fa); + ret_value = H5P_set_driver(plist, H5FD_LOG, &fa, NULL); done: if (fa.logfile) @@ -483,10 +486,11 @@ static H5FD_t * H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { H5FD_log_t * file = NULL; - H5P_genplist_t * plist; /* Property list */ - const H5FD_log_fapl_t *fa; /* File access property list information */ - int fd = -1; /* File descriptor */ - int o_flags; /* Flags for open() call */ + H5P_genplist_t * plist; /* Property list */ + const H5FD_log_fapl_t *fa; /* File access property list information */ + H5FD_log_fapl_t default_fa = H5FD_log_default_config_g; + int fd = -1; /* File descriptor */ + int o_flags; /* Flags for open() call */ #ifdef H5_HAVE_WIN32_API struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif @@ -524,8 +528,10 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) /* Get the driver specific information */ if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if (NULL == (fa = (const H5FD_log_fapl_t *)H5P_peek_driver_info(plist))) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") + if (NULL == (fa = (const H5FD_log_fapl_t *)H5P_peek_driver_info(plist))) { + /* Use default driver configuration*/ + fa = &default_fa; + } /* Start timer for open() call */ if (fa->flags & H5FD_LOG_TIME_OPEN) diff --git a/src/H5FDmirror.c b/src/H5FDmirror.c index 9c8aba4e2d4..19e15088822 100644 --- a/src/H5FDmirror.c +++ b/src/H5FDmirror.c @@ -1336,7 +1336,7 @@ H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa) if (H5FD_MIRROR_CURR_FAPL_T_VERSION != fa->version) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown fapl_t version"); - ret_value = H5P_set_driver(plist, H5FD_MIRROR, (const void *)fa); + ret_value = H5P_set_driver(plist, H5FD_MIRROR, (const void *)fa, NULL); done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index 816b7f9f537..20617e53726 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -45,6 +45,9 @@ static hid_t H5FD_MPIO_g = 0; /* (Can be changed by setting "HDF5_MPI_OPT_TYPES" environment variable to '0' or '1') */ hbool_t H5FD_mpi_opt_types_g = TRUE; +/* Whether the driver initialized MPI on its own */ +hbool_t H5FD_mpi_self_initialized = FALSE; + /* * The view is set to this value */ @@ -240,6 +243,7 @@ hid_t H5FD_mpio_init(void) { static int H5FD_mpio_Debug_inited = 0; + char * env = NULL; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) @@ -248,6 +252,21 @@ H5FD_mpio_init(void) if (H5I_VFL != H5I_get_type(H5FD_MPIO_g)) H5FD_MPIO_g = H5FD_register((const H5FD_class_t *)&H5FD_mpio_g, sizeof(H5FD_class_mpi_t), FALSE); + /* Check if MPI driver has been loaded dynamically */ + env = HDgetenv("HDF5_DRIVER"); + if (env && !HDstrcmp(env, "mpio")) { + int mpi_initialized = 0; + + /* Initialize MPI if not already initialized */ + if (MPI_SUCCESS != MPI_Initialized(&mpi_initialized)) + HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, H5I_INVALID_HID, "can't check if MPI is initialized") + if (!mpi_initialized) { + if (MPI_SUCCESS != MPI_Init(NULL, NULL)) + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, H5I_INVALID_HID, "can't initialize MPI") + H5FD_mpi_self_initialized = TRUE; + } + } + if (!H5FD_mpio_Debug_inited) { const char *s; /* String for environment variables */ @@ -293,6 +312,17 @@ H5FD__mpio_term(void) { FUNC_ENTER_STATIC_NOERR + /* Terminate MPI if the driver initialized it */ + if (H5FD_mpi_self_initialized) { + int mpi_finalized = 0; + + MPI_Finalized(&mpi_finalized); + if (!mpi_finalized) + MPI_Finalize(); + + H5FD_mpi_self_initialized = FALSE; + } + /* Reset VFL ID */ H5FD_MPIO_g = 0; @@ -354,7 +384,7 @@ H5Pset_fapl_mpio(hid_t fapl_id, MPI_Comm comm, MPI_Info info) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI info object") /* duplication is done during driver setting. */ - ret_value = H5P_set_driver(plist, H5FD_MPIO, NULL); + ret_value = H5P_set_driver(plist, H5FD_MPIO, NULL, NULL); done: FUNC_LEAVE_API(ret_value) @@ -809,11 +839,16 @@ H5FD__mpio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t H5_ATTR if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - /* Get the MPI communicator and info object from the property list */ - if (H5P_get(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, &comm) < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get MPI communicator") - if (H5P_get(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, &info) < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get MPI info object") + if (H5FD_mpi_self_initialized) { + comm = MPI_COMM_WORLD; + } + else { + /* Get the MPI communicator and info object from the property list */ + if (H5P_get(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, &comm) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get MPI communicator") + if (H5P_get(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, &info) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get MPI info object") + } /* Get the MPI rank of this process and the total number of processes */ if (MPI_SUCCESS != (mpi_code = MPI_Comm_rank(comm, &mpi_rank))) @@ -1775,11 +1810,16 @@ H5FD__mpio_delete(const char *filename, hid_t fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") HDassert(H5FD_MPIO == H5P_peek_driver(plist)); - /* Get the MPI communicator and info from the fapl */ - if (H5P_get(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, &info) < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI info object") - if (H5P_get(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, &comm) < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI communicator") + if (H5FD_mpi_self_initialized) { + comm = MPI_COMM_WORLD; + } + else { + /* Get the MPI communicator and info from the fapl */ + if (H5P_get(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, &info) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI info object") + if (H5P_get(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, &comm) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI communicator") + } /* Get the MPI rank of this process */ if (MPI_SUCCESS != (mpi_code = MPI_Comm_rank(comm, &mpi_rank))) @@ -1882,5 +1922,4 @@ H5FD__mpio_communicator(const H5FD_t *_file) FUNC_LEAVE_NOAPI(file->comm) } /* end H5FD__mpio_communicator() */ - #endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index e997a553939..b130a56c08c 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -135,8 +135,13 @@ typedef struct H5FD_multi_dxpl_t { } H5FD_multi_dxpl_t; /* Private functions */ -static int compute_next(H5FD_multi_t *file); -static int open_members(H5FD_multi_t *file); +static herr_t H5FD_split_populate_config(const char *meta_ext, hid_t meta_plist_id, const char *raw_ext, + hid_t raw_plist_id, hbool_t relax, H5FD_multi_fapl_t *fa_out); +static herr_t H5FD_multi_populate_config(const H5FD_mem_t *memb_map, const hid_t *memb_fapl, + const char *const *memb_name, const haddr_t *memb_addr, + hbool_t relax, H5FD_multi_fapl_t *fa_out); +static int compute_next(H5FD_multi_t *file); +static int open_members(H5FD_multi_t *file); /* Callback prototypes */ static herr_t H5FD_multi_term(void); @@ -272,74 +277,19 @@ herr_t H5Pset_fapl_split(hid_t fapl, const char *meta_ext, hid_t meta_plist_id, const char *raw_ext, hid_t raw_plist_id) { - H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl[H5FD_MEM_NTYPES]; - const char *memb_name[H5FD_MEM_NTYPES]; - char meta_name[H5FD_MULT_MAX_FILE_NAME_LEN]; - char raw_name[H5FD_MULT_MAX_FILE_NAME_LEN]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; + H5FD_multi_fapl_t fa; + static const char *func = "H5Pset_fapl_split"; /* Function Name for error reporting */ /*NO TRACE*/ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); - /* Initialize */ - ALL_MEMBERS (mt) { - /* Treat global heap as raw data, not metadata */ - memb_map[mt] = ((mt == H5FD_MEM_DRAW || mt == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : H5FD_MEM_SUPER); - memb_fapl[mt] = -1; - memb_name[mt] = NULL; - memb_addr[mt] = HADDR_UNDEF; - } - END_MEMBERS; - - /* The file access properties */ - memb_fapl[H5FD_MEM_SUPER] = meta_plist_id; - memb_fapl[H5FD_MEM_DRAW] = raw_plist_id; - - /* The names */ - /* process meta filename */ - if (meta_ext) { - if (strstr(meta_ext, "%s")) { - /* Note: this doesn't accommodate for when the '%s' in the user's - * string is at a position >sizeof(meta_name) - QK & JK - 2013/01/17 - */ - strncpy(meta_name, meta_ext, sizeof(meta_name)); - meta_name[sizeof(meta_name) - 1] = '\0'; - } - else - sprintf(meta_name, "%%s%s", meta_ext); - } - else { - strncpy(meta_name, "%s.meta", sizeof(meta_name)); - meta_name[sizeof(meta_name) - 1] = '\0'; - } - memb_name[H5FD_MEM_SUPER] = meta_name; - - /* process raw filename */ - if (raw_ext) { - if (strstr(raw_ext, "%s")) { - /* Note: this doesn't accommodate for when the '%s' in the user's - * string is at a position >sizeof(raw_name) - QK & JK - 2013/01/17 - */ - strncpy(raw_name, raw_ext, sizeof(raw_name)); - raw_name[sizeof(raw_name) - 1] = '\0'; - } - else - sprintf(raw_name, "%%s%s", raw_ext); - } - else { - strncpy(raw_name, "%s.raw", sizeof(raw_name)); - raw_name[sizeof(raw_name) - 1] = '\0'; - } - memb_name[H5FD_MEM_DRAW] = raw_name; - - /* The sizes */ - memb_addr[H5FD_MEM_SUPER] = 0; - memb_addr[H5FD_MEM_DRAW] = HADDR_MAX / 2; + if (H5FD_split_populate_config(meta_ext, meta_plist_id, raw_ext, raw_plist_id, TRUE, &fa) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_CANTSET, "can't setup split driver configuration", + -1); - return H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, TRUE); + return H5Pset_driver(fapl, H5FD_MULTI, &fa); } /*------------------------------------------------------------------------- @@ -423,14 +373,7 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, const hid_t *memb_f const char *const *memb_name, const haddr_t *memb_addr, hbool_t relax) { H5FD_multi_fapl_t fa; - H5FD_mem_t mt, mmt; - H5FD_mem_t _memb_map[H5FD_MEM_NTYPES]; - hid_t _memb_fapl[H5FD_MEM_NTYPES]; - char _memb_name[H5FD_MEM_NTYPES][16]; - const char * _memb_name_ptrs[H5FD_MEM_NTYPES]; - haddr_t _memb_addr[H5FD_MEM_NTYPES]; - static const char *letters = "Xsbrglo"; - static const char *func = "H5FDset_fapl_multi"; /* Function Name for error reporting */ + static const char *func = "H5FDset_fapl_multi"; /* Function Name for error reporting */ /*NO TRACE*/ @@ -440,66 +383,9 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, const hid_t *memb_f /* Check arguments and supply default values */ if (H5I_GENPROP_LST != H5Iget_type(fapl_id) || TRUE != H5Pisa_class(fapl_id, H5P_FILE_ACCESS)) H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADVALUE, "not an access list", -1); - if (!memb_map) { - for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) - _memb_map[mt] = H5FD_MEM_DEFAULT; - memb_map = _memb_map; - } - if (!memb_fapl) { - for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) - _memb_fapl[mt] = H5Pcreate(H5P_FILE_ACCESS); - memb_fapl = _memb_fapl; - } - if (!memb_name) { - assert(strlen(letters) == H5FD_MEM_NTYPES); - for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { - sprintf(_memb_name[mt], "%%s-%c.h5", letters[mt]); - _memb_name_ptrs[mt] = _memb_name[mt]; - } - memb_name = _memb_name_ptrs; - } - if (!memb_addr) { - for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) - _memb_addr[mt] = (hsize_t)(mt ? (mt - 1) : 0) * (HADDR_MAX / (H5FD_MEM_NTYPES - 1)); - memb_addr = _memb_addr; - } + if (H5FD_multi_populate_config(memb_map, memb_fapl, memb_name, memb_addr, relax, &fa) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_CANTSET, "can't setup driver configuration", -1); - for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { - /* Map usage type */ - mmt = memb_map[mt]; - if (mmt < 0 || mmt >= H5FD_MEM_NTYPES) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADRANGE, "file resource type out of range", -1); - if (H5FD_MEM_DEFAULT == mmt) - mmt = mt; - - /* - * All members of MEMB_FAPL must be either defaults or actual file - * access property lists. - */ - if (H5P_DEFAULT != memb_fapl[mmt] && TRUE != H5Pisa_class(memb_fapl[mmt], H5P_FILE_ACCESS)) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type incorrect", -1); - - /* All names must be defined */ - if (!memb_name[mmt] || !memb_name[mmt][0]) - H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type not set", -1); - } - - /* - * Initialize driver specific information. No need to copy it into the FA - * struct since all members will be copied by H5Pset_driver(). - */ - memset(&fa, 0, sizeof(H5FD_multi_fapl_t)); - memcpy(fa.memb_map, memb_map, H5FD_MEM_NTYPES * sizeof(H5FD_mem_t)); - memcpy(fa.memb_fapl, memb_fapl, H5FD_MEM_NTYPES * sizeof(hid_t)); - memcpy(fa.memb_name, memb_name, H5FD_MEM_NTYPES * sizeof(char *)); - memcpy(fa.memb_addr, memb_addr, H5FD_MEM_NTYPES * sizeof(haddr_t)); - fa.relax = relax; - - /* Patch up H5P_DEFAULT property lists for members */ - for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { - if (fa.memb_fapl[mt] == H5P_DEFAULT) - fa.memb_fapl[mt] = H5Pcreate(H5P_FILE_ACCESS); - } return H5Pset_driver(fapl_id, H5FD_MULTI, &fa); } @@ -524,6 +410,7 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map /*out*/, hid_t *memb_fapl char **memb_name /*out*/, haddr_t *memb_addr /*out*/, hbool_t *relax) { const H5FD_multi_fapl_t *fa; + H5FD_multi_fapl_t default_fa; H5FD_mem_t mt; static const char * func = "H5FDget_fapl_multi"; /* Function Name for error reporting */ @@ -536,8 +423,17 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map /*out*/, hid_t *memb_fapl H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADTYPE, "not an access list", -1); if (H5FD_MULTI != H5Pget_driver(fapl_id)) H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADVALUE, "incorrect VFL driver", -1); - if (NULL == (fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id))) - H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADVALUE, "bad VFL driver info", -1); + H5E_BEGIN_TRY + { + fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id); + } + H5E_END_TRY; + if (!fa || (H5P_FILE_ACCESS_DEFAULT == fapl_id)) { + if (H5FD_multi_populate_config(NULL, NULL, NULL, NULL, TRUE, &default_fa) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTSET, "can't setup default driver configuration", + -1); + fa = &default_fa; + } if (memb_map) memcpy(memb_map, fa->memb_map, H5FD_MEM_NTYPES * sizeof(H5FD_mem_t)); @@ -565,6 +461,231 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map /*out*/, hid_t *memb_fapl return 0; } +/*------------------------------------------------------------------------- + * Function: H5FD_split_populate_config + * + * Purpose: Populates a H5FD_multi_fapl_t structure with the provided + * split driver values, supplying defaults where values are not + * provided. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_split_populate_config(const char *meta_ext, hid_t meta_plist_id, const char *raw_ext, hid_t raw_plist_id, + hbool_t relax, H5FD_multi_fapl_t *fa_out) +{ + static const char *func = "H5FD_split_populate_config"; /* Function Name for error reporting */ + static char + meta_name_g[H5FD_MULT_MAX_FILE_NAME_LEN]; /* Static scratch buffer to store metadata member name */ + static char + raw_name_g[H5FD_MULT_MAX_FILE_NAME_LEN]; /* Static scratch buffer to store raw data member name */ + const char *_memb_name[H5FD_MEM_NTYPES]; + H5FD_mem_t _memb_map[H5FD_MEM_NTYPES]; + hid_t _memb_fapl[H5FD_MEM_NTYPES]; + haddr_t _memb_addr[H5FD_MEM_NTYPES]; + herr_t ret_value = 0; + + assert(fa_out); + + /* Initialize */ + ALL_MEMBERS (mt) { + /* Treat global heap as raw data, not metadata */ + _memb_map[mt] = ((mt == H5FD_MEM_DRAW || mt == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : H5FD_MEM_SUPER); + _memb_fapl[mt] = H5P_DEFAULT; + _memb_name[mt] = NULL; + _memb_addr[mt] = HADDR_UNDEF; + } + END_MEMBERS; + + /* The file access properties */ + _memb_fapl[H5FD_MEM_SUPER] = meta_plist_id; + _memb_fapl[H5FD_MEM_DRAW] = raw_plist_id; + + /* The names */ + /* process meta filename */ + if (meta_ext) { + if (strstr(meta_ext, "%s")) { + /* Note: this doesn't accommodate for when the '%s' in the user's + * string is at a position >sizeof(meta_name) - QK & JK - 2013/01/17 + */ + strncpy(meta_name_g, meta_ext, sizeof(meta_name_g)); + meta_name_g[sizeof(meta_name_g) - 1] = '\0'; + } + else + sprintf(meta_name_g, "%%s%s", meta_ext); + } + else { + strncpy(meta_name_g, "%s.meta", sizeof(meta_name_g)); + meta_name_g[sizeof(meta_name_g) - 1] = '\0'; + } + _memb_name[H5FD_MEM_SUPER] = meta_name_g; + + /* process raw filename */ + if (raw_ext) { + if (strstr(raw_ext, "%s")) { + /* Note: this doesn't accommodate for when the '%s' in the user's + * string is at a position >sizeof(raw_name) - QK & JK - 2013/01/17 + */ + strncpy(raw_name_g, raw_ext, sizeof(raw_name_g)); + raw_name_g[sizeof(raw_name_g) - 1] = '\0'; + } + else + sprintf(raw_name_g, "%%s%s", raw_ext); + } + else { + strncpy(raw_name_g, "%s.raw", sizeof(raw_name_g)); + raw_name_g[sizeof(raw_name_g) - 1] = '\0'; + } + _memb_name[H5FD_MEM_DRAW] = raw_name_g; + + /* The sizes */ + _memb_addr[H5FD_MEM_SUPER] = 0; + _memb_addr[H5FD_MEM_DRAW] = HADDR_MAX / 2; + + ALL_MEMBERS (mt) { + /* Map usage type */ + H5FD_mem_t mmt = _memb_map[mt]; + if (mmt < 0 || mmt >= H5FD_MEM_NTYPES) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADRANGE, "file resource type out of range", -1); + + /* + * All members of MEMB_FAPL must be either defaults or actual file + * access property lists. + */ + if (H5P_DEFAULT != _memb_fapl[mmt] && TRUE != H5Pisa_class(_memb_fapl[mmt], H5P_FILE_ACCESS)) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type incorrect", -1); + + /* All names must be defined */ + if (!_memb_name[mmt] || !_memb_name[mmt][0]) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type not set", -1); + } + END_MEMBERS; + + /* + * Initialize driver specific information. No need to copy it into the FA + * struct since all members will be copied by H5Pset_driver(). + */ + memset(fa_out, 0, sizeof(H5FD_multi_fapl_t)); + memcpy(fa_out->memb_map, _memb_map, H5FD_MEM_NTYPES * sizeof(H5FD_mem_t)); + memcpy(fa_out->memb_fapl, _memb_fapl, H5FD_MEM_NTYPES * sizeof(hid_t)); + memcpy(fa_out->memb_name, _memb_name, H5FD_MEM_NTYPES * sizeof(char *)); + memcpy(fa_out->memb_addr, _memb_addr, H5FD_MEM_NTYPES * sizeof(haddr_t)); + fa_out->relax = relax; + + /* Patch up H5P_DEFAULT property lists for members */ + ALL_MEMBERS (mt) { + if (fa_out->memb_fapl[mt] == H5P_DEFAULT) { + fa_out->memb_fapl[mt] = H5Pcreate(H5P_FILE_ACCESS); + if (H5Pset_fapl_sec2(fa_out->memb_fapl[mt]) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_CANTSET, + "can't set sec2 driver on member FAPL", -1); + } + } + END_MEMBERS; + + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: H5FD_multi_populate_config + * + * Purpose: Populates a H5FD_multi_fapl_t structure with the provided + * values, supplying defaults where values are not provided. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD_multi_populate_config(const H5FD_mem_t *memb_map, const hid_t *memb_fapl, const char *const *memb_name, + const haddr_t *memb_addr, hbool_t relax, H5FD_multi_fapl_t *fa_out) +{ + static const char *func = "H5FD_multi_populate_config"; /* Function Name for error reporting */ + static const char *letters = "Xsbrglo"; + static char _memb_name_g[H5FD_MEM_NTYPES][16]; /* Static scratch buffer to store member names */ + H5FD_mem_t mt, mmt; + H5FD_mem_t _memb_map[H5FD_MEM_NTYPES]; + hid_t _memb_fapl[H5FD_MEM_NTYPES]; + const char * _memb_name_ptrs[H5FD_MEM_NTYPES]; + haddr_t _memb_addr[H5FD_MEM_NTYPES]; + herr_t ret_value = 0; + + assert(fa_out); + + if (!memb_map) { + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) + _memb_map[mt] = H5FD_MEM_DEFAULT; + memb_map = _memb_map; + } + if (!memb_fapl) { + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + _memb_fapl[mt] = H5Pcreate(H5P_FILE_ACCESS); + if (H5Pset_fapl_sec2(_memb_fapl[mt]) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_CANTSET, + "can't set sec2 driver on member FAPL", -1); + } + memb_fapl = _memb_fapl; + } + if (!memb_name) { + assert(strlen(letters) == H5FD_MEM_NTYPES); + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + sprintf(_memb_name_g[mt], "%%s-%c.h5", letters[mt]); + _memb_name_ptrs[mt] = _memb_name_g[mt]; + } + memb_name = _memb_name_ptrs; + } + if (!memb_addr) { + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) + _memb_addr[mt] = (hsize_t)(mt ? (mt - 1) : 0) * (HADDR_MAX / (H5FD_MEM_NTYPES - 1)); + memb_addr = _memb_addr; + } + + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + /* Map usage type */ + mmt = memb_map[mt]; + if (mmt < 0 || mmt >= H5FD_MEM_NTYPES) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADRANGE, "file resource type out of range", -1); + if (H5FD_MEM_DEFAULT == mmt) + mmt = mt; + + /* + * All members of MEMB_FAPL must be either defaults or actual file + * access property lists. + */ + if (H5P_DEFAULT != memb_fapl[mmt] && TRUE != H5Pisa_class(memb_fapl[mmt], H5P_FILE_ACCESS)) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type incorrect", -1); + + /* All names must be defined */ + if (!memb_name[mmt] || !memb_name[mmt][0]) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_BADVALUE, "file resource type not set", -1); + } + + /* + * Initialize driver specific information. No need to copy it into the FA + * struct since all members will be copied by H5Pset_driver(). + */ + memset(fa_out, 0, sizeof(H5FD_multi_fapl_t)); + memcpy(fa_out->memb_map, memb_map, H5FD_MEM_NTYPES * sizeof(H5FD_mem_t)); + memcpy(fa_out->memb_fapl, memb_fapl, H5FD_MEM_NTYPES * sizeof(hid_t)); + memcpy(fa_out->memb_name, memb_name, H5FD_MEM_NTYPES * sizeof(char *)); + memcpy(fa_out->memb_addr, memb_addr, H5FD_MEM_NTYPES * sizeof(haddr_t)); + fa_out->relax = relax; + + /* Patch up H5P_DEFAULT property lists for members */ + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt = (H5FD_mem_t)(mt + 1)) { + if (fa_out->memb_fapl[mt] == H5P_DEFAULT) { + fa_out->memb_fapl[mt] = H5Pcreate(H5P_FILE_ACCESS); + if (H5Pset_fapl_sec2(fa_out->memb_fapl[mt]) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_INTERNAL, H5E_CANTSET, + "can't set sec2 driver on member FAPL", -1); + } + } + + return ret_value; +} /* end H5FD_multi_populate_config() */ + /*------------------------------------------------------------------------- * Function: H5FD_multi_sb_size * @@ -1010,12 +1131,26 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr */ if (NULL == (file = (H5FD_multi_t *)calloc((size_t)1, sizeof(H5FD_multi_t)))) H5Epush_ret(func, H5E_ERR_CLS, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL); - if (H5P_FILE_ACCESS_DEFAULT == fapl_id || H5FD_MULTI != H5Pget_driver(fapl_id)) { + H5E_BEGIN_TRY + { + fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id); + } + H5E_END_TRY; + if (!fa || (H5P_FILE_ACCESS_DEFAULT == fapl_id) || (H5FD_MULTI != H5Pget_driver(fapl_id))) { + char *env = getenv("HDF5_DRIVER"); + close_fapl = fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if (H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE) < 0) - H5Epush_goto(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTSET, "can't set property value", error) + if (env && !strcmp(env, "split")) { + if (H5Pset_fapl_split(fapl_id, NULL, H5P_DEFAULT, NULL, H5P_DEFAULT) < 0) + H5Epush_goto(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTSET, "can't set property value", error) + } + else { + if (H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE) < 0) + H5Epush_goto(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTSET, "can't set property value", error) + } + + fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id); } - fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id); assert(fa); ALL_MEMBERS (mt) { file->fa.memb_map[mt] = fa->memb_map[mt]; @@ -2036,6 +2171,7 @@ H5FD_multi_delete(const char *filename, hid_t fapl_id) char full_filename[H5FD_MULT_MAX_FILE_NAME_LEN]; int nchars; const H5FD_multi_fapl_t *fa; + H5FD_multi_fapl_t default_fa; static const char * func = "H5FD_multi_delete"; /* Function Name for error reporting */ /* Clear the error stack */ @@ -2043,11 +2179,26 @@ H5FD_multi_delete(const char *filename, hid_t fapl_id) assert(filename); - /* Quiet compiler */ - (void)fapl_id; - /* Get the driver info */ - fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id); + H5E_BEGIN_TRY + { + fa = (const H5FD_multi_fapl_t *)H5Pget_driver_info(fapl_id); + } + H5E_END_TRY; + if (!fa) { + char *env = getenv("HDF5_DRIVER"); + + if (env && !strcmp(env, "split")) { + if (H5FD_split_populate_config(NULL, H5P_DEFAULT, NULL, H5P_DEFAULT, TRUE, &default_fa) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTSET, "can't setup driver configuration", -1); + } + else { + if (H5FD_multi_populate_config(NULL, NULL, NULL, NULL, TRUE, &default_fa) < 0) + H5Epush_ret(func, H5E_ERR_CLS, H5E_VFL, H5E_CANTSET, "can't setup driver configuration", -1); + } + + fa = &default_fa; + } assert(fa); /* Delete each member file using the underlying fapl */ diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index 14ac1374298..b60f6cc3a6d 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -88,10 +88,11 @@ typedef struct { } \ } -/* Define structure to hold driver ID & info for FAPLs */ +/* Define structure to hold driver ID, info & configuration string for FAPLs */ typedef struct { - hid_t driver_id; /* Driver's ID */ - const void *driver_info; /* Driver info, for open callbacks */ + hid_t driver_id; /* Driver's ID */ + const void *driver_info; /* Driver info, for open callbacks */ + const char *driver_config_str; /* Driver configuration string */ } H5FD_driver_prop_t; /* Which kind of VFD field to use for searching */ @@ -124,7 +125,9 @@ H5_DLL hid_t H5FD_register(const void *cls, size_t size, hbool_t app_ref H5_DLL hid_t H5FD_register_driver_by_name(const char *name, hbool_t app_ref); H5_DLL hid_t H5FD_register_driver_by_value(H5FD_class_value_t value, hbool_t app_ref); H5_DLL htri_t H5FD_is_driver_registered_by_name(const char *driver_name, hid_t *registered_id); -H5_DLL htri_t H5FD_is_driver_registered_by_value(H5FD_class_value_t driver_value, hid_t *registered_id); +H5_DLL htri_t H5FD_is_driver_registered_by_value(H5FD_class_value_t driver_value, hid_t *registered_id); +H5_DLL hid_t H5FD_get_driver_id_by_name(const char *name, hbool_t is_api); +H5_DLL hid_t H5FD_get_driver_id_by_value(H5FD_class_value_t value, hbool_t is_api); H5_DLL H5FD_t *H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); H5_DLL herr_t H5FD_close(H5FD_t *file); H5_DLL int H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2); diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index d16d422b538..2c9b58294b1 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -185,13 +185,6 @@ */ typedef int H5FD_class_value_t; -/* A free list is a singly-linked list of address/size pairs. */ -typedef struct H5FD_free_t { - haddr_t addr; - hsize_t size; - struct H5FD_free_t *next; -} H5FD_free_t; - /* Types of allocation requests: see H5Fpublic.h */ typedef enum H5F_mem_t H5FD_mem_t; @@ -316,7 +309,6 @@ extern "C" { #endif /* Function prototypes */ - /* Allows querying a VFD ID for features before the file is opened */ H5_DLL herr_t H5FDdriver_query(hid_t driver_id, unsigned long *flags /*out*/); diff --git a/src/H5FDros3.c b/src/H5FDros3.c index 84447722345..d62b7aa6212 100644 --- a/src/H5FDros3.c +++ b/src/H5FDros3.c @@ -411,7 +411,7 @@ H5Pset_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa) if (FAIL == H5FD__ros3_validate_config(fa)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid ros3 config") - ret_value = H5P_set_driver(plist, H5FD_ROS3, (void *)fa); + ret_value = H5P_set_driver(plist, H5FD_ROS3, (void *)fa, NULL); done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index d6dfdb6408a..a4f85ddecdb 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -293,7 +293,7 @@ H5Pset_fapl_sec2(hid_t fapl_id) if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - ret_value = H5P_set_driver(plist, H5FD_SEC2, NULL); + ret_value = H5P_set_driver(plist, H5FD_SEC2, NULL, NULL); done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5FDsplitter.c b/src/H5FDsplitter.c index 93977af4e6d..1af9654cb01 100644 --- a/src/H5FDsplitter.c +++ b/src/H5FDsplitter.c @@ -104,6 +104,10 @@ static int H5FD__copy_plist(hid_t fapl_id, hid_t *id_out_ptr); /* Prototypes */ static herr_t H5FD__splitter_term(void); +static herr_t H5FD__splitter_populate_config(H5FD_splitter_vfd_config_t *vfd_config, + H5FD_splitter_fapl_t * fapl_out); +static herr_t H5FD__splitter_get_default_wo_path(char *new_path, size_t new_path_len, + const char *base_filename); static hsize_t H5FD__splitter_sb_size(H5FD_t *_file); static herr_t H5FD__splitter_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/); static herr_t H5FD__splitter_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf); @@ -129,6 +133,7 @@ static herr_t H5FD__splitter_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closin static herr_t H5FD__splitter_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); static herr_t H5FD__splitter_lock(H5FD_t *_file, hbool_t rw); static herr_t H5FD__splitter_unlock(H5FD_t *_file); +static herr_t H5FD__splitter_delete(const char *filename, hid_t fapl_id); static const H5FD_class_t H5FD_splitter_g = { H5FD_SPLITTER_VALUE, /* value */ @@ -163,7 +168,7 @@ static const H5FD_class_t H5FD_splitter_g = { H5FD__splitter_truncate, /* truncate */ H5FD__splitter_lock, /* lock */ H5FD__splitter_unlock, /* unlock */ - NULL, /* del */ + H5FD__splitter_delete, /* del */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }; @@ -310,55 +315,14 @@ H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config) if (NULL == (plist_ptr = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid property list") - /* Make sure that the W/O channel supports write-only capability. - * Some drivers (e.g. family or multi) do revision of the superblock - * in-memory, causing problems in that channel. - * Uses the feature flag H5FD_FEAT_DEFAULT_VFD_COMPATIBLE as the - * determining attribute. - */ - if (H5P_DEFAULT != vfd_config->wo_fapl_id) { - H5FD_class_t * wo_driver = NULL; - H5FD_driver_prop_t wo_driver_prop; - H5P_genplist_t * wo_plist_ptr = NULL; - unsigned long wo_driver_flags = 0; - - wo_plist_ptr = (H5P_genplist_t *)H5I_object(vfd_config->wo_fapl_id); - if (NULL == wo_plist_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - if (H5P_peek(wo_plist_ptr, H5F_ACS_FILE_DRV_NAME, &wo_driver_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID & info") - wo_driver = (H5FD_class_t *)H5I_object(wo_driver_prop.driver_id); - if (NULL == wo_driver) - HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid driver ID in file access property list") - if (H5FD_driver_query(wo_driver, &wo_driver_flags) < 0) - HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't query VFD flags") - if (0 == (H5FD_FEAT_DEFAULT_VFD_COMPATIBLE & wo_driver_flags)) - HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "unsuitable W/O driver") - } /* end if W/O VFD is non-default */ - info = H5FL_CALLOC(H5FD_splitter_fapl_t); if (NULL == info) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate file access property list struct") - info->ignore_wo_errs = vfd_config->ignore_wo_errs; - HDstrncpy(info->wo_path, vfd_config->wo_path, H5FD_SPLITTER_PATH_MAX); - HDstrncpy(info->log_file_path, vfd_config->log_file_path, H5FD_SPLITTER_PATH_MAX); - info->rw_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */ - info->wo_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */ - - /* Set non-default channel FAPL IDs in splitter configuration info */ - if (H5P_DEFAULT != vfd_config->rw_fapl_id) { - if (FALSE == H5P_isa_class(vfd_config->rw_fapl_id, H5P_FILE_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") - info->rw_fapl_id = vfd_config->rw_fapl_id; - } - if (H5P_DEFAULT != vfd_config->wo_fapl_id) { - if (FALSE == H5P_isa_class(vfd_config->wo_fapl_id, H5P_FILE_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") - info->wo_fapl_id = vfd_config->wo_fapl_id; - } + if (H5FD__splitter_populate_config(vfd_config, info) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't setup driver configuration") - ret_value = H5P_set_driver(plist_ptr, H5FD_SPLITTER, info); + ret_value = H5P_set_driver(plist_ptr, H5FD_SPLITTER, info, NULL); done: if (info) @@ -382,9 +346,10 @@ H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config) herr_t H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config /*out*/) { - const H5FD_splitter_fapl_t *fapl_ptr = NULL; - H5P_genplist_t * plist_ptr = NULL; - herr_t ret_value = SUCCEED; + const H5FD_splitter_fapl_t *fapl_ptr = NULL; + H5FD_splitter_fapl_t * default_fapl = NULL; + H5P_genplist_t * plist_ptr = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", fapl_id, config); @@ -410,8 +375,14 @@ H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config /*out*/) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") if (H5FD_SPLITTER != H5P_peek_driver(plist_ptr)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - if (NULL == (fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist_ptr))) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unable to get specific-driver info") + fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist_ptr); + if (NULL == fapl_ptr) { + if (NULL == (default_fapl = H5FL_CALLOC(H5FD_splitter_fapl_t))) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate file access property list struct") + if (H5FD__splitter_populate_config(NULL, default_fapl) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't initialize driver configuration info") + fapl_ptr = default_fapl; + } HDstrncpy(config->wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX); HDstrncpy(config->log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX); @@ -424,9 +395,185 @@ H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config /*out*/) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't copy W/O FAPL"); done: + if (default_fapl) + H5FL_FREE(H5FD_splitter_fapl_t, default_fapl); + FUNC_LEAVE_API(ret_value) } /* end H5Pget_fapl_splitter() */ +/*------------------------------------------------------------------------- + * Function: H5FD__splitter_populate_config + * + * Purpose: Populates a H5FD_splitter_fapl_t structure with the provided + * values, supplying defaults where values are not provided. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD__splitter_populate_config(H5FD_splitter_vfd_config_t *vfd_config, H5FD_splitter_fapl_t *fapl_out) +{ + H5P_genplist_t *def_plist; + H5P_genplist_t *plist; + hbool_t free_config = FALSE; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(fapl_out); + + HDmemset(fapl_out, 0, sizeof(H5FD_splitter_fapl_t)); + + if (!vfd_config) { + vfd_config = H5MM_calloc(sizeof(H5FD_splitter_vfd_config_t)); + if (NULL == vfd_config) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate file access property list struct") + + vfd_config->magic = H5FD_SPLITTER_MAGIC; + vfd_config->version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION; + vfd_config->rw_fapl_id = H5P_DEFAULT; + vfd_config->wo_fapl_id = H5P_DEFAULT; + + free_config = TRUE; + } + + /* Make sure that the W/O channel supports write-only capability. + * Some drivers (e.g. family or multi) do revision of the superblock + * in-memory, causing problems in that channel. + * Uses the feature flag H5FD_FEAT_DEFAULT_VFD_COMPATIBLE as the + * determining attribute. + */ + if (H5P_DEFAULT != vfd_config->wo_fapl_id) { + H5FD_class_t * wo_driver = NULL; + H5FD_driver_prop_t wo_driver_prop; + H5P_genplist_t * wo_plist_ptr = NULL; + unsigned long wo_driver_flags = 0; + + wo_plist_ptr = (H5P_genplist_t *)H5I_object(vfd_config->wo_fapl_id); + if (NULL == wo_plist_ptr) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + if (H5P_peek(wo_plist_ptr, H5F_ACS_FILE_DRV_NAME, &wo_driver_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID & info") + wo_driver = (H5FD_class_t *)H5I_object(wo_driver_prop.driver_id); + if (NULL == wo_driver) + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid driver ID in file access property list") + if (H5FD_driver_query(wo_driver, &wo_driver_flags) < 0) + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "can't query VFD flags") + if (0 == (H5FD_FEAT_DEFAULT_VFD_COMPATIBLE & wo_driver_flags)) + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "unsuitable W/O driver") + } /* end if W/O VFD is non-default */ + + fapl_out->ignore_wo_errs = vfd_config->ignore_wo_errs; + HDstrncpy(fapl_out->wo_path, vfd_config->wo_path, H5FD_SPLITTER_PATH_MAX); + HDstrncpy(fapl_out->log_file_path, vfd_config->log_file_path, H5FD_SPLITTER_PATH_MAX); + fapl_out->rw_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */ + fapl_out->wo_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */ + + if (NULL == (def_plist = (H5P_genplist_t *)H5I_object(H5P_FILE_ACCESS_DEFAULT))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + + /* Set non-default channel FAPL IDs in splitter configuration info */ + if (H5P_DEFAULT != vfd_config->rw_fapl_id) { + if (FALSE == H5P_isa_class(vfd_config->rw_fapl_id, H5P_FILE_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") + fapl_out->rw_fapl_id = vfd_config->rw_fapl_id; + } + else { + /* Use copy of default file access property list for R/W channel FAPL ID. + * The Sec2 driver is explicitly set on the FAPL ID, as the default + * driver might have been replaced with the Splitter VFD, which + * would cause recursion badness. + */ + if ((fapl_out->rw_fapl_id = H5P_copy_plist(def_plist, FALSE)) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTCOPY, FAIL, "can't copy property list") + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_out->rw_fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + if (H5P_set_driver_by_value(plist, H5_VFD_SEC2, NULL, TRUE) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't set default driver on R/W channel FAPL") + } + if (H5P_DEFAULT != vfd_config->wo_fapl_id) { + if (FALSE == H5P_isa_class(vfd_config->wo_fapl_id, H5P_FILE_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") + fapl_out->wo_fapl_id = vfd_config->wo_fapl_id; + } + else { + /* Use copy of default file access property list for W/O channel FAPL ID. + * The Sec2 driver is explicitly set on the FAPL ID, as the default + * driver might have been replaced with the Splitter VFD, which + * would cause recursion badness. + */ + if ((fapl_out->wo_fapl_id = H5P_copy_plist(def_plist, FALSE)) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTCOPY, FAIL, "can't copy property list") + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_out->wo_fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + if (H5P_set_driver_by_value(plist, H5_VFD_SEC2, NULL, TRUE) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't set default driver on R/W channel FAPL") + } + +done: + if (free_config && vfd_config) + H5MM_free(vfd_config); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD__splitter_populate_config() */ + +/*------------------------------------------------------------------------- + * Function: H5FD__splitter_get_default_wo_path + * + * Purpose: Given a base filename, returns a default filename for the + * W/O channel file by appending '_wo' to the base file name. + * + * Return: Non-negative on Success/Negative on Failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD__splitter_get_default_wo_path(char *new_path, size_t new_path_len, const char *base_filename) +{ + const char *suffix = "_wo"; + size_t old_filename_len = 0; + char * file_extension = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(new_path); + HDassert(base_filename); + + /* Check that output buffer can hold base filename + `_wo` suffix */ + old_filename_len = HDstrlen(base_filename); + if (old_filename_len > H5FD_SPLITTER_PATH_MAX - HDstrlen(suffix) - 1) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "filename exceeds max length") + + /* Determine if filename contains a ".h5" extension. */ + if ((file_extension = strstr(base_filename, ".h5"))) { + /* Insert the suffix between the filename and ".h5" extension. */ + HDstrcpy(new_path, base_filename); + file_extension = strstr(new_path, ".h5"); + HDsprintf(file_extension, "%s%s", suffix, ".h5"); + } + else if ((file_extension = strrchr(base_filename, '.'))) { + char *new_extension_loc = NULL; + + /* If the filename doesn't contain a ".h5" extension, but contains + * AN extension, just insert the suffix before that extension. + */ + HDstrcpy(new_path, base_filename); + new_extension_loc = strrchr(new_path, '.'); + HDsprintf(new_extension_loc, "%s%s", suffix, file_extension); + } + else { + /* If the filename doesn't contain an extension at all, just insert + * the suffix at the end of the filename. + */ + HDsnprintf(new_path, new_path_len, "%s%s", base_filename, suffix); + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD__splitter_get_default_wo_path() */ + /*------------------------------------------------------------------------- * Function: H5FD__splitter_flush * @@ -654,10 +801,11 @@ H5FD__splitter_fapl_free(void *_fapl) static H5FD_t * H5FD__splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, haddr_t maxaddr) { - H5FD_splitter_t * file_ptr = NULL; /* Splitter VFD info */ - const H5FD_splitter_fapl_t *fapl_ptr = NULL; /* Driver-specific property list */ - H5P_genplist_t * plist_ptr = NULL; - H5FD_t * ret_value = NULL; + H5FD_splitter_t * file_ptr = NULL; /* Splitter VFD info */ + const H5FD_splitter_fapl_t *fapl_ptr = NULL; /* Driver-specific property list */ + H5FD_splitter_fapl_t * default_fapl = NULL; + H5P_genplist_t * plist_ptr = NULL; + H5FD_t * ret_value = NULL; FUNC_ENTER_STATIC @@ -670,8 +818,7 @@ H5FD__splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, ha HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") - if ((H5P_FILE_ACCESS_DEFAULT == splitter_fapl_id) || (H5FD_SPLITTER != H5Pget_driver(splitter_fapl_id))) - /* presupposes that H5P_FILE_ACCESS_DEFAULT is not a splitter */ + if (H5FD_SPLITTER != H5Pget_driver(splitter_fapl_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "driver is not splitter") file_ptr = (H5FD_splitter_t *)H5FL_CALLOC(H5FD_splitter_t); @@ -685,8 +832,20 @@ H5FD__splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, ha if (NULL == plist_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist_ptr); - if (NULL == fapl_ptr) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get VFL driver info") + if (NULL == fapl_ptr) { + if (NULL == (default_fapl = H5FL_CALLOC(H5FD_splitter_fapl_t))) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "unable to allocate file access property list struct") + if (H5FD__splitter_populate_config(NULL, default_fapl) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, NULL, "can't initialize driver configuration info") + + /* If W/O path is not set, use base filename with '_wo' suffix */ + if (*default_fapl->wo_path == '\0') + if (H5FD__splitter_get_default_wo_path(default_fapl->wo_path, H5FD_SPLITTER_PATH_MAX + 1, name) < + 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, NULL, "can't generate default filename for W/O channel") + + fapl_ptr = default_fapl; + } /* Copy simpler info */ HDstrncpy(file_ptr->fa.wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX); @@ -722,6 +881,9 @@ H5FD__splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, ha ret_value = (H5FD_t *)file_ptr; done: + if (default_fapl) + H5FL_FREE(H5FD_splitter_fapl_t, default_fapl); + if (NULL == ret_value) { if (file_ptr) { if (H5I_INVALID_HID != file_ptr->fa.rw_fapl_id) @@ -1277,6 +1439,74 @@ H5FD__splitter_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__splitter_free() */ +/*------------------------------------------------------------------------- + * Function: H5FD__splitter_delete + * + * Purpose: Delete a file + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD__splitter_delete(const char *filename, hid_t fapl_id) +{ + const H5FD_splitter_fapl_t *fapl_ptr = NULL; + H5FD_splitter_fapl_t * default_fapl = NULL; + H5P_genplist_t * plist; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(filename); + + /* Get the driver info */ + if (H5P_FILE_ACCESS_DEFAULT == fapl_id) { + if (NULL == (default_fapl = H5FL_CALLOC(H5FD_splitter_fapl_t))) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate file access property list struct") + if (H5FD__splitter_populate_config(NULL, default_fapl) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't initialize driver configuration info") + + /* If W/O path is not set, use base filename with '_wo' suffix */ + if (*default_fapl->wo_path == '\0') + if (H5FD__splitter_get_default_wo_path(default_fapl->wo_path, H5FD_SPLITTER_PATH_MAX + 1, + filename) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't generate default filename for W/O channel") + + fapl_ptr = default_fapl; + } + else { + if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + if (NULL == (fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist))) { + if (NULL == (default_fapl = H5FL_CALLOC(H5FD_splitter_fapl_t))) + HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, + "unable to allocate file access property list struct") + if (H5FD__splitter_populate_config(NULL, default_fapl) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't initialize driver configuration info") + + /* If W/O path is not set, use base filename with '_wo' suffix */ + if (*default_fapl->wo_path == '\0') + if (H5FD__splitter_get_default_wo_path(default_fapl->wo_path, H5FD_SPLITTER_PATH_MAX + 1, + filename) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't generate default filename for W/O channel") + + fapl_ptr = default_fapl; + } + } + + if (H5FDdelete(filename, fapl_ptr->rw_fapl_id) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "unable to delete file") + if (H5FDdelete(fapl_ptr->wo_path, fapl_ptr->wo_fapl_id) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "unable to delete W/O channel file") + +done: + if (default_fapl) + H5FL_FREE(H5FD_splitter_fapl_t, default_fapl); + + FUNC_LEAVE_NOAPI(ret_value) +} + /*------------------------------------------------------------------------- * Function: H5FD__splitter_log_error * diff --git a/src/H5FDwindows.c b/src/H5FDwindows.c index 6ce33a746c2..fa3c05f2afa 100644 --- a/src/H5FDwindows.c +++ b/src/H5FDwindows.c @@ -56,7 +56,7 @@ H5Pset_fapl_windows(hid_t fapl_id) if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - ret_value = H5P_set_driver(plist, H5FD_WINDOWS, NULL); + ret_value = H5P_set_driver(plist, H5FD_WINDOWS, NULL, NULL); done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Fint.c b/src/H5Fint.c index c2d3e777af4..6522d42a4ab 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -454,9 +454,10 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set initial metadata cache resize config.") /* Prepare the driver property */ - driver_prop.driver_id = f->shared->lf->driver_id; - driver_prop.driver_info = H5FD_fapl_get(f->shared->lf); - driver_prop_copied = TRUE; + driver_prop.driver_id = f->shared->lf->driver_id; + driver_prop.driver_info = H5FD_fapl_get(f->shared->lf); + driver_prop.driver_config_str = H5P_peek_driver_config_str(old_plist); + driver_prop_copied = TRUE; /* Set the driver property */ if (H5P_set(new_plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index cf314b0a88f..051abd94212 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -566,12 +566,11 @@ typedef struct H5F_t H5F_t; #define H5F_ACS_SDATA_BLOCK_SIZE_NAME \ "sdata_block_size" /* Minimum "small data" allocation block size (when aggregating "small" raw data \ allocations) */ -#define H5F_ACS_GARBG_COLCT_REF_NAME "gc_ref" /* Garbage-collect references */ -#define H5F_ACS_FILE_DRV_NAME "vfd_info" /* File driver ID & info */ -#define H5F_ACS_FILE_DRV_INFO_STR_NAME "vfd_info_str" /* File driver info string */ -#define H5F_ACS_VOL_CONN_NAME "vol_connector_info" /* VOL connector ID & info */ -#define H5F_ACS_CLOSE_DEGREE_NAME "close_degree" /* File close degree */ -#define H5F_ACS_FAMILY_OFFSET_NAME "family_offset" /* Offset position in file for family file driver */ +#define H5F_ACS_GARBG_COLCT_REF_NAME "gc_ref" /* Garbage-collect references */ +#define H5F_ACS_FILE_DRV_NAME "vfd_info" /* File driver ID & info */ +#define H5F_ACS_VOL_CONN_NAME "vol_connector_info" /* VOL connector ID & info */ +#define H5F_ACS_CLOSE_DEGREE_NAME "close_degree" /* File close degree */ +#define H5F_ACS_FAMILY_OFFSET_NAME "family_offset" /* Offset position in file for family file driver */ #define H5F_ACS_FAMILY_NEWSIZE_NAME \ "family_newsize" /* New member size of family driver. (private property only used by h5repart) */ #define H5F_ACS_FAMILY_TO_SINGLE_NAME \ diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 6d58a7a433c..e0ab3d715bc 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -41,8 +41,28 @@ #include "H5VMprivate.h" /* Vector Functions */ /* Includes needed to set default file driver */ -#include "H5FDsec2.h" /* POSIX unbuffered I/O */ +#include "H5FDsec2.h" /* POSIX unbuffered I/O */ +#include "H5FDcore.h" +#include "H5FDlog.h" +#include "H5FDfamily.h" +#include "H5FDmulti.h" #include "H5FDstdio.h" /* Standard C buffered I/O */ +#include "H5FDsplitter.h" +#ifdef H5_HAVE_PARALLEL +#include "H5FDmpio.h" +#endif +#ifdef H5_HAVE_DIRECT +#include "H5FDdirect.h" +#endif +#ifdef H5_HAVE_MIRROR_VFD +#include "H5FDmirror.h" +#endif +#ifdef H5_HAVE_LIBHDFS +#include "H5FDhdfs.h" +#endif +#ifdef H5_HAVE_ROS3_VFD +#include "H5FDros3.h" +#endif #ifdef H5_HAVE_WINDOWS #include "H5FDwindows.h" /* Win32 I/O */ #endif @@ -113,7 +133,7 @@ #define H5F_ACS_FILE_DRV_SIZE sizeof(H5FD_driver_prop_t) #define H5F_ACS_FILE_DRV_DEF \ { \ - H5_DEFAULT_VFD, NULL \ + H5_DEFAULT_VFD, NULL, NULL \ } #define H5F_ACS_FILE_DRV_CRT H5P__facc_file_driver_create #define H5F_ACS_FILE_DRV_SET H5P__facc_file_driver_set @@ -122,15 +142,6 @@ #define H5F_ACS_FILE_DRV_COPY H5P__facc_file_driver_copy #define H5F_ACS_FILE_DRV_CMP H5P__facc_file_driver_cmp #define H5F_ACS_FILE_DRV_CLOSE H5P__facc_file_driver_close -/* Definition for file driver info string */ -#define H5F_ACS_FILE_DRV_INFO_STR_SIZE sizeof(const char *) -#define H5F_ACS_FILE_DRV_INFO_STR_DEF NULL -#define H5F_ACS_FILE_DRV_INFO_STR_SET H5P__facc_file_driver_info_str_set -#define H5F_ACS_FILE_DRV_INFO_STR_GET H5P__facc_file_driver_info_str_get -#define H5F_ACS_FILE_DRV_INFO_STR_DEL H5P__facc_file_driver_info_str_del -#define H5F_ACS_FILE_DRV_INFO_STR_COPY H5P__facc_file_driver_info_str_copy -#define H5F_ACS_FILE_DRV_INFO_STR_CMP H5P__facc_file_driver_info_str_cmp -#define H5F_ACS_FILE_DRV_INFO_STR_CLOSE H5P__facc_file_driver_info_str_close /* Definition for file close degree */ #define H5F_CLOSE_DEGREE_SIZE sizeof(H5F_close_degree_t) #define H5F_CLOSE_DEGREE_DEF H5F_CLOSE_DEFAULT @@ -345,14 +356,6 @@ static herr_t H5P__facc_file_driver_copy(const char *name, size_t size, void *va static int H5P__facc_file_driver_cmp(const void *value1, const void *value2, size_t size); static herr_t H5P__facc_file_driver_close(const char *name, size_t size, void *value); -/* File driver info string property callbacks */ -static herr_t H5P__facc_file_driver_info_str_set(hid_t prop_id, const char *name, size_t size, void *value); -static herr_t H5P__facc_file_driver_info_str_get(hid_t prop_id, const char *name, size_t size, void *value); -static herr_t H5P__facc_file_driver_info_str_del(hid_t prop_id, const char *name, size_t size, void *value); -static herr_t H5P__facc_file_driver_info_str_copy(const char *name, size_t size, void *value); -static int H5P__facc_file_driver_info_str_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P__facc_file_driver_info_str_close(const char *name, size_t size, void *value); - /* File image info property callbacks */ static herr_t H5P__file_image_info_copy(void *value); static herr_t H5P__file_image_info_free(void *value); @@ -415,6 +418,9 @@ static int H5P__facc_mpi_info_cmp(const void *value1, const void *value2, siz static herr_t H5P__facc_mpi_info_close(const char *name, size_t size, void *value); #endif /* H5_HAVE_PARALLEL */ +/* Internal routines */ +static inline herr_t H5P__facc_set_def_driver_check_predefined(const char *driver_name, hid_t *driver_id); + /*********************/ /* Package Variables */ /*********************/ @@ -447,7 +453,6 @@ const H5P_libclass_t H5P_CLS_FACC[1] = {{ /*******************/ /* Property value defaults */ -static const char * H5F_def_file_drv_info_str_g = H5F_ACS_FILE_DRV_INFO_STR_DEF; static const H5AC_cache_config_t H5F_def_mdc_initCacheCfg_g = H5F_ACS_META_CACHE_INIT_CONFIG_DEF; /* Default metadata cache settings */ static const size_t H5F_def_rdcc_nslots_g = @@ -614,14 +619,6 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass) H5F_ACS_FILE_DRV_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - /* Register the file driver info string */ - if (H5P__register_real(pclass, H5F_ACS_FILE_DRV_INFO_STR_NAME, H5F_ACS_FILE_DRV_INFO_STR_SIZE, - &H5F_def_file_drv_info_str_g, NULL, H5F_ACS_FILE_DRV_INFO_STR_SET, - H5F_ACS_FILE_DRV_INFO_STR_GET, NULL, NULL, H5F_ACS_FILE_DRV_INFO_STR_DEL, - H5F_ACS_FILE_DRV_INFO_STR_COPY, H5F_ACS_FILE_DRV_INFO_STR_CMP, - H5F_ACS_FILE_DRV_INFO_STR_CLOSE) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - /* Register the file close degree */ if (H5P__register_real(pclass, H5F_ACS_CLOSE_DEGREE_NAME, H5F_CLOSE_DEGREE_SIZE, &H5F_def_close_degree_g, NULL, NULL, NULL, H5F_CLOSE_DEGREE_ENC, H5F_CLOSE_DEGREE_DEC, NULL, NULL, NULL, @@ -834,6 +831,208 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass) FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_reg_prop() */ +/*------------------------------------------------------------------------- + * Function: H5P__facc_set_def_driver + * + * Purpose: Parses a string that contains the name of the default VFL + * driver for the default FAPL. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5P__facc_set_def_driver(void) +{ + const char *driver_env_var; + hbool_t driver_ref_inc = FALSE; + hid_t driver_id = H5I_INVALID_HID; /* VFL driver ID */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Check if VFL driver environment variable is set */ + driver_env_var = HDgetenv("HDF5_DRIVER"); + + /* Only parse VFL driver string if it's set */ + if (driver_env_var && *driver_env_var) { + H5FD_driver_prop_t driver_prop; + H5P_genplist_t * def_fapl; /* Default file access property list */ + H5P_genclass_t * def_fapclass; /* Default file access property class */ + const char * driver_config_env_var; + htri_t driver_is_registered; + + /* Check to see if the driver is already registered */ + if ((driver_is_registered = H5FD_is_driver_registered_by_name(driver_env_var, &driver_id)) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't check if VFL driver is already registered") + if (driver_is_registered) { + HDassert(driver_id >= 0); + + if (H5I_inc_ref(driver_id, TRUE) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTINC, FAIL, "unable to increment ref count on VFD") + driver_ref_inc = TRUE; + } /* end else-if */ + else { + /* Check for VFL drivers that ship with the library */ + if (H5P__facc_set_def_driver_check_predefined(driver_env_var, &driver_id) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't check for predefined VFL driver name") + else if (driver_id > 0) { + if (H5I_inc_ref(driver_id, TRUE) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTINC, FAIL, "can't increment VFL driver refcount") + driver_ref_inc = TRUE; + } + else { + /* Register the VFL driver */ + if ((driver_id = H5FD_register_driver_by_name(driver_env_var, TRUE)) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTREGISTER, FAIL, "can't register VFL driver") + driver_ref_inc = TRUE; + } /* end else */ + } /* end else */ + + /* Retrieve driver configuration string from environment variable, if set. */ + driver_config_env_var = HDgetenv("HDF5_DRIVER_CONFIG"); + + driver_prop.driver_id = driver_id; + driver_prop.driver_info = NULL; + driver_prop.driver_config_str = driver_config_env_var; + + /* Get default file access pclass */ + if (NULL == (def_fapclass = (H5P_genclass_t *)H5I_object(H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_VFL, H5E_BADID, FAIL, + "can't find object for default file access property class ID") + + /* Set new default VFL driver for default file access pclass */ + if (H5P__class_set(def_fapclass, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, + "can't set default VFL driver for default file access property list class") + + /* Get default file access plist */ + if (NULL == (def_fapl = (H5P_genplist_t *)H5I_object(H5P_FILE_ACCESS_DEFAULT))) + HGOTO_ERROR(H5E_VFL, H5E_BADID, FAIL, "can't find object for default fapl ID") + + /* Set new default VFL driver for default FAPL */ + if (H5P_set_driver(def_fapl, driver_prop.driver_id, driver_prop.driver_info, + driver_prop.driver_config_str) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't set default VFL driver for default FAPL") + } + +done: + /* Clean up on error */ + if (ret_value < 0) { + if (driver_id >= 0 && driver_ref_inc && H5I_dec_app_ref(driver_id) < 0) + HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "unable to unregister VFL driver") + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_set_def_driver() */ + +/*------------------------------------------------------------------------- + * Function: H5P__facc_set_def_driver_check_predefined + * + * Purpose: Checks a given driver name against a list of predefined + * names for VFL drivers that are internal to HDF5. If a name + * is matched, the ID for that driver is returned through + * `driver_id`. Otherwise, `driver_id` is set to + * H5I_INVALID_HID. + * + * Return: Non-negative on sucess/Negative on failure + * + *------------------------------------------------------------------------- + */ +static inline herr_t +H5P__facc_set_def_driver_check_predefined(const char *driver_name, hid_t *driver_id) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(driver_name); + HDassert(driver_id); + + if (!HDstrcmp(driver_name, "sec2")) { + if ((*driver_id = H5FD_SEC2) < 0) + HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize sec2 VFD") + } + else if (!HDstrcmp(driver_name, "core") || !HDstrcmp(driver_name, "core_paged")) { + if ((*driver_id = H5FD_CORE) < 0) + HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize core VFD") + } + else if (!HDstrcmp(driver_name, "log")) { + if ((*driver_id = H5FD_LOG) < 0) + HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize log VFD") + } + else if (!HDstrcmp(driver_name, "family")) { + if ((*driver_id = H5FD_FAMILY) < 0) + HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize family VFD") + } + else if (!HDstrcmp(driver_name, "multi") || !HDstrcmp(driver_name, "split")) { + if ((*driver_id = H5FD_MULTI) < 0) + HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize multi VFD") + } + else if (!HDstrcmp(driver_name, "stdio")) { + if ((*driver_id = H5FD_STDIO) < 0) + HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize stdio VFD") + } + else if (!HDstrcmp(driver_name, "splitter")) { + if ((*driver_id = H5FD_SPLITTER) < 0) + HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize splitter VFD") + } + else if (!HDstrcmp(driver_name, "mpio")) { +#ifdef H5_HAVE_PARALLEL + if ((*driver_id = H5FD_MPIO) < 0) + HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize MPI I/O VFD") +#else + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "MPI-I/O VFD is not enabled") +#endif + } + else if (!HDstrcmp(driver_name, "direct")) { +#ifdef H5_HAVE_DIRECT + if ((*driver_id = H5FD_DIRECT) < 0) + HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize Direct I/O VFD") +#else + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "Direct I/O VFD is not enabled") +#endif + } + else if (!HDstrcmp(driver_name, "mirror")) { +#ifdef H5_HAVE_MIRROR_VFD + if ((*driver_id = H5FD_MIRROR) < 0) + HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize mirror VFD") +#else + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "Mirror VFD is not enabled") +#endif + } + else if (!HDstrcmp(driver_name, "hdfs")) { +#ifdef H5_HAVE_LIBHDFS + if ((*driver_id = H5FD_HDFS) < 0) + HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize HDFS VFD") +#else + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "HDFS VFD is not enabled") +#endif + } + else if (!HDstrcmp(driver_name, "ros3")) { +#ifdef H5_HAVE_ROS3_VFD + if ((*driver_id = H5FD_ROS3) < 0) + HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize ROS3 VFD") +#else + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "ROS3 VFD is not enabled") +#endif + } + else if (!HDstrcmp(driver_name, "windows")) { +#ifdef H5_HAVE_WINDOWS + if ((*driver_id = H5FD_WINDOWS) < 0) + HGOTO_ERROR(H5E_VFL, H5E_UNINITIALIZED, FAIL, "couldn't initialize Windows VFD") +#else + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "Windows VFD is not enabled") +#endif + } + else { + *driver_id = H5I_INVALID_HID; + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_set_def_driver_check_predefined() */ + /*------------------------------------------------------------------------- * Function: H5Pset_alignment * @@ -925,42 +1124,52 @@ H5Pget_alignment(hid_t fapl_id, hsize_t *threshold /*out*/, hsize_t *alignment / } /* end H5Pget_alignment() */ /*------------------------------------------------------------------------- - * Function: H5P_set_driver + * Function: H5P_set_driver * - * Purpose: Set the file driver (DRIVER_ID) for a file access - * property list (PLIST_ID) and supply an optional - * struct containing the driver-specific properites - * (DRIVER_INFO). The driver properties will be copied into the - * property list and the reference count on the driver will be - * incremented, allowing the caller to close the driver ID but - * still use the property list. + * Purpose: Set the file driver (NEW_DRIVER_ID) for a file access + * property list (PLIST). A struct (NEW_DRIVER_INFO) or string + * (NEW_DRIVER_CONFIG_STR) containing the driver-specific + * properties can optionally be supplied. The driver properties + * (struct or string) will be copied into the property list and + * the reference count on the driver will be incremented, + * allowing the caller to close the driver ID but still use the + * property list. * - * Return: Success: Non-negative - * Failure: Negative + * Note: Only one of either NEW_DRIVER_INFO or NEW_DRIVER_CONFIG_STR + * should be specified, but not both. + * + * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke - * Tuesday, August 3, 1999 + * Tuesday, August 3, 1999 * *------------------------------------------------------------------------- */ herr_t -H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_driver_info) +H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_driver_info, + const char *new_driver_config_str) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) + /* If VFD configuration information is supplied, ensure that either binary + * configuration data or a configuration string is supplied, but not both. + */ + HDassert(!new_driver_info || !new_driver_config_str); + if (NULL == H5I_object_verify(new_driver_id, H5I_VFL)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver ID") if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ + H5FD_driver_prop_t driver_prop; /* Property for driver ID, info & config. string */ /* Prepare the driver property */ - driver_prop.driver_id = new_driver_id; - driver_prop.driver_info = new_driver_info; + driver_prop.driver_id = new_driver_id; + driver_prop.driver_info = new_driver_info; + driver_prop.driver_config_str = new_driver_config_str; - /* Set the driver ID & info property */ + /* Set the driver ID, info & config. string property */ if (H5P_set(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver ID & info") } /* end if */ @@ -1006,13 +1215,59 @@ H5Pset_driver(hid_t plist_id, hid_t new_driver_id, const void *new_driver_info) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver ID") /* Set the driver */ - if (H5P_set_driver(plist, new_driver_id, new_driver_info) < 0) + if (H5P_set_driver(plist, new_driver_id, new_driver_info, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver info") done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_driver() */ +/*------------------------------------------------------------------------- + * Function: H5P_set_driver_by_name + * + * Purpose: Set the file driver name (DRIVER_NAME) for a file access + * property list (PLIST) and supply an optional string + * containing the driver-specific properties (DRIVER_CONFIG). + * The driver properties string will be copied into the + * property list. + * + * If the file driver specified by DRIVER_NAME is not + * currently registered, an attempt will be made to load the + * driver as a plugin. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5P_set_driver_by_name(H5P_genplist_t *plist, const char *driver_name, const char *driver_config, + hbool_t app_ref) +{ + hid_t new_driver_id = H5I_INVALID_HID; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + assert(plist); + assert(driver_name); + + /* Register the driver */ + if ((new_driver_id = H5FD_register_driver_by_name(driver_name, app_ref)) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTREGISTER, FAIL, "unable to register VFD") + + /* Set the driver */ + if (H5P_set_driver(plist, new_driver_id, NULL, driver_config) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver info") + +done: + if (ret_value < 0) { + if (new_driver_id >= 0 && H5I_dec_app_ref(new_driver_id) < 0) + HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement count on VFD ID") + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P_set_driver_by_name() */ + /*------------------------------------------------------------------------- * Function: H5Pset_driver_by_name * @@ -1033,9 +1288,8 @@ H5Pset_driver(hid_t plist_id, hid_t new_driver_id, const void *new_driver_info) herr_t H5Pset_driver_by_name(hid_t plist_id, const char *driver_name, const char *driver_config) { - H5P_genplist_t *plist; /* Property list pointer */ - hid_t new_driver_id = H5I_INVALID_HID; - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*s", plist_id, driver_name, driver_config); @@ -1048,20 +1302,49 @@ H5Pset_driver_by_name(hid_t plist_id, const char *driver_name, const char *drive if (!*driver_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "driver_name parameter cannot be an empty string") + /* Set the driver */ + if (H5P_set_driver_by_name(plist, driver_name, driver_config, TRUE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver info") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_driver_by_name() */ + +/*------------------------------------------------------------------------- + * Function: H5P_set_driver_by_value + * + * Purpose: Set the file driver value (DRIVER_VALUE) for a file access + * property list (PLIST) and supply an optional string + * containing the driver-specific properties (DRIVER_CONFIG). + * The driver properties string will be copied into the + * property list. + * + * If the file driver specified by DRIVER_VALUE is not + * currently registered, an attempt will be made to load the + * driver as a plugin. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5P_set_driver_by_value(H5P_genplist_t *plist, H5FD_class_value_t driver_value, const char *driver_config, + hbool_t app_ref) +{ + hid_t new_driver_id = H5I_INVALID_HID; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + assert(plist); + assert(driver_value >= 0); + /* Register the driver */ - if ((new_driver_id = H5FD_register_driver_by_name(driver_name, TRUE)) < 0) + if ((new_driver_id = H5FD_register_driver_by_value(driver_value, app_ref)) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTREGISTER, FAIL, "unable to register VFD") - /* Set the driver info string on the property list */ - if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - if (H5P_set(plist, H5F_ACS_FILE_DRV_INFO_STR_NAME, &driver_config) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver info string") - } /* end if */ - else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - /* Set the driver */ - if (H5P_set_driver(plist, new_driver_id, NULL) < 0) + if (H5P_set_driver(plist, new_driver_id, NULL, driver_config) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver info") done: @@ -1070,8 +1353,8 @@ H5Pset_driver_by_name(hid_t plist_id, const char *driver_name, const char *drive HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement count on VFD ID") } - FUNC_LEAVE_API(ret_value) -} /* end H5Pset_driver_by_name() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P_set_driver_by_value() */ /*------------------------------------------------------------------------- * Function: H5Pset_driver_by_value @@ -1093,9 +1376,8 @@ H5Pset_driver_by_name(hid_t plist_id, const char *driver_name, const char *drive herr_t H5Pset_driver_by_value(hid_t plist_id, H5FD_class_value_t driver_value, const char *driver_config) { - H5P_genplist_t *plist; /* Property list pointer */ - hid_t new_driver_id = H5I_INVALID_HID; - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "iDV*s", plist_id, driver_value, driver_config); @@ -1106,30 +1388,13 @@ H5Pset_driver_by_value(hid_t plist_id, H5FD_class_value_t driver_value, const ch if (driver_value < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "negative VFD value is disallowed") - /* Register the driver */ - if ((new_driver_id = H5FD_register_driver_by_value(driver_value, TRUE)) < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTREGISTER, FAIL, "unable to register VFD") - - /* Set the driver info string on the property list */ - if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - if (H5P_set(plist, H5F_ACS_FILE_DRV_INFO_STR_NAME, &driver_config) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver info string") - } /* end if */ - else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - /* Set the driver */ - if (H5P_set_driver(plist, new_driver_id, NULL) < 0) + if (H5P_set_driver_by_value(plist, driver_value, driver_config, TRUE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver info") done: - if (ret_value < 0) { - if (new_driver_id >= 0 && H5I_dec_app_ref(new_driver_id) < 0) - HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement count on VFD ID") - } - FUNC_LEAVE_API(ret_value) -} /* end H5Pset_driver_by_name() */ +} /* end H5Pset_driver_by_value() */ /*------------------------------------------------------------------------- * Function: H5P_peek_driver @@ -1158,7 +1423,7 @@ H5P_peek_driver(H5P_genplist_t *plist) /* Get the current driver ID */ if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ + H5FD_driver_prop_t driver_prop; /* Property for driver ID, info & configuration string */ if (H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID") @@ -1242,7 +1507,7 @@ H5P_peek_driver_info(H5P_genplist_t *plist) /* Get the current driver info */ if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ + H5FD_driver_prop_t driver_prop; /* Property for driver ID, info & configuration string */ if (H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver info") @@ -1294,6 +1559,42 @@ H5Pget_driver_info(hid_t plist_id) FUNC_LEAVE_API(ret_value) } /* end H5Pget_driver_info() */ +/*------------------------------------------------------------------------- + * Function: H5P_peek_driver_config_str + * + * Purpose: Returns a pointer directly to the file driver configuration + * string of a file access property list. + * + * Return: Success: Ptr to *uncopied* driver configuration string, if + * any. + * + * Failure: NULL. NULL is also returned if the driver has not + * been configured with a driver configuration string. + * + *------------------------------------------------------------------------- + */ +const char * +H5P_peek_driver_config_str(H5P_genplist_t *plist) +{ + const char *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Get the current driver configuration string */ + if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { + H5FD_driver_prop_t driver_prop; /* Property for driver ID, info & configuration string */ + + if (H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver configuration string") + ret_value = driver_prop.driver_config_str; + } /* end if */ + else + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, NULL, "not a file access property list") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P_peek_driver_config_str() */ + /*------------------------------------------------------------------------- * Function: H5Pget_driver_config_str * @@ -1315,9 +1616,9 @@ H5Pget_driver_info(hid_t plist_id) ssize_t H5Pget_driver_config_str(hid_t fapl_id, char *config_buf, size_t buf_size) { - H5P_genplist_t *plist; /* Property list pointer */ - char * config_str = NULL; - ssize_t ret_value = -1; + H5P_genplist_t *plist; /* Property list pointer */ + const char * config_str = NULL; + ssize_t ret_value = -1; FUNC_ENTER_API((-1)) H5TRACE3("Zs", "i*sz", fapl_id, config_buf, buf_size); @@ -1331,10 +1632,7 @@ H5Pget_driver_config_str(hid_t fapl_id, char *config_buf, size_t buf_size) HGOTO_ERROR(H5E_ID, H5E_BADID, (-1), "can't find object for ID") /* Retrieve configuration string property */ - if (H5P_peek(plist, H5F_ACS_FILE_DRV_INFO_STR_NAME, &config_str) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, (-1), "can't get driver configuration string property") - - if (config_str) { + if ((config_str = H5P_peek_driver_config_str(plist))) { size_t config_str_len = HDstrlen(config_str); if (config_buf) { @@ -1359,7 +1657,7 @@ H5Pget_driver_config_str(hid_t fapl_id, char *config_buf, size_t buf_size) * * Note: This is an "in-place" copy, since this routine gets called * after the top-level copy has been performed and this routine - * finishes the "deep" part of the copy. + * finishes the "deep" part of the copy. * * Return: Success: Non-negative * Failure: Negative @@ -1410,6 +1708,15 @@ H5P__file_driver_copy(void *value) /* Set the driver info for the copy */ info->driver_info = new_pl; } /* end if */ + + /* Copy driver configuration string, if it exists */ + if (info->driver_config_str) { + char *new_config_str = NULL; + + if (NULL == (new_config_str = H5MM_strdup(info->driver_config_str))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "driver configuration string copy failed") + info->driver_config_str = new_config_str; + } /* end if */ } /* end if */ } /* end if */ @@ -1440,7 +1747,6 @@ H5P__file_driver_free(void *value) if (value) { H5FD_driver_prop_t *info = (H5FD_driver_prop_t *)value; /* Driver ID & info struct */ - /* Copy the driver & info, if there is one */ if (info->driver_id > 0) { /* Free the driver info, if it exists */ @@ -1448,6 +1754,9 @@ H5P__file_driver_free(void *value) if (H5FD_free_driver_info(info->driver_id, info->driver_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "driver info free request failed") + /* Free the driver configuration string, if it exists */ + H5MM_xfree_const(info->driver_config_str); + /* Decrement reference count for driver */ if (H5I_dec_ref(info->driver_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement reference count for driver ID") @@ -1667,6 +1976,16 @@ H5P__facc_file_driver_cmp(const void *_info1, const void *_info2, size_t H5_ATTR HGOTO_DONE(cmp_value); } /* end if */ + /* Compare driver configuration strings */ + if (info1->driver_config_str == NULL && info2->driver_config_str != NULL) + HGOTO_DONE(-1); + if (info1->driver_config_str != NULL && info2->driver_config_str == NULL) + HGOTO_DONE(1); + if (info1->driver_config_str) { + if (0 != (cmp_value = HDstrcmp(info1->driver_config_str, info2->driver_config_str))) + HGOTO_DONE(cmp_value); + } + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_driver_cmp() */ @@ -1699,158 +2018,6 @@ H5P__facc_file_driver_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUS FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_file_driver_close() */ -/*------------------------------------------------------------------------- - * Function: H5P__facc_file_driver_info_str_set - * - * Purpose: Copies a file driver info string when it's set for a - * property list - * - * Return: Success: Non-negative - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -static herr_t -H5P__facc_file_driver_info_str_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) -{ - FUNC_ENTER_STATIC_NOERR - - /* Sanity check */ - HDassert(value); - - /* Copy the info string */ - *(char **)value = H5MM_xstrdup(*(const char **)value); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P__facc_file_driver_info_str_set() */ - -/*------------------------------------------------------------------------- - * Function: H5P__facc_file_driver_info_str_get - * - * Purpose: Copies a file driver info string when it's retrieved from a - * property list - * - * Return: Success: Non-negative - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -static herr_t -H5P__facc_file_driver_info_str_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) -{ - FUNC_ENTER_STATIC_NOERR - - /* Sanity check */ - HDassert(value); - - /* Copy the info string */ - *(char **)value = H5MM_xstrdup(*(const char **)value); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P__facc_file_driver_info_str_get() */ - -/*------------------------------------------------------------------------- - * Function: H5P__facc_file_driver_info_str_del - * - * Purpose: Frees memory used to store the driver info string property - * - * Return: Success: Non-negative - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -static herr_t -H5P__facc_file_driver_info_str_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, - size_t H5_ATTR_UNUSED size, void *value) -{ - FUNC_ENTER_STATIC_NOERR - - HDassert(value); - - H5MM_xfree(*(void **)value); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P__facc_file_driver_info_str_del() */ - -/*------------------------------------------------------------------------- - * Function: H5P__facc_file_driver_info_str_copy - * - * Purpose: Copy callback for the file driver info string property. - * - * Return: Success: Non-negative - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -static herr_t -H5P__facc_file_driver_info_str_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) -{ - FUNC_ENTER_STATIC_NOERR - - HDassert(value); - - *(char **)value = H5MM_xstrdup(*(const char **)value); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P__facc_file_driver_info_str_copy() */ - -/*------------------------------------------------------------------------- - * Function: H5P__facc_file_driver_info_str_cmp - * - * Purpose: Callback routine which is called whenever the file - * driver info string property in the file access property - * list is compared. - * - * Return: positive if VALUE1 is greater than VALUE2, negative if - * VALUE2 is greater than VALUE1 and zero if VALUE1 and - * VALUE2 are equal. - * - *------------------------------------------------------------------------- - */ -static int -H5P__facc_file_driver_info_str_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size) -{ - const char *info_str1 = *(const char *const *)_info1; - const char *info_str2 = *(const char *const *)_info2; - int ret_value = 0; - - FUNC_ENTER_STATIC_NOERR - - if (NULL == info_str1 && NULL != info_str2) - HGOTO_DONE(1); - if (NULL != info_str1 && NULL == info_str2) - HGOTO_DONE(-1); - if (NULL != info_str1 && NULL != info_str2) - ret_value = HDstrcmp(info_str1, info_str2); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P__facc_file_driver_info_str_cmp() */ - -/*------------------------------------------------------------------------- - * Function: H5P__facc_file_driver_info_str_close - * - * Purpose: Close callback for the file driver info string property. - * - * Return: Success: Non-negative - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -static herr_t -H5P__facc_file_driver_info_str_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) -{ - FUNC_ENTER_STATIC_NOERR - - HDassert(value); - - H5MM_xfree(*(void **)value); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P__facc_file_driver_info_str_close() */ - /*------------------------------------------------------------------------- * Function: H5Pset_family_offset * diff --git a/src/H5Pint.c b/src/H5Pint.c index 9530d87a414..9206d4c04eb 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -412,20 +412,22 @@ static const H5I_class_t H5I_GENPROPLST_CLS[1] = {{ }}; /*------------------------------------------------------------------------- - * Function: H5P_init + * Function: H5P_init_phase1 * - * Purpose: Initialize the interface from some other layer. + * Purpose: Initialize the interface from some other layer. This should + * be followed with a call to H5P_init_phase2 after the H5P + * interface is completely setup. * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, March 4, 2000 * *------------------------------------------------------------------------- */ herr_t -H5P_init(void) +H5P_init_phase1(void) { herr_t ret_value = SUCCEED; /* Return value */ @@ -434,7 +436,36 @@ H5P_init(void) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_init() */ +} /* end H5P_init_phase1() */ + +/*------------------------------------------------------------------------- + * Function: H5P_init_phase2 + * + * Purpose: Finish initializing the interface from some other package. + * + * Note: This is broken out as a separate routine so that the + * library's default VFL driver can be chosen and initialized + * after the entire H5P interface has been initialized. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5P_init_phase2(void) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Set up the default VFL driver */ + if (H5P__facc_set_def_driver() < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "unable to set default VFL driver") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P_init_phase2() */ /*-------------------------------------------------------------------------- NAME @@ -449,8 +480,9 @@ DESCRIPTION herr_t H5P__init_package(void) { - size_t tot_init; /* Total # of classes initialized */ - size_t pass_init; /* # of classes initialized in each pass */ + size_t tot_init = 0; /* Total # of classes initialized */ + size_t pass_init; /* # of classes initialized in each pass */ + size_t u; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -472,8 +504,6 @@ H5P__init_package(void) */ tot_init = 0; do { - size_t u; /* Local index variable */ - /* Reset pass initialization counter */ pass_init = 0; @@ -523,6 +553,28 @@ H5P__init_package(void) HDassert(tot_init == NELMTS(init_class)); done: + if (ret_value < 0 && tot_init > 0) { + /* First uninitialize all default property lists */ + H5I_clear_type(H5I_GENPROP_LST, FALSE, FALSE); + + /* Then uninitialize any initialized libclass */ + for (u = 0; u < NELMTS(init_class); u++) { + H5P_libclass_t const *lib_class = init_class[u]; /* Current class to operate on */ + + HDassert(lib_class->class_id); + if (*lib_class->class_id >= 0) { + /* Close the class ID */ + if (H5I_dec_ref(*lib_class->class_id) < 0) + HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to close property list class ID") + } + else if (lib_class->pclass && *lib_class->pclass) { + /* Close a half-initialized pclass */ + if (H5P__close_class(*lib_class->pclass) < 0) + HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to close property list class") + } + } + } + FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__init_package() */ diff --git a/src/H5Ppkg.h b/src/H5Ppkg.h index dd43f763946..2946931aa13 100644 --- a/src/H5Ppkg.h +++ b/src/H5Ppkg.h @@ -188,6 +188,9 @@ H5_DLL herr_t H5P__decode_double(const void **_pp, void *value); H5_DLL herr_t H5P__encode_coll_md_read_flag_t(const void *value, void **_pp, size_t *size); H5_DLL herr_t H5P__decode_coll_md_read_flag_t(const void **_pp, void *value); +/* Private FAPL routines */ +H5_DLL herr_t H5P__facc_set_def_driver(void); + /* Private OCPL routines */ H5_DLL herr_t H5P__get_filter(const struct H5Z_filter_info_t *filter, unsigned int *flags, size_t *cd_nelmts, unsigned cd_values[], size_t namelen, char name[], unsigned *filter_config); diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index 6ebe5d35852..7cbb39769cd 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -156,8 +156,9 @@ struct H5O_fill_t; struct H5T_t; struct H5VL_connector_prop_t; -/* Package initialization routine */ -H5_DLL herr_t H5P_init(void); +/* Package initialization routines */ +H5_DLL herr_t H5P_init_phase1(void); +H5_DLL herr_t H5P_init_phase2(void); /* Internal versions of API routines */ H5_DLL herr_t H5P_close(H5P_genplist_t *plist); @@ -181,7 +182,13 @@ H5_DLL char * H5P_get_class_name(H5P_genclass_t *pclass); H5_DLL herr_t H5P_get_nprops_pclass(const H5P_genclass_t *pclass, size_t *nprops, hbool_t recurse); H5_DLL hid_t H5P_peek_driver(H5P_genplist_t *plist); H5_DLL const void *H5P_peek_driver_info(H5P_genplist_t *plist); -H5_DLL herr_t H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_driver_info); +H5_DLL const char *H5P_peek_driver_config_str(H5P_genplist_t *plist); +H5_DLL herr_t H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_driver_info, + const char *new_driver_config_str); +H5_DLL herr_t H5P_set_driver_by_name(H5P_genplist_t *plist, const char *driver_name, + const char *driver_config, hbool_t app_ref); +H5_DLL herr_t H5P_set_driver_by_value(H5P_genplist_t *plist, H5FD_class_value_t driver_value, + const char *driver_config, hbool_t app_ref); H5_DLL herr_t H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info); H5_DLL herr_t H5P_reset_vol_class(const H5P_genclass_t *pclass, const struct H5VL_connector_prop_t *vol_prop); H5_DLL herr_t H5P_set_vlen_mem_manager(H5P_genplist_t *plist, H5MM_allocate_t alloc_func, void *alloc_info, diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c index f109882ae85..2369be55359 100644 --- a/src/H5VLcallback.c +++ b/src/H5VLcallback.c @@ -3527,7 +3527,7 @@ H5VL__file_open_find_connector_cb(H5PL_type_t plugin_type, const void *plugin_in H5P_genplist_t * fapl_plist; H5P_genplist_t * fapl_plist_copy; hbool_t is_accessible = FALSE; /* Whether file is accessible */ - ssize_t num_errors = 0; + ssize_t num_errors = 0; herr_t status; hid_t connector_id = H5I_INVALID_HID; hid_t fapl_id = H5I_INVALID_HID; diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index bb5356dc0dd..c537f374515 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -127,10 +127,10 @@ set (HDF5_REFERENCE_TEST_FILES btree_idx_1_8.h5 corrupt_stab_msg.h5 deflate.h5 - family_v16_00000.h5 - family_v16_00001.h5 - family_v16_00002.h5 - family_v16_00003.h5 + family_v16-000000.h5 + family_v16-000001.h5 + family_v16-000002.h5 + family_v16-000003.h5 file_image_core_test.h5 filespace_1_6.h5 filespace_1_8.h5 @@ -331,7 +331,7 @@ set (test_CLEANFILES sec2_file.h5 direct_file.h5 family_file000*.h5 - new_family_v16_000*.h5 + new_family_v16-000*.h5 multi_file-*.h5 core_file filter_plugin.h5 diff --git a/test/CMakeVFDTests.cmake b/test/CMakeVFDTests.cmake index 2404d40b696..723595b851c 100644 --- a/test/CMakeVFDTests.cmake +++ b/test/CMakeVFDTests.cmake @@ -25,10 +25,29 @@ set (VFD_LIST split multi family + splitter + #log - log VFD currently has file space allocation bugs ) + if (H5_HAVE_DIRECT) set (VFD_LIST ${VFD_LIST} direct) endif () +if (H5_HAVE_PARALLEL) + # MPI I/O VFD is currently incompatible with too many tests in the VFD test set + # set (VFD_LIST ${VFD_LIST} mpio) +endif () +if (H5_HAVE_MIRROR_VFD) + set (VFD_LIST ${VFD_LIST} mirror) +endif () +if (H5_HAVE_ROS3_VFD) + set (VFD_LIST ${VFD_LIST} ros3) +endif () +if (H5_HAVE_LIBHDFS) + set (VFD_LIST ${VFD_LIST} hdfs) +endif () +if (H5_HAVE_WINDOWS) + set (VFD_LIST ${VFD_LIST} windows) +endif () foreach (vfdtest ${VFD_LIST}) file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdtest}") diff --git a/test/Makefile.am b/test/Makefile.am index 2c4b24fc688..09277b06bbd 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -117,7 +117,7 @@ if HAVE_SHARED_CONDITIONAL # The libh5test library provides common support code for the tests. # The filter_plugin* libraries are for use in filter_plugin.c. # Build them as shared libraries if that option was enabled in configure. - noinst_LTLIBRARIES=libh5test.la libfilter_plugin1_dsets.la libfilter_plugin2_dsets.la libfilter_plugin3_dsets.la libfilter_plugin4_groups.la libnull_vol_connector.la + noinst_LTLIBRARIES=libh5test.la libfilter_plugin1_dsets.la libfilter_plugin2_dsets.la libfilter_plugin3_dsets.la libfilter_plugin4_groups.la libnull_vfd_plugin.la libnull_vol_connector.la libfilter_plugin1_dsets_la_SOURCES=filter_plugin1_dsets.c libfilter_plugin2_dsets_la_SOURCES=filter_plugin2_dsets.c libfilter_plugin3_dsets_la_SOURCES=filter_plugin3_dsets.c @@ -198,7 +198,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse enum1.h5 titerate.h5 ttsafe.h5 tarray1.h5 tgenprop.h5 \ tmisc[0-9]*.h5 set_extent[1-5].h5 ext[12].bin \ getname.h5 getname[1-3].h5 sec2_file.h5 direct_file.h5 \ - family_file000[0-3][0-9].h5 new_family_v16_000[0-3][0-9].h5 \ + family_file000[0-3][0-9].h5 new_family_v16-000[0-3][0-9].h5 \ multi_file-[rs].h5 core_file filter_plugin.h5 \ new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \ dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ diff --git a/test/app_ref.c b/test/app_ref.c index 09cfb72b521..450949b43b9 100644 --- a/test/app_ref.c +++ b/test/app_ref.c @@ -79,11 +79,12 @@ Abrt_Handler(int H5_ATTR_UNUSED sig) int main(void) { - hid_t ids[T_NUMCLASSES]; - hid_t fapl; /* File Access Property List */ - int ninc; - int i; - char filename[1024]; + const char *env_h5_drvr; /* File Driver value from environment */ + hid_t ids[T_NUMCLASSES]; + hid_t fapl; /* File Access Property List */ + int ninc; + int i; + char filename[1024]; h5_reset(); h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof filename); @@ -92,6 +93,19 @@ main(void) TESTING("library shutdown with reference count > 1"); + /* Get the VFD to use */ + env_h5_drvr = HDgetenv("HDF5_DRIVER"); + if (env_h5_drvr == NULL) + env_h5_drvr = "nomatch"; + + /* Don't run this test with the multi/split VFD. A bug in library shutdown + * ordering causes problems with the multi VFD when IDs are left dangling. + */ + if (!HDstrcmp(env_h5_drvr, "multi") || !HDstrcmp(env_h5_drvr, "split")) { + HDputs("\n -- SKIPPED for incompatible VFD --"); + return 0; + } + /* Create the file */ if ((ids[T_FILE] = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR diff --git a/test/btree2.c b/test/btree2.c index aca0c776ddd..78e5a037200 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -8849,8 +8849,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); TEST_ERROR /* Check for VFD which stores data in multiple files */ - single_file_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") != 0 && HDstrcmp(env_h5_drvr, "multi") != 0 && - HDstrcmp(env_h5_drvr, "family") != 0); + single_file_vfd = !h5_driver_uses_multiple_files(env_h5_drvr, H5_EXCLUDE_NON_MULTIPART_DRIVERS); if (single_file_vfd) { /* Make a copy of the file in memory, in order to speed up deletion testing */ @@ -10135,6 +10134,11 @@ main(void) h5_reset(); fapl = h5_fileaccess(); ExpressMode = GetTestExpress(); + + /* For the Direct I/O driver, skip intensive tests due to poor performance */ + if (!HDstrcmp(envval, "direct")) + ExpressMode = 2; + if (ExpressMode > 1) HDprintf("***Express test mode on. Some tests may be skipped\n"); diff --git a/test/cache.c b/test/cache.c index 6989564ff15..e802a9b296a 100644 --- a/test/cache.c +++ b/test/cache.c @@ -35888,6 +35888,11 @@ main(void) HDprintf(" express_test = %d\n", express_test); HDprintf("=========================================\n"); + if (!h5_using_default_driver(NULL)) { + HDputs(" -- SKIPPED for incompatible VFD --"); + HDexit(EXIT_SUCCESS); + } + if (create_entry_arrays() < 0) { HDprintf("ERROR: Unable to create entries arrays. Aborting.\n"); diff --git a/test/cache_api.c b/test/cache_api.c index 7858c6573b9..432dab3a38a 100644 --- a/test/cache_api.c +++ b/test/cache_api.c @@ -306,10 +306,10 @@ check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id) pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } - else if (HDremove(filename) < 0) { + else if (H5Fdelete(filename, H5P_DEFAULT) < 0) { pass = FALSE; - failure_mssg = "HDremove() failed.\n"; + failure_mssg = "H5Fdelete() failed.\n"; } } @@ -442,28 +442,28 @@ check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id) } } - /* close the fapl used to create the file */ + /* close the file and delete it */ if (pass) { - if (H5Pclose(fapl_id) < 0) { + if (H5Fclose(file_id) < 0) { pass = FALSE; - failure_mssg = "H5Pclose() failed.\n"; + failure_mssg = "H5Fclose() failed.\n"; + } + else if (H5Fdelete(filename, fapl_id) < 0) { + + pass = FALSE; + failure_mssg = "H5Fdelete() failed.\n"; } } - /* close the file and delete it */ + /* close the fapl used to create the file */ if (pass) { - if (H5Fclose(file_id) < 0) { - - pass = FALSE; - failure_mssg = "H5Fclose() failed.\n"; - } - else if (HDremove(filename) < 0) { + if (H5Pclose(fapl_id) < 0) { pass = FALSE; - failure_mssg = "HDremove() failed.\n"; + failure_mssg = "H5Pclose() failed.\n"; } } @@ -803,10 +803,10 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } - else if (HDremove(filename) < 0) { + else if (H5Fdelete(filename, H5P_DEFAULT) < 0) { pass = FALSE; - failure_mssg = "HDremove() failed.\n"; + failure_mssg = "H5Fdelete() failed.\n"; } } @@ -1445,10 +1445,10 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } - else if (HDremove(filename) < 0) { + else if (H5Fdelete(filename, H5P_DEFAULT) < 0) { pass = FALSE; - failure_mssg = "HDremove() failed.\n"; + failure_mssg = "H5Fdelete() failed.\n"; } } @@ -2170,10 +2170,10 @@ check_file_mdc_api_errs(unsigned paged, hid_t fcpl_id) pass = FALSE; failure_mssg = "H5Fclose() failed.\n"; } - else if (HDremove(filename) < 0) { + else if (H5Fdelete(filename, H5P_DEFAULT) < 0) { pass = FALSE; - failure_mssg = "HDremove() failed.\n"; + failure_mssg = "H5Fdelete() failed.\n"; } } @@ -2258,8 +2258,13 @@ main(void) for (paged = FALSE; paged <= TRUE; paged++) { hid_t my_fcpl = fcpl_id; - if (paged) - my_fcpl = fcpl2_id; + if (paged) { + /* Only run paged aggregation tests with sec2/default driver */ + if (!h5_using_default_driver(NULL)) + continue; + else + my_fcpl = fcpl2_id; + } if (!check_fapl_mdc_api_calls(paged, my_fcpl)) nerrs += 1; diff --git a/test/cache_image.c b/test/cache_image.c index 4967066f3ca..ad0734abd5e 100644 --- a/test/cache_image.c +++ b/test/cache_image.c @@ -7853,8 +7853,7 @@ main(void) HDprintf("=========================================\n"); /* Check for VFD which stores data in multiple files */ - single_file_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") != 0 && HDstrcmp(env_h5_drvr, "multi") != 0 && - HDstrcmp(env_h5_drvr, "family") != 0); + single_file_vfd = !h5_driver_uses_multiple_files(env_h5_drvr, H5_EXCLUDE_NON_MULTIPART_DRIVERS); nerrs += check_cache_image_ctl_flow_1(single_file_vfd); nerrs += check_cache_image_ctl_flow_2(single_file_vfd); diff --git a/test/cache_tagging.c b/test/cache_tagging.c index 06de17423dd..b69a5011d5e 100644 --- a/test/cache_tagging.c +++ b/test/cache_tagging.c @@ -4572,6 +4572,12 @@ main(void) /* Open the HDF5 Library */ H5open(); + /* Only run with sec2/default driver */ + if (!h5_using_default_driver(NULL)) { + HDputs(" -- SKIPPED for incompatible VFD --"); + HDexit(EXIT_SUCCESS); + } + /* ========== */ /* Test Setup */ /* ========== */ diff --git a/test/cork.c b/test/cork.c index 80934adf5d4..584253f5e6c 100644 --- a/test/cork.c +++ b/test/cork.c @@ -26,7 +26,11 @@ */ #define H5C_FRIEND /*suppress error about including H5Cpkg */ #define H5C_TESTING /*suppress warning about H5C testing funcs*/ +#define H5FD_FRIEND /*suppress error about including H5FDpkg */ +#define H5FD_TESTING + #include "H5Cpkg.h" /* Cache */ +#include "H5FDpkg.h" /* ============ */ /* Test Defines */ @@ -2243,6 +2247,19 @@ main(void) nerrs += verify_old_dset_cork(); for (swmr = 0; swmr <= 1; swmr++) { + if (swmr) { + char *driver = NULL; + + /* Skip these tests if SWMR I/O is not supported for the VFD specified + * by the environment variable. + */ + driver = HDgetenv("HDF5_DRIVER"); + if (!H5FD__supports_swmr_test(driver)) { + HDputs("-- SKIPPED SWMR tests for SWMR-incompatible VFD --"); + continue; + } + } + /* Tests with new/old library format */ /* This is the test moved from th5o.c: test_h5o_cork() */ nerrs += test_objs_cork(swmr, TRUE); diff --git a/test/dangle.c b/test/dangle.c index d41507b6f74..5f7a84f7fe9 100644 --- a/test/dangle.c +++ b/test/dangle.c @@ -660,7 +660,21 @@ test_dangle_force(void) int main(void) { - int nerrors = 0; + const char *env_h5_drvr; /* File Driver value from environment */ + int nerrors = 0; + + /* Get the VFD to use */ + env_h5_drvr = HDgetenv("HDF5_DRIVER"); + if (env_h5_drvr == NULL) + env_h5_drvr = "nomatch"; + + /* Don't run this test with the multi/split VFD. A bug in library shutdown + * ordering causes problems with the multi VFD when IDs are left dangling. + */ + if (!HDstrcmp(env_h5_drvr, "multi") || !HDstrcmp(env_h5_drvr, "split")) { + HDputs(" -- SKIPPED for incompatible VFD --"); + return 0; + } /* Run tests w/weak file close */ HDputs("Testing dangling objects with weak file close:"); diff --git a/test/dsets.c b/test/dsets.c index 26322ad791c..6dde759b329 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -15558,6 +15558,7 @@ main(void) int nerrors = 0; const char *envval; hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + hbool_t driver_uses_modified_filename = h5_driver_uses_modified_filename(); int i; /* Don't run this test using certain file drivers */ @@ -15718,7 +15719,11 @@ main(void) nerrors += (test_multiopen(file) < 0 ? 1 : 0); nerrors += (test_types(file) < 0 ? 1 : 0); nerrors += (test_userblock_offset(envval, my_fapl, new_format) < 0 ? 1 : 0); - nerrors += (test_missing_filter(file) < 0 ? 1 : 0); + + if (!driver_uses_modified_filename) { + nerrors += (test_missing_filter(file) < 0 ? 1 : 0); + } + nerrors += (test_can_apply(file) < 0 ? 1 : 0); nerrors += (test_can_apply2(file) < 0 ? 1 : 0); nerrors += (test_optional_filters(file) < 0 ? 1 : 0); @@ -15727,7 +15732,11 @@ main(void) nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0); nerrors += (test_copy_dcpl(file, my_fapl) < 0 ? 1 : 0); nerrors += (test_filter_delete(file) < 0 ? 1 : 0); - nerrors += (test_filters_endianess() < 0 ? 1 : 0); + + if (!driver_uses_modified_filename) { + nerrors += (test_filters_endianess() < 0 ? 1 : 0); + } + nerrors += (test_zero_dims(file) < 0 ? 1 : 0); nerrors += (test_missing_chunk(file) < 0 ? 1 : 0); nerrors += (test_random_chunks(my_fapl) < 0 ? 1 : 0); @@ -15745,7 +15754,11 @@ main(void) nerrors += (test_chunk_expand(my_fapl) < 0 ? 1 : 0); nerrors += (test_layout_extend(my_fapl) < 0 ? 1 : 0); nerrors += (test_fixed_array(my_fapl) < 0 ? 1 : 0); - nerrors += (test_idx_compatible() < 0 ? 1 : 0); + + if (!driver_uses_modified_filename) { + nerrors += (test_idx_compatible() < 0 ? 1 : 0); + } + nerrors += (test_unfiltered_edge_chunks(my_fapl) < 0 ? 1 : 0); nerrors += (test_single_chunk(my_fapl) < 0 ? 1 : 0); nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0); @@ -15779,7 +15792,9 @@ main(void) nerrors += (test_gather_error() < 0 ? 1 : 0); /* Tests version bounds using its own file */ - nerrors += (test_versionbounds() < 0 ? 1 : 0); + if (!driver_uses_modified_filename) { + nerrors += (test_versionbounds() < 0 ? 1 : 0); + } /* Tests that use their own file */ nerrors += (test_object_header_minimization_dcpl() < 0 ? 1 : 0); diff --git a/test/dtransform.c b/test/dtransform.c index 9445d83eb17..645832d0962 100644 --- a/test/dtransform.c +++ b/test/dtransform.c @@ -199,6 +199,8 @@ const int transformData[ROWS][COLS] = {{36, 31, 25, 19, 13, 7, 1, 5, 11, 16, 22, COMPARE(TYPE, array, COMPARE_DATA, 2) \ } \ \ + if (H5Dclose(dset_nn) < 0) \ + TEST_ERROR; \ if (H5Dclose(dset) < 0) \ TEST_ERROR; \ if (H5Sclose(dataspace) < 0) \ diff --git a/test/dtypes.c b/test/dtypes.c index 2a183029071..321e90aa623 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -3725,53 +3725,55 @@ test_compound_18(void) if (H5Fclose(file) < 0) FAIL_STACK_ERROR - /* Open Generated File */ - /* (generated with gen_bad_compound.c) */ - if ((file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + if (!h5_driver_uses_modified_filename()) { + /* Open Generated File */ + /* (generated with gen_bad_compound.c) */ + if ((file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Try to open the datatype */ + H5E_BEGIN_TRY + { + tid = H5Topen2(file, "cmpnd", H5P_DEFAULT); + } + H5E_END_TRY; + if (tid > 0) { + H5Tclose(tid); + FAIL_PUTS_ERROR("opened named datatype with bad compound datatype") + } /* end if */ - /* Try to open the datatype */ - H5E_BEGIN_TRY - { - tid = H5Topen2(file, "cmpnd", H5P_DEFAULT); - } - H5E_END_TRY; - if (tid > 0) { - H5Tclose(tid); - FAIL_PUTS_ERROR("opened named datatype with bad compound datatype") - } /* end if */ + /* Try to open the dataset */ + H5E_BEGIN_TRY + { + did = H5Dopen2(file, "dataset", H5P_DEFAULT); + } + H5E_END_TRY; + if (did > 0) { + H5Dclose(did); + FAIL_PUTS_ERROR("opened dataset with bad compound datatype") + } /* end if */ - /* Try to open the dataset */ - H5E_BEGIN_TRY - { - did = H5Dopen2(file, "dataset", H5P_DEFAULT); - } - H5E_END_TRY; - if (did > 0) { - H5Dclose(did); - FAIL_PUTS_ERROR("opened dataset with bad compound datatype") - } /* end if */ + /* Open the group with the attribute */ + if ((gid = H5Gopen2(file, "group", H5P_DEFAULT)) < 0) + TEST_ERROR - /* Open the group with the attribute */ - if ((gid = H5Gopen2(file, "group", H5P_DEFAULT)) < 0) - TEST_ERROR + /* Try to open the dataset */ + H5E_BEGIN_TRY + { + aid = H5Aopen(gid, "attr", H5P_DEFAULT); + } + H5E_END_TRY; + if (aid > 0) { + H5Aclose(aid); + FAIL_PUTS_ERROR("opened attribute with bad compound datatype") + } /* end if */ - /* Try to open the dataset */ - H5E_BEGIN_TRY - { - aid = H5Aopen(gid, "attr", H5P_DEFAULT); + /* Close IDs */ + if (H5Gclose(gid) < 0) + FAIL_STACK_ERROR + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR } - H5E_END_TRY; - if (aid > 0) { - H5Aclose(aid); - FAIL_PUTS_ERROR("opened attribute with bad compound datatype") - } /* end if */ - - /* Close IDs */ - if (H5Gclose(gid) < 0) - FAIL_STACK_ERROR - if (H5Fclose(file) < 0) - FAIL_STACK_ERROR PASSED(); return 0; diff --git a/test/error_test.c b/test/error_test.c index cf1e82c5c7b..b90df00ed30 100644 --- a/test/error_test.c +++ b/test/error_test.c @@ -738,7 +738,7 @@ close_error(void) *------------------------------------------------------------------------- */ static herr_t -test_filter_error(const char *fname) +test_filter_error(const char *fname, hid_t fapl) { const char *pathname = H5_get_srcdir_filename(fname); /* Corrected test file name */ hid_t file = -1; @@ -748,7 +748,7 @@ test_filter_error(const char *fname) HDfprintf(stderr, "\nTesting error message during data reading when filter isn't registered\n"); /* Open the file */ - if ((file = H5Fopen(pathname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((file = H5Fopen(pathname, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR; /* Open the regular dataset */ @@ -785,9 +785,15 @@ main(void) hid_t fapl = -1; hid_t estack_id = -1; char filename[1024]; + const char *env_h5_drvr; /* File driver value from environment */ const char *FUNC_main = "main"; int i; + /* Get the VFD to use */ + env_h5_drvr = HDgetenv("HDF5_DRIVER"); + if (env_h5_drvr == NULL) + env_h5_drvr = "nomatch"; + HDfprintf(stderr, " This program tests the Error API. There're supposed to be some error messages\n"); /* Initialize errors */ @@ -877,7 +883,15 @@ main(void) * the test file was pre-generated. */ h5_fixname(DATAFILE, H5P_DEFAULT, filename, sizeof filename); - if (test_filter_error(filename) < 0) + if (!h5_using_default_driver(env_h5_drvr) && HDstrcmp(env_h5_drvr, "stdio")) { + /* If not using the library's default VFD or the stdio VFD, force + * the library's default VFD here. The test file was pre-generated + * and can cause issues with many VFDs. + */ + if (H5Pset_driver(fapl, H5_DEFAULT_VFD, NULL) < 0) + TEST_ERROR; + } + if (test_filter_error(filename, fapl) < 0) TEST_ERROR; h5_clean_files(FILENAME, fapl); diff --git a/test/family_v16_00000.h5 b/test/family_v16-000000.h5 similarity index 100% rename from test/family_v16_00000.h5 rename to test/family_v16-000000.h5 diff --git a/test/family_v16_00001.h5 b/test/family_v16-000001.h5 similarity index 100% rename from test/family_v16_00001.h5 rename to test/family_v16-000001.h5 diff --git a/test/family_v16_00002.h5 b/test/family_v16-000002.h5 similarity index 100% rename from test/family_v16_00002.h5 rename to test/family_v16-000002.h5 diff --git a/test/family_v16_00003.h5 b/test/family_v16-000003.h5 similarity index 100% rename from test/family_v16_00003.h5 rename to test/family_v16-000003.h5 diff --git a/test/file_image.c b/test/file_image.c index 0373468f3de..e2692bffcc7 100644 --- a/test/file_image.c +++ b/test/file_image.c @@ -1361,7 +1361,10 @@ main(void) errors += test_properties(); errors += test_callbacks(); - errors += test_core(); + + if (!h5_driver_uses_modified_filename()) { + errors += test_core(); + } /* Perform tests with/without user block */ for (user = FALSE; user <= TRUE; user++) { diff --git a/test/fillval.c b/test/fillval.c index 4215c891d53..e23bbc1c9c3 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -2722,7 +2722,10 @@ main(int argc, char *argv[]) nerrors += test_create(my_fapl, FILENAME[1], H5D_CONTIGUOUS); nerrors += test_rdwr(my_fapl, FILENAME[3], H5D_CONTIGUOUS); nerrors += test_extend(my_fapl, FILENAME[5], H5D_CONTIGUOUS); - nerrors += test_compatible(); + + if (!h5_driver_uses_modified_filename()) { + nerrors += test_compatible(); + } } /* end if */ /* Compact dataset storage tests */ diff --git a/test/freespace.c b/test/freespace.c index e888b2b0f29..11076094902 100644 --- a/test/freespace.c +++ b/test/freespace.c @@ -661,13 +661,16 @@ test_fs_sect_add(hid_t fapl) /* Close the file */ if (H5Fclose(file) < 0) FAIL_STACK_ERROR + sect_node = NULL; - /* Get the size of a file w/empty heap*/ - if ((tmp_file_size = h5_get_file_size(filename, fapl)) < 0) - TEST_ERROR + if (h5_using_default_driver(NULL)) { + /* Get the size of a file w/empty heap*/ + if ((tmp_file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR - if (tmp_file_size <= (file_size + fr_meta_size)) - TEST_ERROR + if (tmp_file_size <= (file_size + fr_meta_size)) + TEST_ERROR + } PASSED(); @@ -723,13 +726,16 @@ test_fs_sect_add(hid_t fapl) /* Close the file */ if (H5Fclose(file) < 0) FAIL_STACK_ERROR + sect_node = NULL; - /* Get the size of a file w/empty heap*/ - if ((tmp_file_size = h5_get_file_size(filename, fapl)) < 0) - TEST_ERROR + if (h5_using_default_driver(NULL)) { + /* Get the size of a file w/empty heap*/ + if ((tmp_file_size = h5_get_file_size(filename, fapl)) < 0) + TEST_ERROR - if (tmp_file_size != (file_size + fr_meta_size)) - TEST_ERROR + if (tmp_file_size != (file_size + fr_meta_size)) + TEST_ERROR + } PASSED(); @@ -799,6 +805,7 @@ test_fs_sect_add(hid_t fapl) /* Close the file */ if (H5Fclose(file) < 0) FAIL_STACK_ERROR + sect_node = NULL; PASSED(); @@ -878,6 +885,7 @@ test_fs_sect_add(hid_t fapl) /* Close the file */ if (H5Fclose(file) < 0) FAIL_STACK_ERROR + sect_node = NULL; PASSED(); diff --git a/test/getname.c b/test/getname.c index 200c4267577..485e3c19bc9 100644 --- a/test/getname.c +++ b/test/getname.c @@ -3775,8 +3775,12 @@ main(void) /* Call "main" test routine */ nerrors += test_main(file_id, fapl); - nerrors += test_obj_ref(fapl); - nerrors += test_reg_ref(fapl); + + if (!h5_using_parallel_driver(NULL)) { + nerrors += test_obj_ref(fapl); + nerrors += test_reg_ref(fapl); + } + nerrors += test_elinks(fapl); /* Close file */ diff --git a/test/h5test.c b/test/h5test.c index 7e9c1cc8c44..07c0a79e9b6 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -40,10 +40,7 @@ * to the cpp constant. If neither is defined then use some default value. * * HDF5_DRIVER: This string describes what low level file driver to - * use for HDF5 file access. The first word in the - * value is the name of the driver and subsequent data - * is interpreted according to the driver. See - * h5_get_vfd_fapl() for details. + * use for HDF5 file access. * * HDF5_LIBVER_BOUNDS: This string describes what library version bounds to * use for HDF5 file access. See h5_get_libver_fapl() for details. @@ -525,8 +522,8 @@ static char * h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, char *fullname, size_t size, hbool_t nest_printf, hbool_t subst_for_superblock) { - const char *prefix = NULL; - const char *env = NULL; /* HDF5_DRIVER environment variable */ + const char *prefix = NULL; + const char *driver_env_var = NULL; /* HDF5_DRIVER environment variable */ char * ptr, last = '\0'; const char *suffix = _suffix; size_t i, j; @@ -538,6 +535,13 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, char *fu HDmemset(fullname, 0, size); + /* Determine if driver is set by environment variable. If it is, + * only generate a suffix if fixing the filename for the superblock + * file. */ + driver_env_var = HDgetenv("HDF5_DRIVER"); + if (driver_env_var && (H5P_DEFAULT == fapl) && subst_for_superblock) + fapl = H5P_FILE_ACCESS_DEFAULT; + /* figure out the suffix */ if (H5P_DEFAULT != fapl) { if ((driver = H5Pget_driver(fapl)) < 0) @@ -546,28 +550,25 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, char *fu if (suffix) { if (H5FD_FAMILY == driver) { if (subst_for_superblock) - suffix = "00000.h5"; + suffix = "-000000.h5"; else - suffix = nest_printf ? "%%05d.h5" : "%05d.h5"; + suffix = nest_printf ? "-%%06d.h5" : "-%06d.h5"; } else if (H5FD_MULTI == driver) { - /* Get the environment variable, if it exists, in case + /* Check the HDF5_DRIVER environment variable in case * we are using the split driver since both of those * use the multi VFD under the hood. */ - env = HDgetenv("HDF5_DRIVER"); #ifdef HDF5_DRIVER /* Use the environment variable, then the compile-time constant */ - if (!env) - env = HDF5_DRIVER; + if (!driver_env_var) + driver_env_var = HDF5_DRIVER; #endif - if (env && !HDstrcmp(env, "split")) { + if (driver_env_var && !HDstrcmp(driver_env_var, "split")) { /* split VFD */ if (subst_for_superblock) - suffix = "-m.h5"; - else - suffix = NULL; + suffix = ".h5.meta"; } else { /* multi VFD */ @@ -583,7 +584,7 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, char *fu /* Must first check fapl is not H5P_DEFAULT (-1) because H5FD_XXX * could be of value -1 if it is not defined. */ - isppdriver = H5P_DEFAULT != fapl && (H5FD_MPIO == driver); + isppdriver = ((H5P_DEFAULT != fapl) || driver_env_var) && (H5FD_MPIO == driver); /* Check HDF5_NOCLEANUP environment setting. * (The #ifdef is needed to prevent compile failure in case MPI is not @@ -798,11 +799,7 @@ h5_fileaccess(void) if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; - /* Attempt to set up a file driver first */ - if (h5_get_vfd_fapl(fapl_id) < 0) - goto error; - - /* Finally, check for libver bounds */ + /* Check for libver bounds */ if (h5_get_libver_fapl(fapl_id) < 0) goto error; @@ -837,11 +834,7 @@ h5_fileaccess_flags(unsigned flags) if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; - /* Attempt to set up a file driver first */ - if ((flags & H5_FILEACCESS_VFD) && h5_get_vfd_fapl(fapl_id) < 0) - goto error; - - /* Finally, check for libver bounds */ + /* Check for libver bounds */ if ((flags & H5_FILEACCESS_LIBVER) && h5_get_libver_fapl(fapl_id) < 0) goto error; @@ -853,150 +846,6 @@ h5_fileaccess_flags(unsigned flags) return H5I_INVALID_HID; } /* end h5_fileaccess_flags() */ -/*------------------------------------------------------------------------- - * Function: h5_get_vfd_fapl - * - * Purpose: Sets the file driver for a FAPL according to the value specified - * in the constant or environment variable "HDF5_DRIVER". - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Dana Robinson - * February 2016 - * - *------------------------------------------------------------------------- - */ -herr_t -h5_get_vfd_fapl(hid_t fapl) -{ - const char *env = NULL; /* HDF5_DRIVER environment variable */ - const char *tok = NULL; /* strtok pointer */ - char * lasts = NULL; /* Context pointer for strtok_r() call */ - char buf[1024]; /* buffer for tokenizing HDF5_DRIVER */ - - /* Get the environment variable, if it exists */ - env = HDgetenv("HDF5_DRIVER"); -#ifdef HDF5_DRIVER - /* Use the environment variable, then the compile-time constant */ - if (!env) - env = HDF5_DRIVER; -#endif - - /* If the environment variable was not set, just return - * without modifying the FAPL. - */ - if (!env || !*env) - goto done; - - /* Get the first 'word' of the environment variable. - * If it's nothing (environment variable was whitespace) - * just return the default fapl. - */ - HDstrncpy(buf, env, sizeof(buf)); - buf[sizeof(buf) - 1] = '\0'; - if (NULL == (tok = HDstrtok_r(buf, " \t\n\r", &lasts))) - goto done; - - if (!HDstrcmp(tok, "sec2")) { - /* POSIX (section 2) read() and write() system calls */ - if (H5Pset_fapl_sec2(fapl) < 0) - goto error; - } - else if (!HDstrcmp(tok, "stdio")) { - /* Standard C fread() and fwrite() system calls */ - if (H5Pset_fapl_stdio(fapl) < 0) - goto error; - } - else if (!HDstrcmp(tok, "core")) { - /* In-memory driver settings (backing store on, 1 MB increment) */ - if (H5Pset_fapl_core(fapl, (size_t)H5_MB, TRUE) < 0) - goto error; - } - else if (!HDstrcmp(tok, "core_paged")) { - /* In-memory driver with write tracking and paging on */ - if (H5Pset_fapl_core(fapl, (size_t)H5_MB, TRUE) < 0) - goto error; - if (H5Pset_core_write_tracking(fapl, TRUE, (size_t)4096) < 0) - goto error; - } - else if (!HDstrcmp(tok, "split")) { - /* Split meta data and raw data each using default driver */ - if (H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) - goto error; - } - else if (!HDstrcmp(tok, "multi")) { - /* Multi-file driver, general case of the split driver */ - H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl[H5FD_MEM_NTYPES]; - const char *memb_name[H5FD_MEM_NTYPES]; - char * sv[H5FD_MEM_NTYPES]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - H5FD_mem_t mt; - - HDmemset(memb_map, 0, sizeof(memb_map)); - HDmemset(memb_fapl, 0, sizeof(memb_fapl)); - HDmemset(memb_name, 0, sizeof(memb_name)); - HDmemset(memb_addr, 0, sizeof(memb_addr)); - - HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES); - for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { - memb_fapl[mt] = H5P_DEFAULT; - sv[mt] = (char *)HDmalloc(H5TEST_MULTI_FILENAME_LEN); - HDassert(sv[mt]); - HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); - memb_name[mt] = sv[mt]; - memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10); - } /* end for */ - - if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0) - goto error; - - for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) - HDfree(sv[mt]); - } - else if (!HDstrcmp(tok, "family")) { - /* Family of files, each 1MB and using the default driver */ - hsize_t fam_size = 100 * 1024 * 1024; /* 100 MB */ - - /* Was a family size specified in the environment variable? */ - if ((tok = HDstrtok_r(NULL, " \t\n\r", &lasts))) - fam_size = (hsize_t)(HDstrtod(tok, NULL) * 1024 * 1024); - if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT) < 0) - goto error; - } - else if (!HDstrcmp(tok, "log")) { - /* Log file access */ - unsigned log_flags = H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC; - - /* Were special log file flags specified in the environment variable? */ - if ((tok = HDstrtok_r(NULL, " \t\n\r", &lasts))) - log_flags = (unsigned)HDstrtol(tok, NULL, 0); - - if (H5Pset_fapl_log(fapl, NULL, log_flags, (size_t)0) < 0) - goto error; -#ifdef H5_HAVE_DIRECT - } - else if (!HDstrcmp(tok, "direct")) { - /* Linux direct read() and write() system calls. Set memory boundary, - * file block size, and copy buffer size to the default values. - */ - if (H5Pset_fapl_direct(fapl, 1024, 4096, 8 * 4096) < 0) - goto error; -#endif - } - else { - /* Unknown driver */ - goto error; - } /* end if */ - -done: - return 0; - -error: - return -1; -} /* end h5_get_vfd_fapl() */ - /*------------------------------------------------------------------------- * Function: h5_get_libver_fapl * @@ -1333,30 +1182,58 @@ h5_get_file_size(const char *filename, hid_t fapl) #ifdef H5_HAVE_DIRECT driver == H5FD_DIRECT || #endif /* H5_HAVE_DIRECT */ - driver == H5FD_LOG) { + driver == H5FD_LOG || driver == H5FD_SPLITTER) { /* Get the file's statistics */ if (0 == HDstat(filename, &sb)) return ((h5_stat_size_t)sb.st_size); } /* end if */ else if (driver == H5FD_MULTI) { H5FD_mem_t mt; - h5_stat_size_t tot_size = 0; - - HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES); - for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { - /* Create the filename to query */ - HDsnprintf(temp, sizeof temp, "%s-%c.h5", filename, multi_letters[mt]); - - /* Check for existence of file */ - if (0 == HDaccess(temp, F_OK)) { - /* Get the file's statistics */ - if (0 != HDstat(temp, &sb)) - return (-1); - - /* Add to total size */ - tot_size += (h5_stat_size_t)sb.st_size; - } /* end if */ - } /* end for */ + h5_stat_size_t tot_size = 0; + char * driver_env_var = NULL; + + driver_env_var = HDgetenv("HDF5_DRIVER"); + if (driver_env_var && !HDstrcmp(driver_env_var, "split")) { + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { + if (mt != H5FD_MEM_DRAW && mt != H5FD_MEM_SUPER) + continue; + + /* Create the filename to query */ + if (mt == H5FD_MEM_DRAW) { + HDsnprintf(temp, sizeof temp, "%s.raw", filename); + } + else { + HDsnprintf(temp, sizeof temp, "%s.meta", filename); + } + + /* Check for existence of file */ + if (0 == HDaccess(temp, F_OK)) { + /* Get the file's statistics */ + if (0 != HDstat(temp, &sb)) + return (-1); + + /* Add to total size */ + tot_size += (h5_stat_size_t)sb.st_size; + } /* end if */ + } /* end for */ + } + else { + HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES); + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { + /* Create the filename to query */ + HDsnprintf(temp, sizeof temp, "%s-%c.h5", filename, multi_letters[mt]); + + /* Check for existence of file */ + if (0 == HDaccess(temp, F_OK)) { + /* Get the file's statistics */ + if (0 != HDstat(temp, &sb)) + return (-1); + + /* Add to total size */ + tot_size += (h5_stat_size_t)sb.st_size; + } /* end if */ + } /* end for */ + } /* Return total size */ return (tot_size); @@ -2289,3 +2166,137 @@ h5_check_if_file_locking_enabled(hbool_t *is_enabled) } return FAIL; } /* end h5_check_if_file_locking_enabled() */ + +/*------------------------------------------------------------------------- + * Function: h5_using_default_driver + * + * Purpose: Checks if the specified VFD name matches the library's + * default VFD. If `drv_name` is NULL, the HDF5_DRIVER + * environment is checked instead (if it is set). + * + * Return: TRUE/FALSE + * + *------------------------------------------------------------------------- + */ +hbool_t +h5_using_default_driver(const char *drv_name) +{ + hbool_t ret_val = TRUE; + + HDassert(H5_DEFAULT_VFD == H5FD_SEC2); + + if (!drv_name) + drv_name = HDgetenv("HDF5_DRIVER"); + + if (drv_name) + return (!HDstrcmp(drv_name, "sec2") || !HDstrcmp(drv_name, "nomatch")); + + return ret_val; +} + +/*------------------------------------------------------------------------- + * Function: h5_using_parallel_driver + * + * Purpose: Checks if the specified VFD name matches a parallel-enabled + * VFD (usually `mpio`). If `drv_name` is NULL, the + * HDF5_DRIVER environment is checked instead (if it is set). + * + * This is mostly useful for avoiding tests that use features + * which are not currently supported for parallel HDF5, such + * as writing of VL or region reference datatypes. + * + * Return: TRUE/FALSE + * + *------------------------------------------------------------------------- + */ +hbool_t +h5_using_parallel_driver(const char *drv_name) +{ + hbool_t ret_val = FALSE; + + if (!drv_name) + drv_name = HDgetenv("HDF5_DRIVER"); + + if (drv_name) + return (!HDstrcmp(drv_name, "mpio")); + + return ret_val; +} + +/*------------------------------------------------------------------------- + * Function: h5_driver_uses_modified_filename + * + * Purpose: Checks if the current VFD set by use of the HDF5_DRIVER + * environment variable uses a modified filename. Examples + * are the multi and family drivers. + * + * This routine is helpful for skipping tests that use + * pre-generated files. VFDs that use a modified filename will + * not be able to find these files and those tests will fail. + * Eventually, HDF5's testing framework should be modified to + * not run VFD testing against tests that use pre-generated + * files. + * + * Return: TRUE/FALSE + * + *------------------------------------------------------------------------- + */ +hbool_t +h5_driver_uses_modified_filename(void) +{ + hbool_t ret_val = FALSE; + char * driver = HDgetenv("HDF5_DRIVER"); + + if (driver) { + ret_val = !HDstrcmp(driver, "multi") || !HDstrcmp(driver, "split") || !HDstrcmp(driver, "family") || + !HDstrcmp(driver, "splitter"); + } + + return ret_val; +} /* end h5_driver_uses_modified_filename() */ + +/*------------------------------------------------------------------------- + * Function: h5_driver_uses_multiple_files + * + * Purpose: Checks if the specified VFD name matches a driver that + * stores data using multiple files. + * + * The following flags can be used to control what types of + * drivers are checked for by this routine: + * + * H5_EXCLUDE_MULTIPART_DRIVERS - This flag excludes any + * drivers which store data using multiple files which, + * together, make up a single logical file. These are + * drivers like the split, multi and family drivers. + * + * H5_EXCLUDE_NON_MULTIPART_DRIVERS - This flag excludes any + * drivers which store data using multiple files which are + * separate logical files. The splitter driver is an example + * of this type of driver. + * + * Return: TRUE/FALSE + * + *------------------------------------------------------------------------- + */ +hbool_t +h5_driver_uses_multiple_files(const char *drv_name, unsigned flags) +{ + hbool_t ret_val = FALSE; + + if (!drv_name) + drv_name = HDgetenv("HDF5_DRIVER"); + + if (drv_name) { + if ((flags & H5_EXCLUDE_MULTIPART_DRIVERS) == 0) { + if (!HDstrcmp(drv_name, "split") || !HDstrcmp(drv_name, "multi") || !HDstrcmp(drv_name, "family")) + return TRUE; + } + + if ((flags & H5_EXCLUDE_NON_MULTIPART_DRIVERS) == 0) { + if (!HDstrcmp(drv_name, "splitter")) + return TRUE; + } + } + + return ret_val; +} diff --git a/test/h5test.h b/test/h5test.h index 2855fb5b879..914a5341420 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -166,8 +166,11 @@ H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */ #define H5_ALARM_SEC 1200 /* default is 20 minutes */ /* Flags for h5_fileaccess_flags() */ -#define H5_FILEACCESS_VFD 0x01 -#define H5_FILEACCESS_LIBVER 0x02 +#define H5_FILEACCESS_LIBVER 0x01 + +/* Flags for h5_driver_uses_multiple_files() */ +#define H5_EXCLUDE_MULTIPART_DRIVERS 0x01 +#define H5_EXCLUDE_NON_MULTIPART_DRIVERS 0x02 /* Macros to create and fill 2D arrays with a single heap allocation. * These can be used to replace large stack and global arrays which raise @@ -255,9 +258,12 @@ H5TEST_DLL const char * h5_get_version_string(H5F_libver_t libver); H5TEST_DLL int h5_compare_file_bytes(char *fname1, char *fname2); H5TEST_DLL int h5_duplicate_file_by_bytes(const char *orig, const char *dest); H5TEST_DLL herr_t h5_check_if_file_locking_enabled(hbool_t *are_enabled); +H5TEST_DLL hbool_t h5_using_default_driver(const char *drv_name); +H5TEST_DLL hbool_t h5_using_parallel_driver(const char *drv_name); +H5TEST_DLL hbool_t h5_driver_uses_modified_filename(void); +H5TEST_DLL hbool_t h5_driver_uses_multiple_files(const char *drv_name, unsigned flags); /* Functions that will replace components of a FAPL */ -H5TEST_DLL herr_t h5_get_vfd_fapl(hid_t fapl_id); H5TEST_DLL herr_t h5_get_libver_fapl(hid_t fapl_id); /* h5_clean_files() replacements */ diff --git a/test/lheap.c b/test/lheap.c index 26095102c91..283c3e3728a 100644 --- a/test/lheap.c +++ b/test/lheap.c @@ -174,27 +174,29 @@ main(void) goto error; PASSED(); - /* Check opening existing file non-default sizes of lengths and addresses */ - TESTING("opening pre-created file with non-default sizes"); - { - const char *testfile = H5_get_srcdir_filename(TESTFILE); /* Corrected test file name */ - hid_t dset = -1; - file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); - if (file >= 0) { - if ((dset = H5Dopen2(file, "/Dataset1", H5P_DEFAULT)) < 0) - TEST_ERROR - if (H5Dclose(dset) < 0) - TEST_ERROR - if (H5Fclose(file) < 0) - TEST_ERROR + if (!h5_driver_uses_modified_filename()) { + /* Check opening existing file non-default sizes of lengths and addresses */ + TESTING("opening pre-created file with non-default sizes"); + { + const char *testfile = H5_get_srcdir_filename(TESTFILE); /* Corrected test file name */ + hid_t dset = -1; + file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); + if (file >= 0) { + if ((dset = H5Dopen2(file, "/Dataset1", H5P_DEFAULT)) < 0) + TEST_ERROR + if (H5Dclose(dset) < 0) + TEST_ERROR + if (H5Fclose(file) < 0) + TEST_ERROR + } + else { + H5_FAILED(); + HDprintf("***cannot open the pre-created non-default sizes test file (%s)\n", testfile); + goto error; + } /* end else */ } - else { - H5_FAILED(); - HDprintf("***cannot open the pre-created non-default sizes test file (%s)\n", testfile); - goto error; - } /* end else */ + PASSED(); } - PASSED(); /* Verify symbol table messages are cached */ if (h5_verify_cached_stabs(FILENAME, fapl) < 0) diff --git a/test/links.c b/test/links.c index f0227832a27..3b2676e5044 100644 --- a/test/links.c +++ b/test/links.c @@ -9897,7 +9897,7 @@ external_set_elink_cb(hid_t fapl, hbool_t new_format) would report FALSE, causing problems */ base_driver = H5Pget_driver(fapl); op_data.base_fapl = (base_driver == H5FD_FAMILY || base_driver == H5FD_MULTI || - base_driver == H5FD_MPIO || base_driver == H5FD_CORE) + base_driver == H5FD_MPIO || base_driver == H5FD_CORE || base_driver == H5FD_DIRECT) ? H5P_DEFAULT : fapl; op_data.fam_size = ELINK_CB_FAM_SIZE; @@ -10071,8 +10071,11 @@ external_reset_register(void) if (H5Fclose(file) < 0) TEST_ERROR - if (HDremove(filename) != 0) - TEST_ERROR + H5E_BEGIN_TRY + { + H5Fdelete(filename, H5P_DEFAULT); + } + H5E_END_TRY; PASSED(); return SUCCEED; @@ -16629,11 +16632,14 @@ link_filters(hid_t fapl, hbool_t new_format) /* Close file, get file size */ if (H5Fclose(fid) < 0) TEST_ERROR - filesize_filtered = h5_get_file_size(filename, fapl); - /* Check that the file size is smaller with the filter */ - if ((double)filesize_filtered > ((double)filesize_unfiltered * FILTER_FILESIZE_MAX_FRACTION)) - TEST_ERROR + if (h5_using_default_driver(NULL)) { + filesize_filtered = h5_get_file_size(filename, fapl); + + /* Check that the file size is smaller with the filter */ + if ((double)filesize_filtered > ((double)filesize_unfiltered * FILTER_FILESIZE_MAX_FRACTION)) + TEST_ERROR + } /* Close */ if (H5Pclose(fcpl) < 0) @@ -22544,6 +22550,7 @@ main(void) unsigned minimize_dset_oh; unsigned efc; /* Whether to use the external file cache */ const char *env_h5_drvr; /* File Driver value from environment */ + hbool_t driver_uses_modified_filename = h5_driver_uses_modified_filename(); env_h5_drvr = HDgetenv("HDF5_DRIVER"); if (env_h5_drvr == NULL) @@ -22611,88 +22618,100 @@ main(void) nerrors += test_deprec(my_fapl, new_format); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /* tests for external link */ - /* Test external file cache first, so it sees the default efc setting on the fapl - */ - nerrors += external_file_cache(my_fapl, new_format) < 0 ? 1 : 0; + /* Skip external link tests for splitter VFD, which has external link-related bugs */ + if (HDstrcmp(env_h5_drvr, "splitter")) { - /* This test cannot run with the EFC because it assumes that an - * intermediate file is not held open - */ - nerrors += external_link_mult(my_fapl, new_format) < 0 ? 1 : 0; + /* tests for external link */ + /* Test external file cache first, so it sees the default efc setting on the fapl + */ + nerrors += external_file_cache(my_fapl, new_format) < 0 ? 1 : 0; - /* This test cannot run with the EFC because the EFC cannot currently - * reopen a cached file with a different intent - */ - nerrors += external_set_elink_acc_flags(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0; + /* This test cannot run with the EFC because it assumes that an + * intermediate file is not held open + */ + nerrors += external_link_mult(my_fapl, new_format) < 0 ? 1 : 0; - /* Try external link tests both with and without the external file cache */ - for (efc = FALSE; efc <= TRUE; efc++) { - if (efc) { - if (H5Pset_elink_file_cache_size(my_fapl, 8) < 0) - TEST_ERROR - HDprintf("\n---Testing with external file cache---\n"); - } /* end if */ - else { - if (H5Pset_elink_file_cache_size(my_fapl, 0) < 0) - TEST_ERROR - HDprintf("\n---Testing without external file cache---\n"); - } /* end else */ + /* This test cannot run with the EFC because the EFC cannot currently + * reopen a cached file with a different intent + */ + nerrors += external_set_elink_acc_flags(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0; + + /* Try external link tests both with and without the external file cache */ + for (efc = FALSE; efc <= TRUE; efc++) { + if (efc) { + if (H5Pset_elink_file_cache_size(my_fapl, 8) < 0) + TEST_ERROR + HDprintf("\n---Testing with external file cache---\n"); + } /* end if */ + else { + if (H5Pset_elink_file_cache_size(my_fapl, 0) < 0) + TEST_ERROR + HDprintf("\n---Testing without external file cache---\n"); + } /* end else */ - nerrors += external_link_root(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_root(my_fapl, new_format) < 0 ? 1 : 0; #ifndef H5_NO_DEPRECATED_SYMBOLS - nerrors += external_link_root_deprec(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_root_deprec(my_fapl, new_format) < 0 ? 1 : 0; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - nerrors += external_link_path(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_self(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_pingpong(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_toomany(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_dangling(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_recursive(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_query(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_path(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_self(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_pingpong(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_toomany(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_dangling(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_recursive(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_query(my_fapl, new_format) < 0 ? 1 : 0; #ifndef H5_NO_DEPRECATED_SYMBOLS - nerrors += external_link_query_deprec(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_query_deprec(my_fapl, new_format) < 0 ? 1 : 0; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - nerrors += external_link_unlink_compact(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_unlink_dense(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_move(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_ride(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_closing(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_unlink_compact(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_unlink_dense(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_move(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_ride(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_closing(my_fapl, new_format) < 0 ? 1 : 0; #ifndef H5_NO_DEPRECATED_SYMBOLS - nerrors += external_link_closing_deprec(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_closing_deprec(my_fapl, new_format) < 0 ? 1 : 0; #endif /* H5_NO_DEPRECATED_SYMBOLS */ - nerrors += external_link_endian(new_format) < 0 ? 1 : 0; - nerrors += external_link_strong(my_fapl, new_format) < 0 ? 1 : 0; - - nerrors += external_link_prefix(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_abs_mainpath(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_rel_mainpath(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_cwd(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_abstar(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_abstar_cur(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_reltar(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_chdir(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_set_elink_fapl1(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_set_elink_fapl2(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_set_elink_fapl3(new_format) < 0 ? 1 : 0; - nerrors += external_set_elink_cb(my_fapl, new_format) < 0 ? 1 : 0; + + if (!driver_uses_modified_filename) { + nerrors += external_link_endian(new_format) < 0 ? 1 : 0; + } + + nerrors += external_link_strong(my_fapl, new_format) < 0 ? 1 : 0; + + nerrors += external_link_prefix(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_abs_mainpath(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_rel_mainpath(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_cwd(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_abstar(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_abstar_cur(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_reltar(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_chdir(my_fapl, new_format) < 0 ? 1 : 0; + + if (!driver_uses_modified_filename) { + nerrors += external_set_elink_fapl1(my_fapl, new_format) < 0 ? 1 : 0; + } + + nerrors += external_set_elink_fapl2(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_set_elink_fapl3(new_format) < 0 ? 1 : 0; + nerrors += external_set_elink_cb(my_fapl, new_format) < 0 ? 1 : 0; #ifdef H5_HAVE_WINDOW_PATH - nerrors += external_link_win1(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_win2(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_win3(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_win4(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_win5(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_win6(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_win7(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_win8(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_win9(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win1(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win2(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win3(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win4(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win5(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win6(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win7(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win8(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win9(my_fapl, new_format) < 0 ? 1 : 0; #endif - nerrors += external_symlink(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_copy_invalid_object(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_dont_fail_to_source(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_open_twice(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_with_committed_datatype(my_fapl, new_format) < 0 ? 1 : 0; - } /* with/without external file cache */ + nerrors += external_symlink(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_copy_invalid_object(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_dont_fail_to_source(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_open_twice(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_with_committed_datatype(my_fapl, new_format) < 0 ? 1 : 0; + } /* with/without external file cache */ + } /* These tests assume that external links are a form of UD links, * so assume that everything that passed for external links diff --git a/test/links_env.c b/test/links_env.c index 590be20a1bc..3d57c6597ec 100644 --- a/test/links_env.c +++ b/test/links_env.c @@ -152,8 +152,20 @@ external_link_env(hid_t fapl, hbool_t new_format) int main(void) { - hid_t fapl; /* File access property lists */ - int nerrors = 0; /* Error from tests */ + const char *env_h5_drvr; /* File driver value from environment */ + hid_t fapl; /* File access property lists */ + int nerrors = 0; /* Error from tests */ + + /* Get the VFD to use */ + env_h5_drvr = HDgetenv("HDF5_DRIVER"); + if (env_h5_drvr == NULL) + env_h5_drvr = "nomatch"; + + /* Splitter VFD has issues with external links */ + if (!HDstrcmp(env_h5_drvr, "splitter")) { + HDputs(" -- SKIPPED for incompatible VFD --"); + HDexit(EXIT_SUCCESS); + } h5_reset(); fapl = h5_fileaccess(); diff --git a/test/mf.c b/test/mf.c index 59088dc154b..d013cbf90ec 100644 --- a/test/mf.c +++ b/test/mf.c @@ -223,15 +223,16 @@ test_mf_eoa(const char *env_h5_drvr, hid_t fapl) haddr_t addr1, addr2; haddr_t ma_addr = HADDR_UNDEF, new_ma_addr = HADDR_UNDEF; hsize_t ma_size = 0; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + hbool_t suitable_vfd; TESTING("H5MM_alloc() of file allocation"); /* Skip test when using VFDs that has different address spaces for each - * type of metadata allocation. + * type of metadata allocation. Also skip test for Direct VFD. */ - contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") != 0 && HDstrcmp(env_h5_drvr, "multi") != 0); - if (contig_addr_vfd) { + suitable_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") != 0 && HDstrcmp(env_h5_drvr, "multi") != 0 && + HDstrcmp(env_h5_drvr, "direct") != 0); + if (suitable_vfd) { /* Set the filename to use for this test */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); @@ -371,15 +372,16 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) haddr_t addr = 0; haddr_t ma_addr = HADDR_UNDEF, new_ma_addr = HADDR_UNDEF; hsize_t ma_size = 0, new_ma_size = 0; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + hbool_t suitable_vfd; TESTING("H5MF_try_shrink() of file allocation: test 1"); /* Skip test when using VFDs that has different address spaces for each - * type of metadata allocation. + * type of metadata allocation. Also skip test for Direct VFD. */ - contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") != 0 && HDstrcmp(env_h5_drvr, "multi") != 0); - if (contig_addr_vfd) { + suitable_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") != 0 && HDstrcmp(env_h5_drvr, "multi") != 0 && + HDstrcmp(env_h5_drvr, "direct") != 0); + if (suitable_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); @@ -478,9 +480,9 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) TESTING("H5MF_try_shrink() of file allocation: test 2"); /* Skip test when using VFDs that has different address spaces for each - * type of metadata allocation. + * type of metadata allocation. Also skip test for Direct VFD. */ - if (contig_addr_vfd) { + if (suitable_vfd) { /* Re-open the file with meta/small data setting */ if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR @@ -528,9 +530,9 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) TESTING("H5MF_try_shrink() of file allocation: test 3"); /* Skip test when using VFDs that has different address spaces for each - * type of metadata allocation. + * type of metadata allocation. Also skip test for Direct VFD. */ - if (contig_addr_vfd) { + if (suitable_vfd) { /* Re-open the file with meta/small data setting */ if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR @@ -573,9 +575,9 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) TESTING("H5MF_try_shrink() of file allocation: test 4"); /* Skip test when using VFDs that has different address spaces for each - * type of metadata allocation. + * type of metadata allocation. Also skip test for Direct VFD. */ - if (contig_addr_vfd) { + if (suitable_vfd) { /* Re-open the file with meta/small data setting */ if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR @@ -658,15 +660,16 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) htri_t was_extended; haddr_t ma_addr = HADDR_UNDEF, new_ma_addr = HADDR_UNDEF; hsize_t ma_size = 0, new_ma_size = 0; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + hbool_t suitable_vfd; TESTING("H5MF_try_extend() of file allocation: test 1"); /* Skip test when using VFDs that has different address spaces for each - * type of metadata allocation. + * type of metadata allocation. Also skip test for Direct VFD. */ - contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") != 0 && HDstrcmp(env_h5_drvr, "multi") != 0); - if (contig_addr_vfd) { + suitable_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") != 0 && HDstrcmp(env_h5_drvr, "multi") != 0 && + HDstrcmp(env_h5_drvr, "direct") != 0); + if (suitable_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); @@ -763,9 +766,9 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) TESTING("H5MF_try_extend() of file allocation: test 2"); /* Skip test when using VFDs that has different address spaces for each - * type of metadata allocation. + * type of metadata allocation. Also skip test for Direct VFD. */ - if (contig_addr_vfd) { + if (suitable_vfd) { /* Re-open the file with meta/small data setting */ if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0) FAIL_STACK_ERROR @@ -2188,13 +2191,14 @@ test_mf_aggr_alloc1(const char *env_h5_drvr, hid_t fapl) haddr_t addr1, addr2; haddr_t ma_addr = HADDR_UNDEF; hsize_t ma_size = 0; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + hbool_t suitable_vfd; TESTING("H5MF_alloc() of meta/sdata aggregator:test 1"); - /* Skip test when using VFDs that don't use the metadata aggregator */ - contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") != 0 && HDstrcmp(env_h5_drvr, "multi") != 0); - if (contig_addr_vfd) { + /* Skip test when using VFDs that don't use the metadata aggregator. Also skip test for Direct VFD. */ + suitable_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") != 0 && HDstrcmp(env_h5_drvr, "multi") != 0 && + HDstrcmp(env_h5_drvr, "direct") != 0); + if (suitable_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); @@ -2339,13 +2343,14 @@ test_mf_aggr_alloc2(const char *env_h5_drvr, hid_t fapl) haddr_t addr1, addr2, addr3; haddr_t ma_addr = HADDR_UNDEF; hsize_t ma_size = 0; - hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ + hbool_t suitable_vfd; TESTING("H5MF_alloc() of meta/sdata aggregator:test 2"); - /* Skip test when using VFDs that don't use the metadata aggregator */ - contig_addr_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") != 0 && HDstrcmp(env_h5_drvr, "multi") != 0); - if (contig_addr_vfd) { + /* Skip test when using VFDs that don't use the metadata aggregator. Also skip test for Direct VFD. */ + suitable_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") != 0 && HDstrcmp(env_h5_drvr, "multi") != 0 && + HDstrcmp(env_h5_drvr, "direct") != 0); + if (suitable_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); @@ -3847,16 +3852,17 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) htri_t was_extended; H5FS_stat_t state; hsize_t alignment = 0, mis_align = 0, tmp = 0, accum = 0; - hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ + hbool_t suitable_vfd; TESTING("H5MM_alloc() of file allocation with alignment: test 1"); /* Skip test when using VFDs that have their own 'alloc' callback, which - * don't push mis-aligned space fragments on the file free space list + * don't push mis-aligned space fragments on the file free space list. + * Also skip test for Direct VFD. */ - have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") != 0 && HDstrcmp(env_h5_drvr, "split") != 0 && - HDstrcmp(env_h5_drvr, "multi") != 0); - if (have_alloc_vfd) { + suitable_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") != 0 && HDstrcmp(env_h5_drvr, "split") != 0 && + HDstrcmp(env_h5_drvr, "multi") != 0 && HDstrcmp(env_h5_drvr, "direct") != 0); + if (suitable_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); @@ -3966,9 +3972,10 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) TESTING("H5MF_try_shrink() of file allocation with alignment: test 2"); /* Skip test when using VFDs that have their own 'alloc' callback, which - * don't push mis-aligned space fragments on the file free space list + * don't push mis-aligned space fragments on the file free space list. + * Also skip test for Direct VFD. */ - if (have_alloc_vfd) { + if (suitable_vfd) { /* Re-open the file with alignment and meta/sdata setting */ if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0) FAIL_STACK_ERROR @@ -4023,9 +4030,10 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) TESTING("H5MF_try_extend() of file allocation with alignment: test 3"); /* Skip test when using VFDs that have their own 'alloc' callback, which - * don't push mis-aligned space fragments on the file free space list + * don't push mis-aligned space fragments on the file free space list. + * Also skip test for Direct VFD. */ - if (have_alloc_vfd) { + if (suitable_vfd) { /* Re-open the file with alignment and meta/sdata setting */ if ((file = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0) FAIL_STACK_ERROR @@ -4080,6 +4088,9 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) HDputs(" Current VFD doesn't support mis-aligned fragments"); } /* end else */ + if (fapl1 >= 0 && H5Pclose(fapl1) < 0) + FAIL_STACK_ERROR + return (0); error: @@ -4135,7 +4146,7 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) H5FS_stat_t state; htri_t was_extended; hsize_t alignment = 0, tmp = 0, mis_align = 0; - hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ + hbool_t suitable_vfd; TESTING("H5MF_alloc() of free-space manager with alignment: test 1"); @@ -4297,10 +4308,11 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) /* Skip test when using VFDs that have their own 'alloc' callback, which * don't push mis-aligned space fragments on the file free space list + * Also skip test for Direct VFD. */ - have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") != 0 && HDstrcmp(env_h5_drvr, "split") != 0 && - HDstrcmp(env_h5_drvr, "multi") != 0); - if (have_alloc_vfd) { + suitable_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") != 0 && HDstrcmp(env_h5_drvr, "split") != 0 && + HDstrcmp(env_h5_drvr, "multi") != 0 && HDstrcmp(env_h5_drvr, "direct") != 0); + if (suitable_vfd) { if ((file_size = h5_get_file_size(filename, new_fapl)) < 0) TEST_ERROR @@ -4497,16 +4509,17 @@ test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) haddr_t ma_addr = HADDR_UNDEF; hsize_t ma_size = 0, mis_align = 0; hsize_t alignment = 0, tmp = 0; - hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ + hbool_t suitable_vfd; TESTING("H5MF_alloc() of meta/sdata aggregator with alignment: test 1"); /* Skip test when using VFDs that have their own 'alloc' callback, which - * don't push mis-aligned space fragments on the file free space list + * don't push mis-aligned space fragments on the file free space list. + * Also skip test for Direct VFD. */ - have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") != 0 && HDstrcmp(env_h5_drvr, "split") != 0 && - HDstrcmp(env_h5_drvr, "multi") != 0); - if (have_alloc_vfd) { + suitable_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") != 0 && HDstrcmp(env_h5_drvr, "split") != 0 && + HDstrcmp(env_h5_drvr, "multi") != 0 && HDstrcmp(env_h5_drvr, "direct") != 0); + if (suitable_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); @@ -4759,16 +4772,17 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) haddr_t ma_addr = HADDR_UNDEF, sdata_addr = HADDR_UNDEF; hsize_t ma_size = 0, sdata_size = 0, mis_align = 0; hsize_t alignment = 0, tmp = 0; - hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ + hbool_t suitable_vfd; TESTING("H5MF_alloc() of meta/sdata aggregator with alignment: test 2"); /* Skip test when using VFDs that have their own 'alloc' callback, which - * don't push mis-aligned space fragments on the file free space list + * don't push mis-aligned space fragments on the file free space list. + * Also skip test for Direct VFD. */ - have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") != 0 && HDstrcmp(env_h5_drvr, "split") != 0 && - HDstrcmp(env_h5_drvr, "multi") != 0); - if (have_alloc_vfd) { + suitable_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") != 0 && HDstrcmp(env_h5_drvr, "split") != 0 && + HDstrcmp(env_h5_drvr, "multi") != 0 && HDstrcmp(env_h5_drvr, "direct") != 0); + if (suitable_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); @@ -5104,16 +5118,17 @@ test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) haddr_t ma_addr = HADDR_UNDEF, sdata_addr = HADDR_UNDEF; hsize_t ma_size = 0, sdata_size = 0, mis_align = 0; hsize_t alignment = 0, tmp = 0; - hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ + hbool_t suitable_vfd; TESTING("H5MF_alloc() of meta/sdata aggregator with alignment: test 3"); /* Skip test when using VFDs that have their own 'alloc' callback, which - * don't push mis-aligned space fragments on the file free space list + * don't push mis-aligned space fragments on the file free space list. + * Also skip test for Direct VFD. */ - have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") != 0 && HDstrcmp(env_h5_drvr, "split") != 0 && - HDstrcmp(env_h5_drvr, "multi") != 0); - if (have_alloc_vfd) { + suitable_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") != 0 && HDstrcmp(env_h5_drvr, "split") != 0 && + HDstrcmp(env_h5_drvr, "multi") != 0 && HDstrcmp(env_h5_drvr, "direct") != 0); + if (suitable_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); @@ -5417,16 +5432,17 @@ test_mf_align_alloc4(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) haddr_t ma_addr = HADDR_UNDEF; hsize_t ma_size = 0, saved_ma_size = 0; hsize_t alignment = 0, mis_align = 0, tmp = 0; - hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ + hbool_t suitable_vfd; TESTING("H5MF_alloc() of meta/sdata aggregator with alignment: test 4"); /* Skip test when using VFDs that have their own 'alloc' callback, which - * don't push mis-aligned space fragments on the file free space list + * don't push mis-aligned space fragments on the file free space list. + * Also skip test for Direct VFD. */ - have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") != 0 && HDstrcmp(env_h5_drvr, "split") != 0 && - HDstrcmp(env_h5_drvr, "multi") != 0); - if (have_alloc_vfd) { + suitable_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") != 0 && HDstrcmp(env_h5_drvr, "split") != 0 && + HDstrcmp(env_h5_drvr, "multi") != 0 && HDstrcmp(env_h5_drvr, "direct") != 0); + if (suitable_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); @@ -5635,16 +5651,17 @@ test_mf_align_alloc5(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) haddr_t sdata_addr = HADDR_UNDEF, new_sdata_addr = HADDR_UNDEF; hsize_t ma_size = 0, new_ma_size = 0, sdata_size = 0, new_sdata_size = 0; hsize_t alignment = 0, mis_align = 0, tmp = 0; - hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ + hbool_t suitable_vfd; TESTING("H5MF_alloc() of meta/sdata aggregator with alignment: test 5"); /* Skip test when using VFDs that have their own 'alloc' callback, which - * don't push mis-aligned space fragments on the file free space list + * don't push mis-aligned space fragments on the file free space list. + * Also skip test for Direct VFD. */ - have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") != 0 && HDstrcmp(env_h5_drvr, "split") != 0 && - HDstrcmp(env_h5_drvr, "multi") != 0); - if (have_alloc_vfd) { + suitable_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") != 0 && HDstrcmp(env_h5_drvr, "split") != 0 && + HDstrcmp(env_h5_drvr, "multi") != 0 && HDstrcmp(env_h5_drvr, "direct") != 0); + if (suitable_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); @@ -5905,16 +5922,17 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) haddr_t ma_addr = HADDR_UNDEF, new_ma_addr = HADDR_UNDEF, sdata_addr = HADDR_UNDEF; hsize_t ma_size = 0, new_ma_size = 0, sdata_size = 0; hsize_t alignment = 0, mis_align = 0, tmp = 0; - hbool_t have_alloc_vfd; /* Whether VFD used has an 'alloc' callback */ + hbool_t suitable_vfd; TESTING("H5MF_alloc() of meta/sdata aggregator with alignment: test 6"); /* Skip test when using VFDs that have their own 'alloc' callback, which - * don't push mis-aligned space fragments on the file free space list + * don't push mis-aligned space fragments on the file free space list. + * Also skip test for Direct VFD. */ - have_alloc_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") != 0 && HDstrcmp(env_h5_drvr, "split") != 0 && - HDstrcmp(env_h5_drvr, "multi") != 0); - if (have_alloc_vfd) { + suitable_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "stdio") != 0 && HDstrcmp(env_h5_drvr, "split") != 0 && + HDstrcmp(env_h5_drvr, "multi") != 0 && HDstrcmp(env_h5_drvr, "direct") != 0); + if (suitable_vfd) { /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); @@ -6139,20 +6157,23 @@ test_mf_bug1(const char *env_h5_drvr, hid_t fapl) /* Add alignment to member files for split/multi driver */ if (split || multi) { - hid_t memb_fapl; + if (split) { + hid_t memb_fapl_arr[H5FD_MEM_NTYPES]; - /* Creat fapl */ - if ((memb_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - TEST_ERROR + /* Get current multi settings */ + if (H5Pget_fapl_multi(copied_fapl, NULL, memb_fapl_arr, NULL, NULL, NULL) < 0) + TEST_ERROR - /* Set alignment. Note that it is the block size of the parent FAPL that - * is important here. */ - if (H5Pset_alignment(memb_fapl, 0, align) < 0) - TEST_ERROR + /* Set alignment. Note that it is the block size of the parent FAPL that + * is important here. */ + if (H5Pset_alignment(memb_fapl_arr[H5FD_MEM_SUPER], 0, align) < 0) + TEST_ERROR + if (H5Pset_alignment(memb_fapl_arr[H5FD_MEM_DRAW], 0, align) < 0) + TEST_ERROR - if (split) { /* Set split driver with new FAPLs */ - if (H5Pset_fapl_split(copied_fapl, "-m.h5", memb_fapl, "-r.h5", memb_fapl) < 0) + if (H5Pset_fapl_split(copied_fapl, "-m.h5", memb_fapl_arr[H5FD_MEM_SUPER], "-r.h5", + memb_fapl_arr[H5FD_MEM_DRAW]) < 0) TEST_ERROR } /* end if */ else { @@ -6165,14 +6186,17 @@ test_mf_bug1(const char *env_h5_drvr, hid_t fapl) /* Get current multi settings */ HDmemset(memb_name, 0, sizeof memb_name); - if (H5Pget_fapl_multi(copied_fapl, memb_map, NULL, memb_name, memb_addr, &relax) < 0) + if (H5Pget_fapl_multi(copied_fapl, memb_map, memb_fapl_arr, memb_name, memb_addr, &relax) < 0) TEST_ERROR /* Populate memb_fapl_arr, patch memb_addr so member file addresses * are aligned */ for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { - memb_fapl_arr[mt] = memb_fapl; - memb_addr[mt] = ((memb_addr[mt] + align - 1) / align) * align; + /* Set alignment. Note that it is the block size of the parent FAPL that + * is important here. */ + if (H5Pset_alignment(memb_fapl_arr[mt], 0, align) < 0) + TEST_ERROR + memb_addr[mt] = ((memb_addr[mt] + align - 1) / align) * align; } /* end for */ /* Set multi driver with new FAPLs */ @@ -6184,11 +6208,7 @@ test_mf_bug1(const char *env_h5_drvr, hid_t fapl) for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) HDfree(memb_name[mt]); } /* end else */ - - /* Close memb_fapl */ - if (H5Pclose(memb_fapl) < 0) - TEST_ERROR - } /* end if */ + } /* end if */ /* Reopen the file with alignment */ if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, copied_fapl)) < 0) @@ -6253,6 +6273,9 @@ test_mf_bug1(const char *env_h5_drvr, hid_t fapl) PASSED(); + if (H5Pclose(copied_fapl) < 0) + TEST_ERROR + /* Close file */ if (H5Fclose(file) < 0) TEST_ERROR diff --git a/test/mtime.c b/test/mtime.c index 43dc502293e..10cafd1059f 100644 --- a/test/mtime.c +++ b/test/mtime.c @@ -60,6 +60,7 @@ main(void) signed char buf1[32], buf2[32]; char filename[1024]; int token_cmp; + hbool_t driver_uses_modified_filename = h5_driver_uses_modified_filename(); h5_reset(); fapl = h5_fileaccess(); @@ -131,63 +132,67 @@ main(void) } PASSED(); - /* Check opening existing file with old-style modification time information - * and make certain that the time is correct - */ - TESTING("accessing old modification time messages"); - - { - const char *testfile = H5_get_srcdir_filename(TESTFILE1); /* Corrected test file name */ - - file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); - if (file >= 0) { - if (H5Oget_info_by_name3(file, "/Dataset1", &oi1, H5O_INFO_TIME, H5P_DEFAULT) < 0) - TEST_ERROR; - if (oi1.ctime != MTIME1) { + if (!driver_uses_modified_filename) { + /* Check opening existing file with old-style modification time information + * and make certain that the time is correct + */ + TESTING("accessing old modification time messages"); + + { + const char *testfile = H5_get_srcdir_filename(TESTFILE1); /* Corrected test file name */ + + file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); + if (file >= 0) { + if (H5Oget_info_by_name3(file, "/Dataset1", &oi1, H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR; + if (oi1.ctime != MTIME1) { + H5_FAILED(); + /* If this fails, examine H5Omtime.c. Modification time is very + * system dependent (e.g., on Windows DST must be hardcoded). */ + HDputs(" Old modification time incorrect"); + goto error; + } + if (H5Fclose(file) < 0) + TEST_ERROR; + } + else { H5_FAILED(); - /* If this fails, examine H5Omtime.c. Modification time is very - * system dependent (e.g., on Windows DST must be hardcoded). */ - HDputs(" Old modification time incorrect"); + HDprintf("***cannot open the pre-created old modification test file (%s)\n", testfile); goto error; - } - if (H5Fclose(file) < 0) - TEST_ERROR; + } /* end else */ } - else { - H5_FAILED(); - HDprintf("***cannot open the pre-created old modification test file (%s)\n", testfile); - goto error; - } /* end else */ + PASSED(); } - PASSED(); - /* Check opening existing file with new-style modification time information - * and make certain that the time is correct - */ - TESTING("accessing new modification time messages"); - - { - const char *testfile = H5_get_srcdir_filename(TESTFILE2); /* Corrected test file name */ - - file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); - if (file >= 0) { - if (H5Oget_info_by_name3(file, "/Dataset1", &oi2, H5O_INFO_TIME, H5P_DEFAULT) < 0) - TEST_ERROR; - if (oi2.ctime != MTIME2) { + if (!driver_uses_modified_filename) { + /* Check opening existing file with new-style modification time information + * and make certain that the time is correct + */ + TESTING("accessing new modification time messages"); + + { + const char *testfile = H5_get_srcdir_filename(TESTFILE2); /* Corrected test file name */ + + file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); + if (file >= 0) { + if (H5Oget_info_by_name3(file, "/Dataset1", &oi2, H5O_INFO_TIME, H5P_DEFAULT) < 0) + TEST_ERROR; + if (oi2.ctime != MTIME2) { + H5_FAILED(); + HDputs(" Modification time incorrect."); + goto error; + } + if (H5Fclose(file) < 0) + TEST_ERROR; + } + else { H5_FAILED(); - HDputs(" Modification time incorrect."); + HDprintf("***cannot open the pre-created old modification test file (%s)\n", testfile); goto error; - } - if (H5Fclose(file) < 0) - TEST_ERROR; + } /* end else */ } - else { - H5_FAILED(); - HDprintf("***cannot open the pre-created old modification test file (%s)\n", testfile); - goto error; - } /* end else */ + PASSED(); } - PASSED(); /* Verify symbol table messages are cached */ if (h5_verify_cached_stabs(FILENAME, fapl) < 0) diff --git a/test/ntypes.c b/test/ntypes.c index 13cc72a939c..37a63a4bb06 100644 --- a/test/ntypes.c +++ b/test/ntypes.c @@ -3131,11 +3131,19 @@ main(void) nerrors += test_enum_dtype(file) < 0 ? 1 : 0; nerrors += test_array_dtype(file) < 0 ? 1 : 0; nerrors += test_array_dtype2(file) < 0 ? 1 : 0; - nerrors += test_vl_dtype(file) < 0 ? 1 : 0; - nerrors += test_vlstr_dtype(file) < 0 ? 1 : 0; + + if (!h5_using_parallel_driver(NULL)) { + nerrors += test_vl_dtype(file) < 0 ? 1 : 0; + nerrors += test_vlstr_dtype(file) < 0 ? 1 : 0; + } + nerrors += test_str_dtype(file) < 0 ? 1 : 0; - nerrors += test_refer_dtype(file) < 0 ? 1 : 0; - nerrors += test_refer_dtype2(file) < 0 ? 1 : 0; + + if (!h5_using_parallel_driver(NULL)) { + nerrors += test_refer_dtype(file) < 0 ? 1 : 0; + nerrors += test_refer_dtype2(file) < 0 ? 1 : 0; + } + nerrors += test_opaque_dtype(file) < 0 ? 1 : 0; nerrors += test_bitfield_dtype(file) < 0 ? 1 : 0; nerrors += test_ninteger() < 0 ? 1 : 0; diff --git a/test/null_vfd_plugin.c b/test/null_vfd_plugin.c index b4439033113..e01b2002713 100644 --- a/test/null_vfd_plugin.c +++ b/test/null_vfd_plugin.c @@ -14,7 +14,7 @@ * that is used for testing basic VFD plugin handling (registration, etc.). */ -/* Public HDF5 header */ +/* Public HDF5 headers */ #include "hdf5.h" /* For HDF5 plugin functionality */ @@ -25,13 +25,13 @@ /* Prototypes */ static H5FD_t *H5FD_null_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); -static herr_t H5FD_null_close(H5FD_t *_file); -static herr_t H5FD_null_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, - size_t size, void *buf); -static herr_t H5FD_null_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, - size_t size, const void *buf); +static herr_t H5FD_null_close(H5FD_t *_file); +static herr_t H5FD_null_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + void *buf); +static herr_t H5FD_null_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, + const void *buf); static haddr_t H5FD_null_get_eoa(const H5FD_t *_file, H5FD_mem_t type); -static herr_t H5FD_null_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); +static herr_t H5FD_null_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD_null_get_eof(const H5FD_t *_file, H5FD_mem_t type); static const H5FD_class_t H5FD_null_g = { @@ -84,15 +84,13 @@ H5FD_null_close(H5FD_t *_file) } static herr_t -H5FD_null_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, - size_t size, void *buf) +H5FD_null_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf) { return 0; } static herr_t -H5FD_null_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, - const void *buf) +H5FD_null_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf) { return 0; } diff --git a/test/objcopy.c b/test/objcopy.c index e01083d4501..40562c156b0 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -17305,13 +17305,18 @@ test_copy_dataset_open(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst int main(void) { - int nerrors = 0; - hid_t fapl, fapl2; - hid_t fcpl_shared, ocpl; - unsigned max_compact, min_dense; - int configuration; /* Configuration of tests. */ - int ExpressMode; - hbool_t same_file; /* Whether to run tests that only use one file */ + int nerrors = 0; + hid_t fapl, fapl2; + hid_t fcpl_shared, ocpl; + unsigned max_compact, min_dense; + int configuration; /* Configuration of tests. */ + int ExpressMode; + const char *env_h5_drvr; /* File Driver value from environment */ + hbool_t same_file; /* Whether to run tests that only use one file */ + + env_h5_drvr = HDgetenv("HDF5_DRIVER"); + if (env_h5_drvr == NULL) + env_h5_drvr = "nomatch"; /* Setup */ h5_reset(); @@ -17468,9 +17473,14 @@ 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"); - 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"); + + /* Splitter VFD currently has external link-related bugs */ + if (HDstrcmp(env_h5_drvr, "splitter")) { + 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"); + } + nerrors += test_copy_option(fcpl_src, fcpl_dst, src_fapl, dst_fapl, H5O_COPY_SHALLOW_HIERARCHY_FLAG, FALSE, "H5Ocopy(): shallow group copy"); nerrors += test_copy_option(fcpl_src, fcpl_dst, src_fapl, dst_fapl, H5O_COPY_EXPAND_REFERENCE_FLAG, @@ -17548,9 +17558,14 @@ main(void) nerrors += test_copy_same_file_named_datatype(fcpl_src, src_fapl); - /* Test with dataset opened in the file or not */ - nerrors += test_copy_old_layout(fcpl_dst, dst_fapl, FALSE); - nerrors += test_copy_old_layout(fcpl_dst, dst_fapl, TRUE); + /* Check if current driver might modify the filename. Skip these tests + * if so, since the file is pre-generated. + */ + if (!h5_driver_uses_modified_filename()) { + /* Test with dataset opened in the file or not */ + nerrors += test_copy_old_layout(fcpl_dst, dst_fapl, FALSE); + nerrors += test_copy_old_layout(fcpl_dst, dst_fapl, TRUE); + } /* Test with dataset opened in the file or not */ nerrors += test_copy_null_ref(fcpl_src, fcpl_dst, src_fapl, dst_fapl); diff --git a/test/ohdr.c b/test/ohdr.c index b7af77fe4e6..033a46928dc 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -34,6 +34,13 @@ #define H5G_FRIEND /* suppress error about including H5Gpkg */ #include "H5Gpkg.h" +/* + * This file needs to access private routines from the H5FD package. + */ +#define H5FD_FRIEND /* suppress error about including H5FDpkg */ +#define H5FD_TESTING +#include "H5FDpkg.h" + const char *FILENAME[] = {"ohdr", "ohdr_min_a", "ohdr_min_b", NULL}; /* used for object header size comparison */ @@ -1765,8 +1772,7 @@ main(void) env_h5_drvr = "nomatch"; /* Check for VFD which stores data in multiple files */ - single_file_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") != 0 && HDstrcmp(env_h5_drvr, "multi") != 0 && - HDstrcmp(env_h5_drvr, "family") != 0); + single_file_vfd = !h5_driver_uses_multiple_files(env_h5_drvr, 0); /* Reset library */ h5_reset(); @@ -2051,11 +2057,15 @@ main(void) if (h5_verify_cached_stabs(FILENAME, fapl) < 0) TEST_ERROR - /* A test to exercise the re-read of the object header for SWMR access */ - if (test_ohdr_swmr(TRUE) < 0) - TEST_ERROR - if (test_ohdr_swmr(FALSE) < 0) - TEST_ERROR + if (H5FD__supports_swmr_test(env_h5_drvr)) { + /* A test to exercise the re-read of the object header for SWMR access */ + if (test_ohdr_swmr(TRUE) < 0) + TEST_ERROR + if (test_ohdr_swmr(FALSE) < 0) + TEST_ERROR + } + else + HDputs("Skipped SWMR tests for SWMR-incompatible VFD"); /* Pop API context */ if (api_ctx_pushed && H5CX_pop(FALSE) < 0) diff --git a/test/set_extent.c b/test/set_extent.c index 5a07362464c..06656e878c0 100644 --- a/test/set_extent.c +++ b/test/set_extent.c @@ -343,35 +343,42 @@ do_ranks(hid_t fapl, hbool_t new_format) goto error; } /* end if */ - /* VL test */ - if (test_random_rank4_vl(fapl, dcpl, do_fillvalue, disable_edge_filters, FALSE, index_type) < 0) { - DO_RANKS_PRINT_CONFIG("Randomized rank 4 variable length") - HDprintf(" Index: %s\n", index_type == RANK4_INDEX_BTREE - ? "btree" - : (index_type == RANK4_INDEX_FARRAY ? "farray" : "earray")); - goto error; - } /* end if */ - - /* Sparse allocation test (regular and VL) */ - if (!(config & CONFIG_EARLY_ALLOC)) { - if (test_random_rank4(fapl, dcpl, do_fillvalue, disable_edge_filters, TRUE, index_type) < 0) { - DO_RANKS_PRINT_CONFIG("Randomized rank 4 with sparse allocation") + if (!h5_using_parallel_driver(NULL)) { + /* VL test */ + if (test_random_rank4_vl(fapl, dcpl, do_fillvalue, disable_edge_filters, FALSE, index_type) < + 0) { + DO_RANKS_PRINT_CONFIG("Randomized rank 4 variable length") HDprintf(" Index: %s\n", index_type == RANK4_INDEX_BTREE ? "btree" : (index_type == RANK4_INDEX_FARRAY ? "farray" : "earray")); goto error; } /* end if */ - if (test_random_rank4_vl(fapl, dcpl, do_fillvalue, disable_edge_filters, TRUE, index_type) < - 0) { - DO_RANKS_PRINT_CONFIG("Randomized rank 4 variable length with sparse allocation") + } + + /* Sparse allocation test (regular and VL) */ + if (!(config & CONFIG_EARLY_ALLOC)) { + if (test_random_rank4(fapl, dcpl, do_fillvalue, disable_edge_filters, TRUE, index_type) < 0) { + DO_RANKS_PRINT_CONFIG("Randomized rank 4 with sparse allocation") HDprintf(" Index: %s\n", index_type == RANK4_INDEX_BTREE ? "btree" : (index_type == RANK4_INDEX_FARRAY ? "farray" : "earray")); goto error; } /* end if */ - } /* end if */ + + if (!h5_using_parallel_driver(NULL)) { + if (test_random_rank4_vl(fapl, dcpl, do_fillvalue, disable_edge_filters, TRUE, + index_type) < 0) { + DO_RANKS_PRINT_CONFIG("Randomized rank 4 variable length with sparse allocation") + HDprintf(" Index: %s\n", + index_type == RANK4_INDEX_BTREE + ? "btree" + : (index_type == RANK4_INDEX_FARRAY ? "farray" : "earray")); + goto error; + } /* end if */ + } + } /* end if */ /* Break out if using the old format */ if (!new_format) diff --git a/test/stab.c b/test/stab.c index 798619d19fc..22b5005aafa 100644 --- a/test/stab.c +++ b/test/stab.c @@ -1417,7 +1417,8 @@ main(void) unsigned new_format; /* Whether to use the new format or not */ const char *env_h5_drvr; /* File Driver value from environment */ hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ - int nerrors = 0; + hbool_t driver_uses_modified_filename = h5_driver_uses_modified_filename(); + int nerrors = 0; /* Get the VFD to use */ env_h5_drvr = HDgetenv("HDF5_DRIVER"); @@ -1473,14 +1474,21 @@ main(void) if (contig_addr_vfd) { nerrors += lifecycle(fcpl2, fapl2); nerrors += long_compact(fcpl2, fapl2); - nerrors += read_old(); + + if (!driver_uses_modified_filename) { + nerrors += read_old(); + } + nerrors += no_compact(fcpl2, fapl2); nerrors += gcpl_on_root(fapl2); } /* Old group API specific tests */ nerrors += old_api(fapl); - nerrors += corrupt_stab_msg(); + + if (!driver_uses_modified_filename) { + nerrors += corrupt_stab_msg(); + } /* Close 2nd FAPL */ H5Pclose(fapl2); diff --git a/test/tarray.c b/test/tarray.c index af167a75cc2..3b17239008b 100644 --- a/test/tarray.c +++ b/test/tarray.c @@ -2217,8 +2217,10 @@ test_array(void) test_array_bkg(); /* Read compound datatype with array fields and background fields read */ - /* This test uses a custom file */ - test_compat(); /* Test compatibility changes for compound datatype fields */ + if (!h5_driver_uses_modified_filename()) { + /* This test uses a custom file */ + test_compat(); /* Test compatibility changes for compound datatype fields */ + } } /* end test_array() */ diff --git a/test/tattr.c b/test/tattr.c index b602222e3f2..84c2d94827f 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -2275,9 +2275,11 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Check size of file */ - filesize = h5_get_file_size(FILENAME, fapl); - VERIFY(filesize, empty_filesize, "h5_get_file_size"); + if (h5_using_default_driver(NULL)) { + /* Check size of file */ + filesize = h5_get_file_size(FILENAME, fapl); + VERIFY(filesize, empty_filesize, "h5_get_file_size"); + } } /* test_attr_dense_create() */ /**************************************************************** @@ -2419,9 +2421,11 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Check size of file */ - filesize = h5_get_file_size(FILENAME, fapl); - VERIFY(filesize, empty_filesize, "h5_get_file_size"); + if (h5_using_default_driver(NULL)) { + /* Check size of file */ + filesize = h5_get_file_size(FILENAME, fapl); + VERIFY(filesize, empty_filesize, "h5_get_file_size"); + } } /* test_attr_dense_open() */ /**************************************************************** @@ -2449,6 +2453,10 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl) int use_min_dset_oh = (dcpl_g != H5P_DEFAULT); herr_t ret; /* Generic return value */ + /* Only run this test for sec2/default driver */ + if (!h5_using_default_driver(NULL)) + return; + /* Output message about test being performed */ MESSAGE(5, ("Testing Deleting Attributes in Dense Storage\n")); @@ -2612,9 +2620,11 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Check size of file */ - filesize = h5_get_file_size(FILENAME, fapl); - VERIFY(filesize, empty_filesize, "h5_get_file_size"); + if (h5_using_default_driver(NULL)) { + /* Check size of file */ + filesize = h5_get_file_size(FILENAME, fapl); + VERIFY(filesize, empty_filesize, "h5_get_file_size"); + } } /* test_attr_dense_delete() */ /**************************************************************** @@ -2644,6 +2654,10 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) unsigned use_corder; /* Track creation order or not */ herr_t ret; /* Generic return value */ + /* Only run this test for sec2/default driver */ + if (!h5_using_default_driver(NULL)) + return; + /* Output message about test being performed */ MESSAGE(5, ("Testing Renaming Attributes in Dense Storage\n")); @@ -2803,9 +2817,11 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Check size of file */ - filesize = h5_get_file_size(FILENAME, fapl); - VERIFY(filesize, empty_filesize, "h5_get_file_size"); + if (h5_using_default_driver(NULL)) { + /* Check size of file */ + filesize = h5_get_file_size(FILENAME, fapl); + VERIFY(filesize, empty_filesize, "h5_get_file_size"); + } } /* test_attr_dense_rename() */ /**************************************************************** @@ -2834,6 +2850,10 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl) int use_min_dset_oh = (dcpl_g != H5P_DEFAULT); herr_t ret; /* Generic return value */ + /* Only run this test for sec2/default driver */ + if (!h5_using_default_driver(NULL)) + return; + /* Output message about test being performed */ MESSAGE(5, ("Testing Unlinking Object with Attributes in Dense Storage\n")); @@ -2946,9 +2966,11 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Check size of file */ - filesize = h5_get_file_size(FILENAME, fapl); - VERIFY(filesize, empty_filesize, "h5_get_file_size"); + if (h5_using_default_driver(NULL)) { + /* Check size of file */ + filesize = h5_get_file_size(FILENAME, fapl); + VERIFY(filesize, empty_filesize, "h5_get_file_size"); + } } /* test_attr_dense_unlink() */ /**************************************************************** @@ -3110,9 +3132,11 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Check size of file */ - filesize = h5_get_file_size(FILENAME, fapl); - VERIFY(filesize, empty_filesize, "h5_get_file_size"); + if (h5_using_default_driver(NULL)) { + /* Check size of file */ + filesize = h5_get_file_size(FILENAME, fapl); + VERIFY(filesize, empty_filesize, "h5_get_file_size"); + } } /* test_attr_dense_limits() */ /**************************************************************** @@ -3897,9 +3921,11 @@ test_attr_big(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Check size of file */ - filesize = h5_get_file_size(FILENAME, fapl); - VERIFY(filesize, empty_filesize, "h5_get_file_size"); + if (h5_using_default_driver(NULL)) { + /* Check size of file */ + filesize = h5_get_file_size(FILENAME, fapl); + VERIFY(filesize, empty_filesize, "h5_get_file_size"); + } } /* test_attr_big() */ /**************************************************************** @@ -4106,9 +4132,11 @@ test_attr_null_space(hid_t fcpl, hid_t fapl) ret = H5Sclose(null_sid); CHECK(ret, FAIL, "H5Sclose"); - /* Check size of file */ - filesize = h5_get_file_size(FILENAME, fapl); - VERIFY(filesize, empty_filesize, "h5_get_file_size"); + if (h5_using_default_driver(NULL)) { + /* Check size of file */ + filesize = h5_get_file_size(FILENAME, fapl); + VERIFY(filesize, empty_filesize, "h5_get_file_size"); + } } /* test_attr_null_space() */ /**************************************************************** @@ -8706,9 +8734,11 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Check size of file */ - filesize = h5_get_file_size(FILENAME, fapl); - VERIFY(filesize, empty_filesize, "h5_get_file_size"); + if (h5_using_default_driver(NULL)) { + /* Check size of file */ + filesize = h5_get_file_size(FILENAME, fapl); + VERIFY(filesize, empty_filesize, "h5_get_file_size"); + } } /* end for */ /* Close dataspaces */ @@ -9152,9 +9182,11 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Check size of file */ - filesize = h5_get_file_size(FILENAME, fapl); - VERIFY(filesize, empty_filesize, "h5_get_file_size"); + if (h5_using_default_driver(NULL)) { + /* Check size of file */ + filesize = h5_get_file_size(FILENAME, fapl); + VERIFY(filesize, empty_filesize, "h5_get_file_size"); + } } /* end for */ /* Close dataspaces */ @@ -9522,9 +9554,11 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Check size of file */ - filesize = h5_get_file_size(FILENAME, fapl); - VERIFY(filesize, empty_filesize, "h5_get_file_size"); + if (h5_using_default_driver(NULL)) { + /* Check size of file */ + filesize = h5_get_file_size(FILENAME, fapl); + VERIFY(filesize, empty_filesize, "h5_get_file_size"); + } } /* end for */ /* Close dataspaces */ @@ -9879,9 +9913,11 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Check size of file */ - filesize = h5_get_file_size(FILENAME, fapl); - VERIFY(filesize, empty_filesize, "h5_get_file_size"); + if (h5_using_default_driver(NULL)) { + /* Check size of file */ + filesize = h5_get_file_size(FILENAME, fapl); + VERIFY(filesize, empty_filesize, "h5_get_file_size"); + } } /* end for */ /* Close dataspaces */ diff --git a/test/tfile.c b/test/tfile.c index 62f3c7393b2..43c6386d266 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -35,6 +35,10 @@ #define H5F_TESTING #include "H5Fpkg.h" /* File access */ +#define H5FD_FRIEND /*suppress error about including H5FDpkg.h */ +#define H5FD_TESTING +#include "H5FDpkg.h" + #define H5D_FRIEND /*suppress error about including H5Dpkg */ #include "H5Dpkg.h" /* Dataset access */ @@ -176,8 +180,8 @@ const char *FILESPACE_NAME[] = {"tfilespace", NULL}; #define DSET_DS1 "DS1" /* Local test function declarations for version bounds */ -static void test_libver_bounds_low_high(void); -static void test_libver_bounds_super(hid_t fapl); +static void test_libver_bounds_low_high(const char *env_h5_drvr); +static void test_libver_bounds_super(hid_t fapl, const char *env_h5_drvr); static void test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t non_def_fsm); static void test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t non_def_fsm); static void test_libver_bounds_obj(hid_t fapl); @@ -304,186 +308,189 @@ test_file_create(void) VERIFY(ret, FAIL, "H5Pclose"); #endif - /* Create a new file with a non-standard file-creation template */ - tmpl1 = H5Pcreate(H5P_FILE_CREATE); - CHECK(tmpl1, FAIL, "H5Pcreate"); + if (h5_using_default_driver(NULL)) { - /* Try setting some bad userblock sizes */ - H5E_BEGIN_TRY - { - ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE1); - } - H5E_END_TRY; - VERIFY(ret, FAIL, "H5Pset_userblock"); - H5E_BEGIN_TRY - { - ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE2); - } - H5E_END_TRY; - VERIFY(ret, FAIL, "H5Pset_userblock"); - H5E_BEGIN_TRY - { - ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE3); - } - H5E_END_TRY; - VERIFY(ret, FAIL, "H5Pset_userblock"); - H5E_BEGIN_TRY - { - ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE4); - } - H5E_END_TRY; - VERIFY(ret, FAIL, "H5Pset_userblock"); - H5E_BEGIN_TRY - { - ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE5); - } - H5E_END_TRY; - VERIFY(ret, FAIL, "H5Pset_userblock"); - H5E_BEGIN_TRY - { - ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE6); - } - H5E_END_TRY; - VERIFY(ret, FAIL, "H5Pset_userblock"); - H5E_BEGIN_TRY - { - ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE7); - } - H5E_END_TRY; - VERIFY(ret, FAIL, "H5Pset_userblock"); - - /* Set the new file-creation parameters */ - ret = H5Pset_userblock(tmpl1, F2_USERBLOCK_SIZE); - CHECK(ret, FAIL, "H5Pset_userblock"); + /* Create a new file with a non-standard file-creation template */ + tmpl1 = H5Pcreate(H5P_FILE_CREATE); + CHECK(tmpl1, FAIL, "H5Pcreate"); - ret = H5Pset_sizes(tmpl1, (size_t)F2_OFFSET_SIZE, (size_t)F2_LENGTH_SIZE); - CHECK(ret, FAIL, "H5Pset_sizes"); + /* Try setting some bad userblock sizes */ + H5E_BEGIN_TRY + { + ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE1); + } + H5E_END_TRY; + VERIFY(ret, FAIL, "H5Pset_userblock"); + H5E_BEGIN_TRY + { + ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE2); + } + H5E_END_TRY; + VERIFY(ret, FAIL, "H5Pset_userblock"); + H5E_BEGIN_TRY + { + ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE3); + } + H5E_END_TRY; + VERIFY(ret, FAIL, "H5Pset_userblock"); + H5E_BEGIN_TRY + { + ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE4); + } + H5E_END_TRY; + VERIFY(ret, FAIL, "H5Pset_userblock"); + H5E_BEGIN_TRY + { + ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE5); + } + H5E_END_TRY; + VERIFY(ret, FAIL, "H5Pset_userblock"); + H5E_BEGIN_TRY + { + ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE6); + } + H5E_END_TRY; + VERIFY(ret, FAIL, "H5Pset_userblock"); + H5E_BEGIN_TRY + { + ret = H5Pset_userblock(tmpl1, BAD_USERBLOCK_SIZE7); + } + H5E_END_TRY; + VERIFY(ret, FAIL, "H5Pset_userblock"); - ret = H5Pset_sym_k(tmpl1, F2_SYM_INTERN_K, F2_SYM_LEAF_K); - CHECK(ret, FAIL, "H5Pset_sym_k"); + /* Set the new file-creation parameters */ + ret = H5Pset_userblock(tmpl1, F2_USERBLOCK_SIZE); + CHECK(ret, FAIL, "H5Pset_userblock"); - /* - * Try to create second file, with non-standard file-creation template - * params. - */ - fid2 = H5Fcreate(FILE2, H5F_ACC_TRUNC, tmpl1, H5P_DEFAULT); - CHECK(fid2, FAIL, "H5Fcreate"); + ret = H5Pset_sizes(tmpl1, (size_t)F2_OFFSET_SIZE, (size_t)F2_LENGTH_SIZE); + CHECK(ret, FAIL, "H5Pset_sizes"); - /* Release file-creation template */ - ret = H5Pclose(tmpl1); - CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pset_sym_k(tmpl1, F2_SYM_INTERN_K, F2_SYM_LEAF_K); + CHECK(ret, FAIL, "H5Pset_sym_k"); - /* Make certain we can create a dataset properly in the file with the userblock */ - { - hid_t dataset_id, dataspace_id; /* identifiers */ - hsize_t dims[F2_RANK]; - unsigned data[F2_DIM0][F2_DIM1]; - unsigned i, j; + /* + * Try to create second file, with non-standard file-creation template + * params. + */ + fid2 = H5Fcreate(FILE2, H5F_ACC_TRUNC, tmpl1, H5P_DEFAULT); + CHECK(fid2, FAIL, "H5Fcreate"); - /* Create the data space for the dataset. */ - dims[0] = F2_DIM0; - dims[1] = F2_DIM1; - dataspace_id = H5Screate_simple(F2_RANK, dims, NULL); - CHECK(dataspace_id, FAIL, "H5Screate_simple"); + /* Release file-creation template */ + ret = H5Pclose(tmpl1); + CHECK(ret, FAIL, "H5Pclose"); - /* Create the dataset. */ - dataset_id = - H5Dcreate2(fid2, F2_DSET, H5T_NATIVE_UINT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(dataset_id, FAIL, "H5Dcreate2"); + /* Make certain we can create a dataset properly in the file with the userblock */ + { + hid_t dataset_id, dataspace_id; /* identifiers */ + hsize_t dims[F2_RANK]; + unsigned data[F2_DIM0][F2_DIM1]; + unsigned i, j; + + /* Create the data space for the dataset. */ + dims[0] = F2_DIM0; + dims[1] = F2_DIM1; + dataspace_id = H5Screate_simple(F2_RANK, dims, NULL); + CHECK(dataspace_id, FAIL, "H5Screate_simple"); + + /* Create the dataset. */ + dataset_id = H5Dcreate2(fid2, F2_DSET, H5T_NATIVE_UINT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT); + CHECK(dataset_id, FAIL, "H5Dcreate2"); + + for (i = 0; i < F2_DIM0; i++) + for (j = 0; j < F2_DIM1; j++) + data[i][j] = i * 10 + j; + + /* Write data to the new dataset */ + ret = H5Dwrite(dataset_id, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + CHECK(ret, FAIL, "H5Dwrite"); + + /* End access to the dataset and release resources used by it. */ + ret = H5Dclose(dataset_id); + CHECK(ret, FAIL, "H5Dclose"); - for (i = 0; i < F2_DIM0; i++) - for (j = 0; j < F2_DIM1; j++) - data[i][j] = i * 10 + j; + /* Terminate access to the data space. */ + ret = H5Sclose(dataspace_id); + CHECK(ret, FAIL, "H5Sclose"); + } - /* Write data to the new dataset */ - ret = H5Dwrite(dataset_id, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - CHECK(ret, FAIL, "H5Dwrite"); + /* Get the file-creation template */ + tmpl1 = H5Fget_create_plist(fid2); + CHECK(tmpl1, FAIL, "H5Fget_create_plist"); - /* End access to the dataset and release resources used by it. */ - ret = H5Dclose(dataset_id); - CHECK(ret, FAIL, "H5Dclose"); + /* Get the file-creation parameters */ + ret = H5Pget_userblock(tmpl1, &ublock); + CHECK(ret, FAIL, "H5Pget_userblock"); + VERIFY(ublock, F2_USERBLOCK_SIZE, "H5Pget_userblock"); - /* Terminate access to the data space. */ - ret = H5Sclose(dataspace_id); - CHECK(ret, FAIL, "H5Sclose"); - } + ret = H5Pget_sizes(tmpl1, &parm, &parm2); + CHECK(ret, FAIL, "H5Pget_sizes"); + VERIFY(parm, F2_OFFSET_SIZE, "H5Pget_sizes"); + VERIFY(parm2, F2_LENGTH_SIZE, "H5Pget_sizes"); - /* Get the file-creation template */ - tmpl1 = H5Fget_create_plist(fid2); - CHECK(tmpl1, FAIL, "H5Fget_create_plist"); + ret = H5Pget_sym_k(tmpl1, &iparm, &iparm2); + CHECK(ret, FAIL, "H5Pget_sym_k"); + VERIFY(iparm, F2_SYM_INTERN_K, "H5Pget_sym_k"); + VERIFY(iparm2, F2_SYM_LEAF_K, "H5Pget_sym_k"); - /* Get the file-creation parameters */ - ret = H5Pget_userblock(tmpl1, &ublock); - CHECK(ret, FAIL, "H5Pget_userblock"); - VERIFY(ublock, F2_USERBLOCK_SIZE, "H5Pget_userblock"); + /* Clone the file-creation template */ + tmpl2 = H5Pcopy(tmpl1); + CHECK(tmpl2, FAIL, "H5Pcopy"); - ret = H5Pget_sizes(tmpl1, &parm, &parm2); - CHECK(ret, FAIL, "H5Pget_sizes"); - VERIFY(parm, F2_OFFSET_SIZE, "H5Pget_sizes"); - VERIFY(parm2, F2_LENGTH_SIZE, "H5Pget_sizes"); + /* Release file-creation template */ + ret = H5Pclose(tmpl1); + CHECK(ret, FAIL, "H5Pclose"); - ret = H5Pget_sym_k(tmpl1, &iparm, &iparm2); - CHECK(ret, FAIL, "H5Pget_sym_k"); - VERIFY(iparm, F2_SYM_INTERN_K, "H5Pget_sym_k"); - VERIFY(iparm2, F2_SYM_LEAF_K, "H5Pget_sym_k"); + /* Set the new file-creation parameter */ + ret = H5Pset_userblock(tmpl2, F3_USERBLOCK_SIZE); + CHECK(ret, FAIL, "H5Pset_userblock"); - /* Clone the file-creation template */ - tmpl2 = H5Pcopy(tmpl1); - CHECK(tmpl2, FAIL, "H5Pcopy"); + /* + * Try to create second file, with non-standard file-creation template + * params + */ + fid3 = H5Fcreate(FILE3, H5F_ACC_TRUNC, tmpl2, H5P_DEFAULT); + CHECK(fid3, FAIL, "H5Fcreate"); - /* Release file-creation template */ - ret = H5Pclose(tmpl1); - CHECK(ret, FAIL, "H5Pclose"); + /* Release file-creation template */ + ret = H5Pclose(tmpl2); + CHECK(ret, FAIL, "H5Pclose"); - /* Set the new file-creation parameter */ - ret = H5Pset_userblock(tmpl2, F3_USERBLOCK_SIZE); - CHECK(ret, FAIL, "H5Pset_userblock"); + /* Get the file-creation template */ + tmpl1 = H5Fget_create_plist(fid3); + CHECK(tmpl1, FAIL, "H5Fget_create_plist"); - /* - * Try to create second file, with non-standard file-creation template - * params - */ - fid3 = H5Fcreate(FILE3, H5F_ACC_TRUNC, tmpl2, H5P_DEFAULT); - CHECK(fid3, FAIL, "H5Fcreate"); + /* Get the file-creation parameters */ + ret = H5Pget_userblock(tmpl1, &ublock); + CHECK(ret, FAIL, "H5Pget_userblock"); + VERIFY(ublock, F3_USERBLOCK_SIZE, "H5Pget_userblock"); - /* Release file-creation template */ - ret = H5Pclose(tmpl2); - CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pget_sizes(tmpl1, &parm, &parm2); + CHECK(ret, FAIL, "H5Pget_sizes"); + VERIFY(parm, F3_OFFSET_SIZE, "H5Pget_sizes"); + VERIFY(parm2, F3_LENGTH_SIZE, "H5Pget_sizes"); - /* Get the file-creation template */ - tmpl1 = H5Fget_create_plist(fid3); - CHECK(tmpl1, FAIL, "H5Fget_create_plist"); + ret = H5Pget_sym_k(tmpl1, &iparm, &iparm2); + CHECK(ret, FAIL, "H5Pget_sym_k"); + VERIFY(iparm, F3_SYM_INTERN_K, "H5Pget_sym_k"); + VERIFY(iparm2, F3_SYM_LEAF_K, "H5Pget_sym_k"); - /* Get the file-creation parameters */ - ret = H5Pget_userblock(tmpl1, &ublock); - CHECK(ret, FAIL, "H5Pget_userblock"); - VERIFY(ublock, F3_USERBLOCK_SIZE, "H5Pget_userblock"); - - ret = H5Pget_sizes(tmpl1, &parm, &parm2); - CHECK(ret, FAIL, "H5Pget_sizes"); - VERIFY(parm, F3_OFFSET_SIZE, "H5Pget_sizes"); - VERIFY(parm2, F3_LENGTH_SIZE, "H5Pget_sizes"); + /* Release file-creation template */ + ret = H5Pclose(tmpl1); + CHECK(ret, FAIL, "H5Pclose"); - ret = H5Pget_sym_k(tmpl1, &iparm, &iparm2); - CHECK(ret, FAIL, "H5Pget_sym_k"); - VERIFY(iparm, F3_SYM_INTERN_K, "H5Pget_sym_k"); - VERIFY(iparm2, F3_SYM_LEAF_K, "H5Pget_sym_k"); + /* Close second file */ + ret = H5Fclose(fid2); + CHECK(ret, FAIL, "H5Fclose"); - /* Release file-creation template */ - ret = H5Pclose(tmpl1); - CHECK(ret, FAIL, "H5Pclose"); + /* Close third file */ + ret = H5Fclose(fid3); + CHECK(ret, FAIL, "H5Fclose"); + } /* Close first file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); - - /* Close second file */ - ret = H5Fclose(fid2); - CHECK(ret, FAIL, "H5Fclose"); - - /* Close third file */ - ret = H5Fclose(fid3); - CHECK(ret, FAIL, "H5Fclose"); } /* test_file_create() */ /**************************************************************** @@ -492,7 +499,7 @@ test_file_create(void) ** ****************************************************************/ static void -test_file_open(void) +test_file_open(const char *env_h5_drvr) { hid_t fid1, fid2; /*HDF5 File IDs */ hid_t did; /*dataset ID */ @@ -510,6 +517,10 @@ test_file_open(void) * Test single file open */ + /* Only run this test with sec2/default driver */ + if (!h5_using_default_driver(env_h5_drvr)) + return; + /* Output message about test being performed */ MESSAGE(5, ("Testing Low-Level File Opening I/O\n")); @@ -1619,22 +1630,24 @@ test_file_perm2(void) ** H5Fis_accessible() API call. ** *****************************************************************/ -#define FILE_IS_ACCESSIBLE "tfile_is_accessible" +#define FILE_IS_ACCESSIBLE "tfile_is_accessible" +#define FILE_IS_ACCESSIBLE_NON_HDF5 "tfile_is_accessible_non_hdf5" static void test_file_is_accessible(const char *env_h5_drvr) { - hid_t fid = H5I_INVALID_HID; /* File opened with read-write permission */ - hid_t fcpl_id = H5I_INVALID_HID; /* File creation property list */ - hid_t fapl_id = H5I_INVALID_HID; /* File access property list */ - int fd; /* POSIX file descriptor */ - char filename[FILENAME_LEN]; /* Filename to use */ - char sb_filename[FILENAME_LEN]; /* Name of file w/ superblock */ - ssize_t nbytes; /* Number of bytes written */ - unsigned u; /* Local index variable */ - unsigned char buf[1024]; /* Buffer of data to write */ - htri_t is_hdf5; /* Whether a file is an HDF5 file */ - int posix_ret; /* Return value from POSIX calls */ - herr_t ret; /* Return value from HDF5 calls */ + hid_t fid = H5I_INVALID_HID; /* File opened with read-write permission */ + hid_t fcpl_id = H5I_INVALID_HID; /* File creation property list */ + hid_t fapl_id = H5I_INVALID_HID; /* File access property list */ + int fd; /* POSIX file descriptor */ + char filename[FILENAME_LEN]; /* Filename to use */ + char non_hdf5_filename[FILENAME_LEN]; /* Base name of non-hdf5 file */ + char non_hdf5_sb_filename[FILENAME_LEN]; /* Name of non-hdf5 superblock file */ + ssize_t nbytes; /* Number of bytes written */ + unsigned u; /* Local index variable */ + unsigned char buf[1024]; /* Buffer of data to write */ + htri_t is_hdf5; /* Whether a file is an HDF5 file */ + int posix_ret; /* Return value from POSIX calls */ + herr_t ret; /* Return value from HDF5 calls */ /* Output message about test being performed */ MESSAGE(5, ("Testing Detection of HDF5 Files\n")); @@ -1643,13 +1656,11 @@ test_file_is_accessible(const char *env_h5_drvr) fapl_id = h5_fileaccess(); CHECK(fapl_id, H5I_INVALID_HID, "H5Pcreate"); - /* Fix up filenames - * For VFDs that create multiple files, we also need the name - * of the file with the superblock. With single-file VFDs, this - * will be equal to the one from h5_fixname(). - */ + /* Fix up filenames */ h5_fixname(FILE_IS_ACCESSIBLE, fapl_id, filename, sizeof(filename)); - h5_fixname_superblock(FILE_IS_ACCESSIBLE, fapl_id, sb_filename, sizeof(filename)); + h5_fixname(FILE_IS_ACCESSIBLE_NON_HDF5, fapl_id, non_hdf5_filename, sizeof(non_hdf5_filename)); + h5_fixname_superblock(FILE_IS_ACCESSIBLE_NON_HDF5, fapl_id, non_hdf5_sb_filename, + sizeof(non_hdf5_sb_filename)); /****************/ /* Normal usage */ @@ -1722,48 +1733,54 @@ test_file_is_accessible(const char *env_h5_drvr) VERIFY(is_hdf5, TRUE, "H5Fis_accessible"); } /* end if */ - /***********************/ - /* EMPTY non-HDF5 file */ - /***********************/ + /* Don't run the below tests for drivers that use multiple + * logical files, like the splitter driver. + */ + if (!h5_driver_uses_multiple_files(env_h5_drvr, H5_EXCLUDE_MULTIPART_DRIVERS)) { + /***********************/ + /* EMPTY non-HDF5 file */ + /***********************/ - /* Create non-HDF5 file and check it */ - fd = HDopen(sb_filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW); - CHECK(fd, (-1), "HDopen"); + /* Create non-HDF5 file and check it */ + fd = HDopen(non_hdf5_sb_filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW); + CHECK(fd, (-1), "HDopen"); - /* Close the file */ - posix_ret = HDclose(fd); - CHECK(posix_ret, (-1), "HDclose"); + /* Close the file */ + posix_ret = HDclose(fd); + CHECK(posix_ret, (-1), "HDclose"); - /* Verify that the file is NOT an HDF5 file */ - is_hdf5 = H5Fis_accessible(filename, fapl_id); - VERIFY(is_hdf5, FALSE, "H5Fis_accessible (empty non-HDF5 file)"); + /* Verify that the file is NOT an HDF5 file using the base filename */ + is_hdf5 = H5Fis_accessible(non_hdf5_filename, fapl_id); + VERIFY(is_hdf5, FALSE, "H5Fis_accessible (empty non-HDF5 file)"); - /***************************/ - /* Non-empty non-HDF5 file */ - /***************************/ + /***************************/ + /* Non-empty non-HDF5 file */ + /***************************/ - /* Create non-HDF5 file and check it */ - fd = HDopen(sb_filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW); - CHECK(fd, (-1), "HDopen"); + /* Create non-HDF5 file and check it */ + fd = HDopen(non_hdf5_sb_filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW); + CHECK(fd, (-1), "HDopen"); - /* Initialize information to write */ - for (u = 0; u < 1024; u++) - buf[u] = (unsigned char)u; + /* Initialize information to write */ + for (u = 0; u < 1024; u++) + buf[u] = (unsigned char)u; - /* Write some information */ - nbytes = HDwrite(fd, buf, (size_t)1024); - VERIFY(nbytes, 1024, "HDwrite"); + /* Write some information */ + nbytes = HDwrite(fd, buf, (size_t)1024); + VERIFY(nbytes, 1024, "HDwrite"); - /* Close the file */ - posix_ret = HDclose(fd); - CHECK(posix_ret, (-1), "HDclose"); + /* Close the file */ + posix_ret = HDclose(fd); + CHECK(posix_ret, (-1), "HDclose"); - /* Verify that the file is not an HDF5 file */ - is_hdf5 = H5Fis_accessible(filename, fapl_id); - VERIFY(is_hdf5, FALSE, "H5Fis_accessible (non-HDF5 file)"); + /* Verify that the file is not an HDF5 file */ + is_hdf5 = H5Fis_accessible(non_hdf5_filename, fapl_id); + VERIFY(is_hdf5, FALSE, "H5Fis_accessible (non-HDF5 file)"); + } /* Clean up files */ h5_delete_test_file(filename, fapl_id); + h5_delete_test_file(non_hdf5_filename, fapl_id); /* Close property list */ ret = H5Pclose(fapl_id); @@ -1795,6 +1812,9 @@ test_file_ishdf5(const char *env_h5_drvr) int posix_ret; /* Return value from POSIX calls */ herr_t ret; /* Return value from HDF5 calls */ + if (!h5_using_default_driver(env_h5_drvr)) + return; + /* Output message about test being performed */ MESSAGE(5, ("Testing Detection of HDF5 Files (using deprecated H5Fis_hdf5() call)\n")); @@ -1830,33 +1850,28 @@ test_file_ishdf5(const char *env_h5_drvr) /* Non-default user block size */ /*******************************/ - /* This test is not currently working for the family VFD. - * There are failures when creating files with userblocks. - */ - if (0 != HDstrcmp(env_h5_drvr, "family")) { - /* Create a file creation property list with a non-default user block size */ - fcpl_id = H5Pcreate(H5P_FILE_CREATE); - CHECK(fcpl_id, H5I_INVALID_HID, "H5Pcreate"); + /* Create a file creation property list with a non-default user block size */ + fcpl_id = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl_id, H5I_INVALID_HID, "H5Pcreate"); - ret = H5Pset_userblock(fcpl_id, (hsize_t)2048); - CHECK(ret, FAIL, "H5Pset_userblock"); + ret = H5Pset_userblock(fcpl_id, (hsize_t)2048); + CHECK(ret, FAIL, "H5Pset_userblock"); - /* Create file with non-default user block */ - fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id); - CHECK(fid, H5I_INVALID_HID, "H5Fcreate"); + /* Create file with non-default user block */ + fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id); + CHECK(fid, H5I_INVALID_HID, "H5Fcreate"); - /* Release file creation property list */ - ret = H5Pclose(fcpl_id); - CHECK(ret, FAIL, "H5Pclose"); + /* Release file creation property list */ + ret = H5Pclose(fcpl_id); + CHECK(ret, FAIL, "H5Pclose"); - /* Close file */ - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); + /* Close file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); - /* Verify that the file is an HDF5 file */ - is_hdf5 = H5Fis_hdf5(sb_filename); - VERIFY(is_hdf5, TRUE, "H5Fis_hdf5"); - } /* end if */ + /* Verify that the file is an HDF5 file */ + is_hdf5 = H5Fis_hdf5(sb_filename); + VERIFY(is_hdf5, TRUE, "H5Fis_hdf5"); /***************************/ /* Non-empty non-HDF5 file */ @@ -2891,7 +2906,7 @@ test_file_double_datatype_open(void) ** *****************************************************************/ static void -test_userblock_file_size(void) +test_userblock_file_size(const char *env_h5_drvr) { hid_t file1_id, file2_id; hid_t group1_id, group2_id; @@ -2903,6 +2918,11 @@ test_userblock_file_size(void) unsigned long fileno1, fileno2; /* File number */ herr_t ret; /* Generic return value */ + /* Don't run with multi/split, family or direct drivers */ + if (!HDstrcmp(env_h5_drvr, "multi") || !HDstrcmp(env_h5_drvr, "split") || + !HDstrcmp(env_h5_drvr, "family") || !HDstrcmp(env_h5_drvr, "direct")) + return; + /* Output message about test being performed */ MESSAGE(5, ("Testing file size with user block\n")); @@ -3289,13 +3309,17 @@ test_userblock_alignment_helper2(hid_t fapl, hbool_t open_rw) ** *****************************************************************/ static void -test_userblock_alignment(void) +test_userblock_alignment(const char *env_h5_drvr) { hid_t fid; /* File ID */ hid_t fcpl; /* File creation property list ID */ hid_t fapl; /* File access property list ID */ herr_t ret; /* Generic return value */ + /* Only run with sec2 driver */ + if (!h5_using_default_driver(env_h5_drvr)) + return; + /* Output message about test being performed */ MESSAGE(5, ("Testing that non-zero userblocks and object alignment interact correctly.\n")); @@ -3507,13 +3531,17 @@ test_userblock_alignment(void) ** *****************************************************************/ static void -test_userblock_alignment_paged(void) +test_userblock_alignment_paged(const char *env_h5_drvr) { hid_t fid; /* File ID */ hid_t fcpl; /* File creation property list ID */ hid_t fapl; /* File access property list ID */ herr_t ret; /* Generic return value */ + /* Only run with sec2 driver */ + if (!h5_using_default_driver(env_h5_drvr)) + return; + /* Output message about test being performed */ MESSAGE(5, ("Testing interaction between userblock and alignment (via paged aggregation and " "H5Pset_alignment)\n")); @@ -5570,7 +5598,10 @@ test_libver_bounds(void) test_libver_bounds_real(H5F_LIBVER_EARLIEST, 1, H5F_LIBVER_LATEST, 2); test_libver_bounds_real(H5F_LIBVER_LATEST, 2, H5F_LIBVER_EARLIEST, 2); test_libver_bounds_open(); - test_libver_bounds_copy(); + + if (!h5_driver_uses_modified_filename()) { + test_libver_bounds_copy(); + } } /* end test_libver_bounds() */ /************************************************************************************** @@ -5595,7 +5626,7 @@ test_libver_bounds(void) ** **************************************************************************************/ static void -test_libver_bounds_low_high(void) +test_libver_bounds_low_high(const char *env_h5_drvr) { hid_t fapl = H5I_INVALID_HID; /* File access property list */ H5F_libver_t low, high; /* Low and high bounds */ @@ -5635,7 +5666,7 @@ test_libver_bounds_low_high(void) VERIFY(ret, SUCCEED, "H5Pset_libver_bounds"); /* Tests to verify version bounds */ - test_libver_bounds_super(fapl); + test_libver_bounds_super(fapl, env_h5_drvr); test_libver_bounds_obj(fapl); test_libver_bounds_dataset(fapl); test_libver_bounds_dataspace(fapl); @@ -5668,7 +5699,7 @@ test_libver_bounds_low_high(void) ** *************************************************************************/ static void -test_libver_bounds_super(hid_t fapl) +test_libver_bounds_super(hid_t fapl, const char *env_h5_drvr) { hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ herr_t ret; /* The return value */ @@ -5680,12 +5711,14 @@ test_libver_bounds_super(hid_t fapl) /* Verify superblock version when creating a file with input fapl, fcpl #A and with/without SWMR access */ - test_libver_bounds_super_create(fapl, fcpl, TRUE, FALSE); + if (H5FD__supports_swmr_test(env_h5_drvr)) + test_libver_bounds_super_create(fapl, fcpl, TRUE, FALSE); test_libver_bounds_super_create(fapl, fcpl, FALSE, FALSE); /* Verify superblock version when opening a file which is created with input fapl, fcpl #A and with/without SWMR access */ - test_libver_bounds_super_open(fapl, fcpl, TRUE, FALSE); + if (H5FD__supports_swmr_test(env_h5_drvr)) + test_libver_bounds_super_open(fapl, fcpl, TRUE, FALSE); test_libver_bounds_super_open(fapl, fcpl, FALSE, FALSE); /* Close the fcpl */ @@ -5701,12 +5734,14 @@ test_libver_bounds_super(hid_t fapl) /* Verify superblock version when creating a file with input fapl, fcpl #B and with/without SWMR access */ - test_libver_bounds_super_create(fapl, fcpl, TRUE, FALSE); + if (H5FD__supports_swmr_test(env_h5_drvr)) + test_libver_bounds_super_create(fapl, fcpl, TRUE, FALSE); test_libver_bounds_super_create(fapl, fcpl, FALSE, FALSE); /* Verify superblock version when opening a file which is created with input fapl, fcpl #B and with/without SWMR access */ - test_libver_bounds_super_open(fapl, fcpl, TRUE, FALSE); + if (H5FD__supports_swmr_test(env_h5_drvr)) + test_libver_bounds_super_open(fapl, fcpl, TRUE, FALSE); test_libver_bounds_super_open(fapl, fcpl, FALSE, FALSE); /* Close the fcpl */ @@ -5724,38 +5759,44 @@ test_libver_bounds_super(hid_t fapl) /* Verify superblock version when creating a file with input fapl, fcpl #C and with/without SWMR access */ - test_libver_bounds_super_create(fapl, fcpl, TRUE, FALSE); + if (H5FD__supports_swmr_test(env_h5_drvr)) + test_libver_bounds_super_create(fapl, fcpl, TRUE, FALSE); test_libver_bounds_super_create(fapl, fcpl, FALSE, FALSE); /* Verify superblock version when opening a file which is created with input fapl, fcpl #C and with/without SWMR access */ - test_libver_bounds_super_open(fapl, fcpl, TRUE, FALSE); + if (H5FD__supports_swmr_test(env_h5_drvr)) + test_libver_bounds_super_open(fapl, fcpl, TRUE, FALSE); test_libver_bounds_super_open(fapl, fcpl, FALSE, FALSE); /* Close the fcpl */ ret = H5Pclose(fcpl); CHECK(ret, FAIL, "H5Pclose"); - /* Create a fcpl with persistent free-space manager enabled: #D */ - /* This will result in superblock version 2 */ - fcpl = H5Pcreate(H5P_FILE_CREATE); - CHECK(fcpl, H5I_INVALID_HID, "H5Pcreate"); - ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, 1, (hsize_t)1); - CHECK(ret, FAIL, "H5Pset_file_space"); - - /* Verify superblock version when creating a file with input fapl, - fcpl #D and with/without SWMR access */ - test_libver_bounds_super_create(fapl, fcpl, TRUE, TRUE); - test_libver_bounds_super_create(fapl, fcpl, FALSE, TRUE); - - /* Verify superblock version when opening a file which is created - with input fapl, fcpl #D and with/without SWMR access */ - test_libver_bounds_super_open(fapl, fcpl, TRUE, TRUE); - test_libver_bounds_super_open(fapl, fcpl, FALSE, TRUE); - - /* Close the fcpl */ - ret = H5Pclose(fcpl); - CHECK(ret, FAIL, "H5Pclose"); + if (h5_using_default_driver(env_h5_drvr)) { + /* Create a fcpl with persistent free-space manager enabled: #D */ + /* This will result in superblock version 2 */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, H5I_INVALID_HID, "H5Pcreate"); + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, 1, (hsize_t)1); + CHECK(ret, FAIL, "H5Pset_file_space"); + + /* Verify superblock version when creating a file with input fapl, + fcpl #D and with/without SWMR access */ + if (H5FD__supports_swmr_test(env_h5_drvr)) + test_libver_bounds_super_create(fapl, fcpl, TRUE, TRUE); + test_libver_bounds_super_create(fapl, fcpl, FALSE, TRUE); + + /* Verify superblock version when opening a file which is created + with input fapl, fcpl #D and with/without SWMR access */ + if (H5FD__supports_swmr_test(env_h5_drvr)) + test_libver_bounds_super_open(fapl, fcpl, TRUE, TRUE); + test_libver_bounds_super_open(fapl, fcpl, FALSE, TRUE); + + /* Close the fcpl */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + } } /* end test_libver_bounds_super() */ @@ -7747,7 +7788,7 @@ test_min_dset_ohdr(void) ****************************************************************/ #ifndef H5_NO_DEPRECATED_SYMBOLS static void -test_deprec(void) +test_deprec(const char *env_h5_drvr) { hid_t file; /* File IDs for old & new files */ hid_t fcpl; /* File creation property list */ @@ -7800,166 +7841,169 @@ test_deprec(void) ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); - /* Create a file creation property list */ - fcpl = H5Pcreate(H5P_FILE_CREATE); - CHECK(fcpl, FAIL, "H5Pcreate"); + /* Only run this part of the test with the sec2/default driver */ + if (h5_using_default_driver(env_h5_drvr)) { + /* Create a file creation property list */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); - /* Set a property in the FCPL that will push the superblock version up */ - ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)0); - ret = H5Pset_file_space_page_size(fcpl, (hsize_t)512); - CHECK(ret, FAIL, "H5Pset_file_space_strategy"); + /* Set a property in the FCPL that will push the superblock version up */ + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)0); + ret = H5Pset_file_space_page_size(fcpl, (hsize_t)512); + CHECK(ret, FAIL, "H5Pset_file_space_strategy"); - fapl = H5Pcreate(H5P_FILE_ACCESS); - ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1024); - CHECK(ret, FAIL, "H5Pset_alignment"); + fapl = H5Pcreate(H5P_FILE_ACCESS); + ret = H5Pset_alignment(fapl, (hsize_t)1, (hsize_t)1024); + CHECK(ret, FAIL, "H5Pset_alignment"); - /* Creating a file with the non-default file creation property list should - * create a version 2 superblock - */ + /* Creating a file with the non-default file creation property list should + * create a version 2 superblock + */ - /* Create file with custom file creation property list */ - file = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl); - CHECK(file, FAIL, "H5Fcreate"); + /* Create file with custom file creation property list */ + file = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl); + CHECK(file, FAIL, "H5Fcreate"); - new_fapl = H5Fget_access_plist(file); - H5Pget_alignment(new_fapl, NULL, &align); + new_fapl = H5Fget_access_plist(file); + H5Pget_alignment(new_fapl, NULL, &align); - /* Close FCPL */ - ret = H5Pclose(fcpl); - CHECK(ret, FAIL, "H5Pclose"); + /* Close FCPL */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); - /* Get the file's version information */ - ret = H5Fget_info1(file, &finfo); - CHECK(ret, FAIL, "H5Fget_info1"); - VERIFY(finfo.super_ext_size, 152, "H5Fget_info1"); - VERIFY(finfo.sohm.hdr_size, 0, "H5Fget_info1"); - VERIFY(finfo.sohm.msgs_info.index_size, 0, "H5Fget_info1"); - VERIFY(finfo.sohm.msgs_info.heap_size, 0, "H5Fget_info1"); + /* Get the file's version information */ + ret = H5Fget_info1(file, &finfo); + CHECK(ret, FAIL, "H5Fget_info1"); + VERIFY(finfo.super_ext_size, 152, "H5Fget_info1"); + VERIFY(finfo.sohm.hdr_size, 0, "H5Fget_info1"); + VERIFY(finfo.sohm.msgs_info.index_size, 0, "H5Fget_info1"); + VERIFY(finfo.sohm.msgs_info.heap_size, 0, "H5Fget_info1"); - /* Get the file's dataset creation property list */ - fcpl = H5Fget_create_plist(file); - CHECK(fcpl, FAIL, "H5Fget_create_plist"); + /* Get the file's dataset creation property list */ + fcpl = H5Fget_create_plist(file); + CHECK(fcpl, FAIL, "H5Fget_create_plist"); - /* Get the file's version information */ - ret = H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr); - CHECK(ret, FAIL, "H5Pget_version"); - VERIFY(super, 2, "H5Pget_version"); - VERIFY(freelist, 0, "H5Pget_version"); - VERIFY(stab, 0, "H5Pget_version"); - VERIFY(shhdr, 0, "H5Pget_version"); + /* Get the file's version information */ + ret = H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr); + CHECK(ret, FAIL, "H5Pget_version"); + VERIFY(super, 2, "H5Pget_version"); + VERIFY(freelist, 0, "H5Pget_version"); + VERIFY(stab, 0, "H5Pget_version"); + VERIFY(shhdr, 0, "H5Pget_version"); - /* Close FCPL */ - ret = H5Pclose(fcpl); - CHECK(ret, FAIL, "H5Pclose"); + /* Close FCPL */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); - /* Close file */ - ret = H5Fclose(file); - CHECK(ret, FAIL, "H5Fclose"); + /* Close file */ + ret = H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); - /* Re-open the file */ - file = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); - CHECK(file, FAIL, "H5Fcreate"); + /* Re-open the file */ + file = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(file, FAIL, "H5Fcreate"); - /* Get the file's version information */ - ret = H5Fget_info1(file, &finfo); - CHECK(ret, FAIL, "H5Fget_info1"); - VERIFY(finfo.super_ext_size, 152, "H5Fget_info1"); - VERIFY(finfo.sohm.hdr_size, 0, "H5Fget_info1"); - VERIFY(finfo.sohm.msgs_info.index_size, 0, "H5Fget_info1"); - VERIFY(finfo.sohm.msgs_info.heap_size, 0, "H5Fget_info1"); + /* Get the file's version information */ + ret = H5Fget_info1(file, &finfo); + CHECK(ret, FAIL, "H5Fget_info1"); + VERIFY(finfo.super_ext_size, 152, "H5Fget_info1"); + VERIFY(finfo.sohm.hdr_size, 0, "H5Fget_info1"); + VERIFY(finfo.sohm.msgs_info.index_size, 0, "H5Fget_info1"); + VERIFY(finfo.sohm.msgs_info.heap_size, 0, "H5Fget_info1"); - /* Get the file's creation property list */ - fcpl = H5Fget_create_plist(file); - CHECK(fcpl, FAIL, "H5Fget_create_plist"); + /* Get the file's creation property list */ + fcpl = H5Fget_create_plist(file); + CHECK(fcpl, FAIL, "H5Fget_create_plist"); - /* Get the file's version information */ - ret = H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr); - CHECK(ret, FAIL, "H5Pget_version"); - VERIFY(super, 2, "H5Pget_version"); - VERIFY(freelist, 0, "H5Pget_version"); - VERIFY(stab, 0, "H5Pget_version"); - VERIFY(shhdr, 0, "H5Pget_version"); + /* Get the file's version information */ + ret = H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr); + CHECK(ret, FAIL, "H5Pget_version"); + VERIFY(super, 2, "H5Pget_version"); + VERIFY(freelist, 0, "H5Pget_version"); + VERIFY(stab, 0, "H5Pget_version"); + VERIFY(shhdr, 0, "H5Pget_version"); - /* Close FCPL */ - ret = H5Pclose(fcpl); - CHECK(ret, FAIL, "H5Pclose"); + /* Close FCPL */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); - /* Close file */ - ret = H5Fclose(file); - CHECK(ret, FAIL, "H5Fclose"); + /* Close file */ + ret = H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); - { /* Test deprecated H5Pget/set_file_space() */ + { /* Test deprecated H5Pget/set_file_space() */ - H5F_file_space_type_t old_strategy; - hsize_t old_threshold; - hid_t fid; - hid_t ffcpl; + H5F_file_space_type_t old_strategy; + hsize_t old_threshold; + hid_t fid; + hid_t ffcpl; - fcpl = H5Pcreate(H5P_FILE_CREATE); - CHECK(fcpl, FAIL, "H5Pcreate"); + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); - ret = H5Pget_file_space(fcpl, &old_strategy, &old_threshold); - CHECK(ret, FAIL, "H5Pget_file_space"); - VERIFY(old_strategy, H5F_FILE_SPACE_ALL, "H5Pget_file_space"); - VERIFY(old_threshold, H5F_FREE_SPACE_THRESHOLD_DEF, "H5Pget_file_space"); + ret = H5Pget_file_space(fcpl, &old_strategy, &old_threshold); + CHECK(ret, FAIL, "H5Pget_file_space"); + VERIFY(old_strategy, H5F_FILE_SPACE_ALL, "H5Pget_file_space"); + VERIFY(old_threshold, H5F_FREE_SPACE_THRESHOLD_DEF, "H5Pget_file_space"); - /* Set file space strategy and free space section threshold */ - ret = H5Pset_file_space(fcpl, H5F_FILE_SPACE_ALL_PERSIST, (hsize_t)0); - CHECK(ret, FAIL, "H5Pget_file_space"); + /* Set file space strategy and free space section threshold */ + ret = H5Pset_file_space(fcpl, H5F_FILE_SPACE_ALL_PERSIST, (hsize_t)0); + CHECK(ret, FAIL, "H5Pget_file_space"); - /* Get the file space info from the creation property */ - ret = H5Pget_file_space(fcpl, &old_strategy, &old_threshold); - CHECK(ret, FAIL, "H5Pget_file_space"); - VERIFY(old_strategy, H5F_FILE_SPACE_ALL_PERSIST, "H5Pget_file_space"); - VERIFY(old_threshold, H5F_FREE_SPACE_THRESHOLD_DEF, "H5Pget_file_space"); + /* Get the file space info from the creation property */ + ret = H5Pget_file_space(fcpl, &old_strategy, &old_threshold); + CHECK(ret, FAIL, "H5Pget_file_space"); + VERIFY(old_strategy, H5F_FILE_SPACE_ALL_PERSIST, "H5Pget_file_space"); + VERIFY(old_threshold, H5F_FREE_SPACE_THRESHOLD_DEF, "H5Pget_file_space"); - ret = H5Pset_file_space(fcpl, H5F_FILE_SPACE_DEFAULT, (hsize_t)3); - CHECK(ret, FAIL, "H5Pget_file_space"); + ret = H5Pset_file_space(fcpl, H5F_FILE_SPACE_DEFAULT, (hsize_t)3); + CHECK(ret, FAIL, "H5Pget_file_space"); - ret = H5Pget_file_space(fcpl, &old_strategy, &old_threshold); - CHECK(ret, FAIL, "H5Pget_file_space"); - VERIFY(old_strategy, H5F_FILE_SPACE_ALL_PERSIST, "H5Pget_file_space"); - VERIFY(old_threshold, 3, "H5Pget_file_space"); + ret = H5Pget_file_space(fcpl, &old_strategy, &old_threshold); + CHECK(ret, FAIL, "H5Pget_file_space"); + VERIFY(old_strategy, H5F_FILE_SPACE_ALL_PERSIST, "H5Pget_file_space"); + VERIFY(old_threshold, 3, "H5Pget_file_space"); - /* Create a file */ - fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); - CHECK(file, FAIL, "H5Fcreate"); + /* Create a file */ + fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); + CHECK(file, FAIL, "H5Fcreate"); - old_strategy = H5F_FILE_SPACE_DEFAULT; - old_threshold = 0; - ffcpl = H5Fget_create_plist(fid); - ret = H5Pget_file_space(ffcpl, &old_strategy, &old_threshold); - CHECK(ret, FAIL, "H5Pget_file_space"); - VERIFY(old_strategy, H5F_FILE_SPACE_ALL_PERSIST, "H5Pget_file_space"); - VERIFY(old_threshold, 3, "H5Pget_file_space"); + old_strategy = H5F_FILE_SPACE_DEFAULT; + old_threshold = 0; + ffcpl = H5Fget_create_plist(fid); + ret = H5Pget_file_space(ffcpl, &old_strategy, &old_threshold); + CHECK(ret, FAIL, "H5Pget_file_space"); + VERIFY(old_strategy, H5F_FILE_SPACE_ALL_PERSIST, "H5Pget_file_space"); + VERIFY(old_threshold, 3, "H5Pget_file_space"); - /* Close file */ - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); + /* Close file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); - ret = H5Pclose(ffcpl); - CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(ffcpl); + CHECK(ret, FAIL, "H5Pclose"); - ret = H5Pclose(fcpl); - CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); - /* Reopen the file */ - fid = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); - CHECK(fid, FAIL, "H5Fcreate"); + /* Reopen the file */ + fid = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fcreate"); - old_strategy = H5F_FILE_SPACE_DEFAULT; - old_threshold = 0; - ffcpl = H5Fget_create_plist(fid); - ret = H5Pget_file_space(ffcpl, &old_strategy, &old_threshold); - CHECK(ret, FAIL, "H5Pget_file_space"); - VERIFY(old_strategy, H5F_FILE_SPACE_ALL_PERSIST, "H5Pget_file_space"); - VERIFY(old_threshold, 3, "H5Pget_file_space"); + old_strategy = H5F_FILE_SPACE_DEFAULT; + old_threshold = 0; + ffcpl = H5Fget_create_plist(fid); + ret = H5Pget_file_space(ffcpl, &old_strategy, &old_threshold); + CHECK(ret, FAIL, "H5Pget_file_space"); + VERIFY(old_strategy, H5F_FILE_SPACE_ALL_PERSIST, "H5Pget_file_space"); + VERIFY(old_threshold, 3, "H5Pget_file_space"); - ret = H5Pclose(ffcpl); - CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(ffcpl); + CHECK(ret, FAIL, "H5Pclose"); - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } } } /* test_deprec */ @@ -7973,8 +8017,9 @@ test_deprec(void) void test_file(void) { - const char *env_h5_drvr; /* File Driver value from environment */ - hid_t fapl_id = H5I_INVALID_HID; /* VFD-dependent fapl ID */ + const char *env_h5_drvr; /* File Driver value from environment */ + hid_t fapl_id = H5I_INVALID_HID; /* VFD-dependent fapl ID */ + hbool_t driver_uses_modified_filename = h5_driver_uses_modified_filename(); herr_t ret; /* Output message about test being performed */ @@ -7990,7 +8035,7 @@ test_file(void) CHECK(fapl_id, H5I_INVALID_HID, "h5_fileaccess"); test_file_create(); /* Test file creation(also creation templates)*/ - test_file_open(); /* Test file opening */ + test_file_open(env_h5_drvr); /* Test file opening */ test_file_reopen(); /* Test file reopening */ test_file_close(); /* Test file close behavior */ test_get_file_id(); /* Test H5Iget_file_id */ @@ -8008,14 +8053,19 @@ test_file(void) test_file_double_datatype_open(); /* Test opening same named datatype from two files works properly */ test_file_double_file_dataset_open(TRUE); test_file_double_file_dataset_open(FALSE); - test_userblock_file_size(); /* Tests that files created with a userblock have the correct size */ - test_cached_stab_info(); /* Tests that files are created with cached stab info in the superblock */ - test_rw_noupdate(); /* Test to ensure that RW permissions don't write the file unless dirtied */ - test_userblock_alignment(); /* Tests that files created with a userblock and alignment interact properly - */ - test_userblock_alignment_paged(); /* Tests files created with a userblock and alignment (via paged - aggregation) interact properly */ - test_filespace_info(env_h5_drvr); /* Test file creation public routines: */ + test_userblock_file_size( + env_h5_drvr); /* Tests that files created with a userblock have the correct size */ + test_cached_stab_info(); /* Tests that files are created with cached stab info in the superblock */ + + if (!driver_uses_modified_filename) { + test_rw_noupdate(); /* Test to ensure that RW permissions don't write the file unless dirtied */ + } + + test_userblock_alignment( + env_h5_drvr); /* Tests that files created with a userblock and alignment interact properly */ + test_userblock_alignment_paged(env_h5_drvr); /* Tests files created with a userblock and alignment (via + paged aggregation) interact properly */ + test_filespace_info(env_h5_drvr); /* Test file creation public routines: */ /* H5Pget/set_file_space_strategy() & H5Pget/set_file_space_page_size() */ /* Skipped testing for multi/split drivers */ test_file_freespace(env_h5_drvr); /* Test file public routine H5Fget_freespace() */ @@ -8027,19 +8077,25 @@ test_file(void) /* Setup for multi/split drivers are there already */ test_sects_freespace(env_h5_drvr, FALSE); /* Test file public routine H5Fget_free_sections() */ /* Skipped testing for multi/split drivers */ - test_filespace_compatible(); /* Test compatibility for file space management */ - test_filespace_round_compatible(); /* Testing file space compatibility for files from trunk to 1_8 to - trunk */ - test_filespace_1_10_0_compatible(); /* Testing file space compatibility for files from release 1.10.0 */ - test_libver_bounds(); /* Test compatibility for file space management */ - test_libver_bounds_low_high(); + + if (!driver_uses_modified_filename) { + test_filespace_compatible(); /* Test compatibility for file space management */ + + test_filespace_round_compatible(); /* Testing file space compatibility for files from trunk to 1_8 to + trunk */ + test_filespace_1_10_0_compatible(); /* Testing file space compatibility for files from release 1.10.0 + */ + } + + test_libver_bounds(); /* Test compatibility for file space management */ + test_libver_bounds_low_high(env_h5_drvr); test_libver_macros(); /* Test the macros for library version comparison */ test_libver_macros2(); /* Test the macros for library version comparison */ test_incr_filesize(); /* Test H5Fincrement_filesize() and H5Fget_eoa() */ test_min_dset_ohdr(); /* Test datset object header minimization */ #ifndef H5_NO_DEPRECATED_SYMBOLS test_file_ishdf5(env_h5_drvr); /* Test detecting HDF5 files correctly */ - test_deprec(); /* Test deprecated routines */ + test_deprec(env_h5_drvr); /* Test deprecated routines */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ ret = H5Pclose(fapl_id); @@ -8064,13 +8120,17 @@ test_file(void) void cleanup_file(void) { - HDremove(SFILE1); - HDremove(FILE1); - HDremove(FILE2); - HDremove(FILE3); - HDremove(FILE4); - HDremove(FILE5); - HDremove(FILE6); - HDremove(FILE7); - HDremove(DST_FILE); + H5E_BEGIN_TRY + { + H5Fdelete(SFILE1, H5P_DEFAULT); + H5Fdelete(FILE1, H5P_DEFAULT); + H5Fdelete(FILE2, H5P_DEFAULT); + H5Fdelete(FILE3, H5P_DEFAULT); + H5Fdelete(FILE4, H5P_DEFAULT); + H5Fdelete(FILE5, H5P_DEFAULT); + H5Fdelete(FILE6, H5P_DEFAULT); + H5Fdelete(FILE7, H5P_DEFAULT); + H5Fdelete(DST_FILE, H5P_DEFAULT); + } + H5E_END_TRY; } diff --git a/test/th5o.c b/test/th5o.c index ebb6c6e65a0..48c0a8172e1 100644 --- a/test/th5o.c +++ b/test/th5o.c @@ -43,14 +43,17 @@ test_h5o_open(void) { hid_t fid; /* HDF5 File ID */ hid_t grp, dset, dtype, dspace; /* Object identifiers */ + char filename[1024]; hsize_t dims[RANK]; H5I_type_t id_type; /* Type of IDs returned from H5Oopen */ H5G_info_t ginfo; /* Group info struct */ H5T_class_t type_class; /* Class of the datatype */ herr_t ret; /* Value returned from API calls */ + h5_fixname(TEST_FILENAME, H5P_DEFAULT, filename, sizeof filename); + /* Create a new HDF5 file */ - fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); /* Create a group, dataset, and committed datatype within the file */ @@ -155,11 +158,14 @@ test_h5o_close(void) { hid_t fid; /* HDF5 File ID */ hid_t grp, dset, dtype, dspace; /* Object identifiers */ + char filename[1024]; hsize_t dims[RANK]; herr_t ret; /* Value returned from API calls */ + h5_fixname(TEST_FILENAME, H5P_DEFAULT, filename, sizeof filename); + /* Create a new HDF5 file */ - fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); /* Create a group, dataset, and committed datatype within the file */ @@ -247,8 +253,9 @@ test_h5o_open_by_addr(void) { hid_t fid; /* HDF5 File ID */ hid_t grp, dset, dtype, dspace; /* Object identifiers */ - H5L_info2_t li; /* Buffer for H5Lget_info2 */ - haddr_t grp_addr; /* Addresses for objects */ + char filename[1024]; + H5L_info2_t li; /* Buffer for H5Lget_info2 */ + haddr_t grp_addr; /* Addresses for objects */ haddr_t dset_addr; haddr_t dtype_addr; hsize_t dims[RANK]; @@ -257,8 +264,10 @@ test_h5o_open_by_addr(void) H5T_class_t type_class; /* Class of the datatype */ herr_t ret; /* Value returned from API calls */ + h5_fixname(TEST_FILENAME, H5P_DEFAULT, filename, sizeof filename); + /* Create a new HDF5 file */ - fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); /* Create a group, dataset, and committed datatype within the file */ @@ -397,15 +406,18 @@ test_h5o_open_by_token(void) { hid_t fid; /* HDF5 File ID */ hid_t grp, dset, dtype, dspace; /* Object identifiers */ - H5L_info2_t li; /* Buffer for H5Lget_info */ + char filename[1024]; + H5L_info2_t li; /* Buffer for H5Lget_info */ hsize_t dims[RANK]; H5I_type_t id_type; /* Type of IDs returned from H5Oopen */ H5G_info_t ginfo; /* Group info struct */ H5T_class_t type_class; /* Class of the datatype */ herr_t ret; /* Value returned from API calls */ + h5_fixname(TEST_FILENAME, H5P_DEFAULT, filename, sizeof filename); + /* Create a new HDF5 file */ - fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); /* Create a group, dataset, and committed datatype within the file */ @@ -515,12 +527,15 @@ test_h5o_refcount(void) { hid_t fid; /* HDF5 File ID */ hid_t grp, dset, dtype, dspace; /* Object identifiers */ - H5O_info2_t oinfo; /* Object info struct */ + char filename[1024]; + H5O_info2_t oinfo; /* Object info struct */ hsize_t dims[RANK]; herr_t ret; /* Value returned from API calls */ + h5_fixname(TEST_FILENAME, H5P_DEFAULT, filename, sizeof filename); + /* Create a new HDF5 file */ - fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); /* Create a group, dataset, and committed datatype within the file */ @@ -612,7 +627,7 @@ test_h5o_refcount(void) CHECK(ret, FAIL, "H5Fclose"); /* Re-open the file and check that the reference counts were really incremented */ - fid = H5Fopen(TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); + fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); grp = H5Gopen2(fid, "group", H5P_DEFAULT); @@ -650,7 +665,7 @@ test_h5o_refcount(void) CHECK(ret, FAIL, "H5Fclose"); /* Re-open the file and check that the reference counts were really decremented */ - fid = H5Fopen(TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); + fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); grp = H5Gopen2(fid, "group", H5P_DEFAULT); @@ -709,10 +724,11 @@ test_h5o_refcount(void) static void test_h5o_plist(void) { - hid_t fid; /* HDF5 File ID */ - hid_t grp, dset, dtype, dspace; /* Object identifiers */ - hid_t fapl; /* File access property list */ - hid_t gcpl, dcpl, tcpl; /* Object creation properties */ + hid_t fid; /* HDF5 File ID */ + hid_t grp, dset, dtype, dspace; /* Object identifiers */ + hid_t fapl; /* File access property list */ + hid_t gcpl, dcpl, tcpl; /* Object creation properties */ + char filename[1024]; unsigned def_max_compact, def_min_dense; /* Default phase change parameters */ unsigned max_compact, min_dense; /* Actual phase change parameters */ herr_t ret; /* Value returned from API calls */ @@ -725,8 +741,10 @@ test_h5o_plist(void) ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); CHECK(ret, FAIL, "H5Pset_libver_bounds"); + h5_fixname(TEST_FILENAME, fapl, filename, sizeof filename); + /* Create a new HDF5 file */ - fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); CHECK(fid, FAIL, "H5Fcreate"); /* Create group, dataset & named datatype creation property lists */ @@ -840,7 +858,7 @@ test_h5o_plist(void) CHECK(ret, FAIL, "H5Fclose"); /* Re-open the file and check that the object creation properties persist */ - fid = H5Fopen(TEST_FILENAME, H5F_ACC_RDONLY, fapl); + fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl); CHECK(fid, FAIL, "H5Fopen"); /* Re-open objects */ @@ -909,7 +927,8 @@ test_h5o_link(void) hid_t type_id = -1; hid_t fapl_id = -1; hid_t lcpl_id = -1; - hsize_t dims[2] = {TEST6_DIM1, TEST6_DIM2}; + char filename[1024]; + hsize_t dims[2] = {TEST6_DIM1, TEST6_DIM2}; htri_t committed; /* Whether the named datatype is committed */ H5F_libver_t low, high; /* File format bounds */ int * wdata; @@ -917,6 +936,8 @@ test_h5o_link(void) int i, n; herr_t ret; /* Value returned from API calls */ + h5_fixname(TEST_FILENAME, H5P_DEFAULT, filename, sizeof filename); + /* Allocate memory buffers */ /* (These are treated as 2-D buffers) */ wdata = (int *)HDmalloc((size_t)(TEST6_DIM1 * TEST6_DIM2) * sizeof(int)); @@ -957,7 +978,7 @@ test_h5o_link(void) continue; /* Create a new HDF5 file */ - file_id = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); CHECK(file_id, FAIL, "H5Fcreate"); /* Close the FAPL */ @@ -1060,6 +1081,7 @@ test_h5o_comment(void) hid_t fid; /* HDF5 File ID */ hid_t grp, dset, dtype, dspace; /* Object identifiers */ hid_t attr_space, attr_id; + char filename[1024]; hsize_t dims[RANK]; hsize_t attr_dims = 1; int attr_value = 5; @@ -1073,8 +1095,10 @@ test_h5o_comment(void) herr_t ret; /* Value returned from API calls */ int ret_value; + h5_fixname(TEST_FILENAME, H5P_DEFAULT, filename, sizeof filename); + /* Create a new HDF5 file */ - fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); /* Create an attribute for the file */ @@ -1152,7 +1176,7 @@ test_h5o_comment(void) /* Now make sure that the comments are correct all 4 types of objects */ /* Open file */ - fid = H5Fopen(TEST_FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); + fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); /* Getting the comment on the file and verify it */ @@ -1232,6 +1256,7 @@ test_h5o_comment_by_name(void) hid_t fid; /* HDF5 File ID */ hid_t grp, dset, dtype, dspace; /* Object identifiers */ hid_t attr_space, attr_id; + char filename[1024]; hsize_t dims[RANK]; hsize_t attr_dims = 1; int attr_value = 5; @@ -1245,8 +1270,10 @@ test_h5o_comment_by_name(void) herr_t ret; /* Value returned from API calls */ int ret_value; + h5_fixname(TEST_FILENAME, H5P_DEFAULT, filename, sizeof filename); + /* Create a new HDF5 file */ - fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); /* Create an attribute for the file */ @@ -1324,7 +1351,7 @@ test_h5o_comment_by_name(void) /* Now make sure that the comments are correct all 4 types of objects */ /* Open file */ - fid = H5Fopen(TEST_FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); + fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); /* Getting the comment on the file and verify it */ @@ -1390,13 +1417,16 @@ test_h5o_comment_by_name(void) static void test_h5o_getinfo_same_file(void) { - hid_t fid1, fid2; /* HDF5 File ID */ - hid_t gid1, gid2; /* Group IDs */ + hid_t fid1, fid2; /* HDF5 File ID */ + hid_t gid1, gid2; /* Group IDs */ + char filename[1024]; H5O_info2_t oinfo1, oinfo2; /* Object info structs */ herr_t ret; /* Value returned from API calls */ + h5_fixname(TEST_FILENAME, H5P_DEFAULT, filename, sizeof filename); + /* Create a new HDF5 file */ - fid1 = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid1 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fcreate"); /* Create two groups in the file */ @@ -1438,9 +1468,9 @@ test_h5o_getinfo_same_file(void) CHECK(ret, FAIL, "H5Fclose"); /* Open file twice */ - fid1 = H5Fopen(TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); + fid1 = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fopen"); - fid2 = H5Fopen(TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); + fid2 = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid2, FAIL, "H5Fopen"); /* Open the two groups in the file */ @@ -1497,8 +1527,9 @@ test_h5o_open_by_addr_deprec(void) { hid_t fid; /* HDF5 File ID */ hid_t grp, dset, dtype, dspace; /* Object identifiers */ - H5L_info1_t li; /* Buffer for H5Lget_info1 */ - haddr_t grp_addr; /* Addresses for objects */ + char filename[1024]; + H5L_info1_t li; /* Buffer for H5Lget_info1 */ + haddr_t grp_addr; /* Addresses for objects */ haddr_t dset_addr; haddr_t dtype_addr; hsize_t dims[RANK]; @@ -1507,8 +1538,10 @@ test_h5o_open_by_addr_deprec(void) H5T_class_t type_class; /* Class of the datatype */ herr_t ret; /* Value returned from API calls */ + h5_fixname(TEST_FILENAME, H5P_DEFAULT, filename, sizeof filename); + /* Create a new HDF5 file */ - fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); /* Create a group, dataset, and committed datatype within the file */ @@ -1682,13 +1715,16 @@ test_h5o_getinfo_visit(void) hid_t gid1 = -1, gid2 = -1; /* Group IDs */ hid_t sid = -1; /* Dataspace ID */ hid_t aid = -1; /* Attribute ID */ - H5O_info1_t oinfo1, oinfo2; /* Object info structs */ - char attrname[25]; /* Attribute name */ - int j; /* Local index variable */ - herr_t ret; /* Value returned from API calls */ + char filename[1024]; + H5O_info1_t oinfo1, oinfo2; /* Object info structs */ + char attrname[25]; /* Attribute name */ + int j; /* Local index variable */ + herr_t ret; /* Value returned from API calls */ + + h5_fixname(TEST_FILENAME, H5P_DEFAULT, filename, sizeof filename); /* Create an HDF5 file */ - fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); /* Create "group1" in the file */ @@ -1806,5 +1842,12 @@ test_h5o(void) void cleanup_h5o(void) { - HDremove(TEST_FILENAME); + char filename[1024]; + + H5E_BEGIN_TRY + { + h5_fixname(TEST_FILENAME, H5P_DEFAULT, filename, sizeof filename); + H5Fdelete(filename, H5P_DEFAULT); + } + H5E_END_TRY; } diff --git a/test/th5s.c b/test/th5s.c index 51216dcef59..97a67287104 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -194,7 +194,7 @@ test_h5s_basic(void) * If this test fails and the H5S_MAX_RANK variable has changed, follow * the instructions in space_overflow.c for regenerating the th5s.h5 file. */ - { + if (!h5_driver_uses_modified_filename()) { const char *testfile = H5_get_srcdir_filename(TESTFILE); /* Corrected test file name */ fid1 = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT); diff --git a/test/titerate.c b/test/titerate.c index 10ed039fb78..1d873433244 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -1175,8 +1175,10 @@ test_iterate(void) #endif } /* end for */ - /* Test the fix for issue HDFFV-10588 */ - test_corrupted_attnamelen(); + if (!h5_driver_uses_modified_filename()) { + /* Test the fix for issue HDFFV-10588 */ + test_corrupted_attnamelen(); + } /* Close FAPLs */ ret = H5Pclose(fapl); diff --git a/test/tmisc.c b/test/tmisc.c index 302da0d4dea..9b99482ee42 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -287,7 +287,7 @@ typedef struct { #define MISC25C_ATTRNAME2 "ab" /* Definitions for misc. test #26 */ -#define MISC26_FILE "dcpl_file" +#define MISC26_FILE "dcpl_file.h5" /* Definitions for misc. test #27 */ /* (Note that this test file is generated by the "gen_bad_ohdr.c" code) */ @@ -6026,29 +6026,51 @@ test_misc36(void) void test_misc(void) { + hbool_t driver_uses_modified_filename = h5_driver_uses_modified_filename(); + hbool_t default_driver = h5_using_default_driver(NULL); + /* Output message about test being performed */ MESSAGE(5, ("Testing Miscellaneous Routines\n")); - test_misc1(); /* Test unlinking a dataset & immediately re-using name */ - test_misc2(); /* Test storing a VL-derived datatype in two different files */ - test_misc3(); /* Test reading from chunked dataset with non-zero fill value */ - test_misc4(); /* Test retrieving the fileno for various objects with H5Oget_info() */ - test_misc5(); /* Test several level deep nested compound & VL datatypes */ - test_misc6(); /* Test object header continuation code */ - test_misc7(); /* Test for sensible datatypes stored on disk */ - test_misc8(); /* Test storage sizes of various types of dataset storage */ - test_misc9(); /* Test for opening (not creating) core files */ - test_misc10(); /* Test for using dataset creation property lists from old files */ - test_misc11(); /* Test for all properties of a file creation property list being stored */ + test_misc1(); /* Test unlinking a dataset & immediately re-using name */ + test_misc2(); /* Test storing a VL-derived datatype in two different files */ + test_misc3(); /* Test reading from chunked dataset with non-zero fill value */ + test_misc4(); /* Test retrieving the fileno for various objects with H5Oget_info() */ + test_misc5(); /* Test several level deep nested compound & VL datatypes */ + test_misc6(); /* Test object header continuation code */ + test_misc7(); /* Test for sensible datatypes stored on disk */ + test_misc8(); /* Test storage sizes of various types of dataset storage */ + test_misc9(); /* Test for opening (not creating) core files */ + + if (!driver_uses_modified_filename) { + test_misc10(); /* Test for using dataset creation property lists from old files */ + } + + if (default_driver) { + test_misc11(); /* Test for all properties of a file creation property list being stored */ + } + test_misc12(); /* Test VL-strings in chunked datasets operating correctly */ - test_misc13(); /* Test that a user block can be insert in front of file contents */ + + if (default_driver) { + test_misc13(); /* Test that a user block can be insert in front of file contents */ + } + test_misc14(); /* Test that deleted dataset's data is removed from sieve buffer correctly */ - test_misc15(); /* Test that checking a file's access property list more than once works */ + + if (!driver_uses_modified_filename) { + test_misc15(); /* Test that checking a file's access property list more than once works */ + } + test_misc16(); /* Test array of fixed-length string */ test_misc17(); /* Test array of ASCII character */ test_misc18(); /* Test new object header information in H5O_info_t struct */ test_misc19(); /* Test incrementing & decrementing ref count on IDs */ - test_misc20(); /* Test problems with truncated dimensions in version 2 of storage layout message */ + + if (!driver_uses_modified_filename) { + test_misc20(); /* Test problems with truncated dimensions in version 2 of storage layout message */ + } + #ifdef H5_HAVE_FILTER_SZIP test_misc21(); /* Test that "late" allocation time is treated the same as "incremental", for chunked datasets w/a filters */ @@ -6057,19 +6079,39 @@ test_misc(void) test_misc23(); /* Test intermediate group creation */ test_misc24(); /* Test inappropriate API opens of objects */ test_misc25a(); /* Exercise null object header message merge bug */ - test_misc25b(); /* Exercise null object header message merge bug on existing file */ + + if (!driver_uses_modified_filename) { + test_misc25b(); /* Exercise null object header message merge bug on existing file */ + } + test_misc25c(); /* Exercise another null object header message merge bug */ test_misc26(); /* Test closing property lists with long filter pipelines */ - test_misc27(); /* Test opening file with object that has bad # of object header messages */ - test_misc28(); /* Test that chunks are cached appropriately */ - test_misc29(); /* Test that speculative metadata reads are handled correctly */ - test_misc30(); /* Exercise local heap loading bug where free lists were getting dropped */ - test_misc31(); /* Test Reentering library through deprecated routines after H5close() */ - test_misc32(); /* Test filter memory allocation functions */ - test_misc33(); /* Test to verify that H5HL_offset_into() returns error if offset exceeds heap block */ - test_misc34(); /* Test behavior of 0 and NULL in H5MM API calls */ - test_misc35(); /* Test behavior of free-list & allocation statistics API calls */ - test_misc36(); /* Exercise H5atclose and H5is_library_terminating */ + + if (!driver_uses_modified_filename) { + test_misc27(); /* Test opening file with object that has bad # of object header messages */ + } + + test_misc28(); /* Test that chunks are cached appropriately */ + + if (!driver_uses_modified_filename) { + test_misc29(); /* Test that speculative metadata reads are handled correctly */ + } + + test_misc30(); /* Exercise local heap loading bug where free lists were getting dropped */ + + if (default_driver) { + test_misc31(); /* Test Reentering library through deprecated routines after H5close() */ + } + + test_misc32(); /* Test filter memory allocation functions */ + + if (!driver_uses_modified_filename) { + test_misc33(); /* Test to verify that H5HL_offset_into() returns error if offset exceeds heap block */ + } + + test_misc34(); /* Test behavior of 0 and NULL in H5MM API calls */ + test_misc35(); /* Test behavior of free-list & allocation statistics API calls */ + test_misc36(); /* Exercise H5atclose and H5is_library_terminating */ } /* test_misc() */ diff --git a/test/trefer.c b/test/trefer.c index 9b6c415e4c1..0e1ae708bf4 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -3452,11 +3452,17 @@ test_reference_perf(void) void test_reference(void) { - H5F_libver_t low, high; /* Low and high bounds */ + H5F_libver_t low, high; /* Low and high bounds */ + const char * env_h5_drvr; /* File Driver value from environment */ /* Output message about test being performed */ MESSAGE(5, ("Testing References\n")); + /* Get the VFD to use */ + env_h5_drvr = HDgetenv("HDF5_DRIVER"); + if (env_h5_drvr == NULL) + env_h5_drvr = "nomatch"; + test_reference_params(); /* Test for correct parameter checking */ test_reference_obj(); /* Test basic H5R object reference code */ test_reference_vlen_obj(); /* Test reference within vlen */ @@ -3476,7 +3482,11 @@ test_reference(void) } /* end high bound */ } /* end low bound */ - test_reference_obj_deleted(); /* Test H5R object reference code for deleted objects */ + /* The following test is currently broken with the Direct VFD */ + if (HDstrcmp(env_h5_drvr, "direct") != 0) { + test_reference_obj_deleted(); /* Test H5R object reference code for deleted objects */ + } + test_reference_group(); /* Test operations on dereferenced groups */ test_reference_attr(); /* Test attribute references */ test_reference_external(); /* Test external references */ diff --git a/test/tselect.c b/test/tselect.c index 1bfb663dbdb..25720c9f3d1 100644 --- a/test/tselect.c +++ b/test/tselect.c @@ -15991,18 +15991,24 @@ test_h5s_set_extent_none(void) void test_select(void) { - hid_t plist_id; /* Property list for reading random hyperslabs */ - hid_t fapl; /* Property list accessing the file */ - int mdc_nelmts; /* Metadata number of elements */ - size_t rdcc_nelmts; /* Raw data number of elements */ - size_t rdcc_nbytes; /* Raw data number of bytes */ - double rdcc_w0; /* Raw data write percentage */ - hssize_t offset[SPACE7_RANK] = {1, 1}; /* Offset for testing selection offsets */ - herr_t ret; /* Generic return value */ + hid_t plist_id; /* Property list for reading random hyperslabs */ + hid_t fapl; /* Property list accessing the file */ + int mdc_nelmts; /* Metadata number of elements */ + size_t rdcc_nelmts; /* Raw data number of elements */ + size_t rdcc_nbytes; /* Raw data number of bytes */ + double rdcc_w0; /* Raw data write percentage */ + hssize_t offset[SPACE7_RANK] = {1, 1}; /* Offset for testing selection offsets */ + const char *env_h5_drvr; /* File Driver value from environment */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Selections\n")); + /* Get the VFD to use */ + env_h5_drvr = HDgetenv("HDF5_DRIVER"); + if (env_h5_drvr == NULL) + env_h5_drvr = "nomatch"; + /* Create a dataset transfer property list */ plist_id = H5Pcreate(H5P_DATASET_XFER); CHECK(plist_id, FAIL, "H5Pcreate"); @@ -16065,10 +16071,13 @@ test_select(void) test_select_hyper_union_3d(); /* Test hyperslab union code for 3-D dataset */ test_select_hyper_valid_combination(); /* Test different input combinations */ - test_select_hyper_and_2d(); /* Test hyperslab intersection (AND) code for 2-D dataset */ - test_select_hyper_xor_2d(); /* Test hyperslab XOR code for 2-D dataset */ - test_select_hyper_notb_2d(); /* Test hyperslab NOTB code for 2-D dataset */ - test_select_hyper_nota_2d(); /* Test hyperslab NOTA code for 2-D dataset */ + /* The following tests are currently broken with the Direct VFD */ + if (HDstrcmp(env_h5_drvr, "direct") != 0) { + test_select_hyper_and_2d(); /* Test hyperslab intersection (AND) code for 2-D dataset */ + test_select_hyper_xor_2d(); /* Test hyperslab XOR code for 2-D dataset */ + test_select_hyper_notb_2d(); /* Test hyperslab NOTB code for 2-D dataset */ + test_select_hyper_nota_2d(); /* Test hyperslab NOTA code for 2-D dataset */ + } /* test the random hyperslab I/O with the default property list for reading */ test_select_hyper_union_random_5d(H5P_DEFAULT); /* Test hyperslab union code for random 5-D hyperslabs */ diff --git a/test/tsohm.c b/test/tsohm.c index fcbb06a9225..e8ef8ef435f 100644 --- a/test/tsohm.c +++ b/test/tsohm.c @@ -3815,23 +3815,45 @@ test_sohm_external_dtype(void) void test_sohm(void) { + const char *env_h5_drvr; + hbool_t default_driver; + MESSAGE(5, ("Testing Shared Object Header Messages\n")); - test_sohm_fcpl(); /* Test SOHMs and file creation plists */ - test_sohm_fcpl_errors(); /* Bogus H5P* calls for SOHMs */ - test_sohm_size1(); /* Tests the sizes of files with one SOHM */ -#if 0 /* TODO: REVEALS BUG TO BE FIXED - SEE JIRA HDFFV-10645 */ + /* Get the VFD to use */ + env_h5_drvr = HDgetenv("HDF5_DRIVER"); + if (env_h5_drvr == NULL) + env_h5_drvr = "nomatch"; + + default_driver = h5_using_default_driver(env_h5_drvr); + + test_sohm_fcpl(); /* Test SOHMs and file creation plists */ + test_sohm_fcpl_errors(); /* Bogus H5P* calls for SOHMs */ + + /* Only run this test with sec2/default driver */ + if (default_driver) + test_sohm_size1(); /* Tests the sizes of files with one SOHM */ + +#if 0 /* TODO: REVEALS BUG TO BE FIXED - SEE JIRA HDFFV-10645 */ test_sohm_size_consistency_open_create(); -#endif /* Jira HDFFV-10645 */ - test_sohm_attrs(); /* Tests shared messages in attributes */ - test_sohm_size2(0); /* Tests the sizes of files with multiple SOHMs */ - test_sohm_size2(1); /* Tests the sizes of files with multiple - * SOHMs, closing and reopening file after - * each write. */ +#endif /* Jira HDFFV-10645 */ + test_sohm_attrs(); /* Tests shared messages in attributes */ + + /* Only run these tests with sec2/default driver */ + if (default_driver) { + test_sohm_size2(0); /* Tests the sizes of files with multiple SOHMs */ + test_sohm_size2(1); /* Tests the sizes of files with multiple + * SOHMs, closing and reopening file after + * each write. */ + } + test_sohm_delete(); /* Test deleting shared messages */ test_sohm_delete_revert(); /* Test that a file with SOHMs becomes an * empty file again when they are deleted. */ - test_sohm_extlink(); /* Test SOHMs when external links are used */ + + if (!h5_driver_uses_modified_filename()) { + test_sohm_extlink(); /* Test SOHMs when external links are used */ + } test_sohm_extend_dset(); /* Test extending shared datasets */ test_sohm_external_dtype(); /* Test using datatype in another file */ diff --git a/test/vds.c b/test/vds.c index 88ac4ebce8f..46cfe31e1bb 100644 --- a/test/vds.c +++ b/test/vds.c @@ -12288,9 +12288,24 @@ main(void) hid_t src_fapl = -1; /* File access property list */ int test_api_config; unsigned bit_config; - H5F_libver_t low, high; /* Low and high bounds */ + H5F_libver_t low, high; /* Low and high bounds */ + const char * env_h5_drvr; /* File Driver value from environment */ int nerrors = 0; + env_h5_drvr = HDgetenv("HDF5_DRIVER"); + if (env_h5_drvr == NULL) + env_h5_drvr = "nomatch"; + + /* + * Skip VDS tests for parallel-enabled and splitter VFDs. VDS currently + * doesn't support parallel reads and the splitter VFD has external + * link-related bugs. + */ + if (h5_using_parallel_driver(env_h5_drvr) || !HDstrcmp(env_h5_drvr, "splitter")) { + HDputs(" -- SKIPPED for incompatible VFD --"); + HDexit(EXIT_SUCCESS); + } + /* Testing setup */ h5_reset(); fapl = h5_fileaccess(); diff --git a/test/vds_env.c b/test/vds_env.c index 58d90fc9d38..a8419a4266f 100644 --- a/test/vds_env.c +++ b/test/vds_env.c @@ -298,9 +298,24 @@ main(void) { hid_t fapl, my_fapl; unsigned bit_config; - H5F_libver_t low, high; /* Low and high bounds */ + H5F_libver_t low, high; /* Low and high bounds */ + const char * env_h5_drvr; /* File Driver value from environment */ int nerrors = 0; + env_h5_drvr = HDgetenv("HDF5_DRIVER"); + if (env_h5_drvr == NULL) + env_h5_drvr = "nomatch"; + + /* + * Skip VDS tests for parallel-enabled and splitter VFDs. VDS currently + * doesn't support parallel reads and the splitter VFD has external + * link-related bugs. + */ + if (h5_using_parallel_driver(env_h5_drvr) || !HDstrcmp(env_h5_drvr, "splitter")) { + HDputs(" -- SKIPPED for incompatible VFD --"); + HDexit(EXIT_SUCCESS); + } + /* Testing setup */ h5_reset(); fapl = h5_fileaccess(); diff --git a/test/vfd.c b/test/vfd.c index 8484bfd61db..f4d642a2314 100644 --- a/test/vfd.c +++ b/test/vfd.c @@ -51,7 +51,7 @@ const char *FILENAME[] = {"sec2_file", /*0*/ "core_file", /*1*/ "family_file", /*2*/ - "new_family_v16_", /*3*/ + "new_family_v16", /*3*/ "multi_file", /*4*/ "direct_file", /*5*/ "log_file", /*6*/ @@ -66,7 +66,7 @@ const char *FILENAME[] = {"sec2_file", /*0*/ #define LOG_FILENAME "log_vfd_out.log" -#define COMPAT_BASENAME "family_v16_" +#define COMPAT_BASENAME "family_v16" #define MULTI_COMPAT_BASENAME "multi_file_v16" #define SPLITTER_DATASET_NAME "dataset" @@ -3410,7 +3410,18 @@ test_splitter(void) int main(void) { - int nerrors = 0; + char *env_h5_drvr = NULL; + int nerrors = 0; + + /* Don't run VFD tests when HDF5_DRIVER is set. These tests expect a + * specific VFD to be set and HDF5_DRIVER being set can interfere + * with that. + */ + env_h5_drvr = HDgetenv("HDF5_DRIVER"); + if (env_h5_drvr) { + HDprintf(" -- SKIPPED VFD tests because HDF5_DRIVER is set -- \n"); + HDexit(EXIT_SUCCESS); + } h5_reset(); diff --git a/test/vfd_plugin.c b/test/vfd_plugin.c index 4ee36b58b74..a6fcfe99d4f 100644 --- a/test/vfd_plugin.c +++ b/test/vfd_plugin.c @@ -280,10 +280,10 @@ test_set_multi(void) static herr_t test_get_config_str(void) { - const char * const config_str = "{name: sec2}"; - ssize_t config_str_len = 0; - hid_t fapl_id = H5I_INVALID_HID; - char config_str_buf[128]; + const char *const config_str = "{name: sec2}"; + ssize_t config_str_len = 0; + hid_t fapl_id = H5I_INVALID_HID; + char config_str_buf[128]; TESTING("Retrieval of VFD configuration string"); @@ -313,6 +313,33 @@ test_get_config_str(void) if (H5Pclose(fapl_id) < 0) TEST_ERROR; + /* Set default driver and driver configuration using environment variables */ + if (HDsetenv("HDF5_DRIVER", "sec2", 1) < 0) + TEST_ERROR; + if (HDsetenv("HDF5_DRIVER_CONFIG", config_str, 1) < 0) + TEST_ERROR; + + /* Close and re-open HDF5 to have it parse the environment variables */ + if (H5close() < 0) + TEST_ERROR; + if (H5open() < 0) + TEST_ERROR; + + /* Retrieve configuration string from default FAPL */ + HDmemset(config_str_buf, 0, 128); + if ((config_str_len = H5Pget_driver_config_str(H5P_FILE_ACCESS_DEFAULT, config_str_buf, 128)) < 0) + TEST_ERROR; + if (HDstrlen(config_str) != config_str_len) + TEST_ERROR; + if (HDstrncmp(config_str_buf, config_str, 128)) + TEST_ERROR; + + /* Unset environment variables */ + if (HDsetenv("HDF5_DRIVER", "", 1) < 0) + TEST_ERROR; + if (HDsetenv("HDF5_DRIVER_CONFIG", "", 1) < 0) + TEST_ERROR; + PASSED(); return SUCCEED; diff --git a/test/vol.c b/test/vol.c index c7586d50882..1dde76d566b 100644 --- a/test/vol.c +++ b/test/vol.c @@ -814,9 +814,11 @@ test_basic_file_operation(const char *env_h5_drvr) if ((obj_count = H5Fget_obj_ids((hid_t)H5F_OBJ_ALL, H5F_OBJ_DATASET, 2, obj_id_list)) < 0) TEST_ERROR; - /* Can't compare VFD properties for split / multi / family VFDs */ + /* Can't compare VFD properties for several VFDs */ if ((hbool_t)(HDstrcmp(env_h5_drvr, "split") != 0 && HDstrcmp(env_h5_drvr, "multi") != 0 && - HDstrcmp(env_h5_drvr, "family") != 0)) { + HDstrcmp(env_h5_drvr, "family") != 0 && HDstrcmp(env_h5_drvr, "direct") != 0 && + HDstrcmp(env_h5_drvr, "core") != 0 && HDstrcmp(env_h5_drvr, "core_paged") != 0) && + HDstrcmp(env_h5_drvr, "mpio") != 0 && HDstrcmp(env_h5_drvr, "splitter") != 0) { /* H5Fget_access_plist */ if ((fapl_id2 = H5Fget_access_plist(fid)) < 0) TEST_ERROR; @@ -876,9 +878,11 @@ test_basic_file_operation(const char *env_h5_drvr) if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR; - /* Can't compare VFD properties for split / multi / family VFDs */ + /* Can't compare VFD properties for several VFDs */ if ((hbool_t)(HDstrcmp(env_h5_drvr, "split") != 0 && HDstrcmp(env_h5_drvr, "multi") != 0 && - HDstrcmp(env_h5_drvr, "family") != 0)) { + HDstrcmp(env_h5_drvr, "family") != 0 && HDstrcmp(env_h5_drvr, "direct") != 0 && + HDstrcmp(env_h5_drvr, "core") != 0 && HDstrcmp(env_h5_drvr, "core_paged") != 0) && + HDstrcmp(env_h5_drvr, "mpio") != 0 && HDstrcmp(env_h5_drvr, "splitter") != 0) { /* H5Fget_access_plist */ if ((fapl_id2 = H5Fget_access_plist(fid)) < 0) TEST_ERROR; @@ -891,9 +895,11 @@ test_basic_file_operation(const char *env_h5_drvr) if ((fid_reopen = H5Freopen(fid)) < 0) TEST_ERROR; - /* Can't compare VFD properties for split / multi / family VFDs */ + /* Can't compare VFD properties for several VFDs */ if ((hbool_t)(HDstrcmp(env_h5_drvr, "split") != 0 && HDstrcmp(env_h5_drvr, "multi") != 0 && - HDstrcmp(env_h5_drvr, "family") != 0)) { + HDstrcmp(env_h5_drvr, "family") != 0 && HDstrcmp(env_h5_drvr, "direct") != 0 && + HDstrcmp(env_h5_drvr, "core") != 0 && HDstrcmp(env_h5_drvr, "core_paged") != 0) && + HDstrcmp(env_h5_drvr, "mpio") != 0 && HDstrcmp(env_h5_drvr, "splitter") != 0) { /* H5Fget_access_plist */ if ((fapl_id2 = H5Fget_access_plist(fid_reopen)) < 0) TEST_ERROR; @@ -942,7 +948,7 @@ test_basic_file_operation(const char *env_h5_drvr) *------------------------------------------------------------------------- */ static herr_t -test_basic_group_operation(void) +test_basic_group_operation(const char *env_h5_drvr) { hid_t fid = H5I_INVALID_HID; hid_t fapl_id = H5I_INVALID_HID; @@ -985,9 +991,10 @@ test_basic_group_operation(void) if (H5Gget_info_by_idx(fid, "/", H5_INDEX_NAME, H5_ITER_NATIVE, 0, &info, H5P_DEFAULT) < 0) TEST_ERROR; - /* H5Gflush */ - if (H5Gflush(gid) < 0) - TEST_ERROR; + /* H5Gflush - skip for MPIO file driver as flush calls cause assertions in the library */ + if (HDstrcmp(env_h5_drvr, "mpio") != 0) + if (H5Gflush(gid) < 0) + TEST_ERROR; /* H5Gclose */ if (H5Gclose(gid) < 0) @@ -1045,7 +1052,7 @@ test_basic_group_operation(void) *------------------------------------------------------------------------- */ static herr_t -test_basic_dataset_operation(void) +test_basic_dataset_operation(const char *env_h5_drvr) { hid_t fid = H5I_INVALID_HID; hid_t fapl_id = H5I_INVALID_HID; @@ -1110,9 +1117,10 @@ test_basic_dataset_operation(void) if (H5Dset_extent(did, &curr_dims) < 0) TEST_ERROR; - /* H5Dflush */ - if (H5Dflush(did) < 0) - TEST_ERROR; + /* H5Dflush - skip for MPIO file driver as flush calls cause assertions in the library */ + if (HDstrcmp(env_h5_drvr, "mpio") != 0) + if (H5Dflush(did) < 0) + TEST_ERROR; /* H5Dwrite */ if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, in_buf) < 0) @@ -1384,10 +1392,10 @@ test_basic_object_operation(void) if (H5Oclose(oid) < 0) TEST_ERROR; - if (H5Fclose(fid) < 0) - TEST_ERROR; if (H5Gclose(gid) < 0) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; h5_delete_test_file(FILENAME[0], fapl_id); @@ -1463,10 +1471,10 @@ test_basic_link_operation(void) H5P_DEFAULT) < 0) TEST_ERROR; - if (H5Fclose(fid) < 0) - TEST_ERROR; if (H5Gclose(gid) < 0) TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; h5_delete_test_file(FILENAME[0], fapl_id); @@ -1500,7 +1508,7 @@ test_basic_link_operation(void) *------------------------------------------------------------------------- */ static herr_t -test_basic_datatype_operation(void) +test_basic_datatype_operation(const char *env_h5_drvr) { hid_t fid = H5I_INVALID_HID; hid_t fapl_id = H5I_INVALID_HID; @@ -1524,9 +1532,10 @@ test_basic_datatype_operation(void) if (H5Tcommit2(fid, NATIVE_VOL_TEST_DATATYPE_NAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; - /* H5Tflush */ - if (H5Tflush(tid) < 0) - TEST_ERROR; + /* H5Tflush - skip for MPIO file driver as flush calls cause assertions in the library */ + if (HDstrcmp(env_h5_drvr, "mpio") != 0) + if (H5Tflush(tid) < 0) + TEST_ERROR; /* H5Trefresh */ if (H5Trefresh(tid) < 0) @@ -2124,12 +2133,12 @@ main(void) nerrors += test_register_opt_operation() < 0 ? 1 : 0; nerrors += test_native_vol_init() < 0 ? 1 : 0; nerrors += test_basic_file_operation(env_h5_drvr) < 0 ? 1 : 0; - nerrors += test_basic_group_operation() < 0 ? 1 : 0; - nerrors += test_basic_dataset_operation() < 0 ? 1 : 0; + nerrors += test_basic_group_operation(env_h5_drvr) < 0 ? 1 : 0; + nerrors += test_basic_dataset_operation(env_h5_drvr) < 0 ? 1 : 0; nerrors += test_basic_attribute_operation() < 0 ? 1 : 0; nerrors += test_basic_object_operation() < 0 ? 1 : 0; nerrors += test_basic_link_operation() < 0 ? 1 : 0; - nerrors += test_basic_datatype_operation() < 0 ? 1 : 0; + nerrors += test_basic_datatype_operation(env_h5_drvr) < 0 ? 1 : 0; nerrors += test_async_vol_props() < 0 ? 1 : 0; if (nerrors) { diff --git a/testpar/CMakeVFDTests.cmake b/testpar/CMakeVFDTests.cmake index f50ca16860e..785c08d8e10 100644 --- a/testpar/CMakeVFDTests.cmake +++ b/testpar/CMakeVFDTests.cmake @@ -23,6 +23,8 @@ set (VFD_LIST split multi family + splitter + #log - log VFD currently has file space allocation bugs ) set (H5P_VFD_TESTS @@ -33,6 +35,21 @@ set (H5P_VFD_TESTS if (H5_HAVE_DIRECT) set (VFD_LIST ${VFD_LIST} direct) endif () +if (H5_HAVE_PARALLEL) + set (VFD_LIST ${VFD_LIST} mpio) +endif () +if (H5_HAVE_MIRROR_VFD) + set (VFD_LIST ${VFD_LIST} mirror) +endif () +if (H5_HAVE_ROS3_VFD) + set (VFD_LIST ${VFD_LIST} ros3) +endif () +if (H5_HAVE_LIBHDFS) + set (VFD_LIST ${VFD_LIST} hdfs) +endif () +if (H5_HAVE_WINDOWS) + set (VFD_LIST ${VFD_LIST} windows) +endif () foreach (vfdtest ${VFD_LIST}) file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdtest}") diff --git a/testpar/t_pflush1.c b/testpar/t_pflush1.c index 2a80f4af891..5f9a1eee8a1 100644 --- a/testpar/t_pflush1.c +++ b/testpar/t_pflush1.c @@ -207,5 +207,7 @@ main(int argc, char *argv[]) HDfflush(stderr); HDprintf("*** ERROR ***\n"); HDprintf("THERE WAS A REAL ERROR IN t_pflush1.\n"); + HDfflush(stdout); + HD_exit(EXIT_FAILURE); } /* end main() */ diff --git a/testpar/t_pflush2.c b/testpar/t_pflush2.c index c96233a0fcd..8d6e07d065e 100644 --- a/testpar/t_pflush2.c +++ b/testpar/t_pflush2.c @@ -167,7 +167,7 @@ main(int argc, char *argv[]) HDputs(" Test not compatible with current Virtual File Driver"); } MPI_Finalize(); - HDexit(EXIT_FAILURE); + HDexit(EXIT_SUCCESS); } if ((fapl_id1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index 39a3574121c..08568cd2d2d 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -31,7 +31,7 @@ const char *outfile = NULL; * Command-line options: The user can specify short or long-named * parameters. */ -static const char * s_opts = "a:b:c:d:e:f:hi:j:k:l:m:no:q:s:t:u:vz:EG:LM:P:S:T:VXWY:Z:1:2:3:4:5:6:7:8:9:0:"; +static const char *s_opts = "a:b:c:d:e:f:hi:j:k:l:m:no:q:s:t:u:vz:EG:LM:P:S:T:VXWY:Z:1:2:3:4:5:6:7:8:9:0:"; static struct h5_long_options l_opts[] = {{"alignment", require_arg, 'a'}, {"block", require_arg, 'b'}, {"compact", require_arg, 'c'}, diff --git a/tools/test/h5repack/CMakeVFDTests.cmake b/tools/test/h5repack/CMakeVFDTests.cmake index e26941b14b7..4f6e51dc330 100644 --- a/tools/test/h5repack/CMakeVFDTests.cmake +++ b/tools/test/h5repack/CMakeVFDTests.cmake @@ -24,11 +24,28 @@ set (VFD_LIST split multi family + splitter + #log - log VFD currently has file space allocation bugs ) if (H5_HAVE_DIRECT) set (VFD_LIST ${VFD_LIST} direct) endif () +if (H5_HAVE_PARALLEL) + set (VFD_LIST ${VFD_LIST} mpio) +endif () +if (H5_HAVE_MIRROR_VFD) + set (VFD_LIST ${VFD_LIST} mirror) +endif () +if (H5_HAVE_ROS3_VFD) + set (VFD_LIST ${VFD_LIST} ros3) +endif () +if (H5_HAVE_LIBHDFS) + set (VFD_LIST ${VFD_LIST} hdfs) +endif () +if (H5_HAVE_WINDOWS) + set (VFD_LIST ${VFD_LIST} windows) +endif () ############################################################################## ############################################################################## diff --git a/tools/test/h5repack/h5repacktst.c b/tools/test/h5repack/h5repacktst.c index acad74eb97c..9aa6b223af5 100644 --- a/tools/test/h5repack/h5repacktst.c +++ b/tools/test/h5repack/h5repacktst.c @@ -272,98 +272,100 @@ main(void) GOERROR; PASSED(); - TESTING(" files with file space info setting-- options -S and -P are set & -L"); - ++j; /* #3 */ - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - fname = H5REPACK_FSPACE_FNAMES[j]; - if (h5repack_init(&pack_options, 0, TRUE) < 0) - GOERROR; - pack_options.fs_strategy = H5F_FSPACE_STRATEGY_PAGE; /* "PAGE" specified via -S */ - pack_options.fs_persist = TRUE; - if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) - GOERROR; - if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) - GOERROR; - if (h5repack_end(&pack_options) < 0) - GOERROR; - PASSED(); + if (h5_using_default_driver(NULL)) { + TESTING(" files with file space info setting-- options -S and -P are set & -L"); + ++j; /* #3 */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + fname = H5REPACK_FSPACE_FNAMES[j]; + if (h5repack_init(&pack_options, 0, TRUE) < 0) + GOERROR; + pack_options.fs_strategy = H5F_FSPACE_STRATEGY_PAGE; /* "PAGE" specified via -S */ + pack_options.fs_persist = TRUE; + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) + GOERROR; + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); - TESTING(" files with file space info setting-- options -P and -T are set & -L"); - ++j; /* #4 */ - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - fname = H5REPACK_FSPACE_FNAMES[j]; - if (h5repack_init(&pack_options, 0, TRUE) < 0) - GOERROR; - pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ - pack_options.fs_threshold = 2; - if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) - GOERROR; - if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) - GOERROR; - if (h5repack_end(&pack_options) < 0) - GOERROR; - PASSED(); + TESTING(" files with file space info setting-- options -P and -T are set & -L"); + ++j; /* #4 */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + fname = H5REPACK_FSPACE_FNAMES[j]; + if (h5repack_init(&pack_options, 0, TRUE) < 0) + GOERROR; + pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ + pack_options.fs_threshold = 2; + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) + GOERROR; + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); - TESTING(" files with file space info setting-- options -S and -G are set & -L"); - ++j; /* #5 */ - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - fname = H5REPACK_FSPACE_FNAMES[j]; - if (h5repack_init(&pack_options, 0, TRUE) < 0) - GOERROR; - pack_options.fs_strategy = H5F_FSPACE_STRATEGY_PAGE; - pack_options.fs_pagesize = 8192; - if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) - GOERROR; - if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) - GOERROR; - if (h5repack_end(&pack_options) < 0) - GOERROR; - PASSED(); + TESTING(" files with file space info setting-- options -S and -G are set & -L"); + ++j; /* #5 */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + fname = H5REPACK_FSPACE_FNAMES[j]; + if (h5repack_init(&pack_options, 0, TRUE) < 0) + GOERROR; + pack_options.fs_strategy = H5F_FSPACE_STRATEGY_PAGE; + pack_options.fs_pagesize = 8192; + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) + GOERROR; + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); - TESTING(" files with file space info setting-- options -S, -P, -T, -G are set"); - ++j; /* #6 */ - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - fname = H5REPACK_FSPACE_FNAMES[j]; - if (h5repack_init(&pack_options, 0, FALSE) < 0) - GOERROR; - pack_options.fs_strategy = H5F_FSPACE_STRATEGY_NONE; - pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ - pack_options.fs_threshold = 1; - pack_options.fs_pagesize = 8192; - if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) - GOERROR; - if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) - GOERROR; - if (h5repack_end(&pack_options) < 0) - GOERROR; - PASSED(); + TESTING(" files with file space info setting-- options -S, -P, -T, -G are set"); + ++j; /* #6 */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + fname = H5REPACK_FSPACE_FNAMES[j]; + if (h5repack_init(&pack_options, 0, FALSE) < 0) + GOERROR; + pack_options.fs_strategy = H5F_FSPACE_STRATEGY_NONE; + pack_options.fs_persist = -1; /* "FALSE" is set via -P 0 */ + pack_options.fs_threshold = 1; + pack_options.fs_pagesize = 8192; + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) + GOERROR; + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); - TESTING(" files with file space info setting-- options -S, -T, -G are set & -L"); - ++j; /* #7 */ - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - fname = H5REPACK_FSPACE_FNAMES[j]; - if (h5repack_init(&pack_options, 0, TRUE) < 0) - GOERROR; - pack_options.fs_strategy = H5F_FSPACE_STRATEGY_AGGR; - pack_options.fs_threshold = 1; - pack_options.fs_pagesize = 4096; - if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) - GOERROR; - if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) - GOERROR; - if (h5repack_end(&pack_options) < 0) - GOERROR; - PASSED(); + TESTING(" files with file space info setting-- options -S, -T, -G are set & -L"); + ++j; /* #7 */ + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + fname = H5REPACK_FSPACE_FNAMES[j]; + if (h5repack_init(&pack_options, 0, TRUE) < 0) + GOERROR; + pack_options.fs_strategy = H5F_FSPACE_STRATEGY_AGGR; + pack_options.fs_threshold = 1; + pack_options.fs_pagesize = 4096; + if (h5repack(fname, FSPACE_OUT, &pack_options) < 0) + GOERROR; + if (h5diff(fname, FSPACE_OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(fname, FSPACE_OUT, &pack_options) <= 0) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); + } /*------------------------------------------------------------------------- * file with fill values @@ -389,20 +391,22 @@ main(void) * file with all kinds of dataset datatypes *------------------------------------------------------------------------- */ - TESTING(" copy of datasets (all datatypes)"); - if (h5repack_init(&pack_options, 0, FALSE) < 0) - GOERROR; - if (h5repack(FNAME1, FNAME1OUT, &pack_options) < 0) - GOERROR; - if (h5diff(FNAME1, FNAME1OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if (h5repack_verify(FNAME1, FNAME1OUT, &pack_options) <= 0) - GOERROR; - if (h5repack_cmp_pl(FNAME1, pack_options.fin_fapl, FNAME1OUT, pack_options.fout_fapl) <= 0) - GOERROR; - if (h5repack_end(&pack_options) < 0) - GOERROR; - PASSED(); + if (!h5_using_parallel_driver(NULL)) { + TESTING(" copy of datasets (all datatypes)"); + if (h5repack_init(&pack_options, 0, FALSE) < 0) + GOERROR; + if (h5repack(FNAME1, FNAME1OUT, &pack_options) < 0) + GOERROR; + if (h5diff(FNAME1, FNAME1OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(FNAME1, FNAME1OUT, &pack_options) <= 0) + GOERROR; + if (h5repack_cmp_pl(FNAME1, pack_options.fin_fapl, FNAME1OUT, pack_options.fout_fapl) <= 0) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); + } /*------------------------------------------------------------------------- * file with attributes @@ -1487,49 +1491,53 @@ main(void) GOERROR; PASSED(); - /*------------------------------------------------------------------------- - * test file with userblock - *------------------------------------------------------------------------- - */ - TESTING(" file with userblock"); - if (h5repack_init(&pack_options, 0, FALSE) < 0) - GOERROR; - if (h5repack(FNAME16, FNAME16OUT, &pack_options) < 0) - GOERROR; - if (h5diff(FNAME16, FNAME16OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if (h5repack_verify(FNAME16, FNAME16OUT, &pack_options) <= 0) - GOERROR; - if (verify_userblock(FNAME16OUT) < 0) - GOERROR; - if (h5repack_end(&pack_options) < 0) - GOERROR; - PASSED(); + if (h5_using_default_driver(NULL)) { + /*------------------------------------------------------------------------- + * test file with userblock + *------------------------------------------------------------------------- + */ + TESTING(" file with userblock"); + if (h5repack_init(&pack_options, 0, FALSE) < 0) + GOERROR; + if (h5repack(FNAME16, FNAME16OUT, &pack_options) < 0) + GOERROR; + if (h5diff(FNAME16, FNAME16OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(FNAME16, FNAME16OUT, &pack_options) <= 0) + GOERROR; + if (verify_userblock(FNAME16OUT) < 0) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); + } /*------------------------------------------------------------------------- * test --latest options *------------------------------------------------------------------------- */ - TESTING(" latest file format options"); - if (h5repack_init(&pack_options, 0, FALSE) < 0) - GOERROR; - pack_options.latest = 1; - pack_options.grp_compact = 10; - pack_options.grp_indexed = 5; - pack_options.msg_size[0] = 10; - pack_options.msg_size[1] = 20; - pack_options.msg_size[2] = 30; - pack_options.msg_size[3] = 40; - pack_options.msg_size[4] = 50; - if (h5repack(FNAME1, FNAME1OUT, &pack_options) < 0) - GOERROR; - if (h5diff(FNAME1, FNAME1OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if (h5repack_verify(FNAME1, FNAME1OUT, &pack_options) <= 0) - GOERROR; - if (h5repack_end(&pack_options) < 0) - GOERROR; - PASSED(); + if (!h5_using_parallel_driver(NULL)) { + TESTING(" latest file format options"); + if (h5repack_init(&pack_options, 0, FALSE) < 0) + GOERROR; + pack_options.latest = 1; + pack_options.grp_compact = 10; + pack_options.grp_indexed = 5; + pack_options.msg_size[0] = 10; + pack_options.msg_size[1] = 20; + pack_options.msg_size[2] = 30; + pack_options.msg_size[3] = 40; + pack_options.msg_size[4] = 50; + if (h5repack(FNAME1, FNAME1OUT, &pack_options) < 0) + GOERROR; + if (h5diff(FNAME1, FNAME1OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(FNAME1, FNAME1OUT, &pack_options) <= 0) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); + } /*------------------------------------------------------------------------- * test several global filters @@ -1560,36 +1568,38 @@ main(void) SKIPPED(); #endif - /*------------------------------------------------------------------------- - * test file with userblock - *------------------------------------------------------------------------- - */ - TESTING(" file with added userblock"); + if (h5_using_default_driver(NULL)) { + /*------------------------------------------------------------------------- + * test file with userblock + *------------------------------------------------------------------------- + */ + TESTING(" file with added userblock"); #ifdef H5_HAVE_FILTER_DEFLATE - if (h5repack_init(&pack_options, 0, FALSE) < 0) - GOERROR; + if (h5repack_init(&pack_options, 0, FALSE) < 0) + GOERROR; - /* add the options for a user block size and user block filename */ - pack_options.ublock_size = USERBLOCK_SIZE; - pack_options.ublock_filename = FNAME_UB; + /* add the options for a user block size and user block filename */ + pack_options.ublock_size = USERBLOCK_SIZE; + pack_options.ublock_filename = FNAME_UB; - if (h5repack(FNAME8, FNAME8OUT, &pack_options) < 0) - GOERROR; - if (h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if (h5repack_verify(FNAME8, FNAME8OUT, &pack_options) <= 0) - GOERROR; - if (verify_userblock(FNAME8OUT) < 0) - GOERROR; - if (h5repack_end(&pack_options) < 0) - GOERROR; + if (h5repack(FNAME8, FNAME8OUT, &pack_options) < 0) + GOERROR; + if (h5diff(FNAME8, FNAME8OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(FNAME8, FNAME8OUT, &pack_options) <= 0) + GOERROR; + if (verify_userblock(FNAME8OUT) < 0) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; - PASSED(); + PASSED(); #else - SKIPPED(); + SKIPPED(); #endif + } /*------------------------------------------------------------------------- * test file with aligment @@ -1664,48 +1674,50 @@ main(void) PASSED(); - /*------------------------------------------------------------------------- - * test --metadata_block_size option - * Also verify that output file using the metadata_block_size option is - * larger than the output file one not using it. - * FNAME4 is used because it is the same as the test file used for the - * shell script version of this test (h5repack.sh). - *------------------------------------------------------------------------- - */ - TESTING(" metadata block size option"); - /* First run without metadata option. No need to verify the correctness */ - /* since this has been verified by earlier tests. Just record the file */ - /* size of the output file. */ - if (h5repack_init(&pack_options, 0, FALSE) < 0) - GOERROR; - if (h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) - GOERROR; - if (HDstat(FNAME4OUT, &file_stat) < 0) - GOERROR; - fsize1 = file_stat.st_size; - if (h5repack_end(&pack_options) < 0) - GOERROR; + if (h5_using_default_driver(NULL)) { + /*------------------------------------------------------------------------- + * test --metadata_block_size option + * Also verify that output file using the metadata_block_size option is + * larger than the output file one not using it. + * FNAME4 is used because it is the same as the test file used for the + * shell script version of this test (h5repack.sh). + *------------------------------------------------------------------------- + */ + TESTING(" metadata block size option"); + /* First run without metadata option. No need to verify the correctness */ + /* since this has been verified by earlier tests. Just record the file */ + /* size of the output file. */ + if (h5repack_init(&pack_options, 0, FALSE) < 0) + GOERROR; + if (h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) + GOERROR; + if (HDstat(FNAME4OUT, &file_stat) < 0) + GOERROR; + fsize1 = file_stat.st_size; + if (h5repack_end(&pack_options) < 0) + GOERROR; - /* run it again with metadata option */ - if (h5repack_init(&pack_options, 0, FALSE) < 0) - GOERROR; - pack_options.meta_block_size = 8192; - if (h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) - GOERROR; - if (h5diff(FNAME4, FNAME4OUT, NULL, NULL, &diff_options) > 0) - GOERROR; - if (h5repack_verify(FNAME4, FNAME4OUT, &pack_options) <= 0) - GOERROR; - /* record the file size of the output file */ - if (HDstat(FNAME4OUT, &file_stat) < 0) - GOERROR; - fsize2 = file_stat.st_size; - /* verify second file size is larger than the first one */ - if (fsize2 <= fsize1) - GOERROR; - if (h5repack_end(&pack_options) < 0) - GOERROR; - PASSED(); + /* run it again with metadata option */ + if (h5repack_init(&pack_options, 0, FALSE) < 0) + GOERROR; + pack_options.meta_block_size = 8192; + if (h5repack(FNAME4, FNAME4OUT, &pack_options) < 0) + GOERROR; + if (h5diff(FNAME4, FNAME4OUT, NULL, NULL, &diff_options) > 0) + GOERROR; + if (h5repack_verify(FNAME4, FNAME4OUT, &pack_options) <= 0) + GOERROR; + /* record the file size of the output file */ + if (HDstat(FNAME4OUT, &file_stat) < 0) + GOERROR; + fsize2 = file_stat.st_size; + /* verify second file size is larger than the first one */ + if (fsize2 <= fsize1) + GOERROR; + if (h5repack_end(&pack_options) < 0) + GOERROR; + PASSED(); + } /*------------------------------------------------------------------------- * clean temporary test files @@ -1725,7 +1737,10 @@ main(void) return 0; error: + h5tools_close(); + puts("***** H5REPACK TESTS FAILED *****"); + return 1; } @@ -1760,12 +1775,14 @@ make_testfiles(void) * create another file for general copy test (all datatypes) *------------------------------------------------------------------------- */ - if ((fid = H5Fcreate(FNAME1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) - return -1; - if (make_all_objects(fid) < 0) - goto out; - if (H5Fclose(fid) < 0) - return -1; + if (!h5_using_parallel_driver(NULL)) { + if ((fid = H5Fcreate(FNAME1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + return -1; + if (make_all_objects(fid) < 0) + goto out; + if (H5Fclose(fid) < 0) + return -1; + } /*------------------------------------------------------------------------- * create a file for attributes copy test @@ -1934,19 +1951,21 @@ make_testfiles(void) if (H5Fclose(fid) < 0) return -1; - /*------------------------------------------------------------------------- - * create a file with userblock - *------------------------------------------------------------------------- - */ - if (make_userblock() < 0) - goto out; + if (h5_using_default_driver(NULL)) { + /*------------------------------------------------------------------------- + * create a file with userblock + *------------------------------------------------------------------------- + */ + if (make_userblock() < 0) + goto out; - /*------------------------------------------------------------------------- - * create a userblock file - *------------------------------------------------------------------------- - */ - if (make_userblock_file() < 0) - goto out; + /*------------------------------------------------------------------------- + * create a userblock file + *------------------------------------------------------------------------- + */ + if (make_userblock_file() < 0) + goto out; + } /*------------------------------------------------------------------------- * create a file with named datatypes @@ -1959,30 +1978,32 @@ make_testfiles(void) if (H5Fclose(fid) < 0) return -1; - /*------------------------------------------------------------------------- - * create obj and region reference type datasets (bug1814) - * add attribute with int type (bug1726) - * add attribute with obj and region reference type (bug1726) - *------------------------------------------------------------------------- - */ - if ((fid = H5Fcreate(FNAME_REF, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) - return -1; - /* create reference type datasets */ - if (make_references(fid) < 0) - goto out; - if (H5Fclose(fid) < 0) - return -1; + if (!h5_using_parallel_driver(NULL)) { + /*------------------------------------------------------------------------- + * create obj and region reference type datasets (bug1814) + * add attribute with int type (bug1726) + * add attribute with obj and region reference type (bug1726) + *------------------------------------------------------------------------- + */ + if ((fid = H5Fcreate(FNAME_REF, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + return -1; + /* create reference type datasets */ + if (make_references(fid) < 0) + goto out; + if (H5Fclose(fid) < 0) + return -1; - /*------------------------------------------------------------------------- - * create a file with obj and region references in attribute of compound and - * vlen datatype - *-------------------------------------------------------------------------*/ - if ((fid = H5Fcreate(FNAME_ATTR_REF, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) - return -1; - if (make_complex_attr_references(fid) < 0) - goto out; - if (H5Fclose(fid) < 0) - return -1; + /*------------------------------------------------------------------------- + * create a file with obj and region references in attribute of compound and + * vlen datatype + *-------------------------------------------------------------------------*/ + if ((fid = H5Fcreate(FNAME_ATTR_REF, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + return -1; + if (make_complex_attr_references(fid) < 0) + goto out; + if (H5Fclose(fid) < 0) + return -1; + } /*------------------------------------------------------------------------- * create 8 files with combinations ??? @@ -2018,111 +2039,113 @@ make_testfiles(void) if (H5Fclose(fid) < 0) return -1; - /* - * #2 -- h5repack_page_persist.h5 - * Setting: - * strategy=PAGE, persist=TRUE, threshold=1 - * inpage=512 - * latest format - */ - /* Create file creation property list */ - if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - return -1; - if (H5Pset_file_space_page_size(fcpl, (hsize_t)512) < 0) - return -1; - if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) - return -1; - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) - return -1; - if (H5Fclose(fid) < 0) - return -1; - if (H5Pclose(fcpl) < 0) - return -1; - - /* - * #3 -- h5repack_fsm_aggr_persist.h5 - * Setting: - * strategy=FSM_AGGR, persist=TRUE, threshold=1 - * default: inpage=4096 - */ - /* Create file creation property list */ - if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - return -1; - if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) - return -1; - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) - return -1; - if (H5Fclose(fid) < 0) - return -1; - if (H5Pclose(fcpl) < 0) - return -1; - - /* - * #4 -- h5repack_page_threshold.h5 - * Setting: - * strategy=PAGE, persist=FALSE, threshold=3 - * inpage=8192 - * latest format - */ - - /* Create file creation property list */ - if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - return -1; - if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)3) < 0) - return -1; - if (H5Pset_file_space_page_size(fcpl, (hsize_t)8192) < 0) - return -1; - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) - return -1; - if (H5Fclose(fid) < 0) - return -1; - if (H5Pclose(fcpl) < 0) - return -1; - - /* - * #5 -- h5repack_fsm_aggr_threshold.h5 - * Setting: - * strategy=FSM_AGGR, persist=FALSE, threshold=3 - * inpage=4096 - */ + if (h5_using_default_driver(NULL)) { + /* + * #2 -- h5repack_page_persist.h5 + * Setting: + * strategy=PAGE, persist=TRUE, threshold=1 + * inpage=512 + * latest format + */ + /* Create file creation property list */ + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + return -1; + if (H5Pset_file_space_page_size(fcpl, (hsize_t)512) < 0) + return -1; + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, TRUE, (hsize_t)1) < 0) + return -1; + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) + return -1; + if (H5Fclose(fid) < 0) + return -1; + if (H5Pclose(fcpl) < 0) + return -1; + + /* + * #3 -- h5repack_fsm_aggr_persist.h5 + * Setting: + * strategy=FSM_AGGR, persist=TRUE, threshold=1 + * default: inpage=4096 + */ + /* Create file creation property list */ + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + return -1; + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0) + return -1; + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + return -1; + if (H5Fclose(fid) < 0) + return -1; + if (H5Pclose(fcpl) < 0) + return -1; + + /* + * #4 -- h5repack_page_threshold.h5 + * Setting: + * strategy=PAGE, persist=FALSE, threshold=3 + * inpage=8192 + * latest format + */ - /* Create file creation property list */ - if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - return -1; - if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, FALSE, (hsize_t)3) < 0) - return -1; - if (H5Pset_file_space_page_size(fcpl, (hsize_t)FS_PAGESIZE_DEF) < 0) - return -1; - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) - return -1; - if (H5Fclose(fid) < 0) - return -1; - if (H5Pclose(fcpl) < 0) - return -1; + /* Create file creation property list */ + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + return -1; + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, (hsize_t)3) < 0) + return -1; + if (H5Pset_file_space_page_size(fcpl, (hsize_t)8192) < 0) + return -1; + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) + return -1; + if (H5Fclose(fid) < 0) + return -1; + if (H5Pclose(fcpl) < 0) + return -1; + + /* + * #5 -- h5repack_fsm_aggr_threshold.h5 + * Setting: + * strategy=FSM_AGGR, persist=FALSE, threshold=3 + * inpage=4096 + */ - /* - * #6 -- h5repack_aggr.h5 - * Setting: - * strategy=AGGR, persist=FALSE, threshold=1 - * latest format - */ + /* Create file creation property list */ + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + return -1; + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, FALSE, (hsize_t)3) < 0) + return -1; + if (H5Pset_file_space_page_size(fcpl, (hsize_t)FS_PAGESIZE_DEF) < 0) + return -1; + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + return -1; + if (H5Fclose(fid) < 0) + return -1; + if (H5Pclose(fcpl) < 0) + return -1; + + /* + * #6 -- h5repack_aggr.h5 + * Setting: + * strategy=AGGR, persist=FALSE, threshold=1 + * latest format + */ - /* Create file creation property list */ - if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - return -1; - if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_AGGR, FALSE, (hsize_t)1) < 0) - return -1; - HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); - if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) - return -1; - if (H5Fclose(fid) < 0) - return -1; - if (H5Pclose(fcpl) < 0) - return -1; + /* Create file creation property list */ + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + return -1; + if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_AGGR, FALSE, (hsize_t)1) < 0) + return -1; + HDassert(j < NELMTS(H5REPACK_FSPACE_FNAMES)); + if ((fid = H5Fcreate(H5REPACK_FSPACE_FNAMES[++j], H5F_ACC_TRUNC, fcpl, fapl)) < 0) + return -1; + if (H5Fclose(fid) < 0) + return -1; + if (H5Pclose(fcpl) < 0) + return -1; + } /* * #7 -- h5repack_none.h5 @@ -2726,6 +2749,7 @@ make_nbit(hid_t loc_id) hid_t sid = H5I_INVALID_HID; /* dataspace ID */ hid_t dtid = H5I_INVALID_HID; hid_t dsid = H5I_INVALID_HID; + hid_t dxpl = H5P_DEFAULT; hsize_t dims[RANK] = {DIM1, DIM2}; hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; int ** buf = NULL; @@ -2746,6 +2770,16 @@ make_nbit(hid_t loc_id) if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto error; +#ifdef H5_HAVE_PARALLEL + /* Set up collective writes for parallel driver */ + if (h5_using_parallel_driver(NULL)) { + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; + if (H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE) < 0) + goto error; + } +#endif + dtid = H5Tcopy(H5T_NATIVE_INT); if (H5Tset_precision(dtid, (H5Tget_precision(dtid) - 1)) < 0) goto error; @@ -2757,7 +2791,7 @@ make_nbit(hid_t loc_id) goto error; if ((dsid = H5Dcreate2(loc_id, "dset_nbit", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf[0]) < 0) goto error; H5Dclose(dsid); @@ -2765,7 +2799,7 @@ make_nbit(hid_t loc_id) goto error; if ((dsid = H5Dcreate2(loc_id, "dset_int31", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf[0]) < 0) goto error; H5Dclose(dsid); @@ -2773,6 +2807,8 @@ make_nbit(hid_t loc_id) * close *------------------------------------------------------------------------- */ + if (dxpl != H5P_DEFAULT && H5Pclose(dxpl) < 0) + goto error; if (H5Sclose(sid) < 0) goto error; if (H5Pclose(dcpl) < 0) @@ -2788,6 +2824,7 @@ make_nbit(hid_t loc_id) H5E_BEGIN_TRY { H5Tclose(dtid); + H5Pclose(dxpl); H5Pclose(dcpl); H5Sclose(sid); H5Dclose(dsid); @@ -2813,6 +2850,7 @@ make_scaleoffset(hid_t loc_id) hid_t sid = H5I_INVALID_HID; /* dataspace ID */ hid_t dtid = H5I_INVALID_HID; hid_t dsid = H5I_INVALID_HID; + hid_t dxpl = H5P_DEFAULT; hsize_t dims[RANK] = {DIM1, DIM2}; hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; int ** buf = NULL; @@ -2833,6 +2871,16 @@ make_scaleoffset(hid_t loc_id) if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto error; +#ifdef H5_HAVE_PARALLEL + /* Set up collective writes for parallel driver */ + if (h5_using_parallel_driver(NULL)) { + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; + if (H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE) < 0) + goto error; + } +#endif + dtid = H5Tcopy(H5T_NATIVE_INT); /* remove the filters from the dcpl */ @@ -2842,20 +2890,22 @@ make_scaleoffset(hid_t loc_id) goto error; if ((dsid = H5Dcreate2(loc_id, "dset_scaleoffset", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf[0]) < 0) goto error; H5Dclose(dsid); if ((dsid = H5Dcreate2(loc_id, "dset_none", dtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf[0]) < 0) goto error; H5Tclose(dtid); H5Dclose(dsid); /*------------------------------------------------------------------------- - * close space and dcpl + * close space, dxpl and dcpl *------------------------------------------------------------------------- */ + if (dxpl != H5P_DEFAULT && H5Pclose(dxpl) < 0) + goto error; if (H5Sclose(sid) < 0) goto error; if (H5Pclose(dcpl) < 0) @@ -2868,6 +2918,7 @@ make_scaleoffset(hid_t loc_id) error: H5E_BEGIN_TRY { + H5Pclose(dxpl); H5Dclose(dsid); H5Tclose(dtid); H5Pclose(dcpl); @@ -2894,6 +2945,7 @@ make_all_filters(hid_t loc_id) hid_t sid = H5I_INVALID_HID; /* dataspace ID */ hid_t dtid = H5I_INVALID_HID; hid_t dsid = H5I_INVALID_HID; + hid_t dxpl = H5P_DEFAULT; #if defined(H5_HAVE_FILTER_SZIP) unsigned szip_options_mask = H5_SZIP_ALLOW_K13_OPTION_MASK | H5_SZIP_NN_OPTION_MASK; unsigned szip_pixels_per_block = 8; @@ -2921,6 +2973,16 @@ make_all_filters(hid_t loc_id) if (H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) goto error; +#ifdef H5_HAVE_PARALLEL + /* Set up collective writes for parallel driver */ + if (h5_using_parallel_driver(NULL)) { + if ((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; + if (H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE) < 0) + goto error; + } +#endif + /* set the shuffle filter */ if (H5Pset_shuffle(dcpl) < 0) goto error; @@ -3010,7 +3072,7 @@ make_all_filters(hid_t loc_id) goto error; if ((dsid = H5Dcreate2(loc_id, "dset_nbit", dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; - if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + if (H5Dwrite(dsid, dtid, H5S_ALL, H5S_ALL, dxpl, buf[0]) < 0) goto error; /* close */ @@ -3021,6 +3083,8 @@ make_all_filters(hid_t loc_id) if (H5Sclose(sid) < 0) goto error; + if (dxpl != H5P_DEFAULT && H5Pclose(dxpl) < 0) + goto error; if (H5Pclose(dcpl) < 0) goto error; @@ -3033,6 +3097,7 @@ make_all_filters(hid_t loc_id) { H5Tclose(dtid); H5Dclose(dsid); + H5Pclose(dxpl); H5Pclose(dcpl); H5Sclose(sid); } @@ -5802,11 +5867,25 @@ write_attr_in(hid_t loc_id, const char *dset_name, /* for saving reference to da static int make_dset(hid_t loc_id, const char *name, hid_t sid, hid_t dcpl, void *buf) { - hid_t did = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t dxpl_id = H5P_DEFAULT; if ((did = H5Dcreate2(loc_id, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) return -1; - if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + +#ifdef H5_HAVE_PARALLEL + /* Set up collective writes for parallel driver */ + if (h5_using_parallel_driver(NULL)) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto out; + if (H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0) + goto out; + } +#endif + + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, buf) < 0) + goto out; + if (dxpl_id != H5P_DEFAULT && H5Pclose(dxpl_id) < 0) goto out; if (H5Dclose(did) < 0) return -1; @@ -5835,17 +5914,30 @@ make_dset(hid_t loc_id, const char *name, hid_t sid, hid_t dcpl, void *buf) static int write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, hid_t tid, void *buf) { - hid_t did = H5I_INVALID_HID; - hid_t sid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t dxpl_id = H5P_DEFAULT; if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) return -1; if ((did = H5Dcreate2(loc_id, dset_name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; if (buf) { - if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) +#ifdef H5_HAVE_PARALLEL + /* Set up collective writes for parallel driver */ + if (h5_using_parallel_driver(NULL)) { + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto out; + if (H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0) + goto out; + } +#endif + + if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, dxpl_id, buf) < 0) goto out; } + if (dxpl_id != H5P_DEFAULT && H5Pclose(dxpl_id) < 0) + goto out; if (H5Dclose(did) < 0) goto out; if (H5Sclose(sid) < 0) @@ -5856,6 +5948,7 @@ write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *dset_name, hid_t t out: H5E_BEGIN_TRY { + H5Pclose(dxpl_id); H5Dclose(did); H5Sclose(sid); }