diff options
author | James Laird <jlaird@hdfgroup.org> | 2006-08-02 23:11:10 (GMT) |
---|---|---|
committer | James Laird <jlaird@hdfgroup.org> | 2006-08-02 23:11:10 (GMT) |
commit | 6a48d3e2747253c1692f2aca86b8c2f9b371d8c7 (patch) | |
tree | 6d95faf3cea23bc452e2fbe29624de7821424e67 /test | |
parent | 25e655299edc191d259fc330aebbe0f677ebc0c5 (diff) | |
download | hdf5-6a48d3e2747253c1692f2aca86b8c2f9b371d8c7.zip hdf5-6a48d3e2747253c1692f2aca86b8c2f9b371d8c7.tar.gz hdf5-6a48d3e2747253c1692f2aca86b8c2f9b371d8c7.tar.bz2 |
[svn-r12527] Added a test to ensure that the 1.6 branch handles "user-defined" links
correctly (by giving an error message).
Fixed the 1.6 branch's handling of user-defined links.
Fixed a couple of other places where the 1.6 branch aborts instead of
exiting gracefully.
Diffstat (limited to 'test')
-rw-r--r-- | test/le_extlink1.h5 | bin | 0 -> 1120 bytes | |||
-rw-r--r-- | test/links.c | 68 |
2 files changed, 68 insertions, 0 deletions
diff --git a/test/le_extlink1.h5 b/test/le_extlink1.h5 Binary files differnew file mode 100644 index 0000000..877ba37 --- /dev/null +++ b/test/le_extlink1.h5 diff --git a/test/links.c b/test/links.c index d819a5d..6f00f19 100644 --- a/test/links.c +++ b/test/links.c @@ -32,6 +32,8 @@ const char *FILENAME[] = { #define NAME_BUF_SIZE 1024 #define MAX_NAME_LEN ((64*1024)+1024) +#define LE_FILENAME "le_extlink1.h5" + /* The group_new.h5 is generated from gen_new_fill.c in HDF5 'test' directory * for version 1.7 (after "compact group" checkin). To get this data file, * simply compile gen_new_group.c with HDF5 library (after compact group @@ -681,6 +683,71 @@ toomany(hid_t fapl) /*------------------------------------------------------------------------- + * Function: ud_link_compat + * + * Purpose: Ensure that User-defined links (introduced in 1.8) can be + * handled by HDF5 1.6. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: James Laird + * Tuesday, July 25, 2006 + * + *------------------------------------------------------------------------- + */ +static int +ud_link_compat(hid_t fapl) +{ + hid_t fid = (-1); + H5G_stat_t sb; + char * srcdir = getenv("srcdir"); /* The source directory */ + char pathbuf[NAME_BUF_SIZE]; /* Path to the files */ + char namebuf[NAME_BUF_SIZE]; + + TESTING("compatibility with User-defined links"); + + /* + * Create the name of the file to open (in case we are using the --srcdir + * option and the file is in a different directory from this test). + */ + if (srcdir && ((HDstrlen(srcdir) + 2) < sizeof(pathbuf)) ) + { + HDstrcpy(pathbuf, srcdir); + HDstrcat(pathbuf, "/"); + } + else + HDstrcpy(pathbuf, ""); + + if(HDstrlen(pathbuf) + HDstrlen(LE_FILENAME) >= sizeof(namebuf)) TEST_ERROR + HDstrcpy(namebuf, pathbuf); + HDstrcat(namebuf, LE_FILENAME); + + /* Open a file with an external link in it */ + if((fid = H5Fopen(namebuf, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + + /* Trying to open the link or get info about it should fail. */ + H5E_BEGIN_TRY { + if(H5Gopen(fid, "ext_link") >= 0) TEST_ERROR + if(H5Gget_objinfo(fid, "ext_link", FALSE, &sb) >= 0) TEST_ERROR + } H5E_END_TRY + + /* There isn't much more we can do with the link. We shouldn't try moving + * it or deleting it. */ + if(H5Fclose(fid) < 0) TEST_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Fclose(fid); + } H5E_END_TRY + return 1; +} /* end ud_link_compat() */ + + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Test links @@ -712,6 +779,7 @@ main(void) nerrors += ck_new_links(fapl) < 0 ? 1 : 0; nerrors += long_links(fapl) < 0 ? 1 : 0; nerrors += toomany(fapl) < 0 ? 1 : 0; + nerrors += ud_link_compat(fapl) < 0 ? 1 : 0; /* Results */ if (nerrors) { |