diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-09-13 18:26:12 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-09-13 18:26:12 (GMT) |
commit | 27a1a10fbb6101a071ddb4f5f29e3bcaeb9ef8d0 (patch) | |
tree | dc5e01059a3f849f448403a23a62a55ff2bc45f7 /test | |
parent | 095762a736c3125c0190409b7c3ca01c42605ad7 (diff) | |
download | hdf5-27a1a10fbb6101a071ddb4f5f29e3bcaeb9ef8d0.zip hdf5-27a1a10fbb6101a071ddb4f5f29e3bcaeb9ef8d0.tar.gz hdf5-27a1a10fbb6101a071ddb4f5f29e3bcaeb9ef8d0.tar.bz2 |
[svn-r14146] Description:
Move H5Gget_objtype_by_idx() to deprecated symbols section, replacing
with H5Oget_info_by_idx()
Tested on:
FreeBSD/32 6.2 (duty)
FreeBSD/64 6.2 (liberty)
Linux/32 2.6 (kagiso)
Linux/64 2.6 (smirom)
AIX/32 5.3 (copper)
Solaris/32 2.10 (linew)
Mac OS X/32 10.4.10 (amazon)
Diffstat (limited to 'test')
-rw-r--r-- | test/links.c | 8 | ||||
-rwxr-xr-x | test/objcopy.c | 138 | ||||
-rw-r--r-- | test/titerate.c | 77 | ||||
-rw-r--r-- | test/trefer.c | 9 |
4 files changed, 107 insertions, 125 deletions
diff --git a/test/links.c b/test/links.c index d341fee..176792e 100644 --- a/test/links.c +++ b/test/links.c @@ -1478,6 +1478,7 @@ test_compat(hid_t fapl, hbool_t new_format) hid_t group1_id = -1; hid_t group2_id = -1; H5G_stat_t sb_hard1, sb_hard2, sb_soft1; + H5G_obj_t obj_type; /* Object type */ hsize_t num_objs; /* Number of objects in a group */ char filename[1024]; char tmpstr[1024]; @@ -1513,6 +1514,13 @@ test_compat(hid_t fapl, hbool_t new_format) if(H5Gget_objname_by_idx(group1_id, (hsize_t)1, tmpstr, sizeof(tmpstr)) >= 0) TEST_ERROR } H5E_END_TRY; + /* Test getting the type for objects */ + if((obj_type = H5Gget_objtype_by_idx(group1_id, (hsize_t)0)) < 0) FAIL_STACK_ERROR + if(obj_type != H5G_GROUP) TEST_ERROR + H5E_BEGIN_TRY { + if(H5Gget_objtype_by_idx(group1_id, (hsize_t)1) >= 0) TEST_ERROR + } H5E_END_TRY; + /* Test getting the number of objects in a group */ if(H5Gget_num_objs(file_id, &num_objs) < 0) FAIL_STACK_ERROR if(num_objs != 2) TEST_ERROR diff --git a/test/objcopy.c b/test/objcopy.c index 5d2afd2..c916f8f 100755 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -1260,11 +1260,8 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags) if(ginfo2.nlinks > 0) { char objname[NAME_BUF_SIZE]; /* Name of object in group */ char objname2[NAME_BUF_SIZE]; /* Name of object in group */ - H5G_obj_t objtype; /* Type of object in group */ - H5G_obj_t objtype2; /* Type of object in group */ H5L_info_t linfo; /* Link information */ H5L_info_t linfo2; /* Link information */ - hid_t oid, oid2; /* IDs of objects within group */ /* Loop over contents of groups */ for(idx = 0; idx < ginfo.nlinks; idx++) { @@ -1273,11 +1270,6 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags) if(H5Lget_name_by_idx(gid2, ".", H5_INDEX_NAME, H5_ITER_INC, idx, objname2, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR if(HDstrcmp(objname, objname2)) TEST_ERROR - /* Check type of objects */ - if((objtype = H5Gget_objtype_by_idx(gid, idx)) < 0) TEST_ERROR - if((objtype2 = H5Gget_objtype_by_idx(gid2, idx)) < 0) TEST_ERROR - if(objtype != objtype2) TEST_ERROR - /* Get link info */ if(H5Lget_info(gid, objname, &linfo, H5P_DEFAULT) < 0) TEST_ERROR if(H5Lget_info(gid2, objname2, &linfo2, H5P_DEFAULT) < 0) TEST_ERROR @@ -1285,8 +1277,8 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags) /* Extra checks for "real" objects */ if(linfo.type == H5L_TYPE_HARD) { - H5O_info_t oinfo; /* Object info */ - H5O_info_t oinfo2; /* Object info */ + hid_t oid, oid2; /* IDs of objects within group */ + H5O_info_t oinfo, oinfo2; /* Object info */ /* Compare some pieces of the object info */ if(H5Oget_info(gid, objname, &oinfo, H5P_DEFAULT) < 0) TEST_ERROR @@ -1312,83 +1304,59 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags) continue; else addr_insert(&oinfo); - } /* end if */ - /* Compare objects within group */ - switch(objtype) { - case H5G_LINK: - { - char linkname[NAME_BUF_SIZE]; /* Link value */ - char linkname2[NAME_BUF_SIZE]; /* Link value */ - - /* Check link values */ - if(H5Lget_val(gid, objname, linkname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_val(gid2, objname2, linkname2, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(HDstrcmp(linkname, linkname2)) TEST_ERROR - } - break; - - case H5G_GROUP: - /* Open groups */ - if((oid = H5Gopen2(gid, objname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if((oid2 = H5Gopen2(gid2, objname2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - - /* Compare groups */ - if(compare_groups(oid, oid2, pid, depth - 1, copy_flags) != TRUE) TEST_ERROR - - /* Close groups */ - if(H5Gclose(oid) < 0) TEST_ERROR - if(H5Gclose(oid2) < 0) TEST_ERROR - break; - - case H5G_DATASET: - /* Open datasets */ - if((oid = H5Dopen(gid, objname)) < 0) TEST_ERROR - if((oid2 = H5Dopen(gid2, objname2)) < 0) TEST_ERROR - - /* Compare datasets */ - if(compare_datasets(oid, oid2, pid, NULL) != TRUE) TEST_ERROR - - /* Close datasets */ - if(H5Dclose(oid) < 0) TEST_ERROR - if(H5Dclose(oid2) < 0) TEST_ERROR - break; - - case H5G_TYPE: - /* Open datatypes */ - if((oid = H5Topen(gid, objname)) < 0) TEST_ERROR - if((oid2 = H5Topen(gid2, objname2)) < 0) TEST_ERROR - - /* Compare datatypes */ - if(H5Tequal(oid, oid2) != TRUE) TEST_ERROR - - /* Close datatypes */ - if(H5Tclose(oid) < 0) TEST_ERROR - if(H5Tclose(oid2) < 0) TEST_ERROR - break; - - case H5G_UDLINK: - { - char linkval[NAME_BUF_SIZE]; /* Link value */ - char linkval2[NAME_BUF_SIZE]; /* Link value */ - - /* Check that both links are the same type and the same size */ - if(linfo.type != linfo2.type) TEST_ERROR - if(linfo.u.val_size != linfo2.u.val_size) TEST_ERROR - - /* Get link udata */ - if(H5Lget_val(gid, objname, linkval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lget_val(gid2, objname2, linkval2, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR - - /* Compare link udata */ - if(HDmemcmp(linkval, linkval2, linfo.u.val_size)) TEST_ERROR - } - break; - - default: + /* Open objects */ + if((oid = H5Oopen(gid, objname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if((oid2 = H5Oopen(gid2, objname2, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + + /* Compare objects within group */ + switch(oinfo.type) { + case H5O_TYPE_GROUP: + /* Compare groups */ + if(compare_groups(oid, oid2, pid, depth - 1, copy_flags) != TRUE) TEST_ERROR + break; + + case H5O_TYPE_DATASET: + /* Compare datasets */ + if(compare_datasets(oid, oid2, pid, NULL) != TRUE) TEST_ERROR + break; + + case H5O_TYPE_NAMED_DATATYPE: + /* Compare datatypes */ + if(H5Tequal(oid, oid2) != TRUE) TEST_ERROR + break; + + default: HDassert(0 && "Unknown type of object"); - break; - } /* end switch */ + break; + } /* end switch */ + + /* Close objects */ + if(H5Oclose(oid) < 0) TEST_ERROR + if(H5Oclose(oid2) < 0) TEST_ERROR + } /* end if */ + else { + /* Check that both links are the same size */ + if(linfo.u.val_size != linfo2.u.val_size) TEST_ERROR + + /* Compare link values */ + if(linfo.type == H5L_TYPE_SOFT || + (linfo.type >= H5L_TYPE_UD_MIN && linfo.type <= H5L_TYPE_MAX)) { + char linkval[NAME_BUF_SIZE]; /* Link value */ + char linkval2[NAME_BUF_SIZE]; /* Link value */ + + /* Get link values */ + HDassert(linfo.u.val_size <= NAME_BUF_SIZE); + if(H5Lget_val(gid, objname, linkval, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lget_val(gid2, objname2, linkval2, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR + + /* Compare link data */ + if(HDmemcmp(linkval, linkval2, linfo.u.val_size)) TEST_ERROR + } /* end else-if */ + else { +HDassert(0 && "Unknown type of link"); + } /* end else */ + } /* end else */ } /* end for */ } /* end if */ diff --git a/test/titerate.c b/test/titerate.c index e52c93b..d38ecb2 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -167,9 +167,7 @@ test_iter_group(hid_t fapl, hbool_t new_format) CHECK(ret, FAIL, "H5Dclose"); } /* end for */ - /* Create a group and named datatype under root group for testing - * H5Gget_objtype_by_idx. - */ + /* Create a group and named datatype under root group for testing */ grp = H5Gcreate2(file, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(ret, FAIL, "H5Gcreate2"); @@ -183,16 +181,16 @@ test_iter_group(hid_t fapl, hbool_t new_format) CHECK(lnames[NDATASETS], NULL, "strdup"); /* Close everything up */ - ret=H5Tclose(datatype); + ret = H5Tclose(datatype); CHECK(ret, FAIL, "H5Tclose"); - ret=H5Gclose(grp); + ret = H5Gclose(grp); CHECK(ret, FAIL, "H5Gclose"); - ret=H5Sclose(filespace); + ret = H5Sclose(filespace); CHECK(ret, FAIL, "H5Sclose"); - ret=H5Fclose(file); + ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); /* Sort the dataset names */ @@ -203,7 +201,7 @@ test_iter_group(hid_t fapl, hbool_t new_format) file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl); CHECK(file, FAIL, "H5Fopen"); - /* These two functions, H5Gget_objtype_by_idx and H5Lget_name_by_idx, actually + /* These two functions, H5Oget_info_by_idx and H5Lget_name_by_idx, actually * iterate through B-tree for group members in internal library design. */ root_group = H5Gopen2(file, "/", H5P_DEFAULT); @@ -214,13 +212,13 @@ test_iter_group(hid_t fapl, hbool_t new_format) VERIFY(ginfo.nlinks, (NDATASETS + 2), "H5Gget_info"); for(i = 0; i< (int)ginfo.nlinks; i++) { - H5G_obj_t obj_type; /* Type of object in file */ + H5O_info_t oinfo; /* Object info */ ret = (herr_t)H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, dataset_name, (size_t)NAMELEN, H5P_DEFAULT); CHECK(ret, FAIL, "H5Lget_name_by_idx"); - obj_type = H5Gget_objtype_by_idx(root_group, (hsize_t)i); - CHECK(obj_type, H5G_UNKNOWN, "H5Gget_objtype_by_idx"); + ret = H5Oget_info_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_idx"); } /* end for */ H5E_BEGIN_TRY { @@ -231,7 +229,7 @@ test_iter_group(hid_t fapl, hbool_t new_format) ret = H5Gclose(root_group); CHECK(ret, FAIL, "H5Gclose"); - /* These two functions, H5Gget_objtype_by_idx and H5Lget_name_by_idx, actually + /* These two functions, H5Oget_info_by_idx and H5Lget_name_by_idx, actually * iterate through B-tree for group members in internal library design. * (Same as test above, but with the file ID instead of opening the root group) */ @@ -240,14 +238,14 @@ test_iter_group(hid_t fapl, hbool_t new_format) VERIFY(ginfo.nlinks, NDATASETS + 2, "H5Gget_info"); for(i = 0; i< (int)ginfo.nlinks; i++) { - H5G_obj_t obj_type; /* Type of object in file */ + H5O_info_t oinfo; /* Object info */ ret = (herr_t)H5Lget_name_by_idx(file, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, dataset_name, (size_t)NAMELEN, H5P_DEFAULT); CHECK(ret, FAIL, "H5Lget_name_by_idx"); - obj_type = H5Gget_objtype_by_idx(file, (hsize_t)i); - CHECK(obj_type, H5G_UNKNOWN, "H5Gget_objtype_by_idx"); - } + ret = H5Oget_info_by_idx(file, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_idx"); + } /* end for */ H5E_BEGIN_TRY { ret = (herr_t)H5Lget_name_by_idx(file, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)(NDATASETS + 3), dataset_name, (size_t)NAMELEN, H5P_DEFAULT); @@ -733,9 +731,7 @@ static void test_grp_memb_funcs(hid_t fapl) CHECK(ret, FAIL, "H5Dclose"); } /* end for */ - /* Create a group and named datatype under root group for testing - * H5Gget_objtype_by_idx. - */ + /* Create a group and named datatype under root group for testing */ grp = H5Gcreate2(file, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(ret, FAIL, "H5Gcreate2"); @@ -768,7 +764,7 @@ static void test_grp_memb_funcs(hid_t fapl) file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, fapl); CHECK(file, FAIL, "H5Fopen"); - /* These two functions, H5Gget_objtype_by_idx and H5Lget_name_by_idx, actually + /* These two functions, H5Oget_info_by_idx and H5Lget_name_by_idx, actually * iterate through B-tree for group members in internal library design. */ root_group = H5Gopen2(file, "/", H5P_DEFAULT); @@ -778,8 +774,8 @@ static void test_grp_memb_funcs(hid_t fapl) CHECK(ret, FAIL, "H5Gget_info"); VERIFY(ginfo.nlinks, (NDATASETS + 2), "H5Gget_info"); - for(i=0; i< (int)ginfo.nlinks; i++) { - H5G_obj_t obj_type; /* Type of object in file */ + for(i = 0; i < (int)ginfo.nlinks; i++) { + H5O_info_t oinfo; /* Object info */ /* Test with NULL for name, to query length */ name_len = H5Lget_name_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, NULL, (size_t)NAMELEN, H5P_DEFAULT); @@ -795,15 +791,15 @@ static void test_grp_memb_funcs(hid_t fapl) obj_names[i] = HDstrdup(dataset_name); CHECK(obj_names[i], NULL, "strdup"); - obj_type = H5Gget_objtype_by_idx(root_group, (hsize_t)i); - CHECK(obj_type, H5G_UNKNOWN, "H5Gget_objtype_by_idx"); + ret = H5Oget_info_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_idx"); if(!HDstrcmp(dataset_name, "grp")) - VERIFY(obj_type, H5G_GROUP, "H5Lget_name_by_idx"); + VERIFY(oinfo.type, H5O_TYPE_GROUP, "H5Lget_name_by_idx"); if(!HDstrcmp(dataset_name, "dtype")) - VERIFY(obj_type, H5G_TYPE, "H5Lget_name_by_idx"); + VERIFY(oinfo.type, H5O_TYPE_NAMED_DATATYPE, "H5Lget_name_by_idx"); if(!HDstrncmp(dataset_name, "Dataset", (size_t)7)) - VERIFY(obj_type, H5G_DATASET, "H5Lget_name_by_idx"); + VERIFY(oinfo.type, H5O_TYPE_DATASET, "H5Lget_name_by_idx"); } /* end for */ H5E_BEGIN_TRY { @@ -845,7 +841,6 @@ static void test_links(hid_t fapl) char obj_name[NAMELEN]; /* Names of the object in group */ ssize_t name_len; /* Length of object's name */ hid_t gid, gid1; - H5G_obj_t obj_type; /* Type of object */ H5G_info_t ginfo; /* Buffer for querying object's info */ hsize_t i; herr_t ret; /* Generic return value */ @@ -875,24 +870,34 @@ static void test_links(hid_t fapl) CHECK(ret, FAIL, "H5Gget_info"); VERIFY(ginfo.nlinks, 3, "H5Gget_info"); - /* Test these two functions, H5Gget_objtype_by_idx and H5Lget_name_by_idx */ + /* Test these two functions, H5Oget_info_by_idx and H5Lget_name_by_idx */ for(i = 0; i < ginfo.nlinks; i++) { - /* Get object name */ + H5O_info_t oinfo; /* Object info */ + H5L_info_t linfo; /* Link info */ + + /* Get link name */ name_len = H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, i, obj_name, (size_t)NAMELEN, H5P_DEFAULT); CHECK(name_len, FAIL, "H5Lget_name_by_idx"); - obj_type = H5Gget_objtype_by_idx(gid, i); - CHECK(obj_type, H5G_UNKNOWN, "H5Gget_objtype_by_idx"); + /* Get link type */ + ret = H5Lget_info_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &linfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Lget_info_by_idx"); + + /* Get object type */ + if(linfo.type == H5L_TYPE_HARD) { + ret = H5Oget_info_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_idx"); + } /* end if */ if(!HDstrcmp(obj_name, "g1.1")) - VERIFY(obj_type, H5G_GROUP, "H5Lget_name_by_idx"); + VERIFY(oinfo.type, H5O_TYPE_GROUP, "H5Lget_name_by_idx"); else if(!HDstrcmp(obj_name, "hardlink")) - VERIFY(obj_type, H5G_GROUP, "H5Lget_name_by_idx"); + VERIFY(oinfo.type, H5O_TYPE_GROUP, "H5Lget_name_by_idx"); else if(!HDstrcmp(obj_name, "softlink")) - VERIFY(obj_type, H5G_LINK, "H5Lget_name_by_idx"); + VERIFY(linfo.type, H5L_TYPE_SOFT, "H5Lget_name_by_idx"); else CHECK(0, 0, "unknown object name"); - } + } /* end for */ ret = H5Gclose(gid); CHECK(ret, FAIL, "H5Gclose"); diff --git a/test/trefer.c b/test/trefer.c index 802ab79..aff967a 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -937,7 +937,7 @@ test_reference_obj_deleted(void) ** ****************************************************************/ static herr_t -test_deref_iter_op(hid_t UNUSED group, const char *name, const H5L_info_t *info, +test_deref_iter_op(hid_t UNUSED group, const char *name, const H5L_info_t UNUSED *info, void *op_data) { int *count = (int *)op_data; /* Pointer to name counter */ @@ -987,7 +987,7 @@ test_reference_group(void) hobj_ref_t rref; /* Reference to read */ H5G_info_t ginfo; /* Group info struct */ char objname[NAME_SIZE]; /* Buffer to store name */ - H5G_obj_t objtype; /* Object type */ + H5O_info_t oinfo; /* Object info struct */ int count = 0; /* Count within iterated group */ herr_t ret; @@ -1073,8 +1073,9 @@ test_reference_group(void) CHECK(ret, FAIL, "H5Lget_name_by_idx"); VERIFY_STR(objname, DSETNAME2, "H5Lget_name_by_idx"); - objtype = H5Gget_objtype_by_idx(gid, (hsize_t)0); - VERIFY(objtype, H5G_DATASET, "H5Gget_objtype_by_idx"); + ret = H5Oget_info_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_idx"); + VERIFY(oinfo.type, H5O_TYPE_DATASET, "H5Oget_info_by_idx"); /* Unlink one of the objects in the dereferenced group */ ret = H5Ldelete(gid, GROUPNAME2, H5P_DEFAULT); |