diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-01-18 14:32:27 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-01-18 14:32:27 (GMT) |
commit | 9155785889af8ae809fb5e9cdbb330710a174d72 (patch) | |
tree | 1aa6540340928a3c5b05bb240540ce6aa48ec6be /test/tattr.c | |
parent | fa11904aabebe64af2d90be3b3203203569e0bcb (diff) | |
download | hdf5-9155785889af8ae809fb5e9cdbb330710a174d72.zip hdf5-9155785889af8ae809fb5e9cdbb330710a174d72.tar.gz hdf5-9155785889af8ae809fb5e9cdbb330710a174d72.tar.bz2 |
[svn-r13152] Description:
Add anotherdense/shared attribute test.
Clean up minor attribute/object header codelets, in preparation for
adding creation index to attributes.
Tested on:
Mac OS X/32 10.4.8 (amazon)
FreeBSD/32 6.2 (duty)
Diffstat (limited to 'test/tattr.c')
-rw-r--r-- | test/tattr.c | 179 |
1 files changed, 118 insertions, 61 deletions
diff --git a/test/tattr.c b/test/tattr.c index 0efe56b..31ffe2c 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); @@ -3372,7 +3371,6 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) ret = H5Sclose(big_sid); CHECK(ret, FAIL, "H5Sclose"); } /* test_attr_shared_rename() */ -#endif /* QAK */ /**************************************************************** ** @@ -3737,7 +3735,6 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Sclose"); } /* test_attr_shared_delete() */ -#ifndef QAK /**************************************************************** ** ** test_attr_shared_unlink(): Test basic H5A (attribute) code. @@ -3751,7 +3748,8 @@ test_attr_shared_unlink(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 */ @@ -3761,6 +3759,7 @@ 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 */ + 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 */ @@ -3771,6 +3770,17 @@ 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")); + /* 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++) { /* Make copy of file creation property list */ @@ -3782,19 +3792,28 @@ test_attr_shared_unlink(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); @@ -3834,10 +3853,6 @@ test_attr_shared_unlink(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"); @@ -3876,23 +3891,45 @@ test_attr_shared_unlink(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"); + + /* 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"); - /* 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, 1, "H5A_get_shared_rc_test"); + } /* end else */ /* Close attribute */ ret = H5Aclose(attr); @@ -3906,28 +3943,45 @@ test_attr_shared_unlink(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); @@ -3946,10 +4000,6 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) ret = H5Tclose(attr_tid); CHECK(ret, FAIL, "H5Tclose"); - /* Close dataspace */ - ret = H5Sclose(sid); - CHECK(ret, FAIL, "H5Sclose"); - /* Close second dataset */ ret = H5Dclose(dataset2); CHECK(ret, FAIL, "H5Dclose"); @@ -3972,14 +4022,21 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) 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"); + 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); @@ -4019,8 +4076,13 @@ test_attr_shared_unlink(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_unlink() */ -#endif /* QAK */ /**************************************************************** ** @@ -4065,7 +4127,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; @@ -4134,10 +4195,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_delete(fcpl2, fapl2); /* Test deleting shared attributes in compact & dense storage */ -#endif /* QAK */ /* Close FCPLs */ ret = H5Pclose(fcpl); |