mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-04-18 17:40:55 +08:00
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>
This commit is contained in:
parent
7ff3eac667
commit
ea5b3952f7
@ -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 */
|
||||
/*******************/
|
||||
|
@ -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 */
|
||||
/****************************/
|
||||
|
107
test/links.c
107
test/links.c
@ -13716,6 +13716,112 @@ error:
|
||||
return FAIL;
|
||||
} /* 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
|
||||
*
|
||||
@ -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 */
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user