summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5Omessage.c24
-rw-r--r--src/H5Tcommit.c4
-rw-r--r--test/tattr.c794
3 files changed, 462 insertions, 360 deletions
diff --git a/src/H5Omessage.c b/src/H5Omessage.c
index c7979d4..79631fe 100644
--- a/src/H5Omessage.c
+++ b/src/H5Omessage.c
@@ -215,11 +215,13 @@ H5O_msg_append(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned type_id,
HDassert(oh_flags_ptr);
/* Should this message be written as a SOHM? */
- if((shared_mesg = H5SM_try_share(f, dxpl_id, type_id, mesg)) > 0)
- /* Mark the message as shared */
- mesg_flags |= H5O_MSG_FLAG_SHARED;
- else if(shared_mesg < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "error determining if message should be shared")
+ if(!(mesg_flags & H5O_MSG_FLAG_DONTSHARE)) {
+ if((shared_mesg = H5SM_try_share(f, dxpl_id, type_id, mesg)) > 0)
+ /* Mark the message as shared */
+ mesg_flags |= H5O_MSG_FLAG_SHARED;
+ else if(shared_mesg < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "error determining if message should be shared")
+ } /* end if */
/* Append new message to object header */
if(H5O_msg_append_real(f, dxpl_id, oh, type, mesg_flags, update_flags, mesg, oh_flags_ptr) < 0)
@@ -335,11 +337,13 @@ H5O_msg_write(H5O_loc_t *loc, unsigned type_id, unsigned overwrite,
HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file")
/* Should this message be written as a SOHM? */
- if((shared_mesg = H5SM_try_share(loc->file, dxpl_id, type_id, mesg)) > 0)
- /* Mark the message as shared */
- mesg_flags |= H5O_MSG_FLAG_SHARED;
- else if(shared_mesg < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "error while trying to share message")
+ if(!(mesg_flags & H5O_MSG_FLAG_DONTSHARE)) {
+ if((shared_mesg = H5SM_try_share(loc->file, dxpl_id, type_id, mesg)) > 0)
+ /* Mark the message as shared */
+ mesg_flags |= H5O_MSG_FLAG_SHARED;
+ else if(shared_mesg < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "error while trying to share message")
+ } /* end if */
/* Protect the object header */
if(NULL == (oh = H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, NULL, NULL, H5AC_WRITE)))
diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c
index 6ed7856..d8fbe3b 100644
--- a/src/H5Tcommit.c
+++ b/src/H5Tcommit.c
@@ -304,7 +304,7 @@ H5T_commit(H5F_t *file, H5T_t *type, hid_t dxpl_id, hid_t tcpl_id, hid_t UNUSED
/* Mark datatype as being on memory now. Since this datatype may still be used in memory
* after committed to disk, change its size back as in memory. */
- if(H5T_set_loc(type, NULL, H5T_LOC_MEMORY)<0)
+ if(H5T_set_loc(type, NULL, H5T_LOC_MEMORY) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype in memory")
done:
@@ -783,7 +783,7 @@ H5T_open_oid(H5G_loc_t *loc, hid_t dxpl_id)
H5T_t *dt = NULL;
H5T_t *ret_value;
- FUNC_ENTER_NOAPI(H5T_open_oid, NULL)
+ FUNC_ENTER_NOAPI_NOINIT(H5T_open_oid)
HDassert(loc);
diff --git a/test/tattr.c b/test/tattr.c
index 34c96c6..1426c16 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -115,7 +115,6 @@ 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);
@@ -1688,7 +1687,6 @@ test_attr_dtype_shared(hid_t fapl)
filesize=h5_get_file_size(FILENAME);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_dtype_shared() */
-#endif /* QAK */
/****************************************************************
**
@@ -1749,7 +1747,6 @@ test_attr_dense_verify(hid_t loc_id, unsigned max_attr)
} /* end for */
} /* test_attr_dense_verify() */
-#ifndef QAK
/****************************************************************
**
** test_attr_dense_create(): Test basic H5A (attribute) code.
@@ -1808,9 +1805,6 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl)
/* Retrieve limits for compact/dense attribute storage */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
-#ifdef QAK
-HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
-#endif /* QAK */
/* Check on dataset's attribute storage status */
is_dense = H5O_is_attr_dense_test(dataset);
@@ -1937,9 +1931,6 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl)
/* Retrieve limits for compact/dense attribute storage */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
-#ifdef QAK
-HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
-#endif /* QAK */
/* Check on dataset's attribute storage status */
is_dense = H5O_is_attr_dense_test(dataset);
@@ -2069,9 +2060,6 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
/* Retrieve limits for compact/dense attribute storage */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
-#ifdef QAK
-HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
-#endif /* QAK */
/* Check on dataset's attribute storage status */
is_dense = H5O_is_attr_dense_test(dataset);
@@ -2239,9 +2227,6 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
/* Retrieve limits for compact/dense attribute storage */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
-#ifdef QAK
-HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
-#endif /* QAK */
/* Check on dataset's attribute storage status */
is_dense = H5O_is_attr_dense_test(dataset);
@@ -2396,9 +2381,6 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl)
/* Retrieve limits for compact/dense attribute storage */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
-#ifdef QAK
-HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
-#endif /* QAK */
/* Check on dataset's attribute storage status */
is_dense = H5O_is_attr_dense_test(dataset);
@@ -2530,9 +2512,6 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
VERIFY(rmax_compact, max_compact, "H5Pget_attr_phase_change");
VERIFY(rmin_dense, min_dense, "H5Pget_attr_phase_change");
-#ifdef QAK
-HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
-#endif /* QAK */
/* Check on dataset's attribute storage status */
@@ -2626,7 +2605,6 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
filesize = h5_get_file_size(FILENAME);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_dense_limits() */
-#endif /* QAK */
/****************************************************************
**
@@ -2662,7 +2640,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
MESSAGE(5, ("Testing Writing to Shared Attributes in Compact & Dense Storage\n"));
/* Loop over type of shared components */
- for(test_shared = 0; test_shared < 2; 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");
@@ -2739,39 +2717,21 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
CHECK(dataset2, FAIL, "H5Dcreate");
/* Check on dataset's message storage status */
- switch(test_shared) {
- case 1:
- /* 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");
- VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
-
- /* Dataset's dataspace can be shared */
- 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, 1, "H5F_get_sohm_mesg_count_test");
- break;
-
- case 2:
- /* Dataset's datatypes are immutable and shouldn't be shared */
- /* (but committed datatype gets shared) */
- 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");
-
- /* Dataset's dataspace can be shared */
- 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, 1, "H5F_get_sohm_mesg_count_test");
- break;
+ 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");
+ VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+
+ /* Dataset's dataspace can be shared */
+ 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, 1, "H5F_get_sohm_mesg_count_test");
} /* end if */
/* Retrieve limits for compact/dense attribute storage */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
-#ifdef QAK
-HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
-#endif /* QAK */
/* Check on datasets' attribute storage status */
is_dense = H5O_is_attr_dense_test(dataset);
@@ -2896,7 +2856,6 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_shared_write() */
-#ifndef QAK
/****************************************************************
**
** test_attr_shared_rename(): Test basic H5A (attribute) code.
@@ -2932,7 +2891,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
MESSAGE(5, ("Testing Renaming Shared Attributes in Compact & Dense Storage\n"));
/* Loop over type of shared components */
- for(test_shared = 0; test_shared < 2; 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");
@@ -3009,39 +2968,21 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
CHECK(dataset2, FAIL, "H5Dcreate");
/* Check on dataset's message storage status */
- switch(test_shared) {
- case 1:
- /* 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");
- VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
-
- /* Dataset's dataspace can be shared */
- 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, 1, "H5F_get_sohm_mesg_count_test");
- break;
-
- case 2:
- /* Dataset's datatypes are immutable and shouldn't be shared */
- /* (but committed datatype gets shared) */
- 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");
-
- /* Dataset's dataspace can be shared */
- 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, 1, "H5F_get_sohm_mesg_count_test");
- break;
+ if(test_shared) {
+ /* 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");
+ VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+
+ /* Dataset's dataspace can be shared */
+ 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, 1, "H5F_get_sohm_mesg_count_test");
} /* end if */
/* Retrieve limits for compact/dense attribute storage */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
-#ifdef QAK
-HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
-#endif /* QAK */
/* Check on datasets' attribute storage status */
is_dense = H5O_is_attr_dense_test(dataset);
@@ -3262,8 +3203,10 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
static void
test_attr_shared_delete(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dataset, dataset2; /* Dataset ID2 */
+ hid_t fid; /* File ID */
+ 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 attr; /* Attribute ID */
hid_t dcpl; /* Dataset creation property list ID */
@@ -3274,6 +3217,8 @@ 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 */
+ size_t mesg_count; /* # of shared messages */
+ unsigned test_shared; /* Index over shared component type */
unsigned u; /* Local index variable */
h5_stat_size_t empty_filesize; /* Size of empty file */
h5_stat_size_t filesize; /* Size of file after modifications */
@@ -3282,171 +3227,249 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
/* Output message about test being performed */
MESSAGE(5, ("Testing Deleting Shared Attributes in Compact & Dense Storage\n"));
- /* Create file */
- fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
- CHECK(fid, FAIL, "H5Fcreate");
+ /* Loop over type of shared components */
+ 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");
- /* Close file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
+ /* Set up datatype for attributes */
+ attr_tid = H5Tcopy(H5T_NATIVE_UINT);
+ CHECK(attr_tid, FAIL, "H5Tcopy");
- /* Get size of file */
- empty_filesize = h5_get_file_size(FILENAME);
- if(empty_filesize < 0)
- TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
+ /* Special setup for each type of shared components */
+ if(test_shared != 0) {
+ /* Set up copy of file creation property list */
- /* Re-open file */
- fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
- CHECK(fid, FAIL, "H5Fopen");
+ /* 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);
+ 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 */
- /* Create dataspace for dataset */
- sid = H5Screate(H5S_SCALAR);
- CHECK(sid, FAIL, "H5Screate");
+ /* Create file */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, my_fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
- /* Set up to query the object creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ /* Close FCPL copy */
+ ret = H5Pclose(my_fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
- /* Create datasets */
- dataset = H5Dcreate(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, dcpl);
- CHECK(dataset, FAIL, "H5Dcreate");
- dataset2 = H5Dcreate(fid, DSET2_NAME, H5T_NATIVE_UCHAR, sid, dcpl);
- CHECK(dataset2, FAIL, "H5Dcreate");
+ /* Commit datatype to file */
+ if(test_shared == 2) {
+ ret = H5Tcommit(fid, TYPE1_NAME, attr_tid);
+ CHECK(ret, FAIL, "H5Tcommit");
- /* Retrieve limits for compact/dense attribute storage */
- ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
- CHECK(ret, FAIL, "H5Pget_attr_phase_change");
-#ifdef QAK
-HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
-#endif /* QAK */
+ /* Close attribute's datatype */
+ ret = H5Tclose(attr_tid);
+ CHECK(ret, FAIL, "H5Tclose");
+ } /* end switch */
- /* Check on datasets' attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
- is_dense = H5O_is_attr_dense_test(dataset2);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
- /* Add attributes to each dataset, until after converting to dense storage */
-/* XXX: Test with shared & committed datatype/dataspace also */
- for(u = 0; u < max_compact * 2; u++) {
- /* Create attribute name */
- sprintf(attrname, "attr %02u", u);
+ /* Get size of file */
+ empty_filesize = h5_get_file_size(FILENAME);
+ if(empty_filesize < 0)
+ TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
- /* Create attribute on first dataset */
- attr = H5Acreate(dataset, attrname, H5T_NATIVE_UINT, 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");
+ /* Re-open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
- /* 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");
+ /* Re-open attribute datatype as necessary */
+ if(test_shared == 2) {
+ attr_tid = H5Topen(fid, TYPE1_NAME);
+ CHECK(attr_tid, FAIL, "H5Topen");
+ } /* end if */
- /* Write data into the attribute */
- attr_value = u + 1;
- ret = H5Awrite(attr, H5T_NATIVE_UINT, &attr_value);
- CHECK(ret, FAIL, "H5Awrite");
+ /* Create dataspace for dataset */
+ sid = H5Screate(H5S_SCALAR);
+ CHECK(sid, FAIL, "H5Screate");
- /* Close attribute */
- ret = H5Aclose(attr);
- CHECK(ret, FAIL, "H5Aclose");
+ /* Set up to query the object creation properties */
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+
+ /* Create datasets */
+ dataset = H5Dcreate(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, dcpl);
+ CHECK(dataset, FAIL, "H5Dcreate");
+ dataset2 = H5Dcreate(fid, DSET2_NAME, H5T_NATIVE_UCHAR, sid, dcpl);
+ CHECK(dataset2, FAIL, "H5Dcreate");
+
+ /* Check on dataset's message storage status */
+ 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");
+ VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
- /* Check on dataset's attribute storage status */
+ /* Dataset's dataspace can be shared */
+ 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, 1, "H5F_get_sohm_mesg_count_test");
+ } /* end if */
+
+ /* Retrieve limits for compact/dense attribute storage */
+ ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
+ CHECK(ret, FAIL, "H5Pget_attr_phase_change");
+
+ /* Check on datasets' attribute storage status */
is_dense = H5O_is_attr_dense_test(dataset);
- if(u < max_compact)
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
- else
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O_is_attr_dense_test(dataset2);
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+
+ /* Add attributes to each dataset, until after converting to dense storage */
+ for(u = 0; u < max_compact * 2; u++) {
+ /* 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");
- /* Create attribute on second dataset */
- attr = H5Acreate(dataset2, attrname, H5T_NATIVE_UINT, 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 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");
+ /* Write data into the attribute */
+ attr_value = u + 1;
+ ret = H5Awrite(attr, attr_tid, &attr_value);
+ CHECK(ret, FAIL, "H5Awrite");
- /* Write data into the attribute */
- attr_value = u + 1;
- ret = H5Awrite(attr, H5T_NATIVE_UINT, &attr_value);
- CHECK(ret, FAIL, "H5Awrite");
+ /* Close attribute */
+ ret = H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
- /* 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 on dataset's attribute storage status */
+ is_dense = H5O_is_attr_dense_test(dataset);
+ if(u < max_compact)
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ else
+ VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
- /* Close attribute */
- ret = H5Aclose(attr);
- CHECK(ret, FAIL, "H5Aclose");
- /* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset2);
- if(u < max_compact)
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
- else
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
- } /* end for */
+ /* Create attribute on second dataset */
+ attr = H5Acreate(dataset2, attrname, attr_tid, sid, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate");
- /* Delete attributes from second dataset */
- for(u = 0; u < max_compact * 2; u++) {
- /* Create attribute name */
- sprintf(attrname, "attr %02u", u);
+ /* Check that attribute is shared */
+ is_shared = H5A_is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A_is_shared_test");
- /* Delete second dataset's attribute */
- ret = H5Adelete(dataset2, attrname);
- CHECK(ret, FAIL, "H5Adelete");
+ /* 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 on attributes now */
+ /* 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 on first dataset's attribute */
- attr = H5Aopen_name(dataset, attrname);
- CHECK(attr, FAIL, "H5Aopen_name");
+ /* Close attribute */
+ ret = H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
- /* Check that attribute is shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ /* Check on dataset's attribute storage status */
+ is_dense = H5O_is_attr_dense_test(dataset2);
+ if(u < max_compact)
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ else
+ VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ } /* end for */
- /* 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");
+ /* Close attribute's datatype */
+ ret = H5Tclose(attr_tid);
+ CHECK(ret, FAIL, "H5Tclose");
- /* Close attribute */
- ret = H5Aclose(attr);
- CHECK(ret, FAIL, "H5Aclose");
- } /* end for */
+ /* Delete attributes from second dataset */
+ for(u = 0; u < max_compact * 2; u++) {
+ /* Create attribute name */
+ sprintf(attrname, "attr %02u", u);
- /* Close dataspace */
- ret = H5Sclose(sid);
- CHECK(ret, FAIL, "H5Sclose");
+ /* Delete second dataset's attribute */
+ ret = H5Adelete(dataset2, attrname);
+ CHECK(ret, FAIL, "H5Adelete");
- /* Close Datasets */
- ret = H5Dclose(dataset);
- CHECK(ret, FAIL, "H5Dclose");
- ret = H5Dclose(dataset2);
- CHECK(ret, FAIL, "H5Dclose");
- /* Unlink datasets with attributes */
- ret = H5Gunlink(fid, DSET1_NAME);
- CHECK(ret, FAIL, "H5Gunlink");
- ret = H5Gunlink(fid, DSET2_NAME);
- CHECK(ret, FAIL, "H5Gunlink");
+ /* Check refcount on attributes now */
- /* Close file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
+ /* Check refcount on first dataset's attribute */
+ 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");
+
+ /* Close attribute */
+ ret = H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
+ } /* end for */
+
+
+ /* 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");
+
+ /* Unlink datasets with attributes */
+ ret = H5Gunlink(fid, DSET1_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
+ ret = H5Gunlink(fid, DSET2_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
+
+ /* Check on attribute storage status */
+ ret = H5F_get_sohm_mesg_count_test(fid, H5O_ATTR_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+
+ if(test_shared != 0) {
+ /* 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, 0, "H5F_get_sohm_mesg_count_test");
+
+ /* 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, 0, "H5F_get_sohm_mesg_count_test");
+ } /* end if */
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ } /* end for */
/* Check size of file */
filesize = h5_get_file_size(FILENAME);
@@ -3462,8 +3485,10 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
static void
test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dataset, dataset2; /* Dataset ID2 */
+ hid_t fid; /* File ID */
+ 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 attr; /* Attribute ID */
hid_t dcpl; /* Dataset creation property list ID */
@@ -3474,6 +3499,8 @@ test_attr_shared_unlink(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 */
+ size_t mesg_count; /* # of shared messages */
+ unsigned test_shared; /* Index over shared component type */
unsigned u; /* Local index variable */
h5_stat_size_t empty_filesize; /* Size of empty file */
h5_stat_size_t filesize; /* Size of file after modifications */
@@ -3482,179 +3509,255 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
/* Output message about test being performed */
MESSAGE(5, ("Testing Unlinking Object with Shared Attributes in Compact & Dense Storage\n"));
- /* Create file */
- fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
- CHECK(fid, FAIL, "H5Fcreate");
+ /* Loop over type of shared components */
+ 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");
- /* Close file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
+ /* Set up datatype for attributes */
+ attr_tid = H5Tcopy(H5T_NATIVE_UINT);
+ CHECK(attr_tid, FAIL, "H5Tcopy");
- /* Get size of file */
- empty_filesize = h5_get_file_size(FILENAME);
- if(empty_filesize < 0)
- TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
+ /* Special setup for each type of shared components */
+ if(test_shared != 0) {
+ /* Set up copy of file creation property list */
- /* Re-open file */
- fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
- CHECK(fid, FAIL, "H5Fopen");
+ /* 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);
+ 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 */
- /* Create dataspace for dataset */
- sid = H5Screate(H5S_SCALAR);
- CHECK(sid, FAIL, "H5Screate");
+ /* Create file */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, my_fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
- /* Set up to query the object creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ /* Close FCPL copy */
+ ret = H5Pclose(my_fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
- /* Create datasets */
- dataset = H5Dcreate(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, dcpl);
- CHECK(dataset, FAIL, "H5Dcreate");
- dataset2 = H5Dcreate(fid, DSET2_NAME, H5T_NATIVE_UCHAR, sid, dcpl);
- CHECK(dataset2, FAIL, "H5Dcreate");
+ /* Commit datatype to file */
+ if(test_shared == 2) {
+ ret = H5Tcommit(fid, TYPE1_NAME, attr_tid);
+ CHECK(ret, FAIL, "H5Tcommit");
- /* Retrieve limits for compact/dense attribute storage */
- ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
- CHECK(ret, FAIL, "H5Pget_attr_phase_change");
-#ifdef QAK
-HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense);
-#endif /* QAK */
+ /* Close attribute's datatype */
+ ret = H5Tclose(attr_tid);
+ CHECK(ret, FAIL, "H5Tclose");
+ } /* end switch */
- /* Check on datasets' attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
- is_dense = H5O_is_attr_dense_test(dataset2);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
- /* Add attributes to each dataset, until after converting to dense storage */
-/* XXX: Test with shared & committed datatype/dataspace also */
- for(u = 0; u < max_compact * 2; u++) {
- /* Create attribute name */
- sprintf(attrname, "attr %02u", u);
+ /* Get size of file */
+ empty_filesize = h5_get_file_size(FILENAME);
+ if(empty_filesize < 0)
+ TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
- /* Create attribute on first dataset */
- attr = H5Acreate(dataset, attrname, H5T_NATIVE_UINT, 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");
+ /* Re-open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
- /* 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");
+ /* Re-open attribute datatype as necessary */
+ if(test_shared == 2) {
+ attr_tid = H5Topen(fid, TYPE1_NAME);
+ CHECK(attr_tid, FAIL, "H5Topen");
+ } /* end if */
- /* Write data into the attribute */
- attr_value = u + 1;
- ret = H5Awrite(attr, H5T_NATIVE_UINT, &attr_value);
- CHECK(ret, FAIL, "H5Awrite");
+ /* Create dataspace for dataset */
+ sid = H5Screate(H5S_SCALAR);
+ CHECK(sid, FAIL, "H5Screate");
- /* Close attribute */
- ret = H5Aclose(attr);
- CHECK(ret, FAIL, "H5Aclose");
+ /* Set up to query the object creation properties */
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
- /* Check on dataset's attribute storage status */
+ /* Create datasets */
+ dataset = H5Dcreate(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, dcpl);
+ CHECK(dataset, FAIL, "H5Dcreate");
+ dataset2 = H5Dcreate(fid, DSET2_NAME, H5T_NATIVE_UCHAR, sid, dcpl);
+ CHECK(dataset2, FAIL, "H5Dcreate");
+
+ /* Check on dataset's message storage status */
+ 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");
+ VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+
+ /* Dataset's dataspace can be shared */
+ 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, 1, "H5F_get_sohm_mesg_count_test");
+ } /* end if */
+
+ /* Retrieve limits for compact/dense attribute storage */
+ ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
+ CHECK(ret, FAIL, "H5Pget_attr_phase_change");
+
+ /* Check on datasets' attribute storage status */
is_dense = H5O_is_attr_dense_test(dataset);
- if(u < max_compact)
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
- else
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O_is_attr_dense_test(dataset2);
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ /* Add attributes to each dataset, until after converting to dense storage */
+ for(u = 0; u < max_compact * 2; u++) {
+ /* Create attribute name */
+ sprintf(attrname, "attr %02u", u);
- /* Create attribute on second dataset */
- attr = H5Acreate(dataset2, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT);
- CHECK(attr, FAIL, "H5Acreate");
+ /* 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 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");
- /* Write data into the attribute */
- attr_value = u + 1;
- ret = H5Awrite(attr, H5T_NATIVE_UINT, &attr_value);
- CHECK(ret, FAIL, "H5Awrite");
+ /* 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");
+ /* Close attribute */
+ ret = H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
- /* Close attribute */
- ret = H5Aclose(attr);
- CHECK(ret, FAIL, "H5Aclose");
+ /* Check on dataset's attribute storage status */
+ is_dense = H5O_is_attr_dense_test(dataset);
+ if(u < max_compact)
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ else
+ VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
- /* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset2);
- if(u < max_compact)
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
- else
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
- } /* end for */
+ /* Create attribute on second dataset */
+ attr = H5Acreate(dataset2, attrname, attr_tid, sid, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate");
- /* Close second dataset */
- ret = H5Dclose(dataset2);
- CHECK(ret, FAIL, "H5Dclose");
+ /* Check that attribute is shared */
+ is_shared = H5A_is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A_is_shared_test");
- /* Unlink second dataset */
- ret = H5Gunlink(fid, DSET2_NAME);
- CHECK(ret, FAIL, "H5Gunlink");
+ /* 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 on first dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_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 ref count on attributes of first dataset */
- for(u = 0; u < max_compact * 2; u++) {
- /* Create attribute name */
- sprintf(attrname, "attr %02u", u);
+ /* Close attribute */
+ ret = H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
- /* Open attribute on first dataset */
- attr = H5Aopen_name(dataset, attrname);
- CHECK(attr, FAIL, "H5Acreate");
+ /* Check on dataset's attribute storage status */
+ is_dense = H5O_is_attr_dense_test(dataset2);
+ if(u < max_compact)
+ VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ else
+ VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ } /* end for */
- /* 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");
+ /* Close attribute's datatype */
+ ret = H5Tclose(attr_tid);
+ CHECK(ret, FAIL, "H5Tclose");
- /* Close attribute */
- ret = H5Aclose(attr);
- CHECK(ret, FAIL, "H5Aclose");
- } /* end for */
+ /* Close dataspace */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
- /* Close dataspace */
- ret = H5Sclose(sid);
- CHECK(ret, FAIL, "H5Sclose");
+ /* Close second dataset */
+ ret = H5Dclose(dataset2);
+ CHECK(ret, FAIL, "H5Dclose");
- /* Close Datasets */
- ret = H5Dclose(dataset);
- CHECK(ret, FAIL, "H5Dclose");
+ /* Unlink second dataset */
+ ret = H5Gunlink(fid, DSET2_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
- /* Unlink first dataset */
- ret = H5Gunlink(fid, DSET1_NAME);
- CHECK(ret, FAIL, "H5Gunlink");
- /* Close file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
+ /* Check on first dataset's attribute storage status */
+ is_dense = H5O_is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+
+ /* Check ref count on attributes of first dataset */
+ for(u = 0; u < max_compact * 2; u++) {
+ /* Create attribute name */
+ sprintf(attrname, "attr %02u", u);
+
+ /* Open attribute on first dataset */
+ attr = H5Aopen_name(dataset, attrname);
+ 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");
+
+ /* Close attribute */
+ ret = H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
+ } /* end for */
+
+ /* Close Datasets */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Unlink first dataset */
+ ret = H5Gunlink(fid, DSET1_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
+
+ /* Check on attribute storage status */
+ ret = H5F_get_sohm_mesg_count_test(fid, H5O_ATTR_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+
+ if(test_shared != 0) {
+ /* 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, 0, "H5F_get_sohm_mesg_count_test");
+
+ /* 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, 0, "H5F_get_sohm_mesg_count_test");
+ } /* end if */
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ } /* end for */
/* Check size of file */
filesize = h5_get_file_size(FILENAME);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
} /* test_attr_shared_unlink() */
-#endif /* QAK */
/****************************************************************
**
@@ -3699,7 +3802,6 @@ 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;
@@ -3768,10 +3870,6 @@ 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_write(fcpl2, fapl2); /* Test writing to shared attributes in compact & dense storage */
-#endif /* QAK */
/* Close FCPLs */
ret = H5Pclose(fcpl);