summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorraylu-hdf <60487644+raylu-hdf@users.noreply.github.com>2023-02-21 16:38:00 (GMT)
committerGitHub <noreply@github.com>2023-02-21 16:38:00 (GMT)
commitea5b3952f71ae613830ece0a4416656ecacf070d (patch)
tree2c5208e01de82143144d37a9d1a77c070f64d683
parent7ff3eac6672de87d83bc75896c5f69f50cef1077 (diff)
downloadhdf5-ea5b3952f71ae613830ece0a4416656ecacf070d.zip
hdf5-ea5b3952f71ae613830ece0a4416656ecacf070d.tar.gz
hdf5-ea5b3952f71ae613830ece0a4416656ecacf070d.tar.bz2
HDFFV-10368 (OESS-319): Making two useful macros (H5L_EXT_FLAGS_ALL and H5L_EXT_VERSION) public (#2386)
* HDFFV-10368 (OESS-319): Move two useful macros (H5L_EXT_FLAGS_ALL and H5L_EXT_VERSION) from H5Lpkg.h to H5Lpublic.h for public usage. The test in vol.c only envokes H5Lcreate_external using the passthru VOL. To test if the macros are public, one can use them in the link creation of the passthru VOL, such as printing out their values. * Committing clang-format changes * Moved the test for the external link public macros (H5L_EXT_FLAGS_ALL and H5L_EXT_VERSION) from vol.c to links.c. * Committing clang-format changes * Minor change: changed a pointer variable to an integer. * Committing clang-format changes * Moved two macros (H5L_EXT_VERSION and H5L_EXT_FLAGS_ALL) to H5Ldevelop.h for only developers to use. --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
-rw-r--r--src/H5Ldevelop.h10
-rw-r--r--src/H5Lpkg.h6
-rw-r--r--test/links.c107
-rw-r--r--test/vol.c4
4 files changed, 119 insertions, 8 deletions
diff --git a/src/H5Ldevelop.h b/src/H5Ldevelop.h
index 34e50a0..148a5a5 100644
--- a/src/H5Ldevelop.h
+++ b/src/H5Ldevelop.h
@@ -30,6 +30,16 @@
*/
#define H5L_LINK_CLASS_T_VERS 1
+/**
+ * \brief Version of external link format
+ */
+#define H5L_EXT_VERSION 0
+
+/**
+ * \brief Valid flags for external links
+ */
+#define H5L_EXT_FLAGS_ALL 0
+
/*******************/
/* Public Typedefs */
/*******************/
diff --git a/src/H5Lpkg.h b/src/H5Lpkg.h
index 6fd15e7..25d9978 100644
--- a/src/H5Lpkg.h
+++ b/src/H5Lpkg.h
@@ -34,12 +34,6 @@
/* Package Private Macros */
/**************************/
-/* Version of external link format */
-#define H5L_EXT_VERSION 0
-
-/* Valid flags for external links */
-#define H5L_EXT_FLAGS_ALL 0
-
/****************************/
/* Package Private Typedefs */
/****************************/
diff --git a/test/links.c b/test/links.c
index 0b815e2..56912fe 100644
--- a/test/links.c
+++ b/test/links.c
@@ -13717,6 +13717,112 @@ error:
} /* end external_link_with_committed_datatype() */
/*-------------------------------------------------------------------------
+ * Function: external_link_public_macros
+ *
+ * Purpose: Test public macros for external links
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *-------------------------------------------------------------------------
+ */
+static int
+external_link_public_macros(hid_t fapl, hbool_t new_format)
+{
+ hid_t fid = -1; /* File ID */
+ H5L_info2_t linfo; /* Link information */
+ char objname[NAME_BUF_SIZE]; /* Object name */
+ char filename1[NAME_BUF_SIZE];
+ char filename2[NAME_BUF_SIZE];
+ unsigned flags; /* External link flags, packed as a bitmap */
+ const char *file; /* File from external link */
+ const char *path; /* Path from external link */
+
+ if (new_format)
+ TESTING("external link public macros (w/new group format)");
+ else
+ TESTING("external link public macros");
+
+ /* Set up filenames */
+ h5_fixname(FILENAME[3], fapl, filename1, sizeof filename1);
+ h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2);
+
+ /* Create file to point to */
+ if ((fid = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR;
+
+ /* Close file */
+ if (H5Fclose(fid) < 0)
+ TEST_ERROR;
+
+ /* Check that external links are registered with the library */
+ if (H5Lis_registered(H5L_TYPE_EXTERNAL) != TRUE)
+ TEST_ERROR;
+
+ /* Create file with link to first file */
+ if ((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR;
+
+ /* Create external link to object in first file */
+ if (H5Lcreate_external(filename1, "/", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR;
+
+ /* Check information for external link */
+ if (H5Lget_info2(fid, "ext_link", &linfo, H5P_DEFAULT) < 0)
+ goto error;
+
+ if (H5L_TYPE_EXTERNAL != linfo.type) {
+ H5_FAILED();
+ HDputs(" Unexpected object type - should have been an external link");
+ goto error;
+ }
+
+ if (H5Lget_val(fid, "ext_link", objname, sizeof(objname), H5P_DEFAULT) < 0)
+ TEST_ERROR;
+
+ if (H5Lunpack_elink_val(objname, linfo.u.val_size, &flags, &file, &path) < 0)
+ TEST_ERROR;
+
+ if (HDstrcmp(file, filename1) != 0) {
+ H5_FAILED();
+ HDputs(" External link file name incorrect");
+ goto error;
+ }
+
+ if (HDstrcmp(path, "/") != 0) {
+ H5_FAILED();
+ HDputs(" External link path incorrect");
+ goto error;
+ }
+
+ /* External link version & flags */
+ if (flags != ((H5L_EXT_VERSION << 4) | H5L_EXT_FLAGS_ALL)) {
+ H5_FAILED();
+ HDputs(" External link version or flags are incorrect");
+ goto error;
+ }
+
+ /* Close first file */
+ if (H5Fclose(fid) < 0)
+ TEST_ERROR;
+
+ /* Check that all file IDs have been closed */
+ if (H5I_nmembers(H5I_FILE) != 0)
+ TEST_ERROR;
+ H5F_sfile_assert_num(0);
+
+ PASSED();
+ return SUCCEED;
+
+error:
+ H5E_BEGIN_TRY
+ {
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
+ return FAIL;
+} /* end external_link_public_macros() */
+
+/*-------------------------------------------------------------------------
* Function: ud_hard_links
*
* Purpose: Check that the functionality of hard links can be duplicated
@@ -22717,6 +22823,7 @@ main(void)
nerrors += external_dont_fail_to_source(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += external_open_twice(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += external_link_with_committed_datatype(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_public_macros(my_fapl, new_format) < 0 ? 1 : 0;
} /* with/without external file cache */
}
diff --git a/test/vol.c b/test/vol.c
index 4cfb3de..776248b 100644
--- a/test/vol.c
+++ b/test/vol.c
@@ -28,7 +28,7 @@
#include "H5VLpkg.h" /* Virtual Object Layer */
/* Filename */
-const char *FILENAME[] = {"native_vol_test", NULL};
+const char *FILENAME[] = {"vol_test_file", NULL};
#define NATIVE_VOL_TEST_GROUP_NAME "test_group"
#define NATIVE_VOL_TEST_DATASET_NAME "test_dataset"
@@ -2285,7 +2285,7 @@ error:
H5E_END_TRY;
return FAIL;
-} /* end test_vol_cap_flags() */
+} /* end test_get_vol_name() */
/*-------------------------------------------------------------------------
* Function: test_wrap_register()