From 0b7a7166c6420df5370e73ff22580a5048ddf762 Mon Sep 17 00:00:00 2001 From: Jordan Henderson Date: Fri, 22 Mar 2024 12:59:02 -0500 Subject: [PATCH] Add macro for default VFD name --- src/H5FDtest.c | 5 +++-- src/H5private.h | 3 ++- test/h5test.c | 8 ++++---- test/swmr.c | 2 +- test/vfd_plugin.c | 4 +--- tools/libtest/h5tools_test_utils.c | 8 ++++---- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/H5FDtest.c b/src/H5FDtest.c index f39bb4b183e..2a48fb5b8cd 100644 --- a/src/H5FDtest.c +++ b/src/H5FDtest.c @@ -74,7 +74,8 @@ * This function is only intended for use in the test code. * * Return: true (1) if the VFD supports SWMR I/O or vfd_name is - * NULL or the empty string (which implies the default VFD). + * NULL or the empty string (which implies the default VFD) or + * compares equal to the default VFD's name. * * false (0) if it does not * @@ -92,7 +93,7 @@ H5FD__supports_swmr_test(const char *vfd_name) if (!vfd_name) vfd_name = getenv("HDF5_TEST_DRIVER"); - if (!vfd_name || !strcmp(vfd_name, "")) + if (!vfd_name || !strcmp(vfd_name, "") || !strcmp(vfd_name, H5_DEFAULT_VFD_NAME)) ret_value = true; else ret_value = !strcmp(vfd_name, "log") || !strcmp(vfd_name, "sec2"); diff --git a/src/H5private.h b/src/H5private.h index 8cee9586769..a3b37e5d834 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -110,7 +110,8 @@ * H5_init_library(); also, make sure that the initializer for default * VFD does *not* call H5_init_library(). */ -#define H5_DEFAULT_VFD H5FD_SEC2 +#define H5_DEFAULT_VFD H5FD_SEC2 +#define H5_DEFAULT_VFD_NAME "sec2" /* Define the default VOL driver */ #define H5_DEFAULT_VOL H5VL_NATIVE diff --git a/test/h5test.c b/test/h5test.c index 2465980178c..e921dc85c52 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -783,8 +783,8 @@ h5_fileaccess_flags(unsigned flags) * Function: h5_get_vfd_fapl * * Purpose: Sets the file driver for a FAPL according to the value - * specified in the constant "HDF5_DRIVER" or environment - * variable "HDF5_DRIVER" or "HDF5_TEST_DRIVER". + * specified in the environment variable "HDF5_DRIVER" or + * "HDF5_TEST_DRIVER". * * Return: Non-negative on success/Negative on failure * @@ -2457,7 +2457,7 @@ h5_get_test_driver_name(void) else if ((envval = getenv("HDF5_TEST_DRIVER"))) return envval; else - return "sec2"; + return H5_DEFAULT_VFD_NAME; } /*------------------------------------------------------------------------- @@ -2483,7 +2483,7 @@ h5_using_default_driver(const char *drv_name) drv_name = h5_get_test_driver_name(); if (drv_name) - return !strcmp(drv_name, "sec2"); + return !strcmp(drv_name, H5_DEFAULT_VFD_NAME); return ret_val; } diff --git a/test/swmr.c b/test/swmr.c index 7c48e606bf2..94c98737c59 100644 --- a/test/swmr.c +++ b/test/swmr.c @@ -7828,7 +7828,7 @@ main(void) /* Tests SWMR VFD compatibility flag. * Only needs to run when the VFD is the default (sec2). */ - if (NULL == driver_name || !strcmp(driver_name, "") || !strcmp(driver_name, "sec2")) + if (NULL == driver_name || !strcmp(driver_name, "") || !strcmp(driver_name, H5_DEFAULT_VFD_NAME)) nerrors += test_swmr_vfd_flag(); /* Test multiple opens via different locking flags */ diff --git a/test/vfd_plugin.c b/test/vfd_plugin.c index 8bfc09f07aa..91f8ec50c41 100644 --- a/test/vfd_plugin.c +++ b/test/vfd_plugin.c @@ -19,8 +19,6 @@ #include "null_vfd_plugin.h" -#define DEFAULT_DRIVER_NAME "sec2" - /*------------------------------------------------------------------------- * Function: test_set_by_name() * @@ -301,7 +299,7 @@ test_get_config_str(void) 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) + if (H5Pset_driver_by_name(fapl_id, H5_DEFAULT_VFD_NAME, config_str) < 0) TEST_ERROR; if ((config_str_len = H5Pget_driver_config_str(fapl_id, config_str_buf, 128)) < 0) TEST_ERROR; diff --git a/tools/libtest/h5tools_test_utils.c b/tools/libtest/h5tools_test_utils.c index 32f109b0caf..369472e8d86 100644 --- a/tools/libtest/h5tools_test_utils.c +++ b/tools/libtest/h5tools_test_utils.c @@ -983,28 +983,28 @@ test_set_configured_fapl(void) "(common) H5P_DEFAULT with no struct should succeed", 1, UTIL_TEST_DEFAULT, - "sec2", + H5_DEFAULT_VFD_NAME, NULL, }, { "(common) H5P_DEFAULT with (ignored) struct should succeed", 1, UTIL_TEST_DEFAULT, - "sec2", + H5_DEFAULT_VFD_NAME, &wrong_fa, }, { "(common) provided fapl entry should not fail", 1, UTIL_TEST_CREATE, - "sec2", + H5_DEFAULT_VFD_NAME, NULL, }, { "(common) provided fapl entry should not fail; ignores struct", 1, UTIL_TEST_CREATE, - "sec2", + H5_DEFAULT_VFD_NAME, &wrong_fa, }, {