diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2006-12-19 01:59:28 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2006-12-19 01:59:28 (GMT) |
commit | 43ec5b7ef4df2d72bcde2da9366d55383b8f40e8 (patch) | |
tree | 705125a1b023c990db69abd82ae878eb90800447 /test/tattr.c | |
parent | 5865018c85449e4b03bb3f5d5e7d7948e110fe17 (diff) | |
download | hdf5-43ec5b7ef4df2d72bcde2da9366d55383b8f40e8.zip hdf5-43ec5b7ef4df2d72bcde2da9366d55383b8f40e8.tar.gz hdf5-43ec5b7ef4df2d72bcde2da9366d55383b8f40e8.tar.bz2 |
[svn-r13074] Description:
Add support for opening attributes in dense and/or shared storage by
index.
Move routines for building and operating on tables of attributes into
separate source module.
Fix bug where reverting from "dense" to "compact" storage would 'unshare'
attributes.
Minor code cleanups, etc.
Tested on:
Linux/32 2.6 (chicago)
Linux/64 2.6 (chicago2)
Diffstat (limited to 'test/tattr.c')
-rw-r--r-- | test/tattr.c | 94 |
1 files changed, 75 insertions, 19 deletions
diff --git a/test/tattr.c b/test/tattr.c index 3e7e73d..5860dae 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -1683,6 +1683,65 @@ test_attr_dtype_shared(hid_t fapl) /**************************************************************** ** +** test_attr_dense_verify(): Test basic H5A (attribute) code. +** Verify attributes on object +** +****************************************************************/ +static void +test_attr_dense_verify(hid_t loc_id, unsigned max_attr) +{ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + hid_t attr; /* Attribute ID */ + unsigned value; /* Attribute value */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic return value */ + + /* Re-open all the attributes by name and verify the data */ + for(u = 0; u < max_attr; u++) { + /* Open attribute */ + sprintf(attrname, "attr %02u", u); + attr = H5Aopen_name(loc_id, attrname); + CHECK(attr, FAIL, "H5Aopen"); + + /* Read data from the attribute */ + ret = H5Aread(attr, H5T_NATIVE_UINT, &value); + CHECK(ret, FAIL, "H5Aread"); + VERIFY(value, u, "H5Aread"); + + /* Close attribute */ + ret = H5Aclose(attr); + CHECK(ret, FAIL, "H5Aclose"); + } /* end for */ + + /* Re-open all the attributes by index and verify the data */ + for(u = 0; u < max_attr; u++) { + size_t name_len; /* Length of attribute name */ + char check_name[ATTR_NAME_LEN]; /* Buffer for checking attribute names */ + + /* Open attribute */ + attr = H5Aopen_idx(loc_id, u); + CHECK(attr, FAIL, "H5Aopen_idx"); + + /* Verify Name */ + sprintf(attrname, "attr %02u", u); + name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, check_name); + VERIFY(name_len, HDstrlen(attrname), "H5Aget_name"); + if(HDstrcmp(check_name, attrname)) + TestErrPrintf("attribute name different: attr_name = '%s', should be '%s'\n", check_name, attrname); + + /* Read data from the attribute */ + ret = H5Aread(attr, H5T_NATIVE_UINT, &value); + CHECK(ret, FAIL, "H5Aread"); + VERIFY(value, u, "H5Aread"); + + /* Close attribute */ + ret = H5Aclose(attr); + CHECK(ret, FAIL, "H5Aclose"); + } /* end for */ +} /* test_attr_dense_verify() */ + +/**************************************************************** +** ** test_attr_dense_create(): Test basic H5A (attribute) code. ** Tests "dense" attribute storage creation ** @@ -1852,6 +1911,9 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense); /* Close attribute */ ret = H5Aclose(attr); CHECK(ret, FAIL, "H5Aclose"); + + /* Verify attributes written so far */ + test_attr_dense_verify(dataset, u); } /* end for */ /* Check on dataset's attribute storage status */ @@ -1880,24 +1942,8 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense); ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); - /* Re-open all the attributes and verify the data */ - for(u = 0; u <= max_compact; u++) { - unsigned value; - - /* Open attribute */ - sprintf(attrname, "attr %02u", u); - attr = H5Aopen_name(dataset, attrname); - CHECK(attr, FAIL, "H5Aopen"); - - /* Read data from the attribute */ - ret = H5Aread(attr, H5T_NATIVE_UINT, &value); - CHECK(ret, FAIL, "H5Aread"); - VERIFY(value, u, "H5Aread"); - - /* Close attribute */ - ret = H5Aclose(attr); - CHECK(ret, FAIL, "H5Aclose"); - } /* end for */ + /* Verify all the attributes written */ + test_attr_dense_verify(dataset, (u + 1)); /* Close Dataset */ ret = H5Dclose(dataset); @@ -1978,7 +2024,7 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense); /* Check # of attributes */ attr_count = H5Aget_num_attrs(dataset); CHECK(attr_count, FAIL, "H5Aget_num_attrs"); - VERIFY(attr_count, (u + 1), "H5Aget_num_attrs"); + VERIFY(attr_count, (int)(u + 1), "H5Aget_num_attrs"); } /* end for */ /* Check on dataset's attribute storage status */ @@ -2012,6 +2058,9 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense); sprintf(attrname, "attr %02u", u); ret = H5Adelete(dataset, attrname); CHECK(ret, FAIL, "H5Adelete"); + + /* Verify attributes still left */ + test_attr_dense_verify(dataset, u); } /* end for */ /* Check on dataset's attribute storage status */ @@ -2023,6 +2072,13 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense); ret = H5Adelete(dataset, attrname); CHECK(ret, FAIL, "H5Adelete"); + /* Check on dataset's attribute storage status */ + is_dense = H5O_is_attr_dense_test(dataset); + VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test"); + + /* Verify attributes still left */ + test_attr_dense_verify(dataset, (u - 1)); + /* Close Dataset */ ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); |