summaryrefslogtreecommitdiffstats
path: root/test/links.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2016-12-18 10:19:26 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2016-12-18 10:19:26 (GMT)
commitf8cfbee05e26a815134cd1f1fb0ad87d8d9b16dd (patch)
tree22777f588c0cda947647ae6500ae39bf27e99300 /test/links.c
parentfc482f126f1e523e6df9e02050bab0742d016697 (diff)
downloadhdf5-f8cfbee05e26a815134cd1f1fb0ad87d8d9b16dd.zip
hdf5-f8cfbee05e26a815134cd1f1fb0ad87d8d9b16dd.tar.gz
hdf5-f8cfbee05e26a815134cd1f1fb0ad87d8d9b16dd.tar.bz2
Merge SWMR-related testing to existing tests.
Diffstat (limited to 'test/links.c')
-rw-r--r--test/links.c101
1 files changed, 99 insertions, 2 deletions
diff --git a/test/links.c b/test/links.c
index 2c841f0..182eb6c 100644
--- a/test/links.c
+++ b/test/links.c
@@ -27,8 +27,12 @@
#define H5G_FRIEND /*suppress error about including H5Gpkg */
#define H5G_TESTING
+#define H5FD_FRIEND /*suppress error about including H5FDpkg */
+#define H5FD_TESTING
+
#include "h5test.h"
#include "H5srcdir.h"
+#include "H5FDpkg.h" /* File drivers */
#include "H5Gpkg.h" /* Groups */
#include "H5Iprivate.h" /* IDs */
#include "H5Lprivate.h" /* Links */
@@ -3951,7 +3955,7 @@ external_set_elink_fapl3(hbool_t new_format)
*-------------------------------------------------------------------------
*/
static int
-external_set_elink_acc_flags(hid_t fapl, hbool_t new_format)
+external_set_elink_acc_flags(const char *env_h5_drvr, hid_t fapl, hbool_t new_format)
{
hid_t file1 = -1, file2 = -1, group = -1, subgroup = -1, gapl = -1;
char filename1[NAME_BUF_SIZE],
@@ -4010,6 +4014,15 @@ external_set_elink_acc_flags(hid_t fapl, hbool_t new_format)
} H5E_END_TRY;
if(subgroup != FAIL) TEST_ERROR
+ /* Attempt to set SWMR flags on gapl.
+ * This is just a smoke check of the flags. The actual external link
+ * functionality is tested in the SWMR tests.
+ */
+ /* Set SWMR reader flags on gapl */
+ if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ) < 0) TEST_ERROR
+ /* Set SWMR writer flags on gapl */
+ if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE) < 0) TEST_ERROR
+
/* Attempt to set invalid flags on gapl */
H5E_BEGIN_TRY {
ret = H5Pset_elink_acc_flags(gapl, H5F_ACC_TRUNC);
@@ -4023,10 +4036,94 @@ external_set_elink_acc_flags(hid_t fapl, hbool_t new_format)
ret = H5Pset_elink_acc_flags(gapl, H5F_ACC_CREAT);
} H5E_END_TRY;
if(ret != FAIL) TEST_ERROR
+ /* SWMR reader with write access */
+ H5E_BEGIN_TRY {
+ ret = H5Pset_elink_acc_flags(gapl, H5F_ACC_RDWR | H5F_ACC_SWMR_READ);
+ } H5E_END_TRY;
+ if(ret != FAIL) TEST_ERROR
+ /* SWMR writer with read-only access */
+ H5E_BEGIN_TRY {
+ ret = H5Pset_elink_acc_flags(gapl, H5F_ACC_RDONLY | H5F_ACC_SWMR_WRITE);
+ } H5E_END_TRY;
+ if(ret != FAIL) TEST_ERROR
/* Close file1 */
if(H5Fclose(file1) < 0) TEST_ERROR
+ /* Only run this part with VFDs that support SWMR */
+ if(H5FD_supports_swmr_test(env_h5_drvr)) {
+
+ /* Reopen file1, with read-write and SWMR-write access */
+ /* Only supported under the latest file format */
+ if(new_format) {
+ if((file1 = H5Fopen(filename1, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) FAIL_STACK_ERROR
+
+ /* Open a group through the external link using default gapl */
+ if((group = H5Gopen2(file1, "/ext_link/group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ /* Verify that the correct parameters have been set on file2 */
+ if((file2 = H5Iget_file_id(group)) < 0) FAIL_STACK_ERROR
+ if(H5Fget_intent(file2, &flags) < 0) FAIL_STACK_ERROR
+ if(flags != (H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE)) TEST_ERROR
+
+ /* Close file2 and group */
+ if(H5Gclose(group) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(file2) < 0) FAIL_STACK_ERROR
+
+ /* Set elink access flags on gapl to be H5F_ACC_RDWR (dropping SWMR_WRITE) */
+ if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDWR) < 0) FAIL_STACK_ERROR
+
+ /* Open a group through the external link using gapl */
+ if((group = H5Gopen2(file1, "/ext_link/group", gapl)) < 0) FAIL_STACK_ERROR
+
+ /* Verify that the correct parameters have been set on file2 */
+ if((file2 = H5Iget_file_id(group)) < 0) FAIL_STACK_ERROR
+ if(H5Fget_intent(file2, &flags) < 0) FAIL_STACK_ERROR
+ if(flags != H5F_ACC_RDWR) TEST_ERROR
+
+ /* Close file2 and group */
+ if(H5Gclose(group) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(file2) < 0) FAIL_STACK_ERROR
+
+ /* Close file1 */
+ if(H5Fclose(file1) < 0) TEST_ERROR
+ }
+
+ /* Reopen file1, with read-only and SWMR-read access */
+ if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR
+
+ /* Open a group through the external link using default gapl */
+ if((group = H5Gopen2(file1, "/ext_link/group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ /* Verify that the correct parameters have been set on file2 */
+ if((file2 = H5Iget_file_id(group)) < 0) FAIL_STACK_ERROR
+ if(H5Fget_intent(file2, &flags) < 0) FAIL_STACK_ERROR
+ if(flags != (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ)) TEST_ERROR
+
+ /* Close file2 and group */
+ if(H5Gclose(group) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(file2) < 0) FAIL_STACK_ERROR
+
+ /* Set elink access flags on gapl to be H5F_ACC_RDWR (dropping SWMR_WRITE) */
+ if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDONLY) < 0) FAIL_STACK_ERROR
+
+ /* Open a group through the external link using gapl */
+ if((group = H5Gopen2(file1, "/ext_link/group", gapl)) < 0) FAIL_STACK_ERROR
+
+ /* Verify that the correct parameters have been set on file2 */
+ if((file2 = H5Iget_file_id(group)) < 0) FAIL_STACK_ERROR
+ if(H5Fget_intent(file2, &flags) < 0) FAIL_STACK_ERROR
+ if(flags != H5F_ACC_RDONLY) TEST_ERROR
+
+ /* Close file2 and group */
+ if(H5Gclose(group) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(file2) < 0) FAIL_STACK_ERROR
+
+ /* Close file1 */
+ if(H5Fclose(file1) < 0) TEST_ERROR
+ } /* end if */
+
+
/* Verify that H5Fcreate and H5Fopen reject H5F_ACC_DEFAULT */
H5E_BEGIN_TRY {
file1 = H5Fcreate(filename1, H5F_ACC_DEFAULT, H5P_DEFAULT, fapl);
@@ -14840,7 +14937,7 @@ main(void)
/* This test cannot run with the EFC because the EFC cannot currently
* reopen a cached file with a different intent */
- nerrors += external_set_elink_acc_flags(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_set_elink_acc_flags(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0;
/* Try external link tests both with and without the external file cache
*/