diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2021-04-16 18:47:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-16 18:47:32 (GMT) |
commit | d5c449248f74886529b9fad09473dd73d60a34fd (patch) | |
tree | ca3495dbf738c1561ad6501920a9d54680251664 /test | |
parent | e21f7aaac4a4d34a8a5aa1330fb2ed6814532cfb (diff) | |
download | hdf5-d5c449248f74886529b9fad09473dd73d60a34fd.zip hdf5-d5c449248f74886529b9fad09473dd73d60a34fd.tar.gz hdf5-d5c449248f74886529b9fad09473dd73d60a34fd.tar.bz2 |
Brings the native implementation of H5Fdelete() from Bitbucket (#524)
* Committing clang-format changes
* Brings the native VFD H5Fdelete() implementation from Bitbucket
Only brings the 'del' callbacks, not the 'open/close' scheme.
* Formatter changes
* Committing clang-format changes
* Fixes direct VFD callback name
* Removes UNUSED macro from family API call
* Adds barrier and rank 0 check to MPI-I/O VFD delete
* Revert "Adds barrier and rank 0 check to MPI-I/O VFD delete"
This reverts commit 909765f759d9d96e84f4b8b1cc14f7d2b3ac8143.
* Revert "Revert "Adds barrier and rank 0 check to MPI-I/O VFD delete""
This reverts commit 9b04bef1157853fc79fcb8fcc3e8ba1371091702.
* Adds a second barrier after the delete in MPI-I/O VFD
* Only delete files in the core VFD when the backing store flag is set
* Fixes string issues in multi VFD
Also, h5test.c cleanup code now uses H5Fdelete().
* Formatted source
* Rework fapl checks for MPI-I/O VFD delete callback
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/cache_logging.c | 16 | ||||
-rw-r--r-- | test/h5test.c | 54 | ||||
-rw-r--r-- | test/tfile.c | 21 | ||||
-rw-r--r-- | test/vfd.c | 34 |
4 files changed, 60 insertions, 65 deletions
diff --git a/test/cache_logging.c b/test/cache_logging.c index 448e12b..93d4505 100644 --- a/test/cache_logging.c +++ b/test/cache_logging.c @@ -16,7 +16,8 @@ #include "h5test.h" #define LOG_LOCATION "cache_logging.out" -#define FILE_NAME "cache_logging" + +const char *FILENAME[] = {"cache_logging", NULL}; #define N_GROUPS 100 @@ -50,7 +51,7 @@ test_logging_api(void) TESTING("metadata cache log api calls"); fapl = h5_fileaccess(); - h5_fixname(FILE_NAME, fapl, filename, sizeof filename); + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); /* Set up metadata cache logging */ is_enabled = TRUE; @@ -84,8 +85,6 @@ test_logging_api(void) TEST_ERROR; if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; - if (H5Pclose(fapl) < 0) - TEST_ERROR; /* Check to see if the logging flags were set correctly */ is_enabled = FALSE; @@ -127,10 +126,19 @@ test_logging_api(void) if (H5Fclose(fid) < 0) TEST_ERROR; + HDremove(LOG_LOCATION); + h5_clean_files(FILENAME, fapl); + PASSED(); return 0; error: + H5E_BEGIN_TRY + { + H5Pclose(fapl); + } + H5E_END_TRY + return 1; } /* test_logging_api() */ diff --git a/test/h5test.c b/test/h5test.c index 64eb784..2a54982 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -190,65 +190,22 @@ h5_clean_files(const char *base_name[], hid_t fapl) * *------------------------------------------------------------------------- */ -/* Disable warning for "format not a string literal" here -QAK */ -/* - * This pragma only needs to surround the snprintf() calls with - * sub_filename in the code below, but early (4.4.7, at least) gcc only - * allows diagnostic pragmas to be toggled outside of functions. - */ -H5_GCC_DIAG_OFF("format-nonliteral") void h5_delete_test_file(const char *base_name, hid_t fapl) { - char filename[1024]; /* VFD-dependent filename to delete */ - char sub_filename[2048]; /* sub-files in multi & family VFDs */ - hid_t driver = -1; /* VFD ID */ + char filename[1024]; /* VFD-dependent filename to delete */ /* Get the VFD-dependent filename */ if (NULL == h5_fixname(base_name, fapl, filename, sizeof(filename))) return; - driver = H5Pget_driver(fapl); - - if (driver == H5FD_FAMILY) { - int j; - for (j = 0; /*void*/; j++) { - HDsnprintf(sub_filename, sizeof(sub_filename), filename, j); - - /* If we can't access the file, it probably doesn't exist - * and we are done deleting the sub-files. - */ - if (HDaccess(sub_filename, F_OK) < 0) - break; - - HDremove(sub_filename); - } /* end for */ - } - else if (driver == H5FD_CORE) { - hbool_t backing; /* Whether the core file has backing store */ - - H5Pget_fapl_core(fapl, NULL, &backing); - - /* If the file was stored to disk with bacing store, remove it */ - if (backing) - HDremove(filename); - } - else if (driver == H5FD_MULTI) { - H5FD_mem_t mt; - - HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES); - - for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { - HDsnprintf(sub_filename, sizeof(sub_filename), "%s-%c.h5", filename, multi_letters[mt]); - HDremove(sub_filename); - } + H5E_BEGIN_TRY + { + H5Fdelete(filename, fapl); } - else { - HDremove(filename); - } /* end driver selection tree */ + H5E_END_TRY; } /* end h5_delete_test_file() */ -H5_GCC_DIAG_ON("format-nonliteral") /*------------------------------------------------------------------------- * Function: h5_delete_all_test_files @@ -1963,6 +1920,7 @@ static const H5FD_class_t H5FD_dummy_g = { NULL, /* truncate */ NULL, /* lock */ NULL, /* unlock */ + NULL, /* del */ H5FD_FLMAP_DICHOTOMY /* fl_map */ }; diff --git a/test/tfile.c b/test/tfile.c index 1861291..6a52392 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1918,10 +1918,6 @@ test_file_delete(hid_t fapl_id) /* HDF5 FILE */ /*************/ - /* This is just a placeholder until the native VOL connector supports - * H5Fdelete(). - */ - /* Get fapl-dependent filename */ h5_fixname(FILE_DELETE, fapl_id, filename, sizeof(filename)); @@ -1937,19 +1933,20 @@ test_file_delete(hid_t fapl_id) is_hdf5 = H5Fis_accessible(filename, fapl_id); VERIFY(is_hdf5, TRUE, "H5Fis_accessible"); - /* Attempt to delete the file - should fail */ + /* Delete the file */ + ret = H5Fdelete(filename, fapl_id); + VERIFY(ret, SUCCEED, "H5Fdelete"); + + /* Verify that the file is NO LONGER an HDF5 file */ + /* This should fail since there is no file */ H5E_BEGIN_TRY { - ret = H5Fdelete(filename, fapl_id); + is_hdf5 = H5Fis_accessible(filename, fapl_id); } H5E_END_TRY; - VERIFY(ret, FAIL, "H5Fdelete"); - - /* Verify that the file still exists */ - is_hdf5 = H5Fis_accessible(filename, fapl_id); - VERIFY(is_hdf5, TRUE, "H5Fis_accessible"); + VERIFY(is_hdf5, FAIL, "H5Fis_accessible"); - /* Actually delete the test file */ + /* Just in case deletion fails - silent on errors */ h5_delete_test_file(FILE_DELETE, fapl_id); /*****************/ @@ -340,7 +340,7 @@ test_core(void) if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) TEST_ERROR; - /* Retrieve the access property list... */ + /* Retrieve the access property list */ if ((fapl_id_out = H5Fget_access_plist(fid)) < 0) TEST_ERROR; @@ -553,6 +553,38 @@ test_core(void) TEST_ERROR; h5_delete_test_file(FILENAME[1], fapl_id); + /************************************************************************ + * Check that delete behavior works correctly + ************************************************************************/ + + /* Create and close a file */ + if (H5Pset_fapl_core(fapl_id, (size_t)CORE_INCREMENT, TRUE) < 0) + TEST_ERROR; + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + + /* Try to delete the file with the backing store off (shouldn't delete anything) */ + if (H5Pset_fapl_core(fapl_id, (size_t)CORE_INCREMENT, FALSE) < 0) + TEST_ERROR; + if (H5Fdelete(filename, fapl_id) < 0) + TEST_ERROR; + if (-1 == HDaccess(filename, F_OK)) + FAIL_PUTS_ERROR("file deleted when backing store set to FALSE"); + + /* Try to delete the file with the backing store on (should work) */ + if (H5Pset_fapl_core(fapl_id, (size_t)CORE_INCREMENT, TRUE) < 0) + TEST_ERROR; + if (H5Fdelete(filename, fapl_id) < 0) + TEST_ERROR; + if (0 == HDaccess(filename, F_OK)) + FAIL_PUTS_ERROR("file not deleted when backing store set to TRUE"); + + /************************************************************************ + * Clean up + ************************************************************************/ + /* Close the fapl */ if (H5Pclose(fapl_id) < 0) TEST_ERROR; |