summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-01-10 04:01:31 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-01-10 04:01:31 (GMT)
commit1f3ffdab86a097c9845357c2f87174671234870e (patch)
tree659e43068677e7a54ab786a74c9bea06c9af9220
parenta2a3e47d06ce348ce27718b4a3e0e4b156fba6f5 (diff)
downloadhdf5-1f3ffdab86a097c9845357c2f87174671234870e.zip
hdf5-1f3ffdab86a097c9845357c2f87174671234870e.tar.gz
hdf5-1f3ffdab86a097c9845357c2f87174671234870e.tar.bz2
[svn-r13130] Description:
Further tests & bugfixes for shared/committed components of shared/un- shared attributes using dense/compact storage. Tested on: Mac OS X/32 10.4.8 (amazon) FreeBSD/32 6.1 (duty)
-rw-r--r--src/H5Adense.c8
-rw-r--r--src/H5Apkg.h2
-rw-r--r--src/H5Oattr.c36
-rw-r--r--src/H5Oattribute.c14
-rw-r--r--src/H5Oprivate.h2
-rw-r--r--src/H5Oshared.c4
-rwxr-xr-xsrc/H5SM.c24
-rw-r--r--test/tattr.c204
8 files changed, 192 insertions, 102 deletions
diff --git a/src/H5Adense.c b/src/H5Adense.c
index 972d80e..c492932 100644
--- a/src/H5Adense.c
+++ b/src/H5Adense.c
@@ -51,7 +51,7 @@
#define H5A_FHEAP_MAN_WIDTH 4
#define H5A_FHEAP_MAN_START_BLOCK_SIZE 512
#define H5A_FHEAP_MAN_MAX_DIRECT_SIZE (64 * 1024)
-#define H5A_FHEAP_MAN_MAX_INDEX 32
+#define H5A_FHEAP_MAN_MAX_INDEX 40
#define H5A_FHEAP_MAN_START_ROOT_ROWS 1
#define H5A_FHEAP_CHECKSUM_DBLOCKS TRUE
#define H5A_FHEAP_MAX_MAN_SIZE (4 * 1024)
@@ -824,6 +824,12 @@ H5A_dense_rename(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, const char *old_name,
HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust attribute link count")
} /* end if */
} /* end if */
+ else if(shared_mesg == 0) {
+ /* Increment reference count on attribute components */
+ /* (so that they aren't deleted when the attribute is removed shortly) */
+ if(H5O_attr_link(f, dxpl_id, attr_copy) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust attribute link count")
+ } /* end if */
else if(shared_mesg < 0)
HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "error determining if message should be shared")
diff --git a/src/H5Apkg.h b/src/H5Apkg.h
index 238546f..82471d1 100644
--- a/src/H5Apkg.h
+++ b/src/H5Apkg.h
@@ -51,7 +51,7 @@
/**************************/
/* Standard length of fractal heap ID for attribute */
-#define H5A_DENSE_FHEAP_ID_LEN 7
+#define H5A_DENSE_FHEAP_ID_LEN 8
/****************************/
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index aae4858..1358147 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -665,10 +665,19 @@ H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link)
HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "can't tell if datatype is shared")
if(tri_ret > 0)
{
- 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 heap")
+ /* Check whether datatype is shared */
+ if(H5T_committed(attr->dt)) {
+ /* Decrement the reference count on the shared datatype, if requested */
+ if(adj_link)
+ if(H5T_link(attr->dt, -1, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust shared datatype link count")
+ } /* end if */
+ else {
+ 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 heap")
+ } /* end else */
} /* end if */
if((tri_ret = H5O_msg_is_shared(H5O_SDSPACE_ID, attr->ds)) < 0)
@@ -681,14 +690,6 @@ H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link)
HGOTO_ERROR(H5E_ATTR, H5E_SOHM, FAIL, "can't remove dataspace from shared storage")
} /* end if */
- /* Check whether datatype is shared */
- if(H5T_committed(attr->dt)) {
- /* Decrement the reference count on the shared datatype, if requested */
- if(adj_link)
- if(H5T_link(attr->dt, -1, dxpl_id) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust shared datatype link count")
- } /* end if */
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_attr_delete() */
@@ -724,17 +725,18 @@ H5O_attr_link(H5F_t *f, hid_t dxpl_id, const void *_mesg)
* Otherwise they may be deleted when the attribute
* message is deleted.
*/
- if(H5SM_try_share(f, dxpl_id, H5O_DTYPE_ID, attr->dt) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "error trying to re-share attribute datatype")
- if(H5SM_try_share(f, dxpl_id, H5O_SDSPACE_ID, attr->ds) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "error trying to re-share attribute dataspace")
-
/* Check whether datatype is shared */
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_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust shared datatype link count")
} /* end if */
+ else {
+ if(H5SM_try_share(f, dxpl_id, H5O_DTYPE_ID, attr->dt) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "error trying to re-share attribute datatype")
+ } /* end else */
+ if(H5SM_try_share(f, dxpl_id, H5O_SDSPACE_ID, attr->ds) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "error trying to re-share attribute dataspace")
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c
index 57cc4ae..237e352 100644
--- a/src/H5Oattribute.c
+++ b/src/H5Oattribute.c
@@ -957,15 +957,11 @@ H5O_attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
oh->nattrs++;
/* Append renamed attribute to object header */
- /* (increments the link count on shared components) */
+ /* (doesn't increment the link count on shared components because
+ * attributes no longer have a 'link' callback) */
if(H5O_msg_append_real(udata->f, udata->dxpl_id, oh, H5O_MSG_ATTR, 0, 0, attr, oh_flags_ptr) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to relocate renamed attribute in header")
- /* Decrement the link count on shared components */
- /* (to balance all the link count adjustments out) */
- if(H5O_attr_delete(udata->f, udata->dxpl_id, attr, TRUE) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, H5_ITER_ERROR, "unable to delete attribute")
-
/* Release the local copy of the attribute */
H5O_msg_free_real(H5O_MSG_ATTR, attr);
} /* end if */
@@ -1324,6 +1320,12 @@ H5O_attr_remove(const H5O_loc_t *loc, const char *name, hid_t dxpl_id)
if((shared_mesg = H5SM_try_share(loc->file, dxpl_id, H5O_ATTR_ID, &(atable.attrs[u]))) > 0)
/* Mark the message as shared */
mesg_flags |= H5O_MSG_FLAG_SHARED;
+ else if(shared_mesg == 0) {
+ /* Increment reference count on attribute components */
+ /* (so that they aren't deleted when the dense attribute storage is deleted) */
+ if(H5O_attr_link(loc->file, dxpl_id, &(atable.attrs[u])) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust attribute link count")
+ } /* end if */
else if(shared_mesg < 0)
HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "error determining if message should be shared")
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index 1a42569..2d555e8 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -49,7 +49,7 @@ typedef struct H5O_t H5O_t;
* depends on how the heap is configured; currently they're seven bytes long
* but are stored in 8-byte fields in memory.
*/
-#define H5SM_FHEAP_ID_LEN 7
+#define H5SM_FHEAP_ID_LEN 8
typedef uint64_t H5SM_fheap_id_t;
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index fa6a7ef..eef0bd8 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -318,7 +318,7 @@ H5O_shared_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *buf)
*/
if(mesg->flags & H5O_SHARED_IN_HEAP_FLAG) {
HDassert(version >= H5O_SHARED_VERSION_3 );
- HDmemcpy(&(mesg->u.heap_id), buf, (size_t) H5SM_FHEAP_ID_LEN);
+ HDmemcpy(&(mesg->u.heap_id), buf, sizeof(mesg->u.heap_id));
}
else {
/* The H5O_COMMITTED_FLAG should be set if this message
@@ -395,7 +395,7 @@ H5O_shared_encode(H5F_t *f, uint8_t *buf/*out*/, const void *_mesg)
* object header that holds it.
*/
if(mesg->flags & H5O_SHARED_IN_HEAP_FLAG) {
- HDmemcpy(buf, &(mesg->u.heap_id), (size_t) H5SM_FHEAP_ID_LEN);
+ HDmemcpy(buf, &(mesg->u.heap_id), sizeof(mesg->u.heap_id));
}
else {
H5F_addr_encode(f, &buf, mesg->u.oloc.addr);
diff --git a/src/H5SM.c b/src/H5SM.c
index e5e28e7..40e47c7 100755
--- a/src/H5SM.c
+++ b/src/H5SM.c
@@ -38,7 +38,7 @@
#define H5SM_FHEAP_MAN_WIDTH 4
#define H5SM_FHEAP_MAN_START_BLOCK_SIZE 1024
#define H5SM_FHEAP_MAN_MAX_DIRECT_SIZE (64 * 1024)
-#define H5SM_FHEAP_MAN_MAX_INDEX 32
+#define H5SM_FHEAP_MAN_MAX_INDEX 40
#define H5SM_FHEAP_MAN_START_ROOT_ROWS 1
#define H5SM_FHEAP_CHECKSUM_DBLOCKS TRUE
#define H5SM_FHEAP_MAX_MAN_SIZE (4 * 1024)
@@ -486,6 +486,7 @@ H5SM_create_index(H5F_t *f, H5SM_index_header_t *header, hid_t dxpl_id)
if(H5HF_get_id_len(fheap, &fheap_id_len) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTGETSIZE, FAIL, "can't get fractal heap ID length")
HDassert(fheap_id_len == H5SM_FHEAP_ID_LEN);
+ HDassert(sizeof(H5SM_fheap_id_t) == H5SM_FHEAP_ID_LEN);
#endif /* NDEBUG */
done:
@@ -1145,22 +1146,21 @@ size_t
H5SM_find_in_list(H5SM_list_t *list, const H5SM_mesg_key_t *key)
{
size_t x;
- size_t ret_value = UFAIL;
+ size_t ret_value;
- FUNC_ENTER_NOAPI_NOFUNC(H5SM_find_in_list)
+ FUNC_ENTER_NOAPI(H5SM_find_in_list, UFAIL)
HDassert(list);
HDassert(key);
for(x = 0; x < list->header->list_max; x++)
- {
- if((list->messages[x].ref_count > 0 )&& 0 == H5SM_message_compare(key, &(list->messages[x])))
- {
- ret_value = x;
- break;
- }
- }
+ if((list->messages[x].ref_count > 0) && 0 == H5SM_message_compare(key, &(list->messages[x])))
+ HGOTO_DONE(x)
+
+ /* If we reached this point, we didn't find the message */
+ HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, UFAIL, "message not in list")
+done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5SM_find_in_list */
@@ -1323,7 +1323,7 @@ H5SM_delete_from_index(H5F_t *f, hid_t dxpl_id, H5SM_index_header_t *header,
/* If there are no messages left in the index, delete it */
- if(header->num_messages <=0) {
+ if(header->num_messages == 0) {
/* Unprotect cache and release heap */
if(list && H5AC_unprotect(f, dxpl_id, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DELETED_FLAG) < 0)
@@ -1444,7 +1444,7 @@ H5SM_reconstitute(H5O_shared_t *sh_mesg, const uint8_t *heap_id)
/* Set flag for shared message */
sh_mesg->flags = H5O_SHARED_IN_HEAP_FLAG;
- HDmemcpy(&sh_mesg->u.heap_id, heap_id, (size_t)H5SM_FHEAP_ID_LEN);
+ HDmemcpy(&sh_mesg->u.heap_id, heap_id, sizeof(sh_mesg->u.heap_id));
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5SM_reconstitute() */
diff --git a/test/tattr.c b/test/tattr.c
index c0f89d2..0efe56b 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -2931,7 +2931,6 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
ret = H5Sclose(big_sid);
CHECK(ret, FAIL, "H5Sclose");
} /* test_attr_shared_write() */
-#endif /* QAK */
/****************************************************************
**
@@ -2981,9 +2980,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
CHECK(sid, FAIL, "H5Screate_simple");
/* Loop over type of shared components */
- for(test_shared = 0; test_shared < 1; test_shared++) {
-HDfprintf(stderr, "Fix Loop!\n");
-HDfprintf(stderr, "test_shared = %u\n", test_shared);
+ for(test_shared = 0; test_shared < 3; test_shared++) {
/* Make copy of file creation property list */
my_fcpl = H5Pcopy(fcpl);
CHECK(my_fcpl, FAIL, "H5Pcopy");
@@ -3311,6 +3308,7 @@ HDfprintf(stderr, "test_shared = %u\n", test_shared);
CHECK(ret, FAIL, "H5Aclose");
} /* end for */
+
/* Close attribute's datatype */
ret = H5Tclose(attr_tid);
CHECK(ret, FAIL, "H5Tclose");
@@ -3374,8 +3372,8 @@ HDfprintf(stderr, "test_shared = %u\n", test_shared);
ret = H5Sclose(big_sid);
CHECK(ret, FAIL, "H5Sclose");
} /* test_attr_shared_rename() */
+#endif /* QAK */
-#ifndef QAK
/****************************************************************
**
** test_attr_shared_delete(): Test basic H5A (attribute) code.
@@ -3389,7 +3387,8 @@ test_attr_shared_delete(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 on first dataset */
@@ -3399,6 +3398,7 @@ test_attr_shared_delete(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 */
@@ -3407,7 +3407,18 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
herr_t ret; /* Generic return value */
/* Output message about test being performed */
- MESSAGE(5, ("Testing Deleting Shared Attributes in Compact & Dense Storage\n"));
+ MESSAGE(5, ("Testing Deleting 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++) {
@@ -3420,19 +3431,28 @@ test_attr_shared_delete(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);
@@ -3472,10 +3492,6 @@ test_attr_shared_delete(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");
@@ -3514,23 +3530,45 @@ test_attr_shared_delete(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");
+ /* 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 shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ /* Check that attribute is not shared */
+ is_shared = H5A_is_shared_test(attr);
+ VERIFY(is_shared, FALSE, "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");
+ } /* end if */
+ else {
+ /* Create "big" attribute on first dataset */
+ attr = H5Acreate(dataset, attrname, attr_tid, big_sid, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate");
- /* Write data into the attribute */
- attr_value = u + 1;
- ret = H5Awrite(attr, attr_tid, &attr_value);
- CHECK(ret, FAIL, "H5Awrite");
+ /* 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);
@@ -3544,28 +3582,45 @@ test_attr_shared_delete(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");
+ /* 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 shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ /* Check that attribute is not shared */
+ is_shared = H5A_is_shared_test(attr);
+ VERIFY(is_shared, FALSE, "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");
+ } /* end if */
+ else {
+ /* Create "big" attribute on second dataset */
+ attr = H5Acreate(dataset2, attrname, attr_tid, big_sid, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate");
- /* Write data into the attribute */
- attr_value = u + 1;
- ret = H5Awrite(attr, attr_tid, &attr_value);
- CHECK(ret, FAIL, "H5Awrite");
+ /* 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");
+ /* 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);
@@ -3579,10 +3634,6 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
} /* end for */
- /* Close attribute's datatype */
- ret = H5Tclose(attr_tid);
- CHECK(ret, FAIL, "H5Tclose");
-
/* Delete attributes from second dataset */
for(u = 0; u < max_compact * 2; u++) {
@@ -3600,14 +3651,21 @@ test_attr_shared_delete(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");
+ 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");
+ /* 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);
@@ -3615,9 +3673,9 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
} /* end for */
- /* Close dataspace */
- ret = H5Sclose(sid);
- CHECK(ret, FAIL, "H5Sclose");
+ /* Close attribute's datatype */
+ ret = H5Tclose(attr_tid);
+ CHECK(ret, FAIL, "H5Tclose");
/* Close Datasets */
ret = H5Dclose(dataset);
@@ -3625,6 +3683,21 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
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");
@@ -3656,8 +3729,15 @@ test_attr_shared_delete(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_delete() */
+#ifndef QAK
/****************************************************************
**
** test_attr_shared_unlink(): Test basic H5A (attribute) code.
@@ -4056,7 +4136,7 @@ test_attr(void)
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 */
+ test_attr_shared_delete(fcpl2, fapl2); /* Test deleting shared attributes in compact & dense storage */
#endif /* QAK */
/* Close FCPLs */