mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-03-25 17:00:45 +08:00
Make sure plugin interface is initialized before property list interface phase 2 (#1216)
This commit is contained in:
parent
3a2b3bb035
commit
3f2271364e
2
src/H5.c
2
src/H5.c
@ -29,6 +29,7 @@
|
||||
#include "H5Lprivate.h" /* Links */
|
||||
#include "H5MMprivate.h" /* Memory management */
|
||||
#include "H5Pprivate.h" /* Property lists */
|
||||
#include "H5PLprivate.h" /* Plugins */
|
||||
#include "H5SLprivate.h" /* Skip lists */
|
||||
#include "H5Tprivate.h" /* Datatypes */
|
||||
|
||||
@ -273,6 +274,7 @@ H5_init_library(void)
|
||||
, {H5AC_init, "metadata caching"}
|
||||
, {H5L_init, "link"}
|
||||
, {H5S_init, "dataspace"}
|
||||
, {H5PL_init, "plugins"}
|
||||
/* Finish initializing interfaces that depend on the interfaces above */
|
||||
, {H5P_init_phase2, "property list"}
|
||||
, {H5VL_init_phase2, "VOL"}
|
||||
|
@ -191,7 +191,6 @@ H5VL_init_phase2(void)
|
||||
, {H5CX_init, "context"}
|
||||
, {H5ES_init, "event set"}
|
||||
, {H5Z_init, "transform"}
|
||||
, {H5PL_init, "plugin"}
|
||||
, {H5R_init, "reference"}
|
||||
};
|
||||
|
||||
|
@ -313,8 +313,53 @@ test_get_config_str(void)
|
||||
if (H5Pclose(fapl_id) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
PASSED();
|
||||
|
||||
return SUCCEED;
|
||||
|
||||
error:
|
||||
H5E_BEGIN_TRY
|
||||
{
|
||||
H5Pclose(fapl_id);
|
||||
}
|
||||
H5E_END_TRY;
|
||||
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: test_env_var
|
||||
*
|
||||
* Purpose: Tests loading of NULL VFD plugin with HDF5_DRIVER
|
||||
* environment variable and setting of VFD configuration
|
||||
* string with HDF5_DRIVER_CONFIG environment variable
|
||||
*
|
||||
* Return: EXIT_SUCCESS/EXIT_FAILURE
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
test_env_var(void)
|
||||
{
|
||||
const char *const config_str = "{name: null}";
|
||||
ssize_t config_str_len = 0;
|
||||
htri_t driver_is_registered;
|
||||
char config_str_buf[128];
|
||||
|
||||
TESTING("Loading of VFD plugin with HDF5_DRIVER environment variable");
|
||||
|
||||
/* 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(H5P_FILE_ACCESS_DEFAULT, config_str_buf, 128)) < 0)
|
||||
TEST_ERROR;
|
||||
if (0 != config_str_len)
|
||||
TEST_ERROR;
|
||||
if (HDstrlen(config_str_buf) > 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Set default driver and driver configuration using environment variables */
|
||||
if (HDsetenv(HDF5_DRIVER, "sec2", 1) < 0)
|
||||
if (HDsetenv(HDF5_DRIVER, "null_vfd_plugin", 1) < 0)
|
||||
TEST_ERROR;
|
||||
if (HDsetenv(HDF5_DRIVER_CONFIG, config_str, 1) < 0)
|
||||
TEST_ERROR;
|
||||
@ -325,7 +370,15 @@ test_get_config_str(void)
|
||||
if (H5open() < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Retrieve configuration string from default FAPL */
|
||||
/* Check driver */
|
||||
if ((driver_is_registered = H5FDis_driver_registered_by_name("null_vfd_plugin")) < 0)
|
||||
TEST_ERROR;
|
||||
if (!driver_is_registered)
|
||||
TEST_ERROR;
|
||||
if (H5Pget_driver(H5P_FILE_ACCESS_DEFAULT) == H5_DEFAULT_VFD)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Check driver configuration string */
|
||||
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;
|
||||
@ -345,11 +398,8 @@ test_get_config_str(void)
|
||||
return SUCCEED;
|
||||
|
||||
error:
|
||||
H5E_BEGIN_TRY
|
||||
{
|
||||
H5Pclose(fapl_id);
|
||||
}
|
||||
H5E_END_TRY;
|
||||
HDsetenv(HDF5_DRIVER, "", 1);
|
||||
HDsetenv(HDF5_DRIVER_CONFIG, "", 1);
|
||||
|
||||
return FAIL;
|
||||
}
|
||||
@ -376,6 +426,7 @@ main(void)
|
||||
nerrors += (test_set_by_value() < 0) ? 1 : 0;
|
||||
nerrors += (test_set_multi() < 0) ? 1 : 0;
|
||||
nerrors += (test_get_config_str() < 0) ? 1 : 0;
|
||||
nerrors += (test_env_var() < 0) ? 1 : 0;
|
||||
|
||||
if (nerrors) {
|
||||
HDprintf("***** %d VFD plugin TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : "");
|
||||
|
Loading…
x
Reference in New Issue
Block a user