[svn-r12875] Description:

Fix retrieving name for references to root group.

    Also, move 'ref' test earlier in testing, right after 'getname' test

Tested on:
    Linux/64 2.6 (chicago2)
This commit is contained in:
Quincey Koziol 2006-11-07 12:06:42 -05:00
parent c17b59ac25
commit de285fb909
6 changed files with 35 additions and 16 deletions

View File

@ -52,6 +52,7 @@ typedef struct H5G_ref_path_iter_t {
/* In */
hid_t file; /* File id where it came from */
hid_t dxpl_id; /* DXPL for operations */
hbool_t is_root_group; /* Flag to indicate that the root group is being looked at */
const H5O_loc_t *loc; /* The location of the object we're looking for */
/* In/Out */
@ -1115,7 +1116,10 @@ H5G_refname_iterator(hid_t group, const char *name, void *_udata)
len = HDstrlen(udata->container);
if(NULL == (udata->container = H5MM_realloc(udata->container, HDstrlen(udata->container) + HDstrlen(name) + 2)))
HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate path string")
HDstrcat(udata->container, name);
if(!udata->is_root_group)
HDstrcat(udata->container, name);
else
udata->is_root_group = FALSE;
HDstrcat(udata->container, "/");
ret_value = H5G_obj_iterate(udata->file, udata->container, H5_ITER_INC, 0, &last_obj, H5G_refname_iterator, udata, udata->dxpl_id);
@ -1183,7 +1187,7 @@ H5G_get_refobj_name(hid_t file, hid_t dxpl_id, const H5O_loc_t *loc,
char *name, size_t size)
{
H5G_ref_path_iter_t udata; /* User data for iteration */
int last_obj = 0; /* Start object for iteration */
herr_t status; /* Status from iteration */
ssize_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_get_refobj_name)
@ -1191,7 +1195,8 @@ H5G_get_refobj_name(hid_t file, hid_t dxpl_id, const H5O_loc_t *loc,
/* Set up user data for iterator */
udata.file = file;
udata.dxpl_id = dxpl_id;
if(NULL == (udata.container = H5MM_strdup("/")))
udata.is_root_group = TRUE;
if(NULL == (udata.container = H5MM_strdup("")))
HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate root group name")
udata.loc = loc;
@ -1200,9 +1205,9 @@ H5G_get_refobj_name(hid_t file, hid_t dxpl_id, const H5O_loc_t *loc,
HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, FAIL, "can't create skip list for path nodes")
/* Iterate over all the objects in the file */
if((ret_value = H5G_obj_iterate(file, "/", H5_ITER_INC, 0, &last_obj, H5G_refname_iterator, &udata, dxpl_id)) < 0)
if((status = H5G_refname_iterator(file, "/", &udata)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group iteration failed while looking for object name")
else if(ret_value > 0) {
else if(status > 0) {
/* Set the length of the full path */
ret_value = HDstrlen(udata.container) + 1;
@ -1213,6 +1218,8 @@ H5G_get_refobj_name(hid_t file, hid_t dxpl_id, const H5O_loc_t *loc,
name[size - 1] = '\0';
} /* end if */
} /* end if */
else
ret_value = 0;
done:
H5MM_xfree(udata.container);

View File

@ -40,8 +40,8 @@ TEST_PROG=testhdf5 lheap ohdr stab gheap cache cache_api \
dtypes dsets cmpd_dset extend external objcopy links unlink big mtime \
fillval mount flush1 flush2 enum \
set_extent ttsafe stream_test \
getname vfd ntypes dangle dtransform reserved cross_read \
btree2 fheap ref
getname ref vfd ntypes dangle dtransform reserved cross_read \
btree2 fheap
# List programs to be built when testing here. error_test and err_compat are
# built at the same time as the other tests, but executed by testerror.sh.

View File

@ -82,9 +82,9 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \
unlink$(EXEEXT) big$(EXEEXT) mtime$(EXEEXT) fillval$(EXEEXT) \
mount$(EXEEXT) flush1$(EXEEXT) flush2$(EXEEXT) enum$(EXEEXT) \
set_extent$(EXEEXT) ttsafe$(EXEEXT) stream_test$(EXEEXT) \
getname$(EXEEXT) vfd$(EXEEXT) ntypes$(EXEEXT) dangle$(EXEEXT) \
getname$(EXEEXT) ref$(EXEEXT) vfd$(EXEEXT) ntypes$(EXEEXT) dangle$(EXEEXT) \
dtransform$(EXEEXT) reserved$(EXEEXT) cross_read$(EXEEXT) \
btree2$(EXEEXT) fheap$(EXEEXT) ref$(EXEEXT)
btree2$(EXEEXT) fheap$(EXEEXT)
am__EXEEXT_2 = gen_deflate$(EXEEXT) gen_filters$(EXEEXT) \
gen_new_array$(EXEEXT) gen_new_fill$(EXEEXT) \
gen_new_group$(EXEEXT) gen_new_mtime$(EXEEXT) \
@ -632,8 +632,8 @@ TEST_PROG = testhdf5 lheap ohdr stab gheap cache cache_api \
dtypes dsets cmpd_dset extend external objcopy links unlink big mtime \
fillval mount flush1 flush2 enum \
set_extent ttsafe stream_test \
getname vfd ntypes dangle dtransform reserved cross_read \
btree2 fheap ref
getname ref vfd ntypes dangle dtransform reserved cross_read \
btree2 fheap
# These programs generate test files for the tests. They don't need to be

View File

@ -818,7 +818,7 @@ int main( void )
/* Verify */
if(check_name(group_id, "/g14/g3/g4", "") < 0) TEST_ERROR;
if(check_name(group2_id, "", "") < 0) TEST_ERROR;
if(check_name(group2_id, "/", "") < 0) TEST_ERROR;
/* Close */
H5Gclose( group_id );
@ -860,7 +860,7 @@ int main( void )
if (H5Funmount(group2_id, ".")<0) TEST_ERROR;
/* Verify */
if(check_name(group2_id, "", "") < 0) TEST_ERROR;
if(check_name(group2_id, "/", "") < 0) TEST_ERROR;
/* Close */
H5Gclose( group2_id );
@ -902,7 +902,7 @@ int main( void )
if (H5Funmount(group2_id, ".")<0) TEST_ERROR;
/* Verify */
if(check_name(group2_id, "", "") < 0) TEST_ERROR;
if(check_name(group2_id, "/", "") < 0) TEST_ERROR;
if(check_name(group3_id, "/g13/g1", "/g13/g1") < 0) TEST_ERROR;
/* Close */

View File

@ -1626,7 +1626,7 @@ external_link_root(hid_t fapl, hbool_t new_format)
/* Check name */
if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
if(name_len != 0) TEST_ERROR
if(HDstrcmp(objname, "/")) TEST_ERROR
/* Create object in external file */
if((gid2 = H5Gcreate(gid, "new_group", (size_t)0)) < 0) TEST_ERROR

View File

@ -34,7 +34,7 @@
/* 1-D dataset with fixed dimensions */
#define SPACE1_RANK 1
#define SPACE1_DIM1 7
#define SPACE1_DIM1 8
int
main(void)
@ -184,6 +184,10 @@ main(void)
if(H5Rcreate(&wbuf[6], fid1, "/Group1/Group2/Link/Dataset5", H5R_OBJECT, -1) < 0)
TEST_ERROR
/* Create reference to root group */
if(H5Rcreate(&wbuf[7], fid1, "/", H5R_OBJECT, -1) < 0)
TEST_ERROR
/* Write selection to disk */
if(H5Dwrite(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0)
TEST_ERROR
@ -243,6 +247,14 @@ main(void)
else
TEST_ERROR
HDmemset(buf, 0, 100);
TESTING("getting path to root group");
i = H5Iget_name(H5Rdereference(dataset, H5R_OBJECT , &wbuf[7]), (char*)buf, 100);
if((HDstrcmp(buf, "/") == 0) && (i == 2))
PASSED()
else
TEST_ERROR
/* Now we mount fid2 at /Group2 and look for dataset4. It shouldn't be found */
if(H5Fmount(fid1, "/Group1/Group2", fid2, H5P_DEFAULT) < 0)
TEST_ERROR