summaryrefslogtreecommitdiffstats
path: root/test/links.c
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2011-02-08 15:55:31 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2011-02-08 15:55:31 (GMT)
commitf3ee1cc38d0604116afbffe72cd98dabfe1014a7 (patch)
treeb7b11d751b526c91b0e0695d34c66991b80d74b3 /test/links.c
parente1cd1485b8bb78b4a99ca4246c522bbaf3c0ed76 (diff)
parenta6d5fa2c7db165fa2cecee86bdbd201339349968 (diff)
downloadhdf5-f3ee1cc38d0604116afbffe72cd98dabfe1014a7.zip
hdf5-f3ee1cc38d0604116afbffe72cd98dabfe1014a7.tar.gz
hdf5-f3ee1cc38d0604116afbffe72cd98dabfe1014a7.tar.bz2
[svn-r20063] Merge changes from trunk from revision 19519 to 20062 into open_file_pool branch. No testing needed as the branch is currently identical to the trunk.
Diffstat (limited to 'test/links.c')
-rw-r--r--test/links.c140
1 files changed, 37 insertions, 103 deletions
diff --git a/test/links.c b/test/links.c
index 12b8ba4..c8ece99 100644
--- a/test/links.c
+++ b/test/links.c
@@ -2640,6 +2640,8 @@ external_link_dangling(hid_t fapl, hbool_t new_format)
{
hid_t fid = (-1); /* File ID */
hid_t gid = (-1); /* Group IDs */
+ hid_t rid = (-1); /* Root Group ID */
+ hid_t status = (-1); /* Status */
char filename1[NAME_BUF_SIZE],
filename2[NAME_BUF_SIZE]; /* Names of files to externally link across */
@@ -2672,6 +2674,9 @@ external_link_dangling(hid_t fapl, hbool_t new_format)
/* Open first file */
if((fid=H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
+ /* Get root group ID */
+ if((rid=H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) TEST_ERROR;
+
/* Open object through dangling file external link */
H5E_BEGIN_TRY {
gid = H5Gopen2(fid, "no_file", H5P_DEFAULT);
@@ -2692,125 +2697,36 @@ external_link_dangling(hid_t fapl, hbool_t new_format)
goto error;
}
- /* Close first file */
- if(H5Fclose(fid) < 0) TEST_ERROR
-
-
- PASSED();
- return 0;
-
- error:
+ /* Try to get name of object by index through dangling file external link */
H5E_BEGIN_TRY {
- H5Gclose (gid);
- H5Fclose (fid);
+ status = H5Lget_name_by_idx(rid, "no_file", H5_INDEX_NAME, H5_ITER_INC, 0, NULL, 0, H5P_DEFAULT);
} H5E_END_TRY;
- return -1;
-} /* end external_link_dangling() */
-
-
-
-/*-------------------------------------------------------------------------
- * Function: external_link_env: test 1
- *
- * Purpose:
- * 1. target link: "extlinks1"
- * 2. main file: "extlinks0"
- * 3. target file: "tmp/extlinks1"
- * 4. The environment variable "HDF5_EXT_PREFIX" should be set to ".:tmp"
- * Should be able to access the target file in tmp directory through searching
- * the pathnames set in HDF5_EXT_PREFIX.
- * This test will be skipped if HDF5_EXT_PREFIX is not set as expected.
- *
- *
- * Return: Success: 0
- * Failure: -1
- *
- * Programmer: Vailin Choi
- * Feb. 20, 2008
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static int
-external_link_env(hid_t fapl, hbool_t new_format)
-{
- hid_t fid = (-1); /* File ID */
- hid_t gid = (-1); /* Group IDs */
- const char *envval = NULL;
-
- char filename1[NAME_BUF_SIZE],
- filename2[NAME_BUF_SIZE],
- filename3[NAME_BUF_SIZE];
-
- if(new_format)
- TESTING("external links via environment variable (w/new group format)")
- else
- TESTING("external links via environment variable")
-
- if ((envval = HDgetenv("HDF5_EXT_PREFIX")) == NULL)
- envval = "nomatch";
- if (HDstrcmp(envval, ".:tmp")) {
- SKIPPED();
- return(0);
- }
-
- /* set up name for main file:"extlinks0" */
- h5_fixname(FILENAME[12], fapl, filename1, sizeof filename1);
- /* set up name for external linked target file: "extlinks1" */
- h5_fixname(FILENAME[14], fapl, filename2, sizeof filename2);
-
- if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST)
- TEST_ERROR
-
- /* set up name for target file: "tmp/extlinks1" */
- h5_fixname(FILENAME[15], fapl, filename3, sizeof filename3);
+ if (status >= 0) {
+ H5_FAILED();
+ puts(" Retreiving name of object by index through dangling file external link should have failed.");
+ } /* end if */
- /* Create the target file */
- if((fid=H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ /* Close root group */
+ if(H5Gclose(rid) < 0) TEST_ERROR
- /* closing for target file */
- if(H5Gclose(gid) < 0) TEST_ERROR
+ /* Close first file */
if(H5Fclose(fid) < 0) TEST_ERROR
- /* Create the main file */
- if((fid=H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
-
- /* Create external link to target file */
- if(H5Lcreate_external(filename2, "/A", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
-
- /* Open object through external link */
- H5E_BEGIN_TRY {
- gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT);
- } H5E_END_TRY;
-
- /* should be able to find the target file from pathnames set via environment variable */
- if (gid < 0) {
- H5_FAILED();
- puts(" Should have found the file in tmp directory.");
- goto error;
- }
-
- /* closing for main file */
- if(H5Gclose(gid) < 0) TEST_ERROR
- if(H5Fclose(fid) < 0) TEST_ERROR
-
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
- H5Gclose (gid);
- H5Fclose (fid);
+ H5Gclose (gid);
+ H5Fclose (fid);
} H5E_END_TRY;
return -1;
-} /* end external_link_env() */
+} /* end external_link_dangling() */
/*-------------------------------------------------------------------------
- * Function: external_link_prefix: test 2
+ * Function: external_link_prefix
*
* Purpose: 1. target link: "extlinks2"
* 2. main file: "extlinks0"
@@ -4033,6 +3949,7 @@ external_set_elink_acc_flags(hid_t fapl, hbool_t new_format)
hid_t file1 = -1, file2 = -1, group = -1, subgroup = -1, gapl = -1;
char filename1[NAME_BUF_SIZE],
filename2[NAME_BUF_SIZE];
+ herr_t ret;
unsigned flags;
if(new_format)
@@ -4083,6 +4000,24 @@ external_set_elink_acc_flags(hid_t fapl, hbool_t new_format)
} H5E_END_TRY;
if(subgroup != FAIL) TEST_ERROR
+ /* Attempt to set invalid flags on gapl */
+ H5E_BEGIN_TRY {
+ ret = H5Pset_elink_acc_flags(gapl, H5F_ACC_TRUNC);
+ } H5E_END_TRY;
+ if(ret != FAIL) TEST_ERROR
+ H5E_BEGIN_TRY {
+ ret = H5Pset_elink_acc_flags(gapl, H5F_ACC_EXCL);
+ } H5E_END_TRY;
+ if(ret != FAIL) TEST_ERROR
+ H5E_BEGIN_TRY {
+ ret = H5Pset_elink_acc_flags(gapl, H5F_ACC_DEBUG);
+ } H5E_END_TRY;
+ if(ret != FAIL) TEST_ERROR
+ H5E_BEGIN_TRY {
+ ret = H5Pset_elink_acc_flags(gapl, H5F_ACC_CREAT);
+ } H5E_END_TRY;
+ if(ret != FAIL) TEST_ERROR
+
/* Close file1 and group */
if(H5Gclose(group) < 0) TEST_ERROR
if(H5Fclose(file1) < 0) TEST_ERROR
@@ -13996,7 +13931,6 @@ main(void)
nerrors += external_link_strong(my_fapl, new_format) < 0 ? 1 : 0;
/* tests for external link */
- nerrors += external_link_env(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += external_link_prefix(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += external_link_abs_mainpath(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += external_link_rel_mainpath(my_fapl, new_format) < 0 ? 1 : 0;