diff options
author | Larry Knox <lrknox@hdfgroup.org> | 2024-03-05 14:52:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-05 14:52:09 (GMT) |
commit | 7741170bdd225da130f3ab98c454c118b5511b14 (patch) | |
tree | 35e631c884f16cf1251523c703b25df5cb178541 /test/links.c | |
parent | c44e0e35ed584d4efe67bdf1dafe25a793085e0f (diff) | |
download | hdf5-7741170bdd225da130f3ab98c454c118b5511b14.zip hdf5-7741170bdd225da130f3ab98c454c118b5511b14.tar.gz hdf5-7741170bdd225da130f3ab98c454c118b5511b14.tar.bz2 |
Sync develop branch changes since 2/16 to hdf5_1_14 branch (#4058)
* Remove oneapi return value warning. (#4028)
* Replaced last sprintf with snprintf (#4007)
* Replaced last sprintf with snprintf
To have the size of the buffer, it was required to change a function signature, and change all users of it.
In most cases, determining the buffer size wasn't trivial and so SIZE_MAX is passed. But at least this improves the infrastructure. Someone can later figure out the correct sizes.
* Test vlen sequence IO in API tests (#4027)
* Check argument for CMake REGEX FCMangle.h. (#4029)
* Replace deprecated Fortran 'include mpif.h' with 'USE mpi' (#4031)
With MPI 4.1 the use of the mpif.h include file has been deprecated. Codes
should transition to USE mpi or USE mpi_f08.
Signed-off-by: Christoph Niethammer <niethammer@hlrs.de>
* Fix H5F_get_access_plist to copy file locking settings (#4030)
H5F_get_access_plist previously did not copy over the file locking settings
from a file into the new File Access Property List that it creates. This would
make it difficult to match the file locking settings between an external file
and its parent file.
* Fix missing NOT from if check in HL folder (#4036)
* Fix the datatype passed to H5*exists_async APIs in tests. (#4033)
Add a new testing function to verify C_BOOL values.
* Add deb and rpm binaries to snapshots (#4035)
* Update and Add general INSTALL (#4016)
* Improve performance of flushing single objects (#4017)
Improve performance of flushing a single object, and remove metadata
cache flush markers
* Fix memory leak in H5LTopen_file_image when H5LT_FILE_IMAGE_DONT_COPY flag is used (#4021)
When the H5LT_FILE_IMAGE_DONT_COPY flag is passed to H5LTopen_file_image, the internally-allocated
udata structure gets leaked as the core file driver doesn't have a way to determine when or if it
needs to call the 'udata_free' callback. This has been fixed by freeing the udata structure when
the 'image_free' callback gets made during file close, where the file is holding the last reference
to the udata structure.
* Fix allocating too much memory in dset API test (#4041)
* Don't try to load general-19 warnings file for icc (#4042)
The Autools Classic Intel compiler configuration attempts to load a file
named `general-19` from the intel-warnings/classic directory, which does
not exist.
This removes the attempted load of the file.
* Remove unused AIX cross-compile cache overrides (#4043)
The ibm-aix Autotools config file had some unmaintained and unnecessary
Autoconf cache overrides. These have been removed.
* Consolidate Autotools linux files (#4044)
There are many architecture-specific linux files in the config
directory, all of which simply redirect to linux-gnulibc1.
This change renames linux-gnulibc1 to linux-gnu and deletes the more
specific files.
* Remove check for gettimeofday + tz in CMake (#4045)
This is not used in the library
* Remove limitations on preset generators (#4051)
* Fix issue with FAPL file locking setting inheriting test (#4053)
Fixes an issue where the HDF5_USE_FILE_LOCKING environment variable being
set can interfere with the file locking setting that the test expects to
be returned.
* Bump the github-actions group with 2 updates (#4054)
Bumps the github-actions group with 2 updates: [actions/download-artifact](https://github.com/actions/download-artifact) and [github/codeql-action](https://github.com/github/codeql-action).
* Fix VOL-compatibility issues in External Link API test (#4039)
Fix link API tests with incorrect filename
* Add upddated cmake tools from source location (#4040)
* Add options to allow tools type selection and naming (#4046)
* Improve error messages when tools attempt to use non-enabled S3 and HDFS VFDs. (#4047)
* Correct several 1.15/1.15.0 references to 1.14/1.14.4.
* Ignore HDF5Examples/CMakeUserPresets.json
Diffstat (limited to 'test/links.c')
-rw-r--r-- | test/links.c | 222 |
1 files changed, 222 insertions, 0 deletions
diff --git a/test/links.c b/test/links.c index e068d71..299a7c2 100644 --- a/test/links.c +++ b/test/links.c @@ -100,6 +100,8 @@ static const char *FILENAME[] = {"links0", TMPDIR "extlinks21D", /* 49: */ TMPDIR "extlinks21E", /* 50: */ "extlinks21E", /* 51: (same as #50, only without the TMPDIR prefix) */ + "extlinks22", /* 52: */ + "extlinks22A", /* 53: */ NULL}; #define FAMILY_SIZE 1024 @@ -9821,6 +9823,225 @@ error: } /* end external_set_elink_acc_flags() */ /*------------------------------------------------------------------------- + * Function: external_link_inherit_locking + * + * Purpose: Test that opening a file through an external link using a + * default FAPL will cause that file to inherit the parent + * file's file locking settings. + * + * Return: Success: 0 + * Failure: 1 + * + *------------------------------------------------------------------------- + */ +static int +external_link_inherit_locking(hid_t fapl_id, bool new_format) +{ + htri_t use_locking_env = FAIL; + htri_t ignore_disabled_env = FAIL; + hid_t fid = H5I_INVALID_HID; + hid_t tmp_fid = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t ext_fid = H5I_INVALID_HID; + hid_t file_fapl = H5I_INVALID_HID; + hid_t tmp_fapl = H5I_INVALID_HID; + bool use_locking = true; + bool ignore_disabled_locking = false; + char *filename = NULL; + char *ext_filename = NULL; + + if (new_format) + TESTING("inheriting of file locking settings (w/new group format)"); + else + TESTING("inheriting of file locking settings"); + + /* Get the settings for the file locking environment variables */ + h5_check_file_locking_env_var(&use_locking_env, &ignore_disabled_env); + + /* Check that external links are registered with the library */ + if (H5Lis_registered(H5L_TYPE_EXTERNAL) != true) + TEST_ERROR; + + if (NULL == (filename = malloc(NAME_BUF_SIZE))) + TEST_ERROR; + if (NULL == (ext_filename = malloc(NAME_BUF_SIZE))) + TEST_ERROR; + + if ((file_fapl = H5Pcopy(fapl_id)) < 0) + TEST_ERROR; + + /* Create external file */ + h5_fixname(FILENAME[53], file_fapl, ext_filename, NAME_BUF_SIZE); + if ((ext_fid = H5Fcreate(ext_filename, H5F_ACC_TRUNC, H5P_DEFAULT, file_fapl)) < 0) + TEST_ERROR; + if (H5Fclose(ext_fid) < 0) + TEST_ERROR; + + /* Create main file and link to external file */ + h5_fixname(FILENAME[52], file_fapl, filename, NAME_BUF_SIZE); + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, file_fapl)) < 0) + TEST_ERROR; + if (H5Lcreate_external(ext_filename, "/", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + + /* Test for file locking on unless disabled by environment variable */ + if (use_locking_env != false) { + /* Set file locking on */ + if (H5Pset_file_locking(file_fapl, true, true) < 0) + TEST_ERROR; + + /* Open main file */ + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, file_fapl)) < 0) + TEST_ERROR; + + /* Make sure that locking setting retrieved from access plist + * matches what we set. + */ + if ((tmp_fapl = H5Fget_access_plist(fid)) < 0) + TEST_ERROR; + if (H5Pget_file_locking(tmp_fapl, &use_locking, &ignore_disabled_locking) < 0) + TEST_ERROR; + if (use_locking != true) + TEST_ERROR; + /* Check for "ignore disabled file locks" setting being on, unless + * disabled by environment variable + */ + if (ignore_disabled_env != false && ignore_disabled_locking != true) + TEST_ERROR; + if (H5Pclose(tmp_fapl) < 0) + TEST_ERROR; + + /* Open external file through link */ + if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Get file ID for external file */ + if ((tmp_fid = H5Iget_file_id(gid)) < 0) + TEST_ERROR; + + /* Make sure that locking setting retrieved from external file's + * access plist matches what we set. + */ + if ((tmp_fapl = H5Fget_access_plist(tmp_fid)) < 0) + TEST_ERROR; + if (H5Pget_file_locking(tmp_fapl, &use_locking, &ignore_disabled_locking) < 0) + TEST_ERROR; + if (use_locking != true) + TEST_ERROR; + /* Check for "ignore disabled file locks" setting being on, unless + * disabled by environment variable + */ + if (ignore_disabled_env != false && ignore_disabled_locking != true) + TEST_ERROR; + if (H5Pclose(tmp_fapl) < 0) + TEST_ERROR; + + if (H5Gclose(gid) < 0) + TEST_ERROR; + if (H5Fclose(tmp_fid) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + } + + /* Test for file locking off unless force enabled by environment variable */ + if (use_locking_env != true) { + /* Set file locking off */ + if (H5Pset_file_locking(file_fapl, false, false) < 0) + TEST_ERROR; + + /* Open main file */ + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, file_fapl)) < 0) + TEST_ERROR; + + /* Make sure that locking setting retrieved from access plist + * matches what we set. + */ + if ((tmp_fapl = H5Fget_access_plist(fid)) < 0) + TEST_ERROR; + if (H5Pget_file_locking(tmp_fapl, &use_locking, &ignore_disabled_locking) < 0) + TEST_ERROR; + if (use_locking != false) + TEST_ERROR; + /* Check for "ignore disabled file locks" setting being off, unless + * force enabled by environment variable + */ + if (ignore_disabled_env != true && ignore_disabled_locking != false) + TEST_ERROR; + if (H5Pclose(tmp_fapl) < 0) + TEST_ERROR; + + /* Open external file through link */ + if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Get file ID for external file */ + if ((tmp_fid = H5Iget_file_id(gid)) < 0) + TEST_ERROR; + + /* Make sure that locking setting retrieved from external file's + * access plist matches what we set. + */ + if ((tmp_fapl = H5Fget_access_plist(tmp_fid)) < 0) + TEST_ERROR; + if (H5Pget_file_locking(tmp_fapl, &use_locking, &ignore_disabled_locking) < 0) + TEST_ERROR; + if (use_locking != false) + TEST_ERROR; + /* Check for "ignore disabled file locks" setting being off, unless + * force enabled by environment variable + */ + if (ignore_disabled_env != true && ignore_disabled_locking != false) + TEST_ERROR; + if (H5Pclose(tmp_fapl) < 0) + TEST_ERROR; + + if (H5Gclose(gid) < 0) + TEST_ERROR; + if (H5Fclose(tmp_fid) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + } + + if (H5Fdelete(ext_filename, file_fapl) < 0) + TEST_ERROR; + if (H5Fdelete(filename, file_fapl) < 0) + TEST_ERROR; + + if (H5Pclose(file_fapl) < 0) + TEST_ERROR; + + free(ext_filename); + ext_filename = NULL; + free(filename); + filename = NULL; + + PASSED(); + + return SUCCEED; + +error: + H5E_BEGIN_TRY + { + H5Pclose(tmp_fapl); + H5Pclose(file_fapl); + H5Fclose(ext_fid); + H5Gclose(gid); + H5Fclose(tmp_fid); + H5Fclose(fid); + } + H5E_END_TRY + + free(ext_filename); + free(filename); + + return FAIL; +} + +/*------------------------------------------------------------------------- * Function: external_set_elink_cb * * Purpose: Verify functionality of H5P_set/get_elink_cb @@ -23034,6 +23255,7 @@ main(void) nerrors += external_set_elink_fapl2(my_fapl, new_format) < 0 ? 1 : 0; nerrors += external_set_elink_fapl3(new_format) < 0 ? 1 : 0; + nerrors += external_link_inherit_locking(my_fapl, new_format) < 0 ? 1 : 0; nerrors += external_set_elink_cb(my_fapl, new_format) < 0 ? 1 : 0; #ifdef H5_HAVE_WINDOW_PATH nerrors += external_link_win1(my_fapl, new_format) < 0 ? 1 : 0; |