diff options
author | jhendersonHDF <jhenderson@hdfgroup.org> | 2023-05-26 20:29:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-26 20:29:02 (GMT) |
commit | 79bb60c3f6f67411e5d70b84743fc9f6b6143cbc (patch) | |
tree | dce0c97c567cb20eeb65de917e21347376979f18 /test/API/H5_api_test.c | |
parent | 77e64e0df46bb7498be014b1005efd49c4ad7518 (diff) | |
download | hdf5-79bb60c3f6f67411e5d70b84743fc9f6b6143cbc.zip hdf5-79bb60c3f6f67411e5d70b84743fc9f6b6143cbc.tar.gz hdf5-79bb60c3f6f67411e5d70b84743fc9f6b6143cbc.tar.bz2 |
API test updates (#3018)
* Remove macros from api tests (#2929)
* Remove macros and undefined callbacks (#2959)
* Remove remaining macros from H5_api_tests_disabled.h (#2968)
* Put some vol capability checks in testpar tests and remove remaining warnings (#2995)
* API tests datatype generation cleanup
* Clean up API tests' random datatype generation and fix bug with enum
datatype generation
* Init parallel API tests with MPI_THREAD_MULTIPLE
* HDF5 API tests - Check VOL connector registration
* Determine whether a VOL connector failed to load before running API
tests
* Cleanup some usages of H5VL_CAP_FLAG_CREATION_ORDER in API tests
* Remove some now-unused macros from H5_api_tests_disabled.h
* Enable HDF5 API tests by default
* Implement CMake option to install HDF5 API tests
* Check for invalid AAPL from H5Acreate
* Enable building of VOL connectors alongside HDF5 in CMake
* Prepend CMake VOL URL option indices with 0s so they come in order
* Don't turn on API tests by default yet
* Document VOL connector FetchContent functionality
* Add release note for API test updates
* Only install testing library if API tests are installed
* Fix grammar
Diffstat (limited to 'test/API/H5_api_test.c')
-rw-r--r-- | test/API/H5_api_test.c | 104 |
1 files changed, 96 insertions, 8 deletions
diff --git a/test/API/H5_api_test.c b/test/API/H5_api_test.c index 6d61b75..3719524 100644 --- a/test/API/H5_api_test.c +++ b/test/API/H5_api_test.c @@ -116,10 +116,15 @@ H5_api_test_run(void) int main(int argc, char **argv) { + const char *vol_connector_string; const char *vol_connector_name; unsigned seed; - hid_t fapl_id = H5I_INVALID_HID; - hbool_t err_occurred = FALSE; + hid_t fapl_id = H5I_INVALID_HID; + hid_t default_con_id = H5I_INVALID_HID; + hid_t registered_con_id = H5I_INVALID_HID; + char *vol_connector_string_copy = NULL; + char *vol_connector_info = NULL; + hbool_t err_occurred = FALSE; /* Simple argument checking, TODO can improve that later */ if (argc > 1) { @@ -140,7 +145,7 @@ main(int argc, char **argv) MPI_Init(&argc, &argv); #endif - /* h5_reset(); */ + H5open(); n_tests_run_g = 0; n_tests_passed_g = 0; @@ -156,26 +161,97 @@ main(int argc, char **argv) HDsnprintf(H5_api_test_filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s", test_path_prefix, TEST_FILE_NAME); - if (NULL == (vol_connector_name = HDgetenv(HDF5_VOL_CONNECTOR))) { + if (NULL == (vol_connector_string = HDgetenv(HDF5_VOL_CONNECTOR))) { HDprintf("No VOL connector selected; using native VOL connector\n"); vol_connector_name = "native"; + vol_connector_info = NULL; } + else { + char *token; - HDprintf("Running API tests with VOL connector '%s'\n\n", vol_connector_name); + if (NULL == (vol_connector_string_copy = HDstrdup(vol_connector_string))) { + HDfprintf(stderr, "Unable to copy VOL connector string\n"); + err_occurred = TRUE; + goto done; + } + + if (NULL == (token = HDstrtok(vol_connector_string_copy, " "))) { + HDfprintf(stderr, "Error while parsing VOL connector string\n"); + err_occurred = TRUE; + goto done; + } + + vol_connector_name = token; + + if (NULL != (token = HDstrtok(NULL, " "))) { + vol_connector_info = token; + } + } + + HDprintf("Running API tests with VOL connector '%s' and info string '%s'\n\n", vol_connector_name, + vol_connector_info ? vol_connector_info : ""); HDprintf("Test parameters:\n"); HDprintf(" - Test file name: '%s'\n", H5_api_test_filename); HDprintf(" - Test seed: %u\n", seed); HDprintf("\n\n"); - /* Retrieve the VOL cap flags - work around an HDF5 - * library issue by creating a FAPL - */ if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) { HDfprintf(stderr, "Unable to create FAPL\n"); err_occurred = TRUE; goto done; } + /* + * If using a VOL connector other than the native + * connector, check whether the VOL connector was + * successfully registered before running the tests. + * Otherwise, HDF5 will default to running the tests + * with the native connector, which could be misleading. + */ + if (0 != HDstrcmp(vol_connector_name, "native")) { + htri_t is_registered; + + if ((is_registered = H5VLis_connector_registered_by_name(vol_connector_name)) < 0) { + HDfprintf(stderr, "Unable to determine if VOL connector is registered\n"); + err_occurred = TRUE; + goto done; + } + + if (!is_registered) { + HDfprintf(stderr, "Specified VOL connector '%s' wasn't correctly registered!\n", + vol_connector_name); + err_occurred = TRUE; + goto done; + } + else { + /* + * If the connector was successfully registered, check that + * the connector ID set on the default FAPL matches the ID + * for the registered connector before running the tests. + */ + if (H5Pget_vol_id(fapl_id, &default_con_id) < 0) { + HDfprintf(stderr, "Couldn't retrieve ID of VOL connector set on default FAPL\n"); + err_occurred = TRUE; + goto done; + } + + if ((registered_con_id = H5VLget_connector_id_by_name(vol_connector_name)) < 0) { + HDfprintf(stderr, "Couldn't retrieve ID of registered VOL connector\n"); + err_occurred = TRUE; + goto done; + } + + if (default_con_id != registered_con_id) { + HDfprintf(stderr, "VOL connector set on default FAPL didn't match specified VOL connector\n"); + err_occurred = TRUE; + goto done; + } + } + } + + /* Retrieve the VOL cap flags - work around an HDF5 + * library issue by creating a FAPL + */ vol_cap_flags_g = H5VL_CAP_FLAG_NONE; if (H5Pget_vol_cap_flags(fapl_id, &vol_cap_flags_g) < 0) { HDfprintf(stderr, "Unable to retrieve VOL connector capability flags\n"); @@ -212,6 +288,18 @@ main(int argc, char **argv) } done: + HDfree(vol_connector_string_copy); + + if (default_con_id >= 0 && H5VLclose(default_con_id) < 0) { + HDfprintf(stderr, "Unable to close VOL connector ID\n"); + err_occurred = TRUE; + } + + if (registered_con_id >= 0 && H5VLclose(registered_con_id) < 0) { + HDfprintf(stderr, "Unable to close VOL connector ID\n"); + err_occurred = TRUE; + } + if (fapl_id >= 0 && H5Pclose(fapl_id) < 0) { HDfprintf(stderr, "Unable to close FAPL\n"); err_occurred = TRUE; |