From 3da0802c40d58759995916bf9d0880e19f0af44d Mon Sep 17 00:00:00 2001 From: jhendersonHDF Date: Wed, 29 Sep 2021 13:28:12 -0500 Subject: VFD plugins (#602) * Implement support for loading of Virtual File Drivers as plugins Fix plugin caching for VOL connector and VFD plugins Fix plugin iteration to skip paths that can't be opened * Enable dynamic loading of VFDs with HDF5_DRIVER environment variable * Temporarily disable error reporting during H5F_open double file open * Default to using HDstat in h5_get_file_size for unknown VFDs * Use macros for some environment variables that HDF5 interprets * Update "null" and "ctl testing" VFDs --- .gitattributes | 8 +- MANIFEST | 11 +- bin/trace | 1 + c++/test/CMakeVFDTests.cmake | 18 + c++/test/testhdf5.cpp | 2 +- config/conclude.am | 19 +- examples/h5_drivers.c | 2 +- fortran/test/t.c | 2 +- hl/tools/h5watch/swmr_check_compat_vfd.c | 2 +- src/H5.c | 4 +- src/H5FD.c | 56 ++ src/H5FDcore.c | 45 +- src/H5FDcore.h | 3 +- src/H5FDdevelop.h | 3 + src/H5FDdirect.c | 84 +- src/H5FDdirect.h | 6 +- src/H5FDfamily.c | 232 +++++- src/H5FDfamily.h | 3 +- src/H5FDhdfs.c | 3 +- src/H5FDhdfs.h | 6 +- src/H5FDint.c | 371 +++++++++ src/H5FDlog.c | 91 ++- src/H5FDlog.h | 3 +- src/H5FDmirror.c | 3 +- src/H5FDmirror.h | 3 +- src/H5FDmpio.c | 63 +- src/H5FDmulti.c | 432 ++++++---- src/H5FDprivate.h | 21 +- src/H5FDpublic.h | 43 + src/H5FDros3.c | 3 +- src/H5FDros3.h | 6 +- src/H5FDsec2.c | 5 +- src/H5FDsec2.h | 3 +- src/H5FDsplitter.c | 355 +++++++-- src/H5FDsplitter.h | 3 +- src/H5FDstdio.c | 3 +- src/H5FDwindows.c | 2 +- src/H5Fint.c | 17 +- src/H5PLint.c | 65 +- src/H5PLpath.c | 29 +- src/H5PLplugin_cache.c | 140 ++-- src/H5PLprivate.h | 31 +- src/H5PLpublic.h | 6 +- src/H5Pfapl.c | 567 ++++++++++++- src/H5Pint.c | 74 +- src/H5Ppkg.h | 3 + src/H5Pprivate.h | 13 +- src/H5Ppublic.h | 79 ++ src/H5VLcallback.c | 29 +- src/H5VLint.c | 70 +- src/H5public.h | 52 ++ src/H5trace.c | 59 ++ test/CMakeLists.txt | 59 +- test/CMakeTests.cmake | 10 +- test/CMakeVFDTests.cmake | 38 + test/Makefile.am | 12 +- test/accum.c | 2 +- test/accum_swmr_reader.c | 2 +- test/app_ref.c | 24 +- test/btree2.c | 10 +- test/cache.c | 5 + test/cache_api.c | 47 +- test/cache_image.c | 5 +- test/cache_tagging.c | 6 + test/cork.c | 17 + test/dangle.c | 16 +- test/dsets.c | 25 +- test/dtransform.c | 2 + test/dtypes.c | 86 +- test/error_test.c | 20 +- test/family_v16-000000.h5 | Bin 0 -> 5120 bytes test/family_v16-000001.h5 | Bin 0 -> 5120 bytes test/family_v16-000002.h5 | Bin 0 -> 5120 bytes test/family_v16-000003.h5 | Bin 0 -> 4048 bytes test/family_v16_00000.h5 | Bin 5120 -> 0 bytes test/family_v16_00001.h5 | Bin 5120 -> 0 bytes test/family_v16_00002.h5 | Bin 5120 -> 0 bytes test/family_v16_00003.h5 | Bin 4048 -> 0 bytes test/fheap.c | 2 +- test/file_image.c | 5 +- test/filenotclosed.c | 2 +- test/fillval.c | 5 +- test/flush1.c | 2 +- test/flush2.c | 2 +- test/flushrefresh.c | 2 +- test/freespace.c | 28 +- test/getname.c | 8 +- test/h5test.c | 399 +++++----- test/h5test.h | 12 +- test/lheap.c | 40 +- test/links.c | 175 ++-- test/links_env.c | 16 +- test/mf.c | 203 ++--- test/mtime.c | 101 +-- test/ntypes.c | 16 +- test/null_vfd_plugin.c | 131 +++ test/null_vfd_plugin.h | 33 + test/objcopy.c | 41 +- test/ohdr.c | 26 +- test/page_buffer.c | 2 +- test/reserved.c | 2 +- test/set_extent.c | 43 +- test/stab.c | 16 +- test/swmr.c | 8 +- test/swmr_check_compat_vfd.c | 2 +- test/tarray.c | 6 +- test/tattr.c | 108 ++- test/testhdf5.c | 2 +- test/tfile.c | 886 +++++++++++---------- 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/ttsafe.c | 2 +- test/vds.c | 17 +- test/vds_env.c | 17 +- test/vfd.c | 18 +- test/vfd_plugin.c | 388 +++++++++ test/vol.c | 71 +- test/vol_plugin.c | 4 +- testpar/CMakeVFDTests.cmake | 17 + testpar/t_pflush1.c | 4 +- testpar/t_pflush2.c | 4 +- tools/lib/h5diff.c | 16 +- tools/lib/h5diff.h | 2 + tools/lib/h5tools.c | 219 +++-- tools/lib/h5tools.h | 9 +- tools/libtest/h5tools_test_utils.c | 7 +- tools/src/h5diff/h5diff_common.c | 56 ++ tools/src/h5dump/h5dump.c | 74 +- tools/src/h5ls/h5ls.c | 78 +- tools/src/h5perf/perf.c | 2 +- tools/src/h5perf/pio_engine.c | 2 +- tools/src/h5perf/sio_engine.c | 2 +- tools/src/h5repack/h5repack.c | 4 +- tools/src/h5repack/h5repack_copy.c | 4 +- tools/src/h5repack/h5repack_main.c | 88 +- tools/src/h5repack/h5repack_verify.c | 8 +- tools/src/h5stat/h5stat.c | 24 +- tools/src/misc/h5mkgrp.c | 46 +- tools/test/h5diff/testfiles/h5diff_10.txt | 12 + tools/test/h5diff/testfiles/h5diff_600.txt | 12 + tools/test/h5diff/testfiles/h5diff_603.txt | 12 + tools/test/h5diff/testfiles/h5diff_606.txt | 12 + tools/test/h5diff/testfiles/h5diff_612.txt | 12 + tools/test/h5diff/testfiles/h5diff_615.txt | 12 + tools/test/h5diff/testfiles/h5diff_621.txt | 12 + tools/test/h5diff/testfiles/h5diff_622.txt | 12 + tools/test/h5diff/testfiles/h5diff_623.txt | 12 + tools/test/h5diff/testfiles/h5diff_624.txt | 12 + tools/test/h5repack/CMakeVFDTests.cmake | 17 + tools/test/h5repack/h5repacktst.c | 807 ++++++++++--------- tools/test/h5repack/testfiles/h5repack-help.txt | 12 + tools/test/misc/testfiles/h5mkgrp_help.txt | 6 + tools/test/perform/chunk_cache.c | 2 +- tools/test/perform/overhead.c | 2 +- tools/test/perform/zip_perf.c | 2 +- tools/testfiles/h5dump-help.txt | 6 + tools/testfiles/help-1.ls | 6 + tools/testfiles/help-2.ls | 6 + tools/testfiles/help-3.ls | 6 + .../pbits/tnofilename-with-packed-bits.ddl | 6 + tools/testfiles/pbits/tpbitsIncomplete.ddl | 6 + tools/testfiles/pbits/tpbitsLengthExceeded.ddl | 6 + tools/testfiles/pbits/tpbitsLengthPositive.ddl | 6 + tools/testfiles/pbits/tpbitsMaxExceeded.ddl | 6 + tools/testfiles/pbits/tpbitsOffsetExceeded.ddl | 6 + tools/testfiles/pbits/tpbitsOffsetNegative.ddl | 6 + tools/testfiles/textlinksrc-nodangle-1.ls | 6 + tools/testfiles/tgroup-1.ls | 6 + 173 files changed, 6120 insertions(+), 2283 deletions(-) create mode 100644 test/family_v16-000000.h5 create mode 100644 test/family_v16-000001.h5 create mode 100644 test/family_v16-000002.h5 create mode 100644 test/family_v16-000003.h5 delete mode 100644 test/family_v16_00000.h5 delete mode 100644 test/family_v16_00001.h5 delete mode 100644 test/family_v16_00002.h5 delete mode 100644 test/family_v16_00003.h5 create mode 100644 test/null_vfd_plugin.c create mode 100644 test/null_vfd_plugin.h create mode 100644 test/vfd_plugin.c diff --git a/.gitattributes b/.gitattributes index e01442a..385f805 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 0782b22..32c3457 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1199,10 +1199,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 @@ -1287,6 +1287,8 @@ ./test/ntypes.c ./test/null_vol_connector.c ./test/null_vol_connector.h +./test/null_vfd_plugin.c +./test/null_vfd_plugin.h ./test/objcopy.c ./test/objcopy_ref.c ./test/ohdr.c @@ -1395,6 +1397,7 @@ ./test/vds_swmr_reader.c ./test/vds_swmr_writer.c ./test/vfd.c +./test/vfd_plugin.c ./test/vol.c ./test/vol_plugin.c diff --git a/bin/trace b/bin/trace index cc26f86..55ce7d4 100755 --- a/bin/trace +++ b/bin/trace @@ -53,6 +53,7 @@ $Source = ""; "H5D_scatter_func_t" => "DS", "H5FD_mpio_xfer_t" => "Dt", "H5D_vds_view_t" => "Dv", + "H5FD_class_value_t" => "DV", "H5D_chunk_iter_op_t" => "x", "herr_t" => "e", "H5E_auto1_t" => "Ea", diff --git a/c++/test/CMakeVFDTests.cmake b/c++/test/CMakeVFDTests.cmake index 360d14e..6a74244 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/c++/test/testhdf5.cpp b/c++/test/testhdf5.cpp index 71428ce..af50646 100644 --- a/c++/test/testhdf5.cpp +++ b/c++/test/testhdf5.cpp @@ -114,7 +114,7 @@ main(int argc, char *argv[]) TestSummary(); /* Clean up test files, if allowed */ - if (GetTestCleanup() && !getenv("HDF5_NOCLEANUP")) + if (GetTestCleanup() && !getenv(HDF5_NOCLEANUP)) TestCleanup(); /* Release test infrastructure */ diff --git a/config/conclude.am b/config/conclude.am index 7d19082..e798d8d 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/examples/h5_drivers.c b/examples/h5_drivers.c index bd57004..d9321ed 100644 --- a/examples/h5_drivers.c +++ b/examples/h5_drivers.c @@ -35,7 +35,7 @@ void cleanup(const char *filename) { if (cleanup_g == -1) - cleanup_g = getenv("HDF5_NOCLEANUP") ? 0 : 1; + cleanup_g = getenv(HDF5_NOCLEANUP) ? 0 : 1; if (cleanup_g) remove(filename); } diff --git a/fortran/test/t.c b/fortran/test/t.c index 6dce111..6c856fa 100644 --- a/fortran/test/t.c +++ b/fortran/test/t.c @@ -152,6 +152,6 @@ void nh5_env_nocleanup_c(int_f *status) { *status = (int_f)0; - if (HDgetenv("HDF5_NOCLEANUP")) + if (HDgetenv(HDF5_NOCLEANUP)) *status = (int_f)1; } /* h5_env_nocleanup_c */ diff --git a/hl/tools/h5watch/swmr_check_compat_vfd.c b/hl/tools/h5watch/swmr_check_compat_vfd.c index a2340bf..b4021e4 100644 --- a/hl/tools/h5watch/swmr_check_compat_vfd.c +++ b/hl/tools/h5watch/swmr_check_compat_vfd.c @@ -45,7 +45,7 @@ main(void) { char *driver = NULL; - driver = HDgetenv("HDF5_DRIVER"); + driver = HDgetenv(HDF5_DRIVER); if (H5FD__supports_swmr_test(driver)) return EXIT_SUCCESS; diff --git a/src/H5.c b/src/H5.c index 3ceaecd..731f15a 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/H5FD.c b/src/H5FD.c index d3f72e8..da0b97b 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -301,6 +301,62 @@ done: } /* end H5FD_register() */ /*------------------------------------------------------------------------- + * Function: H5FDis_driver_registered_by_name + * + * Purpose: Tests whether a VFD class has been registered or not + * according to a supplied driver name. + * + * Return: >0 if a VFD with that name has been registered + * 0 if a VFD with that name has NOT been registered + * <0 on errors + * + *------------------------------------------------------------------------- + */ +htri_t +H5FDis_driver_registered_by_name(const char *driver_name) +{ + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("t", "*s", driver_name); + + /* Check if driver with this name is registered */ + if ((ret_value = H5FD_is_driver_registered_by_name(driver_name, NULL)) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't check if VFD is registered") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5FDis_driver_registered_by_name() */ + +/*------------------------------------------------------------------------- + * Function: H5FDis_driver_registered_by_value + * + * Purpose: Tests whether a VFD class has been registered or not + * according to a supplied driver value (ID). + * + * Return: >0 if a VFD with that value has been registered + * 0 if a VFD with that value hasn't been registered + * <0 on errors + * + *------------------------------------------------------------------------- + */ +htri_t +H5FDis_driver_registered_by_value(H5FD_class_value_t driver_value) +{ + htri_t ret_value = FALSE; + + FUNC_ENTER_API(FAIL) + H5TRACE1("t", "DV", driver_value); + + /* Check if driver with this value is registered */ + if ((ret_value = H5FD_is_driver_registered_by_value(driver_value, NULL)) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't check if VFD is registered") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5FDis_driver_registered_by_value() */ + +/*------------------------------------------------------------------------- * Function: H5FDunregister * * Purpose: Removes a driver ID from the library. This in no way affects diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 820c74f..ce96582 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -149,8 +149,10 @@ 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 */ "core", /* name */ MAXADDR, /* maxaddr */ H5F_CLOSE_WEAK, /* fc_degree */ @@ -187,6 +189,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); @@ -409,6 +416,32 @@ done: } /* 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 * * Purpose: Initializes any interface-specific data or routines. @@ -426,7 +459,7 @@ H5FD__init_package(void) FUNC_ENTER_STATIC /* Check the use disabled file locks environment variable */ - lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING"); + lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) @@ -529,7 +562,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 +572,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 +656,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 +781,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 +1768,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/H5FDcore.h b/src/H5FDcore.h index d456c3e..590478e 100644 --- a/src/H5FDcore.h +++ b/src/H5FDcore.h @@ -20,7 +20,8 @@ #ifndef H5FDcore_H #define H5FDcore_H -#define H5FD_CORE (H5FD_core_init()) +#define H5FD_CORE (H5FD_core_init()) +#define H5FD_CORE_VALUE H5_VFD_CORE #ifdef __cplusplus extern "C" { diff --git a/src/H5FDdevelop.h b/src/H5FDdevelop.h index 4895658..e897eb0 100644 --- a/src/H5FDdevelop.h +++ b/src/H5FDdevelop.h @@ -160,6 +160,7 @@ typedef struct H5FD_t H5FD_t; /* Class information for each file driver */ typedef struct H5FD_class_t { + H5FD_class_value_t value; const char * name; haddr_t maxaddr; H5F_close_degree_t fc_degree; @@ -235,6 +236,8 @@ extern "C" { #endif H5_DLL hid_t H5FDregister(const H5FD_class_t *cls); +H5_DLL htri_t H5FDis_driver_registered_by_name(const char *driver_name); +H5_DLL htri_t H5FDis_driver_registered_by_value(H5FD_class_value_t driver_value); H5_DLL herr_t H5FDunregister(hid_t driver_id); H5_DLL H5FD_t *H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); H5_DLL herr_t H5FDclose(H5FD_t *file); diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 7cca09f..8c5001c 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); @@ -140,6 +142,7 @@ static herr_t H5FD__direct_unlock(H5FD_t *_file); static herr_t H5FD__direct_delete(const char *filename, hid_t fapl_id); static const H5FD_class_t H5FD_direct_g = { + H5FD_DIRECT_VALUE, /* value */ "direct", /* name */ MAXADDR, /* maxaddr */ H5F_CLOSE_WEAK, /* fc_degree */ @@ -200,7 +203,7 @@ H5FD__init_package(void) FUNC_ENTER_STATIC /* Check the use disabled file locks environment variable */ - lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING"); + lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) @@ -296,28 +299,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) @@ -367,6 +352,53 @@ done: } /* 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_populate_config() */ + +/*------------------------------------------------------------------------- * Function: H5FD__direct_fapl_get * * Purpose: Returns a file access property list which indicates how the @@ -450,6 +482,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 +531,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/H5FDdirect.h b/src/H5FDdirect.h index f06de7f..a439e55 100644 --- a/src/H5FDdirect.h +++ b/src/H5FDdirect.h @@ -21,9 +21,11 @@ #define H5FDdirect_H #ifdef H5_HAVE_DIRECT -#define H5FD_DIRECT (H5FD_direct_init()) +#define H5FD_DIRECT (H5FD_direct_init()) +#define H5FD_DIRECT_VALUE H5_VFD_DIRECT #else -#define H5FD_DIRECT (H5I_INVALID_HID) +#define H5FD_DIRECT (H5I_INVALID_HID) +#define H5FD_DIRECT_VALUE H5_VFD_INVALID #endif /* H5_HAVE_DIRECT */ #ifdef H5_HAVE_DIRECT diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index af67c78..d187b7b 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); @@ -105,6 +112,7 @@ static herr_t H5FD__family_delete(const char *filename, hid_t fapl_id); /* The class struct */ static const H5FD_class_t H5FD_family_g = { + H5FD_FAMILY_VALUE, /* value */ "family", /* name */ HADDR_MAX, /* maxaddr */ H5F_CLOSE_WEAK, /* fc_degree */ @@ -141,6 +149,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 +367,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 +376,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 +717,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 +734,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 +783,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 +799,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 +1512,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 +1528,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 +1555,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 +1601,9 @@ done: 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/H5FDfamily.h b/src/H5FDfamily.h index 20ef532..7b76a16 100644 --- a/src/H5FDfamily.h +++ b/src/H5FDfamily.h @@ -20,7 +20,8 @@ #ifndef H5FDfamily_H #define H5FDfamily_H -#define H5FD_FAMILY (H5FD_family_init()) +#define H5FD_FAMILY (H5FD_family_init()) +#define H5FD_FAMILY_VALUE H5_VFD_FAMILY #ifdef __cplusplus extern "C" { diff --git a/src/H5FDhdfs.c b/src/H5FDhdfs.c index ac48b42..bbaf42c 100644 --- a/src/H5FDhdfs.c +++ b/src/H5FDhdfs.c @@ -278,6 +278,7 @@ static herr_t H5FD__hdfs_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing static herr_t H5FD__hdfs_validate_config(const H5FD_hdfs_fapl_t *fa); static const H5FD_class_t H5FD_hdfs_g = { + H5FD_HDFS_VALUE, /* value */ "hdfs", /* name */ MAXADDR, /* maxaddr */ H5F_CLOSE_WEAK, /* fc_degree */ @@ -624,7 +625,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/H5FDhdfs.h b/src/H5FDhdfs.h index 7c871a4..a9f34a0 100644 --- a/src/H5FDhdfs.h +++ b/src/H5FDhdfs.h @@ -22,9 +22,11 @@ #define H5FDhdfs_H #ifdef H5_HAVE_LIBHDFS -#define H5FD_HDFS (H5FD_hdfs_init()) +#define H5FD_HDFS (H5FD_hdfs_init()) +#define H5FD_HDFS_VALUE H5_VFD_HDFS #else /* H5_HAVE_LIBHDFS */ -#define H5FD_HDFS (H5I_INVALID_HID) +#define H5FD_HDFS (H5I_INVALID_HID) +#define H5FD_HDFS_VALUE H5_VFD_INVALID #endif /* H5_HAVE_LIBHDFS */ #ifdef H5_HAVE_LIBHDFS diff --git a/src/H5FDint.c b/src/H5FDint.c index f13f222..c567499 100644 --- a/src/H5FDint.c +++ b/src/H5FDint.c @@ -35,6 +35,7 @@ #include "H5Fprivate.h" /* File access */ #include "H5FDpkg.h" /* File Drivers */ #include "H5Iprivate.h" /* IDs */ +#include "H5PLprivate.h" /* Plugins */ /****************/ /* Local Macros */ @@ -44,6 +45,20 @@ /* Local Typedefs */ /******************/ +/* Information needed for iterating over the registered VFD hid_t IDs. + * The name or value of the new VFD that is being registered is stored + * in the name (or value) field and the found_id field is initialized to + * H5I_INVALID_HID (-1). If we find a VFD with the same name / value, + * we set the found_id field to the existing ID for return to the function. + */ +typedef struct H5FD_get_driver_ud_t { + /* IN */ + H5PL_vfd_key_t key; + + /* OUT */ + hid_t found_id; /* The driver ID, if we found a match */ +} H5FD_get_driver_ud_t; + /********************/ /* Package Typedefs */ /********************/ @@ -51,6 +66,7 @@ /********************/ /* Local Prototypes */ /********************/ +static int H5FD__get_driver_cb(void *obj, hid_t id, void *_op_data); /*********************/ /* Package Variables */ @@ -425,3 +441,358 @@ H5FD_delete(const char *filename, hid_t fapl_id) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_delete() */ + +/*------------------------------------------------------------------------- + * Function: H5FD_check_plugin_load + * + * Purpose: Check if a VFD plugin matches the search criteria, and can + * be loaded. + * + * Note: Matching the driver's name / value, but the driver having + * an incompatible version is not an error, but means that the + * driver isn't a "match". Setting the SUCCEED value to FALSE + * and not failing for that case allows the plugin framework + * to keep looking for other DLLs that match and have a + * compatible version. + * + * Return: SUCCEED / FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5FD_check_plugin_load(const H5FD_class_t *cls, const H5PL_key_t *key, hbool_t *success) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cls); + HDassert(key); + HDassert(success); + + /* Which kind of key are we looking for? */ + if (key->vfd.kind == H5FD_GET_DRIVER_BY_NAME) { + /* Check if plugin name matches VFD class name */ + if (cls->name && !HDstrcmp(cls->name, key->vfd.u.name)) + *success = TRUE; + } /* end if */ + else { + /* Sanity check */ + HDassert(key->vfd.kind == H5FD_GET_DRIVER_BY_VALUE); + + /* Check if plugin value matches VFD class value */ + if (cls->value == key->vfd.u.value) + *success = TRUE; + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_check_plugin_load() */ + +/*------------------------------------------------------------------------- + * Function: H5FD__get_driver_cb + * + * Purpose: Callback routine to search through registered VFDs + * + * Return: Success: H5_ITER_STOP if the class and op_data name + * members match. H5_ITER_CONT otherwise. + * Failure: Can't fail + * + *------------------------------------------------------------------------- + */ +static int +H5FD__get_driver_cb(void *obj, hid_t id, void *_op_data) +{ + H5FD_get_driver_ud_t *op_data = (H5FD_get_driver_ud_t *)_op_data; /* User data for callback */ + H5FD_class_t * cls = (H5FD_class_t *)obj; + int ret_value = H5_ITER_CONT; /* Callback return value */ + + FUNC_ENTER_STATIC_NOERR + + if (H5FD_GET_DRIVER_BY_NAME == op_data->key.kind) { + if (0 == HDstrcmp(cls->name, op_data->key.u.name)) { + op_data->found_id = id; + ret_value = H5_ITER_STOP; + } /* end if */ + } /* end if */ + else { + HDassert(H5FD_GET_DRIVER_BY_VALUE == op_data->key.kind); + if (cls->value == op_data->key.u.value) { + op_data->found_id = id; + ret_value = H5_ITER_STOP; + } /* end if */ + } /* end else */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD__get_driver_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5FD_register_driver_by_name + * + * Purpose: Registers a new VFD as a member of the virtual file driver + * class. + * + * Return: Success: A VFD ID which is good until the library is + * closed. + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +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 */ + + FUNC_ENTER_NOAPI(H5I_INVALID_HID) + + /* Check if driver is already registered */ + if ((driver_is_registered = H5FD_is_driver_registered_by_name(name, &driver_id)) < 0) + HGOTO_ERROR(H5E_VFL, H5E_BADITER, H5I_INVALID_HID, "can't check if driver is already registered") + + /* If driver is already registered, increment ref count on ID and return ID */ + if (driver_is_registered) { + HDassert(driver_id >= 0); + + if (H5I_inc_ref(driver_id, app_ref) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VFD") + } /* end if */ + else { + H5PL_key_t key; + const H5FD_class_t *cls; + + /* Try loading the driver */ + key.vfd.kind = H5FD_GET_DRIVER_BY_NAME; + key.vfd.u.name = name; + if (NULL == (cls = (const H5FD_class_t *)H5PL_load(H5PL_TYPE_VFD, &key))) + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VFD") + + /* Register the driver we loaded */ + if ((driver_id = H5FD_register(cls, sizeof(*cls), app_ref)) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VFD ID") + } /* end else */ + + ret_value = driver_id; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_register_driver_by_name() */ + +/*------------------------------------------------------------------------- + * Function: H5FD_register_driver_by_value + * + * Purpose: Registers a new VFD as a member of the virtual file driver + * class. + * + * Return: Success: A VFD ID which is good until the library is + * closed. + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +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 */ + + FUNC_ENTER_NOAPI(H5I_INVALID_HID) + + /* Check if driver is already registered */ + if ((driver_is_registered = H5FD_is_driver_registered_by_value(value, &driver_id)) < 0) + HGOTO_ERROR(H5E_VFL, H5E_BADITER, H5I_INVALID_HID, "can't check if driver is already registered") + + /* If driver is already registered, increment ref count on ID and return ID */ + if (driver_is_registered) { + HDassert(driver_id >= 0); + + if (H5I_inc_ref(driver_id, app_ref) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VFD") + } /* end if */ + else { + H5PL_key_t key; + const H5FD_class_t *cls; + + /* Try loading the driver */ + key.vfd.kind = H5FD_GET_DRIVER_BY_VALUE; + key.vfd.u.value = value; + if (NULL == (cls = (const H5FD_class_t *)H5PL_load(H5PL_TYPE_VFD, &key))) + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VFD") + + /* Register the driver we loaded */ + if ((driver_id = H5FD_register(cls, sizeof(*cls), app_ref)) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VFD ID") + } /* end else */ + + ret_value = driver_id; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_register_driver_by_value() */ + +/*------------------------------------------------------------------------- + * Function: H5FD_is_driver_registered_by_name + * + * Purpose: Checks if a driver with a particular name is registered. + * If `registered_id` is non-NULL and a driver with the + * specified name has been registered, the driver's ID will be + * returned in `registered_id`. + * + * Return: >0 if a VFD with that name has been registered + * 0 if a VFD with that name has NOT been registered + * <0 on errors + * + *------------------------------------------------------------------------- + */ +htri_t +H5FD_is_driver_registered_by_name(const char *driver_name, hid_t *registered_id) +{ + H5FD_get_driver_ud_t op_data; /* Callback info for driver search */ + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set up op data for iteration */ + op_data.key.kind = H5FD_GET_DRIVER_BY_NAME; + op_data.key.u.name = driver_name; + op_data.found_id = H5I_INVALID_HID; + + /* Find driver with name */ + if (H5I_iterate(H5I_VFL, H5FD__get_driver_cb, &op_data, FALSE) < 0) + HGOTO_ERROR(H5E_VFL, H5E_BADITER, FAIL, "can't iterate over VFDs") + + /* Found a driver with that name */ + if (op_data.found_id != H5I_INVALID_HID) { + if (registered_id) + *registered_id = op_data.found_id; + ret_value = TRUE; + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_is_driver_registered_by_name() */ + +/*------------------------------------------------------------------------- + * Function: H5FD_is_driver_registered_by_value + * + * Purpose: Checks if a driver with a particular value (ID) is + * registered. If `registered_id` is non-NULL and a driver + * with the specified value has been registered, the driver's + * ID will be returned in `registered_id`. + * + * Return: >0 if a VFD with that value has been registered + * 0 if a VFD with that value has NOT been registered + * <0 on errors + * + *------------------------------------------------------------------------- + */ +htri_t +H5FD_is_driver_registered_by_value(H5FD_class_value_t driver_value, hid_t *registered_id) +{ + H5FD_get_driver_ud_t op_data; /* Callback info for driver search */ + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set up op data for iteration */ + op_data.key.kind = H5FD_GET_DRIVER_BY_VALUE; + op_data.key.u.value = driver_value; + op_data.found_id = H5I_INVALID_HID; + + /* Find driver with value */ + if (H5I_iterate(H5I_VFL, H5FD__get_driver_cb, &op_data, FALSE) < 0) + HGOTO_ERROR(H5E_VFL, H5E_BADITER, FAIL, "can't iterate over VFDs") + + /* Found a driver with that value */ + if (op_data.found_id != H5I_INVALID_HID) { + if (registered_id) + *registered_id = op_data.found_id; + ret_value = TRUE; + } + +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 87871ab..1828a88 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -180,42 +180,46 @@ static herr_t H5FD__log_unlock(H5FD_t *_file); static herr_t H5FD__log_delete(const char *filename, hid_t fapl_id); static const H5FD_class_t H5FD_log_g = { - "log", /* name */ - MAXADDR, /* maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - H5FD__log_term, /* terminate */ - NULL, /* sb_size */ - NULL, /* sb_encode */ - NULL, /* sb_decode */ - sizeof(H5FD_log_fapl_t), /* fapl_size */ - H5FD__log_fapl_get, /* fapl_get */ - H5FD__log_fapl_copy, /* fapl_copy */ - H5FD__log_fapl_free, /* fapl_free */ - 0, /* dxpl_size */ - NULL, /* dxpl_copy */ - NULL, /* dxpl_free */ - H5FD__log_open, /* open */ - H5FD__log_close, /* close */ - H5FD__log_cmp, /* cmp */ - H5FD__log_query, /* query */ - NULL, /* get_type_map */ - H5FD__log_alloc, /* alloc */ - H5FD__log_free, /* free */ - H5FD__log_get_eoa, /* get_eoa */ - H5FD__log_set_eoa, /* set_eoa */ - H5FD__log_get_eof, /* get_eof */ - H5FD__log_get_handle, /* get_handle */ - H5FD__log_read, /* read */ - H5FD__log_write, /* write */ - NULL, /* flush */ - H5FD__log_truncate, /* truncate */ - H5FD__log_lock, /* lock */ - H5FD__log_unlock, /* unlock */ - H5FD__log_delete, /* del */ - NULL, /* ctl */ - H5FD_FLMAP_DICHOTOMY /* fl_map */ + H5FD_LOG_VALUE, /* value */ + "log", /* name */ + MAXADDR, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + H5FD__log_term, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + sizeof(H5FD_log_fapl_t), /* fapl_size */ + H5FD__log_fapl_get, /* fapl_get */ + H5FD__log_fapl_copy, /* fapl_copy */ + H5FD__log_fapl_free, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD__log_open, /* open */ + H5FD__log_close, /* close */ + H5FD__log_cmp, /* cmp */ + H5FD__log_query, /* query */ + NULL, /* get_type_map */ + H5FD__log_alloc, /* alloc */ + H5FD__log_free, /* free */ + H5FD__log_get_eoa, /* get_eoa */ + H5FD__log_set_eoa, /* set_eoa */ + H5FD__log_get_eof, /* get_eof */ + H5FD__log_get_handle, /* get_handle */ + H5FD__log_read, /* read */ + H5FD__log_write, /* write */ + NULL, /* flush */ + H5FD__log_truncate, /* truncate */ + H5FD__log_lock, /* lock */ + H5FD__log_unlock, /* unlock */ + H5FD__log_delete, /* del */ + NULL, /* ctl */ + 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); @@ -237,7 +241,7 @@ H5FD__init_package(void) FUNC_ENTER_STATIC /* Check the use disabled file locks environment variable */ - lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING"); + lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) @@ -348,7 +352,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 +487,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 +529,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/H5FDlog.h b/src/H5FDlog.h index 969c091..bc96c52 100644 --- a/src/H5FDlog.h +++ b/src/H5FDlog.h @@ -20,7 +20,8 @@ #ifndef H5FDlog_H #define H5FDlog_H -#define H5FD_LOG (H5FD_log_init()) +#define H5FD_LOG (H5FD_log_init()) +#define H5FD_LOG_VALUE H5_VFD_LOG /* Flags for H5Pset_fapl_log() */ /* Flags for tracking 'meta' operations (truncate) */ diff --git a/src/H5FDmirror.c b/src/H5FDmirror.c index d539f4d..738e9d5 100644 --- a/src/H5FDmirror.c +++ b/src/H5FDmirror.c @@ -160,6 +160,7 @@ static herr_t H5FD__mirror_unlock(H5FD_t *_file); static herr_t H5FD__mirror_verify_reply(H5FD_mirror_t *file); static const H5FD_class_t H5FD_mirror_g = { + H5FD_MIRROR_VALUE, /* value */ "mirror", /* name */ MAXADDR, /* maxaddr */ H5F_CLOSE_WEAK, /* fc_degree */ @@ -1336,7 +1337,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/H5FDmirror.h b/src/H5FDmirror.h index 49e24c1..66954b1 100644 --- a/src/H5FDmirror.h +++ b/src/H5FDmirror.h @@ -19,7 +19,8 @@ #ifdef H5_HAVE_MIRROR_VFD -#define H5FD_MIRROR (H5FD_mirror_init()) +#define H5FD_MIRROR (H5FD_mirror_init()) +#define H5FD_MIRROR_VALUE H5_VFD_MIRROR #ifdef __cplusplus extern "C" { diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index 7c85897..f4d3fed 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 */ @@ -92,6 +95,7 @@ static herr_t H5FD__mpio_ctl(H5FD_t *_file, uint64_t op_code, uint64_t flags, c /* The MPIO file driver information */ static const H5FD_class_t H5FD_mpio_g = { + H5_VFD_MPIO, /* value */ "mpio", /* name */ HADDR_MAX, /* maxaddr */ H5F_CLOSE_SEMI, /* fc_degree */ @@ -233,6 +237,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) @@ -241,6 +246,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_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 */ @@ -286,6 +306,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; @@ -347,7 +378,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) @@ -802,11 +833,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))) @@ -1768,11 +1804,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))) diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index 0d1967d..3dcfa37 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); @@ -171,6 +176,7 @@ static herr_t H5FD_multi_ctl(H5FD_t *_file, uint64_t op_code, uint64_t flags, c /* The class struct */ static const H5FD_class_t H5FD_multi_g = { + H5_VFD_MULTI, /* value */ "multi", /* name */ HADDR_MAX, /* maxaddr */ H5F_CLOSE_WEAK, /* fc_degree */ @@ -274,74 +280,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); } /*------------------------------------------------------------------------- @@ -425,14 +376,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*/ @@ -442,66 +386,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; - } - - 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; + 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); - /* - * 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); } @@ -526,6 +413,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 */ @@ -538,8 +426,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)); @@ -568,6 +465,231 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map /*out*/, hid_t *memb_fapl } /*------------------------------------------------------------------------- + * 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 * * Purpose: Returns the size of the private information to be stored in @@ -1012,12 +1134,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]; @@ -2040,6 +2176,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 */ @@ -2047,11 +2184,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 6dbd483..fa562f9 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -81,12 +81,19 @@ 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 */ +typedef enum H5FD_get_driver_kind_t { + H5FD_GET_DRIVER_BY_NAME, /* Name field is set */ + H5FD_GET_DRIVER_BY_VALUE /* Value field is set */ +} H5FD_get_driver_kind_t; + /*****************************/ /* Library Private Variables */ /*****************************/ @@ -97,6 +104,7 @@ typedef struct { /* Forward declarations for prototype arguments */ struct H5F_t; +union H5PL_key_t; H5_DLL int H5FD_term_interface(void); H5_DLL herr_t H5FD_locate_signature(H5FD_t *file, haddr_t *sig_addr); @@ -107,10 +115,17 @@ H5_DLL herr_t H5FD_sb_load(H5FD_t *file, const char *name, const uint8_t H5_DLL void * H5FD_fapl_get(H5FD_t *file); H5_DLL herr_t H5FD_free_driver_info(hid_t driver_id, const void *driver_info); 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 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); H5_DLL herr_t H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags /*out*/); +H5_DLL herr_t H5FD_check_plugin_load(const H5FD_class_t *cls, const union H5PL_key_t *key, hbool_t *success); H5_DLL haddr_t H5FD_alloc(H5FD_t *file, H5FD_mem_t type, struct H5F_t *f, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size); H5_DLL herr_t H5FD_free(H5FD_t *file, H5FD_mem_t type, struct H5F_t *f, haddr_t addr, hsize_t size); diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index b8f4f12..a72dc80 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -28,6 +28,39 @@ #define H5FD_VFD_DEFAULT 0 /* Default VFL driver value */ +/* VFD identifier values + * These are H5FD_class_value_t values, NOT hid_t values! + */ +#define H5_VFD_INVALID ((H5FD_class_value_t)(-1)) +#define H5_VFD_SEC2 ((H5FD_class_value_t)(0)) +#define H5_VFD_CORE ((H5FD_class_value_t)(1)) +#define H5_VFD_LOG ((H5FD_class_value_t)(2)) +#define H5_VFD_FAMILY ((H5FD_class_value_t)(3)) +#define H5_VFD_MULTI ((H5FD_class_value_t)(4)) +#define H5_VFD_STDIO ((H5FD_class_value_t)(5)) +#define H5_VFD_SPLITTER ((H5FD_class_value_t)(6)) +#ifdef H5_HAVE_PARALLEL +#define H5_VFD_MPIO ((H5FD_class_value_t)(7)) +#endif +#ifdef H5_HAVE_DIRECT +#define H5_VFD_DIRECT ((H5FD_class_value_t)(8)) +#endif +#ifdef H5_HAVE_MIRROR_VFD +#define H5_VFD_MIRROR ((H5FD_class_value_t)(9)) +#endif +#ifdef H5_HAVE_LIBHDFS +#define H5_VFD_HDFS ((H5FD_class_value_t)(10)) +#endif +#ifdef H5_HAVE_ROS3_VFD +#define H5_VFD_ROS3 ((H5FD_class_value_t)(11)) +#endif + +/* VFD IDs below this value are reserved for library use. */ +#define H5_VFD_RESERVED 256 + +/* Maximum VFD ID */ +#define H5_VFD_MAX 65535 + /* Define VFL driver features that can be enabled on a per-driver basis */ /* These are returned with the 'query' function pointer in H5FD_class_t */ /* @@ -213,6 +246,16 @@ /* Public Typedefs */ /*******************/ +/* + * File driver identifiers. + * + * Values 0 through 255 are for drivers defined by the HDF5 library. + * Values 256 through 511 are available for testing new drivers. + * Subsequent values should be obtained from the HDF5 development + * team at mailto:help@hdfgroup.org. + */ +typedef int H5FD_class_value_t; + /* Types of allocation requests: see H5Fpublic.h */ typedef enum H5F_mem_t H5FD_mem_t; diff --git a/src/H5FDros3.c b/src/H5FDros3.c index a32d65e..2ffee17 100644 --- a/src/H5FDros3.c +++ b/src/H5FDros3.c @@ -237,6 +237,7 @@ static herr_t H5FD__ros3_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing static herr_t H5FD__ros3_validate_config(const H5FD_ros3_fapl_t *fa); static const H5FD_class_t H5FD_ros3_g = { + H5FD_ROS3_VALUE, /* value */ "ros3", /* name */ MAXADDR, /* maxaddr */ H5F_CLOSE_WEAK, /* fc_degree */ @@ -411,7 +412,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/H5FDros3.h b/src/H5FDros3.h index 8e42ca2..d69ebe4 100644 --- a/src/H5FDros3.h +++ b/src/H5FDros3.h @@ -22,9 +22,11 @@ #define H5FDros3_H #ifdef H5_HAVE_ROS3_VFD -#define H5FD_ROS3 (H5FD_ros3_init()) +#define H5FD_ROS3 (H5FD_ros3_init()) +#define H5FD_ROS3_VALUE H5_VFD_ROS3 #else -#define H5FD_ROS3 (H5I_INVALID_HID) +#define H5FD_ROS3 (H5I_INVALID_HID) +#define H5FD_ROS3_VALUE H5_VFD_INVALID #endif /* H5_HAVE_ROS3_VFD */ #ifdef H5_HAVE_ROS3_VFD diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 15103da..2dbdd6f 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -143,6 +143,7 @@ static herr_t H5FD__sec2_ctl(H5FD_t *_file, uint64_t op_code, uint64_t flags, c void **output); static const H5FD_class_t H5FD_sec2_g = { + H5FD_SEC2_VALUE, /* value */ "sec2", /* name */ MAXADDR, /* maxaddr */ H5F_CLOSE_WEAK, /* fc_degree */ @@ -200,7 +201,7 @@ H5FD__init_package(void) FUNC_ENTER_STATIC /* Check the use disabled file locks environment variable */ - lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING"); + lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); if (lock_env_var && !HDstrcmp(lock_env_var, "BEST_EFFORT")) ignore_disabled_file_locks_s = TRUE; /* Override: Ignore disabled locks */ else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "1"))) @@ -295,7 +296,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/H5FDsec2.h b/src/H5FDsec2.h index 541ac71..5c35677 100644 --- a/src/H5FDsec2.h +++ b/src/H5FDsec2.h @@ -20,7 +20,8 @@ #ifndef H5FDsec2_H #define H5FDsec2_H -#define H5FD_SEC2 (H5FD_sec2_init()) +#define H5FD_SEC2 (H5FD_sec2_init()) +#define H5FD_SEC2_VALUE H5_VFD_SEC2 #ifdef __cplusplus extern "C" { diff --git a/src/H5FDsplitter.c b/src/H5FDsplitter.c index 3113e8b..321973e 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,10 +133,12 @@ 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 herr_t H5FD__splitter_ctl(H5FD_t *_file, uint64_t op_code, uint64_t flags, const void *input, void **output); static const H5FD_class_t H5FD_splitter_g = { + H5FD_SPLITTER_VALUE, /* value */ "splitter", /* name */ MAXADDR, /* maxaddr */ H5F_CLOSE_WEAK, /* fc_degree */ @@ -140,7 +146,7 @@ static const H5FD_class_t H5FD_splitter_g = { H5FD__splitter_sb_size, /* sb_size */ H5FD__splitter_sb_encode, /* sb_encode */ H5FD__splitter_sb_decode, /* sb_decode */ - sizeof(H5FD_splitter_fapl_t), /* fapl_size */ + sizeof(H5FD_splitter_fapl_t), /* fapl_size */ H5FD__splitter_fapl_get, /* fapl_get */ H5FD__splitter_fapl_copy, /* fapl_copy */ H5FD__splitter_fapl_free, /* fapl_free */ @@ -151,7 +157,7 @@ static const H5FD_class_t H5FD_splitter_g = { H5FD__splitter_close, /* close */ H5FD__splitter_cmp, /* cmp */ H5FD__splitter_query, /* query */ - H5FD__splitter_get_type_map, /* get_type_map */ + H5FD__splitter_get_type_map, /* get_type_map */ H5FD__splitter_alloc, /* alloc */ H5FD__splitter_free, /* free */ H5FD__splitter_get_eoa, /* get_eoa */ @@ -164,7 +170,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__splitter_ctl, /* ctl */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }; @@ -312,57 +318,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 + 1); - info->wo_path[H5FD_SPLITTER_PATH_MAX] = '\0'; - HDstrncpy(info->log_file_path, vfd_config->log_file_path, H5FD_SPLITTER_PATH_MAX + 1); - info->log_file_path[H5FD_SPLITTER_PATH_MAX] = '\0'; - 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) @@ -386,9 +349,10 @@ done: 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); @@ -414,8 +378,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 + 1); HDstrncpy(config->log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX + 1); @@ -428,10 +398,188 @@ 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 + 1); + fapl_out->wo_path[H5FD_SPLITTER_PATH_MAX] = '\0'; + HDstrncpy(fapl_out->log_file_path, vfd_config->log_file_path, H5FD_SPLITTER_PATH_MAX + 1); + fapl_out->log_file_path[H5FD_SPLITTER_PATH_MAX] = '\0'; + 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 * * Purpose: Flushes all data to disk for both channels. @@ -658,10 +806,11 @@ done: 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 @@ -674,8 +823,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); @@ -689,8 +837,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 + 1); @@ -726,6 +886,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) @@ -1339,6 +1502,74 @@ done: } /* 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 * * Purpose: Log an error from the W/O channel appropriately. diff --git a/src/H5FDsplitter.h b/src/H5FDsplitter.h index ee6e7c5..3a743e4 100644 --- a/src/H5FDsplitter.h +++ b/src/H5FDsplitter.h @@ -17,7 +17,8 @@ #ifndef H5FDsplitter_H #define H5FDsplitter_H -#define H5FD_SPLITTER (H5FD_splitter_init()) +#define H5FD_SPLITTER (H5FD_splitter_init()) +#define H5FD_SPLITTER_VALUE H5_VFD_SPLITTER /* The version of the H5FD_splitter_vfd_config_t structure used */ #define H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION 1 diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 312263c..122379a 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -183,6 +183,7 @@ static herr_t H5FD_stdio_unlock(H5FD_t *_file); static herr_t H5FD_stdio_delete(const char *filename, hid_t fapl_id); static const H5FD_class_t H5FD_stdio_g = { + H5_VFD_STDIO, /* value */ "stdio", /* name */ MAXADDR, /* maxaddr */ H5F_CLOSE_WEAK, /* fc_degree */ @@ -243,7 +244,7 @@ H5FD_stdio_init(void) H5Eclear2(H5E_DEFAULT); /* Check the use disabled file locks environment variable */ - lock_env_var = getenv("HDF5_USE_FILE_LOCKING"); + lock_env_var = getenv(HDF5_USE_FILE_LOCKING); if (lock_env_var && !strcmp(lock_env_var, "BEST_EFFORT")) ignore_disabled_file_locks_s = 1; /* Override: Ignore disabled locks */ else if (lock_env_var && (!strcmp(lock_env_var, "TRUE") || !strcmp(lock_env_var, "1"))) diff --git a/src/H5FDwindows.c b/src/H5FDwindows.c index 6ce33a7..fa3c05f 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 c2d3e77..d772088 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -277,7 +277,7 @@ H5F__parse_file_lock_env_var(htri_t *use_locks) FUNC_ENTER_PACKAGE_NOERR /* Check the file locking environment variable */ - lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING"); + lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); if (lock_env_var && (!HDstrcmp(lock_env_var, "FALSE") || !HDstrcmp(lock_env_var, "0"))) *use_locks = FALSE; /* Override: Never use locks */ else if (lock_env_var && (!HDstrcmp(lock_env_var, "TRUE") || !HDstrcmp(lock_env_var, "BEST_EFFORT") || @@ -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) @@ -1828,7 +1829,13 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) else tent_flags = flags; - if (NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) { + H5E_BEGIN_TRY + { + lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF); + } + H5E_END_TRY; + + if (NULL == lf) { if (tent_flags == flags) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', tent_flags = %x", name, tent_flags) diff --git a/src/H5PLint.c b/src/H5PLint.c index d20401e..848bd1d 100644 --- a/src/H5PLint.c +++ b/src/H5PLint.c @@ -144,7 +144,7 @@ H5PL__init_package(void) * to ignore plugins. The special symbol H5PL_NO_PLUGIN (defined in * H5PLpublic.h) means we don't want to load plugins. */ - if (NULL != (env_var = HDgetenv("HDF5_PLUGIN_PRELOAD"))) + if (NULL != (env_var = HDgetenv(HDF5_PLUGIN_PRELOAD))) if (!HDstrcmp(env_var, H5PL_NO_PLUGIN)) { H5PL_plugin_control_mask_g = 0; H5PL_allow_plugins_g = FALSE; @@ -243,6 +243,11 @@ H5PL_load(H5PL_type_t type, const H5PL_key_t *key) "Virtual Object Layer (VOL) driver plugins disabled") break; + case H5PL_TYPE_VFD: + if ((H5PL_plugin_control_mask_g & H5PL_VFD_PLUGIN) == 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "Virtual File Driver (VFD) plugins disabled") + break; + case H5PL_TYPE_ERROR: case H5PL_TYPE_NONE: default: @@ -275,9 +280,31 @@ done: * * Purpose: Opens a plugin. * - * The success parameter will be set to TRUE and the plugin_info - * parameter will be filled in on success. Otherwise, they - * will be FALSE and NULL, respectively. + * `path` specifies the path to the plugin library file. + * + * `type` specifies the type of plugin being searched for and + * will be used to verify that a loaded plugin matches the + * type requested. H5PL_TYPE_NONE may be passed, in which case + * no plugin type verification is performed. This is most + * useful when iterating over available plugins without regard + * to their types. + * + * `key` specifies the information that will be used to find a + * specific plugin. For filter plugins, this is typically an + * integer identifier. For VOL connector and VFD plugins, this + * is typically either an integer identifier or a name string. + * After a plugin has been opened, this information will be + * compared against the relevant information provided by the + * plugin to ensure that the plugin is a match. If + * H5PL_TYPE_NONE is provided for `type`, then `key` should be + * NULL. + * + * On successful open of a plugin, the `success` parameter + * will be set to TRUE and the `plugin_type` and `plugin_info` + * parameters will be filled appropriately. On failure, the + * `success` parameter will be set to FALSE, the `plugin_type` + * parameter will be set to H5PL_TYPE_ERROR and the + * `plugin_info` parameter will be set to NULL. * * Return: SUCCEED/FAIL * @@ -308,6 +335,8 @@ H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key, hbool_t *s /* Check args - Just assert on package functions */ HDassert(path); + if (type == H5PL_TYPE_NONE) + HDassert(!key); HDassert(success); HDassert(plugin_info); @@ -396,6 +425,34 @@ H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key, hbool_t *s break; } + case H5PL_TYPE_VFD: { + const void *cls; + + /* Get the plugin info */ + if (NULL == (cls = (const void *)(*get_plugin_info)())) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get VFD info from plugin") + + /* Setup temporary plugin key if one wasn't supplied */ + if (!key) { + tmp_key.vfd.kind = H5FD_GET_DRIVER_BY_NAME; + tmp_key.vfd.u.name = ((const H5FD_class_t *)cls)->name; + key = &tmp_key; + } + + /* Ask VFD interface if this class is the one we are looking for and is compatible, etc */ + if (H5FD_check_plugin_load(cls, key, success) < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, FAIL, "VFD compatibility check failed") + + /* Check for finding the correct plugin */ + if (*success) { + if (plugin_type) + *plugin_type = H5PL_TYPE_VFD; + *plugin_info = cls; + } + + break; + } + case H5PL_TYPE_ERROR: case H5PL_TYPE_NONE: default: diff --git a/src/H5PLpath.c b/src/H5PLpath.c index 39a7d0d..9aecad1 100644 --- a/src/H5PLpath.c +++ b/src/H5PLpath.c @@ -248,7 +248,7 @@ H5PL__create_path_table(void) /* Retrieve paths from HDF5_PLUGIN_PATH if the user sets it * or from the default paths if it isn't set. */ - env_var = HDgetenv("HDF5_PLUGIN_PATH"); + env_var = HDgetenv(HDF5_PLUGIN_PATH); if (NULL == env_var) paths = H5MM_strdup(H5PL_DEFAULT_PATH); else @@ -571,12 +571,12 @@ H5PL__path_table_iterate(H5PL_iterate_type_t iter_type, H5PL_iterate_t iter_op, FUNC_ENTER_PACKAGE - for (u = 0; (u < H5PL_num_paths_g) && (ret_value == H5_ITER_CONT); u++) - ret_value = H5PL__path_table_iterate_process_path(H5PL_paths_g[u], iter_type, iter_op, op_data); - - if (ret_value < 0) - HGOTO_ERROR(H5E_PLUGIN, H5E_BADITER, H5_ITER_ERROR, "can't iterate over plugins in plugin path '%s'", - H5PL_paths_g[u]); + for (u = 0; (u < H5PL_num_paths_g) && (ret_value == H5_ITER_CONT); u++) { + if ((ret_value = + H5PL__path_table_iterate_process_path(H5PL_paths_g[u], iter_type, iter_op, op_data)) < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_BADITER, H5_ITER_ERROR, + "can't iterate over plugins in plugin path '%s'", H5PL_paths_g[u]); + } done: FUNC_LEAVE_NOAPI(ret_value); @@ -615,9 +615,9 @@ H5PL__path_table_iterate_process_path(const char *plugin_path, H5PL_iterate_type HDassert(plugin_path); HDassert(iter_op); - /* Open the directory */ + /* Open the directory - skip the path if the directory can't be opened */ if (!(dirp = HDopendir(plugin_path))) - HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, H5_ITER_ERROR, "can't open directory: %s", plugin_path) + HGOTO_DONE(H5_ITER_CONT) /* Iterate through all entries in the directory */ while (NULL != (dp = HDreaddir(dirp))) { @@ -663,7 +663,8 @@ H5PL__path_table_iterate_process_path(const char *plugin_path, H5PL_iterate_type /* Determine if we should process this plugin */ plugin_matches = (iter_type == H5PL_ITER_TYPE_ALL) || ((iter_type == H5PL_ITER_TYPE_FILTER) && (plugin_type == H5PL_TYPE_FILTER)) || - ((iter_type == H5PL_ITER_TYPE_VOL) && (plugin_type == H5PL_TYPE_VOL)); + ((iter_type == H5PL_ITER_TYPE_VOL) && (plugin_type == H5PL_TYPE_VOL)) || + ((iter_type == H5PL_ITER_TYPE_VFD) && (plugin_type == H5PL_TYPE_VFD)); /* If the plugin was successfully loaded, call supplied callback function on plugin */ if (plugin_loaded && plugin_matches && (ret_value = iter_op(plugin_type, plugin_info, op_data))) @@ -706,10 +707,11 @@ H5PL__path_table_iterate_process_path(const char *plugin_path, H5PL_iterate_type HDassert(plugin_path); HDassert(iter_op); - /* Specify a file mask. *.* = We want everything! */ + /* Specify a file mask. *.* = We want everything! - + * skip the path if the directory can't be opened */ HDsprintf(service, "%s\\*.dll", plugin_path); if ((hFind = FindFirstFileA(service, &fdFile)) == INVALID_HANDLE_VALUE) - HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, H5_ITER_ERROR, "can't open directory") + HGOTO_DONE(H5_ITER_CONT) /* Loop over all the files */ do { @@ -740,7 +742,8 @@ H5PL__path_table_iterate_process_path(const char *plugin_path, H5PL_iterate_type /* Determine if we should process this plugin */ plugin_matches = (iter_type == H5PL_ITER_TYPE_ALL) || ((iter_type == H5PL_ITER_TYPE_FILTER) && (plugin_type == H5PL_TYPE_FILTER)) || - ((iter_type == H5PL_ITER_TYPE_VOL) && (plugin_type == H5PL_TYPE_VOL)); + ((iter_type == H5PL_ITER_TYPE_VOL) && (plugin_type == H5PL_TYPE_VOL)) || + ((iter_type == H5PL_ITER_TYPE_VFD) && (plugin_type == H5PL_TYPE_VFD)); /* If the plugin was successfully loaded, call supplied callback function on plugin */ if (plugin_loaded && plugin_matches && (ret_value = iter_op(plugin_type, plugin_info, op_data))) diff --git a/src/H5PLplugin_cache.c b/src/H5PLplugin_cache.c index b7cdac0..25e373f 100644 --- a/src/H5PLplugin_cache.c +++ b/src/H5PLplugin_cache.c @@ -263,59 +263,99 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f /* Loop over all the plugins, looking for one that matches */ for (u = 0; u < H5PL_num_plugins_g; u++) { - /* If the plugin type (filter, VOL connector, etc.) match, proceed */ - if (search_params->type == H5PL_cache_g[u].type) { - hbool_t matched = FALSE; /* Whether cached plugin info matches */ + hbool_t matched = FALSE; /* Whether cached plugin info matches */ - switch (search_params->type) { - case H5PL_TYPE_FILTER: - if (search_params->key->id == H5PL_cache_g[u].key.id) + /* Determine if the plugin types match */ + if (search_params->type != H5PL_cache_g[u].type) + continue; + + /* Determine if cache entry matches based on type-specific information */ + switch (search_params->type) { + case H5PL_TYPE_FILTER: + /* Check if specified filter plugin ID matches cache entry's ID */ + if (search_params->key->id == H5PL_cache_g[u].key.id) + matched = TRUE; + + break; + + case H5PL_TYPE_VOL: + if (search_params->key->vol.kind == H5VL_GET_CONNECTOR_BY_NAME) { + /* Make sure the plugin cache entry key type matches our search key type */ + if (H5PL_cache_g[u].key.vol.kind != H5VL_GET_CONNECTOR_BY_NAME) + continue; + + /* Check if specified VOL connector name matches cache entry's name */ + if (!HDstrcmp(search_params->key->vol.u.name, H5PL_cache_g[u].key.vol.u.name)) + matched = TRUE; + } + else { + HDassert(search_params->key->vol.kind == H5VL_GET_CONNECTOR_BY_VALUE); + + /* Make sure the plugin cache entry key type matches our search key type */ + if (H5PL_cache_g[u].key.vol.kind != H5VL_GET_CONNECTOR_BY_VALUE) + continue; + + /* Check if specified VOL connector ID matches cache entry's ID */ + if (search_params->key->vol.u.value == H5PL_cache_g[u].key.vol.u.value) + matched = TRUE; + } + + break; + + case H5PL_TYPE_VFD: + if (search_params->key->vfd.kind == H5FD_GET_DRIVER_BY_NAME) { + /* Make sure the plugin cache entry key type matches our search key type */ + if (H5PL_cache_g[u].key.vfd.kind != H5FD_GET_DRIVER_BY_NAME) + continue; + + /* Check if specified VFD name matches cache entry's name */ + if (!HDstrcmp(search_params->key->vfd.u.name, H5PL_cache_g[u].key.vfd.u.name)) matched = TRUE; - break; - - case H5PL_TYPE_VOL: - if (search_params->key->vol.kind == H5VL_GET_CONNECTOR_BY_VALUE) { - if (search_params->key->vol.u.value == H5PL_cache_g[u].key.vol.u.value) - matched = TRUE; - } /* end if */ - else if (search_params->key->vol.kind == H5VL_GET_CONNECTOR_BY_NAME) { - if (0 == HDstrcmp(search_params->key->vol.u.name, H5PL_cache_g[u].key.vol.u.name)) - matched = TRUE; - } /* end else-if */ - else - HGOTO_ERROR(H5E_PLUGIN, H5E_BADVALUE, FAIL, "bad VOL plugin search key type") - break; - - case H5PL_TYPE_ERROR: - case H5PL_TYPE_NONE: - default: - HGOTO_ERROR(H5E_PLUGIN, H5E_BADVALUE, FAIL, "bad plugin type") - } /* end switch */ - - /* If the plugin type (filter, VOL connector, etc.) and key match, query the plugin for its info - */ - if (matched) { - H5PL_get_plugin_info_t get_plugin_info_function; - const void * info; - - /* Get the "get plugin info" function from the plugin. */ - if (NULL == (get_plugin_info_function = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC( - (H5PL_cache_g[u]).handle, "H5PLget_plugin_info"))) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get function for H5PLget_plugin_info") - - /* Call the "get plugin info" function */ - if (NULL == (info = (*get_plugin_info_function)())) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info") - - /* Set output parameters */ - *found = TRUE; - *plugin_info = info; - - /* No need to continue processing */ + } + else { + HDassert(search_params->key->vfd.kind == H5FD_GET_DRIVER_BY_VALUE); + + /* Make sure the plugin cache entry key type matches our search key type */ + if (H5PL_cache_g[u].key.vfd.kind != H5FD_GET_DRIVER_BY_VALUE) + continue; + + /* Check if specified VFD ID matches cache entry's ID */ + if (search_params->key->vfd.u.value == H5PL_cache_g[u].key.vfd.u.value) + matched = TRUE; + } + break; - } /* end if */ - } /* end if */ - } /* end for */ + + case H5PL_TYPE_ERROR: + case H5PL_TYPE_NONE: + default: + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "Invalid plugin type specified") + } + + /* If the plugin type (filter, VOL connector, VFD plugin, etc.) and key match, + * query the plugin for its info. + */ + if (matched) { + H5PL_get_plugin_info_t get_plugin_info_function; + const void * info; + + /* Get the "get plugin info" function from the plugin. */ + if (NULL == (get_plugin_info_function = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC( + H5PL_cache_g[u].handle, "H5PLget_plugin_info"))) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get function for H5PLget_plugin_info") + + /* Call the "get plugin info" function */ + if (NULL == (info = (*get_plugin_info_function)())) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info") + + /* Set output parameters */ + *found = TRUE; + *plugin_info = info; + + /* No need to continue processing */ + break; + } + } /* end for */ done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5PLprivate.h b/src/H5PLprivate.h index 7eae513..7ff5c1a 100644 --- a/src/H5PLprivate.h +++ b/src/H5PLprivate.h @@ -22,6 +22,7 @@ /* Private headers needed by this file */ #include "H5private.h" /* Generic Functions */ +#include "H5FDprivate.h" /* File Drivers */ #include "H5VLprivate.h" /* Virtual Object Layer */ /**************************/ @@ -32,16 +33,29 @@ /* Library Private Typedefs */ /****************************/ +/* Key used to find VOL connector plugins */ +typedef struct H5PL_vol_key_t { + H5VL_get_connector_kind_t kind; /* Kind of VOL lookup to do */ + union { + H5VL_class_value_t value; /* VOL connector value */ + const char * name; /* VOL connector name */ + } u; +} H5PL_vol_key_t; + +/* Key used to find VFD plugins */ +typedef struct H5PL_vfd_key_t { + H5FD_get_driver_kind_t kind; /* Kind of VFD lookup to do */ + union { + H5FD_class_value_t value; /* VFD value */ + const char * name; /* VFD name */ + } u; +} H5PL_vfd_key_t; + /* The key that will be used to find the plugin */ typedef union H5PL_key_t { - int id; /* I/O filters */ - struct { - H5VL_get_connector_kind_t kind; /* Kind of VOL lookup to do */ - union { - H5VL_class_value_t value; /* VOL connector value */ - const char * name; /* VOL connector name */ - } u; - } vol; + int id; /* I/O filters */ + H5PL_vol_key_t vol; + H5PL_vfd_key_t vfd; } H5PL_key_t; /* Enum dictating the type of plugins to process @@ -50,6 +64,7 @@ typedef union H5PL_key_t { typedef enum { H5PL_ITER_TYPE_FILTER, H5PL_ITER_TYPE_VOL, + H5PL_ITER_TYPE_VFD, H5PL_ITER_TYPE_ALL, } H5PL_iterate_type_t; diff --git a/src/H5PLpublic.h b/src/H5PLpublic.h index 55ff594..ab24bd5 100644 --- a/src/H5PLpublic.h +++ b/src/H5PLpublic.h @@ -35,14 +35,16 @@ typedef enum H5PL_type_t { H5PL_TYPE_ERROR = -1, /**< Error */ H5PL_TYPE_FILTER = 0, /**< Filter */ - H5PL_TYPE_VOL = 1, /**< VOL driver */ - H5PL_TYPE_NONE = 2 /**< Sentinel: This must be last! */ + H5PL_TYPE_VOL = 1, /**< VOL connector */ + H5PL_TYPE_VFD = 2, /**< VFD */ + H5PL_TYPE_NONE = 3 /**< Sentinel: This must be last! */ } H5PL_type_t; //! /* Common dynamic plugin type flags used by the set/get_loading_state functions */ #define H5PL_FILTER_PLUGIN 0x0001 #define H5PL_VOL_PLUGIN 0x0002 +#define H5PL_VFD_PLUGIN 0x0004 #define H5PL_ALL_PLUGIN 0xFFFF #ifdef __cplusplus diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index a8e0d8e..f37cb74 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 @@ -398,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 herr_t H5P__facc_set_def_driver_check_predefined(const char *driver_name, hid_t *driver_id); + /*********************/ /* Package Variables */ /*********************/ @@ -809,6 +832,208 @@ done: } /* 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 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 * * Purpose: Sets the alignment properties of a file access property list @@ -899,42 +1124,52 @@ done: } /* 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 */ @@ -980,7 +1215,7 @@ 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: @@ -988,6 +1223,180 @@ done: } /* 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 + * + * Purpose: Set the file driver name (DRIVER_NAME) for a file access + * property list (PLIST_ID) 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 +H5Pset_driver_by_name(hid_t plist_id, const char *driver_name, const char *driver_config) +{ + 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); + + /* Check arguments */ + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + if (!driver_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "driver_name parameter cannot be NULL") + 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_value(driver_value, 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_value() */ + +/*------------------------------------------------------------------------- + * Function: H5Pset_driver_by_value + * + * Purpose: Set the file driver value (DRIVER_VALUE) for a file access + * property list (PLIST_ID) 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 +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 */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "iDV*s", plist_id, driver_value, driver_config); + + /* Check arguments */ + if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + if (driver_value < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "negative VFD value is disallowed") + + /* Set the driver */ + 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: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_driver_by_value() */ + +/*------------------------------------------------------------------------- * Function: H5P_peek_driver * * Purpose: Return the ID of the low-level file driver. PLIST_ID should @@ -1014,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") @@ -1098,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") @@ -1151,13 +1560,104 @@ done: } /* 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 + * + * Purpose: Retrieves a string representation of the configuration for + * the driver set on the given FAPL. The returned string can + * be used to configure the same driver in an identical way. + * + * `config_buf` may be NULL, in which case the length of the + * driver configuration string is simply returned. The caller + * can then allocate a buffer of the appropriate size and call + * this routine again. + * + * Return: Length of the driver configuration string on success (not + * including the NUL terminator) + * Negative on failure + * + *------------------------------------------------------------------------- + */ +ssize_t +H5Pget_driver_config_str(hid_t fapl_id, char *config_buf, size_t buf_size) +{ + 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); + + /* Check arguments */ + if (!config_buf && buf_size) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "config_buf cannot be NULL if buf_size is non-zero") + + /* Get the plist structure */ + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_ID, H5E_BADID, (-1), "can't find object for ID") + + /* Retrieve configuration string property */ + if ((config_str = H5P_peek_driver_config_str(plist))) { + size_t config_str_len = HDstrlen(config_str); + + if (config_buf) { + HDstrncpy(config_buf, config_str, MIN(config_str_len + 1, buf_size)); + if (config_str_len >= buf_size) + config_buf[buf_size - 1] = '\0'; + } + + ret_value = (ssize_t)config_str_len; + } + else + ret_value = 0; + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Pget_driver_config_str() */ + +/*------------------------------------------------------------------------- * Function: H5P__file_driver_copy * * Purpose: Copy file driver ID & info. * * 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 @@ -1208,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 */ @@ -1238,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 */ @@ -1246,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") @@ -1465,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() */ diff --git a/src/H5Pint.c b/src/H5Pint.c index 9530d87..9206d4c 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 dd43f76..2946931 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 6ebe5d3..7cbb397 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/H5Ppublic.h b/src/H5Ppublic.h index a5c5c37..3fa7118 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -3448,6 +3448,34 @@ H5_DLL const void *H5Pget_driver_info(hid_t plist_id); /** * \ingroup FAPL * + * \brief Retrieves a string representation of the configuration for + * the driver set on the given FAPL. The returned string can + * be used to configure the same driver in an identical way. + * + * \fapl_id + * \param[out] config_buf Driver configuration string output buffer + * \param[in] buf_size Size of driver configuration string output buffer + * + * \return Returns the length of the driver configuration string on + * success (not including the NUL terminator). Returns negative + * on failure. + * + * \details H5Pget_driver_config_str() retrieves a string representation + * of the configuration for the driver set on the given FAPL. The + * returned string can be used to configure the same driver in + * an identical way. + * + * If \p config_buf is NULL, the length of the driver configuration + * string is simply returned. The caller can then allocate a buffer + * of the appropriate size and call this routine again. + * + * \version 1.12.1 Function publicized in this release. + * + */ +H5_DLL ssize_t H5Pget_driver_config_str(hid_t fapl_id, char *config_buf, size_t buf_size); +/** + * \ingroup FAPL + * * \brief Retrieves the size of the external link open file cache * * \fapl_id{plist_id} @@ -4287,6 +4315,57 @@ H5_DLL herr_t H5Pset_driver(hid_t plist_id, hid_t driver_id, const void *driver_ /** * \ingroup FAPL * + * \brief Sets a file driver according to a given driver name + * + * \plist_id + * \param[in] driver_name The new driver name + * \param[in] driver_config Optional string containing driver properties + * + * \return \herr_t + * + * \details H5Pset_driver_by_name() sets the file driver, by the name + * driver_name, for a file access or data transfer property list, + * \p plist_id, and supplies an optional string containing the + * driver-specific properties, \p driver_config. The driver + * properties string will be copied into the property list. + * + * If the driver specified by \p driver_name is not currently + * registered, an attempt will be made to load the driver as a + * plugin. + * + * \version 1.12.1 Function publicized in this release. + * + */ +H5_DLL herr_t H5Pset_driver_by_name(hid_t plist_id, const char *driver_name, const char *driver_config); +/** + * \ingroup FAPL + * + * \brief Sets a file driver according to a given driver value (ID). + * + * \plist_id + * \param[in] driver_value The new driver value (ID) + * \param[in] driver_config Optional string containing driver properties + * + * \return \herr_t + * + * \details H5Pset_driver_by_value() sets the file driver, by the value + * driver_value, for a file access or data transfer property list, + * \p plist_id, and supplies an optional string containing the + * driver-specific properties, \p driver_config. The driver + * properties string will be copied into the property list. + * + * If the driver specified by \p driver_value is not currently + * registered, an attempt will be made to load the driver as a + * plugin. + * + * \version 1.12.1 Function publicized in this release. + * + */ +H5_DLL herr_t H5Pset_driver_by_value(hid_t plist_id, H5FD_class_value_t driver_value, + const char *driver_config); +/** + * \ingroup FAPL + * * \brief Sets the number of files that can be held open in an external * link open file cache * diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c index a61b003..2369be5 100644 --- a/src/H5VLcallback.c +++ b/src/H5VLcallback.c @@ -3527,6 +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; herr_t status; hid_t connector_id = H5I_INVALID_HID; hid_t fapl_id = H5I_INVALID_HID; @@ -3565,6 +3566,10 @@ H5VL__file_open_find_connector_cb(H5PL_type_t plugin_type, const void *plugin_in vol_cb_args.args.is_accessible.fapl_id = fapl_id; vol_cb_args.args.is_accessible.accessible = &is_accessible; + /* Store current error stack size */ + if ((num_errors = H5Eget_num(H5E_DEFAULT)) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, H5_ITER_ERROR, "can't get current error stack size") + /* Check if file is accessible with given VOL connector */ H5E_BEGIN_TRY { @@ -3572,11 +3577,23 @@ H5VL__file_open_find_connector_cb(H5PL_type_t plugin_type, const void *plugin_in } H5E_END_TRY; - /* If the file was accessible with the current VOL connector, return - * the FAPL with that VOL connector set on it. Errors are ignored here - * as some VOL connectors may not support H5Fis_accessible. - */ - if (status == SUCCEED && is_accessible) { + if (status < 0) { + ssize_t new_num_errors = 0; + + /* Pop any errors generated by the above call */ + if ((new_num_errors = H5Eget_num(H5E_DEFAULT)) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, H5_ITER_ERROR, "can't get current error stack size") + if (new_num_errors > num_errors) { + new_num_errors -= num_errors; + if (H5Epop(H5E_DEFAULT, (size_t)new_num_errors) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTRELEASE, H5_ITER_ERROR, "can't sanitize error stack") + } + } + else if (status == SUCCEED && is_accessible) { + /* If the file was accessible with the current VOL connector, return + * the FAPL with that VOL connector set on it. + */ + /* Modify 'connector_prop' to point to the VOL connector that * was actually used to open the file, rather than the original * VOL connector that was requested. @@ -3586,7 +3603,7 @@ H5VL__file_open_find_connector_cb(H5PL_type_t plugin_type, const void *plugin_in udata->fapl_id = fapl_id; ret_value = H5_ITER_STOP; - } /* end if */ + } done: if (ret_value != H5_ITER_STOP) { diff --git a/src/H5VLint.c b/src/H5VLint.c index b4432d0..936614f 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -69,11 +69,7 @@ typedef struct H5VL_wrap_ctx_t { */ typedef struct { /* IN */ - H5VL_get_connector_kind_t kind; /* Which kind of connector search to make */ - union { - const char * name; /* The name of the VOL connector to check */ - H5VL_class_value_t value; /* The value of the VOL connector to check */ - } u; + H5PL_vol_key_t key; /* OUT */ hid_t found_id; /* The connector ID, if we found a match */ @@ -341,15 +337,15 @@ H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data) FUNC_ENTER_STATIC_NOERR - if (H5VL_GET_CONNECTOR_BY_NAME == op_data->kind) { - if (0 == HDstrcmp(cls->name, op_data->u.name)) { + if (H5VL_GET_CONNECTOR_BY_NAME == op_data->key.kind) { + if (0 == HDstrcmp(cls->name, op_data->key.u.name)) { op_data->found_id = id; ret_value = H5_ITER_STOP; } /* end if */ } /* end if */ else { - HDassert(H5VL_GET_CONNECTOR_BY_VALUE == op_data->kind); - if (cls->value == op_data->u.value) { + HDassert(H5VL_GET_CONNECTOR_BY_VALUE == op_data->key.kind); + if (cls->value == op_data->key.u.value) { op_data->found_id = id; ret_value = H5_ITER_STOP; } /* end if */ @@ -398,7 +394,7 @@ H5VL__set_def_conn(void) } /* end if */ /* Check for environment variable set */ - env_var = HDgetenv("HDF5_VOL_CONNECTOR"); + env_var = HDgetenv(HDF5_VOL_CONNECTOR); /* Only parse the string if it's set */ if (env_var && *env_var) { @@ -1299,9 +1295,9 @@ H5VL__register_connector_by_class(const H5VL_class_t *cls, hbool_t app_ref, hid_ "callback is provided") /* Set up op data for iteration */ - op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; - op_data.u.name = cls->name; - op_data.found_id = H5I_INVALID_HID; + op_data.key.kind = H5VL_GET_CONNECTOR_BY_NAME; + op_data.key.u.name = cls->name; + op_data.found_id = H5I_INVALID_HID; /* Check if connector is already registered */ if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) @@ -1350,9 +1346,9 @@ H5VL__register_connector_by_name(const char *name, hbool_t app_ref, hid_t vipl_i FUNC_ENTER_PACKAGE /* Set up op data for iteration */ - op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; - op_data.u.name = name; - op_data.found_id = H5I_INVALID_HID; + op_data.key.kind = H5VL_GET_CONNECTOR_BY_NAME; + op_data.key.u.name = name; + op_data.found_id = H5I_INVALID_HID; /* Check if connector is already registered */ if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, app_ref) < 0) @@ -1410,12 +1406,12 @@ H5VL__register_connector_by_value(H5VL_class_value_t value, hbool_t app_ref, hid FUNC_ENTER_PACKAGE /* Set up op data for iteration */ - op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE; - op_data.u.value = value; - op_data.found_id = H5I_INVALID_HID; + op_data.key.kind = H5VL_GET_CONNECTOR_BY_VALUE; + op_data.key.u.value = value; + op_data.found_id = H5I_INVALID_HID; /* Check if connector is already registered */ - if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, app_ref) < 0) HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL ids") /* If connector alread registered, increment ref count on ID and return ID */ @@ -1449,8 +1445,9 @@ done: * * Purpose: Checks if a connector with a particular name is registered. * - * Return: Success: 0 - * Failure: -1 + * Return: >0 if a VOL connector with that name has been registered + * 0 if a VOL connector with that name has NOT been registered + * <0 on errors * * Programmer: Dana Robinson * June 17, 2017 @@ -1466,9 +1463,9 @@ H5VL__is_connector_registered_by_name(const char *name) FUNC_ENTER_PACKAGE /* Set up op data for iteration */ - op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; - op_data.u.name = name; - op_data.found_id = H5I_INVALID_HID; + op_data.key.kind = H5VL_GET_CONNECTOR_BY_NAME; + op_data.key.u.name = name; + op_data.found_id = H5I_INVALID_HID; /* Find connector with name */ if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) @@ -1488,8 +1485,9 @@ done: * Purpose: Checks if a connector with a particular value (ID) is * registered. * - * Return: Success: 0 - * Failure: -1 + * Return: >0 if a VOL connector with that value has been registered + * 0 if a VOL connector with that value hasn't been registered + * <0 on errors * *------------------------------------------------------------------------- */ @@ -1502,9 +1500,9 @@ H5VL__is_connector_registered_by_value(H5VL_class_value_t value) FUNC_ENTER_PACKAGE /* Set up op data for iteration */ - op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE; - op_data.u.value = value; - op_data.found_id = H5I_INVALID_HID; + op_data.key.kind = H5VL_GET_CONNECTOR_BY_VALUE; + op_data.key.u.value = value; + op_data.found_id = H5I_INVALID_HID; /* Find connector with value */ if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) @@ -1635,9 +1633,9 @@ H5VL__peek_connector_id_by_name(const char *name) FUNC_ENTER_PACKAGE /* Set up op data for iteration */ - op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; - op_data.u.name = name; - op_data.found_id = H5I_INVALID_HID; + op_data.key.kind = H5VL_GET_CONNECTOR_BY_NAME; + op_data.key.u.name = name; + op_data.found_id = H5I_INVALID_HID; /* Find connector with name */ if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) @@ -1671,9 +1669,9 @@ H5VL__peek_connector_id_by_value(H5VL_class_value_t value) FUNC_ENTER_PACKAGE /* Set up op data for iteration */ - op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE; - op_data.u.value = value; - op_data.found_id = H5I_INVALID_HID; + op_data.key.kind = H5VL_GET_CONNECTOR_BY_VALUE; + op_data.key.u.value = value; + op_data.found_id = H5I_INVALID_HID; /* Find connector with value */ if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) diff --git a/src/H5public.h b/src/H5public.h index c9430dc..3e59e24 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -168,6 +168,58 @@ (((H5_VERS_MAJOR == Maj) && (H5_VERS_MINOR == Min) && (H5_VERS_RELEASE <= Rel)) || \ ((H5_VERS_MAJOR == Maj) && (H5_VERS_MINOR < Min)) || (H5_VERS_MAJOR < Maj)) +/* Macros for various environment variables that HDF5 interprets */ +/** + * Used to specify the name of an HDF5 Virtual File Driver to use as + * the default file driver for file access. Setting this environment + * variable overrides the default file driver for File Access Property + * Lists. + */ +#define HDF5_DRIVER "HDF5_DRIVER" +/** + * Used to specify a configuration string for the HDF5 Virtual File + * Driver being used for file access. + */ +#define HDF5_DRIVER_CONFIG "HDF5_DRIVER_CONFIG" +/** + * Used to specify the name of an HDF5 Virtual Object Layer Connector + * to use as the default VOL connector for file access. Setting this + * environment variable overrides the default VOL connector for File + * Access Property Lists. + */ +#define HDF5_VOL_CONNECTOR "HDF5_VOL_CONNECTOR" +/** + * Used to specify a delimiter-separated (currently, ';' for Windows + * and ':' for other systems) list of paths that HDF5 should search + * when loading plugins. + */ +#define HDF5_PLUGIN_PATH "HDF5_PLUGIN_PATH" +/** + * Used to control the loading of HDF5 plugins at runtime. If this + * environment variable is set to the special string "::" (defined + * in H5PLpublic.h as H5PL_NO_PLUGIN), then dynamic loading of any + * HDF5 plugins will be disabled. No other values are valid for this + * environment variable. + */ +#define HDF5_PLUGIN_PRELOAD "HDF5_PLUGIN_PRELOAD" +/** + * Used to control whether HDF5 uses file locking when creating or + * opening a file. Valid values for this environment variable are + * as follows: + * + * "TRUE" or "1" - Request that file locks should be used + * "FALSE" or "0" - Request that file locks should NOT be used + * "BEST_EFFORT" - Request that file locks should be used and + * that any locking errors caused by file + * locking being disabled on the system + * should be ignored + */ +#define HDF5_USE_FILE_LOCKING "HDF5_USE_FILE_LOCKING" +/** + * Used to instruct HDF5 not to cleanup files created during testing. + */ +#define HDF5_NOCLEANUP "HDF5_NOCLEANUP" + /** * Status return values. Failed integer functions in HDF5 result almost * always in a negative value (unsigned failing functions sometimes return diff --git a/src/H5trace.c b/src/H5trace.c index 3a5d420..a735df3 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -1046,6 +1046,65 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) } /* end block */ break; + case 'V': /* H5FD_class_value_t */ + { + H5FD_class_value_t class_val = + (H5FD_class_value_t)HDva_arg(ap, H5FD_class_value_t); + + switch (class_val) { + case H5_VFD_INVALID: + H5RS_acat(rs, "H5_VFD_INVALID"); + break; + case H5_VFD_SEC2: + H5RS_acat(rs, "H5_VFD_SEC2"); + break; + case H5_VFD_CORE: + H5RS_acat(rs, "H5_VFD_CORE"); + break; + case H5_VFD_LOG: + H5RS_acat(rs, "H5_VFD_LOG"); + break; + case H5_VFD_FAMILY: + H5RS_acat(rs, "H5_VFD_FAMILY"); + break; + case H5_VFD_MULTI: + H5RS_acat(rs, "H5_VFD_MULTI"); + break; + case H5_VFD_STDIO: + H5RS_acat(rs, "H5_VFD_STDIO"); + break; +#ifdef H5_HAVE_PARALLEL + case H5_VFD_MPIO: + H5RS_acat(rs, "H5_VFD_MPIO"); + break; +#endif +#ifdef H5_HAVE_DIRECT + case H5_VFD_DIRECT: + H5RS_acat(rs, "H5_VFD_DIRECT"); + break; +#endif +#ifdef H5_HAVE_MIRROR_VFD + case H5_HAVE_MIRROR_VFD: + H5RS_acat(rs, "H5_HAVE_MIRROR_VFD"); + break; +#endif +#ifdef H5_HAVE_LIBHDFS + case H5_HAVE_LIBHDFS: + H5RS_acat(rs, "H5_HAVE_LIBHDFS"); + break; +#endif +#ifdef H5_HAVE_ROS3_VFD + case H5_HAVE_ROS3_VFD: + H5RS_acat(rs, "H5_HAVE_ROS3_VFD"); + break; +#endif + default: + H5RS_asprintf_cat(rs, "%ld", (long)class_val); + break; + } + } /* end block */ + break; + default: H5RS_asprintf_cat(rs, "BADTYPE(D%c)", type[1]); goto error; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 56427f5..1461101 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -78,7 +78,7 @@ if (HDF5_ENABLE_FORMATTERS) endif () ################################################################################# -# If filter and vol plugin tests can be tested +# If filter, vfd and vol plugin tests can be tested ################################################################################# if (BUILD_SHARED_LIBS) # make plugins dir @@ -162,6 +162,50 @@ if (BUILD_SHARED_LIBS) endforeach () ################################################################################# + # make vfd plugins dir + ################################################################################# + file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/null_vfd_plugin_dir") + + #----------------------------------------------------------------------------- + # Define VFD Plugin Test Sources + #----------------------------------------------------------------------------- + set (VFD_PLUGIN_LIBS + null_vfd_plugin + ) + + foreach (vfd_lib ${VFD_PLUGIN_LIBS}) + set (HDF5_VFD_PLUGIN_LIB_CORENAME "${vfd_lib}") + set (HDF5_VFD_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_VFD_PLUGIN_LIB_CORENAME}") + set (HDF5_VFD_PLUGIN_LIB_TARGET ${HDF5_VFD_PLUGIN_LIB_CORENAME}) + + add_library (${HDF5_VFD_PLUGIN_LIB_TARGET} SHARED ${HDF5_TEST_SOURCE_DIR}/${vfd_lib}.c) + target_include_directories (${HDF5_VFD_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") + TARGET_C_PROPERTIES (${HDF5_VFD_PLUGIN_LIB_TARGET} SHARED) + target_link_libraries (${HDF5_VFD_PLUGIN_LIB_TARGET} PUBLIC ${HDF5_TEST_LIBSH_TARGET}) + H5_SET_LIB_OPTIONS (${HDF5_VFD_PLUGIN_LIB_TARGET} ${HDF5_VFD_PLUGIN_LIB_NAME} SHARED "LIB") + set_target_properties (${HDF5_VFD_PLUGIN_LIB_TARGET} PROPERTIES FOLDER libraries/TEST_PLUGIN) + + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TEST_${HDF5_VFD_PLUGIN_LIB_TARGET}_FORMAT ${HDF5_VFD_PLUGIN_LIB_TARGET}) + endif () + + #----------------------------------------------------------------------------- + # Copy VFD plugin to a plugins folder + #----------------------------------------------------------------------------- + add_custom_command ( + TARGET ${HDF5_VFD_PLUGIN_LIB_TARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different + "$" + "${CMAKE_BINARY_DIR}/null_vfd_plugin_dir/$" + ) + endforeach () + + ################################################################################# # make vol plugins dir ################################################################################# file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/null_vol_plugin_dir") @@ -661,6 +705,19 @@ if (BUILD_SHARED_LIBS) clang_format (HDF5_TEST_filter_plugin_FORMAT filter_plugin) endif () + add_executable (vfd_plugin ${HDF5_TEST_SOURCE_DIR}/vfd_plugin.c) + target_include_directories (vfd_plugin PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") + TARGET_C_PROPERTIES (vfd_plugin SHARED) + target_link_libraries (vfd_plugin PRIVATE ${HDF5_TEST_LIBSH_TARGET}) + set_target_properties (vfd_plugin PROPERTIES FOLDER test) + + #----------------------------------------------------------------------------- + # Add Target to clang-format + #----------------------------------------------------------------------------- + if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_TEST_vfd_plugin_FORMAT vfd_plugin) + endif () + add_executable (vol_plugin ${HDF5_TEST_SOURCE_DIR}/vol_plugin.c) target_include_directories (vol_plugin PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (vol_plugin SHARED) diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index bb5356d..c537f37 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 892ccf3..723595b 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}") @@ -208,3 +227,22 @@ add_custom_target(HDF5_VFDTEST_LIB_files ALL COMMENT "Copying files needed by HD foreach (h5_vfd ${VFD_LIST}) ADD_VFD_TEST (${h5_vfd} 0) endforeach () + + ############################################################################## + ### V F D P L U G I N T E S T S + ############################################################################## + if (BUILD_SHARED_LIBS) + if (WIN32) + set (CMAKE_SEP "\;") + set (BIN_REL_PATH "../../") + else () + set (CMAKE_SEP ":") + set (BIN_REL_PATH "../") + endif () + + add_test (NAME H5PLUGIN-vfd_plugin COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) + set_tests_properties (H5PLUGIN-vfd_plugin PROPERTIES + ENVIRONMENT "HDF5_PLUGIN_PATH=${CMAKE_BINARY_DIR}/null_vfd_plugin_dir;srcdir=${HDF5_TEST_BINARY_DIR}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR} + ) + endif () diff --git a/test/Makefile.am b/test/Makefile.am index d465664..09277b0 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -94,7 +94,7 @@ check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version \ swmr_check_compat_vfd vds_env vds_swmr_gen vds_swmr_reader vds_swmr_writer \ mirror_vfd if HAVE_SHARED_CONDITIONAL - check_PROGRAMS+= filter_plugin vol_plugin + check_PROGRAMS+= filter_plugin vfd_plugin vol_plugin endif # These programs generate test files for the tests. They don't need to be @@ -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 @@ -129,6 +129,12 @@ if HAVE_SHARED_CONDITIONAL libfilter_plugin3_dsets_la_LIBADD=$(LIBHDF5) libfilter_plugin4_groups_la_LIBADD=$(LIBHDF5) + # VFD plugin test libraries + # + # null_vfd_plugin is used for testing basic VFD plugin functionality. + libnull_vfd_plugin_la_SOURCES=null_vfd_plugin.c + libnull_vfd_plugin_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere + # VOL plugin test libraries # # null_vol_connector is used for testing basic VOL plugin functionality. @@ -192,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/accum.c b/test/accum.c index c3346bc..08f86ca 100644 --- a/test/accum.c +++ b/test/accum.c @@ -2121,7 +2121,7 @@ test_swmr_write_big(hbool_t newest_format) /* Skip this test if SWMR I/O is not supported for the VFD specified * by the environment variable. */ - driver = HDgetenv("HDF5_DRIVER"); + driver = HDgetenv(HDF5_DRIVER); if (!H5FD__supports_swmr_test(driver)) { SKIPPED(); HDputs(" Test skipped due to VFD not supporting SWMR I/O."); diff --git a/test/accum_swmr_reader.c b/test/accum_swmr_reader.c index ce0e830..76f45bf 100644 --- a/test/accum_swmr_reader.c +++ b/test/accum_swmr_reader.c @@ -56,7 +56,7 @@ main(void) /* Skip this test if SWMR I/O is not supported for the VFD specified * by the environment variable. */ - driver = HDgetenv("HDF5_DRIVER"); + driver = HDgetenv(HDF5_DRIVER); if (!H5FD__supports_swmr_test(driver)) return EXIT_SUCCESS; diff --git a/test/app_ref.c b/test/app_ref.c index 09cfb72..2777dc0 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 aca0c77..2d34fa7 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 */ @@ -10127,7 +10126,7 @@ main(void) const char * envval = NULL; hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - envval = HDgetenv("HDF5_DRIVER"); + envval = HDgetenv(HDF5_DRIVER); if (envval == NULL) envval = "nomatch"; @@ -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 6989564..e802a9b 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 7858c65..432dab3 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 4967066..4100c1f 100644 --- a/test/cache_image.c +++ b/test/cache_image.c @@ -7839,7 +7839,7 @@ main(void) int express_test; /* Get the VFD to use */ - env_h5_drvr = HDgetenv("HDF5_DRIVER"); + env_h5_drvr = HDgetenv(HDF5_DRIVER); if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; @@ -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 06de174..b69a501 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 80934ad..8001f5d 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 d41507b..95d3105 100644 --- a/test/dangle.c +++ b/test/dangle.c @@ -660,7 +660,21 @@ error: 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 922f370..5e80ef7 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -15558,10 +15558,11 @@ 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 */ - envval = HDgetenv("HDF5_DRIVER"); + envval = HDgetenv(HDF5_DRIVER); if (envval == NULL) envval = "nomatch"; @@ -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 743103f..b721a59 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 8b3101c..1c1a6ec 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 f4dc340..9ac76dd 100644 --- a/test/error_test.c +++ b/test/error_test.c @@ -738,7 +738,7 @@ error: *------------------------------------------------------------------------- */ 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-000000.h5 b/test/family_v16-000000.h5 new file mode 100644 index 0000000..ac75ea9 Binary files /dev/null and b/test/family_v16-000000.h5 differ diff --git a/test/family_v16-000001.h5 b/test/family_v16-000001.h5 new file mode 100644 index 0000000..bf55b32 Binary files /dev/null and b/test/family_v16-000001.h5 differ diff --git a/test/family_v16-000002.h5 b/test/family_v16-000002.h5 new file mode 100644 index 0000000..9bd0891 Binary files /dev/null and b/test/family_v16-000002.h5 differ diff --git a/test/family_v16-000003.h5 b/test/family_v16-000003.h5 new file mode 100644 index 0000000..fedce2a Binary files /dev/null and b/test/family_v16-000003.h5 differ diff --git a/test/family_v16_00000.h5 b/test/family_v16_00000.h5 deleted file mode 100644 index ac75ea9..0000000 Binary files a/test/family_v16_00000.h5 and /dev/null differ diff --git a/test/family_v16_00001.h5 b/test/family_v16_00001.h5 deleted file mode 100644 index bf55b32..0000000 Binary files a/test/family_v16_00001.h5 and /dev/null differ diff --git a/test/family_v16_00002.h5 b/test/family_v16_00002.h5 deleted file mode 100644 index 9bd0891..0000000 Binary files a/test/family_v16_00002.h5 and /dev/null differ diff --git a/test/family_v16_00003.h5 b/test/family_v16_00003.h5 deleted file mode 100644 index fedce2a..0000000 Binary files a/test/family_v16_00003.h5 and /dev/null differ diff --git a/test/fheap.c b/test/fheap.c index 86a555d..3c3088d 100644 --- a/test/fheap.c +++ b/test/fheap.c @@ -16365,7 +16365,7 @@ main(void) hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ /* Don't run this test using certain file drivers */ - envval = HDgetenv("HDF5_DRIVER"); + envval = HDgetenv(HDF5_DRIVER); if (envval == NULL) envval = "nomatch"; diff --git a/test/file_image.c b/test/file_image.c index 0d031f5..e2b7810 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/filenotclosed.c b/test/filenotclosed.c index b5def9b..58edc06 100644 --- a/test/filenotclosed.c +++ b/test/filenotclosed.c @@ -68,7 +68,7 @@ main(void) hbool_t contig_addr_vfd; /* Contiguous address vfd */ /* Get the VFD to use */ - env_h5_drvr = HDgetenv("HDF5_DRIVER"); + env_h5_drvr = HDgetenv(HDF5_DRIVER); if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; diff --git a/test/fillval.c b/test/fillval.c index 8de6ef1..7faeb65 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/flush1.c b/test/flush1.c index 456f5f4..f5c4e2b 100644 --- a/test/flush1.c +++ b/test/flush1.c @@ -201,7 +201,7 @@ main(void) TEST_ERROR /* Check if the current VFD supports SWMR */ - driver = HDgetenv("HDF5_DRIVER"); + driver = HDgetenv(HDF5_DRIVER); vfd_supports_swmr = H5FD__supports_swmr_test(driver); /*************************************************/ diff --git a/test/flush2.c b/test/flush2.c index 3262b14..bf1187b 100644 --- a/test/flush2.c +++ b/test/flush2.c @@ -251,7 +251,7 @@ main(void) PUTS_ERROR("bad vfd-dependent fapl") /* Check if the current VFD supports SWMR */ - driver = HDgetenv("HDF5_DRIVER"); + driver = HDgetenv(HDF5_DRIVER); vfd_supports_swmr = H5FD__supports_swmr_test(driver); /* TEST 1 */ diff --git a/test/flushrefresh.c b/test/flushrefresh.c index 5efff2f..8d2c083 100644 --- a/test/flushrefresh.c +++ b/test/flushrefresh.c @@ -153,7 +153,7 @@ main(int argc, const char *argv[]) * anything. */ /* Determine driver being used */ - envval = HDgetenv("HDF5_DRIVER"); + envval = HDgetenv(HDF5_DRIVER); if (envval == NULL || H5FD__supports_swmr_test(envval)) { if (test_flush() != SUCCEED) diff --git a/test/freespace.c b/test/freespace.c index e888b2b..1107609 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 200c426..485e3c1 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 ba0662a..e69a682 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 @@ -591,12 +592,12 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, char *fu */ if (isppdriver) { #ifdef H5_HAVE_PARALLEL - if (getenv_all(MPI_COMM_WORLD, 0, "HDF5_NOCLEANUP")) + if (getenv_all(MPI_COMM_WORLD, 0, HDF5_NOCLEANUP)) SetTestNoCleanup(); #endif /* H5_HAVE_PARALLEL */ } else { - if (HDgetenv("HDF5_NOCLEANUP")) + if (HDgetenv(HDF5_NOCLEANUP)) SetTestNoCleanup(); } @@ -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; @@ -854,150 +847,6 @@ error: } /* 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 * * Purpose: Sets the library version bounds for a FAPL according to the @@ -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); @@ -1404,7 +1281,9 @@ h5_get_file_size(const char *filename, hid_t fapl) return (tot_size); } /* end if */ else { - HDassert(0 && "Unknown VFD!"); + /* Get the file's statistics */ + if (0 == HDstat(filename, &sb)) + return ((h5_stat_size_t)sb.st_size); } /* end else */ } /* end else */ @@ -1892,7 +1771,9 @@ dummy_vfd_write(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hi } /* Dummy VFD with the minimum parameters to make a VFD that can be registered */ +#define DUMMY_VFD_VALUE (H5FD_class_value_t)155 static const H5FD_class_t H5FD_dummy_g = { + DUMMY_VFD_VALUE, /* value */ "dummy", /* name */ 1, /* maxaddr */ H5F_CLOSE_WEAK, /* fc_degree */ @@ -2288,3 +2169,137 @@ error: } 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 2855fb5..914a534 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 2609510..283c3e3 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 f022783..e1a9dba 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,8 +22550,9 @@ 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"); + env_h5_drvr = HDgetenv(HDF5_DRIVER); if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; @@ -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 590be20..7170132 100644 --- a/test/links_env.c +++ b/test/links_env.c @@ -152,8 +152,20 @@ error: 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 59088dc..5f2abc0 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 @@ -9128,7 +9151,7 @@ main(void) hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ /* Get the VFD to use */ - env_h5_drvr = HDgetenv("HDF5_DRIVER"); + env_h5_drvr = HDgetenv(HDF5_DRIVER); if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; diff --git a/test/mtime.c b/test/mtime.c index 43dc502..10cafd1 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 13cc72a..37a63a4 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 new file mode 100644 index 0000000..8031484 --- /dev/null +++ b/test/null_vfd_plugin.c @@ -0,0 +1,131 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Purpose: A simple Virtual File Driver (VFD) with almost no functionality + * that is used for testing basic VFD plugin handling (registration, etc.). + */ + +/* Public HDF5 headers */ +#include "hdf5.h" + +/* For HDF5 plugin functionality */ +#include "H5PLextern.h" + +/* This driver's header */ +#include "null_vfd_plugin.h" + +/* 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 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 haddr_t H5FD_null_get_eof(const H5FD_t *_file, H5FD_mem_t type); + +static const H5FD_class_t H5FD_null_g = { + NULL_VFD_VALUE, /* value */ + NULL_VFD_NAME, /* name */ + 1, /* maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + NULL, /* terminate */ + NULL, /* sb_size */ + NULL, /* sb_encode */ + NULL, /* sb_decode */ + 0, /* fapl_size */ + NULL, /* fapl_get */ + NULL, /* fapl_copy */ + NULL, /* fapl_free */ + 0, /* dxpl_size */ + NULL, /* dxpl_copy */ + NULL, /* dxpl_free */ + H5FD_null_open, /* open */ + H5FD_null_close, /* close */ + NULL, /* cmp */ + NULL, /* query */ + NULL, /* get_type_map */ + NULL, /* alloc */ + NULL, /* free */ + H5FD_null_get_eoa, /* get_eoa */ + H5FD_null_set_eoa, /* set_eoa */ + H5FD_null_get_eof, /* get_eof */ + NULL, /* get_handle */ + H5FD_null_read, /* read */ + H5FD_null_write, /* write */ + NULL, /* flush */ + NULL, /* truncate */ + NULL, /* lock */ + NULL, /* unlock */ + NULL, /* del */ + NULL, /* ctl */ + H5FD_FLMAP_DICHOTOMY /* fl_map */ +}; + +static H5FD_t * +H5FD_null_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) +{ + return NULL; +} + +static herr_t +H5FD_null_close(H5FD_t *_file) +{ + return 0; +} + +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) +{ + 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) +{ + return 0; +} + +static haddr_t +H5FD_null_get_eoa(const H5FD_t *_file, H5FD_mem_t type) +{ + return HADDR_UNDEF; +} + +static herr_t +H5FD_null_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) +{ + return 0; +} + +static haddr_t +H5FD_null_get_eof(const H5FD_t *_file, H5FD_mem_t type) +{ + return HADDR_UNDEF; +} + +/* These two functions are necessary to load this plugin using + * the HDF5 library. + */ + +H5PL_type_t +H5PLget_plugin_type(void) +{ + return H5PL_TYPE_VFD; +} + +const void * +H5PLget_plugin_info(void) +{ + return &H5FD_null_g; +} diff --git a/test/null_vfd_plugin.h b/test/null_vfd_plugin.h new file mode 100644 index 0000000..7b7671f --- /dev/null +++ b/test/null_vfd_plugin.h @@ -0,0 +1,33 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The public header file for the null testing VFD plugin. + */ +#ifndef H5FDnull_H +#define H5FDnull_H + +#define H5FD_NULL (H5FD_null_init()) +#define NULL_VFD_NAME "null_vfd_plugin" +#define NULL_VFD_VALUE ((H5FD_class_value_t)200) + +#ifdef __cplusplus +extern "C" { +#endif + +H5_DLL hid_t H5FD_null_init(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/test/objcopy.c b/test/objcopy.c index e01083d..c8a5bac 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -17305,13 +17305,18 @@ error: 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 d28b11e..60d32b7 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 */ @@ -1813,13 +1820,12 @@ main(void) herr_t ret; /* Generic return value */ /* Get the VFD to use */ - env_h5_drvr = HDgetenv("HDF5_DRIVER"); + env_h5_drvr = HDgetenv(HDF5_DRIVER); if (env_h5_drvr == NULL) 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(); @@ -2107,11 +2113,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/page_buffer.c b/test/page_buffer.c index b80d330..cb59fda 100644 --- a/test/page_buffer.c +++ b/test/page_buffer.c @@ -2153,7 +2153,7 @@ main(void) h5_reset(); /* Get the VFD to use */ - env_h5_drvr = HDgetenv("HDF5_DRIVER"); + env_h5_drvr = HDgetenv(HDF5_DRIVER); if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; diff --git a/test/reserved.c b/test/reserved.c index 6e41a16..f864329 100644 --- a/test/reserved.c +++ b/test/reserved.c @@ -489,7 +489,7 @@ main(void) hid_t fapl; const char *envval = NULL; - envval = HDgetenv("HDF5_DRIVER"); + envval = HDgetenv(HDF5_DRIVER); if (envval == NULL) envval = "nomatch"; /* QAK: should be able to use the core driver? */ diff --git a/test/set_extent.c b/test/set_extent.c index 3078c2d..ab2a443 100644 --- a/test/set_extent.c +++ b/test/set_extent.c @@ -117,7 +117,7 @@ main(void) const char *env_h5_drvr; /* File Driver value from environment */ hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */ - env_h5_drvr = HDgetenv("HDF5_DRIVER"); + env_h5_drvr = HDgetenv(HDF5_DRIVER); if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; /* Current VFD that does not support contigous address space */ @@ -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 798619d..31ff497 100644 --- a/test/stab.c +++ b/test/stab.c @@ -1417,10 +1417,11 @@ 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"); + env_h5_drvr = HDgetenv(HDF5_DRIVER); if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; @@ -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/swmr.c b/test/swmr.c index 24a0b7c..e6fdb47 100644 --- a/test/swmr.c +++ b/test/swmr.c @@ -6270,13 +6270,13 @@ test_file_locking(hid_t in_fapl, hbool_t turn_locking_on, hbool_t env_var_overri /* If requested, set the environment variable */ if (env_var_override) { - if (HDsetenv("HDF5_USE_FILE_LOCKING", turn_locking_on ? "FALSE" : "TRUE", TRUE) < 0) + if (HDsetenv(HDF5_USE_FILE_LOCKING, turn_locking_on ? "FALSE" : "TRUE", TRUE) < 0) TEST_ERROR if (H5F__reparse_file_lock_variable_test() < 0) TEST_ERROR } else { - if (HDsetenv("HDF5_USE_FILE_LOCKING", "", TRUE) < 0) + if (HDsetenv(HDF5_USE_FILE_LOCKING, "", TRUE) < 0) TEST_ERROR if (H5F__reparse_file_lock_variable_test() < 0) TEST_ERROR @@ -7367,7 +7367,7 @@ main(void) /* Skip this test if SWMR I/O is not supported for the VFD specified * by the environment variable. */ - driver = HDgetenv("HDF5_DRIVER"); + driver = HDgetenv(HDF5_DRIVER); if (!H5FD__supports_swmr_test(driver)) { HDprintf("This VFD does not support SWMR I/O\n"); return EXIT_SUCCESS; @@ -7377,7 +7377,7 @@ main(void) * about file locking. File locking should be used unless explicitly * disabled. */ - lock_env_var = HDgetenv("HDF5_USE_FILE_LOCKING"); + lock_env_var = HDgetenv(HDF5_USE_FILE_LOCKING); if (lock_env_var && !HDstrcmp(lock_env_var, "FALSE")) use_file_locking = FALSE; else diff --git a/test/swmr_check_compat_vfd.c b/test/swmr_check_compat_vfd.c index 4133696..720c747 100644 --- a/test/swmr_check_compat_vfd.c +++ b/test/swmr_check_compat_vfd.c @@ -43,7 +43,7 @@ main(void) { char *driver = NULL; - driver = HDgetenv("HDF5_DRIVER"); + driver = HDgetenv(HDF5_DRIVER); if (H5FD__supports_swmr_test(driver)) return EXIT_SUCCESS; diff --git a/test/tarray.c b/test/tarray.c index af167a7..3b17239 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 756e139..b807bce 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -2274,9 +2274,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() */ /**************************************************************** @@ -2418,9 +2420,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() */ /**************************************************************** @@ -2448,6 +2452,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")); @@ -2611,9 +2619,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() */ /**************************************************************** @@ -2643,6 +2653,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")); @@ -2802,9 +2816,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() */ /**************************************************************** @@ -2833,6 +2849,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")); @@ -2945,9 +2965,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() */ /**************************************************************** @@ -3109,9 +3131,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() */ /**************************************************************** @@ -3896,9 +3920,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() */ /**************************************************************** @@ -4105,9 +4131,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() */ /**************************************************************** @@ -8705,9 +8733,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 */ @@ -9151,9 +9181,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 */ @@ -9521,9 +9553,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 */ @@ -9878,9 +9912,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/testhdf5.c b/test/testhdf5.c index 45c0f9f..dc5f0aa 100644 --- a/test/testhdf5.c +++ b/test/testhdf5.c @@ -81,7 +81,7 @@ main(int argc, char *argv[]) TestSummary(); /* Clean up test files, if allowed */ - if (GetTestCleanup() && !HDgetenv("HDF5_NOCLEANUP")) + if (GetTestCleanup() && !HDgetenv(HDF5_NOCLEANUP)) TestCleanup(); /* Release test infrastructure */ diff --git a/test/tfile.c b/test/tfile.c index 0014d08..47d1b67 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,15 +8017,16 @@ 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 */ MESSAGE(5, ("Testing Low-Level File I/O\n")); /* Get the VFD to use */ - env_h5_drvr = HDgetenv("HDF5_DRIVER"); + env_h5_drvr = HDgetenv(HDF5_DRIVER); if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; @@ -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 ebb6c6e..48c0a81 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 51216dc..97a6728 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 10ed039..1d87343 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 b267330..bb8d8c8 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 9b6c415..48d3670 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 1bfb663..5fec1da 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 b4ece0b..774378a 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/ttsafe.c b/test/ttsafe.c index 067a715..da78a7d 100644 --- a/test/ttsafe.c +++ b/test/ttsafe.c @@ -132,7 +132,7 @@ main(int argc, char *argv[]) TestSummary(); /* Clean up test files, if allowed */ - if (GetTestCleanup() && !HDgetenv("HDF5_NOCLEANUP")) + if (GetTestCleanup() && !HDgetenv(HDF5_NOCLEANUP)) TestCleanup(); /* Release test infrastructure */ diff --git a/test/vds.c b/test/vds.c index ac9bb5d..61b974b 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 58d90fc..5020db6 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 4e9b9ee..ea526b1 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*/ @@ -68,7 +68,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" @@ -3488,6 +3488,7 @@ H5FD__ctl_test_vfd_ctl(H5FD_t H5_ATTR_UNUSED *_file, uint64_t op_code, uint64_t /* Minimal VFD for ctl feature tests */ static const H5FD_class_t H5FD_ctl_test_vfd_g = { + (H5FD_class_value_t)201, /* value */ "ctl_test_vfd", /* name */ HADDR_MAX, /* maxaddr */ H5F_CLOSE_SEMI, /* fc_degree */ @@ -3925,7 +3926,18 @@ error: 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 %s is set -- \n", HDF5_DRIVER); + HDexit(EXIT_SUCCESS); + } h5_reset(); diff --git a/test/vfd_plugin.c b/test/vfd_plugin.c new file mode 100644 index 0000000..df211cc --- /dev/null +++ b/test/vfd_plugin.c @@ -0,0 +1,388 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Tests basic VFD plugin operations. Uses a basic testing VFD + * which is loaded as a dynamic plugin. + */ + +#include "h5test.h" + +#include "null_vfd_plugin.h" + +#define DEFAULT_DRIVER_NAME "sec2" + +/*------------------------------------------------------------------------- + * Function: test_set_by_name() + * + * Purpose: Tests if we can load and register a VFD plugin by name. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_set_by_name(void) +{ + htri_t is_registered = FAIL; + hid_t driver_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + + TESTING("VFD plugin registration by name"); + + /* The null VFD should not be registered at the start of the test */ + if ((is_registered = H5FDis_driver_registered_by_name(NULL_VFD_NAME)) < 0) + TEST_ERROR; + if (TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VFD is inappropriately registered"); + + /* Register the null VFD by name */ + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR; + if (H5Pset_driver_by_name(fapl_id, NULL_VFD_NAME, NULL) < 0) + TEST_ERROR; + + /* The null VFD should be registered now */ + if ((is_registered = H5FDis_driver_registered_by_name(NULL_VFD_NAME)) < 0) + TEST_ERROR; + if (FALSE == is_registered) + FAIL_PUTS_ERROR("NULL VFD was not registered"); + + /* Unregister the null VFD */ + if ((driver_id = H5Pget_driver(fapl_id)) < 0) + TEST_ERROR; + if (H5FDunregister(driver_id) < 0) + TEST_ERROR; + + /* Close FAPL, which holds last reference to null VFD */ + if (H5Pclose(fapl_id) < 0) + TEST_ERROR; + + /* The null VFD should not be registered now */ + if ((is_registered = H5FDis_driver_registered_by_name(NULL_VFD_NAME)) < 0) + TEST_ERROR; + if (TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VFD is inappropriately registered"); + + PASSED(); + + return SUCCEED; + +error: + H5E_BEGIN_TRY + { + H5Pclose(fapl_id); + } + H5E_END_TRY; + + return FAIL; +} + +/*------------------------------------------------------------------------- + * Function: test_set_by_value() + * + * Purpose: Tests if we can load and register a VFD plugin by value + * (ID). + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_set_by_value(void) +{ + htri_t is_registered = FAIL; + hid_t driver_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + + TESTING("VFD plugin registration by value (ID)"); + + /* The null VFD should not be registered at the start of the test */ + if ((is_registered = H5FDis_driver_registered_by_value(NULL_VFD_VALUE)) < 0) + TEST_ERROR; + if (TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VFD is inappropriately registered"); + + /* Register the null VFD by value */ + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR; + if (H5Pset_driver_by_value(fapl_id, NULL_VFD_VALUE, NULL) < 0) + TEST_ERROR; + + /* The null VFD should be registered now */ + if ((is_registered = H5FDis_driver_registered_by_value(NULL_VFD_VALUE)) < 0) + TEST_ERROR; + if (FALSE == is_registered) + FAIL_PUTS_ERROR("NULL VFD was not registered"); + + /* Unregister the null VFD */ + if ((driver_id = H5Pget_driver(fapl_id)) < 0) + TEST_ERROR; + if (H5FDunregister(driver_id) < 0) + TEST_ERROR; + + /* Close FAPL, which holds last reference to null VFD */ + if (H5Pclose(fapl_id) < 0) + TEST_ERROR; + + /* The null VFD should not be registered now */ + if ((is_registered = H5FDis_driver_registered_by_value(NULL_VFD_VALUE)) < 0) + TEST_ERROR; + if (TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VFD is inappropriately registered"); + + PASSED(); + + return SUCCEED; + +error: + H5E_BEGIN_TRY + { + H5Pclose(fapl_id); + } + H5E_END_TRY; + + return FAIL; +} + +/*------------------------------------------------------------------------- + * Function: test_set_multi() + * + * Purpose: Tests if we can register a VFD plugin multiple times. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +#define N_REGISTRATIONS 10 +static herr_t +test_set_multi(void) +{ + htri_t is_registered = FAIL; + hid_t driver_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + int i; + + TESTING("registering a VFD plugin multiple times"); + + /* The null VFD should not be registered at the start of the test */ + if ((is_registered = H5FDis_driver_registered_by_name(NULL_VFD_NAME)) < 0) + TEST_ERROR; + if (TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VFD is inappropriately registered"); + + /* Register the VFD multiple times */ + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR; + for (i = 0; i < N_REGISTRATIONS; i++) { + if (H5Pset_driver_by_name(fapl_id, NULL_VFD_NAME, NULL) < 0) + TEST_ERROR; + } + + /* The null VFD should be registered now */ + if ((is_registered = H5FDis_driver_registered_by_name(NULL_VFD_NAME)) < 0) + TEST_ERROR; + if (FALSE == is_registered) + FAIL_PUTS_ERROR("NULL VFD was not registered"); + + /* Unregister the null VFD */ + if ((driver_id = H5Pget_driver(fapl_id)) < 0) + TEST_ERROR; + for (i = 0; i < N_REGISTRATIONS; i++) { + if (H5FDunregister(driver_id) < 0) + TEST_ERROR; + } + + /* Close FAPL, which holds last reference to null VFD */ + if (H5Pclose(fapl_id) < 0) + TEST_ERROR; + + /* The null VFD should not be registered now */ + if ((is_registered = H5FDis_driver_registered_by_name(NULL_VFD_NAME)) < 0) + TEST_ERROR; + if (TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VFD is inappropriately registered"); + + /* Repeat testing with the _by_value routines */ + + /* The null VFD should not be registered at the start of the test */ + if ((is_registered = H5FDis_driver_registered_by_value(NULL_VFD_VALUE)) < 0) + TEST_ERROR; + if (TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VFD is inappropriately registered"); + + /* Register the VFD multiple times */ + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR; + for (i = 0; i < N_REGISTRATIONS; i++) { + if (H5Pset_driver_by_value(fapl_id, NULL_VFD_VALUE, NULL) < 0) + TEST_ERROR; + } + + /* The null VFD should be registered now */ + if ((is_registered = H5FDis_driver_registered_by_value(NULL_VFD_VALUE)) < 0) + TEST_ERROR; + if (FALSE == is_registered) + FAIL_PUTS_ERROR("NULL VFD was not registered"); + + /* Unregister the null VFD */ + if ((driver_id = H5Pget_driver(fapl_id)) < 0) + TEST_ERROR; + for (i = 0; i < N_REGISTRATIONS; i++) { + if (H5FDunregister(driver_id) < 0) + TEST_ERROR; + } + + /* Close FAPL, which holds last reference to null VFD */ + if (H5Pclose(fapl_id) < 0) + TEST_ERROR; + + /* The null VFD should not be registered now */ + if ((is_registered = H5FDis_driver_registered_by_value(NULL_VFD_VALUE)) < 0) + TEST_ERROR; + if (TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VFD is inappropriately registered"); + + PASSED(); + + return SUCCEED; + +error: + H5E_BEGIN_TRY + { + H5Pclose(fapl_id); + } + H5E_END_TRY; + + return FAIL; +} +#undef N_REGISTRATIONS + +/*------------------------------------------------------------------------- + * Function: test_get_config_str() + * + * Purpose: Tests if we can retrieve a configuration string set for a + * VFL driver. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +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]; + + TESTING("Retrieval of VFD configuration string"); + + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR; + + /* Try to retrieve length of default configuration string - should be 0 */ + HDmemset(config_str_buf, 0, 128); + + if ((config_str_len = H5Pget_driver_config_str(fapl_id, config_str_buf, 128)) < 0) + TEST_ERROR; + if (0 != config_str_len) + TEST_ERROR; + if (HDstrlen(config_str_buf) > 0) + TEST_ERROR; + + /* Set a new configuration string on the FAPL and retrieve it */ + if (H5Pset_driver_by_name(fapl_id, DEFAULT_DRIVER_NAME, config_str) < 0) + TEST_ERROR; + if ((config_str_len = H5Pget_driver_config_str(fapl_id, 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; + + 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; + +error: + H5E_BEGIN_TRY + { + H5Pclose(fapl_id); + } + H5E_END_TRY; + + return FAIL; +} + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Tests VFD plugin operations + * + * Return: EXIT_SUCCESS/EXIT_FAILURE + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + int nerrors = 0; + + h5_reset(); + + HDputs("Testing VFD plugin functionality."); + + nerrors += (test_set_by_name() < 0) ? 1 : 0; + nerrors += (test_set_by_value() < 0) ? 1 : 0; + nerrors += (test_set_multi() < 0) ? 1 : 0; + nerrors += (test_get_config_str() < 0) ? 1 : 0; + + if (nerrors) { + HDprintf("***** %d VFD plugin TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); + HDexit(EXIT_FAILURE); + } + + HDputs("All VFD plugin tests passed."); + + HDexit(EXIT_SUCCESS); +} diff --git a/test/vol.c b/test/vol.c index c7586d5..76be111 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 @@ error: *------------------------------------------------------------------------- */ 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 @@ error: *------------------------------------------------------------------------- */ 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 @@ error: *------------------------------------------------------------------------- */ 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) @@ -1975,11 +1984,11 @@ test_async_vol_props(void) FAIL_STACK_ERROR; /* Override possible environment variable & re-initialize default VOL connector */ - conn_env_str = HDgetenv("HDF5_VOL_CONNECTOR"); + conn_env_str = HDgetenv(HDF5_VOL_CONNECTOR); if (conn_env_str) { if (NULL == (conn_env_str = HDstrdup(conn_env_str))) TEST_ERROR - if (HDunsetenv("HDF5_VOL_CONNECTOR") < 0) + if (HDunsetenv(HDF5_VOL_CONNECTOR) < 0) TEST_ERROR if (H5VL__reparse_def_vol_conn_variable_test() < 0) TEST_ERROR @@ -2004,7 +2013,7 @@ test_async_vol_props(void) FAIL_STACK_ERROR; /* Set environment variable to use 'fake async' connector & re-init default connector */ - if (HDsetenv("HDF5_VOL_CONNECTOR", "fake_async", TRUE) < 0) + if (HDsetenv(HDF5_VOL_CONNECTOR, "fake_async", TRUE) < 0) TEST_ERROR if (H5VL__reparse_def_vol_conn_variable_test() < 0) TEST_ERROR @@ -2022,7 +2031,7 @@ test_async_vol_props(void) TEST_ERROR /* Reset environment variable & re-init default connector */ - if (HDunsetenv("HDF5_VOL_CONNECTOR") < 0) + if (HDunsetenv(HDF5_VOL_CONNECTOR) < 0) TEST_ERROR if (H5VL__reparse_def_vol_conn_variable_test() < 0) TEST_ERROR @@ -2072,7 +2081,7 @@ test_async_vol_props(void) /* Restore environment variable, if there was one */ if (conn_env_str) { - if (HDsetenv("HDF5_VOL_CONNECTOR", conn_env_str, TRUE) < 0) + if (HDsetenv(HDF5_VOL_CONNECTOR, conn_env_str, TRUE) < 0) TEST_ERROR HDfree(conn_env_str); @@ -2112,7 +2121,7 @@ main(void) int nerrors = 0; /* Get the VFD to use */ - env_h5_drvr = HDgetenv("HDF5_DRIVER"); + env_h5_drvr = HDgetenv(HDF5_DRIVER); if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; @@ -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/test/vol_plugin.c b/test/vol_plugin.c index 7656870..c7baf5a 100644 --- a/test/vol_plugin.c +++ b/test/vol_plugin.c @@ -150,8 +150,8 @@ error: static herr_t test_multiple_registration(void) { - htri_t is_registered = FAIL; - hid_t vol_ids[N_REGISTRATIONS]; + htri_t is_registered = FAIL; + hid_t vol_ids[N_REGISTRATIONS] = {0}; int i; TESTING("registering a VOL connector multiple times"); diff --git a/testpar/CMakeVFDTests.cmake b/testpar/CMakeVFDTests.cmake index f50ca16..785c08d 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 2a80f4a..cc569f6 100644 --- a/testpar/t_pflush1.c +++ b/testpar/t_pflush1.c @@ -133,7 +133,7 @@ main(int argc, char *argv[]) TESTING("H5Fflush (part1)"); /* Don't run using the split VFD */ - envval = HDgetenv("HDF5_DRIVER"); + envval = HDgetenv(HDF5_DRIVER); if (envval == NULL) envval = "nomatch"; @@ -207,5 +207,7 @@ error: 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 c96233a..e782f8a 100644 --- a/testpar/t_pflush2.c +++ b/testpar/t_pflush2.c @@ -157,7 +157,7 @@ main(int argc, char *argv[]) TESTING("H5Fflush (part2 with flush)"); /* Don't run using the split VFD */ - envval = HDgetenv("HDF5_DRIVER"); + envval = HDgetenv(HDF5_DRIVER); if (envval == NULL) envval = "nomatch"; @@ -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/lib/h5diff.c b/tools/lib/h5diff.c index 0ad319e..74db58f 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -648,14 +648,16 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char *------------------------------------------------------------------------- */ /* open file 1 */ - if (opts->custom_vol[0]) { - if ((fapl1_id = h5tools_get_fapl(H5P_DEFAULT, &(opts->vol_info[0]), NULL)) < 0) { + if (opts->custom_vol[0] || opts->custom_vfd[0]) { + if ((fapl1_id = h5tools_get_fapl(H5P_DEFAULT, opts->custom_vol[0] ? &(opts->vol_info[0]) : NULL, + opts->custom_vfd[0] ? &(opts->vfd_info[0]) : NULL)) < 0) { parallel_print("h5diff: unable to create fapl for input file\n"); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "unable to create input fapl\n"); } } - if ((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, fapl1_id, FALSE, NULL, (size_t)0)) < 0) { + if ((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, fapl1_id, (fapl1_id != H5P_DEFAULT), NULL, + (size_t)0)) < 0) { parallel_print("h5diff: <%s>: unable to open file\n", fname1); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "<%s>: unable to open file\n", fname1); } @@ -663,14 +665,16 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char /* open file 2 */ - if (opts->custom_vol[1]) { - if ((fapl2_id = h5tools_get_fapl(H5P_DEFAULT, &(opts->vol_info[1]), NULL)) < 0) { + if (opts->custom_vol[1] || opts->custom_vfd[1]) { + if ((fapl2_id = h5tools_get_fapl(H5P_DEFAULT, opts->custom_vol[1] ? &(opts->vol_info[1]) : NULL, + opts->custom_vfd[1] ? &(opts->vfd_info[1]) : NULL)) < 0) { parallel_print("h5diff: unable to create fapl for output file\n"); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "unable to create output fapl\n"); } } - if ((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, fapl2_id, FALSE, NULL, (size_t)0)) < 0) { + if ((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, fapl2_id, (fapl2_id != H5P_DEFAULT), NULL, + (size_t)0)) < 0) { parallel_print("h5diff: <%s>: unable to open file\n", fname2); H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "<%s>: unable to open file\n", fname2); } diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h index 7b41538..8d7ac13 100644 --- a/tools/lib/h5diff.h +++ b/tools/lib/h5diff.h @@ -89,7 +89,9 @@ typedef struct { char * obj_name[2]; /* name for object */ struct subset_t * sset[2]; /* subsetting parameters */ h5tools_vol_info_t vol_info[2]; /* VOL information for input file, output file */ + h5tools_vfd_info_t vfd_info[2]; /* VFD information for input file, output file */ hbool_t custom_vol[2]; /* Using a custom input, output VOL? */ + hbool_t custom_vfd[2]; /* Using a custom input, output VFD? */ } diff_opt_t; /*------------------------------------------------------------------------- diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index eee9c53..4de2c5c 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -459,8 +459,8 @@ h5tools_set_error_file(const char *fname, int is_bin) /*------------------------------------------------------------------------- * Function: h5tools_set_fapl_vfd * - * Purpose: Given a VFL driver name, sets the appropriate driver on the - * specified FAPL. + * Purpose: Given a VFL driver name or ID, sets the appropriate driver on + * the specified FAPL. * * Return: positive - succeeded * negative - failed @@ -471,107 +471,139 @@ h5tools_set_fapl_vfd(hid_t fapl_id, h5tools_vfd_info_t *vfd_info) { herr_t ret_value = SUCCEED; - /* Determine which driver the user wants to open the file with */ - if (!HDstrcmp(vfd_info->name, drivernames[SEC2_VFD_IDX])) { - /* SEC2 Driver */ - if (H5Pset_fapl_sec2(fapl_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_sec2 failed"); - } - else if (!HDstrcmp(vfd_info->name, drivernames[DIRECT_VFD_IDX])) { + switch (vfd_info->type) { + case VFD_BY_NAME: + /* Determine which driver the user wants to open the file with */ + if (!HDstrcmp(vfd_info->u.name, drivernames[SEC2_VFD_IDX])) { + /* SEC2 Driver */ + if (H5Pset_fapl_sec2(fapl_id) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_sec2 failed"); + } + else if (!HDstrcmp(vfd_info->u.name, drivernames[DIRECT_VFD_IDX])) { #ifdef H5_HAVE_DIRECT - /* Direct Driver */ - if (H5Pset_fapl_direct(fapl_id, 1024, 4096, 8 * 4096) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_direct failed"); + /* Direct Driver */ + if (H5Pset_fapl_direct(fapl_id, 1024, 4096, 8 * 4096) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_direct failed"); #else - H5TOOLS_GOTO_ERROR(FAIL, "Direct VFD is not enabled"); + H5TOOLS_GOTO_ERROR(FAIL, "Direct VFD is not enabled"); #endif - } - else if (!HDstrcmp(vfd_info->name, drivernames[LOG_VFD_IDX])) { - unsigned long long log_flags = H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC; + } + else if (!HDstrcmp(vfd_info->u.name, drivernames[LOG_VFD_IDX])) { + unsigned long long log_flags = H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC; - /* Log Driver */ - if (H5Pset_fapl_log(fapl_id, NULL, log_flags, (size_t)0) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_log failed"); - } - else if (!HDstrcmp(vfd_info->name, drivernames[WINDOWS_VFD_IDX])) { + /* Log Driver */ + if (H5Pset_fapl_log(fapl_id, NULL, log_flags, (size_t)0) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_log failed"); + } + else if (!HDstrcmp(vfd_info->u.name, drivernames[WINDOWS_VFD_IDX])) { #ifdef H5_HAVE_WINDOWS - /* There is no Windows VFD - use SEC2 */ - if (H5Pset_fapl_sec2(fapl_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_sec2 failed"); + /* There is no Windows VFD - use SEC2 */ + if (H5Pset_fapl_sec2(fapl_id) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_sec2 failed"); #else - H5TOOLS_GOTO_ERROR(FAIL, "Windows VFD is not enabled"); + H5TOOLS_GOTO_ERROR(FAIL, "Windows VFD is not enabled"); #endif - } - else if (!HDstrcmp(vfd_info->name, drivernames[STDIO_VFD_IDX])) { - /* Stdio Driver */ - if (H5Pset_fapl_stdio(fapl_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_stdio failed"); - } - else if (!HDstrcmp(vfd_info->name, drivernames[CORE_VFD_IDX])) { - /* Core Driver */ - if (H5Pset_fapl_core(fapl_id, (size_t)H5_MB, TRUE) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_core failed"); - } - else if (!HDstrcmp(vfd_info->name, drivernames[FAMILY_VFD_IDX])) { - /* FAMILY Driver */ - /* Set member size to be 0 to indicate the current first member size - * is the member size. - */ - if (H5Pset_fapl_family(fapl_id, (hsize_t)0, H5P_DEFAULT) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_family failed"); - } - else if (!HDstrcmp(vfd_info->name, drivernames[SPLIT_VFD_IDX])) { - /* SPLIT Driver */ - if (H5Pset_fapl_split(fapl_id, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_split failed"); - } - else if (!HDstrcmp(vfd_info->name, drivernames[MULTI_VFD_IDX])) { - /* MULTI Driver */ - if (H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_multi failed"); - } - else if (!HDstrcmp(vfd_info->name, drivernames[MPIO_VFD_IDX])) { + } + else if (!HDstrcmp(vfd_info->u.name, drivernames[STDIO_VFD_IDX])) { + /* Stdio Driver */ + if (H5Pset_fapl_stdio(fapl_id) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_stdio failed"); + } + else if (!HDstrcmp(vfd_info->u.name, drivernames[CORE_VFD_IDX])) { + /* Core Driver */ + if (H5Pset_fapl_core(fapl_id, (size_t)H5_MB, TRUE) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_core failed"); + } + else if (!HDstrcmp(vfd_info->u.name, drivernames[FAMILY_VFD_IDX])) { + /* FAMILY Driver */ + /* Set member size to be 0 to indicate the current first member size + * is the member size. + */ + if (H5Pset_fapl_family(fapl_id, (hsize_t)0, H5P_DEFAULT) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_family failed"); + } + else if (!HDstrcmp(vfd_info->u.name, drivernames[SPLIT_VFD_IDX])) { + /* SPLIT Driver */ + if (H5Pset_fapl_split(fapl_id, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_split failed"); + } + else if (!HDstrcmp(vfd_info->u.name, drivernames[MULTI_VFD_IDX])) { + /* MULTI Driver */ + if (H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_multi failed"); + } + else if (!HDstrcmp(vfd_info->u.name, drivernames[MPIO_VFD_IDX])) { #ifdef H5_HAVE_PARALLEL - int mpi_initialized, mpi_finalized; + int mpi_initialized, mpi_finalized; - /* MPI-I/O Driver */ + /* MPI-I/O Driver */ - /* check if MPI is available. */ - MPI_Initialized(&mpi_initialized); - MPI_Finalized(&mpi_finalized); + /* check if MPI is available. */ + MPI_Initialized(&mpi_initialized); + MPI_Finalized(&mpi_finalized); - if (mpi_initialized && !mpi_finalized) { - if (H5Pset_fapl_mpio(fapl_id, MPI_COMM_WORLD, MPI_INFO_NULL) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_mpio failed"); - } + if (mpi_initialized && !mpi_finalized) { + if (H5Pset_fapl_mpio(fapl_id, MPI_COMM_WORLD, MPI_INFO_NULL) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_mpio failed"); + } #else - H5TOOLS_GOTO_ERROR(FAIL, "MPI-I/O VFD is not enabled"); + H5TOOLS_GOTO_ERROR(FAIL, "MPI-I/O VFD is not enabled"); #endif /* H5_HAVE_PARALLEL */ - } - else if (!HDstrcmp(vfd_info->name, drivernames[ROS3_VFD_IDX])) { + } + else if (!HDstrcmp(vfd_info->u.name, drivernames[ROS3_VFD_IDX])) { #ifdef H5_HAVE_ROS3_VFD - if (!vfd_info->info) - H5TOOLS_GOTO_ERROR(FAIL, "Read-only S3 VFD info is invalid"); - if (H5Pset_fapl_ros3(fapl_id, (H5FD_ros3_fapl_t *)vfd_info->info) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_ros3() failed"); + if (!vfd_info->info) + H5TOOLS_GOTO_ERROR(FAIL, "Read-only S3 VFD info is invalid"); + if (H5Pset_fapl_ros3(fapl_id, (H5FD_ros3_fapl_t *)vfd_info->info) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_ros3() failed"); #else - H5TOOLS_GOTO_ERROR(FAIL, "Read-only S3 VFD is not enabled"); + H5TOOLS_GOTO_ERROR(FAIL, "Read-only S3 VFD is not enabled"); #endif - } - else if (!HDstrcmp(vfd_info->name, drivernames[HDFS_VFD_IDX])) { + } + else if (!HDstrcmp(vfd_info->u.name, drivernames[HDFS_VFD_IDX])) { #ifdef H5_HAVE_LIBHDFS - if (!vfd_info->info) - H5TOOLS_GOTO_ERROR(FAIL, "HDFS VFD info is invalid"); - if (H5Pset_fapl_hdfs(fapl_id, (H5FD_hdfs_fapl_t *)vfd_info->info) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_hdfs() failed"); + if (!vfd_info->info) + H5TOOLS_GOTO_ERROR(FAIL, "HDFS VFD info is invalid"); + if (H5Pset_fapl_hdfs(fapl_id, (H5FD_hdfs_fapl_t *)vfd_info->info) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_hdfs() failed"); #else - H5TOOLS_GOTO_ERROR(FAIL, "The HDFS VFD is not enabled"); + H5TOOLS_GOTO_ERROR(FAIL, "The HDFS VFD is not enabled"); #endif + } + else { + /* + * Try to load VFD plugin. + * + * Currently, driver configuration strings are unsupported. + */ + if (H5Pset_driver_by_name(fapl_id, vfd_info->u.name, (const char *)vfd_info->info) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "can't load VFD plugin by driver name '%s'", vfd_info->u.name); + } + + break; + + case VFD_BY_VALUE: + /* + * Try to load VFD plugin. + * + * Currently, driver configuration strings are unsupported. + */ + if (H5Pset_driver_by_value(fapl_id, vfd_info->u.value, (const char *)vfd_info->info) < 0) + H5TOOLS_GOTO_ERROR(FAIL, "can't load VFD plugin by driver value '%ld'", + (long int)vfd_info->u.value); + break; + + default: + H5TOOLS_GOTO_ERROR(FAIL, "invalid VFD retrieval type"); } - else - H5TOOLS_GOTO_ERROR(FAIL, "invalid VFD name"); done: + if (ret_value < 0) { + /* Clear error message unless asked for */ + if (enable_error_stack <= 1) + H5Epop(H5tools_ERR_STACK_g, 1); + } + return ret_value; } @@ -671,6 +703,10 @@ done: if (ret_value < 0) { if (connector_id >= 0 && H5Idec_ref(connector_id) < 0) H5TOOLS_ERROR(FAIL, "failed to decrement refcount on VOL connector ID"); + + /* Clear error message unless asked for */ + if (enable_error_stack <= 1) + H5Epop(H5tools_ERR_STACK_g, 1); } return ret_value; @@ -719,9 +755,15 @@ h5tools_get_fapl(hid_t prev_fapl_id, h5tools_vol_info_t *vol_info, h5tools_vfd_i ret_value = new_fapl_id; done: - if ((new_fapl_id >= 0) && (ret_value < 0)) { - H5Pclose(new_fapl_id); - new_fapl_id = H5I_INVALID_HID; + if (ret_value < 0) { + if (new_fapl_id >= 0) { + H5Pclose(new_fapl_id); + new_fapl_id = H5I_INVALID_HID; + } + + /* Clear error message unless asked for */ + if (enable_error_stack <= 1) + H5Epop(H5tools_ERR_STACK_g, 1); } return ret_value; @@ -937,8 +979,9 @@ h5tools_fopen(const char *fname, unsigned flags, hid_t fapl_id, hbool_t use_spec if (drivernum == LOG_VFD_IDX) continue; - vfd_info.info = NULL; - vfd_info.name = drivernames[drivernum]; + vfd_info.type = VFD_BY_NAME; + vfd_info.info = NULL; + vfd_info.u.name = drivernames[drivernum]; /* Get a fapl reflecting the selected VOL connector and VFD */ if ((tmp_fapl_id = h5tools_get_fapl(fapl_id, &vol_info, &vfd_info)) < 0) @@ -989,6 +1032,10 @@ done: if (tmp_fapl_id >= 0) H5Pclose(tmp_fapl_id); + /* Clear error message unless asked for */ + if (ret_value < 0 && enable_error_stack <= 1) + H5Epop(H5tools_ERR_STACK_g, 1); + return ret_value; } diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 9d065f3..dde4026 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -553,6 +553,7 @@ typedef struct h5tools_context_t { */ typedef enum { VOL_BY_NAME, VOL_BY_VALUE } h5tools_vol_info_type_t; +typedef enum { VFD_BY_NAME, VFD_BY_VALUE } h5tools_vfd_info_type_t; typedef struct h5tools_vol_info_t { h5tools_vol_info_type_t type; @@ -568,12 +569,16 @@ typedef struct h5tools_vol_info_t { } h5tools_vol_info_t; typedef struct h5tools_vfd_info_t { + h5tools_vfd_info_type_t type; /* Pointer to information to be passed to the driver for its setup */ const void *info; - /* Name of the VFD */ - const char *name; + /* Field specifying either the driver's name or value (ID) */ + union { + const char * name; + H5FD_class_value_t value; + } u; } h5tools_vfd_info_t; /* This enum should match the entries in the above 'volnames' diff --git a/tools/libtest/h5tools_test_utils.c b/tools/libtest/h5tools_test_utils.c index 37d38fd..1a15a47 100644 --- a/tools/libtest/h5tools_test_utils.c +++ b/tools/libtest/h5tools_test_utils.c @@ -1201,9 +1201,10 @@ test_set_configured_fapl(void) #endif /* UTIL_TEST_DEBUG */ /* test */ - vfd_info.info = C.conf_fa; - vfd_info.name = C.vfdname; - result = h5tools_get_fapl(H5P_DEFAULT, NULL, &vfd_info); + vfd_info.type = VFD_BY_NAME; + vfd_info.info = C.conf_fa; + vfd_info.u.name = C.vfdname; + result = h5tools_get_fapl(H5P_DEFAULT, NULL, &vfd_info); if (C.expected == 0) JSVERIFY(result, H5I_INVALID_HID, C.message) else diff --git a/tools/src/h5diff/h5diff_common.c b/tools/src/h5diff/h5diff_common.c index b669087..3d89936 100644 --- a/tools/src/h5diff/h5diff_common.c +++ b/tools/src/h5diff/h5diff_common.c @@ -48,6 +48,12 @@ static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'}, {"vol-value-2", require_arg, '4'}, {"vol-name-2", require_arg, '5'}, {"vol-info-2", require_arg, '6'}, + {"vfd-value-1", require_arg, '7'}, + {"vfd-name-1", require_arg, '8'}, + {"vfd-info-1", require_arg, '9'}, + {"vfd-value-2", require_arg, '0'}, + {"vfd-name-2", require_arg, 'Y'}, + {"vfd-info-2", require_arg, 'Z'}, {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- @@ -432,6 +438,38 @@ parse_command_line(int argc, const char *argv[], const char **fname1, const char case '6': opts->vol_info[1].info_string = H5_optarg; break; + + case '7': + opts->vfd_info[0].type = VFD_BY_VALUE; + opts->vfd_info[0].u.value = (H5FD_class_value_t)HDatoi(H5_optarg); + opts->custom_vfd[0] = TRUE; + break; + + case '8': + opts->vfd_info[0].type = VFD_BY_NAME; + opts->vfd_info[0].u.name = H5_optarg; + opts->custom_vol[0] = TRUE; + break; + + case '9': + opts->vfd_info[0].info = (const void *)H5_optarg; + break; + + case '0': + opts->vfd_info[1].type = VFD_BY_VALUE; + opts->vfd_info[1].u.value = (H5FD_class_value_t)HDatoi(H5_optarg); + opts->custom_vfd[1] = TRUE; + break; + + case 'Y': + opts->vfd_info[1].type = VFD_BY_NAME; + opts->vfd_info[1].u.name = H5_optarg; + opts->custom_vfd[1] = TRUE; + break; + + case 'Z': + opts->vfd_info[1].info = (const void *)H5_optarg; + break; } } @@ -657,6 +695,24 @@ usage(void) PRINTVALSTREAM(rawoutstream, " --vol-info-2 VOL-specific info to pass to the VOL connector used for\n"); PRINTVALSTREAM(rawoutstream, " opening the second HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --vfd-value-1 Value (ID) of the VFL driver to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " first HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --vfd-name-1 Name of the VFL driver to use for opening the first\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --vfd-info-1 VFD-specific info to pass to the VFL driver used for\n"); + PRINTVALSTREAM(rawoutstream, " opening the first HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --vfd-value-2 Value (ID) of the VFL driver to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " second HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --vfd-name-2 Name of the VFL driver to use for opening the second\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --vfd-info-2 VFD-specific info to pass to the VFL driver used for\n"); + PRINTVALSTREAM(rawoutstream, " opening the second HDF5 file specified\n"); PRINTVALSTREAM(rawoutstream, " --follow-symlinks\n"); PRINTVALSTREAM(rawoutstream, " Follow symbolic links (soft links and external links and compare the)\n"); diff --git a/tools/src/h5dump/h5dump.c b/tools/src/h5dump/h5dump.c index 36114ba..e6d1de3 100644 --- a/tools/src/h5dump/h5dump.c +++ b/tools/src/h5dump/h5dump.c @@ -18,14 +18,15 @@ /* Name of tool */ #define PROGRAMNAME "h5dump" -static const char *driver_name_g = NULL; /* The driver to open the file with. */ const char * outfname_g = NULL; static hbool_t doxml_g = FALSE; static hbool_t useschema_g = TRUE; static const char *xml_dtd_uri_g = NULL; static hbool_t use_custom_vol_g = FALSE; +static hbool_t use_custom_vfd_g = FALSE; static h5tools_vol_info_t vol_info_g; +static h5tools_vfd_info_t vfd_info_g; #ifdef H5_HAVE_ROS3_VFD /* Default "anonymous" S3 configuration */ @@ -127,6 +128,9 @@ static struct h5_long_options l_opts[] = {{"attribute", require_arg, 'a'}, {"vol-value", require_arg, '1'}, {"vol-name", require_arg, '2'}, {"vol-info", require_arg, '3'}, + {"vfd-value", require_arg, '4'}, + {"vfd-name", require_arg, '5'}, + {"vfd-info", require_arg, '6'}, {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- @@ -196,6 +200,14 @@ usage(const char *prog) PRINTVALSTREAM(rawoutstream, " --vol-info VOL-specific info to pass to the VOL connector used for\n"); PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --vfd-value Value (ID) of the VFL driver to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --vfd-name Name of the VFL driver to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --vfd-info VFD-specific info to pass to the VFL driver used for\n"); + PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n"); PRINTVALSTREAM(rawoutstream, "--------------- Object Options ---------------\n"); PRINTVALSTREAM(rawoutstream, " -a P, --attribute=P Print the specified attribute\n"); PRINTVALSTREAM(rawoutstream, @@ -943,7 +955,10 @@ parse_start: last_was_dset = TRUE; break; case 'f': - driver_name_g = H5_optarg; + vfd_info_g.type = VFD_BY_NAME; + vfd_info_g.u.name = H5_optarg; + vfd_info_g.info = NULL; + use_custom_vfd_g = TRUE; break; case 'g': dump_opts.display_all = 0; @@ -1264,6 +1279,22 @@ end_collect: vol_info_g.info_string = H5_optarg; break; + case '4': + vfd_info_g.type = VFD_BY_VALUE; + vfd_info_g.u.value = (H5FD_class_value_t)HDatoi(H5_optarg); + use_custom_vfd_g = TRUE; + break; + + case '5': + vfd_info_g.type = VFD_BY_NAME; + vfd_info_g.u.name = H5_optarg; + use_custom_vfd_g = TRUE; + break; + + case '6': + vfd_info_g.info = (const void *)H5_optarg; + break; + case '?': default: usage(h5tools_getprogname()); @@ -1378,40 +1409,9 @@ main(int argc, const char *argv[]) /* Initialize indexing options */ h5trav_set_index(sort_by, sort_order); - if (driver_name_g != NULL) { - h5tools_vfd_info_t vfd_info; - - vfd_info.info = NULL; - vfd_info.name = driver_name_g; - - if (!HDstrcmp(driver_name_g, drivernames[ROS3_VFD_IDX])) { -#ifdef H5_HAVE_ROS3_VFD - vfd_info.info = (void *)&ros3_fa_g; -#else - error_msg("Read-Only S3 VFD not enabled.\n"); - h5tools_setstatus(EXIT_FAILURE); - goto done; -#endif - } - else if (!HDstrcmp(driver_name_g, drivernames[HDFS_VFD_IDX])) { -#ifdef H5_HAVE_LIBHDFS - vfd_info.info = (void *)&hdfs_fa_g; -#else - error_msg("The HDFS VFD is not enabled.\n"); - h5tools_setstatus(EXIT_FAILURE); - goto done; -#endif - } - - if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, NULL, &vfd_info)) < 0) { - error_msg("unable to create FAPL for file access\n"); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - } /* driver name defined */ - - if (use_custom_vol_g) { - if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, &vol_info_g, NULL)) < 0) { + if (use_custom_vol_g || use_custom_vfd_g) { + if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, use_custom_vol_g ? &vol_info_g : NULL, + use_custom_vfd_g ? &vfd_info_g : NULL)) < 0) { error_msg("unable to create FAPL for file access\n"); h5tools_setstatus(EXIT_FAILURE); goto done; @@ -1421,7 +1421,7 @@ main(int argc, const char *argv[]) while (H5_optind < argc) { fname = HDstrdup(argv[H5_optind++]); - fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0); + fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, (fapl_id != H5P_DEFAULT), NULL, 0); if (fid < 0) { error_msg("unable to open file \"%s\"\n", fname); diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c index 4392d85..2ec8da2 100644 --- a/tools/src/h5ls/h5ls.c +++ b/tools/src/h5ls/h5ls.c @@ -240,6 +240,12 @@ usage(void) PRINTVALSTREAM(rawoutstream, " --vol-info VOL-specific info to pass to the VOL connector used for\n"); PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --vfd-value Value (ID) of the VFL driver to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --vfd-name Name of the VFL driver to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --vfd-info VFD-specific info to pass to the VFL driver used for\n"); + PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " file/OBJECT\n"); PRINTVALSTREAM(rawoutstream, " Each object consists of an HDF5 file name optionally followed by a\n"); @@ -2649,11 +2655,12 @@ main(int argc, const char *argv[]) int argno; static char root_name[] = "/"; char drivername[50]; - const char * preferred_driver = NULL; - int err_exit = 0; - hid_t fapl_id = H5P_DEFAULT; - hbool_t custom_vol_fapl = FALSE; + int err_exit = 0; + hid_t fapl_id = H5P_DEFAULT; + hbool_t custom_vol_fapl = FALSE; + hbool_t custom_vfd_fapl = FALSE; h5tools_vol_info_t vol_info; + h5tools_vfd_info_t vfd_info; #ifdef H5_HAVE_ROS3_VFD /* Default "anonymous" S3 configuration */ @@ -2684,8 +2691,9 @@ main(int argc, const char *argv[]) /* Initialize h5tools lib */ h5tools_init(); - /* Initialize fapl info struct */ + /* Initialize fapl info structs */ HDmemset(&vol_info, 0, sizeof(h5tools_vol_info_t)); + HDmemset(&vfd_info, 0, sizeof(h5tools_vfd_info_t)); /* Build object display table */ DISPATCH(H5O_TYPE_GROUP, "Group", NULL, NULL); @@ -2747,9 +2755,6 @@ main(int argc, const char *argv[]) else if (!HDstrcmp(argv[argno], "--string")) { string_g = TRUE; } - else if (!HDstrncmp(argv[argno], "--vfd=", (size_t)6)) { - preferred_driver = argv[argno] + 6; - } else if (!HDstrncmp(argv[argno], "--vol-value=", (size_t)12)) { vol_info.type = VOL_BY_VALUE; vol_info.u.value = (H5VL_class_value_t)HDatoi(argv[argno] + 12); @@ -2763,6 +2768,25 @@ main(int argc, const char *argv[]) else if (!HDstrncmp(argv[argno], "--vol-info=", (size_t)11)) { vol_info.info_string = argv[argno] + 11; } + else if (!HDstrncmp(argv[argno], "--vfd=", (size_t)6)) { + vfd_info.type = VFD_BY_NAME; + vfd_info.u.name = argv[argno] + 6; + vfd_info.info = NULL; + custom_vfd_fapl = TRUE; + } + else if (!HDstrncmp(argv[argno], "--vfd-value=", (size_t)12)) { + vfd_info.type = VFD_BY_VALUE; + vfd_info.u.value = (H5FD_class_value_t)HDatoi(argv[argno] + 12); + custom_vfd_fapl = TRUE; + } + else if (!HDstrncmp(argv[argno], "--vfd-name=", (size_t)11)) { + vfd_info.type = VFD_BY_NAME; + vfd_info.u.name = argv[argno] + 11; + custom_vfd_fapl = TRUE; + } + else if (!HDstrncmp(argv[argno], "--vfd-info=", (size_t)11)) { + vfd_info.info = (const void *)(argv[argno] + 11); + } else if (!HDstrncmp(argv[argno], "--width=", (size_t)8)) { width_g = (int)HDstrtol(argv[argno] + 8, &rest, 0); @@ -2959,42 +2983,14 @@ main(int argc, const char *argv[]) } /* Setup a custom fapl for file accesses */ - if (custom_vol_fapl) { - if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, &vol_info, NULL)) < 0) { + if (custom_vol_fapl || custom_vfd_fapl) { + if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, custom_vol_fapl ? &vol_info : NULL, + custom_vfd_fapl ? &vfd_info : NULL)) < 0) { error_msg("failed to setup file access property list (fapl) for file\n"); leave(EXIT_FAILURE); } } - if (preferred_driver) { - h5tools_vfd_info_t vfd_info; - - vfd_info.info = NULL; - vfd_info.name = preferred_driver; - - if (!HDstrcmp(preferred_driver, drivernames[ROS3_VFD_IDX])) { -#ifdef H5_HAVE_ROS3_VFD - vfd_info.info = (void *)&ros3_fa; -#else - HDfprintf(rawerrorstream, "Error: Read-Only S3 VFD is not enabled\n\n"); - leave(EXIT_FAILURE); -#endif - } - else if (!HDstrcmp(preferred_driver, drivernames[HDFS_VFD_IDX])) { -#ifdef H5_HAVE_LIBHDFS - vfd_info.info = (void *)&hdfs_fa; -#else - HDfprintf(rawerrorstream, "Error: The HDFS VFD is not enabled\n\n"); - leave(EXIT_FAILURE); -#endif - } - - if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, NULL, &vfd_info)) < 0) { - HDfprintf(rawerrorstream, "Error: Unable to create FAPL for file access\n\n"); - leave(EXIT_FAILURE); - } - } - /* Each remaining argument is an hdf5 file followed by an optional slash * and object name. * @@ -3019,8 +3015,8 @@ main(int argc, const char *argv[]) file_id = H5I_INVALID_HID; while (fname && *fname) { - file_id = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, - drivername, sizeof drivername); + file_id = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, (fapl_id != H5P_DEFAULT), drivername, + sizeof drivername); if (file_id >= 0) { if (verbose_g) diff --git a/tools/src/h5perf/perf.c b/tools/src/h5perf/perf.c index 83d4ab0..50b18bc 100644 --- a/tools/src/h5perf/perf.c +++ b/tools/src/h5perf/perf.c @@ -605,7 +605,7 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, char *fu * we are using the split driver since both of those * use the multi VFD under the hood. */ - env = HDgetenv("HDF5_DRIVER"); + env = HDgetenv(HDF5_DRIVER); #ifdef HDF5_DRIVER /* Use the environment variable, then the compile-time constant */ if (!env) diff --git a/tools/src/h5perf/pio_engine.c b/tools/src/h5perf/pio_engine.c index cac36d7..f890c7d 100644 --- a/tools/src/h5perf/pio_engine.c +++ b/tools/src/h5perf/pio_engine.c @@ -2676,7 +2676,7 @@ do_cleanupfile(iotype iot, char *fname) return; if (clean_file_g == -1) - clean_file_g = (getenv("HDF5_NOCLEANUP") == NULL) ? 1 : 0; + clean_file_g = (getenv(HDF5_NOCLEANUP) == NULL) ? 1 : 0; if (clean_file_g) { switch (iot) { diff --git a/tools/src/h5perf/sio_engine.c b/tools/src/h5perf/sio_engine.c index e69a7cd..3ebacc0 100644 --- a/tools/src/h5perf/sio_engine.c +++ b/tools/src/h5perf/sio_engine.c @@ -1272,7 +1272,7 @@ do_cleanupfile(iotype iot, char *filename) hid_t driver; if (clean_file_g == -1) - clean_file_g = (HDgetenv("HDF5_NOCLEANUP") == NULL) ? 1 : 0; + clean_file_g = (HDgetenv(HDF5_NOCLEANUP) == NULL) ? 1 : 0; if (clean_file_g) { diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index 7cad36b..d75b1cf 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -758,8 +758,8 @@ check_objects(const char *fname, pack_opt_t *options) * open the file *------------------------------------------------------------------------- */ - if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, options->fin_fapl, - (options->fin_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0)) < 0) + if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, options->fin_fapl, (options->fin_fapl != H5P_DEFAULT), + NULL, 0)) < 0) H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname, H5FOPENERROR); /*------------------------------------------------------------------------- diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index 934b4d1..3806a4e 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -81,8 +81,8 @@ copy_objects(const char *fnamein, const char *fnameout, pack_opt_t *options) * open input file *------------------------------------------------------------------------- */ - if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, options->fin_fapl, - (options->fin_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, (size_t)0)) < 0) + if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, options->fin_fapl, (options->fin_fapl != H5P_DEFAULT), + NULL, (size_t)0)) < 0) H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fnamein, H5FOPENERROR); /* get user block size and file space strategy/persist/threshold */ diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index 3526268..08568cd 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:VXW1:2:3:4:5:6:"; +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'}, @@ -68,6 +68,12 @@ static struct h5_long_options l_opts[] = {{"alignment", require_arg, 'a'}, {"dst-vol-value", require_arg, '4'}, {"dst-vol-name", require_arg, '5'}, {"dst-vol-info", require_arg, '6'}, + {"src-vfd-value", require_arg, '7'}, + {"src-vfd-name", require_arg, '8'}, + {"src-vfd-info", require_arg, '9'}, + {"dst-vfd-value", require_arg, '0'}, + {"dst-vfd-name", require_arg, 'Y'}, + {"dst-vfd-info", require_arg, 'Z'}, {NULL, 0, '\0'}}; /*------------------------------------------------------------------------- @@ -112,6 +118,24 @@ usage(const char *prog) PRINTVALSTREAM(rawoutstream, " --dst-vol-info VOL-specific info to pass to the VOL connector used for\n"); PRINTVALSTREAM(rawoutstream, " opening the output HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --src-vfd-value Value (ID) of the VFL driver to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " input HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --src-vfd-name Name of the VFL driver to use for opening the input\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --src-vfd-info VFD-specific info to pass to the VFL driver used for\n"); + PRINTVALSTREAM(rawoutstream, " opening the input HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --dst-vfd-value Value (ID) of the VFL driver to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " output HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --dst-vfd-name Name of the VFL driver to use for opening the output\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --dst-vfd-info VFD-specific info to pass to the VFL driver used for\n"); + PRINTVALSTREAM(rawoutstream, " opening the output HDF5 file specified\n"); PRINTVALSTREAM(rawoutstream, " -L, --latest Use latest version of file format\n"); PRINTVALSTREAM(rawoutstream, " This option will take precedence over the options\n"); @@ -486,15 +510,21 @@ parse_command_line(int argc, const char **argv, pack_opt_t *options) { h5tools_vol_info_t in_vol_info; h5tools_vol_info_t out_vol_info; - hbool_t custom_in_fapl = FALSE; - hbool_t custom_out_fapl = FALSE; - hid_t tmp_fapl = H5I_INVALID_HID; + h5tools_vfd_info_t in_vfd_info; + h5tools_vfd_info_t out_vfd_info; + hbool_t custom_in_vol = FALSE; + hbool_t custom_in_vfd = FALSE; + hbool_t custom_out_vol = FALSE; + hbool_t custom_out_vfd = FALSE; + hid_t tmp_fapl = H5I_INVALID_HID; int bound, opt; int ret_value = 0; /* Initialize fapl info structs */ HDmemset(&in_vol_info, 0, sizeof(h5tools_vol_info_t)); HDmemset(&out_vol_info, 0, sizeof(h5tools_vol_info_t)); + HDmemset(&in_vfd_info, 0, sizeof(h5tools_vfd_info_t)); + HDmemset(&out_vfd_info, 0, sizeof(h5tools_vfd_info_t)); /* parse command line options */ while (EOF != (opt = H5_get_option(argc, argv, s_opts, l_opts))) { @@ -741,13 +771,13 @@ parse_command_line(int argc, const char **argv, pack_opt_t *options) case '1': in_vol_info.type = VOL_BY_VALUE; in_vol_info.u.value = (H5VL_class_value_t)HDatoi(H5_optarg); - custom_in_fapl = TRUE; + custom_in_vol = TRUE; break; case '2': in_vol_info.type = VOL_BY_NAME; in_vol_info.u.name = H5_optarg; - custom_in_fapl = TRUE; + custom_in_vol = TRUE; break; case '3': @@ -757,19 +787,51 @@ parse_command_line(int argc, const char **argv, pack_opt_t *options) case '4': out_vol_info.type = VOL_BY_VALUE; out_vol_info.u.value = (H5VL_class_value_t)HDatoi(H5_optarg); - custom_out_fapl = TRUE; + custom_out_vol = TRUE; break; case '5': out_vol_info.type = VOL_BY_NAME; out_vol_info.u.name = H5_optarg; - custom_out_fapl = TRUE; + custom_out_vol = TRUE; break; case '6': out_vol_info.info_string = H5_optarg; break; + case '7': + in_vfd_info.type = VFD_BY_VALUE; + in_vfd_info.u.value = (H5FD_class_value_t)HDatoi(H5_optarg); + custom_in_vfd = TRUE; + break; + + case '8': + in_vfd_info.type = VFD_BY_NAME; + in_vfd_info.u.name = H5_optarg; + custom_in_vfd = TRUE; + break; + + case '9': + in_vfd_info.info = (const void *)H5_optarg; + break; + + case '0': + out_vfd_info.type = VFD_BY_VALUE; + out_vfd_info.u.value = (H5FD_class_value_t)HDatoi(H5_optarg); + custom_out_vfd = TRUE; + break; + + case 'Y': + out_vfd_info.type = VFD_BY_NAME; + out_vfd_info.u.name = H5_optarg; + custom_out_vfd = TRUE; + break; + + case 'Z': + out_vfd_info.info = (const void *)H5_optarg; + break; + default: break; } /* end switch */ @@ -803,8 +865,9 @@ parse_command_line(int argc, const char **argv, pack_opt_t *options) } /* Setup FAPL for input and output file accesses */ - if (custom_in_fapl) { - if ((tmp_fapl = h5tools_get_fapl(options->fin_fapl, &in_vol_info, NULL)) < 0) { + if (custom_in_vol || custom_in_vfd) { + if ((tmp_fapl = h5tools_get_fapl(options->fin_fapl, custom_in_vol ? &in_vol_info : NULL, + custom_in_vfd ? &in_vfd_info : NULL)) < 0) { error_msg("failed to setup FAPL for input file\n"); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; @@ -823,8 +886,9 @@ parse_command_line(int argc, const char **argv, pack_opt_t *options) options->fin_fapl = tmp_fapl; } - if (custom_out_fapl) { - if ((tmp_fapl = h5tools_get_fapl(options->fout_fapl, &out_vol_info, NULL)) < 0) { + if (custom_out_vol || custom_out_vfd) { + if ((tmp_fapl = h5tools_get_fapl(options->fout_fapl, custom_out_vol ? &out_vol_info : NULL, + custom_out_vfd ? &out_vfd_info : NULL)) < 0) { error_msg("failed to setup FAPL for output file\n"); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; diff --git a/tools/src/h5repack/h5repack_verify.c b/tools/src/h5repack/h5repack_verify.c index 0542d03..8c54dde 100644 --- a/tools/src/h5repack/h5repack_verify.c +++ b/tools/src/h5repack/h5repack_verify.c @@ -378,11 +378,11 @@ h5repack_cmp_pl(const char *fname1, hid_t fname1_fapl, const char *fname2, hid_t *------------------------------------------------------------------------- */ /* Open the files */ - if ((fid1 = h5tools_fopen(fname1, H5F_ACC_RDONLY, fname1_fapl, - (fname1_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0)) < 0) + if ((fid1 = h5tools_fopen(fname1, H5F_ACC_RDONLY, fname1_fapl, (fname1_fapl != H5P_DEFAULT), NULL, 0)) < + 0) H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname1, H5FOPENERROR); - if ((fid2 = h5tools_fopen(fname2, H5F_ACC_RDONLY, fname2_fapl, - (fname2_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0)) < 0) + if ((fid2 = h5tools_fopen(fname2, H5F_ACC_RDONLY, fname2_fapl, (fname2_fapl != H5P_DEFAULT), NULL, 0)) < + 0) H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname2, H5FOPENERROR); /*------------------------------------------------------------------------- diff --git a/tools/src/h5stat/h5stat.c b/tools/src/h5stat/h5stat.c index efc80b6..d745c0f 100644 --- a/tools/src/h5stat/h5stat.c +++ b/tools/src/h5stat/h5stat.c @@ -1702,25 +1702,9 @@ main(int argc, const char *argv[]) if (drivername) { h5tools_vfd_info_t vfd_info; - vfd_info.info = NULL; - vfd_info.name = drivername; - - if (!HDstrcmp(drivername, drivernames[ROS3_VFD_IDX])) { -#ifdef H5_HAVE_ROS3_VFD - vfd_info.info = (void *)&ros3_fa; -#else - error_msg("Read-Only S3 VFD not enabled.\n"); - goto done; -#endif - } - else if (!HDstrcmp(drivername, drivernames[HDFS_VFD_IDX])) { -#ifdef H5_HAVE_LIBHDFS - vfd_info.info = (void *)&hdfs_fa; -#else - error_msg("HDFS VFD not enabled.\n"); - goto done; -#endif - } + vfd_info.type = VFD_BY_NAME; + vfd_info.info = NULL; + vfd_info.u.name = drivername; if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, NULL, &vfd_info)) < 0) { error_msg("Unable to create FAPL for file access\n"); @@ -1737,7 +1721,7 @@ main(int argc, const char *argv[]) HDprintf("Filename: %s\n", fname); - fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0); + fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, (fapl_id != H5P_DEFAULT), NULL, 0); if (fid < 0) { error_msg("unable to open file \"%s\"\n", fname); diff --git a/tools/src/misc/h5mkgrp.c b/tools/src/misc/h5mkgrp.c index a85ee4d..1e66fce 100644 --- a/tools/src/misc/h5mkgrp.c +++ b/tools/src/misc/h5mkgrp.c @@ -26,7 +26,8 @@ static const char * s_opts = "hlpvV"; static struct h5_long_options l_opts[] = { {"help", no_arg, 'h'}, {"latest", no_arg, 'l'}, {"parents", no_arg, 'p'}, {"verbose", no_arg, 'v'}, {"version", no_arg, 'V'}, {"vol-value", require_arg, '1'}, - {"vol-name", require_arg, '2'}, {"vol-info", require_arg, '3'}, {NULL, 0, '\0'}}; + {"vol-name", require_arg, '2'}, {"vol-info", require_arg, '3'}, {"vfd-value", require_arg, '4'}, + {"vfd-name", require_arg, '5'}, {"vfd-info", require_arg, '6'}, {NULL, 0, '\0'}}; /* Command line parameter settings */ typedef struct mkgrp_opt_t { @@ -105,6 +106,14 @@ usage(const char *prog) PRINTVALSTREAM(rawoutstream, " --vol-info VOL-specific info to pass to the VOL connector used for\n"); PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --vfd-value Value (ID) of the VFL driver to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, " --vfd-name Name of the VFL driver to use for opening the\n"); + PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n"); + PRINTVALSTREAM(rawoutstream, + " --vfd-info VFD-specific info to pass to the VFL driver used for\n"); + PRINTVALSTREAM(rawoutstream, " opening the HDF5 file specified\n"); PRINTVALSTREAM(rawoutstream, "\n"); } /* end usage() */ @@ -126,8 +135,10 @@ parse_command_line(int argc, const char *argv[], mkgrp_opt_t *options) { int opt; /* Option from command line */ size_t curr_group; /* Current group name to copy */ - hbool_t custom_fapl = FALSE; + hbool_t custom_vol = FALSE; + hbool_t custom_vfd = FALSE; h5tools_vol_info_t vol_info; + h5tools_vfd_info_t vfd_info; hid_t tmp_fapl_id = H5I_INVALID_HID; /* Check for empty command line */ @@ -136,8 +147,9 @@ parse_command_line(int argc, const char *argv[], mkgrp_opt_t *options) leave(EXIT_SUCCESS); } - /* Initialize fapl info struct */ + /* Initialize fapl info structs */ HDmemset(&vol_info, 0, sizeof(h5tools_vol_info_t)); + HDmemset(&vfd_info, 0, sizeof(h5tools_vfd_info_t)); /* Parse command line options */ while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) { @@ -172,19 +184,35 @@ parse_command_line(int argc, const char *argv[], mkgrp_opt_t *options) case '1': vol_info.type = VOL_BY_VALUE; vol_info.u.value = (H5VL_class_value_t)HDatoi(H5_optarg); - custom_fapl = TRUE; + custom_vol = TRUE; break; case '2': vol_info.type = VOL_BY_NAME; vol_info.u.name = H5_optarg; - custom_fapl = TRUE; + custom_vol = TRUE; break; case '3': vol_info.info_string = H5_optarg; break; + case '4': + vfd_info.type = VFD_BY_VALUE; + vfd_info.u.value = (H5FD_class_value_t)HDatoi(H5_optarg); + custom_vfd = TRUE; + break; + + case '5': + vfd_info.type = VFD_BY_NAME; + vfd_info.u.name = H5_optarg; + custom_vfd = TRUE; + break; + + case '6': + vfd_info.info = (const void *)H5_optarg; + break; + /* Bad command line argument */ default: usage(h5tools_getprogname()); @@ -223,8 +251,9 @@ parse_command_line(int argc, const char *argv[], mkgrp_opt_t *options) } /* Setup a custom fapl for file accesses */ - if (custom_fapl) { - if ((tmp_fapl_id = h5tools_get_fapl(options->fapl_id, &vol_info, NULL)) < 0) { + if (custom_vol || custom_vfd) { + if ((tmp_fapl_id = h5tools_get_fapl(options->fapl_id, custom_vol ? &vol_info : NULL, + custom_vfd ? &vfd_info : NULL)) < 0) { error_msg("failed to setup file access property list (fapl) for file\n"); leave(EXIT_FAILURE); } @@ -296,7 +325,8 @@ main(int argc, const char *argv[]) } /* Attempt to open an existing HDF5 file first */ - fid = h5tools_fopen(params_g.fname, H5F_ACC_RDWR, params_g.fapl_id, FALSE, NULL, 0); + fid = h5tools_fopen(params_g.fname, H5F_ACC_RDWR, params_g.fapl_id, (params_g.fapl_id != H5P_DEFAULT), + NULL, 0); /* If we couldn't open an existing file, try creating file */ /* (use "EXCL" instead of "TRUNC", so we don't blow away existing non-HDF5 file) */ diff --git a/tools/test/h5diff/testfiles/h5diff_10.txt b/tools/test/h5diff/testfiles/h5diff_10.txt index 3631db7..c8e8560 100644 --- a/tools/test/h5diff/testfiles/h5diff_10.txt +++ b/tools/test/h5diff/testfiles/h5diff_10.txt @@ -36,6 +36,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] HDF5 file specified --vol-info-2 VOL-specific info to pass to the VOL connector used for opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. diff --git a/tools/test/h5diff/testfiles/h5diff_600.txt b/tools/test/h5diff/testfiles/h5diff_600.txt index 8a4ce6d..c8190ce 100644 --- a/tools/test/h5diff/testfiles/h5diff_600.txt +++ b/tools/test/h5diff/testfiles/h5diff_600.txt @@ -36,6 +36,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] HDF5 file specified --vol-info-2 VOL-specific info to pass to the VOL connector used for opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. diff --git a/tools/test/h5diff/testfiles/h5diff_603.txt b/tools/test/h5diff/testfiles/h5diff_603.txt index d4c7336..03c23e7 100644 --- a/tools/test/h5diff/testfiles/h5diff_603.txt +++ b/tools/test/h5diff/testfiles/h5diff_603.txt @@ -37,6 +37,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] HDF5 file specified --vol-info-2 VOL-specific info to pass to the VOL connector used for opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. diff --git a/tools/test/h5diff/testfiles/h5diff_606.txt b/tools/test/h5diff/testfiles/h5diff_606.txt index 3123587..0e9d5be 100644 --- a/tools/test/h5diff/testfiles/h5diff_606.txt +++ b/tools/test/h5diff/testfiles/h5diff_606.txt @@ -37,6 +37,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] HDF5 file specified --vol-info-2 VOL-specific info to pass to the VOL connector used for opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. diff --git a/tools/test/h5diff/testfiles/h5diff_612.txt b/tools/test/h5diff/testfiles/h5diff_612.txt index ce2d887..ac19926 100644 --- a/tools/test/h5diff/testfiles/h5diff_612.txt +++ b/tools/test/h5diff/testfiles/h5diff_612.txt @@ -37,6 +37,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] HDF5 file specified --vol-info-2 VOL-specific info to pass to the VOL connector used for opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. diff --git a/tools/test/h5diff/testfiles/h5diff_615.txt b/tools/test/h5diff/testfiles/h5diff_615.txt index 61fd036..44eba43 100644 --- a/tools/test/h5diff/testfiles/h5diff_615.txt +++ b/tools/test/h5diff/testfiles/h5diff_615.txt @@ -37,6 +37,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] HDF5 file specified --vol-info-2 VOL-specific info to pass to the VOL connector used for opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. diff --git a/tools/test/h5diff/testfiles/h5diff_621.txt b/tools/test/h5diff/testfiles/h5diff_621.txt index dc8655d..32310eb 100644 --- a/tools/test/h5diff/testfiles/h5diff_621.txt +++ b/tools/test/h5diff/testfiles/h5diff_621.txt @@ -37,6 +37,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] HDF5 file specified --vol-info-2 VOL-specific info to pass to the VOL connector used for opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. diff --git a/tools/test/h5diff/testfiles/h5diff_622.txt b/tools/test/h5diff/testfiles/h5diff_622.txt index f20ffbe..630184f 100644 --- a/tools/test/h5diff/testfiles/h5diff_622.txt +++ b/tools/test/h5diff/testfiles/h5diff_622.txt @@ -37,6 +37,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] HDF5 file specified --vol-info-2 VOL-specific info to pass to the VOL connector used for opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. diff --git a/tools/test/h5diff/testfiles/h5diff_623.txt b/tools/test/h5diff/testfiles/h5diff_623.txt index f73d202..82c4ce2 100644 --- a/tools/test/h5diff/testfiles/h5diff_623.txt +++ b/tools/test/h5diff/testfiles/h5diff_623.txt @@ -37,6 +37,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] HDF5 file specified --vol-info-2 VOL-specific info to pass to the VOL connector used for opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. diff --git a/tools/test/h5diff/testfiles/h5diff_624.txt b/tools/test/h5diff/testfiles/h5diff_624.txt index 903b738..a675ec6 100644 --- a/tools/test/h5diff/testfiles/h5diff_624.txt +++ b/tools/test/h5diff/testfiles/h5diff_624.txt @@ -37,6 +37,18 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] HDF5 file specified --vol-info-2 VOL-specific info to pass to the VOL connector used for opening the second HDF5 file specified + --vfd-value-1 Value (ID) of the VFL driver to use for opening the + first HDF5 file specified + --vfd-name-1 Name of the VFL driver to use for opening the first + HDF5 file specified + --vfd-info-1 VFD-specific info to pass to the VFL driver used for + opening the first HDF5 file specified + --vfd-value-2 Value (ID) of the VFL driver to use for opening the + second HDF5 file specified + --vfd-name-2 Name of the VFL driver to use for opening the second + HDF5 file specified + --vfd-info-2 VFD-specific info to pass to the VFL driver used for + opening the second HDF5 file specified --follow-symlinks Follow symbolic links (soft links and external links and compare the) links' target objects. diff --git a/tools/test/h5repack/CMakeVFDTests.cmake b/tools/test/h5repack/CMakeVFDTests.cmake index e26941b..4f6e51d 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 b62fa53..ed3fedd 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 @@ error: 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 @@ error: { H5Tclose(dtid); H5Dclose(dsid); + H5Pclose(dxpl); H5Pclose(dcpl); H5Sclose(sid); } @@ -5802,11 +5867,25 @@ out: 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 @@ out: 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); } diff --git a/tools/test/h5repack/testfiles/h5repack-help.txt b/tools/test/h5repack/testfiles/h5repack-help.txt index cb10d22..894f88c 100644 --- a/tools/test/h5repack/testfiles/h5repack-help.txt +++ b/tools/test/h5repack/testfiles/h5repack-help.txt @@ -20,6 +20,18 @@ usage: h5repack [OPTIONS] file1 file2 HDF5 file specified --dst-vol-info VOL-specific info to pass to the VOL connector used for opening the output HDF5 file specified + --src-vfd-value Value (ID) of the VFL driver to use for opening the + input HDF5 file specified + --src-vfd-name Name of the VFL driver to use for opening the input + HDF5 file specified + --src-vfd-info VFD-specific info to pass to the VFL driver used for + opening the input HDF5 file specified + --dst-vfd-value Value (ID) of the VFL driver to use for opening the + output HDF5 file specified + --dst-vfd-name Name of the VFL driver to use for opening the output + HDF5 file specified + --dst-vfd-info VFD-specific info to pass to the VFL driver used for + opening the output HDF5 file specified -L, --latest Use latest version of file format This option will take precedence over the options --low and --high diff --git a/tools/test/misc/testfiles/h5mkgrp_help.txt b/tools/test/misc/testfiles/h5mkgrp_help.txt index 9525230..5d81b34 100644 --- a/tools/test/misc/testfiles/h5mkgrp_help.txt +++ b/tools/test/misc/testfiles/h5mkgrp_help.txt @@ -11,4 +11,10 @@ usage: h5mkgrp [OPTIONS] FILE GROUP... HDF5 file specified --vol-info VOL-specific info to pass to the VOL connector used for opening the HDF5 file specified + --vfd-value Value (ID) of the VFL driver to use for opening the + HDF5 file specified + --vfd-name Name of the VFL driver to use for opening the + HDF5 file specified + --vfd-info VFD-specific info to pass to the VFL driver used for + opening the HDF5 file specified diff --git a/tools/test/perform/chunk_cache.c b/tools/test/perform/chunk_cache.c index ad9bf09..a99334f 100644 --- a/tools/test/perform/chunk_cache.c +++ b/tools/test/perform/chunk_cache.c @@ -81,7 +81,7 @@ counter(unsigned H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, static void cleanup(void) { - if (!getenv("HDF5_NOCLEANUP")) { + if (!getenv(HDF5_NOCLEANUP)) { remove(FILENAME); } } diff --git a/tools/test/perform/overhead.c b/tools/test/perform/overhead.c index 64192ba..c974928 100644 --- a/tools/test/perform/overhead.c +++ b/tools/test/perform/overhead.c @@ -119,7 +119,7 @@ usage(const char *prog) static void cleanup(void) { - if (!getenv("HDF5_NOCLEANUP")) { + if (!getenv(HDF5_NOCLEANUP)) { remove(FILE_NAME_1); } } diff --git a/tools/test/perform/zip_perf.c b/tools/test/perform/zip_perf.c index 123fb98..30eb06e 100644 --- a/tools/test/perform/zip_perf.c +++ b/tools/test/perform/zip_perf.c @@ -103,7 +103,7 @@ error(const char *fmt, ...) static void cleanup(void) { - if (!HDgetenv("HDF5_NOCLEANUP")) + if (!HDgetenv(HDF5_NOCLEANUP)) HDunlink(filename); HDfree(filename); } diff --git a/tools/testfiles/h5dump-help.txt b/tools/testfiles/h5dump-help.txt index 5b11223..53c666b 100644 --- a/tools/testfiles/h5dump-help.txt +++ b/tools/testfiles/h5dump-help.txt @@ -28,6 +28,12 @@ usage: h5dump [OPTIONS] files HDF5 file specified --vol-info VOL-specific info to pass to the VOL connector used for opening the HDF5 file specified + --vfd-value Value (ID) of the VFL driver to use for opening the + HDF5 file specified + --vfd-name Name of the VFL driver to use for opening the + HDF5 file specified + --vfd-info VFD-specific info to pass to the VFL driver used for + opening the HDF5 file specified --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/help-1.ls b/tools/testfiles/help-1.ls index 0926c4c..6ed1aab 100644 --- a/tools/testfiles/help-1.ls +++ b/tools/testfiles/help-1.ls @@ -52,6 +52,12 @@ usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...] HDF5 file specified --vol-info VOL-specific info to pass to the VOL connector used for opening the HDF5 file specified + --vfd-value Value (ID) of the VFL driver to use for opening the + HDF5 file specified + --vfd-name Name of the VFL driver to use for opening the + HDF5 file specified + --vfd-info VFD-specific info to pass to the VFL driver used for + opening the HDF5 file specified file/OBJECT Each object consists of an HDF5 file name optionally followed by a diff --git a/tools/testfiles/help-2.ls b/tools/testfiles/help-2.ls index 0926c4c..6ed1aab 100644 --- a/tools/testfiles/help-2.ls +++ b/tools/testfiles/help-2.ls @@ -52,6 +52,12 @@ usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...] HDF5 file specified --vol-info VOL-specific info to pass to the VOL connector used for opening the HDF5 file specified + --vfd-value Value (ID) of the VFL driver to use for opening the + HDF5 file specified + --vfd-name Name of the VFL driver to use for opening the + HDF5 file specified + --vfd-info VFD-specific info to pass to the VFL driver used for + opening the HDF5 file specified file/OBJECT Each object consists of an HDF5 file name optionally followed by a diff --git a/tools/testfiles/help-3.ls b/tools/testfiles/help-3.ls index 0926c4c..6ed1aab 100644 --- a/tools/testfiles/help-3.ls +++ b/tools/testfiles/help-3.ls @@ -52,6 +52,12 @@ usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...] HDF5 file specified --vol-info VOL-specific info to pass to the VOL connector used for opening the HDF5 file specified + --vfd-value Value (ID) of the VFL driver to use for opening the + HDF5 file specified + --vfd-name Name of the VFL driver to use for opening the + HDF5 file specified + --vfd-info VFD-specific info to pass to the VFL driver used for + opening the HDF5 file specified file/OBJECT Each object consists of an HDF5 file name optionally followed by a diff --git a/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl b/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl index 5b11223..53c666b 100644 --- a/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl +++ b/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl @@ -28,6 +28,12 @@ usage: h5dump [OPTIONS] files HDF5 file specified --vol-info VOL-specific info to pass to the VOL connector used for opening the HDF5 file specified + --vfd-value Value (ID) of the VFL driver to use for opening the + HDF5 file specified + --vfd-name Name of the VFL driver to use for opening the + HDF5 file specified + --vfd-info VFD-specific info to pass to the VFL driver used for + opening the HDF5 file specified --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/pbits/tpbitsIncomplete.ddl b/tools/testfiles/pbits/tpbitsIncomplete.ddl index 5b11223..53c666b 100644 --- a/tools/testfiles/pbits/tpbitsIncomplete.ddl +++ b/tools/testfiles/pbits/tpbitsIncomplete.ddl @@ -28,6 +28,12 @@ usage: h5dump [OPTIONS] files HDF5 file specified --vol-info VOL-specific info to pass to the VOL connector used for opening the HDF5 file specified + --vfd-value Value (ID) of the VFL driver to use for opening the + HDF5 file specified + --vfd-name Name of the VFL driver to use for opening the + HDF5 file specified + --vfd-info VFD-specific info to pass to the VFL driver used for + opening the HDF5 file specified --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/pbits/tpbitsLengthExceeded.ddl b/tools/testfiles/pbits/tpbitsLengthExceeded.ddl index 5b11223..53c666b 100644 --- a/tools/testfiles/pbits/tpbitsLengthExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsLengthExceeded.ddl @@ -28,6 +28,12 @@ usage: h5dump [OPTIONS] files HDF5 file specified --vol-info VOL-specific info to pass to the VOL connector used for opening the HDF5 file specified + --vfd-value Value (ID) of the VFL driver to use for opening the + HDF5 file specified + --vfd-name Name of the VFL driver to use for opening the + HDF5 file specified + --vfd-info VFD-specific info to pass to the VFL driver used for + opening the HDF5 file specified --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/pbits/tpbitsLengthPositive.ddl b/tools/testfiles/pbits/tpbitsLengthPositive.ddl index 5b11223..53c666b 100644 --- a/tools/testfiles/pbits/tpbitsLengthPositive.ddl +++ b/tools/testfiles/pbits/tpbitsLengthPositive.ddl @@ -28,6 +28,12 @@ usage: h5dump [OPTIONS] files HDF5 file specified --vol-info VOL-specific info to pass to the VOL connector used for opening the HDF5 file specified + --vfd-value Value (ID) of the VFL driver to use for opening the + HDF5 file specified + --vfd-name Name of the VFL driver to use for opening the + HDF5 file specified + --vfd-info VFD-specific info to pass to the VFL driver used for + opening the HDF5 file specified --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/pbits/tpbitsMaxExceeded.ddl b/tools/testfiles/pbits/tpbitsMaxExceeded.ddl index 5b11223..53c666b 100644 --- a/tools/testfiles/pbits/tpbitsMaxExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsMaxExceeded.ddl @@ -28,6 +28,12 @@ usage: h5dump [OPTIONS] files HDF5 file specified --vol-info VOL-specific info to pass to the VOL connector used for opening the HDF5 file specified + --vfd-value Value (ID) of the VFL driver to use for opening the + HDF5 file specified + --vfd-name Name of the VFL driver to use for opening the + HDF5 file specified + --vfd-info VFD-specific info to pass to the VFL driver used for + opening the HDF5 file specified --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl b/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl index 5b11223..53c666b 100644 --- a/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl @@ -28,6 +28,12 @@ usage: h5dump [OPTIONS] files HDF5 file specified --vol-info VOL-specific info to pass to the VOL connector used for opening the HDF5 file specified + --vfd-value Value (ID) of the VFL driver to use for opening the + HDF5 file specified + --vfd-name Name of the VFL driver to use for opening the + HDF5 file specified + --vfd-info VFD-specific info to pass to the VFL driver used for + opening the HDF5 file specified --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/pbits/tpbitsOffsetNegative.ddl b/tools/testfiles/pbits/tpbitsOffsetNegative.ddl index 5b11223..53c666b 100644 --- a/tools/testfiles/pbits/tpbitsOffsetNegative.ddl +++ b/tools/testfiles/pbits/tpbitsOffsetNegative.ddl @@ -28,6 +28,12 @@ usage: h5dump [OPTIONS] files HDF5 file specified --vol-info VOL-specific info to pass to the VOL connector used for opening the HDF5 file specified + --vfd-value Value (ID) of the VFL driver to use for opening the + HDF5 file specified + --vfd-name Name of the VFL driver to use for opening the + HDF5 file specified + --vfd-info VFD-specific info to pass to the VFL driver used for + opening the HDF5 file specified --------------- Object Options --------------- -a P, --attribute=P Print the specified attribute If an attribute name contains a slash (/), escape the diff --git a/tools/testfiles/textlinksrc-nodangle-1.ls b/tools/testfiles/textlinksrc-nodangle-1.ls index 0926c4c..6ed1aab 100644 --- a/tools/testfiles/textlinksrc-nodangle-1.ls +++ b/tools/testfiles/textlinksrc-nodangle-1.ls @@ -52,6 +52,12 @@ usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...] HDF5 file specified --vol-info VOL-specific info to pass to the VOL connector used for opening the HDF5 file specified + --vfd-value Value (ID) of the VFL driver to use for opening the + HDF5 file specified + --vfd-name Name of the VFL driver to use for opening the + HDF5 file specified + --vfd-info VFD-specific info to pass to the VFL driver used for + opening the HDF5 file specified file/OBJECT Each object consists of an HDF5 file name optionally followed by a diff --git a/tools/testfiles/tgroup-1.ls b/tools/testfiles/tgroup-1.ls index 0926c4c..6ed1aab 100644 --- a/tools/testfiles/tgroup-1.ls +++ b/tools/testfiles/tgroup-1.ls @@ -52,6 +52,12 @@ usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...] HDF5 file specified --vol-info VOL-specific info to pass to the VOL connector used for opening the HDF5 file specified + --vfd-value Value (ID) of the VFL driver to use for opening the + HDF5 file specified + --vfd-name Name of the VFL driver to use for opening the + HDF5 file specified + --vfd-info VFD-specific info to pass to the VFL driver used for + opening the HDF5 file specified file/OBJECT Each object consists of an HDF5 file name optionally followed by a -- cgit v0.12