diff options
Diffstat (limited to 'test/links.c')
-rw-r--r-- | test/links.c | 522 |
1 files changed, 521 insertions, 1 deletions
diff --git a/test/links.c b/test/links.c index c71e1b9..1eba67e 100644 --- a/test/links.c +++ b/test/links.c @@ -8329,7 +8329,6 @@ error: return -1; } /* end open_by_idx_old() */ -#endif /* QAK */ /*------------------------------------------------------------------------- @@ -8808,6 +8807,525 @@ error: return -1; } /* end object_info_old() */ +#endif /* QAK */ + + +/*------------------------------------------------------------------------- + * Function: group_info + * + * Purpose: Create a group with creation order indices and test querying + * group info. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Quincey Koziol + * Monday, November 27, 2006 + * + *------------------------------------------------------------------------- + */ +static int +group_info(hid_t fapl) +{ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1); /* Group ID */ + hid_t soft_group_id = (-1); /* Group ID for soft links */ + hid_t gcpl_id = (-1); /* Group creation property list ID */ + H5L_index_t idx_type; /* Type of index to operate on */ + H5_iter_order_t order; /* Order within in the index */ + hbool_t use_index; /* Use index on creation order values */ + unsigned max_compact; /* Maximum # of links to store in group compactly */ + unsigned min_dense; /* Minimum # of links to store in group "densely" */ + H5G_info_t grp_info; /* Buffer for querying object's info */ + char filename[NAME_BUF_SIZE];/* File name */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char objname2[NAME_BUF_SIZE]; /* Object name */ + char valname[NAME_BUF_SIZE]; /* Link value */ + herr_t ret; /* Generic return value */ + unsigned u, v; /* Local index variables */ + + /* Create group creation property list */ + if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR + + /* Query the group creation properties */ + if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR + + /* Loop over operating on different indices on link fields */ + for(idx_type = H5L_INDEX_NAME; idx_type <=H5L_INDEX_CRT_ORDER; idx_type++) { + /* Loop over operating in different orders */ + for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) { + /* Loop over using index for creation order value */ + for(use_index = FALSE; use_index <= TRUE; use_index++) { + /* Print appropriate test message */ + if(idx_type == H5L_INDEX_CRT_ORDER) { + if(order == H5_ITER_INC) { + if(use_index) + TESTING("query group info by creation order index in increasing order w/creation order index") + else + TESTING("query group info by creation order index in increasing order w/o creation order index") + } /* end if */ + else if(order == H5_ITER_DEC) { + if(use_index) + TESTING("query group info by creation order index in decreasing order w/creation order index") + else + TESTING("query group info by creation order index in decreasing order w/o creation order index") + } /* end else */ + else { + HDassert(order == H5_ITER_NATIVE); + if(use_index) + TESTING("query group info by creation order index in native order w/creation order index") + else + TESTING("query group info by creation order index in native order w/o creation order index") + } /* end else */ + } /* end if */ + else { + if(order == H5_ITER_INC) { + if(use_index) + TESTING("query group info by name index in increasing order w/creation order index") + else + TESTING("query group info by name index in increasing order w/o creation order index") + } /* end if */ + else if(order == H5_ITER_DEC) { + if(use_index) + TESTING("query group info by name index in decreasing order w/creation order index") + else + TESTING("query group info by name index in decreasing order w/o creation order index") + } /* end else */ + else { + HDassert(order == H5_ITER_NATIVE); + if(use_index) + TESTING("query group info by name index in native order w/creation order index") + else + TESTING("query group info by name index in native order w/o creation order index") + } /* end else */ + } /* end else */ + + /* Create file */ + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Set creation order tracking & indexing on group */ + if(H5Pset_creation_order_index(gcpl_id, use_index) < 0) TEST_ERROR + if(H5Pset_creation_order_tracking(gcpl_id, TRUE) < 0) TEST_ERROR + + /* Create group with creation order tracking on */ + if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Create group with creation order tracking on for soft links */ + if((soft_group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Llink(file_id, CORDER_SOFT_GROUP_NAME, soft_group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + + /* Check for out of bound query by index on empty group */ + H5E_BEGIN_TRY { + ret = H5Gget_info_by_idx(group_id, ".", H5L_INDEX_NAME, order, (hsize_t)0, &grp_info, H5P_DEFAULT); + } H5E_END_TRY; + if(ret >= 0) TEST_ERROR + + /* Create several links, up to limit of compact form */ + for(u = 0; u < max_compact; u++) { + hid_t group_id2, group_id3; /* Group IDs */ + + /* Make name for link */ + sprintf(objname, "filler %02u", u); + + /* Create hard link, with group object */ + if((group_id2 = H5Gcreate_expand(group_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Llink(group_id, objname, group_id2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Retrieve group's information */ + if(H5Gget_info(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check (new/empty) group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != 0) TEST_ERROR + if(grp_info.nlinks != 0) TEST_ERROR + + /* Create objects in new group created */ + for(v = 0; v <= u; v++) { + /* Make name for link */ + sprintf(objname2, "filler %02u", v); + + /* Create hard link, with group object */ + if((group_id3 = H5Gcreate(group_id2, objname2, (size_t)0)) < 0) TEST_ERROR + + /* Close group created */ + if(H5Gclose(group_id3) < 0) TEST_ERROR + } /* end for */ + + /* Retrieve group's information */ + if(H5Gget_info(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check (new) group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + + /* Retrieve group's information */ + if(order != H5_ITER_NATIVE) { + if(order == H5_ITER_INC) { + if(H5Gget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)u, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + } /* end if */ + else { + if(H5Gget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)0, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + } /* end else */ + + /* Check (new) group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + } /* end if */ + + /* Close group created */ + if(H5Gclose(group_id2) < 0) TEST_ERROR + + + /* Retrieve main group's information, by name */ + if(H5Gget_info(group_id, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check main group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + + + /* Create soft link in another group, to objects in main group */ + sprintf(valname, "/%s/%s", CORDER_GROUP_NAME, objname); + if(H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Retrieve soft link group's information, by name */ + if(H5Gget_info(soft_group_id, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check soft link group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + } /* end for */ + + /* Verify state of group (compact) */ + if(H5G_has_links_test(group_id, NULL) != TRUE) TEST_ERROR + + /* Check for out of bound query by index */ + H5E_BEGIN_TRY { + ret = H5Gget_info_by_idx(group_id, ".", H5L_INDEX_NAME, order, (hsize_t)u, &grp_info, H5P_DEFAULT); + } H5E_END_TRY; + if(ret >= 0) TEST_ERROR + + + /* Create more links, to push group into dense form */ + for(; u < (max_compact * 2); u++) { + hid_t group_id2, group_id3; /* Group IDs */ + + /* Make name for link */ + sprintf(objname, "filler %02u", u); + + /* Create hard link, with group object */ + if((group_id2 = H5Gcreate_expand(group_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Llink(group_id, objname, group_id2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Retrieve group's information */ + if(H5Gget_info(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check (new/empty) group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_COMPACT) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != 0) TEST_ERROR + if(grp_info.nlinks != 0) TEST_ERROR + + /* Create objects in new group created */ + for(v = 0; v <= u; v++) { + /* Make name for link */ + sprintf(objname2, "filler %02u", v); + + /* Create hard link, with group object */ + if((group_id3 = H5Gcreate(group_id2, objname2, (size_t)0)) < 0) TEST_ERROR + + /* Close group created */ + if(H5Gclose(group_id3) < 0) TEST_ERROR + } /* end for */ + + /* Retrieve group's information */ + if(H5Gget_info(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check (new) group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + + /* Retrieve group's information */ + if(order != H5_ITER_NATIVE) { + if(order == H5_ITER_INC) { + if(H5Gget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)u, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + } /* end if */ + else { + if(H5Gget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)0, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + } /* end else */ + + /* Check (new) group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + } /* end if */ + + /* Close group created */ + if(H5Gclose(group_id2) < 0) TEST_ERROR + + + /* Retrieve main group's information, by name */ + if(H5Gget_info(group_id, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check main group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + + + /* Create soft link in another group, to objects in main group */ + sprintf(valname, "/%s/%s", CORDER_GROUP_NAME, objname); + if(H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Retrieve soft link group's information, by name */ + if(H5Gget_info(soft_group_id, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check soft link group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_DENSE) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != (int64_t)(u + 1)) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + } /* end for */ + + /* Verify state of group (dense) */ + if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR + + /* Check for out of bound query by index */ + H5E_BEGIN_TRY { + ret = H5Gget_info_by_idx(group_id, ".", H5L_INDEX_NAME, order, (hsize_t)u, &grp_info, H5P_DEFAULT); + } H5E_END_TRY; + if(ret >= 0) TEST_ERROR + + + /* Close the groups */ + if(H5Gclose(group_id) < 0) TEST_ERROR + if(H5Gclose(soft_group_id) < 0) TEST_ERROR + + /* Close the file */ + if(H5Fclose(file_id) < 0) TEST_ERROR + + PASSED(); + } /* end for */ + } /* end for */ + } /* end for */ + + /* Free resources */ + if(H5Pclose(gcpl_id) < 0) TEST_ERROR + + return 0; + +error: + /* Free resources */ + H5E_BEGIN_TRY { + H5Pclose(gcpl_id); + H5Gclose(group_id); + H5Gclose(soft_group_id); + H5Fclose(file_id); + } H5E_END_TRY; + + return -1; +} /* end group_info() */ + + +/*------------------------------------------------------------------------- + * Function: group_info_old + * + * Purpose: Create an old-style group and test querying + * group info. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Quincey Koziol + * Monday, November 27, 2006 + * + *------------------------------------------------------------------------- + */ +static int +group_info_old(hid_t fapl) +{ + hid_t file_id = (-1); /* File ID */ + hid_t group_id = (-1); /* Group ID */ + hid_t soft_group_id = (-1); /* Group ID for soft links */ + H5_iter_order_t order; /* Order within in the index */ + H5G_info_t grp_info; /* Buffer for querying object's info */ + char filename[NAME_BUF_SIZE];/* File name */ + char objname[NAME_BUF_SIZE]; /* Object name */ + char objname2[NAME_BUF_SIZE]; /* Object name */ + char valname[NAME_BUF_SIZE]; /* Link value */ + herr_t ret; /* Generic return value */ + unsigned u, v; /* Local index variables */ + + /* Loop over operating in different orders */ + for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) { + if(order == H5_ITER_INC) { + TESTING("query group info by name index in increasing order in old-style group") + } /* end if */ + else if(order == H5_ITER_DEC) { + TESTING("query group info by name index in decreasing order in old-style group") + } /* end else */ + else { + HDassert(order == H5_ITER_NATIVE); + TESTING("query group info by name index in native order in old-style group") + } /* end else */ + + /* Create file */ + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create old-style group */ + if((group_id = H5Gcreate_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Create old-style group for soft links */ + if((soft_group_id = H5Gcreate_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Llink(file_id, CORDER_SOFT_GROUP_NAME, soft_group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + + /* Check for out of bound query by index on empty group */ + H5E_BEGIN_TRY { + ret = H5Gget_info_by_idx(group_id, ".", H5L_INDEX_NAME, order, (hsize_t)0, &grp_info, H5P_DEFAULT); + } H5E_END_TRY; + if(ret >= 0) TEST_ERROR + + /* Create several links */ + for(u = 0; u < CORDER_NLINKS; u++) { + hid_t group_id2, group_id3; /* Group IDs */ + + /* Make name for link */ + sprintf(objname, "filler %02u", u); + + /* Create hard link, with group object */ + if((group_id2 = H5Gcreate(group_id, objname, (size_t)0)) < 0) TEST_ERROR + + /* Retrieve group's information */ + if(H5Gget_info(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check (new/empty) group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != 0) TEST_ERROR + if(grp_info.nlinks != 0) TEST_ERROR + + /* Create objects in new group created */ + for(v = 0; v <= u; v++) { + /* Make name for link */ + sprintf(objname2, "filler %02u", v); + + /* Create hard link, with group object */ + if((group_id3 = H5Gcreate(group_id2, objname2, (size_t)0)) < 0) TEST_ERROR + + /* Close group created */ + if(H5Gclose(group_id3) < 0) TEST_ERROR + } /* end for */ + + /* Retrieve group's information */ + if(H5Gget_info(group_id2, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check (new) group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != 0) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + + /* Retrieve group's information */ + if(order != H5_ITER_NATIVE) { + if(order == H5_ITER_INC) { + if(H5Gget_info_by_idx(group_id, ".", H5L_INDEX_NAME, order, (hsize_t)u, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + } /* end if */ + else { + if(H5Gget_info_by_idx(group_id, ".", H5L_INDEX_NAME, order, (hsize_t)0, &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + } /* end else */ + + /* Check (new) group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != 0) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + } /* end if */ + + /* Close group created */ + if(H5Gclose(group_id2) < 0) TEST_ERROR + + + /* Retrieve main group's information, by name */ + if(H5Gget_info(group_id, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check main group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != 0) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + + + /* Create soft link in another group, to objects in main group */ + sprintf(valname, "/%s/%s", CORDER_GROUP_NAME, objname); + if(H5Lcreate_soft(valname, soft_group_id, objname, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Retrieve soft link group's information, by name */ + if(H5Gget_info(soft_group_id, ".", &grp_info, H5P_DEFAULT) < 0) TEST_ERROR + + /* Check soft link group's information */ + if(grp_info.storage_type != H5G_STORAGE_TYPE_SYMBOL_TABLE) TEST_ERROR + if(grp_info.min_corder != 0) TEST_ERROR + if(grp_info.max_corder != 0) TEST_ERROR + if(grp_info.nlinks != (hsize_t)(u + 1)) TEST_ERROR + } /* end for */ + + /* Verify state of group (old-style) */ + if(H5G_has_stab_test(group_id) != TRUE) TEST_ERROR + + /* Check for out of bound query by index */ + H5E_BEGIN_TRY { + ret = H5Gget_info_by_idx(group_id, ".", H5L_INDEX_NAME, order, (hsize_t)u, &grp_info, H5P_DEFAULT); + } H5E_END_TRY; + if(ret >= 0) TEST_ERROR + + /* Check for bad index query by index group */ + H5E_BEGIN_TRY { + ret = H5Gget_info_by_idx(group_id, ".", H5L_INDEX_CRT_ORDER, order, (hsize_t)0, &grp_info, H5P_DEFAULT); + } H5E_END_TRY; + if(ret >= 0) TEST_ERROR + + + /* Close the groups */ + if(H5Gclose(group_id) < 0) TEST_ERROR + if(H5Gclose(soft_group_id) < 0) TEST_ERROR + + /* Close the file */ + if(H5Fclose(file_id) < 0) TEST_ERROR + + PASSED(); + } /* end for */ + + return 0; + +error: + /* Free resources */ + H5E_BEGIN_TRY { + H5Gclose(group_id); + H5Gclose(soft_group_id); + H5Fclose(file_id); + } H5E_END_TRY; + + return -1; +} /* end group_info_old() */ /*------------------------------------------------------------------------- @@ -8918,6 +9436,7 @@ main(void) nerrors += link_iterate(fapl2) < 0 ? 1 : 0; nerrors += open_by_idx(fapl2) < 0 ? 1 : 0; nerrors += object_info(fapl2) < 0 ? 1 : 0; + nerrors += group_info(fapl2) < 0 ? 1 : 0; } /* end if */ else { /* Test new API calls on old-style groups */ @@ -8926,6 +9445,7 @@ main(void) nerrors += link_iterate_old(fapl) < 0 ? 1 : 0; nerrors += open_by_idx_old(fapl) < 0 ? 1 : 0; nerrors += object_info_old(fapl) < 0 ? 1 : 0; + nerrors += group_info_old(fapl) < 0 ? 1 : 0; } } /* end for */ #else /* QAK */ |