From 26d2abe9e87a051cd897f77a4a472a432675db8c Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 9 Jan 2007 15:07:04 -0500 Subject: [svn-r13128] Description: More progress on address bugs in combinations of shared/committed/unshared components of shared/unshared attributes in compact/dense storage. (Yes, there are a lot of combinations. :-) Tested on: Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2) --- src/H5A.c | 10 ++ src/H5Adense.c | 2 +- src/H5L.c | 3 +- src/H5O.c | 2 +- src/H5Oattr.c | 6 +- src/H5Oattribute.c | 10 -- src/H5Omessage.c | 2 +- src/H5SM.c | 2 +- test/tattr.c | 470 +++++++++++++++++++++++++++++++++++++---------------- 9 files changed, 347 insertions(+), 160 deletions(-) diff --git a/src/H5A.c b/src/H5A.c index 0b846d8..e4300d5 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -383,6 +383,16 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, attr->dt_size = H5O_msg_raw_size(attr->oloc.file, H5O_DTYPE_ID, attr->dt); } /* end if */ else if(tri_ret > 0) { + /* Check whether datatype is committed & increment ref count */ + /* (to maintain ref. count incr/decr similarity with "shared message" + * type of datatype sharing) + */ + if(H5T_committed(attr->dt)) { + /* Increment the reference count on the shared datatype */ + if(H5T_link(attr->dt, 1, dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared datatype link count") + } /* end if */ + /* Message is shared. Use size of shared message */ if(NULL == H5O_msg_get_share(H5O_DTYPE_ID, attr->dt, &sh_mesg)) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "couldn't get size of shared message") diff --git a/src/H5Adense.c b/src/H5Adense.c index e4cf59e..972d80e 100644 --- a/src/H5Adense.c +++ b/src/H5Adense.c @@ -1302,7 +1302,7 @@ H5A_dense_delete_bt2_cb(const void *_record, void *_bt2_udata) } /* end if */ else { /* Perform the deletion action on the attribute */ - /* (takes care of shared & committed datatype/dataspace components) */ + /* (takes care of shared/committed datatype & dataspace components) */ if(H5O_attr_delete(bt2_udata->f, bt2_udata->dxpl_id, fh_udata.attr, TRUE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") } /* end else */ diff --git a/src/H5L.c b/src/H5L.c index 045bba8..9a0a6ba 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -2096,9 +2096,8 @@ H5L_delete(H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) /* Set up user data for unlink operation */ udata.dxpl_id = dxpl_id; - if(H5G_traverse(loc, norm_name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK|H5G_TARGET_MOUNT, H5L_delete_cb, &udata, lapl_id, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name doesn't exist") + HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "can't unlink object") done: /* Free the normalized path name */ diff --git a/src/H5O.c b/src/H5O.c index 103352e..9470a7f 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -1400,7 +1400,7 @@ H5O_delete_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh) /* Check for dense attribute storage & delete it if necessary */ if(oh->version > H5O_VERSION_1 && H5F_addr_defined(oh->attr_fheap_addr)) { if(H5A_dense_delete(f, dxpl_id, oh) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message") + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete dense attribute storage") } /* end if */ /* Free main (first) object header "chunk" */ diff --git a/src/H5Oattr.c b/src/H5Oattr.c index d8f4a1b..aae4858 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -54,7 +54,7 @@ const H5O_msg_class_t H5O_MSG_ATTR[1] = {{ H5O_attr_reset, /* reset method */ H5O_attr_free, /* free method */ H5O_attr_delete, /* file delete method */ - H5O_attr_link, /* link method */ + NULL /* H5O_attr_link */, /* link method */ H5O_attr_get_share, /* get share method */ H5O_attr_set_share, /* set share method */ H5O_attr_is_shared, /*is shared method */ @@ -668,7 +668,7 @@ H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link) if(NULL == H5O_msg_get_share(H5O_DTYPE_ID, attr->dt, &sh_mesg)) HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "can't get shared message from datatype") if(H5SM_try_delete(f, dxpl_id, H5O_DTYPE_ID, &sh_mesg) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "can't remove datatype from SOHM heap") + HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "can't remove datatype from heap") } /* end if */ if((tri_ret = H5O_msg_is_shared(H5O_SDSPACE_ID, attr->ds)) < 0) @@ -678,7 +678,7 @@ H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link) if(NULL == H5O_msg_get_share(H5O_SDSPACE_ID, attr->ds, &sh_mesg)) HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "can't get shared message from dataspace") if(H5SM_try_delete(f, dxpl_id, H5O_SDSPACE_ID, &sh_mesg) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_SOHM, FAIL, "can't remove dataspace from SOHM heap") + HGOTO_ERROR(H5E_ATTR, H5E_SOHM, FAIL, "can't remove dataspace from shared storage") } /* end if */ /* Check whether datatype is shared */ diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index ea77e26..57cc4ae 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -241,16 +241,6 @@ HDfprintf(stderr, "%s: adding attribute, attr->name = '%s'\n", FUNC, attr->name) /* Mark the message as shared */ mesg_flags |= H5O_MSG_FLAG_SHARED; - /* Check whether datatype is committed */ - /* (to maintain ref. count incr/decr similarity with "shared message" - * type of datatype sharing) - */ - if(H5T_committed(attr->dt)) { - /* Increment the reference count on the shared datatype */ - if(H5T_link(attr->dt, 1, dxpl_id) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared datatype link count") - } /* end if */ - /* Retrieve ref count for shared attribute */ if(H5SM_get_refcount(loc->file, dxpl_id, H5O_ATTR_ID, &attr->sh_loc, &attr_rc) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve shared message ref count") diff --git a/src/H5Omessage.c b/src/H5Omessage.c index 79631fe..bcb3e6e 100644 --- a/src/H5Omessage.c +++ b/src/H5Omessage.c @@ -1143,7 +1143,7 @@ H5O_msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, else { /* Convert message into a null message */ if(H5O_release_mesg(udata->f, udata->dxpl_id, oh, mesg, TRUE, udata->adj_link) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5_ITER_ERROR, "unable to convert into null message") + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5_ITER_ERROR, "unable to release message") /* Indicate that the object header was modified */ *oh_flags_ptr |= H5AC__DIRTIED_FLAG; diff --git a/src/H5SM.c b/src/H5SM.c index 22ffc6d..4a6e106 100755 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -1367,7 +1367,7 @@ done: /* Free the serialized message buffer on error */ if(ret_value < 0 && *encoded_mesg) - H5MM_xfree(*encoded_mesg); + *encoded_mesg = H5MM_xfree(*encoded_mesg); FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM_delete_from_index() */ diff --git a/test/tattr.c b/test/tattr.c index 1426c16..c0f89d2 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -115,6 +115,7 @@ struct attr4_struct { #define ATTR5_RANK 0 float attr_data5=(float)-5.123; /* Test data for 5th attribute */ +#ifndef QAK herr_t attr_op1(hid_t loc_id, const char *name, void *op_data); @@ -1551,6 +1552,7 @@ test_attr_dtype_shared(hid_t fapl) if(empty_filesize<0) TestErrPrintf("Line %d: file size wrong!\n",__LINE__); + /* Re-open file */ file_id=H5Fopen(FILENAME,H5F_ACC_RDWR,fapl); CHECK(file_id, FAIL, "H5Fopen"); @@ -2609,7 +2611,7 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl) /**************************************************************** ** ** test_attr_shared_write(): Test basic H5A (attribute) code. -** Tests writing to shared attributes in "compact" & "dense" storage +** Tests writing mix of shared & un-shared attributes in "compact" & "dense" storage ** ****************************************************************/ static void @@ -2619,7 +2621,8 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) hid_t my_fcpl; /* File creation property list ID */ hid_t dataset, dataset2; /* Dataset IDs */ hid_t attr_tid; /* Attribute's datatype ID */ - hid_t sid; /* Dataspace ID */ + hid_t sid, big_sid; /* Dataspace IDs */ + hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */ hid_t attr; /* Attribute ID */ hid_t dcpl; /* Dataset creation property list ID */ char attrname[NAME_BUF_SIZE]; /* Name of attribute */ @@ -2629,6 +2632,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) htri_t is_shared; /* Is attributes shared? */ hsize_t shared_refcount; /* Reference count of shared attribute */ unsigned attr_value; /* Attribute value */ + unsigned big_value[SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3]; /* Data for "big" attribute */ size_t mesg_count; /* # of shared messages */ unsigned test_shared; /* Index over shared component type */ unsigned u; /* Local index variable */ @@ -2637,7 +2641,18 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) herr_t ret; /* Generic return value */ /* Output message about test being performed */ - MESSAGE(5, ("Testing Writing to Shared Attributes in Compact & Dense Storage\n")); + MESSAGE(5, ("Testing Writing Shared & Unshared Attributes in Compact & Dense Storage\n")); + + /* Initialize "big" attribute data */ + HDmemset(big_value, 1, sizeof(big_value)); + + /* Create dataspace for dataset */ + sid = H5Screate(H5S_SCALAR); + CHECK(sid, FAIL, "H5Screate"); + + /* Create "big" dataspace for "large" attributes */ + big_sid = H5Screate_simple(SPACE1_RANK, big_dims, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); /* Loop over type of shared components */ for(test_shared = 0; test_shared < 3; test_shared++) { @@ -2650,19 +2665,28 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) CHECK(attr_tid, FAIL, "H5Tcopy"); /* Special setup for each type of shared components */ - if(test_shared != 0) { + if(test_shared == 0) { + /* Make attributes > 500 bytes shared */ + ret = H5Pset_shared_mesg_nindexes(my_fcpl, (unsigned)1); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + ret = H5Pset_shared_mesg_index(my_fcpl, (unsigned)0, H5O_MESG_ATTR_FLAG, (unsigned)500); + } /* end if */ + else { /* Set up copy of file creation property list */ - /* Make attributes, datatypes & dataspaces > 1 byte shared (i.e. all of them :-) */ ret = H5Pset_shared_mesg_nindexes(my_fcpl, (unsigned)3); CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - ret = H5Pset_shared_mesg_index(my_fcpl, (unsigned)0, H5O_MESG_ATTR_FLAG, (unsigned)1); + + /* Make attributes > 500 bytes shared */ + ret = H5Pset_shared_mesg_index(my_fcpl, (unsigned)0, H5O_MESG_ATTR_FLAG, (unsigned)500); + + /* Make datatypes & dataspaces > 1 byte shared (i.e. all of them :-) */ CHECK_I(ret, "H5Pset_shared_mesg_index"); ret = H5Pset_shared_mesg_index(my_fcpl, (unsigned)1, H5O_MESG_DTYPE_FLAG, (unsigned)1); CHECK_I(ret, "H5Pset_shared_mesg_index"); ret = H5Pset_shared_mesg_index(my_fcpl, (unsigned)2, H5O_MESG_SDSPACE_FLAG, (unsigned)1); CHECK_I(ret, "H5Pset_shared_mesg_index"); - } /* end if */ + } /* end else */ /* Create file */ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, my_fcpl, fapl); @@ -2702,10 +2726,6 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) CHECK(attr_tid, FAIL, "H5Topen"); } /* end if */ - /* Create dataspace for dataset */ - sid = H5Screate(H5S_SCALAR); - CHECK(sid, FAIL, "H5Screate"); - /* Set up to query the object creation properties */ dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); @@ -2744,23 +2764,45 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) /* Create attribute name */ sprintf(attrname, "attr %02u", u); - /* Create attribute on first dataset */ - attr = H5Acreate(dataset, attrname, attr_tid, sid, H5P_DEFAULT); - CHECK(attr, FAIL, "H5Acreate"); - - /* Check that attribute is shared */ - is_shared = H5A_is_shared_test(attr); - VERIFY(is_shared, TRUE, "H5A_is_shared_test"); - - /* Check refcount for attribute */ - ret = H5A_get_shared_rc_test(attr, &shared_refcount); - CHECK(ret, FAIL, "H5A_get_shared_rc_test"); - VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test"); - - /* Write data into the attribute */ - attr_value = u + 1; - ret = H5Awrite(attr, attr_tid, &attr_value); - CHECK(ret, FAIL, "H5Awrite"); + /* Alternate between creating "small" & "big" attributes */ + if(u % 2) { + /* Create "small" attribute on first dataset */ + attr = H5Acreate(dataset, attrname, attr_tid, sid, H5P_DEFAULT); + CHECK(attr, FAIL, "H5Acreate"); + + /* Check that attribute is not shared */ + is_shared = H5A_is_shared_test(attr); + VERIFY(is_shared, FALSE, "H5A_is_shared_test"); + + /* Write data into the attribute */ + attr_value = u + 1; + ret = H5Awrite(attr, attr_tid, &attr_value); + CHECK(ret, FAIL, "H5Awrite"); + } /* end if */ + else { + /* Create "big" attribute on first dataset */ + attr = H5Acreate(dataset, attrname, attr_tid, big_sid, H5P_DEFAULT); + CHECK(attr, FAIL, "H5Acreate"); + + /* Check that attribute is shared */ + is_shared = H5A_is_shared_test(attr); + VERIFY(is_shared, TRUE, "H5A_is_shared_test"); + + /* Check refcount for attribute */ + ret = H5A_get_shared_rc_test(attr, &shared_refcount); + CHECK(ret, FAIL, "H5A_get_shared_rc_test"); + VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test"); + + /* Write data into the attribute */ + big_value[0] = u + 1; + ret = H5Awrite(attr, attr_tid, big_value); + CHECK(ret, FAIL, "H5Awrite"); + + /* Check refcount for attribute */ + ret = H5A_get_shared_rc_test(attr, &shared_refcount); + CHECK(ret, FAIL, "H5A_get_shared_rc_test"); + VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test"); + } /* end else */ /* Close attribute */ ret = H5Aclose(attr); @@ -2774,28 +2816,45 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test"); - /* Create attribute on second dataset */ - attr = H5Acreate(dataset2, attrname, attr_tid, sid, H5P_DEFAULT); - CHECK(attr, FAIL, "H5Acreate"); - - /* Check that attribute is shared */ - is_shared = H5A_is_shared_test(attr); - VERIFY(is_shared, TRUE, "H5A_is_shared_test"); - - /* Check refcount for attribute */ - ret = H5A_get_shared_rc_test(attr, &shared_refcount); - CHECK(ret, FAIL, "H5A_get_shared_rc_test"); - VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test"); - - /* Write data into the attribute */ - attr_value = u + 1; - ret = H5Awrite(attr, attr_tid, &attr_value); - CHECK(ret, FAIL, "H5Awrite"); - - /* Check refcount for attribute */ - ret = H5A_get_shared_rc_test(attr, &shared_refcount); - CHECK(ret, FAIL, "H5A_get_shared_rc_test"); - VERIFY(shared_refcount, 2, "H5A_get_shared_rc_test"); + /* Alternate between creating "small" & "big" attributes */ + if(u % 2) { + /* Create "small" attribute on second dataset */ + attr = H5Acreate(dataset2, attrname, attr_tid, sid, H5P_DEFAULT); + CHECK(attr, FAIL, "H5Acreate"); + + /* Check that attribute is not shared */ + is_shared = H5A_is_shared_test(attr); + VERIFY(is_shared, FALSE, "H5A_is_shared_test"); + + /* Write data into the attribute */ + attr_value = u + 1; + ret = H5Awrite(attr, attr_tid, &attr_value); + CHECK(ret, FAIL, "H5Awrite"); + } /* end if */ + else { + /* Create "big" attribute on second dataset */ + attr = H5Acreate(dataset2, attrname, attr_tid, big_sid, H5P_DEFAULT); + CHECK(attr, FAIL, "H5Acreate"); + + /* Check that attribute is shared */ + is_shared = H5A_is_shared_test(attr); + VERIFY(is_shared, TRUE, "H5A_is_shared_test"); + + /* Check refcount for attribute */ + ret = H5A_get_shared_rc_test(attr, &shared_refcount); + CHECK(ret, FAIL, "H5A_get_shared_rc_test"); + VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test"); + + /* Write data into the attribute */ + big_value[0] = u + 1; + ret = H5Awrite(attr, attr_tid, big_value); + CHECK(ret, FAIL, "H5Awrite"); + + /* Check refcount for attribute */ + ret = H5A_get_shared_rc_test(attr, &shared_refcount); + CHECK(ret, FAIL, "H5A_get_shared_rc_test"); + VERIFY(shared_refcount, 2, "H5A_get_shared_rc_test"); + } /* end else */ /* Close attribute */ ret = H5Aclose(attr); @@ -2813,16 +2872,27 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) ret = H5Tclose(attr_tid); CHECK(ret, FAIL, "H5Tclose"); - /* Close dataspace */ - ret = H5Sclose(sid); - CHECK(ret, FAIL, "H5Sclose"); - /* Close Datasets */ ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); ret = H5Dclose(dataset2); CHECK(ret, FAIL, "H5Dclose"); + /* Check on shared message status now */ + if(test_shared != 0) { + if(test_shared == 1) { + /* Check on datatype storage status */ + ret = H5F_get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count); + CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test"); + VERIFY(mesg_count, 1, "H5F_get_sohm_mesg_count_test"); + } /* end if */ + + /* Check on dataspace storage status */ + ret = H5F_get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count); + CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test"); + VERIFY(mesg_count, 2, "H5F_get_sohm_mesg_count_test"); + } /* end if */ + /* Unlink datasets with attributes */ ret = H5Gunlink(fid, DSET1_NAME); CHECK(ret, FAIL, "H5Gunlink"); @@ -2854,7 +2924,14 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) /* Check size of file */ filesize = h5_get_file_size(FILENAME); VERIFY(filesize, empty_filesize, "h5_get_file_size"); + + /* Close dataspaces */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Sclose(big_sid); + CHECK(ret, FAIL, "H5Sclose"); } /* test_attr_shared_write() */ +#endif /* QAK */ /**************************************************************** ** @@ -2869,7 +2946,8 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) hid_t my_fcpl; /* File creation property list ID */ hid_t dataset, dataset2; /* Dataset ID2 */ hid_t attr_tid; /* Attribute's datatype ID */ - hid_t sid; /* Dataspace ID */ + hid_t sid, big_sid; /* Dataspace IDs */ + hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */ hid_t attr; /* Attribute ID */ hid_t dcpl; /* Dataset creation property list ID */ char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */ @@ -2880,6 +2958,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) htri_t is_shared; /* Is attributes shared? */ hsize_t shared_refcount; /* Reference count of shared attribute */ unsigned attr_value; /* Attribute value */ + unsigned big_value[SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3]; /* Data for "big" attribute */ size_t mesg_count; /* # of shared messages */ unsigned test_shared; /* Index over shared component type */ unsigned u; /* Local index variable */ @@ -2888,10 +2967,23 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) herr_t ret; /* Generic return value */ /* Output message about test being performed */ - MESSAGE(5, ("Testing Renaming Shared Attributes in Compact & Dense Storage\n")); + MESSAGE(5, ("Testing Renaming Shared & Unshared Attributes in Compact & Dense Storage\n")); + + /* Initialize "big" attribute data */ + HDmemset(big_value, 1, sizeof(big_value)); + + /* Create dataspace for dataset */ + sid = H5Screate(H5S_SCALAR); + CHECK(sid, FAIL, "H5Screate"); + + /* Create "big" dataspace for "large" attributes */ + big_sid = H5Screate_simple(SPACE1_RANK, big_dims, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); /* Loop over type of shared components */ - for(test_shared = 0; test_shared < 3; test_shared++) { + for(test_shared = 0; test_shared < 1; test_shared++) { +HDfprintf(stderr, "Fix Loop!\n"); +HDfprintf(stderr, "test_shared = %u\n", test_shared); /* Make copy of file creation property list */ my_fcpl = H5Pcopy(fcpl); CHECK(my_fcpl, FAIL, "H5Pcopy"); @@ -2901,19 +2993,28 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) CHECK(attr_tid, FAIL, "H5Tcopy"); /* Special setup for each type of shared components */ - if(test_shared != 0) { + if(test_shared == 0) { + /* Make attributes > 500 bytes shared */ + ret = H5Pset_shared_mesg_nindexes(my_fcpl, (unsigned)1); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + ret = H5Pset_shared_mesg_index(my_fcpl, (unsigned)0, H5O_MESG_ATTR_FLAG, (unsigned)500); + } /* end if */ + else { /* Set up copy of file creation property list */ - /* Make attributes, datatypes & dataspaces > 1 byte shared (i.e. all of them :-) */ ret = H5Pset_shared_mesg_nindexes(my_fcpl, (unsigned)3); CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - ret = H5Pset_shared_mesg_index(my_fcpl, (unsigned)0, H5O_MESG_ATTR_FLAG, (unsigned)1); + + /* Make attributes > 500 bytes shared */ + ret = H5Pset_shared_mesg_index(my_fcpl, (unsigned)0, H5O_MESG_ATTR_FLAG, (unsigned)500); + + /* Make datatypes & dataspaces > 1 byte shared (i.e. all of them :-) */ CHECK_I(ret, "H5Pset_shared_mesg_index"); ret = H5Pset_shared_mesg_index(my_fcpl, (unsigned)1, H5O_MESG_DTYPE_FLAG, (unsigned)1); CHECK_I(ret, "H5Pset_shared_mesg_index"); ret = H5Pset_shared_mesg_index(my_fcpl, (unsigned)2, H5O_MESG_SDSPACE_FLAG, (unsigned)1); CHECK_I(ret, "H5Pset_shared_mesg_index"); - } /* end if */ + } /* end else */ /* Create file */ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, my_fcpl, fapl); @@ -2953,10 +3054,6 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) CHECK(attr_tid, FAIL, "H5Topen"); } /* end if */ - /* Create dataspace for dataset */ - sid = H5Screate(H5S_SCALAR); - CHECK(sid, FAIL, "H5Screate"); - /* Set up to query the object creation properties */ dcpl = H5Pcreate(H5P_DATASET_CREATE); CHECK(dcpl, FAIL, "H5Pcreate"); @@ -2968,7 +3065,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) CHECK(dataset2, FAIL, "H5Dcreate"); /* Check on dataset's message storage status */ - if(test_shared) { + if(test_shared != 0) { /* Dataset's datatypes are immutable and shouldn't be shared */ ret = H5F_get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count); CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test"); @@ -2995,23 +3092,45 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) /* Create attribute name */ sprintf(attrname, "attr %02u", u); - /* Create attribute on first dataset */ - attr = H5Acreate(dataset, attrname, attr_tid, sid, H5P_DEFAULT); - CHECK(attr, FAIL, "H5Acreate"); - - /* Check that attribute is shared */ - is_shared = H5A_is_shared_test(attr); - VERIFY(is_shared, TRUE, "H5A_is_shared_test"); - - /* Check refcount for attribute */ - ret = H5A_get_shared_rc_test(attr, &shared_refcount); - CHECK(ret, FAIL, "H5A_get_shared_rc_test"); - VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test"); - - /* Write data into the attribute */ - attr_value = u + 1; - ret = H5Awrite(attr, attr_tid, &attr_value); - CHECK(ret, FAIL, "H5Awrite"); + /* Alternate between creating "small" & "big" attributes */ + if(u % 2) { + /* Create "small" attribute on first dataset */ + attr = H5Acreate(dataset, attrname, attr_tid, sid, H5P_DEFAULT); + CHECK(attr, FAIL, "H5Acreate"); + + /* Check that attribute is not shared */ + is_shared = H5A_is_shared_test(attr); + VERIFY(is_shared, FALSE, "H5A_is_shared_test"); + + /* Write data into the attribute */ + attr_value = u + 1; + ret = H5Awrite(attr, attr_tid, &attr_value); + CHECK(ret, FAIL, "H5Awrite"); + } /* end if */ + else { + /* Create "big" attribute on first dataset */ + attr = H5Acreate(dataset, attrname, attr_tid, big_sid, H5P_DEFAULT); + CHECK(attr, FAIL, "H5Acreate"); + + /* Check that attribute is shared */ + is_shared = H5A_is_shared_test(attr); + VERIFY(is_shared, TRUE, "H5A_is_shared_test"); + + /* Check refcount for attribute */ + ret = H5A_get_shared_rc_test(attr, &shared_refcount); + CHECK(ret, FAIL, "H5A_get_shared_rc_test"); + VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test"); + + /* Write data into the attribute */ + big_value[0] = u + 1; + ret = H5Awrite(attr, attr_tid, big_value); + CHECK(ret, FAIL, "H5Awrite"); + + /* Check refcount for attribute */ + ret = H5A_get_shared_rc_test(attr, &shared_refcount); + CHECK(ret, FAIL, "H5A_get_shared_rc_test"); + VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test"); + } /* end else */ /* Close attribute */ ret = H5Aclose(attr); @@ -3025,28 +3144,45 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test"); - /* Create attribute on second dataset */ - attr = H5Acreate(dataset2, attrname, attr_tid, sid, H5P_DEFAULT); - CHECK(attr, FAIL, "H5Acreate"); - - /* Check that attribute is shared */ - is_shared = H5A_is_shared_test(attr); - VERIFY(is_shared, TRUE, "H5A_is_shared_test"); - - /* Check refcount for attribute */ - ret = H5A_get_shared_rc_test(attr, &shared_refcount); - CHECK(ret, FAIL, "H5A_get_shared_rc_test"); - VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test"); - - /* Write data into the attribute */ - attr_value = u + 1; - ret = H5Awrite(attr, attr_tid, &attr_value); - CHECK(ret, FAIL, "H5Awrite"); - - /* Check refcount for attribute */ - ret = H5A_get_shared_rc_test(attr, &shared_refcount); - CHECK(ret, FAIL, "H5A_get_shared_rc_test"); - VERIFY(shared_refcount, 2, "H5A_get_shared_rc_test"); + /* Alternate between creating "small" & "big" attributes */ + if(u % 2) { + /* Create "small" attribute on second dataset */ + attr = H5Acreate(dataset2, attrname, attr_tid, sid, H5P_DEFAULT); + CHECK(attr, FAIL, "H5Acreate"); + + /* Check that attribute is not shared */ + is_shared = H5A_is_shared_test(attr); + VERIFY(is_shared, FALSE, "H5A_is_shared_test"); + + /* Write data into the attribute */ + attr_value = u + 1; + ret = H5Awrite(attr, attr_tid, &attr_value); + CHECK(ret, FAIL, "H5Awrite"); + } /* end if */ + else { + /* Create "big" attribute on second dataset */ + attr = H5Acreate(dataset2, attrname, attr_tid, big_sid, H5P_DEFAULT); + CHECK(attr, FAIL, "H5Acreate"); + + /* Check that attribute is shared */ + is_shared = H5A_is_shared_test(attr); + VERIFY(is_shared, TRUE, "H5A_is_shared_test"); + + /* Check refcount for attribute */ + ret = H5A_get_shared_rc_test(attr, &shared_refcount); + CHECK(ret, FAIL, "H5A_get_shared_rc_test"); + VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test"); + + /* Write data into the attribute */ + big_value[0] = u + 1; + ret = H5Awrite(attr, attr_tid, big_value); + CHECK(ret, FAIL, "H5Awrite"); + + /* Check refcount for attribute */ + ret = H5A_get_shared_rc_test(attr, &shared_refcount); + CHECK(ret, FAIL, "H5A_get_shared_rc_test"); + VERIFY(shared_refcount, 2, "H5A_get_shared_rc_test"); + } /* end else */ /* Close attribute */ ret = H5Aclose(attr); @@ -3074,14 +3210,21 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) attr = H5Aopen_name(dataset2, attrname2); CHECK(attr, FAIL, "H5Aopen_name"); - /* Check that attribute is shared */ - is_shared = H5A_is_shared_test(attr); - VERIFY(is_shared, TRUE, "H5A_is_shared_test"); - - /* Check refcount for attribute */ - ret = H5A_get_shared_rc_test(attr, &shared_refcount); - CHECK(ret, FAIL, "H5A_get_shared_rc_test"); - VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test"); + if(u % 2) { + /* Check that attribute is not shared */ + is_shared = H5A_is_shared_test(attr); + VERIFY(is_shared, FALSE, "H5A_is_shared_test"); + } /* end if */ + else { + /* Check that attribute is shared */ + is_shared = H5A_is_shared_test(attr); + VERIFY(is_shared, TRUE, "H5A_is_shared_test"); + + /* Check refcount for attribute */ + ret = H5A_get_shared_rc_test(attr, &shared_refcount); + CHECK(ret, FAIL, "H5A_get_shared_rc_test"); + VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test"); + } /* end else */ /* Close attribute */ ret = H5Aclose(attr); @@ -3091,14 +3234,21 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) attr = H5Aopen_name(dataset, attrname); CHECK(attr, FAIL, "H5Aopen_name"); - /* Check that attribute is shared */ - is_shared = H5A_is_shared_test(attr); - VERIFY(is_shared, TRUE, "H5A_is_shared_test"); - - /* Check refcount for attribute */ - ret = H5A_get_shared_rc_test(attr, &shared_refcount); - CHECK(ret, FAIL, "H5A_get_shared_rc_test"); - VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test"); + if(u % 2) { + /* Check that attribute is not shared */ + is_shared = H5A_is_shared_test(attr); + VERIFY(is_shared, FALSE, "H5A_is_shared_test"); + } /* end if */ + else { + /* Check that attribute is shared */ + is_shared = H5A_is_shared_test(attr); + VERIFY(is_shared, TRUE, "H5A_is_shared_test"); + + /* Check refcount for attribute */ + ret = H5A_get_shared_rc_test(attr, &shared_refcount); + CHECK(ret, FAIL, "H5A_get_shared_rc_test"); + VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test"); + } /* end else */ /* Close attribute */ ret = H5Aclose(attr); @@ -3116,14 +3266,21 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) attr = H5Aopen_name(dataset2, attrname); CHECK(attr, FAIL, "H5Aopen_name"); - /* Check that attribute is shared */ - is_shared = H5A_is_shared_test(attr); - VERIFY(is_shared, TRUE, "H5A_is_shared_test"); - - /* Check refcount for attribute */ - ret = H5A_get_shared_rc_test(attr, &shared_refcount); - CHECK(ret, FAIL, "H5A_get_shared_rc_test"); - VERIFY(shared_refcount, 2, "H5A_get_shared_rc_test"); + if(u % 2) { + /* Check that attribute is not shared */ + is_shared = H5A_is_shared_test(attr); + VERIFY(is_shared, FALSE, "H5A_is_shared_test"); + } /* end if */ + else { + /* Check that attribute is shared */ + is_shared = H5A_is_shared_test(attr); + VERIFY(is_shared, TRUE, "H5A_is_shared_test"); + + /* Check refcount for attribute */ + ret = H5A_get_shared_rc_test(attr, &shared_refcount); + CHECK(ret, FAIL, "H5A_get_shared_rc_test"); + VERIFY(shared_refcount, 2, "H5A_get_shared_rc_test"); + } /* end else */ /* Close attribute */ ret = H5Aclose(attr); @@ -3133,14 +3290,21 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) attr = H5Aopen_name(dataset, attrname); CHECK(attr, FAIL, "H5Aopen_name"); - /* Check that attribute is shared */ - is_shared = H5A_is_shared_test(attr); - VERIFY(is_shared, TRUE, "H5A_is_shared_test"); - - /* Check refcount for attribute */ - ret = H5A_get_shared_rc_test(attr, &shared_refcount); - CHECK(ret, FAIL, "H5A_get_shared_rc_test"); - VERIFY(shared_refcount, 2, "H5A_get_shared_rc_test"); + if(u % 2) { + /* Check that attribute is not shared */ + is_shared = H5A_is_shared_test(attr); + VERIFY(is_shared, FALSE, "H5A_is_shared_test"); + } /* end if */ + else { + /* Check that attribute is shared */ + is_shared = H5A_is_shared_test(attr); + VERIFY(is_shared, TRUE, "H5A_is_shared_test"); + + /* Check refcount for attribute */ + ret = H5A_get_shared_rc_test(attr, &shared_refcount); + CHECK(ret, FAIL, "H5A_get_shared_rc_test"); + VERIFY(shared_refcount, 2, "H5A_get_shared_rc_test"); + } /* end else */ /* Close attribute */ ret = H5Aclose(attr); @@ -3151,16 +3315,27 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) ret = H5Tclose(attr_tid); CHECK(ret, FAIL, "H5Tclose"); - /* Close dataspace */ - ret = H5Sclose(sid); - CHECK(ret, FAIL, "H5Sclose"); - /* Close Datasets */ ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); ret = H5Dclose(dataset2); CHECK(ret, FAIL, "H5Dclose"); + /* Check on shared message status now */ + if(test_shared != 0) { + if(test_shared == 1) { + /* Check on datatype storage status */ + ret = H5F_get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count); + CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test"); + VERIFY(mesg_count, 1, "H5F_get_sohm_mesg_count_test"); + } /* end if */ + + /* Check on dataspace storage status */ + ret = H5F_get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count); + CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test"); + VERIFY(mesg_count, 2, "H5F_get_sohm_mesg_count_test"); + } /* end if */ + /* Unlink datasets with attributes */ ret = H5Gunlink(fid, DSET1_NAME); CHECK(ret, FAIL, "H5Gunlink"); @@ -3192,8 +3367,15 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) /* Check size of file */ filesize = h5_get_file_size(FILENAME); VERIFY(filesize, empty_filesize, "h5_get_file_size"); + + /* Close dataspaces */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Sclose(big_sid); + CHECK(ret, FAIL, "H5Sclose"); } /* test_attr_shared_rename() */ +#ifndef QAK /**************************************************************** ** ** test_attr_shared_delete(): Test basic H5A (attribute) code. @@ -3758,6 +3940,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) filesize = h5_get_file_size(FILENAME); VERIFY(filesize, empty_filesize, "h5_get_file_size"); } /* test_attr_shared_unlink() */ +#endif /* QAK */ /**************************************************************** ** @@ -3802,6 +3985,7 @@ test_attr(void) ret = H5Pset_shared_mesg_index(fcpl2, (unsigned)0, H5O_MESG_ATTR_FLAG, (unsigned)1); CHECK_I(ret, "H5Pset_shared_mesg_index"); +#ifndef QAK /* Loop over using new group format */ for(new_format = FALSE; new_format <= TRUE; new_format++) { hid_t my_fapl; @@ -3870,6 +4054,10 @@ test_attr(void) test_attr_shared_rename(fcpl2, fapl2); /* Test renaming shared attributes in compact & dense storage */ test_attr_shared_delete(fcpl2, fapl2); /* Test deleting shared attributes in compact & dense storage */ test_attr_shared_unlink(fcpl2, fapl2); /* Test unlinking object with shared attributes in compact & dense storage */ +#else /* QAK */ +HDfprintf(stderr, "Uncomment tests!\n"); + test_attr_shared_rename(fcpl2, fapl2); /* Test renaming shared attributes in compact & dense storage */ +#endif /* QAK */ /* Close FCPLs */ ret = H5Pclose(fcpl); -- cgit v0.12