diff options
-rw-r--r-- | release_docs/RELEASE.txt | 3 | ||||
-rw-r--r-- | src/H5Gname.c | 386 | ||||
-rw-r--r-- | src/H5Gprivate.h | 2 | ||||
-rw-r--r-- | src/H5I.c | 3 | ||||
-rw-r--r-- | src/H5Iprivate.h | 1 | ||||
-rw-r--r-- | src/H5public.h | 8 | ||||
-rw-r--r-- | test/getname.c | 885 | ||||
-rw-r--r-- | test/mount.c | 6 |
8 files changed, 1114 insertions, 180 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index ac96520..5895af5 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -80,6 +80,9 @@ Bug Fixes since HDF5-1.6.6 Release Library ------- + - H5Iget_name could not be used with an object identifier returned + by H5Rdereference; the function would not be able to determine + a valid object name. It has been fixed. SLU - 2008/1/30 - Changed library's behavior for reading files that might have corrupted object header information from a previous (buggy) version of the library. By default, the library now rebuilds the diff --git a/src/H5Gname.c b/src/H5Gname.c index 443da48..78c1ea0 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -35,6 +35,7 @@ #include "H5FLprivate.h" /* Free Lists */ #include "H5Gpkg.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory wrappers */ /* Private typedefs */ @@ -47,6 +48,19 @@ typedef struct H5G_names_t { H5RS_str_t *dst_name; /* Name of object relative to destination location */ } H5G_names_t; +/* Info to pass to the iteration function when building name */ +typedef struct H5G_gnba_iter_t { + /* In */ + hid_t file; /* File ID */ + const H5G_entry_t *loc; /* The location of the object we're looking for */ + hid_t dxpl_id; /* DXPL for operations */ + + /* In/Out */ + H5SL_t *grp_table; /* Skip list for tracking visited nodes */ + + /* Out */ + char *path; /* Name of the object */ +} H5G_gnba_iter_t; /* Private macros */ @@ -55,6 +69,9 @@ typedef struct H5G_names_t { /* Declare extern the PQ free list for the wrapped strings */ H5FL_BLK_EXTERN(str_buf); +/* Declare the free list to manage haddr_t's */ +H5FL_DEFINE_STATIC(haddr_t); + /* PRIVATE PROTOTYPES */ static htri_t H5G_common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r); static H5RS_str_t *H5G_build_fullpath(const char *prefix, const char *name); @@ -63,6 +80,10 @@ static H5RS_str_t *H5G_build_fullpath_refstr_str(H5RS_str_t *path_r, const char static herr_t H5G_name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char *src_path, const char *dst_path); static int H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key); +static herr_t H5G_free_grp_table_node(void *item, void *key, void *operator_data/*in,out*/); +static char* H5G_string_append(char *dst, const char *src); +static char* H5G_string_unappend(char *dst, const char *src); +static herr_t H5G_get_name_by_addr_cb(hid_t gid, const char *path, void *_udata); /*------------------------------------------------------------------------- @@ -351,33 +372,57 @@ done: * Programmer: Quincey Koziol * Tuesday, December 13, 2005 * + * Modifications: Raymond Lu + * 15 Jan 2008 + * Added functionality to get the name for a reference data. + * Borrowed most of the code from v1.8. *------------------------------------------------------------------------- */ ssize_t H5G_get_name(hid_t id, char *name/*out*/, size_t size) { H5G_entry_t *ent; /*symbol table entry */ - size_t len = 0; - ssize_t ret_value; + ssize_t ret_value = FAIL; - FUNC_ENTER_NOAPI_NOFUNC(H5G_get_name) + FUNC_ENTER_NOAPI(H5G_get_name, FAIL) /* get symbol table entry */ if(NULL != (ent = H5G_loc(id))) { + ssize_t len = 0; + + /* If the user path is available and it's not "hidden", use it */ if (ent->user_path_r != NULL && ent->obj_hidden == 0) { len = H5RS_len(ent->user_path_r); if(name) { - HDstrncpy(name, H5RS_get_str(ent->user_path_r), MIN(len + 1, size)); - if(len >= size) + HDstrncpy(name, H5RS_get_str(ent->user_path_r), MIN((size_t)len + 1, size)); + if((size_t)len >= size) name[size-1] = '\0'; } /* end if */ } /* end if */ - } /* end if */ + else if(!ent->obj_hidden) { + hid_t file; + + /* Retrieve file ID for name search */ + if((file = H5I_get_file_id(id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve file ID") - /* Set return value */ - ret_value=(ssize_t)len; + /* Search for name of object */ + if((len = H5G_get_name_by_addr(file, H5AC_ind_dxpl_id, ent, name, size)) < 0) { + H5I_dec_ref(file); + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't determine name") + } /* end if */ + + /* Close file ID used for search */ + if(H5I_dec_ref(file) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCLOSEFILE, FAIL, "can't determine name") + } /* end else */ + + /* Set return value */ + ret_value = len; + } /* end if */ +done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_get_name() */ @@ -891,3 +936,328 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_name_replace() */ + +/*------------------------------------------------------------------------- + * Function: H5G_free_grp_table_node + * + * Purpose: Free the key for a group table node + * + * Return: Non-negative on success, negative on failure + * + * Programmer: Quincey Koziol + * + * Modifications: + * Raymond Lu + * 22 January 2008 + * Borrowed this function from v1.8. + *------------------------------------------------------------------------- + */ +static herr_t +H5G_free_grp_table_node(void *item, void UNUSED *key, void UNUSED *operator_data/*in,out*/) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_free_grp_table_node) + + H5FL_FREE(haddr_t, item); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5G_free_grp_table_node() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_string_append + * + * Purpose: Private function to append a path name. + * + * Return: Pointer to the string being appended. + * NULL on failure. + * + * Programmer: Raymond Lu + * 30 January 2008 + *------------------------------------------------------------------------- + */ +static char* +H5G_string_append(char *dst, const char *src) +{ + size_t src_len, dst_len; + size_t len_needed; /* Length of path string needed */ + char *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5G_string_append) + + if(!dst) + dst_len = 0; + else + dst_len = strlen(dst); + + if(!src) + src_len = 0; + else + src_len = strlen(src); + + if(src_len) { + if(dst_len) { + len_needed = dst_len + src_len + 2; + if((dst = H5MM_realloc(dst, len_needed)) == NULL) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, NULL, "can't allocate space") + + dst = strcat(dst, "/"); + dst = strcat(dst, src); + } else { + len_needed = src_len + 1; + if((dst = H5MM_malloc(len_needed)) == NULL) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, NULL, "can't allocate space") + + dst = strncpy(dst, src, src_len); + dst[len_needed-1] = '\0'; + } + } + + ret_value = dst; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5G_string_append */ + + +/*------------------------------------------------------------------------- + * Function: H5G_string_unappend + * + * Purpose: Private function to unappend a path name. + * + * Return: Pointer to the string being unappended. + * NULL on failure. + * + * Programmer: Raymond Lu + * 30 January 2008 + *------------------------------------------------------------------------- + */ +static char* +H5G_string_unappend(char *dst, const char *src) +{ + size_t src_len, dst_len; + size_t len_needed; /* Length of path string needed */ + char *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5G_string_unappend) + + if(!dst) + dst_len = 0; + else + dst_len = strlen(dst); + + if(!src) + src_len = 0; + else + src_len = strlen(src); + + if(dst_len >= (src_len + 1)) + len_needed = dst_len - (src_len + 1) + 1; + else + len_needed = 1; + + if((dst = H5MM_realloc(dst, len_needed)) == NULL) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, NULL, "can't reallocate space") + + dst[len_needed - 1] = '\0'; + ret_value = dst; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5G_string_unappend */ + + +/*------------------------------------------------------------------------- + * Function: H5G_get_name_by_addr_cb + * + * Purpose: Callback for retrieving object's name by address + * + * Return: Positive if path is for object desired + * 0 if not correct object + * negative on failure. + * + * Programmer: Quincey Koziol + * November 4 2007 + * + * Modifications: + * Raymond Lu + * 15 Jan 2008 + * This function was borrowed from v1.8 with some modifications. + * It's written by Quincey. + *------------------------------------------------------------------------- + */ +static herr_t +H5G_get_name_by_addr_cb(hid_t gid, const char *path, void *_udata) +{ + H5G_gnba_iter_t *udata = (H5G_gnba_iter_t *)_udata; /* User data for iteration */ + H5G_entry_t *group_ent, object_ent; + H5G_stat_t obj_stat; + int idx = 0; + haddr_t *new_node; /* New group node for table */ + int status; /* Status from iteration */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5G_get_name_by_addr_cb) + + /* Sanity check */ + HDassert(path); + HDassert(udata->loc); + + if((group_ent = H5G_loc(gid)) == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "bad group location") + + /* To handle dangling symbolic link, return continue instead of failure */ + if(H5G_find(group_ent, path, &object_ent, udata->dxpl_id) < 0) + HGOTO_DONE(H5_ITER_CONT) + + /* Check for object in same file (handles mounted files) */ + if(object_ent.header == udata->loc->header && object_ent.file == udata->loc->file) { + if((udata->path = H5G_string_append(udata->path, path)) == NULL) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, H5_ITER_ERROR, "can't append path space") + + /* Free the ID to name buffer */ + H5G_name_free(&object_ent); + + /* We found a match so we return immediately */ + HGOTO_DONE(H5_ITER_STOP) + } /* end if */ + + /* Free the ID to name buffer */ + H5G_name_free(&object_ent); + + /* Check if we've seen this object before */ + if(H5SL_search(udata->grp_table, &object_ent.header)) + HGOTO_DONE(H5_ITER_CONT) + + /* Allocate new path node */ + if((new_node = H5FL_MALLOC(haddr_t)) == NULL) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, H5_ITER_ERROR, "can't allocate group node") + + /* Set node information */ + *new_node = object_ent.header; + + /* Insert this object into skip list */ + if(H5SL_insert(udata->grp_table, new_node, new_node) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5_ITER_ERROR, "can't insert path node into table") + + if(H5G_get_objinfo(group_ent, path, FALSE, &obj_stat, udata->dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "can't get object's stat") + + /* Recursively search the groups */ + if(H5G_GROUP == obj_stat.type) { + /* Append the path name of the current group */ + if((udata->path = H5G_string_append(udata->path, path)) == NULL) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, H5_ITER_ERROR, "can't append path space") + + /* Iterate all the links */ + if((status = H5Giterate(gid, path, &idx, H5G_get_name_by_addr_cb, udata)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group iteration failed while looking for object name") + else if(status > 0) + /* If the object is found */ + HGOTO_DONE(H5_ITER_STOP) + else { + /* Chop off the path name of the current group if object isn't found */ + if((udata->path = H5G_string_unappend(udata->path, path)) == NULL ) + HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, H5_ITER_ERROR, "can't unappend path name") + } + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_get_name_by_addr_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_get_name_by_addr + * + * Purpose: Tries to figure out the path to an object from it's address + * + * Return: returns size of path name, and copies it into buffer + * pointed to by name if that buffer is big enough. + * 0 if it cannot find the path + * negative on failure. + * + * Programmer: Quincey Koziol + * November 4 2007 + * + * Modifications: + * Raymond Lu + * 15 Jan 2008 + * This function was borrowed from v1.8 with some modifications, + * primarily changing H5G_visit to H5Giterate. It's written + * by Quincey. + *------------------------------------------------------------------------- + */ +ssize_t +H5G_get_name_by_addr(hid_t file, hid_t dxpl_id, const H5G_entry_t *loc, + char *name, size_t size) +{ + H5G_gnba_iter_t udata; /* User data for iteration */ + H5G_entry_t *root_loc; /* Root group's location */ + hbool_t found_obj = FALSE; /* If we found the object */ + int idx = 0; + int status; /* Status from iteration */ + ssize_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5G_get_name_by_addr, FAIL) + + HDmemset(&udata, 0, sizeof(H5G_gnba_iter_t)); + + /* Construct the link info for the file's root group */ + if((root_loc = H5G_loc(file)) == NULL) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get root group's location") + + /* Check for root group being the object looked for */ + if(root_loc->header == loc->header && root_loc->file == loc->file) { + udata.path = H5MM_strdup(""); + found_obj = TRUE; + } /* end if */ + else { + /* Set up user data for iterator */ + udata.file = file; + udata.loc = loc; + udata.dxpl_id = dxpl_id; + udata.path = NULL; + + /* Create skip list to keep track of visited group nodes */ + if((udata.grp_table = H5SL_create(H5SL_TYPE_HADDR, 0.5, (size_t)16)) == NULL) + HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, FAIL, "can't create skip list for group nodes") + + /* Iterate all the links in the file */ + if((status = H5Giterate(file, "/", &idx, H5G_get_name_by_addr_cb, &udata)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group iteration failed while looking for object name") + else if(status > 0) + found_obj = TRUE; + } /* end else */ + + /* Check for finding the object */ + if(found_obj) { + size_t full_path_len = HDstrlen(udata.path) + 1; /* Length of path + 1 (for "/") */ + + /* Set the length of the full path */ + ret_value = full_path_len; + + /* If there's a buffer provided, copy into it, up to the limit of its size */ + if(name) { + /* Copy the initial path separator */ + HDstrcpy(name, "/"); + + /* Append the rest of the path */ + /* (less one character, for the initial path separator) */ + HDstrncat(name, udata.path, (size - 1)); + if((size_t)ret_value >= size) + name[size - 1] = '\0'; + } /* end if */ + } /* end if */ + else + ret_value = 0; + +done: + /* Release resources */ + H5MM_xfree(udata.path); + + if(udata.grp_table) + H5SL_destroy(udata.grp_table, H5G_free_grp_table_node, NULL); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_get_name_by_addr() */ + diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 6fe4e17..75328a3 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -177,6 +177,8 @@ H5_DLL herr_t H5G_name_free(H5G_entry_t *ent); H5_DLL herr_t H5G_name_replace(int type, H5G_entry_t *loc, H5RS_str_t *dst_name, H5G_entry_t *dst_loc, H5G_names_op_t op); H5_DLL ssize_t H5G_get_name(hid_t id, char *name/*out*/, size_t size); +H5_DLL ssize_t H5G_get_name_by_addr(hid_t file, hid_t dxpl_id, const H5G_entry_t *loc, + char *name, size_t size); #endif @@ -114,7 +114,6 @@ H5FL_DEFINE_STATIC(H5I_id_info_t); /*--------------------- Local function prototypes ---------------------------*/ static H5I_id_info_t *H5I_find_id(hid_t id); -static hid_t H5I_get_file_id(hid_t obj_id); #ifdef H5I_DEBUG_OUTPUT static herr_t H5I_debug(H5I_type_t grp); #endif /* H5I_DEBUG_OUTPUT */ @@ -1464,7 +1463,7 @@ done: * *------------------------------------------------------------------------- */ -static hid_t +hid_t H5I_get_file_id(hid_t obj_id) { H5G_entry_t *ent; diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index f477570..810c893 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -64,6 +64,7 @@ H5_DLL herr_t H5I_destroy_group(H5I_type_t grp); H5_DLL hid_t H5I_register(H5I_type_t grp, void *object); H5_DLL void *H5I_object(hid_t id); H5_DLL void *H5I_object_verify(hid_t id, H5I_type_t id_type); +H5_DLL hid_t H5I_get_file_id(hid_t); H5_DLL H5I_type_t H5I_get_type(hid_t id); H5_DLL void *H5I_remove(hid_t id); H5_DLL void *H5I_search(H5I_type_t grp, H5I_search_func_t func, void *key); diff --git a/src/H5public.h b/src/H5public.h index a3b8c37..8209de6 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -211,6 +211,14 @@ typedef ssize_t hssize_t; #endif #define HADDR_MAX (HADDR_UNDEF-1) +/* Iteration callback values */ +/* (Actually, any postive value will cause the iterator to stop and pass back + * that positive value to the function that called the iterator) + */ +#define H5_ITER_ERROR (-1) +#define H5_ITER_CONT (0) +#define H5_ITER_STOP (1) + /* Functions in H5.c */ H5_DLL herr_t H5open(void); H5_DLL herr_t H5close(void); diff --git a/test/getname.c b/test/getname.c index 2e8f112..72930f0 100644 --- a/test/getname.c +++ b/test/getname.c @@ -41,6 +41,9 @@ const char *FILENAME[] = { "getname1", "getname2", "getname3", + "getname4", + "getname5", + "getname6", NULL }; @@ -48,9 +51,30 @@ const char *FILENAME[] = { #define NX 4 #define NY 5 +/* Object reference macros */ +#define SPACE1_RANK 1 +#define SPACE1_DIM1 8 + +/* Dataset region reference macros */ +#define REFREG_DSETNAMEV "MATRIX" +#define REFREG_DSETNAMER "REGION_REFERENCES" + #define NAME_BUF_SIZE 64 #define SMALL_NAME_BUF_SIZE 2 +/*------------------------------------------------------------------------- + * Function: check_name + * + * Purpose: Private function to test H5Iget_name and H5G_user_path_test. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu> + * April 12, 2002 + * + *------------------------------------------------------------------------- + */ static int check_name(hid_t id, const char *chk_name, const char *chk_user_path) { @@ -84,27 +108,43 @@ error: return -1; } -int main( void ) + +/*------------------------------------------------------------------------- + * Function: test_main + * + * Purpose: Tests the "ID to name" functionality. Test H5Iget_name + * for some major cases, like group, file mounting, named + * datatype. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu> + * April 12, 2002 + * + * Modifications: + * Added test for groups with cycle. + * Raymond Lu + * 30 January 2008 + *------------------------------------------------------------------------- + */ +static int test_main(hid_t fapl ) { char filename0[1024]; char filename1[1024]; char filename2[1024]; char filename3[1024]; - hid_t fapl; hid_t file_id, file1_id, file2_id, file3_id; hid_t group_id, group2_id, group3_id, group4_id, group5_id, group6_id, group7_id; hid_t dataset_id, dataset2_id; hid_t space_id; hid_t type_id, type2_id; hsize_t dims[1] = { 5 }; + size_t shint = 0; /* Name length */ size_t name_len; - /* Reset the library and get the file access property list */ - h5_reset(); - fapl = h5_fileaccess(); - /* Initialize the file names */ h5_fixname(FILENAME[0], fapl, filename0, sizeof filename0); h5_fixname(FILENAME[1], fapl, filename1, sizeof filename1); @@ -114,7 +154,6 @@ int main( void ) /* Create a new file_id using default properties. */ if ((file_id = H5Fcreate( filename0, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ))<0) TEST_ERROR; - /*------------------------------------------------------------------------- * Test H5Iget_name with H5Gcreate, one group *------------------------------------------------------------------------- @@ -123,7 +162,7 @@ int main( void ) TESTING("H5Iget_name with H5Gcreate, one group"); /* Create group "g0" in the root group using absolute name */ - if ((group_id = H5Gcreate( file_id, "/g0", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g0", shint ))<0) TEST_ERROR; /* Verify */ if(check_name(group_id, "/g0", "/g0") < 0) TEST_ERROR; @@ -143,10 +182,10 @@ int main( void ) TESTING("H5Iget_name with H5Gcreate, more than one group"); /* Create group "g1" in the root group using absolute name */ - if ((group_id = H5Gcreate( file_id, "/g1", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g1", shint ))<0) TEST_ERROR; /* Create group "g2" in group "g1" using absolute name */ - if ((group2_id = H5Gcreate( file_id, "/g1/g2", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g1/g2", shint ))<0) TEST_ERROR; /* Verify */ if(check_name(group_id, "/g1", "/g1") < 0) TEST_ERROR; @@ -268,9 +307,9 @@ int main( void ) TESTING("H5Iget_name with a long path"); /* Create group "g2/bar/baz" */ - if ((group_id = H5Gcreate( file_id, "g2", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "g2/bar", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file_id, "g2/bar/baz", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "g2", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "g2/bar", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "g2/bar/baz", shint ))<0) TEST_ERROR; /* Create a dataset */ if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) TEST_ERROR; @@ -419,10 +458,10 @@ int main( void ) TESTING("H5Iget_name with H5Gmove and relative names"); /* Create group "/g3" */ - if ((group_id = H5Gcreate( file_id, "/g3", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g3", shint ))<0) TEST_ERROR; /* Create group "/g3/foo" using absolute name */ - if ((group2_id = H5Gcreate( file_id, "/g3/foo1", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g3/foo1", shint ))<0) TEST_ERROR; /* Open group "/g3/foo" again */ if ((group3_id = H5Gopen( file_id, "/g3/foo1"))<0) TEST_ERROR; @@ -469,13 +508,13 @@ int main( void ) TESTING("H5Iget_name with H5Gmove and a long path"); /* Create group "g4/A/B" */ - if ((group_id = H5Gcreate( file_id, "g4", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "g4/A", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file_id, "g4/A/B", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "g4", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "g4/A", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "g4/A/B", shint ))<0) TEST_ERROR; /* Create group "g5/C" */ - if ((group4_id = H5Gcreate( file_id, "g5", 0 ))<0) TEST_ERROR; - if ((group5_id = H5Gcreate( file_id, "g5/C", 0 ))<0) TEST_ERROR; + if ((group4_id = H5Gcreate( file_id, "g5", shint ))<0) TEST_ERROR; + if ((group5_id = H5Gcreate( file_id, "g5/C", shint ))<0) TEST_ERROR; /* Verify */ if(check_name(group3_id, "/g4/A/B", "/g4/A/B") < 0) TEST_ERROR; @@ -519,10 +558,10 @@ int main( void ) TESTING("H5Iget_name with H5Gmove and a long path #2"); /* Create group "g6/A/B" and "g7" */ - if ((group_id = H5Gcreate( file_id, "g6", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "g6/A", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file_id, "g6/A/B", 0 ))<0) TEST_ERROR; - if ((group4_id = H5Gcreate( file_id, "g7", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "g6", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "g6/A", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "g6/A/B", shint ))<0) TEST_ERROR; + if ((group4_id = H5Gcreate( file_id, "g7", shint ))<0) TEST_ERROR; /* Verify */ if(check_name(group3_id, "/g6/A/B", "/g6/A/B") < 0) TEST_ERROR; @@ -552,7 +591,7 @@ int main( void ) TESTING("H5Iget_name with H5Gunlink"); /* Create a new group. */ - if ((group_id = H5Gcreate( file_id, "/g8", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g8", shint ))<0) TEST_ERROR; /* Delete */ if (H5Gunlink( file_id, "/g8")<0) TEST_ERROR; @@ -573,9 +612,9 @@ int main( void ) TESTING("H5Iget_name with H5Gunlink and a long path"); /* Create group "g9/a/b" */ - if ((group_id = H5Gcreate( file_id, "g9", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "g9/a", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file_id, "g9/a/b", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "g9", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "g9/a", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "g9/a/b", shint ))<0) TEST_ERROR; /* Delete */ if (H5Gunlink( file_id, "/g9/a")<0) TEST_ERROR; @@ -591,8 +630,8 @@ int main( void ) H5Gclose( group3_id ); /* Recreate groups */ - if ((group2_id = H5Gcreate( group_id, "a", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( group_id, "a/b", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( group_id, "a", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( group_id, "a/b", shint ))<0) TEST_ERROR; /* Delete, using relative path */ if (H5Gunlink( group_id, "a")<0) TEST_ERROR; @@ -611,9 +650,9 @@ int main( void ) H5Gclose( group_id ); /* Create group "g10/a/b" */ - if ((group_id = H5Gcreate( file_id, "g10", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "g10/a", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file_id, "g10/a/b", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "g10", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "g10/a", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "g10/a/b", shint ))<0) TEST_ERROR; /* Delete */ if (H5Gunlink( file_id, "/g10/a/b")<0) TEST_ERROR; @@ -625,7 +664,7 @@ int main( void ) H5Gclose( group3_id ); /* Recreate group */ - if ((group3_id = H5Gcreate( group_id, "a/b", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( group_id, "a/b", shint ))<0) TEST_ERROR; /* Delete, using relative path */ if (H5Gunlink( group_id, "a/b")<0) TEST_ERROR; @@ -651,8 +690,8 @@ int main( void ) /* Create group "g11/g" */ - if ((group_id = H5Gcreate( file_id, "g11", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "g11/g", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "g11", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "g11/g", shint ))<0) TEST_ERROR; /* Create two datasets "g11/d" and "g11/g/d"*/ if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) TEST_ERROR; @@ -686,7 +725,7 @@ int main( void ) TESTING("H5Iget_name with H5Fmount; with IDs on the list"); /* Create a group "g12" in the first file */ - if ((group_id = H5Gcreate( file_id, "/g12", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g12", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -731,9 +770,9 @@ int main( void ) TESTING("H5Iget_name with H5Fmount; long name"); /* Create a group "g13/g1/g2" in the first file */ - if ((group_id = H5Gcreate( file_id, "/g13", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "/g13/g1", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file_id, "/g13/g1/g2", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g13", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g13/g1", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "/g13/g1/g2", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -743,9 +782,9 @@ int main( void ) /* Create second file and group "g" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g14", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file1_id, "/g14/g3", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file1_id, "/g14/g3/g4", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file1_id, "/g14", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g14/g3", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file1_id, "/g14/g3/g4", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -765,7 +804,7 @@ int main( void ) /* Verify */ - if(check_name(group_id, "", "") < 0) TEST_ERROR; + if(check_name(group_id, "/g14/g3/g4", "") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -790,7 +829,7 @@ int main( void ) if (H5Funmount(group2_id, "g1")<0) TEST_ERROR; /* Verify */ - if(check_name(group_id, "", "") < 0) TEST_ERROR; + if(check_name(group_id, "/g14/g3/g4", "") < 0) TEST_ERROR if(check_name(group3_id, "/g14/g3/g4", "/g14/g3/g4") < 0) TEST_ERROR; /* Close */ @@ -814,8 +853,8 @@ int main( void ) if (H5Funmount(group2_id, ".")<0) TEST_ERROR; /* Verify */ - if(check_name(group_id, "", "") < 0) TEST_ERROR; - if(check_name(group2_id, "", "") < 0) TEST_ERROR; + if(check_name(group_id, "/g14/g3/g4", "") < 0) TEST_ERROR + if(check_name(group2_id, "/", "") < 0) TEST_ERROR /* Close */ H5Gclose( group_id ); @@ -857,7 +896,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 ); @@ -899,7 +938,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 */ @@ -920,10 +959,10 @@ int main( void ) TESTING("H5Iget_name with H5Funmount"); /* Create a group "g15/g1/g2" in the first file */ - if ((group_id = H5Gcreate( file_id, "/g15", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "/g15/g1", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file_id, "/g15/g1/g2", 0 ))<0) TEST_ERROR; - if ((group4_id = H5Gcreate( file_id, "/g15/g1/g2/g3", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g15", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g15/g1", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "/g15/g1/g2", shint ))<0) TEST_ERROR; + if ((group4_id = H5Gcreate( file_id, "/g15/g1/g2/g3", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -934,9 +973,9 @@ int main( void ) /* Create second file and group "g" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g16", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file1_id, "/g16/g4", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file1_id, "/g16/g4/g5", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file1_id, "/g16", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g16/g4", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file1_id, "/g16/g4/g5", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -964,7 +1003,7 @@ int main( void ) if(check_name(group_id, "/g15/g1/g2/g3", "/g15/g1/g2/g3") < 0) TEST_ERROR; /* Verify */ - if(check_name(group2_id, "", "") < 0) TEST_ERROR; + if(check_name(group2_id, "/g16/g4/g5", "") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -991,7 +1030,7 @@ int main( void ) if (H5Tinsert (type_id, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT)<0) TEST_ERROR; /* Create group "g17" */ - if ((group_id = H5Gcreate( file_id, "g17", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "g17", shint ))<0) TEST_ERROR; /* Save datatype for later */ if (H5Tcommit (group_id, "t", type_id)<0) TEST_ERROR; @@ -1025,7 +1064,7 @@ int main( void ) if((type_id=H5Dget_type(dataset_id))<0) TEST_ERROR; /* Verify */ - if(check_name(type_id, "", "") < 0) TEST_ERROR; + if(check_name(type_id, "/g17/t", "") < 0) TEST_ERROR; /* Close */ H5Dclose( dataset_id ); @@ -1259,8 +1298,8 @@ PASSED(); TESTING("H5Iget_name with added names with mounting"); /* Create a group "g18/g2" in the first file */ - if ((group_id = H5Gcreate( file_id, "/g18", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "/g18/g2", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g18", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g18/g2", shint ))<0) TEST_ERROR; /* Also create a dataset and a datatype */ if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) TEST_ERROR; @@ -1272,9 +1311,9 @@ PASSED(); /* Create second file and group "/g3/g4/g5" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group3_id = H5Gcreate( file1_id, "/g3", 0 ))<0) TEST_ERROR; - if ((group4_id = H5Gcreate( file1_id, "/g3/g4", 0 ))<0) TEST_ERROR; - if ((group5_id = H5Gcreate( file1_id, "/g3/g4/g5", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file1_id, "/g3", shint ))<0) TEST_ERROR; + if ((group4_id = H5Gcreate( file1_id, "/g3/g4", shint ))<0) TEST_ERROR; + if ((group5_id = H5Gcreate( file1_id, "/g3/g4/g5", shint ))<0) TEST_ERROR; /* Mount first file at "g3/g4" in the second file */ if (H5Fmount(file1_id, "/g3/g4", file_id, H5P_DEFAULT)<0) TEST_ERROR; @@ -1312,9 +1351,9 @@ PASSED(); if(check_name(type_id, "/g18/t2", "/g18/t2") < 0) TEST_ERROR; /* Get name for the IDs of the second file, should be "" */ - if(check_name(group6_id, "", "") < 0) TEST_ERROR; - if(check_name(dataset2_id, "", "") < 0) TEST_ERROR; - if(check_name(type2_id, "", "") < 0) TEST_ERROR; + if(check_name(group6_id, "/g18/g2", "") < 0) TEST_ERROR; + if(check_name(dataset2_id, "/g18/d2", "") < 0) TEST_ERROR; + if(check_name(type2_id, "/g18/t2", "") < 0) TEST_ERROR; H5Tclose( type_id ); H5Tclose( type2_id ); @@ -1340,8 +1379,8 @@ PASSED(); /* Create a file and group "/g1/g2" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g1", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file1_id, "/g1/g2", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file1_id, "/g1", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g1/g2", shint ))<0) TEST_ERROR; /* Verify */ if(check_name(group2_id, "/g1/g2", "/g1/g2") < 0) TEST_ERROR; @@ -1368,13 +1407,13 @@ PASSED(); /* Create a file and group "/g1/g2" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g1", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file1_id, "/g1/g2", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file1_id, "/g1", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g1/g2", shint ))<0) TEST_ERROR; /* Create a new file and group "/g3/g4" in it */ if ((file2_id = H5Fcreate( filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file2_id, "/g3", 0 ))<0) TEST_ERROR; - if ((group4_id = H5Gcreate( file2_id, "/g3/g4", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file2_id, "/g3", shint ))<0) TEST_ERROR; + if ((group4_id = H5Gcreate( file2_id, "/g3/g4", shint ))<0) TEST_ERROR; /* Mount first file at "/g3/g4" in the second file */ if(H5Fmount(file2_id, "/g3/g4", file1_id, H5P_DEFAULT)<0) TEST_ERROR; @@ -1416,13 +1455,13 @@ PASSED(); /* Create a file and group "/g1/g2" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g1", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file1_id, "/g1/g2", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file1_id, "/g1", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g1/g2", shint ))<0) TEST_ERROR; /* Create a new file and group "/g3/g4" in it */ if ((file2_id = H5Fcreate( filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file2_id, "/g3", 0 ))<0) TEST_ERROR; - if ((group4_id = H5Gcreate( file2_id, "/g3/g4", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file2_id, "/g3", shint ))<0) TEST_ERROR; + if ((group4_id = H5Gcreate( file2_id, "/g3/g4", shint ))<0) TEST_ERROR; /* Mount first file at "g3/g4" in the second file */ if(H5Fmount(file2_id, "/g3/g4", file1_id, H5P_DEFAULT)<0) TEST_ERROR; @@ -1514,8 +1553,8 @@ PASSED(); TESTING("H5Iget_name with H5Glink hard"); /* Create group "g19/g1" */ - if ((group_id = H5Gcreate( file_id, "/g19", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "/g19/g1", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g19", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g19/g1", shint ))<0) TEST_ERROR; /* Create hard link to "g19/g1/ group */ if (H5Glink(file_id, H5G_LINK_HARD, "/g19/g1", "/g19/g2")<0) TEST_ERROR; @@ -1556,7 +1595,7 @@ PASSED(); if (H5Gunlink( file_id, "/g19/g3")<0) TEST_ERROR; /* Verify */ - if(check_name(group4_id, "", "") < 0) TEST_ERROR; + if(check_name(group4_id, "/g19/g1", "") < 0) TEST_ERROR; if(check_name(group2_id, "/g19/g1", "/g19/g1") < 0) TEST_ERROR; if(check_name(group3_id, "/g19/g2", "/g19/g2") < 0) TEST_ERROR; @@ -1576,7 +1615,7 @@ PASSED(); if (H5Gunlink( group_id, "g3")<0) TEST_ERROR; /* Verify */ - if(check_name(group4_id, "", "") < 0) TEST_ERROR; + if(check_name(group4_id, "/g19/g1", "") < 0) TEST_ERROR; if(check_name(group2_id, "/g19/g1", "/g19/g1") < 0) TEST_ERROR; if(check_name(group3_id, "/g19/g2", "/g19/g2") < 0) TEST_ERROR; @@ -1600,8 +1639,8 @@ PASSED(); TESTING("H5Iget_name with H5Glink symbolic"); /* Create group "g20/g1" */ - if ((group_id = H5Gcreate( file_id, "/g20", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "/g20/g1", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g20", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g20/g1", shint ))<0) TEST_ERROR; /* Create symbolic link to "g20/g1/ group */ if (H5Glink(file_id, H5G_LINK_SOFT, "/g20/g1", "/g20/g2")<0) TEST_ERROR; @@ -1631,8 +1670,8 @@ PASSED(); TESTING("H5Iget_name with H5Glink symbolic and move target"); /* Create group "g21/g1" */ - if ((group_id = H5Gcreate( file_id, "/g21", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "/g21/g1", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g21", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g21/g1", shint ))<0) TEST_ERROR; /* Create symbolic link to "g21/g1/ group */ if (H5Glink(file_id, H5G_LINK_SOFT, "/g21/g1", "/g21/g2")<0) TEST_ERROR; @@ -1666,8 +1705,8 @@ PASSED(); TESTING("H5Iget_name with H5Glink symbolic and move source"); /* Create group "g22/g1" */ - if ((group_id = H5Gcreate( file_id, "/g22", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "/g22/g1", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g22", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g22/g1", shint ))<0) TEST_ERROR; /* Create symbolic link to "g22/g1/ group */ if (H5Glink(file_id, H5G_LINK_SOFT, "/g22/g1", "/g22/g2")<0) TEST_ERROR; @@ -1699,8 +1738,6 @@ PASSED(); PASSED(); - - /*------------------------------------------------------------------------- * Test H5Iget_name with H5Glink symbolic and unlink target *------------------------------------------------------------------------- @@ -1709,8 +1746,8 @@ PASSED(); TESTING("H5Iget_name with H5Glink symbolic and unlink target"); /* Create group "g23/g1" */ - if ((group_id = H5Gcreate( file_id, "/g23", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "/g23/g1", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g23", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g23/g1", shint ))<0) TEST_ERROR; /* Create symbolic link to "g23/g1/ group */ if (H5Glink(file_id, H5G_LINK_SOFT, "/g23/g1", "/g23/g2")<0) TEST_ERROR; @@ -1742,8 +1779,8 @@ PASSED(); TESTING("H5Iget_name with H5Glink symbolic and unlink source"); /* Create group "g24/g1" */ - if ((group_id = H5Gcreate( file_id, "/g24", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "/g24/g1", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g24", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g24/g1", shint ))<0) TEST_ERROR; /* Create symbolic link to "g24/g1/ group */ if (H5Glink(file_id, H5G_LINK_SOFT, "/g24/g1", "/g24/g2")<0) TEST_ERROR; @@ -1758,7 +1795,7 @@ PASSED(); if (H5Gunlink( file_id, "/g24/g2")<0) TEST_ERROR; /* Verify */ - if(check_name(group3_id, "", "") < 0) TEST_ERROR; + if(check_name(group3_id, "/g24/g1", "") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -1775,9 +1812,9 @@ PASSED(); TESTING("H5Iget_name with several nested mounted files"); /* Create a group "g25/g1/g2" in the first file */ - if ((group_id = H5Gcreate( file_id, "/g25", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "/g25/g1", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file_id, "/g25/g1/g2", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g25", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g25/g1", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "/g25/g1/g2", shint))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -1787,9 +1824,9 @@ PASSED(); /* Create second file and group "/g26/g3/g4" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g26", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file1_id, "/g26/g3", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file1_id, "/g26/g3/g4", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file1_id, "/g26", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g26/g3", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file1_id, "/g26/g3/g4", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -1799,9 +1836,9 @@ PASSED(); /* Create third file and group "/g27/g5/g6" in it */ file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file2_id, "/g27", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file2_id, "/g27/g5", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file2_id, "/g27/g5/g6", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file2_id, "/g27", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file2_id, "/g27/g5", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file2_id, "/g27/g5/g6", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -1811,9 +1848,9 @@ PASSED(); /* Create fourth file and group "/g28/g5/g6" in it */ file3_id = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file3_id, "/g28", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file3_id, "/g28/g7", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file3_id, "/g28/g7/g8", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file3_id, "/g28", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file3_id, "/g28/g7", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file3_id, "/g28/g7/g8", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -1865,7 +1902,7 @@ PASSED(); if (H5Funmount(file_id, "/g25/g1/g26/g3/g27/g5")<0) TEST_ERROR; /* Verify */ - if(check_name(group4_id, "", "") < 0) TEST_ERROR; + if(check_name(group4_id, "/g28/g7/g8", "") < 0) TEST_ERROR; if(check_name(group3_id, "/g25/g1/g26/g3/g27/g5/g6", "/g25/g1/g26/g3/g27/g5/g6") < 0) TEST_ERROR; if(check_name(group2_id, "", "/g25/g1/g26/g3/g4") < 0) TEST_ERROR; if(check_name(group_id, "", "/g25/g1/g2") < 0) TEST_ERROR; @@ -1877,7 +1914,7 @@ PASSED(); if (H5Funmount(file_id, "/g25/g1/g26/g3")<0) TEST_ERROR; /* Verify */ - if(check_name(group3_id, "", "") < 0) TEST_ERROR; + if(check_name(group3_id, "/g27/g5/g6", "") < 0) TEST_ERROR; if(check_name(group2_id, "/g25/g1/g26/g3/g4", "/g25/g1/g26/g3/g4") < 0) TEST_ERROR; if(check_name(group_id, "", "/g25/g1/g2") < 0) TEST_ERROR; @@ -1888,7 +1925,7 @@ PASSED(); if (H5Funmount(file_id, "/g25/g1")<0) TEST_ERROR; /* Verify */ - if(check_name(group2_id, "", "") < 0) TEST_ERROR; + if(check_name(group2_id, "/g26/g3/g4", "") < 0) TEST_ERROR; if(check_name(group_id, "/g25/g1/g2", "/g25/g1/g2") < 0) TEST_ERROR; /* Close */ @@ -1899,7 +1936,6 @@ PASSED(); PASSED(); - /*------------------------------------------------------------------------- * Test H5Iget_name and H5Gmove with repeated path components *------------------------------------------------------------------------- @@ -1908,11 +1944,11 @@ PASSED(); TESTING("H5Iget_name and H5Gmove with repeated path components"); /* Create a group "g29/g1/g2/g1/g2" in a file */ - if ((group_id = H5Gcreate( file_id, "/g29", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "/g29/g1", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file_id, "/g29/g1/g2", 0 ))<0) TEST_ERROR; - if ((group4_id = H5Gcreate( file_id, "/g29/g1/g2/g1", 0 ))<0) TEST_ERROR; - if ((group5_id = H5Gcreate( file_id, "/g29/g1/g2/g1/g2", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g29", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g29/g1", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "/g29/g1/g2", shint ))<0) TEST_ERROR; + if ((group4_id = H5Gcreate( file_id, "/g29/g1/g2/g1", shint ))<0) TEST_ERROR; + if ((group5_id = H5Gcreate( file_id, "/g29/g1/g2/g1/g2", shint ))<0) TEST_ERROR; /* Rename group */ if (H5Gmove( file_id, "/g29/g1/g2/g1/g2", "/g29/g1/g2/g1/g3" )<0) TEST_ERROR; @@ -1952,9 +1988,9 @@ PASSED(); TESTING("H5Iget_name with higher mounted file"); /* Create a group "/g30/g1/g2" in the first file */ - if ((group_id = H5Gcreate( file_id, "/g30", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "/g30/g1", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file_id, "/g30/g1/g2", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g30", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g30/g1", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "/g30/g1/g2", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -1964,9 +2000,9 @@ PASSED(); /* Create second file and group "/g31/g3/g4" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g31", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file1_id, "/g31/g3", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file1_id, "/g31/g3/g4", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file1_id, "/g31", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g31/g3", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file1_id, "/g31/g3/g4", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -1976,9 +2012,9 @@ PASSED(); /* Create third file and group "/g32/g5/g6" in it */ file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file2_id, "/g32", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file2_id, "/g32/g5", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file2_id, "/g32/g5/g6", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file2_id, "/g32", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file2_id, "/g32/g5", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file2_id, "/g32/g5/g6", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -1988,9 +2024,9 @@ PASSED(); /* Create fourth file and group "/g33/g5/g6" in it */ file3_id = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file3_id, "/g33", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file3_id, "/g33/g7", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file3_id, "/g33/g7/g8", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file3_id, "/g33", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file3_id, "/g33/g7", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file3_id, "/g33/g7/g8", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2043,7 +2079,7 @@ PASSED(); if (H5Funmount(file_id, "/g30")<0) TEST_ERROR; /* Verify */ - if(check_name(group4_id, "", "") < 0) TEST_ERROR; + if(check_name(group4_id, "/g33/g7/g8", "") < 0) TEST_ERROR; if(check_name(group3_id, "/g30/g1/g31/g3/g32/g5/g6", "/g30/g1/g31/g3/g32/g5/g6") < 0) TEST_ERROR; if(check_name(group2_id, "", "/g30/g1/g31/g3/g4") < 0) TEST_ERROR; if(check_name(group_id, "", "/g30/g1/g2") < 0) TEST_ERROR; @@ -2052,8 +2088,8 @@ PASSED(); if (H5Funmount(file_id, "/g30/g1/g31/g3")<0) TEST_ERROR; /* Verify */ - if(check_name(group4_id, "", "") < 0) TEST_ERROR; - if(check_name(group3_id, "", "") < 0) TEST_ERROR; + if(check_name(group4_id, "/g33/g7/g8", "") < 0) TEST_ERROR; + if(check_name(group3_id, "/g32/g5/g6", "") < 0) TEST_ERROR; if(check_name(group2_id, "/g30/g1/g31/g3/g4", "/g30/g1/g31/g3/g4") < 0) TEST_ERROR; if(check_name(group_id, "", "/g30/g1/g2") < 0) TEST_ERROR; @@ -2061,9 +2097,9 @@ PASSED(); if (H5Funmount(file_id, "/g30/g1")<0) TEST_ERROR; /* Verify */ - if(check_name(group4_id, "", "") < 0) TEST_ERROR; - if(check_name(group3_id, "", "") < 0) TEST_ERROR; - if(check_name(group2_id, "", "") < 0) TEST_ERROR; + if(check_name(group4_id, "/g33/g7/g8", "") < 0) TEST_ERROR; + if(check_name(group3_id, "/g32/g5/g6", "") < 0) TEST_ERROR; + if(check_name(group2_id, "/g31/g3/g4", "") < 0) TEST_ERROR; if(check_name(group_id, "/g30/g1/g2", "/g30/g1/g2") < 0) TEST_ERROR; /* Close groups */ @@ -2090,9 +2126,9 @@ PASSED(); /* Create second file and group "/g35/g3/g4" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g35", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file1_id, "/g35/g3", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file1_id, "/g35/g3/g4", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file1_id, "/g35", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g35/g3", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file1_id, "/g35/g3/g4", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2100,9 +2136,9 @@ PASSED(); H5Gclose( group3_id ); /* Create group "/g34/g1/g2" in first file */ - if ((group_id = H5Gcreate( file_id, "/g34", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "/g34/g1", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file_id, "/g34/g1/g2", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g34", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g34/g1", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "/g34/g1/g2", shint ))<0) TEST_ERROR; /* Create hard link to "/g34/g1/g2 group */ if (H5Glink(file_id, H5G_LINK_HARD, "/g34/g1/g2", "/g34/g2a")<0) TEST_ERROR; @@ -2140,7 +2176,6 @@ PASSED(); PASSED(); - /*------------------------------------------------------------------------- * Test H5Iget_name with mounted files and unlinking *------------------------------------------------------------------------- @@ -2149,9 +2184,9 @@ PASSED(); TESTING("H5Iget_name with mounted files and unlinking"); /* Create group "/g36/g1/g2" in first file */ - if ((group_id = H5Gcreate( file_id, "/g36", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file_id, "/g36/g1", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file_id, "/g36/g1/g2", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file_id, "/g36", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g36/g1", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "/g36/g1/g2", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2238,9 +2273,9 @@ PASSED(); /* Create file and group "/g38/g1/g2" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g38", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file1_id, "/g38/g1", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file1_id, "/g38/g1/g2", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file1_id, "/g38", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g38/g1", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file1_id, "/g38/g1/g2", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2250,9 +2285,9 @@ PASSED(); /* Create second file and group "/g39/g1/g2" in it */ file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file2_id, "/g39", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file2_id, "/g39/g3", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file2_id, "/g39/g3/g4", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file2_id, "/g39", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file2_id, "/g39/g3", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file2_id, "/g39/g3/g4", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2262,9 +2297,9 @@ PASSED(); /* Create third file and group "/g40/g5/g6" in it */ file3_id = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file3_id, "/g40", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file3_id, "/g40/g5", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file3_id, "/g40/g5/g6", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file3_id, "/g40", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file3_id, "/g40/g5", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file3_id, "/g40/g5/g6", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2299,7 +2334,7 @@ PASSED(); if (H5Funmount(file1_id, "/g38/g1")<0) TEST_ERROR; /* Verify */ - if(check_name(group_id, "", "") < 0) TEST_ERROR; + if(check_name(group_id, "/g39/g3/g4", "") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2320,9 +2355,9 @@ PASSED(); /* Create file and group "/g39/g1/g2" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g41", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file1_id, "/g41/g1", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file1_id, "/g41/g1/g2", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file1_id, "/g41", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g41/g1", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file1_id, "/g41/g1/g2", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2332,9 +2367,9 @@ PASSED(); /* Create second file and group "/g42/g1/g2" in it */ file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file2_id, "/g42", 0 ))<0) TEST_ERROR; - if ((group2_id = H5Gcreate( file2_id, "/g42/g3", 0 ))<0) TEST_ERROR; - if ((group3_id = H5Gcreate( file2_id, "/g42/g3/g4", 0 ))<0) TEST_ERROR; + if ((group_id = H5Gcreate( file2_id, "/g42", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file2_id, "/g42/g3", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file2_id, "/g42/g3/g4", shint ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2355,7 +2390,7 @@ PASSED(); if ((group2_id = H5Gopen( group_id, "g4" ))<0) TEST_ERROR; /* Verify */ - if(check_name(group2_id, "", "") < 0) TEST_ERROR; + if(check_name(group2_id, "/g42/g3/g4", "") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2366,20 +2401,536 @@ PASSED(); PASSED(); /*------------------------------------------------------------------------- - * end tests + * Test H5Iget_name with looped groups for both hard and soft links. *------------------------------------------------------------------------- */ +TESTING("H5Iget_name with looped groups for hard and soft links"); + + /* Create group "g43/g1/g2/g3" */ + if ((group_id = H5Gcreate( file_id, "/g43", shint ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g43/g1", shint ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "/g43/g1/g2", shint ))<0) TEST_ERROR; + if ((group4_id = H5Gcreate( file_id, "/g43/g1/g2/g3", shint ))<0) TEST_ERROR; + + /* Create hard link to make a loop */ + if (H5Glink2(group_id,".",H5G_LINK_HARD,group4_id,"g43")<0) TEST_ERROR; + + /* Open the group */ + if ((group5_id = H5Gopen( file_id, "/g43/g1/g2/g3/g43" ))<0) TEST_ERROR; + + /* Verify */ + if(check_name(group5_id, "/g43/g1/g2/g3/g43", "/g43/g1/g2/g3/g43") < 0) TEST_ERROR; + + /* Create a second hard link to make a loop */ + if (H5Glink2(group_id,".",H5G_LINK_HARD,group4_id,"g4")<0) TEST_ERROR; + + /* Open the group */ + if ((group6_id = H5Gopen( file_id, "/g43/g1/g2/g3/g4" ))<0) TEST_ERROR; + + /* Verify */ + if(check_name(group6_id, "/g43/g1/g2/g3/g4", "/g43/g1/g2/g3/g4") < 0) TEST_ERROR; + + /* Create a soft link to make a loop */ + if (H5Glink2(group_id,".",H5G_LINK_SOFT,group4_id,"gsoft")<0) TEST_ERROR; + + /* Open the group */ + if ((group7_id = H5Gopen( file_id, "/g43/g1/g2/g3/gsoft" ))<0) TEST_ERROR; + + /* Verify */ + if(check_name(group7_id, "/g43/g1/g2/g3/gsoft", "/g43/g1/g2/g3/gsoft") < 0) TEST_ERROR; + + /* Close */ + H5Gclose( group_id ); + H5Gclose( group2_id ); + H5Gclose( group3_id ); + H5Gclose( group4_id ); + H5Gclose( group5_id ); + H5Gclose( group6_id ); + H5Gclose( group7_id ); + +PASSED(); /* Close file */ H5Fclose( file_id ); - puts("All getname tests passed."); - h5_cleanup(FILENAME, fapl); - return 0; + + return(0); error: - H5Fclose( file_id ); - H5_FAILED(); - return 1; + return(1); +} + + +/*------------------------------------------------------------------------- + * Function: test_obj_ref + * + * Purpose: Test H5Iget_name for object references. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Leon Arber + * Nov. 1, 2006 + * + * Modifications: + * Raymond Lu + * 30 January 2008 + * This function was borrowed from v1.8, which was probably + * written by Leon Arber. + *------------------------------------------------------------------------- + */ +static int +test_obj_ref(hid_t fapl) +{ + char filename1[1024]; + char filename2[1024]; + hid_t fid1, fid2; /* HDF5 File IDs */ + hid_t dataset, dataset2; /* Dataset ID */ + hid_t group, group2; /* Group ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hobj_ref_t wbuf[SPACE1_DIM1]; /* Buffer to write to disk */ + int tu32[SPACE1_DIM1]; /* Int data */ + int i; /* counting variables */ + char buf[100]; + size_t size_hint = 0; + + /* Initialize the file names */ + h5_fixname(FILENAME[3], fapl, filename1, sizeof filename1); + h5_fixname(FILENAME[4], fapl, filename2, sizeof filename2); + + /* Create files */ + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + + /* Create dataspace for datasets */ + if((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0) + TEST_ERROR + + /* Create a group */ + if((group = H5Gcreate(fid1, "Group1", size_hint)) < 0) TEST_ERROR + + /* Create a single dataset inside the second file, which will be mounted + * and used to mask objects in the first file */ + if((dataset = H5Dcreate(fid2, "Dataset1", H5T_STD_U32LE, sid1, H5P_DEFAULT)) < 0) + TEST_ERROR + if(H5Dclose(dataset) < 0) + TEST_ERROR + + /* Create a dataset(inside Group1) */ + if((dataset = H5Dcreate(group, "Dataset1", H5T_STD_U32LE, sid1, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Initialize data buffer */ + for(i = 0; i < SPACE1_DIM1; i++) + tu32[i] = i * 3; + + /* Write selection to disk */ + if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, tu32) < 0) + TEST_ERROR + + /* Close Dataset */ + if(H5Dclose(dataset) < 0) + TEST_ERROR + + /* Create another dataset(inside Group1) */ + if((dataset = H5Dcreate(group, "Dataset2", H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Close Dataset */ + if(H5Dclose(dataset) < 0) + TEST_ERROR + + /* Create a datatype to refer to */ + if((tid1 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t))) < 0) + TEST_ERROR + + /* Insert fields */ + if(H5Tinsert(tid1, "a", HOFFSET(s1_t, a), H5T_NATIVE_UINT) < 0) + TEST_ERROR + if(H5Tinsert(tid1, "b", HOFFSET(s1_t, b), H5T_NATIVE_UINT) < 0) + TEST_ERROR + if(H5Tinsert(tid1, "c", HOFFSET(s1_t, c), H5T_NATIVE_FLOAT) < 0) + TEST_ERROR + + /* Save datatype for later */ + if(H5Tcommit(group, "Datatype1", tid1) < 0) + TEST_ERROR + + /* Close datatype */ + if(H5Tclose(tid1) < 0) + TEST_ERROR + + /* Create a new group in group1 */ + if((group2 = H5Gcreate(group, "Group2", size_hint)) < 0) TEST_ERROR + + /* Create a hard link to group1 in group2 */ + if (H5Glink2(fid1,"/Group1",H5G_LINK_HARD,fid1,"/Group1/Group2/Link")<0) TEST_ERROR; + + /* Create dataset in that group */ + if((dataset = H5Dcreate(group2, "Dataset4", H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Close Dataset */ + if(H5Dclose(dataset) < 0) + TEST_ERROR + + /* Close group */ + if(H5Gclose(group) < 0) + TEST_ERROR + if(H5Gclose(group2) < 0) + TEST_ERROR + + /* Open up that hard link and make a new dataset there */ + if((group = H5Gopen(fid1, "/Group1/Group2/Link")) < 0) + TEST_ERROR + + if((dataset = H5Dcreate(group, "Dataset5", H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT)) < 0) + TEST_ERROR + + if(H5Dclose(dataset) < 0) + TEST_ERROR + if(H5Gclose(group) < 0) + TEST_ERROR + + /* Create a dataset to store references */ + if((dataset = H5Dcreate(fid1, "Dataset3", H5T_STD_REF_OBJ, sid1, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Create reference to dataset */ + if(H5Rcreate(&wbuf[0], fid1, "/Dataset3", H5R_OBJECT, -1) < 0) + TEST_ERROR + + /* Create reference to dataset */ + if(H5Rcreate(&wbuf[1], fid1, "/Group1/Dataset2", H5R_OBJECT, -1) < 0) + TEST_ERROR + + /* Create reference to group */ + if(H5Rcreate(&wbuf[2], fid1, "/Group1", H5R_OBJECT, -1) < 0) + TEST_ERROR + + /* Create reference to named datatype */ + if(H5Rcreate(&wbuf[3], fid1, "/Group1/Datatype1", H5R_OBJECT, -1) < 0) + TEST_ERROR + + if(H5Rcreate(&wbuf[4], fid1, "/Group1/Group2/Dataset4", H5R_OBJECT, -1) < 0) + TEST_ERROR + if(H5Rcreate(&wbuf[5], fid1, "/Group1/Group2", H5R_OBJECT, -1) < 0) + TEST_ERROR + 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 + + TESTING("getting path to normal dataset in root group"); + if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[0])) < 0) TEST_ERROR + i = H5Iget_name(dataset2,(char*)buf, sizeof(buf)); + if(H5Dclose(dataset2) < 0) TEST_ERROR + if(!((HDstrcmp(buf, "/Dataset3") == 0) &&(i == 9))) TEST_ERROR + PASSED() + + HDmemset(buf, 0, sizeof(buf)); + TESTING("getting path to dataset in /Group1"); + if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[1])) < 0) TEST_ERROR + i = H5Iget_name(dataset2,(char*)buf, sizeof(buf)); + if(H5Dclose(dataset2) < 0) TEST_ERROR + if(!((HDstrcmp(buf, "/Group1/Dataset2") == 0) &&(i == 16))) TEST_ERROR + PASSED() + + HDmemset(buf, 0, sizeof(buf)); + TESTING("getting path to /Group1"); + if((group = H5Rdereference(dataset, H5R_OBJECT, &wbuf[2])) < 0) TEST_ERROR + i = H5Iget_name(group,(char*)buf, sizeof(buf)); + if(H5Gclose(group) < 0) TEST_ERROR + if(!((HDstrcmp(buf, "/Group1") == 0) &&(i == 7))) TEST_ERROR + PASSED() + + HDmemset(buf, 0, sizeof(buf)); + TESTING("getting path to datatype in /Group1"); + if((tid1 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[3])) < 0) TEST_ERROR + i = H5Iget_name(tid1,(char*)buf, sizeof(buf)); + if(H5Tclose(tid1) < 0) TEST_ERROR + if(!((HDstrcmp(buf, "/Group1/Datatype1") == 0) &&(i == 17))) TEST_ERROR + PASSED() + + HDmemset(buf, 0, sizeof(buf)); + TESTING("getting path to dataset in nested group"); + if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[4])) < 0) TEST_ERROR + i = H5Iget_name(dataset2,(char*)buf, sizeof(buf)); + if(H5Dclose(dataset2) < 0) TEST_ERROR + if(!((HDstrcmp(buf, "/Group1/Group2/Dataset4") == 0) &&(i == 23))) TEST_ERROR + PASSED() + + HDmemset(buf, 0, sizeof(buf)); + TESTING("getting path to nested group"); + if((group = H5Rdereference(dataset, H5R_OBJECT, &wbuf[5])) < 0) TEST_ERROR + i = H5Iget_name(group,(char*)buf, sizeof(buf)); + if(H5Gclose(group) < 0) TEST_ERROR + if(!((HDstrcmp(buf, "/Group1/Group2") == 0) &&(i == 14))) TEST_ERROR + PASSED() + + HDmemset(buf, 0, sizeof(buf)); + TESTING("getting path to dataset created via hard link"); + if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[6])) < 0) TEST_ERROR + i = H5Iget_name(dataset2,(char*)buf, sizeof(buf)); + if(H5Dclose(dataset2) < 0) TEST_ERROR + if(!((HDstrcmp(buf, "/Group1/Dataset5") == 0) &&(i == 16))) TEST_ERROR + PASSED() + + HDmemset(buf, 0, sizeof(buf)); + TESTING("getting path to root group"); + if((group = H5Rdereference(dataset, H5R_OBJECT, &wbuf[7])) < 0) TEST_ERROR + i = H5Iget_name(group,(char*)buf, sizeof(buf)); + if(H5Gclose(group) < 0) TEST_ERROR + if(!((HDstrcmp(buf, "/") == 0) &&(i == 1))) TEST_ERROR + PASSED() + + /* 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 + + TESTING("getting path to dataset hidden by a mounted file"); + if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[4])) < 0) TEST_ERROR + i = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); + if(H5Dclose(dataset2) < 0) TEST_ERROR + if(i != 0) TEST_ERROR + PASSED() + + /* Now we try unlinking dataset2 from the file and searching for it. It shouldn't be found */ + if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[1])) < 0) + TEST_ERROR + if(H5Gunlink(fid1, "/Group1/Dataset2") < 0) + TEST_ERROR + + TESTING("getting path to dataset that has been unlinked"); + i = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); + if(H5Dclose(dataset2) < 0) TEST_ERROR + if(i != 0) TEST_ERROR + PASSED() + + /* Close disk dataspace */ + if(H5Sclose(sid1) < 0) + TEST_ERROR + + /* Close Dataset */ + if(H5Dclose(dataset) < 0) + TEST_ERROR + + /* Close file */ + if(H5Fclose(fid1) < 0) + TEST_ERROR + if(H5Fclose(fid2) < 0) + TEST_ERROR + + return 0; + +error: + return 1; +} + + +/*------------------------------------------------------------------------- + * Function: test_reg_ref + * + * Purpose: Test H5Iget_name for region references. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Leon Arber + * Nov. 1, 2006 + * + * Modifications: + * Raymond Lu + * 30 January 2008 + * This function was borrowed from v1.8, which was probably + * written by Leon Arber. + *------------------------------------------------------------------------- + */ +static int +test_reg_ref(hid_t fapl) +{ + char filename1[1024]; + hid_t file_id; /* file identifier */ + hid_t dsetv_id; /*dataset identifiers*/ + hid_t dsetr_id; + hid_t space_id, spacer_id; + hsize_t dims[2] = {2,9}; + hsize_t dimsr[1] = {2}; + int rank = 2; + int rankr = 1; + herr_t status; + hdset_reg_ref_t ref[2]; + hdset_reg_ref_t ref_out[2]; + int data[2][9] = {{1,1,2,3,3,4,5,5,6},{1,2,2,3,4,4,5,6,6}}; + hsize_t start[2]; + hsize_t count[2]; + hsize_t coord[2][3] = {{0, 0, 1}, {6, 0, 8}}; + unsigned num_points = 3; + size_t name_size1, name_size2; + char buf1[NAME_BUF_SIZE], buf2[NAME_BUF_SIZE]; + + /* Initialize the file name */ + h5_fixname(FILENAME[5], fapl, filename1, sizeof filename1); + + /* Create file with default file create property but vfd access property. */ + if((file_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + + /* Create dataspace for datasets */ + if((space_id = H5Screate_simple(rank, dims, NULL)) < 0) + TEST_ERROR + if((spacer_id = H5Screate_simple(rankr, dimsr, NULL)) < 0) + TEST_ERROR + + /* Create integer dataset */ + if((dsetv_id = H5Dcreate(file_id, REFREG_DSETNAMEV, H5T_NATIVE_INT, space_id, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Write data to the dataset */ + if((status = H5Dwrite(dsetv_id, H5T_NATIVE_INT, H5S_ALL , H5S_ALL, H5P_DEFAULT,data)) < 0) + TEST_ERROR + if((status = H5Dclose(dsetv_id)) < 0) + TEST_ERROR + + /* Dataset with references */ + if((dsetr_id = H5Dcreate(file_id, REFREG_DSETNAMER, H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* + * Create a reference to the hyperslab. + */ + start[0] = 0; + start[1] = 3; + count[0] = 2; + count[1] = 3; + if((status = H5Sselect_hyperslab(space_id,H5S_SELECT_SET,start,NULL,count,NULL)) < 0) + TEST_ERROR + if((status = H5Rcreate(&ref[0], file_id, REFREG_DSETNAMEV, H5R_DATASET_REGION, space_id)) < 0) + TEST_ERROR + + /* Create a reference to elements selection */ + if((status = H5Sselect_none(space_id)) < 0) + TEST_ERROR + if((status = H5Sselect_elements(space_id, H5S_SELECT_SET, num_points,(const hsize_t **)coord)) < 0) + TEST_ERROR + if((status = H5Rcreate(&ref[1], file_id, REFREG_DSETNAMEV, H5R_DATASET_REGION, space_id)) < 0) + TEST_ERROR + + /* Write dataset with the references */ + if((status = H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT,ref)) < 0) + TEST_ERROR + + /* Close all objects */ + if((status = H5Sclose(space_id)) < 0) + TEST_ERROR + if((status = H5Sclose(spacer_id)) < 0) + TEST_ERROR + if((status = H5Dclose(dsetr_id)) < 0) + TEST_ERROR + if((status = H5Fclose(file_id)) < 0) + TEST_ERROR + + /* Reopen the file to read selections back */ + if((file_id = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR + + /* Reopen the dataset with object references and read references to the buffer */ + if((dsetr_id = H5Dopen(file_id, REFREG_DSETNAMER)) < 0) + TEST_ERROR + + if((status = H5Dread(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_out)) < 0) + TEST_ERROR + + TESTING("H5Iget_name to get name from region reference(hyperslab)"); + + /* Dereference the first reference */ + dsetv_id = H5Rdereference(dsetr_id, H5R_DATASET_REGION, &ref_out[0]); + + /* Get name of the dataset the first region reference points using H5Iget_name */ + name_size2 = H5Iget_name(dsetv_id,(char*)buf2, NAME_BUF_SIZE); + if(!((HDstrcmp(buf2, "/MATRIX") == 0) &&(name_size2 == 7))) TEST_ERROR + + if((status = H5Dclose(dsetv_id)) < 0) TEST_ERROR + + PASSED() + + TESTING("H5Iget_name to get name from region reference(pnt selec)"); + + /* Dereference the second reference */ + if((dsetv_id = H5Rdereference(dsetr_id, H5R_DATASET_REGION, &ref_out[1])) < 0) TEST_ERROR + + /* Get name of the dataset the first region reference points using H5Iget_name */ + name_size2 = H5Iget_name(dsetv_id,(char*)buf2, NAME_BUF_SIZE); + if(!((HDstrcmp(buf2, "/MATRIX") == 0) &&(name_size2 == 7))) TEST_ERROR + + if((status = H5Dclose(dsetv_id)) < 0) TEST_ERROR + + PASSED() + + if((status = H5Dclose(dsetr_id)) < 0) + TEST_ERROR + if((status = H5Fclose(file_id)) < 0) + TEST_ERROR + + return 0; + +error: + return 1; } +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Tests the "ID to name" functionality. + * + * Return: Success: 1 + * Failure: 0 + * + * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu> + * April 12, 2002 + * + * Modifications: + * Raymond Lu + * 30 January 2008 + * Added some tests for object reference and region reference. + * The code was borrowed from v1.8, which was probably written + * by Leon Arber. + *------------------------------------------------------------------------- + */ +main(void) +{ + int nerrors = 0; + hid_t fapl; + + /* Reset the library and get the file access property list */ + h5_reset(); + fapl = h5_fileaccess(); + + /* Call "main" test routine */ + nerrors += test_main(fapl); + nerrors += test_obj_ref(fapl); + nerrors += test_reg_ref(fapl); + + if(nerrors) + goto error; + puts("All getname tests passed."); + + h5_cleanup(FILENAME, fapl); + + return 0; + +error: + puts("***** GET NAME TESTS FAILED *****"); + + return 1; +} diff --git a/test/mount.c b/test/mount.c index 01658c6..4a62a05 100644 --- a/test/mount.c +++ b/test/mount.c @@ -1440,7 +1440,7 @@ test_mount_after_unmount(hid_t fapl) *objname = '\0'; if(H5Iget_name( gidAMXMY, objname, (size_t)NAME_BUF_SIZE ) < 0) TEST_ERROR - if(HDstrcmp(objname, "")) + if(HDstrcmp(objname, "/X/M/Y")) TEST_ERROR /* Rename object in file #3 that is "disconnected" from name hiearchy */ @@ -1460,7 +1460,7 @@ test_mount_after_unmount(hid_t fapl) *objname = '\0'; if(H5Iget_name( gidAMXMY, objname, (size_t)NAME_BUF_SIZE ) < 0) TEST_ERROR - if(HDstrcmp(objname, "")) + if(HDstrcmp(objname, "/X/M/Z")) TEST_ERROR /* Mount fourth file */ @@ -3171,7 +3171,7 @@ test_close_parent(hid_t fapl) /* Check the name of "M" is not defined any longer */ if((name_len = H5Iget_name(gidM, name, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR - if(name_len != 0) + if(name_len == 0 || HDstrcmp(name, "/M")) TEST_ERROR /* Just file #2's underlying shared file should be open still */ |