summaryrefslogtreecommitdiffstats
path: root/test/th5o.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/th5o.c')
-rw-r--r--test/th5o.c179
1 files changed, 156 insertions, 23 deletions
diff --git a/test/th5o.c b/test/th5o.c
index 00d706c..63fee5f 100644
--- a/test/th5o.c
+++ b/test/th5o.c
@@ -410,13 +410,13 @@ test_h5o_refcount(void)
CHECK(ret, FAIL, "H5Sclose");
/* Get ref counts for each object. They should all be 1, since each object has a hard link. */
- ret = H5Oget_info_by_name(fid, "group", &oinfo, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid, "group", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
VERIFY(oinfo.rc, 1, "reference count in H5Oget_info_by_name");
- ret = H5Oget_info_by_name(fid, "datatype", &oinfo, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid, "datatype", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
VERIFY(oinfo.rc, 1, "reference count in H5Oget_info_by_name");
- ret = H5Oget_info_by_name(fid, "dataset", &oinfo, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid, "dataset", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
VERIFY(oinfo.rc, 1, "reference count in H5Oget_info_by_name");
@@ -429,13 +429,13 @@ test_h5o_refcount(void)
CHECK(ret, FAIL, "H5Oincr_refcount");
/* Get ref counts for each object. They should all be 2 now. */
- ret = H5Oget_info_by_name(fid, "group", &oinfo, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid, "group", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
VERIFY(oinfo.rc, 2, "reference count in H5Oget_info_by_name");
- ret = H5Oget_info_by_name(fid, "datatype", &oinfo, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid, "datatype", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
VERIFY(oinfo.rc, 2, "reference count in H5Oget_info_by_name");
- ret = H5Oget_info_by_name(fid, "dataset", &oinfo, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid, "dataset", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
VERIFY(oinfo.rc, 2, "reference count in H5Oget_info_by_name");
@@ -447,13 +447,13 @@ test_h5o_refcount(void)
ret = H5Odecr_refcount(dset);
CHECK(ret, FAIL, "H5Odecr_refcount");
- ret = H5Oget_info_by_name(fid, "group", &oinfo, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid, "group", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
VERIFY(oinfo.rc, 1, "reference count in H5Oget_info_by_name");
- ret = H5Oget_info_by_name(fid, "datatype", &oinfo, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid, "datatype", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
VERIFY(oinfo.rc, 1, "reference count in H5Oget_info_by_name");
- ret = H5Oget_info_by_name(fid, "dataset", &oinfo, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid, "dataset", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
VERIFY(oinfo.rc, 1, "reference count in H5Oget_info_by_name");
@@ -485,13 +485,13 @@ test_h5o_refcount(void)
dset = H5Dopen2(fid, "dataset", H5P_DEFAULT);
CHECK(dset, FAIL, "H5Dopen2");
- ret = H5Oget_info_by_name(fid, "group", &oinfo, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid, "group", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
VERIFY(oinfo.rc, 2, "reference count in H5Oget_info_by_name");
- ret = H5Oget_info_by_name(fid, "datatype", &oinfo, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid, "datatype", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
VERIFY(oinfo.rc, 2, "reference count in H5Oget_info_by_name");
- ret = H5Oget_info_by_name(fid, "dataset", &oinfo, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid, "dataset", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
VERIFY(oinfo.rc, 2, "reference count in H5Oget_info_by_name");
@@ -523,13 +523,13 @@ test_h5o_refcount(void)
dset = H5Dopen2(fid, "dataset", H5P_DEFAULT);
CHECK(dset, FAIL, "H5Dopen2");
- ret = H5Oget_info_by_name(fid, "group", &oinfo, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid, "group", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
VERIFY(oinfo.rc, 1, "reference count in H5Oget_info_by_name");
- ret = H5Oget_info_by_name(fid, "datatype", &oinfo, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid, "datatype", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
VERIFY(oinfo.rc, 1, "reference count in H5Oget_info_by_name");
- ret = H5Oget_info_by_name(fid, "dataset", &oinfo, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid, "dataset", &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
VERIFY(oinfo.rc, 1, "reference count in H5Oget_info_by_name");
@@ -1272,9 +1272,9 @@ test_h5o_getinfo_same_file(void)
HDmemset(&oinfo2, 0, sizeof(oinfo2));
/* Query the object info for each object, through group IDs */
- ret = H5Oget_info(gid1, &oinfo1);
+ ret = H5Oget_info2(gid1, &oinfo1, H5O_INFO_BASIC);
CHECK(ret, FAIL, "H5Oget_info");
- ret = H5Oget_info(gid2, &oinfo2);
+ ret = H5Oget_info2(gid2, &oinfo2, H5O_INFO_BASIC);
CHECK(ret, FAIL, "H5Oget_info");
VERIFY(oinfo1.fileno, oinfo2.fileno, "file number from H5Oget_info");
@@ -1284,9 +1284,9 @@ test_h5o_getinfo_same_file(void)
HDmemset(&oinfo2, 0, sizeof(oinfo2));
/* Query the object info for each object, by name */
- ret = H5Oget_info_by_name(fid1, "group1", &oinfo1, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid1, "group1", &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
- ret = H5Oget_info_by_name(fid1, "group2", &oinfo2, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid1, "group2", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
VERIFY(oinfo1.fileno, oinfo2.fileno, "file number from H5Oget_info");
@@ -1317,9 +1317,9 @@ test_h5o_getinfo_same_file(void)
HDmemset(&oinfo2, 0, sizeof(oinfo2));
/* Query the object info for each object, through group IDs */
- ret = H5Oget_info(gid1, &oinfo1);
+ ret = H5Oget_info2(gid1, &oinfo1, H5O_INFO_BASIC);
CHECK(ret, FAIL, "H5Oget_info");
- ret = H5Oget_info(gid2, &oinfo2);
+ ret = H5Oget_info2(gid2, &oinfo2, H5O_INFO_BASIC);
CHECK(ret, FAIL, "H5Oget_info");
VERIFY(oinfo1.fileno, oinfo2.fileno, "file number from H5Oget_info");
@@ -1329,9 +1329,9 @@ test_h5o_getinfo_same_file(void)
HDmemset(&oinfo2, 0, sizeof(oinfo2));
/* Query the object info for each object, by name */
- ret = H5Oget_info_by_name(fid1, "group1", &oinfo1, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid1, "group1", &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
- ret = H5Oget_info_by_name(fid1, "group2", &oinfo2, H5P_DEFAULT);
+ ret = H5Oget_info_by_name2(fid1, "group2", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Oget_info_by_name");
VERIFY(oinfo1.fileno, oinfo2.fileno, "file number from H5Oget_info");
@@ -1348,6 +1348,136 @@ test_h5o_getinfo_same_file(void)
} /* test_h5o_getinfo_same_file() */
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+
+/****************************************************************
+**
+** visit_obj_cb():
+** This is the callback function invoked by H5Ovisit1() in
+** test_h5o_getinfo_visit():
+** --Verify that the object info returned to the callback
+** function is the same as H5Oget_info2().
+**
+****************************************************************/
+static int
+visit_obj_cb(hid_t group_id, const char *name, const H5O_info_t *oinfo1,
+ void H5_ATTR_UNUSED *_op_data)
+{
+ H5O_info_t oinfo2; /* Object info structs */
+
+ /* Verify the object info for "group1", "group2" and the root group */
+ if(!(HDstrcmp(name, "group1"))) {
+ H5Oget_info_by_name2(group_id, name, &oinfo2, H5O_INFO_NUM_ATTRS, H5P_DEFAULT);
+ VERIFY(oinfo1->num_attrs, oinfo2.num_attrs, "obj info from H5Ovisit1");
+ } else if(!(HDstrcmp(name, "group2"))) {
+ H5Oget_info_by_name2(group_id, name, &oinfo2, H5O_INFO_HDR, H5P_DEFAULT);
+ VERIFY(oinfo1->hdr.nmesgs, oinfo2.hdr.nmesgs, "obj info from H5Ovisit1/H5Oget_info2");
+ VERIFY(oinfo1->hdr.nchunks, oinfo2.hdr.nchunks, "obj info from H5Ovisit1/H5Oget_info2");
+ } else if(!(HDstrcmp(name, "."))) {
+ H5Oget_info_by_name2(group_id, name, &oinfo2, H5O_INFO_META_SIZE, H5P_DEFAULT);
+ VERIFY(oinfo1->meta_size.obj.index_size, oinfo2.meta_size.obj.index_size, "obj info from H5Ovisit1/H5Oget_info2");
+ VERIFY(oinfo1->meta_size.obj.heap_size, oinfo2.meta_size.obj.heap_size, "obj info from H5Ovisit1/H5Oget_info2");
+ }
+
+ return(H5_ITER_CONT);
+} /* end visit_obj_cb() */
+
+
+/****************************************************************
+**
+** test_h5o_getinfo_visit():
+** Verify that the object info returned via H5Oget_info1()
+** and H5Oget_info2() are the same.
+** Verify that the object info retrieved via H5Ovisit1() is
+** the same as H5Oget_info2().
+**
+****************************************************************/
+static void
+test_h5o_getinfo_visit(void)
+{
+ hid_t fid = -1; /* HDF5 File ID */
+ hid_t gid1 = -1, gid2 = -1; /* Group IDs */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t aid = -1; /* Attribute ID */
+ H5O_info_t oinfo1, oinfo2; /* Object info structs */
+ char attrname[25]; /* Attribute name */
+ int j; /* Local index variable */
+ herr_t ret; /* Value returned from API calls */
+
+ /* Create an HDF5 file */
+ fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Create "group1" in the file */
+ gid1 = H5Gcreate2(fid, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(gid1, FAIL, "H5Gcreate2");
+
+ /* Create dataspace */
+ sid = H5Screate(H5S_SCALAR);
+ CHECK(sid, FAIL, "H5Screate");
+
+ /* Attach 10 attributes to "group1" */
+ for(j = 0; j <10; j++) {
+ /* Create the attribute name */
+ sprintf(attrname, "attr%u", j);
+ /* Create the attribute */
+ aid = H5Acreate2(gid1, attrname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid, FAIL, "H5Acreate2");
+ /* Close the attribute */
+ ret = H5Aclose(aid);
+ CHECK(ret, FAIL, "H5Aclose");
+ }
+
+ /* Create "group2" in the file */
+ gid2 = H5Gcreate2(fid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(gid2, FAIL, "H5Gcreate2");
+
+ /* Reset object info */
+ HDmemset(&oinfo1, 0, sizeof(oinfo1));
+ HDmemset(&oinfo2, 0, sizeof(oinfo2));
+
+ /* Query the object info for "group1" via H5Oget_info1 and H5Oget_info2 */
+ ret = H5Oget_info1(gid1, &oinfo1);
+ CHECK(ret, FAIL, "H5Oget_info");
+ ret = H5Oget_info2(gid1, &oinfo2, H5O_INFO_BASIC|H5O_INFO_NUM_ATTRS);
+ CHECK(ret, FAIL, "H5Oget_info");
+
+ /* Verify the object info for "group1" is correct */
+ VERIFY(oinfo1.fileno, oinfo2.fileno, "obj info from H5Oget_info1/2");
+ VERIFY(oinfo1.num_attrs, oinfo2.num_attrs, "obj info from H5Oget_info1/2");
+
+ /* Reset object info */
+ HDmemset(&oinfo1, 0, sizeof(oinfo1));
+ HDmemset(&oinfo2, 0, sizeof(oinfo2));
+
+ /* Query the object info for "group2" via H5Oget_info1 and H5Oget_info2 */
+ ret = H5Oget_info_by_name1(fid, "group2", &oinfo1, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Oget_info_by_name");
+ ret = H5Oget_info_by_name2(fid, "group2", &oinfo2, H5O_INFO_HDR|H5O_INFO_META_SIZE, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Oget_info_by_name");
+
+ /* Verify the object info for "group2" is correct */
+ VERIFY(oinfo1.hdr.nmesgs, oinfo2.hdr.nmesgs, "obj info from H5Oget_info1/2");
+ VERIFY(oinfo1.hdr.nchunks, oinfo2.hdr.nchunks, "obj info from H5Oget_info1/2");
+ VERIFY(oinfo1.meta_size.obj.index_size, oinfo2.meta_size.obj.index_size, "obj info from H5Oget_info1/2");
+ VERIFY(oinfo1.meta_size.obj.heap_size, oinfo2.meta_size.obj.heap_size, "obj info from H5Oget_info1/2");
+
+ /* Close everything */
+ ret = H5Gclose(gid1);
+ CHECK(ret, FAIL, "H5Gclose");
+ ret = H5Gclose(gid2);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ /* Verify the object info returned to the callback function is correct */
+ ret = H5Ovisit1(fid, H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, NULL);
+
+ /* Close the file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+} /* test_h5o_getinfo_visit() */
+
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
/****************************************************************
@@ -1370,6 +1500,9 @@ test_h5o(void)
test_h5o_comment(); /* Test routines for comment */
test_h5o_comment_by_name(); /* Test routines for comment by name */
test_h5o_getinfo_same_file(); /* Test info for objects in the same file */
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+ test_h5o_getinfo_visit(); /* Test object info for H5Oget_info1/2 and H5Ovisit1 */
+#endif
} /* test_h5o() */