summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorScot Breitenfeld <brtnfld@hdfgroup.org>2015-04-13 18:59:09 (GMT)
committerScot Breitenfeld <brtnfld@hdfgroup.org>2015-04-13 18:59:09 (GMT)
commit50695fd6844740bc89a50db8dc017f5b8b493d81 (patch)
treeec7c2233b12d2f2700e84a9c8542ebd4ed1e2090 /test
parentce5aaa9d23441b9d651097199e2977459b2ed86e (diff)
downloadhdf5-50695fd6844740bc89a50db8dc017f5b8b493d81.zip
hdf5-50695fd6844740bc89a50db8dc017f5b8b493d81.tar.gz
hdf5-50695fd6844740bc89a50db8dc017f5b8b493d81.tar.bz2
[svn-r26789] brought changes 26767 and 26772 from the trunk into the branch.
Tested: h5committest
Diffstat (limited to 'test')
-rw-r--r--test/getname.c59
1 files changed, 57 insertions, 2 deletions
diff --git a/test/getname.c b/test/getname.c
index dac115c..ee1d97b 100644
--- a/test/getname.c
+++ b/test/getname.c
@@ -103,7 +103,11 @@ test_main(hid_t file_id, hid_t fapl)
hid_t space_id;
hid_t type_id, type2_id;
hsize_t dims[1] = { 5 };
- size_t name_len; /* Name length */
+ size_t name_len; /* Name length */
+ H5O_info_t oinfo; /* Object info structs */
+ hid_t dtype; /* Object identifier for testing */
+ hid_t dtype_anon; /* Object identifier for testing anonymous */
+ ssize_t size; /* Size returned by H5Iget_name */
/* Initialize the file names */
h5_fixname(FILENAME[1], fapl, filename1, sizeof filename1);
@@ -2355,7 +2359,58 @@ test_main(hid_t file_id, hid_t fapl)
H5Gclose(group_id);
H5Gclose(group2_id);
H5Fclose(file1_id);
- H5Fclose(file2_id);
+
+ PASSED();
+
+ /*-------------------------------------------------------------------------
+ * Test H5Iget_name with anonymous datatypes
+ *-------------------------------------------------------------------------
+ */
+
+ TESTING("H5Iget_name with anonymous datatypes");
+
+ /* Commit the type anonymously and link it in */
+ if((dtype = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ /* Test H5Iget_name with created datatype, should fail because not committed */
+ H5E_BEGIN_TRY {
+ if((size = H5Iget_name(dtype, NULL, 0)) >= 0) TEST_ERROR
+ } H5E_END_TRY;
+
+ if(H5Tcommit_anon(file2_id, dtype, H5P_DEFAULT, H5P_DEFAULT)) TEST_ERROR
+
+ /* Test H5Iget_name with anonymously created datatype, should pass because committed */
+ if((size = H5Iget_name(dtype, NULL, 0)) != 0) TEST_ERROR
+
+ /* Create a link to the object */
+ if( H5Olink(dtype, file2_id, "datatype", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Commit a second datatype with no links to it and commit it */
+ if((dtype_anon = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR
+ if(H5Tcommit_anon(file2_id, dtype_anon, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* Test H5Iget_name with anonymously created datatype, should pass because committed */
+ if((size = H5Iget_name(dtype_anon, NULL,0)) != 0) TEST_ERROR
+
+ /* Store the address of the datatype for later use */
+ if(H5Oget_info(dtype_anon, &oinfo) < 0) TEST_ERROR
+
+ /* Update the reference count to dtype_anon to preserve the datatype */
+ if(H5Oincr_refcount(dtype_anon) < 0) TEST_ERROR
+
+ if(H5Tclose(dtype) < 0) TEST_ERROR
+ if(H5Tclose(dtype_anon) < 0) TEST_ERROR
+ if(H5Fclose(file2_id) < 0) TEST_ERROR
+
+ /* Re-open the file and check that the anonymous datatypes persist */
+ if( (file2_id = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
+
+ /* Check the H5Iget_name does not return an error for anon committed datatypes */
+ if((dtype_anon = H5Oopen_by_addr(file2_id, oinfo.addr)) < 0) TEST_ERROR
+
+ if((size = H5Iget_name(dtype_anon,NULL,0)) != 0) TEST_ERROR
+
+ if(H5Tclose(dtype_anon) < 0) TEST_ERROR
+ if(H5Fclose(file2_id) < 0) TEST_ERROR
PASSED();