summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2018-11-28 23:38:03 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2018-11-28 23:38:03 (GMT)
commit6eabeabdaa77642fd4db5fd234ccc756a24125be (patch)
treeb7c2fb4bee8782df27f18efbcb1f11d6847e1fde
parent3abf58dce034dd9e5afabbdd7d1d80c1ba4374ad (diff)
downloadhdf5-6eabeabdaa77642fd4db5fd234ccc756a24125be.zip
hdf5-6eabeabdaa77642fd4db5fd234ccc756a24125be.tar.gz
hdf5-6eabeabdaa77642fd4db5fd234ccc756a24125be.tar.bz2
Refactor infrastructure for setting FAPL information from environment
variables during testing, including connecting native, pass-through, and dynamically loaded VOL connectors. Also bring native and pass-through VOL connectors into alignment, removing the "H5VLnative_private.h" header.
-rw-r--r--MANIFEST1
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/H5Dvirtual.c1
-rw-r--r--src/H5Fint.c1
-rw-r--r--src/H5Gtraverse.c1
-rw-r--r--src/H5L.c1
-rw-r--r--src/H5Lexternal.c1
-rw-r--r--src/H5Oint.c1
-rw-r--r--src/H5Pfapl.c6
-rw-r--r--src/H5VLnative.c44
-rw-r--r--src/H5VLnative.h6
-rw-r--r--src/H5VLnative_private.h37
-rw-r--r--src/H5VLpassthru.c8
-rw-r--r--test/h5test.c360
-rw-r--r--test/h5test.h10
-rw-r--r--test/vol.c1
16 files changed, 236 insertions, 244 deletions
diff --git a/MANIFEST b/MANIFEST
index 625a9fc..cb22f4d 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -894,7 +894,6 @@
./src/H5VLmodule.h
./src/H5VLnative.c
./src/H5VLnative.h
-./src/H5VLnative_private.h
./src/H5VLpassthru.c
./src/H5VLpassthru.h
./src/H5VLpkg.h
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 80b26ff..cd81ba5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -870,7 +870,6 @@ set (H5_PRIVATE_HEADERS
${HDF5_SRC_DIR}/H5UCprivate.h
${HDF5_SRC_DIR}/H5VLpkg.h
- ${HDF5_SRC_DIR}/H5VLnative_private.h
${HDF5_SRC_DIR}/H5VLprivate.h
${HDF5_SRC_DIR}/H5VMprivate.h
diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c
index feb836d..c0d49d8 100644
--- a/src/H5Dvirtual.c
+++ b/src/H5Dvirtual.c
@@ -58,7 +58,6 @@
#include "H5Oprivate.h" /* Object headers */
#include "H5Pprivate.h" /* Property Lists */
#include "H5Sprivate.h" /* Dataspaces */
-#include "H5VLnative_private.h" /* Native VOL driver */
#include "H5VLprivate.h" /* Virtual Object Layer */
/****************/
diff --git a/src/H5Fint.c b/src/H5Fint.c
index 1ef5013..056a98b 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -38,7 +38,6 @@
#include "H5SMprivate.h" /* Shared Object Header Messages */
#include "H5Tprivate.h" /* Datatypes */
#include "H5VLprivate.h" /* Virtual Object Layer */
-#include "H5VLnative_private.h" /* Native VOL connector */
/****************/
diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c
index 2d8de99..d029bea 100644
--- a/src/H5Gtraverse.c
+++ b/src/H5Gtraverse.c
@@ -43,7 +43,6 @@
#include "H5MMprivate.h" /* Memory management */
#include "H5Ppublic.h" /* Property Lists */
#include "H5WBprivate.h" /* Wrapped Buffers */
-#include "H5VLnative_private.h" /* Native VOL driver */
/****************/
diff --git a/src/H5L.c b/src/H5L.c
index 9c14fce..9506e7d 100644
--- a/src/H5L.c
+++ b/src/H5L.c
@@ -34,7 +34,6 @@
#include "H5Oprivate.h" /* File objects */
#include "H5Pprivate.h" /* Property lists */
#include "H5VLprivate.h" /* Virtual Object Layer */
-#include "H5VLnative_private.h" /* Native VOL connector */
/****************/
diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c
index 73f7b89..0f3296f 100644
--- a/src/H5Lexternal.c
+++ b/src/H5Lexternal.c
@@ -34,7 +34,6 @@
#include "H5Opublic.h" /* File objects */
#include "H5Pprivate.h" /* Property lists */
#include "H5VLprivate.h" /* Virtual Object Layer */
-#include "H5VLnative_private.h" /* Native VOL connector */
/****************/
diff --git a/src/H5Oint.c b/src/H5Oint.c
index 059a8a8..52290f2 100644
--- a/src/H5Oint.c
+++ b/src/H5Oint.c
@@ -43,7 +43,6 @@
#endif /* H5O_ENABLE_BOGUS */
#include "H5Opkg.h" /* Object headers */
#include "H5VLprivate.h" /* Virtual Object Layer */
-#include "H5VLnative_private.h" /* Native VOL driver */
/****************/
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index e802e3b..923c792 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -41,15 +41,15 @@
#include "H5Ppkg.h" /* Property lists */
#include "H5VLprivate.h" /* Virtual Object Layer */
-/* Includes needed to set as default file driver */
+/* Includes needed to set default file driver */
#include "H5FDsec2.h" /* POSIX unbuffered I/O */
#include "H5FDstdio.h" /* Standard C buffered I/O */
#ifdef H5_HAVE_WINDOWS
#include "H5FDwindows.h" /* Win32 I/O */
#endif
-/* Includes needed to set the default VOL connector */
-#include "H5VLnative_private.h" /* Native VOL connector */
+/* Includes needed to set default VOL connector */
+#include "H5VLnative.h" /* Native VOL connector */
/****************/
diff --git a/src/H5VLnative.c b/src/H5VLnative.c
index 6c51d95..3fc1a7c 100644
--- a/src/H5VLnative.c
+++ b/src/H5VLnative.c
@@ -41,7 +41,7 @@
#include "H5SMprivate.h" /* Shared Object Header Messages */
#include "H5Tpkg.h" /* Datatypes */
#include "H5VLprivate.h" /* Virtual Object Layer */
-#include "H5VLnative_private.h" /* Native VOL connector */
+#include "H5VLnative.h" /* Native VOL connector */
/*
* The VOL connector identification number.
@@ -208,10 +208,9 @@ static H5VL_class_t H5VL_native_cls_g = {
/*-------------------------------------------------------------------------
- * Function: H5VL_native_init
+ * Function: H5VL_native_register
*
- * Purpose: Initialize this VOL connector by registering it with the
- * library.
+ * Purpose: Register the native VOL connector and retrieve an ID for it.
*
* Return: Success: The ID for the native connector
* Failure: H5I_INVALID_HID
@@ -219,7 +218,7 @@ static H5VL_class_t H5VL_native_cls_g = {
*-------------------------------------------------------------------------
*/
hid_t
-H5VL_native_init(hid_t vipl_id)
+H5VL_native_register(void)
{
hid_t ret_value = H5I_INVALID_HID; /* Return value */
@@ -227,7 +226,7 @@ H5VL_native_init(hid_t vipl_id)
/* Register the native VOL connector, if it isn't already */
if(NULL == H5I_object_verify(H5VL_NATIVE_ID_g, H5I_VOL))
- if((H5VL_NATIVE_ID_g = H5VL_register_connector((const H5VL_class_t *)&H5VL_native_cls_g, TRUE, vipl_id)) < 0)
+ if((H5VL_NATIVE_ID_g = H5VL_register_connector((const H5VL_class_t *)&H5VL_native_cls_g, TRUE, H5P_DEFAULT)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTINSERT, H5I_INVALID_HID, "can't create ID for native VOL connector")
/* Set return value */
@@ -235,7 +234,7 @@ H5VL_native_init(hid_t vipl_id)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5VL_native_init() */
+} /* end H5VL_native_register() */
/*---------------------------------------------------------------------------
@@ -252,7 +251,7 @@ H5VL__native_term(void)
{
FUNC_ENTER_STATIC_NOERR
- /* Reset VFL ID */
+ /* Reset VOL ID */
H5VL_NATIVE_ID_g = H5I_INVALID_HID;
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -260,35 +259,6 @@ H5VL__native_term(void)
/*-------------------------------------------------------------------------
- * Function: H5Pset_fapl_native
- *
- * Purpose: Modify the file access property list to use the H5VL_NATIVE
- * connector defined in this source file.
- *
- * Return: SUCCEED/FAIL
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5Pset_fapl_native(hid_t fapl_id)
-{
- H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value;
-
- FUNC_ENTER_API(FAIL)
- H5TRACE1("e", "i", 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_vol(plist, H5VL_NATIVE_ID_g, NULL);
-
-done:
- FUNC_LEAVE_API(ret_value)
-} /* end H5Pset_fapl_native() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5VL__native_attr_create
*
* Purpose: Creates an attribute on an object.
diff --git a/src/H5VLnative.h b/src/H5VLnative.h
index af4ea59..8ae3a66 100644
--- a/src/H5VLnative.h
+++ b/src/H5VLnative.h
@@ -17,6 +17,9 @@
#ifndef _H5VLnative_H
#define _H5VLnative_H
+/* Identifier for the native VOL connector */
+#define H5VL_NATIVE (H5VL_native_register())
+
/* Characteristics of the native VOL connector */
#define H5VL_NATIVE_NAME "native"
#define H5VL_NATIVE_VALUE H5_VOL_NATIVE /* enum value */
@@ -27,7 +30,8 @@
extern "C" {
#endif
-H5_DLL herr_t H5Pset_fapl_native(hid_t fapl_id);
+H5_DLL hid_t H5VL_native_register(void);
+
#ifdef __cplusplus
}
diff --git a/src/H5VLnative_private.h b/src/H5VLnative_private.h
deleted file mode 100644
index 559c8aa..0000000
--- a/src/H5VLnative_private.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * 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://support.hdfgroup.org/ftp/HDF5/releases. *
- * If you do not have access to either file, you may request a copy from *
- * help@hdfgroup.org. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/*
- * Purpose: The private header file for the native VOL connector.
- */
-
-#ifndef _H5VLnative_private_H
-#define _H5VLnative_private_H
-
-/* Include connector's public header */
-#include "H5VLnative.h"
-
-/* Initializer function for native VOL connector */
-#define H5VL_NATIVE (H5VL_native_init(H5P_DEFAULT))
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-H5_DLL hid_t H5VL_native_init(hid_t vipl_id);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _H5VLnative_private_H */
diff --git a/src/H5VLpassthru.c b/src/H5VLpassthru.c
index 3181834..f8568de 100644
--- a/src/H5VLpassthru.c
+++ b/src/H5VLpassthru.c
@@ -237,7 +237,7 @@ static const H5VL_class_t H5VL_pass_through_g = {
};
/* The connector identification number, initialized at runtime */
-static hid_t H5VL_PASSTHRU_g = 0;
+static hid_t H5VL_PASSTHRU_g = H5I_INVALID_HID;
/*-------------------------------------------------------------------------
@@ -315,7 +315,7 @@ H5VL_pass_through_term(void)
#endif
/* Reset VOL ID */
- H5VL_PASSTHRU_g = 0;
+ H5VL_PASSTHRU_g = H5I_INVALID_HID;
return(0);
} /* end H5VL_pass_through_term() */
@@ -462,7 +462,7 @@ H5VL_pass_through_info_to_str(const void *_info, char **str)
assert(*str);
/* Encode our info */
- snprintf(*str, 32 + under_vol_str_len, "under_val=%u, under_info={%s}", (unsigned)under_value, (under_vol_string ? under_vol_string : ""));
+ snprintf(*str, 32 + under_vol_str_len, "under_val=%u;under_info={%s}", (unsigned)under_value, (under_vol_string ? under_vol_string : ""));
return(0);
} /* end H5VL_pass_through_info_to_str() */
@@ -492,7 +492,7 @@ H5VL_pass_through_str_to_info(const char *str, void **_info)
#endif
/* Retrieve the underlying VOL connector value and info */
- sscanf(str, "under_vol=%u,", &under_vol_value);
+ sscanf(str, "under_vol=%u;", &under_vol_value);
under_vol_id = H5VLregister_connector_by_value((H5VL_class_value_t)under_vol_value, H5P_DEFAULT);
under_vol_info_start = strchr(str, '{');
under_vol_info_end = strrchr(str, '}');
diff --git a/test/h5test.c b/test/h5test.c
index 3c02e4e..0453162 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -792,8 +792,8 @@ h5_rmprefix(const char *filename)
* Function: h5_fileaccess
*
* Purpose: Returns a file access template which is the default template
- * but with a file driver set according to the constant or
- * environment variable HDF5_DRIVER
+ * but with a file driver, VOL connector, or libver bound set
+ * according to a constant or environment variable
*
* Return: Success: A file access property list
* Failure: -1
@@ -806,135 +806,34 @@ h5_rmprefix(const char *filename)
hid_t
h5_fileaccess(void)
{
- const char *val = NULL;
- const char *name;
- char s[1024];
hid_t fapl = -1;
- /* First use the environment variable, then the constant */
- val = HDgetenv("HDF5_DRIVER");
-#ifdef HDF5_DRIVER
- if(!val)
- val = HDF5_DRIVER;
-#endif
-
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
return -1;
- if(!val || !*val)
- return fapl; /* use default */
-
- HDstrncpy(s, val, sizeof s);
- s[sizeof(s)-1] = '\0';
- if(NULL == (name = HDstrtok(s, " \t\n\r")))
- return fapl;
-
- if(!HDstrcmp(name, "sec2")) {
- /* Unix read() and write() system calls */
- if (H5Pset_fapl_sec2(fapl) < 0)
- return -1;
- }
- else if(!HDstrcmp(name, "stdio")) {
- /* Standard C fread() and fwrite() system calls */
- if (H5Pset_fapl_stdio(fapl) < 0)
- return -1;
- }
- else if(!HDstrcmp(name, "core")) {
- /* In-memory driver settings (backing store on, 1 MB increment) */
- if(H5Pset_fapl_core(fapl, (size_t)1, TRUE) < 0)
- return -1;
- }
- else if(!HDstrcmp(name, "core_paged")) {
- /* In-memory driver with write tracking and paging on */
- if(H5Pset_fapl_core(fapl, (size_t)1, TRUE) < 0)
- return -1;
- if(H5Pset_core_write_tracking(fapl, TRUE, (size_t)4096) < 0)
- return -1;
- }
- else if(!HDstrcmp(name, "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)
- return -1;
- }
- else if(!HDstrcmp(name, "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; H5_INC_ENUM(H5FD_mem_t, mt)) {
- memb_fapl[mt] = H5P_DEFAULT;
- if(NULL == (sv[mt] = (char *)HDmalloc(H5TEST_MULTI_FILENAME_LEN)))
- return -1;
- 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)
- return -1;
+ /* Attempt to set up a file driver first */
+ if(h5_get_vfd_fapl(fapl) < 0)
+ return -1;
- for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt))
- HDfree(sv[mt]);
- }
- else if(!HDstrcmp(name, "family")) {
- hsize_t fam_size = 100*1024*1024; /*100 MB*/
-
- /* Family of files, each 1MB and using the default driver */
- if((val = HDstrtok(NULL, " \t\n\r")))
- fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024);
- if(H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0)
- return -1;
- }
- else if(!HDstrcmp(name, "log")) {
- unsigned log_flags = H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC;
-
- /* Log file access */
- if((val = HDstrtok(NULL, " \t\n\r")))
- log_flags = (unsigned)HDstrtol(val, NULL, 0);
- if(H5Pset_fapl_log(fapl, NULL, log_flags, (size_t)0) < 0)
- return -1;
- }
- else if(!HDstrcmp(name, "direct")) {
-#ifdef H5_HAVE_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)
- return -1;
-#endif
- }
- else if(!HDstrcmp(name, "latest")) {
- /* use the latest format */
- if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
- return -1;
- }
- else {
- /* Unknown driver */
+ /* Next, try to set up a VOL connector */
+ if(h5_get_vol_fapl(fapl) < 0)
return -1;
- }
-
- return fapl;
-}
+
+ /* Finally, check for libver bounds */
+ if(h5_get_libver_fapl(fapl) < 0)
+ return -1;
+
+ return(fapl);
+} /* end h5_fileaccess() */
/*-------------------------------------------------------------------------
* Function: h5_get_vfd_fapl
*
- * Purpose: Returns a file access property list which is the default
- * fapl but with a file driver set according to the constant or
- * environment variable HDF5_DRIVER.
+ * Purpose: Sets the file driver for a FAPL according to the value specified
+ * in the constant or environment variable "HDF5_DRIVER".
*
- * Return: Success: A file access property list ID
+ * Return: Success: 0
* Failure: -1
*
* Programmer: Dana Robinson
@@ -942,60 +841,58 @@ h5_fileaccess(void)
*
*-------------------------------------------------------------------------
*/
-hid_t
-h5_get_vfd_fapl(void)
+herr_t
+h5_get_vfd_fapl(hid_t fapl)
{
const char *env = NULL; /* HDF5_DRIVER environment variable */
const char *tok = NULL; /* strtok pointer */
char buf[1024]; /* buffer for tokenizing HDF5_DRIVER */
- hid_t fapl = -1; /* fapl to be returned */
/* Get the environment variable, if it exists */
env = HDgetenv("HDF5_DRIVER");
-
- /* Create a default fapl */
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- return -1;
+#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
- * the default fapl.
+ * without modifying the FAPL.
*/
if(!env || !*env)
- return fapl;
+ 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));
- HDmemset(buf, 0, sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
if(NULL == (tok = HDstrtok(buf, " \t\n\r")))
- return fapl;
+ goto done;
if(!HDstrcmp(tok, "sec2")) {
/* POSIX (section 2) read() and write() system calls */
if(H5Pset_fapl_sec2(fapl) < 0)
- return -1;
+ goto error;
} else if(!HDstrcmp(tok, "stdio")) {
/* Standard C fread() and fwrite() system calls */
if(H5Pset_fapl_stdio(fapl) < 0)
- return -1;
+ goto error;
} else if(!HDstrcmp(tok, "core")) {
/* In-memory driver settings (backing store on, 1 MB increment) */
if(H5Pset_fapl_core(fapl, (size_t)1, TRUE) < 0)
- return -1;
+ goto error;
} else if(!HDstrcmp(tok, "core_paged")) {
/* In-memory driver with write tracking and paging on */
if(H5Pset_fapl_core(fapl, (size_t)1, TRUE) < 0)
- return -1;
+ goto error;
if(H5Pset_core_write_tracking(fapl, TRUE, (size_t)4096) < 0)
- return -1;
+ 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)
- return -1;
+ 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];
@@ -1021,19 +918,19 @@ h5_get_vfd_fapl(void)
} /* end for */
if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0)
- return -1;
+ goto error;
for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, 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*/
+ hsize_t fam_size = 100 * 1024 * 1024; /* 100 MB */
/* Was a family size specified in the environment variable? */
if((tok = HDstrtok(NULL, " \t\n\r")))
- fam_size = (hsize_t)(HDstrtod(tok, NULL) * 1024*1024);
+ fam_size = (hsize_t)(HDstrtod(tok, NULL) * 1024 * 1024);
if(H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT) < 0)
- return -1;
+ goto error;
} else if(!HDstrcmp(tok, "log")) {
/* Log file access */
unsigned log_flags = H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC;
@@ -1043,25 +940,194 @@ h5_get_vfd_fapl(void)
log_flags = (unsigned)HDstrtol(tok, NULL, 0);
if(H5Pset_fapl_log(fapl, NULL, log_flags, (size_t)0) < 0)
- return -1;
+ 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)
- return -1;
+ if(H5Pset_fapl_direct(fapl, 1024, 4096, 8 * 4096) < 0)
+ goto error;
#endif
} else {
/* Unknown driver */
- return -1;
+ goto error;
} /* end if */
- return fapl;
+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
+ * value in the constant or environment variable "HDF5_LIBVER_BOUNDS".
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * November 2018
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+h5_get_libver_fapl(hid_t fapl)
+{
+ const char *env = NULL; /* HDF5_DRIVER environment variable */
+ const char *tok = NULL; /* strtok pointer */
+ char buf[1024]; /* buffer for tokenizing HDF5_DRIVER */
+
+ /* Get the environment variable, if it exists */
+ env = HDgetenv("HDF5_LIBVER_BOUNDS");
+#ifdef HDF5_LIBVER_BOUNDS
+ /* Use the environment variable, then the compile-time constant */
+ if(!env)
+ env = HDF5_LIBVER_BOUNDS;
+#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(buf, " \t\n\r")))
+ goto done;
+
+ if(!HDstrcmp(tok, "latest")) {
+ /* use the latest format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ goto error;
+ } /* end if */
+ else {
+ /* Unknown setting */
+ goto error;
+ } /* end else */
+
+done:
+ return 0;
+
+error:
+ return -1;
+} /* end h5_get_vfd_fapl() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: h5_get_vol_fapl
+ *
+ * Purpose: Returns a file access property list which is the default
+ * fapl but with a VOL connector set according to the constant
+ * or environment variable HDF5_VOL_CONNECTOR.
+ *
+ * Return: Success: A file access property list ID
+ * Failure: -1
+ *
+ * Programmer: Jordan Henderson
+ * November 2018
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+h5_get_vol_fapl(hid_t fapl)
+{
+ const char *env = NULL;
+ const char *tok = NULL;
+ htri_t connector_is_registered;
+ char buf[1024]; /* Buffer for tokenizing HDF5_VOL_CONNECTOR */
+ void *vol_info = NULL; /* VOL connector info */
+ hid_t connector_id = -1;
+
+ /* Get the environment variable, if it exists */
+ env = HDgetenv("HDF5_VOL_CONNECTOR");
+#ifdef HDF5_VOL_CONNECTOR
+ /* Use the environment variable, then the compile-time constant */
+ if(!env)
+ env = HDF5_VOL_CONNECTOR;
+#endif
+
+ /* If the environment variable was not set, just return. */
+ if(!env || !*env)
+ goto done;
+
+ /* Get the first 'word' of the environment variable.
+ * If it's nothing (environment variable was whitespace) just return.
+ */
+ HDstrncpy(buf, env, sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ if(NULL == (tok = HDstrtok(buf, " \t\n\r")))
+ goto done;
+
+ /* First, check to see if the connector is already registered */
+ if((connector_is_registered = H5VLis_connector_registered(tok)) < 0)
+ goto done;
+ else if(connector_is_registered) {
+ /* Retrieve the ID of the already-registered VOL connector */
+ if((connector_id = H5VLget_connector_id(tok)) < 0)
+ goto error;
+ } /* end else-if */
+ else {
+ /* Check for VOL connectors that ship with the library */
+ if(!HDstrcmp(tok, "native")) {
+ connector_id = H5VL_NATIVE;
+ if(H5Iinc_ref(connector_id) < 0)
+ goto error;
+ } else if(!HDstrcmp(tok, "pass_through")) {
+ connector_id = H5VL_PASSTHRU;
+ if(H5Iinc_ref(connector_id) < 0)
+ goto error;
+ } else {
+ /* Register the VOL connector */
+ /* (NOTE: No provisions for vipl_id currently) */
+ if((connector_id = H5VLregister_connector_by_name(tok, H5P_DEFAULT)) < 0)
+ goto error;
+ } /* end else */
+ } /* end else */
+
+ /* Was there any connector info specified in the environment variable? */
+ if(NULL != (tok = HDstrtok(NULL, " \t\n\r")))
+ if(H5VLconnector_str_to_info(tok, connector_id, &vol_info) < 0)
+ goto error;
+
+ /* Set the VOL connector in the FAPL */
+ if(H5Pset_vol(fapl, connector_id, vol_info) < 0)
+ goto error;
+
+ /* Release VOL connector info, if there was any */
+ if(vol_info)
+ if(H5VLfree_connector_info(connector_id, vol_info) < 0)
+ goto error;
+
+ /* Close the connector ID */
+ if(connector_id >= 0)
+ if(H5VLunregister_connector(connector_id) < 0)
+ goto error;
+
+done:
+ return 0;
+
+error:
+ if(vol_info)
+ H5VLfree_connector_info(connector_id, vol_info);
+ if(connector_id >= 0)
+ H5VLunregister_connector(connector_id);
+
+ return -1;
+} /* end h5_get_vol_fapl() */
+
+
+/*-------------------------------------------------------------------------
* Function: h5_no_hwconv
*
* Purpose: Turn off hardware data type conversions.
diff --git a/test/h5test.h b/test/h5test.h
index 2fb0e0c..c72f389 100644
--- a/test/h5test.h
+++ b/test/h5test.h
@@ -144,12 +144,10 @@ H5TEST_DLL herr_t h5_verify_cached_stabs(const char *base_name[], hid_t fapl);
H5TEST_DLL H5FD_class_t *h5_get_dummy_vfd_class(void);
H5TEST_DLL H5VL_class_t *h5_get_dummy_vol_class(void);
-/* Functions that will replace VFD-dependent functions that violate
- * the single responsibility principle. Unlike their predecessors,
- * these new functions do not have hidden side effects.
- */
-/* h5_fileaccess() replacement */
-H5TEST_DLL hid_t h5_get_vfd_fapl(void);
+/* 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_vol_fapl(hid_t fapl_id);
+H5TEST_DLL herr_t h5_get_libver_fapl(hid_t fapl_id);
/* h5_clean_files() replacements */
H5TEST_DLL void h5_delete_test_file(const char *base_name, hid_t fapl);
diff --git a/test/vol.c b/test/vol.c
index 357fa45..177c5b8 100644
--- a/test/vol.c
+++ b/test/vol.c
@@ -19,7 +19,6 @@
*/
#include "h5test.h"
-#include "H5VLnative_private.h"
#define NATIVE_VOL_TEST_FILENAME "native_vol_test"