summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorScot Breitenfeld <brtnfld@hdfgroup.org>2015-04-08 16:06:48 (GMT)
committerScot Breitenfeld <brtnfld@hdfgroup.org>2015-04-08 16:06:48 (GMT)
commit1215ef0370d0164d3d1bdbbc5c1a8d5fe175c727 (patch)
tree79a4314bc1f45ae3848f61e1cf6af92ef2156929 /test
parent4662835250ea71afff2ccffac5e5311a215229b7 (diff)
downloadhdf5-1215ef0370d0164d3d1bdbbc5c1a8d5fe175c727.zip
hdf5-1215ef0370d0164d3d1bdbbc5c1a8d5fe175c727.tar.gz
hdf5-1215ef0370d0164d3d1bdbbc5c1a8d5fe175c727.tar.bz2
[svn-r26767] Added test to address HDFFV-3065:
H5Iget_name on datatype that is not named returns no error 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 2d999b9..a73bb78 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, H5P_DEFAULT)) < 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();