summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5B2cache.c2
-rw-r--r--src/H5B2pkg.h2
-rw-r--r--test/tattr.c83
3 files changed, 86 insertions, 1 deletions
diff --git a/src/H5B2cache.c b/src/H5B2cache.c
index 86592c5..d8679aa 100644
--- a/src/H5B2cache.c
+++ b/src/H5B2cache.c
@@ -647,6 +647,7 @@ H5B2_cache_internal_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr
/* B-tree type */
*p++ = shared->type->id;
+ HDassert((size_t)(p - shared->page) == (H5B2_INT_PREFIX_SIZE - H5B2_SIZEOF_CHKSUM));
/* Serialize records for internal node */
native = internal->int_native;
@@ -982,6 +983,7 @@ H5B2_cache_leaf_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5
/* b-tree type */
*p++ = shared->type->id;
+ HDassert((size_t)(p - shared->page) == (H5B2_LEAF_PREFIX_SIZE - H5B2_SIZEOF_CHKSUM));
/* Serialize records for leaf node */
native = leaf->leaf_native;
diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h
index 3dfbe41..43fab1f 100644
--- a/src/H5B2pkg.h
+++ b/src/H5B2pkg.h
@@ -69,6 +69,7 @@
#define H5B2_METADATA_PREFIX_SIZE ( \
H5B2_SIZEOF_MAGIC /* Signature */ \
+ 1 /* Version */ \
+ + 1 /* Tree type */ \
+ H5B2_SIZEOF_CHKSUM /* Metadata checksum */ \
)
@@ -78,7 +79,6 @@
H5B2_METADATA_PREFIX_SIZE \
\
/* Header specific fields */ \
- + 1 /* Tree type */ \
+ 4 /* Node size, in bytes */ \
+ 2 /* Record size, in bytes */ \
+ 2 /* Depth of tree */ \
diff --git a/test/tattr.c b/test/tattr.c
index 68e21a2..55b3f01 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -129,6 +129,8 @@ float attr_data5=(float)-5.123; /* Test data for 5th attribute */
#define ATTR7_NAME "attr 1 - 000000"
#define ATTR8_NAME "attr 2"
+#define NATTR_MANY 35000
+
/* Attribute iteration struct */
typedef struct {
H5_iter_order_t order; /* Direction of iteration */
@@ -3217,6 +3219,86 @@ test_attr_null_space(hid_t fcpl, hid_t fapl)
/****************************************************************
**
+** test_attr_many(): Test basic H5A (attribute) code.
+** Tests storing lots of attributes
+**
+****************************************************************/
+static void
+test_attr_many(hid_t fcpl, hid_t fapl)
+{
+ hid_t fid; /* HDF5 File ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t aid; /* Attribute ID */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned u; /* Local index variable */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Storing Many Attributes\n"));
+
+ /* Create file */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Create dataspace for attribute */
+ sid = H5Screate(H5S_SCALAR);
+ CHECK(sid, FAIL, "H5Screate");
+
+ /* Create many attributes (on root group) */
+ for(u = 0; u < NATTR_MANY; u++) {
+ sprintf(attrname, "a-%06u", u);
+
+ aid = H5Acreate(fid, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT);
+ CHECK(aid, FAIL, "H5Acreate");
+
+ ret = H5Awrite(aid, H5T_NATIVE_UINT, &u);
+ CHECK(ret, FAIL, "H5Awrite");
+
+ ret = H5Aclose(aid);
+ CHECK(ret, FAIL, "H5Aclose");
+ } /* end for */
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+
+ /* Re-open the file and check on the attributes */
+
+ /* Re-open file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Verify attributes */
+ for(u = 0; u < NATTR_MANY; u++) {
+ unsigned value; /* Attribute value */
+
+ sprintf(attrname, "a-%06u", u);
+
+ aid = H5Aopen_name(fid, attrname);
+ CHECK(aid, FAIL, "H5Aopen_name");
+
+ ret = H5Aread(aid, H5T_NATIVE_UINT, &value);
+ CHECK(ret, FAIL, "H5Aread");
+ VERIFY(value, u, "H5Aread");
+
+ ret = H5Aclose(aid);
+ CHECK(ret, FAIL, "H5Aclose");
+ } /* end for */
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+
+ /* Close dataspaces */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+} /* test_attr_many() */
+
+
+/****************************************************************
+**
** test_attr_corder_create_empty(): Test basic H5A (attribute) code.
** Tests basic code to create objects with attribute creation order info
**
@@ -8238,6 +8320,7 @@ test_attr(void)
test_attr_dense_limits(my_fcpl, my_fapl); /* Test dense attribute storage limits */
test_attr_big(my_fcpl, my_fapl); /* Test storing big attribute */
test_attr_null_space(my_fcpl, my_fapl); /* Test storing attribute with NULL dataspace */
+ test_attr_many(my_fcpl, my_fapl); /* Test storing lots of attributes */
/* Attribute creation order tests */
test_attr_corder_create_basic(my_fcpl, my_fapl);/* Test creating an object w/attribute creation order info */