summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/dsets.c26
-rw-r--r--test/links.c351
-rw-r--r--test/tattr.c430
-rw-r--r--test/tsohm.c2044
4 files changed, 1498 insertions, 1353 deletions
diff --git a/test/dsets.c b/test/dsets.c
index 94c967e..092b616 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -13079,14 +13079,14 @@ test_object_header_minimization_dcpl(void)
/* TESTS */
/*********/
- /* TEST default value (not set explicitly)
+ /* default value (not set explicitly)
*/
if (FAIL == H5Pget_dset_no_attrs_hint(dcpl_id, &minimize))
FAIL_PUTS_ERROR("unable to get minimize value\n");
if (FALSE != minimize)
FAIL_PUTS_ERROR("Expected FALSE default but was not!\n");
- /* TEST FALSE-set value
+ /* FALSE-set value
*/
if (FAIL == H5Pset_dset_no_attrs_hint(dcpl_id, FALSE))
FAIL_PUTS_ERROR("unable to set minimize value to FALSE\n");
@@ -13095,7 +13095,7 @@ test_object_header_minimization_dcpl(void)
if (FALSE != minimize)
FAIL_PUTS_ERROR("Expected FALSE default but was not!\n");
- /* TEST TRUE-set value
+ /* TRUE-set value
*/
if (FAIL == H5Pset_dset_no_attrs_hint(dcpl_id, TRUE))
FAIL_PUTS_ERROR("unable to set minimize value to TRUE\n");
@@ -13104,7 +13104,7 @@ test_object_header_minimization_dcpl(void)
if (TRUE != minimize)
FAIL_PUTS_ERROR("Expected TRUE default but was not!\n");
- /* TEST error cases
+ /* error cases
*/
H5E_BEGIN_TRY {
if (SUCCEED == H5Pget_dset_no_attrs_hint(-1, &minimize))
@@ -13163,6 +13163,7 @@ main(void)
hid_t fcpl = -1, fcpl2 = -1;
unsigned new_format;
unsigned paged;
+ unsigned minimized_ohdr;
int mdc_nelmts;
size_t rdcc_nelmts;
size_t rdcc_nbytes;
@@ -13213,10 +13214,12 @@ main(void)
/* Test with paged aggregation enabled or not */
for(paged = FALSE; paged <= TRUE; paged++) {
- /* Temporary: skip testing for multi/split drivers:
- fail file create when persisting free-space or using paged aggregation strategy */
- if(!contig_addr_vfd && paged)
- continue;
+ /* Temporary: skip testing for multi/split drivers:
+ fail file create when persisting free-space or using paged aggregation strategy */
+ if(!contig_addr_vfd && paged)
+ continue;
+
+ for (minimized_ohdr = FALSE; minimized_ohdr <= TRUE; minimized_ohdr++) {
/* Test with old & new format groups */
for(new_format = FALSE; new_format <= TRUE; new_format++) {
@@ -13248,6 +13251,12 @@ main(void)
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, my_fcpl, my_fapl)) < 0)
goto error;
+ if (TRUE == minimized_ohdr) {
+ if (0 > H5Fset_dset_no_attrs_hint(file, TRUE))
+ goto error;
+ puts("(minimized dataset object headers with file setting)");
+ }
+
/* Cause the library to emit initial messages */
if((grp = H5Gcreate2(file, "emit diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto error;
@@ -13325,6 +13334,7 @@ main(void)
if(H5Fclose(file) < 0)
goto error;
} /* end for new_format */
+ } /* for minimized dset object headers */
} /* end for paged */
/* Close property lists */
diff --git a/test/links.c b/test/links.c
index fb2c75a..4d8b810 100644
--- a/test/links.c
+++ b/test/links.c
@@ -315,6 +315,8 @@ typedef struct {
const obj_visit_t *info; /* Pointer to the object visit structure to use */
} ovisit_ud_t;
+static hid_t dcpl_g; /* for [un]minimized dataset object headers */
+
/*-------------------------------------------------------------------------
@@ -377,7 +379,7 @@ mklinks(hid_t fapl, hbool_t new_format)
if(H5Gclose(grp) < 0) TEST_ERROR
/* Create a dataset */
- if((d1 = H5Dcreate2(file, "d1", H5T_NATIVE_INT, scalar, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((d1 = H5Dcreate2(file, "d1", H5T_NATIVE_INT, scalar, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Dclose(d1) < 0) TEST_ERROR
/* Create a hard link */
@@ -451,8 +453,8 @@ new_links(hid_t fapl, hbool_t new_format)
if((grp2_b = H5Gcreate2(file_b, "grp2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
/* Create datasets */
- if((dset1 = H5Dcreate2(file_a, "dataset1", H5T_NATIVE_INT, scalar, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if((dset2 = H5Dcreate2(grp1_a, "dataset2", H5T_NATIVE_INT, scalar, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((dset1 = H5Dcreate2(file_a, "dataset1", H5T_NATIVE_INT, scalar, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((dset2 = H5Dcreate2(grp1_a, "dataset2", H5T_NATIVE_INT, scalar, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR
/* Create links within a file. Both of source and destination use
* H5L_SAME_LOC. Both hard and soft links should fail. */
@@ -1014,7 +1016,7 @@ test_lcpl(hid_t fapl, hbool_t new_format)
if((space_id=H5Screate_simple(2 ,dims, NULL)) < 0) TEST_ERROR
/* Create a dataset using the default LCPL */
- if((dset_id = H5Dcreate2(file_id, "/dataset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((dset_id = H5Dcreate2(file_id, "/dataset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Dclose(dset_id) < 0) TEST_ERROR
/* Check that its character encoding is the default */
@@ -1043,7 +1045,7 @@ test_lcpl(hid_t fapl, hbool_t new_format)
if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR
/* Create a dataset using the new LCPL */
- if((dset_id = H5Dcreate2(file_id, "/dataset2", H5T_NATIVE_INT, space_id, lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((dset_id = H5Dcreate2(file_id, "/dataset2", H5T_NATIVE_INT, space_id, lcpl_id, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Dclose(dset_id) < 0) TEST_ERROR
/* Check that its character encoding is UTF-8 */
@@ -3758,7 +3760,12 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format)
if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR
/* Create dataset creation property list */
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ }
+ if (0 > dcpl) TEST_ERROR;
if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) TEST_ERROR;
/* create "Dataset" in group "A" of target file */
@@ -6100,7 +6107,7 @@ external_link_closing(hid_t fapl, hbool_t new_format)
/* Test creating each kind of object */
if((gid = H5Gcreate2(fid1, "elink/elink/elink/group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Tcommit2(fid1, "elink/elink/elink/type1", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- if((did = H5Dcreate2(fid1, "elink/elink/elink/dataset1", tid2, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((did = H5Dcreate2(fid1, "elink/elink/elink/dataset1", tid2, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR
/* Close objects */
if(H5Gclose(gid) < 0) TEST_ERROR
@@ -7298,7 +7305,7 @@ external_open_twice(hid_t fapl, hbool_t new_format)
if((space = H5Screate(H5S_SCALAR)) < 0)
TEST_ERROR
if((oid1 = H5Dcreate2(fid2, "dset", H5T_NATIVE_INT, space, H5P_DEFAULT,
- H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ dcpl_g, H5P_DEFAULT)) < 0)
TEST_ERROR
if(H5Dclose(oid1) < 0)
TEST_ERROR
@@ -7514,8 +7521,12 @@ external_link_with_committed_datatype(hid_t fapl, hbool_t new_format)
if((sid2 = H5Screate_simple(2, dims, NULL)) < 0)
FAIL_STACK_ERROR
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
- FAIL_STACK_ERROR
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ }
+ if (0 > dcpl) FAIL_STACK_ERROR
if(H5Pset_chunk(dcpl, 2, chunks) < 0)
FAIL_STACK_ERROR
@@ -9058,7 +9069,7 @@ lapl_nlinks(hid_t fapl, hbool_t new_format)
dims[0] = 2;
dims[1] = 2;
if((sid = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR
- if((did = H5Dcreate2(gid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((did = H5Dcreate2(gid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Dclose(did) < 0) TEST_ERROR
/* Close group */
@@ -9170,7 +9181,7 @@ linkinfo(hid_t fapl, hbool_t new_format)
if(H5Lcreate_soft("group", fid, "softlink", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
if((sid = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR
- if((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_PLIST_TYPE, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
if(H5Lcreate_external("file_name", "obj_path", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
@@ -9335,13 +9346,13 @@ build_visit_file(hid_t fapl)
/* Create dataset in each group */
if((sid = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR
- if((did = H5Dcreate2(fid, "/Dataset_zero", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((did = H5Dcreate2(fid, "/Dataset_zero", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Dclose(did) < 0) TEST_ERROR
- if((did = H5Dcreate2(fid, "/Group1/Dataset_one", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((did = H5Dcreate2(fid, "/Group1/Dataset_one", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Dclose(did) < 0) TEST_ERROR
- if((did = H5Dcreate2(fid, "/Group1/Group2/Dataset_two", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((did = H5Dcreate2(fid, "/Group1/Group2/Dataset_two", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Dclose(did) < 0) TEST_ERROR
if(H5Sclose(sid) < 0) TEST_ERROR
@@ -14890,6 +14901,7 @@ main(void)
hid_t fapl, fapl2; /* File access property lists */
int nerrors = 0;
unsigned new_format; /* Whether to use the new format or not */
+ unsigned minimize_dset_oh;
unsigned efc; /* Whether to use the external file cache */
const char *env_h5_drvr; /* File Driver value from environment */
@@ -14900,165 +14912,184 @@ main(void)
h5_reset();
fapl = h5_fileaccess();
- /* Copy the file access property list */
+ /* fapl2 uses "latest version bounds" */
if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
-
- /* Set the "use the latest version of the format" bounds for creating objects in the file */
if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR
- /* Loop over using new group format */
- for(new_format = FALSE; new_format <= TRUE; new_format++) {
- hid_t my_fapl;
+ for (minimize_dset_oh = 0; minimize_dset_oh <= 1; minimize_dset_oh++) {
+ if (minimize_dset_oh) {
+ printf("\n-Testing with minimzed dataset object headers-\n");
+ dcpl_g = H5Pcreate(H5P_DATASET_CREATE);
+ if (0 > dcpl_g) TEST_ERROR
+ } else {
+ printf("\n-Testing with unminimzed dataset object headers-\n");
+ dcpl_g = H5P_DEFAULT;
+ }
- /* Check for FAPL to use */
- if(new_format)
- my_fapl = fapl2;
- else
- my_fapl = fapl;
-
- /* General tests... (on both old & new format groups */
- nerrors += mklinks(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += cklinks(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += new_links(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += ck_new_links(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += long_links(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += toomany(my_fapl, new_format) < 0 ? 1 : 0;
-
- /* Test new H5L link creation routine */
- nerrors += test_lcpl(my_fapl, new_format);
- nerrors += test_move(my_fapl, new_format);
- nerrors += test_copy(my_fapl, new_format);
- nerrors += test_move_preserves(my_fapl, new_format);
+ for(new_format = FALSE; new_format <= TRUE; new_format++) {
+ hid_t my_fapl;
+
+ /* Check for FAPL to use */
+ if(new_format) {
+ my_fapl = fapl2;
+ printf("\n--Testing with 'new format'--\n");
+ } else {
+ my_fapl = fapl;
+ printf("\n--Testing with 'old format'--\n");
+ }
+
+ /* always enter tests without external cache */
+ if(H5Pset_elink_file_cache_size(my_fapl, 0) < 0) TEST_ERROR
+
+ /* General tests... (on both old & new format groups */
+ nerrors += mklinks(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += cklinks(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += new_links(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += ck_new_links(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += long_links(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += toomany(my_fapl, new_format) < 0 ? 1 : 0;
+
+ /* Test new H5L link creation routine */
+ nerrors += test_lcpl(my_fapl, new_format);
+ nerrors += test_move(my_fapl, new_format);
+ nerrors += test_copy(my_fapl, new_format);
+ nerrors += test_move_preserves(my_fapl, new_format);
#ifndef H5_NO_DEPRECATED_SYMBOLS
- nerrors += test_deprec(my_fapl, new_format);
+ nerrors += test_deprec(my_fapl, new_format);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
- /* tests for external link */
- /* Test external file cache first, so it sees the default efc setting on
- * the fapl */
- nerrors += external_file_cache(my_fapl, new_format) < 0 ? 1 : 0;
-
- /* This test cannot run with the EFC because it assumes that an
- * intermediate file is not held open */
- nerrors += external_link_mult(my_fapl, new_format) < 0 ? 1 : 0;
-
- /* This test cannot run with the EFC because the EFC cannot currently
- * reopen a cached file with a different intent */
- nerrors += external_set_elink_acc_flags(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0;
-
- /* Try external link tests both with and without the external file cache
- */
- for(efc = FALSE; efc <= TRUE; efc++) {
- if(efc) {
- if(H5Pset_elink_file_cache_size(my_fapl, 8) < 0)
- TEST_ERROR
- printf("\n---Testing with external file cache---\n");
- } /* end if */
- else {
- if(H5Pset_elink_file_cache_size(my_fapl, 0) < 0)
- TEST_ERROR
- printf("\n---Testing without external file cache---\n");
- } /* end else */
+ /* tests for external link */
+ /* Test external file cache first, so it sees the default efc setting on
+ * the fapl */
+ nerrors += external_file_cache(my_fapl, new_format) < 0 ? 1 : 0;
+
+ /* This test cannot run with the EFC because it assumes that an
+ * intermediate file is not held open */
+ nerrors += external_link_mult(my_fapl, new_format) < 0 ? 1 : 0;
+
+ /* This test cannot run with the EFC because the EFC cannot currently
+ * reopen a cached file with a different intent */
+ nerrors += external_set_elink_acc_flags(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0;
+
+ /* Try external link tests both with and without the external file cache
+ */
+ for(efc = FALSE; efc <= TRUE; efc++) {
+ if(efc) {
+ if(H5Pset_elink_file_cache_size(my_fapl, 8) < 0)
+ TEST_ERROR
+ printf("\n---Testing with external file cache---\n");
+ } /* end if */
+ else {
+ if(H5Pset_elink_file_cache_size(my_fapl, 0) < 0)
+ TEST_ERROR
+ printf("\n---Testing without external file cache---\n");
+ } /* end else */
- nerrors += external_link_root(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_path(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_self(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_pingpong(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_toomany(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_dangling(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_recursive(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_query(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_unlink_compact(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_unlink_dense(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_move(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_ride(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_closing(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_endian(new_format) < 0 ? 1 : 0;
- nerrors += external_link_strong(my_fapl, new_format) < 0 ? 1 : 0;
-
- nerrors += external_link_prefix(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_abs_mainpath(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_rel_mainpath(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_cwd(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_abstar(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_abstar_cur(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_reltar(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_chdir(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_set_elink_fapl1(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_set_elink_fapl2(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_set_elink_fapl3(new_format) < 0 ? 1 : 0;
- nerrors += external_set_elink_cb(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_root(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_path(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_self(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_pingpong(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_toomany(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_dangling(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_recursive(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_query(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_unlink_compact(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_unlink_dense(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_move(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_ride(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_closing(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_endian(new_format) < 0 ? 1 : 0;
+ nerrors += external_link_strong(my_fapl, new_format) < 0 ? 1 : 0;
+
+ nerrors += external_link_prefix(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_abs_mainpath(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_rel_mainpath(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_cwd(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_abstar(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_abstar_cur(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_reltar(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_chdir(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_set_elink_fapl1(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_set_elink_fapl2(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_set_elink_fapl3(new_format) < 0 ? 1 : 0;
+ nerrors += external_set_elink_cb(my_fapl, new_format) < 0 ? 1 : 0;
#ifdef H5_HAVE_WINDOW_PATH
- nerrors += external_link_win1(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_win2(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_win3(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_win4(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_win5(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_win6(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_win7(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_win8(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_win9(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_win1(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_win2(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_win3(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_win4(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_win5(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_win6(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_win7(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_win8(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_win9(my_fapl, new_format) < 0 ? 1 : 0;
#endif
- nerrors += external_symlink(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_copy_invalid_object(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_dont_fail_to_source(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_open_twice(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_with_committed_datatype(my_fapl, new_format) < 0 ? 1 : 0;
- } /* end for */
-
- /* These tests assume that external links are a form of UD links,
- * so assume that everything that passed for external links
- * above has already been tested for UD links.
- */
- if(new_format == TRUE) {
- nerrors += ud_hard_links(fapl2) < 0 ? 1 : 0; /* requires new format groups */
- nerrors += ud_link_reregister(fapl2) < 0 ? 1 : 0; /* requires new format groups */
- } /* end if */
- nerrors += ud_callbacks(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += ud_link_errors(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += lapl_udata(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += lapl_nlinks(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += linkinfo(my_fapl, new_format) < 0 ? 1 : 0;
-
- /* Misc. extra tests, useful for both new & old format files */
- nerrors += link_visit(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += link_visit_by_name(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += obj_visit(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += obj_visit_by_name(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += obj_visit_stop(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += link_filters(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += obj_exists(my_fapl, new_format) < 0 ? 1 : 0;
-
- /* Keep this test last, it's testing files that are used above */
- /* do not do this for files used by external link tests */
- nerrors += check_all_closed(my_fapl, new_format, EXTSTOP) < 0 ? 1 : 0;
- } /* end for */
-
- /* New group revision feature tests */
- nerrors += corder_create_empty(fapl2) < 0 ? 1 : 0;
+ nerrors += external_symlink(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_copy_invalid_object(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_dont_fail_to_source(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_open_twice(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_with_committed_datatype(my_fapl, new_format) < 0 ? 1 : 0;
+ } /* with/without external file cache */
+
+ /* These tests assume that external links are a form of UD links,
+ * so assume that everything that passed for external links
+ * above has already been tested for UD links.
+ */
+ if(new_format == TRUE) {
+ nerrors += ud_hard_links(fapl2) < 0 ? 1 : 0; /* requires new format groups */
+ nerrors += ud_link_reregister(fapl2) < 0 ? 1 : 0; /* requires new format groups */
+ } /* end if */
+ nerrors += ud_callbacks(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += ud_link_errors(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += lapl_udata(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += lapl_nlinks(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += linkinfo(my_fapl, new_format) < 0 ? 1 : 0;
+
+ /* Misc. extra tests, useful for both new & old format files */
+ nerrors += link_visit(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += link_visit_by_name(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += obj_visit(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += obj_visit_by_name(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += obj_visit_stop(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += link_filters(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += obj_exists(my_fapl, new_format) < 0 ? 1 : 0;
+
+ /* Keep this test last, it's testing files that are used above */
+ /* do not do this for files used by external link tests */
+ nerrors += check_all_closed(my_fapl, new_format, EXTSTOP) < 0 ? 1 : 0;
+ } /* new/old format */
+
+ /* New group revision feature tests */
+ nerrors += corder_create_empty(fapl2) < 0 ? 1 : 0;
/* XXX: when creation order indexing is fully working, go back and add checks
* to these tests to make certain that the creation order values are
* correct.
*/
- nerrors += corder_create_compact(fapl2) < 0 ? 1 : 0;
- nerrors += corder_create_dense(fapl2) < 0 ? 1 : 0;
- nerrors += corder_transition(fapl2) < 0 ? 1 : 0;
- nerrors += corder_delete(fapl2) < 0 ? 1 : 0;
- nerrors += link_info_by_idx(fapl2) < 0 ? 1 : 0;
- nerrors += delete_by_idx(fapl2) < 0 ? 1 : 0;
- nerrors += link_iterate(fapl2) < 0 ? 1 : 0;
- nerrors += open_by_idx(fapl2) < 0 ? 1 : 0;
- nerrors += object_info(fapl2) < 0 ? 1 : 0;
- nerrors += group_info(fapl2) < 0 ? 1 : 0;
- nerrors += timestamps(fapl2) < 0 ? 1 : 0;
-
- /* Test new API calls on old-style groups */
- nerrors += link_info_by_idx_old(fapl) < 0 ? 1 : 0;
- nerrors += delete_by_idx_old(fapl) < 0 ? 1 : 0;
- nerrors += link_iterate_old(fapl) < 0 ? 1 : 0;
- nerrors += open_by_idx_old(fapl) < 0 ? 1 : 0;
- nerrors += object_info_old(fapl) < 0 ? 1 : 0;
- nerrors += group_info_old(fapl) < 0 ? 1 : 0;
+ nerrors += corder_create_compact(fapl2) < 0 ? 1 : 0;
+ nerrors += corder_create_dense(fapl2) < 0 ? 1 : 0;
+ nerrors += corder_transition(fapl2) < 0 ? 1 : 0;
+ nerrors += corder_delete(fapl2) < 0 ? 1 : 0;
+ nerrors += link_info_by_idx(fapl2) < 0 ? 1 : 0;
+ nerrors += delete_by_idx(fapl2) < 0 ? 1 : 0;
+ nerrors += link_iterate(fapl2) < 0 ? 1 : 0;
+ nerrors += open_by_idx(fapl2) < 0 ? 1 : 0;
+ nerrors += object_info(fapl2) < 0 ? 1 : 0;
+ nerrors += group_info(fapl2) < 0 ? 1 : 0;
+ nerrors += timestamps(fapl2) < 0 ? 1 : 0;
+
+ /* Test new API calls on old-style groups */
+ nerrors += link_info_by_idx_old(fapl) < 0 ? 1 : 0;
+ nerrors += delete_by_idx_old(fapl) < 0 ? 1 : 0;
+ nerrors += link_iterate_old(fapl) < 0 ? 1 : 0;
+ nerrors += open_by_idx_old(fapl) < 0 ? 1 : 0;
+ nerrors += object_info_old(fapl) < 0 ? 1 : 0;
+ nerrors += group_info_old(fapl) < 0 ? 1 : 0;
+
+ if (minimize_dset_oh) {
+ if (0 > H5Pclose(dcpl_g)) TEST_ERROR;
+ dcpl_g = -1;
+ }
+ } /* [un]minimized dataset object headers */
/* Close 2nd FAPL */
H5Pclose(fapl2);
diff --git a/test/tattr.c b/test/tattr.c
index 4358d4c..75768b9 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -157,6 +157,8 @@ typedef struct {
static herr_t attr_op1(hid_t loc_id, const char *name, const H5A_info_t *ainfo,
void *op_data);
+static hid_t dcpl_g = H5P_DEFAULT;
+
/****************************************************************
@@ -196,7 +198,7 @@ test_attr_basic_write(hid_t fapl)
CHECK(sid1, FAIL, "H5Screate_simple");
/* Create a dataset */
- dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
/* Create dataspace for attribute */
@@ -516,7 +518,7 @@ test_attr_flush(hid_t fapl)
spc = H5Screate(H5S_SCALAR);
CHECK(spc, FAIL, "H5Screate");
- set = H5Dcreate2(fil, DSET1_NAME, H5T_NATIVE_DOUBLE, spc, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ set = H5Dcreate2(fil, DSET1_NAME, H5T_NATIVE_DOUBLE, spc, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(set, FAIL, "H5Dcreate2");
att = H5Acreate2(set, ATTR1_NAME, H5T_NATIVE_DOUBLE, spc, H5P_DEFAULT, H5P_DEFAULT);
@@ -587,7 +589,7 @@ test_attr_plist(hid_t fapl)
CHECK(sid1, FAIL, "H5Screate_simple");
/* Create a dataset */
- dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
/* Create dataspace for attribute */
@@ -701,7 +703,7 @@ test_attr_compound_write(hid_t fapl)
CHECK(sid1, FAIL, "H5Screate_simple");
/* Create a dataset */
- dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
/* Close dataset's dataspace */
@@ -937,7 +939,7 @@ test_attr_scalar_write(hid_t fapl)
CHECK(sid1, FAIL, "H5Screate_simple");
/* Create a dataset */
- dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
/* Create dataspace for attribute */
@@ -1078,7 +1080,7 @@ test_attr_mult_write(hid_t fapl)
CHECK(sid1, FAIL, "H5Screate_simple");
/* Create a dataset */
- dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
/* Close dataset's dataspace */
@@ -1456,7 +1458,7 @@ test_attr_iterate(hid_t fapl)
CHECK(sid, FAIL, "H5Screate");
/* Create a new dataset */
- dataset = H5Dcreate2(file, DSET2_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(file, DSET2_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
/* Close dataspace */
@@ -1681,7 +1683,7 @@ test_attr_dtype_shared(hid_t fapl)
CHECK(space_id, FAIL, "H5Screate");
/* Create dataset */
- dset_id = H5Dcreate2(file_id, DSET1_NAME, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dset_id = H5Dcreate2(file_id, DSET1_NAME, type_id, space_id, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(dset_id, FAIL, "H5Dcreate2");
/* Check reference count on named datatype */
@@ -1835,7 +1837,7 @@ test_attr_duplicate_ids(hid_t fapl)
/* Create a dataset */
dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT,
- H5P_DEFAULT, H5P_DEFAULT);
+ dcpl_g, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
/* Create dataspace for attribute */
@@ -2160,9 +2162,14 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl)
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
- /* Query the group creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ /* need DCPL to query the group creation properties */
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Create a dataset */
dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
@@ -2291,9 +2298,14 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl)
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
- /* Query the group creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ /* need DCPL to query the group creation properties */
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Enable creation order tracking on attributes, so creation order tests work */
ret = H5Pset_attr_creation_order(dcpl, H5P_CRT_ORDER_TRACKED);
@@ -2431,9 +2443,14 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
- /* Query the group creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ /* need DCPL to query the group creation properties */
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Enable creation order tracking on attributes, so creation order tests work */
ret = H5Pset_attr_creation_order(dcpl, H5P_CRT_ORDER_TRACKED);
@@ -2610,9 +2627,14 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
- /* Query the group creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ /* need DCPL to query the group creation properties */
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Create a dataset */
dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
@@ -2769,9 +2791,14 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl)
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
- /* Query the group creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ /* need DCPL to query the group creation properties */
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Create a dataset */
dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
@@ -2897,9 +2924,14 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl)
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
- /* Query the group creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ /* need DCPL to query the group creation properties */
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Change limits on compact/dense attribute storage */
max_compact = 0;
@@ -3064,9 +3096,14 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
- /* Query the group creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ /* need DCPL to query the group creation properties */
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Create a dataset */
dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
@@ -3594,9 +3631,14 @@ test_attr_big(hid_t fcpl, hid_t fapl)
big_sid = H5Screate_simple(ATTR6_RANK, dims, NULL);
CHECK(big_sid, FAIL, "H5Screate_simple");
- /* Query the group creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ /* need DCPL to query the group creation properties */
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Retrieve limits for compact/dense attribute storage */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
@@ -3861,7 +3903,7 @@ test_attr_null_space(hid_t fcpl, hid_t fapl)
CHECK(null_sid, FAIL, "H5Screate");
/* Create a dataset */
- dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
@@ -4054,7 +4096,7 @@ test_attr_deprec(hid_t fcpl, hid_t fapl)
CHECK(sid, FAIL, "H5Screate");
/* Create a dataset */
- dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
@@ -4290,8 +4332,13 @@ test_attr_corder_create_basic(hid_t fcpl, hid_t fapl)
CHECK(fid, FAIL, "H5Fcreate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Get creation order indexing on object */
ret = H5Pget_attr_creation_order(dcpl, &crt_order_flags);
@@ -4413,8 +4460,13 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl)
CHECK(fid, FAIL, "H5Fcreate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Set attribute creation order tracking & indexing for object */
ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED));
@@ -4613,8 +4665,13 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl)
CHECK(fid, FAIL, "H5Fcreate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Set attribute creation order tracking & indexing for object */
ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED));
@@ -4948,8 +5005,13 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
CHECK(fid, FAIL, "H5Fcreate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Set attribute creation order tracking & indexing for object */
ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED));
@@ -5359,8 +5421,13 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl)
CHECK(sid, FAIL, "H5Screate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Set attribute creation order tracking & indexing for object */
ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED));
@@ -5702,8 +5769,13 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(sid, FAIL, "H5Screate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Query the attribute creation properties */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
@@ -5914,8 +5986,13 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(sid, FAIL, "H5Screate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Query the attribute creation properties */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
@@ -6857,8 +6934,13 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(sid, FAIL, "H5Screate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Query the attribute creation properties */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
@@ -7218,8 +7300,13 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(sid, FAIL, "H5Screate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Query the attribute creation properties */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
@@ -7565,8 +7652,13 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(sid, FAIL, "H5Screate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Query the attribute creation properties */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
@@ -7819,8 +7911,13 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(sid, FAIL, "H5Screate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Query the attribute creation properties */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
@@ -8120,8 +8217,13 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
} /* end if */
/* Set up to query the object creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Create datasets */
dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
@@ -8451,8 +8553,13 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
} /* end if */
/* Set up to query the object creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Create datasets */
dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
@@ -8897,8 +9004,13 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
} /* end if */
/* Set up to query the object creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Create datasets */
dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
@@ -9266,8 +9378,13 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
} /* end if */
/* Set up to query the object creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ } else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Create datasets */
dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
@@ -9858,7 +9975,7 @@ test_attr_bug3(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Tcommit2");
/* Create dataset */
- did = H5Dcreate2(fid, "dset", tid2, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ did = H5Dcreate2(fid, "dset", tid2, sid2, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(did, FAIL, "H5Dcreate2");
/* Create attribute on datatype, using that datatype as its datatype */
@@ -9993,7 +10110,7 @@ test_attr_bug4(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Tcommit2");
/* Create dataset */
- did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(did, FAIL, "H5Dcreate2");
/* Create attributes on group and dataset */
@@ -10075,7 +10192,7 @@ test_attr_bug5(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Tcommit2");
/* Create dataset */
- did1 = H5Dcreate2(fid1, BUG3_DSET_NAME, tid1, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ did1 = H5Dcreate2(fid1, BUG3_DSET_NAME, tid1, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(did1, FAIL, "H5Dcreate2");
/* Create attribute on root group */
@@ -10773,52 +10890,58 @@ test_attr(void)
{
hid_t fapl = (-1), fapl2 = (-1); /* File access property lists */
hid_t fcpl = (-1), fcpl2 = (-1); /* File creation property lists */
- unsigned new_format; /* Whether to use the new format or not */
- unsigned use_shared; /* Whether to use shared attributes or not */
- herr_t ret; /* Generic return value */
+ hid_t dcpl = -1;
+ unsigned new_format; /* Whether to use the new format or not */
+ unsigned use_shared; /* Whether to use shared attributes or not */
+ unsigned minimize_dset_oh; /* Whether to use minimized dataset object headers */
+ herr_t ret; /* Generic return value */
- /* Output message about test being performed */
MESSAGE(5, ("Testing Attributes\n"));
- /* Create a default file access property list */
fapl = H5Pcreate(H5P_FILE_ACCESS);
CHECK(fapl, FAIL, "H5Pcreate");
- /* Copy the file access property list */
fapl2 = H5Pcopy(fapl);
CHECK(fapl2, FAIL, "H5Pcopy");
-
- /* Set the "use the latest version of the format" bounds for creating objects in the file */
ret = H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
CHECK(ret, FAIL, "H5Pset_libver_bounds");
- /* Create a default file creation property list */
fcpl = H5Pcreate(H5P_FILE_CREATE);
CHECK(fcpl, FAIL, "H5Pcreate");
- /* Copy the file creation property list */
+ /* files with fcpl2 make all attributes ( > 1 byte) shared
+ * (i.e. all of them :-) */
fcpl2 = H5Pcopy(fcpl);
CHECK(fcpl2, FAIL, "H5Pcopy");
-
- /* Make attributes > 1 byte shared (i.e. all of them :-) */
ret = H5Pset_shared_mesg_nindexes(fcpl2, (unsigned)1);
CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
ret = H5Pset_shared_mesg_index(fcpl2, (unsigned)0, H5O_SHMESG_ATTR_FLAG, (unsigned)1);
CHECK_I(ret, "H5Pset_shared_mesg_index");
- /* Loop over using new group format */
+ for(minimize_dset_oh = 0; minimize_dset_oh <= 1; minimize_dset_oh++) {
+ if (minimize_dset_oh == 0) {
+ MESSAGE(7, ("testing with default dataset object headers\n"));
+ dcpl_g = H5P_DEFAULT;
+ } else {
+ MESSAGE(7, ("testing with minimzied dataset object headers\n"));
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ ret = H5Pset_dset_no_attrs_hint(dcpl, TRUE);
+ CHECK_I(ret, "H5Pset_dset_no_attrs_hint");
+
+ dcpl_g = dcpl;
+ }
+
for(new_format = FALSE; new_format <= TRUE; new_format++) {
hid_t my_fapl;
- /* Set the FAPL for the type of format */
if(new_format) {
MESSAGE(7, ("testing with new file format\n"));
my_fapl = fapl2;
- } /* end if */
- else {
+ } else {
MESSAGE(7, ("testing with old file format\n"));
my_fapl = fapl;
- } /* end else */
+ }
/* These next two tests use the same file information */
test_attr_basic_write(my_fapl); /* Test basic H5A writing code */
@@ -10848,22 +10971,48 @@ test_attr(void)
/* This next test uses its own file information */
test_attr_duplicate_ids(my_fapl);
- /* Tests on "new format" attribute storage */
- if(new_format == TRUE) {
- /* Loop over using shared attributes */
- for(use_shared = FALSE; use_shared <= TRUE; use_shared++) {
- hid_t my_fcpl;
-
- /* Set the FCPL for shared or not */
- if(use_shared) {
- MESSAGE(7, ("testing with shared attributes\n"));
- my_fcpl = fcpl2;
- } /* end if */
- else {
- MESSAGE(7, ("testing without shared attributes\n"));
- my_fcpl = fcpl;
- } /* end else */
-
+ for(use_shared = FALSE; use_shared <= TRUE; use_shared++) {
+ hid_t my_fcpl;
+
+ if(new_format == TRUE && use_shared) {
+ MESSAGE(7, ("testing with shared attributes\n"));
+ my_fcpl = fcpl2;
+ } else {
+ MESSAGE(7, ("testing without shared attributes\n"));
+ my_fcpl = fcpl;
+ }
+
+ 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_deprec(fcpl, my_fapl); /* Test deprecated API routines */
+ test_attr_many(new_format, my_fcpl, my_fapl); /* Test storing lots of attributes */
+
+ /* New attribute API routine tests
+ */
+ test_attr_info_by_idx(new_format, my_fcpl, my_fapl); /* Test querying attribute info by index */
+ test_attr_delete_by_idx(new_format, my_fcpl, my_fapl); /* Test deleting attribute by index */
+ test_attr_iterate2(new_format, my_fcpl, my_fapl); /* Test iterating over attributes by index */
+ test_attr_open_by_idx(new_format, my_fcpl, my_fapl); /* Test opening attributes by index */
+ test_attr_open_by_name(new_format, my_fcpl, my_fapl); /* Test opening attributes by name */
+ test_attr_create_by_name(new_format, my_fcpl, my_fapl); /* Test creating attributes by name */
+
+ /* Tests that address specific bugs
+ */
+ test_attr_bug1(my_fcpl, my_fapl); /* Test odd allocation operations */
+ test_attr_bug2(my_fcpl, my_fapl); /* Test many deleted attributes */
+ test_attr_bug3(my_fcpl, my_fapl); /* Test "self referential" attributes */
+ test_attr_bug4(my_fcpl, my_fapl); /* Test attributes on named datatypes */
+ test_attr_bug5(my_fcpl, my_fapl); /* Test opening/closing attributes through different file handles */
+ test_attr_bug6(my_fcpl, my_fapl); /* Test reading empty attribute */
+ /* test_attr_bug7 is specific to the "new" object header format,
+ * and in fact fails if used with the old format due to the
+ * attributes being larger than 64K */
+ test_attr_bug8(my_fcpl, my_fapl); /* Test attribute expanding object header with undecoded messages */
+ test_attr_bug9(my_fcpl, my_fapl); /* Test large attributes converting to dense storage */
+
+ /* tests specific to the "new format"
+ */
+ if (new_format == TRUE) {
/* General attribute tests */
test_attr_dense_create(my_fcpl, my_fapl); /* Test dense attribute storage creation */
test_attr_dense_open(my_fcpl, my_fapl); /* Test opening attributes in dense storage */
@@ -10873,12 +11022,8 @@ test_attr(void)
test_attr_dense_limits(my_fcpl, my_fapl); /* Test dense attribute storage limits */
test_attr_dense_dup_ids(my_fcpl, my_fapl); /* Test duplicated IDs for dense attribute storage */
- 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_deprec(fcpl, my_fapl); /* Test deprecated API routines */
- test_attr_many(new_format, my_fcpl, my_fapl); /* Test storing lots of attributes */
-
- /* Attribute creation order tests */
+ /* Attribute creation order tests
+ */
test_attr_corder_create_basic(my_fcpl, my_fapl);/* Test creating an object w/attribute creation order info */
test_attr_corder_create_compact(my_fcpl, my_fapl); /* Test compact attribute storage on an object w/attribute creation order info */
test_attr_corder_create_dense(my_fcpl, my_fapl);/* Test dense attribute storage on an object w/attribute creation order info */
@@ -10886,64 +11031,33 @@ test_attr(void)
test_attr_corder_transition(my_fcpl, my_fapl); /* Test attribute storage transitions on an object w/attribute creation order info */
test_attr_corder_delete(my_fcpl, my_fapl); /* Test deleting object using dense storage w/attribute creation order info */
- /* New attribute API routine tests */
- test_attr_info_by_idx(new_format, my_fcpl, my_fapl); /* Test querying attribute info by index */
- test_attr_delete_by_idx(new_format, my_fcpl, my_fapl); /* Test deleting attribute by index */
- test_attr_iterate2(new_format, my_fcpl, my_fapl); /* Test iterating over attributes by index */
- test_attr_open_by_idx(new_format, my_fcpl, my_fapl); /* Test opening attributes by index */
- test_attr_open_by_name(new_format, my_fcpl, my_fapl); /* Test opening attributes by name */
- test_attr_create_by_name(new_format, my_fcpl, my_fapl); /* Test creating attributes by name */
-
- /* More complex tests with both "new format" and "shared" attributes */
+ /* More complex tests with exclusively both "new format" and "shared" attributes
+ */
if(use_shared == TRUE) {
test_attr_shared_write(my_fcpl, my_fapl); /* Test writing to shared attributes in compact & dense storage */
test_attr_shared_rename(my_fcpl, my_fapl); /* Test renaming shared attributes in compact & dense storage */
test_attr_shared_delete(my_fcpl, my_fapl); /* Test deleting shared attributes in compact & dense storage */
test_attr_shared_unlink(my_fcpl, my_fapl); /* Test unlinking object with shared attributes in compact & dense storage */
- } /* end if */
+ } /* if using shared attributes */
+
+ test_attr_delete_last_dense(my_fcpl, my_fapl);
- /* Tests that address specific bugs */
- test_attr_bug1(my_fcpl, my_fapl); /* Test odd allocation operations */
- test_attr_bug2(my_fcpl, my_fapl); /* Test many deleted attributes */
- test_attr_bug3(my_fcpl, my_fapl); /* Test "self referential" attributes */
- test_attr_bug4(my_fcpl, my_fapl); /* Test attributes on named datatypes */
- test_attr_bug5(my_fcpl, my_fapl); /* Test opening/closing attributes through different file handles */
- test_attr_bug6(my_fcpl, my_fapl); /* Test reading empty attribute */
+ /* test_attr_bug7 is specific to the "new" object header format,
+ * and in fact fails if used with the old format due to the
+ * attributes being larger than 64K */
test_attr_bug7(my_fcpl, my_fapl); /* Test creating and deleting large attributes in ohdr chunk 0 */
- test_attr_bug8(my_fcpl, my_fapl); /* Test attribute expanding object header with undecoded messages */
- test_attr_bug9(my_fcpl, my_fapl); /* Test large attributes converting to dense storage */
- test_attr_delete_last_dense(my_fcpl, my_fapl); /* Test */
- } /* end for */
- } /* end if */
- else {
- /* General attribute tests */
- test_attr_big(fcpl, my_fapl); /* Test storing big attribute */
- test_attr_null_space(fcpl, my_fapl); /* Test storing attribute with NULL dataspace */
- test_attr_deprec(fcpl, my_fapl); /* Test deprecated API routines */
- test_attr_many(new_format, fcpl, my_fapl); /* Test storing lots of attributes */
-
- /* New attribute API routine tests, on old-format storage */
- test_attr_info_by_idx(new_format, fcpl, my_fapl); /* Test querying attribute info by index */
- test_attr_delete_by_idx(new_format, fcpl, my_fapl); /* Test deleting attribute by index */
- test_attr_iterate2(new_format, fcpl, my_fapl); /* Test iterating over attributes by index */
- test_attr_open_by_idx(new_format, fcpl, my_fapl); /* Test opening attributes by index */
- test_attr_open_by_name(new_format, fcpl, my_fapl); /* Test opening attributes by name */
- test_attr_create_by_name(new_format, fcpl, my_fapl); /* Test creating attributes by name */
-
- /* Tests that address specific bugs */
- test_attr_bug1(fcpl, my_fapl); /* Test odd allocation operations */
- test_attr_bug2(fcpl, my_fapl); /* Test many deleted attributes */
- test_attr_bug3(fcpl, my_fapl); /* Test "self referential" attributes */
- test_attr_bug4(fcpl, my_fapl); /* Test attributes on named datatypes */
- test_attr_bug5(fcpl, my_fapl); /* Test opening/closing attributes through different file handles */
- test_attr_bug6(fcpl, my_fapl); /* Test reading empty attribute */
- /* Skip test_attr_bug7 because it is specific to the new object
- * header format and in fact fails if used with the old format, due
- * to the attributes being larger than 64K */
- test_attr_bug8(fcpl, my_fapl); /* Test attribute expanding object header with undecoded messages */
- test_attr_bug9(fcpl, my_fapl); /* Test large attributes converting to dense storage */
- } /* end else */
- } /* end for */
+
+ } /* if using "new format" */
+ } /* for unshared/shared attributes */
+ } /* for old/new format */
+
+ if (minimize_dset_oh != 0) {
+ ret = H5Pclose(dcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ dcpl_g = H5P_DEFAULT;
+ }
+
+ } /* for default/minimized dataset object headers */
/* Close FCPLs */
ret = H5Pclose(fcpl);
diff --git a/test/tsohm.c b/test/tsohm.c
index d00a03a..388cd4a 100644
--- a/test/tsohm.c
+++ b/test/tsohm.c
@@ -13,7 +13,7 @@
/***********************************************************
*
-* Test program: tsohm
+* Test program: tsohm
*
* Test Shared Object Header Messages
*
@@ -25,9 +25,9 @@
* This file needs to access private information from the H5F package.
* This file also needs to access the file testing code.
*/
-#define H5F_FRIEND /*suppress error about including H5Fpkg */
+#define H5F_FRIEND /* suppress error about including H5Fpkg */
#define H5F_TESTING
-#include "H5Fpkg.h" /* File access */
+#include "H5Fpkg.h" /* File access */
/* Default SOHM values */
#define DEF_NUM_INDEXES 0
@@ -178,40 +178,45 @@ static void test_sohm_extlink(void);
/****************************************************************
**
-** check_fcpl_values(): Helper function for test_sohm_fcpl.
-** Verifies that the *_in and *_out parameters are equal.
+** verify_fcpl_values(): Verifies that FCPL is set as expected.
**
****************************************************************/
-static void check_fcpl_values(hid_t fcpl_id, const unsigned nindexes_in,
- const unsigned *flags_in, const unsigned *minsizes_in,
- unsigned l2b, unsigned b2l)
+static void
+verify_fcpl_values(
+ hid_t fcpl_id,
+ const unsigned nindexes_expected,
+ const unsigned *flags_expected,
+ const unsigned *minsizes_expected,
+ unsigned l2b,
+ unsigned b2l)
{
- unsigned num_indexes;
- unsigned index_flags, min_mesg_size;
- unsigned list_size, btree_size;
- unsigned x;
- herr_t ret;
-
- /* Verify number of indexes is set to default */
- ret = H5Pget_shared_mesg_nindexes(fcpl_id, &num_indexes);
+ unsigned nindexes_actual;
+ unsigned list_size;
+ unsigned btree_size;
+ unsigned x;
+ herr_t ret;
+
+ /* Number of indexes */
+ ret = H5Pget_shared_mesg_nindexes(fcpl_id, &nindexes_actual);
CHECK_I(ret, "H5Pget_shared_mesg_nindexes");
- VERIFY(num_indexes, nindexes_in, "H5Pget_shared_mesg_nindexes");
+ VERIFY(nindexes_actual, nindexes_expected, "H5Pget_shared_mesg_nindexes");
- /* Verify index flags and minsizes are set */
- for(x=0; x<num_indexes; ++x)
- {
- ret = H5Pget_shared_mesg_index(fcpl_id, x, &index_flags, &min_mesg_size);
+ /* Index flags and minsizes */
+ for(x=0; x<nindexes_actual; ++x) {
+ unsigned flags_i;
+ unsigned min_mesg_size;
+ ret = H5Pget_shared_mesg_index(fcpl_id, x, &flags_i, &min_mesg_size);
CHECK_I(ret, "H5Pget_shared_mesg_index");
- VERIFY(index_flags, flags_in[x], "H5Pget_shared_mesg_index");
- VERIFY(min_mesg_size, minsizes_in[x], "H5Pget_shared_mesg_index");
+ VERIFY(flags_i, flags_expected[x], "H5Pget_shared_mesg_index");
+ VERIFY(min_mesg_size, minsizes_expected[x], "H5Pget_shared_mesg_index");
}
- /* Check list-to-btree and btree-to-list values */
+ /* List-to-btree and btree-to-list values */
ret = H5Pget_shared_mesg_phase_change(fcpl_id, &list_size, &btree_size);
CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
VERIFY(list_size, l2b, "H5Pset_shared_mesg_phase_change");
VERIFY(btree_size, b2l, "H5Pset_shared_mesg_phase_change");
-}
+} /* verify_fcpl_values */
/****************************************************************
@@ -219,22 +224,21 @@ static void check_fcpl_values(hid_t fcpl_id, const unsigned nindexes_in,
** test_sohm_fcpl(): Test File Creation Property Lists.
**
****************************************************************/
-static void test_sohm_fcpl(void)
+static void
+test_sohm_fcpl(void)
{
- hid_t fid = -1;
- hid_t fcpl_id = -1;
- hid_t fcpl2_id = -1;
- unsigned x;
- herr_t ret; /* Generic return value */
+ hid_t fid = -1;
+ hid_t fcpl_id = -1;
+ hid_t fcpl2_id = -1;
+ unsigned x;
+ herr_t ret;
- /* Output message about test being performed */
MESSAGE(5, ("Testing File Creation Properties for Shared Messages\n"));
fcpl_id = H5Pcreate(H5P_FILE_CREATE);
CHECK_I(fcpl_id, "H5Pcreate");
- /* Verify fcpl values */
- check_fcpl_values(fcpl_id, DEF_NUM_INDEXES, def_type_flags, def_minsizes, DEF_L2B, DEF_B2L);
+ verify_fcpl_values(fcpl_id, DEF_NUM_INDEXES, def_type_flags, def_minsizes, DEF_L2B, DEF_B2L);
/* Create a file with this fcpl and make sure that all the values can be
* retrieved.
@@ -245,8 +249,7 @@ static void test_sohm_fcpl(void)
fcpl2_id = H5Fget_create_plist(fid);
CHECK_I(fcpl2_id, "H5Fcreate");
- /* Verify fcpl values */
- check_fcpl_values(fcpl2_id, DEF_NUM_INDEXES, def_type_flags, def_minsizes, DEF_L2B, DEF_B2L);
+ verify_fcpl_values(fcpl2_id, DEF_NUM_INDEXES, def_type_flags, def_minsizes, DEF_L2B, DEF_B2L);
ret = H5Pclose(fcpl2_id);
CHECK_I(ret, "H5Pclose");
@@ -262,8 +265,7 @@ static void test_sohm_fcpl(void)
fcpl2_id = H5Fget_create_plist(fid);
CHECK_I(ret, "H5Fcreate");
- /* Verify fcpl values */
- check_fcpl_values(fcpl2_id, DEF_NUM_INDEXES, def_type_flags, def_minsizes, DEF_L2B, DEF_B2L);
+ verify_fcpl_values(fcpl2_id, DEF_NUM_INDEXES, def_type_flags, def_minsizes, DEF_L2B, DEF_B2L);
/* Clean up */
ret = H5Pclose(fcpl2_id);
@@ -289,7 +291,7 @@ static void test_sohm_fcpl(void)
ret = H5Pset_shared_mesg_phase_change(fcpl_id, TEST_L2B, TEST_B2L);
CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
- check_fcpl_values(fcpl_id, TEST_NUM_INDEXES, test_type_flags, test_minsizes, TEST_L2B, TEST_B2L);
+ verify_fcpl_values(fcpl_id, TEST_NUM_INDEXES, test_type_flags, test_minsizes, TEST_L2B, TEST_B2L);
/* Use the fcpl to create a file and get it back again */
fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT);
@@ -297,8 +299,7 @@ static void test_sohm_fcpl(void)
fcpl2_id = H5Fget_create_plist(fid);
CHECK_I(fcpl2_id, "H5Fcreate");
- /* Verify fcpl values */
- check_fcpl_values(fcpl2_id, TEST_NUM_INDEXES, test_type_flags, test_minsizes, TEST_L2B, TEST_B2L);
+ verify_fcpl_values(fcpl2_id, TEST_NUM_INDEXES, test_type_flags, test_minsizes, TEST_L2B, TEST_B2L);
ret = H5Pclose(fcpl2_id);
CHECK_I(ret, "H5Pclose");
@@ -314,8 +315,7 @@ static void test_sohm_fcpl(void)
fcpl2_id = H5Fget_create_plist(fid);
CHECK_I(ret, "H5Fcreate");
- /* Verify fcpl values */
- check_fcpl_values(fcpl2_id, TEST_NUM_INDEXES, test_type_flags, test_minsizes, TEST_L2B, TEST_B2L);
+ verify_fcpl_values(fcpl2_id, TEST_NUM_INDEXES, test_type_flags, test_minsizes, TEST_L2B, TEST_B2L);
/* Clean up */
ret = H5Pclose(fcpl2_id);
@@ -323,7 +323,70 @@ static void test_sohm_fcpl(void)
ret = H5Fclose(fid);
CHECK_I(ret, "H5Fclose");
- /* Test giving bogus values to H5P* functions */
+ /* Actually, the list max can be exactly 1 greater than the
+ * btree min, but no more.
+ * Reset the second index.
+ */
+ ret = H5Pset_shared_mesg_index(fcpl_id, 1, test_type_flags[1], 15);
+ CHECK_I(ret, "H5Pset_shared_mesg_index");
+ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 10, 11);
+ CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT);
+ CHECK_I(fid, "H5Fcreate");
+ ret = H5Fclose(fid);
+ CHECK_I(ret, "H5Fclose");
+
+ /* Test edge cases:
+ * H5O_SHMESG_MAX_NINDEXES and H5O_SHMESG_MAX_LIST_SIZE should be valid
+ * values.
+ * Creating a file with uninitialized indexes should work. (TODO: not implemented?)
+ */
+ ret = H5Pset_shared_mesg_nindexes(fcpl_id, H5O_SHMESG_MAX_NINDEXES);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ ret = H5Pset_shared_mesg_phase_change(fcpl_id, H5O_SHMESG_MAX_LIST_SIZE, H5O_SHMESG_MAX_LIST_SIZE);
+ CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT);
+ CHECK_I(fid, "H5Fcreate");
+
+ /* Clean up */
+ ret = H5Pclose(fcpl_id);
+ CHECK_I(ret, "H5Pclose");
+ ret = H5Fclose(fid);
+ CHECK_I(ret, "H5Fclose");
+} /* test_sohm_fcpl */
+
+
+/****************************************************************
+**
+** test_sohm_fcpl_errors(): Test bogus FCPL settings for SOHMs
+**
+****************************************************************/
+static void
+test_sohm_fcpl_errors(void)
+{
+ hid_t fcpl_id = -1;
+ hid_t fid = -1;
+ unsigned x;
+ herr_t ret;
+
+ MESSAGE(5, ("Testing bogus file creation properties for shared messages\n"));
+
+ fcpl_id = H5Pcreate(H5P_FILE_CREATE);
+ CHECK_I(fcpl_id, "H5Pcreate");
+
+ /* Set up index values */
+ ret = H5Pset_shared_mesg_nindexes(fcpl_id, TEST_NUM_INDEXES);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ for(x = 0; x < TEST_NUM_INDEXES; ++x) {
+ ret = H5Pset_shared_mesg_index(fcpl_id, x, test_type_flags[x], test_minsizes[x]);
+ CHECK_I(ret, "H5Pset_shared_mesg_index");
+ }
+
+ ret = H5Pset_shared_mesg_phase_change(fcpl_id, TEST_L2B, TEST_B2L);
+ CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
+
+ verify_fcpl_values(fcpl_id, TEST_NUM_INDEXES, test_type_flags, test_minsizes, TEST_L2B, TEST_B2L);
+
H5E_BEGIN_TRY {
/* Trying to create too many indexes should fail */
ret = H5Pset_shared_mesg_nindexes(fcpl_id, H5O_SHMESG_MAX_NINDEXES + 1);
@@ -370,40 +433,7 @@ static void test_sohm_fcpl(void)
ret = H5Pset_shared_mesg_phase_change(fcpl_id, H5O_SHMESG_MAX_LIST_SIZE, H5O_SHMESG_MAX_LIST_SIZE+1);
VERIFY(ret, -1, "H5Pset_shared_mesg_phase_change");
} H5E_END_TRY
-
-
- /* Actually, the list max can be exactly 1 greater than the
- * btree min, but no more. Also, the errors above shouldn't
- * have corrupted the fcpl, although we do need to reset the
- * second index that we changed above.
- */
- ret = H5Pset_shared_mesg_index(fcpl_id, 1, test_type_flags[1], 15);
- CHECK_I(ret, "H5Pset_shared_mesg_index");
- ret = H5Pset_shared_mesg_phase_change(fcpl_id, 10, 11);
- CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
- fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT);
- CHECK_I(fid, "H5Fcreate");
- ret = H5Fclose(fid);
- CHECK_I(ret, "H5Fclose");
-
- /* Test edge cases; H5O_SHMESG_MAX_NINDEXES and H5O_SHMESG_MAX_LIST_SIZE should be
- * valid values. Also, creating a file with uninitialized indexes
- * (indexes 3-5) should work.
- */
- ret = H5Pset_shared_mesg_nindexes(fcpl_id, H5O_SHMESG_MAX_NINDEXES);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
- ret = H5Pset_shared_mesg_phase_change(fcpl_id, H5O_SHMESG_MAX_LIST_SIZE, H5O_SHMESG_MAX_LIST_SIZE);
- CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
- fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT);
- CHECK_I(fid, "H5Fcreate");
-
-
- /* Clean up */
- ret = H5Pclose(fcpl_id);
- CHECK_I(ret, "H5Pclose");
- ret = H5Fclose(fid);
- CHECK_I(ret, "H5Fclose");
-}
+} /* test_sohm_fcpl_errors */
/*-------------------------------------------------------------------------
@@ -455,7 +485,8 @@ error:
H5Tclose(dtype1_id);
} H5E_END_TRY
return -1;
-}
+} /* make_dtype1 */
+
/*-------------------------------------------------------------------------
* Function: make_dtype_2
@@ -518,9 +549,9 @@ error:
H5Tclose(int_id);
} H5E_END_TRY
return -1;
-}
-
+} /* make_dtype2 */
+
/*-------------------------------------------------------------------------
* Function: close_reopen_file
*
@@ -540,16 +571,16 @@ error:
static hid_t
close_reopen_file(hid_t file, const char* filename, hid_t fapl_id)
{
- hid_t fid;
-
- if(H5Fclose(file) < 0) FAIL_STACK_ERROR
- if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) FAIL_STACK_ERROR
-
- return(fid);
+ if (H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+ file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id);
+ if (file < 0)
+ FAIL_STACK_ERROR
+ return(file);
error:
return -1;
-}
+} /* close_reopen_file */
/*-------------------------------------------------------------------------
@@ -557,7 +588,6 @@ error:
*
* Purpose: Creates object headers that use a large datatype message.
*
- * Used in test_sohm_basic. Should close the file ID passed in.
* Set test_file_closing to 1 to add file closing and reopening
* whenever possible (to test that SOHMs are written correctly
* on disk and not just in memory).
@@ -571,7 +601,10 @@ error:
*-------------------------------------------------------------------------
*/
static hid_t
-size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_closing)
+size1_helper(hid_t file,
+ const char *filename,
+ hid_t fapl_id,
+ int test_file_closing)
{
dtype1_struct wdata;
dtype1_struct rdata;
@@ -581,6 +614,42 @@ size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_clos
hsize_t dim1[1];
int x;
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * Macro: TSOHM_S1H_VERIFY_DATA
+ *
+ * Purpose: Encapsulate a common pattern:
+ * Reads the dataset and verifies that [a subset of] the data
+ * are as expected.
+ *
+ * Programmer: Jacob Smith
+ * 2018 November 1
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+#define TSOHM_S1H_VERIFY_DATA(dset_id, dtype_id) \
+{ \
+ HDmemset(&rdata, 0, sizeof(rdata)); \
+ if (0 > H5Dread( \
+ (dset_id), \
+ (dtype_id), \
+ H5S_ALL, \
+ H5S_ALL, \
+ H5P_DEFAULT, \
+ &rdata)) \
+ { \
+ H5_FAILED(); AT(); \
+ printf("Can't read data\n"); \
+ goto error; \
+ } \
+ if (rdata.i1 != wdata.i1 || \
+ rdata.i2 != wdata.i2 || \
+ HDstrcmp(rdata.str, wdata.str)) \
+ { \
+ H5_FAILED(); AT(); \
+ printf("incorrect read data\n"); \
+ goto error; \
+ } \
+} /* TSOHM_S1H_VERIFY_DATA() definition */
+
/* Closing and re-opening the file takes a long time on systems without
* local disks. Don't close and reopen if express testing is enabled.
*/
@@ -603,107 +672,68 @@ size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_clos
/* Intialize rdata */
HDmemset(&rdata, 0, sizeof(rdata));
- if((dtype1_id = make_dtype_1()) < 0) TEST_ERROR
+ dtype1_id = make_dtype_1();
+ if(dtype1_id < 0) TEST_ERROR
- /* Create the dataspace and dataset */
dim1[0] = 1;
- if((space_id = H5Screate_simple(1, dim1, NULL)) < 0) TEST_ERROR
+ space_id = H5Screate_simple(1, dim1, NULL);
+ if(space_id < 0) TEST_ERROR
- if((dset_id = H5Dcreate2(file, DSETNAME[0], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ dset_id = H5Dcreate2(file, DSETNAME[0], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if(dset_id < 0) FAIL_STACK_ERROR
/* Test writing and reading */
if(H5Dwrite(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) FAIL_STACK_ERROR
-
- if(H5Dread(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) FAIL_STACK_ERROR
-
- if(rdata.i1 != wdata.i1 || rdata.i2 != wdata.i2 || HDstrcmp(rdata.str, wdata.str)) {
- H5_FAILED(); AT();
- printf("incorrect read data\n");
- goto error;
- } /* end if */
+ TSOHM_S1H_VERIFY_DATA(dset_id, dtype1_id)
if(H5Dclose(dset_id) < 0) FAIL_STACK_ERROR
- /* Close and re-open the file if requested*/
if(test_file_closing)
if((file = close_reopen_file(file, filename, fapl_id)) < 0) TEST_ERROR
- /* Create more datasets with the same datatype */
- if((dset_id = H5Dcreate2(file, DSETNAME[1], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if(H5Dclose(dset_id) < 0) FAIL_STACK_ERROR
+ /* Create 3 more datasets with the same datatype/dataspace */
+ for (x = 1; x < 4; x++) {
+ dset_id = H5Dcreate2(file, DSETNAME[x], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (0 > dset_id) FAIL_STACK_ERROR
+ if (x == 3)
+ if(H5Dwrite(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) TEST_ERROR
+ if (H5Dclose(dset_id) < 0) FAIL_STACK_ERROR
- /* Close and re-open the file if requested*/
- if(test_file_closing)
- if((file = close_reopen_file(file, filename, fapl_id)) < 0) TEST_ERROR
-
- if((dset_id = H5Dcreate2(file, DSETNAME[2], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Dclose(dset_id) < 0) TEST_ERROR
-
- /* Close and re-open the file if requested*/
- if(test_file_closing)
- if((file = close_reopen_file(file, filename, fapl_id)) < 0) TEST_ERROR
-
- if((dset_id = H5Dcreate2(file,DSETNAME[3],dtype1_id,space_id,H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
-
- /* Write data to dataset 3 for later */
- if(H5Dwrite(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) TEST_ERROR
+ if (test_file_closing)
+ if((file = close_reopen_file(file, filename, fapl_id)) < 0) TEST_ERROR
+ }
- if(H5Dclose(dset_id) < 0) TEST_ERROR
if(H5Tclose(dtype1_id) < 0) TEST_ERROR
- /* Close and re-open the file if requested*/
- if(test_file_closing)
- if((file = close_reopen_file(file, filename, fapl_id)) < 0) TEST_ERROR
-
/* Make sure the data has been written successfully */
- if((dset_id = H5Dopen2(file, DSETNAME[0], H5P_DEFAULT)) < 0) TEST_ERROR
- if((dtype1_id = H5Dget_type(dset_id)) < 0) TEST_ERROR
-
- /* Read data back again */
- HDmemset(&rdata, 0, sizeof(rdata));
- if(H5Dread(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) {
- H5_FAILED(); AT();
- printf("Can't read data\n");
- goto error;
- } /* end if */
-
- if(rdata.i1 != wdata.i1 || rdata.i2 != wdata.i2 || HDstrcmp(rdata.str, wdata.str)) {
- H5_FAILED(); AT();
- printf("incorrect read data\n");
- goto error;
- } /* end if */
+ dset_id = H5Dopen2(file, DSETNAME[0], H5P_DEFAULT);
+ if(dset_id < 0) TEST_ERROR
+ dtype1_id = H5Dget_type(dset_id);
+ if(dtype1_id < 0) TEST_ERROR
+ TSOHM_S1H_VERIFY_DATA(dset_id, dtype1_id)
if(H5Dclose(dset_id) < 0) TEST_ERROR
- /* Create several copies of the dataset (this increases the amount of space saved by sharing the datatype message) */
+ /* Create several copies of the dataset
+ * this increases the amount of space saved by sharing the datatype message
+ */
for(x = 0; x < SOHM_HELPER_NUM_EX_DSETS; x++) {
- if((dset_id = H5Dcreate2(file, EXTRA_DSETNAME[x], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ dset_id = H5Dcreate2(file, EXTRA_DSETNAME[x], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if(dset_id < 0) TEST_ERROR
if(H5Dclose(dset_id) < 0) TEST_ERROR
- /* Close and re-open the file if requested*/
if(test_file_closing)
if((file = close_reopen_file(file, filename, fapl_id)) < 0) TEST_ERROR
- } /* end for */
+ }
if(H5Tclose(dtype1_id) < 0) TEST_ERROR
if(H5Sclose(space_id) < 0) TEST_ERROR
/* Ensure that we can still read data back from dataset 3 */
- if((dset_id = H5Dopen2(file, DSETNAME[3], H5P_DEFAULT)) < 0) TEST_ERROR
- if((dtype1_id = H5Dget_type(dset_id)) < 0) TEST_ERROR
-
- /* Read data back again */
- HDmemset(&rdata, 0, sizeof(rdata));
- if(H5Dread(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) {
- H5_FAILED(); AT();
- printf("Can't read data\n");
- goto error;
- } /* end if */
-
- if(rdata.i1 != wdata.i1 || rdata.i2 != wdata.i2 || HDstrcmp(rdata.str, wdata.str)) {
- H5_FAILED(); AT();
- printf("incorrect read data\n");
- goto error;
- } /* end if */
+ dset_id = H5Dopen2(file, DSETNAME[3], H5P_DEFAULT);
+ if(dset_id < 0) TEST_ERROR
+ dtype1_id = H5Dget_type(dset_id);
+ if(dtype1_id < 0) TEST_ERROR
+ TSOHM_S1H_VERIFY_DATA(dset_id, dtype1_id)
if(H5Dclose(dset_id) < 0) TEST_ERROR
if(H5Tclose(dtype1_id) < 0) TEST_ERROR
@@ -717,7 +747,52 @@ size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_clos
H5Fclose(file);
} H5E_END_TRY
return -1;
-}
+#undef TSOHM_S1H_VERIFY_DATA /* macro is exclusive to this function */
+} /* size1_helper */
+
+
+/*----------------------------------------------------------------------------
+ * Function: getsize_testsize1
+ *
+ * Purpose: Creates a test file, populates it, and returns its file size.
+ * Oject header information from the "first" dataset in the file
+ * is stored in pointer `oinfo`.
+ *
+ * Programmer: Jacob Smith
+ * 2018 November 1
+ *----------------------------------------------------------------------------
+ */
+static h5_stat_size_t
+getsize_testsize1(
+ const char *filename,
+ hid_t fcpl_id,
+ hid_t fapl_id,
+ unsigned open_close,
+ H5O_info_t *oinfo)
+{
+ hid_t file = -1;
+ herr_t ret;
+
+ file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id);
+ CHECK_I(file, "H5Fcreate");
+
+ file = size1_helper(file, FILENAME, fapl_id, open_close);
+ CHECK_I(file, "size1_helper");
+
+ ret = H5Oget_info_by_name2(
+ file,
+ DSETNAME[0],
+ oinfo,
+ H5O_INFO_HDR,
+ H5P_DEFAULT);
+ CHECK_I(ret, "H5Oget_info_by_name");
+
+ ret = H5Fclose(file);
+ CHECK_I(ret, "H5Fclose");
+
+ return h5_get_file_size(FILENAME, fapl_id);
+} /* getsize_testsize1 */
+
/*-------------------------------------------------------------------------
* Function: test_sohm_size1
@@ -728,16 +803,30 @@ size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_clos
* Monday, April 10, 2006
*
* Modifications:
+ * 2018 November 1 - Jacob Smith
+ * Heavily refactored to re-use and loop over patterns of
+ * file creation, setup, and size read.
*
*-------------------------------------------------------------------------
*/
-static void test_sohm_size1(void)
+static void
+test_sohm_size1(void)
{
hid_t file = -1;
hid_t fcpl_id = -1;
hid_t fapl_id = -1;
- hsize_t sohm_oh_size;
- hsize_t sohm_btree_oh_size;
+
+ unsigned use_shared = 0;
+ unsigned use_btree = 0;
+ unsigned open_close = 0;
+ h5_stat_size_t file_sizes[9];
+ unsigned size_index = 0;
+ hsize_t oh_sizes[3];
+ unsigned oh_size_index = 0;
+
+ hsize_t norm_oh_size;
+ hsize_t sohm_oh_size;
+ hsize_t sohm_btree_oh_size;
h5_stat_size_t norm_empty_filesize;
h5_stat_size_t sohm_empty_filesize;
h5_stat_size_t sohm_btree_empty_filesize;
@@ -747,6 +836,7 @@ static void test_sohm_size1(void)
h5_stat_size_t norm_final_filesize2;
h5_stat_size_t sohm_final_filesize2;
h5_stat_size_t sohm_btree_final_filesize2;
+
H5O_info_t oinfo;
unsigned num_indexes = 1;
unsigned index_flags = H5O_SHMESG_DTYPE_FLAG;
@@ -757,177 +847,115 @@ static void test_sohm_size1(void)
MESSAGE(5, ("Testing that shared datatypes save space\n"));
-
/* Create a FAPL with "semi" close degree, to detect dangling IDs */
fapl_id = H5Pcreate(H5P_FILE_ACCESS);
CHECK_I(fapl_id, "H5Pcreate");
-
ret = H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI);
CHECK_I(ret, "H5Pset_fclose_degree");
- /* Create a file with SOHMs disabled and get its size */
- fcpl_id = H5Pcreate(H5P_FILE_CREATE);
- CHECK_I(fcpl_id, "H5Pcreate");
-
- ret = H5Pset_shared_mesg_nindexes(fcpl_id, 0);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
-
- file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id);
- CHECK_I(file, "H5Fcreate");
-
- ret = H5Fclose(file);
- CHECK_I(ret, "H5Fclose");
-
- /* Get the file size */
- norm_empty_filesize = h5_get_file_size(FILENAME, fapl_id);
-
- /* Add a bunch of large datatypes to the file */
- file = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_id);
- CHECK_I(file, "H5Fopen");
- file = size1_helper(file, FILENAME, fapl_id, 0);
- CHECK_I(file, "size1_helper");
- ret = H5Fclose(file);
- CHECK_I(ret, "H5Fclose");
-
- /* Get the new file size */
- norm_final_filesize = h5_get_file_size(FILENAME, fapl_id);
-
- /* Use the same property list to create a new file. */
- file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id);
- CHECK_I(file, "H5Fcreate");
-
- ret = H5Pclose(fcpl_id);
- CHECK_I(ret, "H5Pclose");
-
- /* Add the same large datatypes, but keep closing and re-opening the file */
- file = size1_helper(file, FILENAME, fapl_id, 1);
- CHECK_I(file, "size1_helper");
- ret = H5Fclose(file);
- CHECK_I(ret, "H5Fclose");
-
- /* Get the file size */
- norm_final_filesize2 = h5_get_file_size(FILENAME, fapl_id);
-
-
-
- /* Now do the same thing for a file with SOHMs enabled */
- /* Create FCPL with SOHMs enabled */
- fcpl_id = H5Pcreate(H5P_FILE_CREATE);
- CHECK_I(fcpl_id, "H5Pcreate");
-
- /* Tests one index holding only datatype messages */
- ret = H5Pset_shared_mesg_nindexes(fcpl_id, num_indexes);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
- ret = H5Pset_shared_mesg_index(fcpl_id, 0, index_flags, min_mesg_size);
- CHECK_I(ret, "H5Pset_shared_mesg_index");
- ret = H5Pset_shared_mesg_phase_change(fcpl_id, list_max, btree_min);
- CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
-
- /* Create a file */
- file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id);
- CHECK_I(file, "H5Fcreate");
-
- ret = H5Fclose(file);
- CHECK_I(ret, "H5Fclose");
-
- sohm_empty_filesize = h5_get_file_size(FILENAME, fapl_id);
-
- /* Add a bunch of datatypes to this file */
- file = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_id);
- CHECK_I(file, "H5Fopen");
- file = size1_helper(file, FILENAME, fapl_id, 0);
- CHECK_I(file, "size1_helper");
-
- /* Get the size of a dataset object header */
- ret = H5Oget_info_by_name2(file, DSETNAME[0], &oinfo, H5O_INFO_HDR, H5P_DEFAULT);
- CHECK_I(ret, "H5Oget_info_by_name");
- ret = H5Fclose(file);
- CHECK_I(ret, "H5Fclose");
- sohm_oh_size = oinfo.hdr.space.total;
+ /* ----------------------------------------
+ * Run operations, accumulating file sizes to compare later.
+ */
+
+ for (use_shared = 0; use_shared < 2; use_shared++) {
+ for (use_btree = 0; use_btree < 2; use_btree++) {
+
+ /* cannot use btree indexing without shared messages; skip case */
+ if (use_btree && !use_shared)
+ continue;
+
+ fcpl_id = H5Pcreate(H5P_FILE_CREATE);
+ CHECK_I(fcpl_id, "H5Pcreate");
+
+ if (use_shared) {
+ /* Tests one index holding only datatype messages */
+ ret = H5Pset_shared_mesg_nindexes(fcpl_id, num_indexes);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ ret = H5Pset_shared_mesg_index(
+ fcpl_id,
+ 0,
+ index_flags,
+ min_mesg_size);
+ CHECK_I(ret, "H5Pset_shared_mesg_index");
+
+ if (use_btree) {
+ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0);
+ } else {
+ ret = H5Pset_shared_mesg_phase_change(
+ fcpl_id,
+ list_max,
+ btree_min);
+ }
+ CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
+ } else {
+ ret = H5Pset_shared_mesg_nindexes(fcpl_id, 0);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ }
+
+ file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id);
+ CHECK_I(file, "H5Fcreate");
+ ret = H5Fclose(file);
+ CHECK_I(ret, "H5Fclose");
- /* Get the new file size */
- sohm_final_filesize = h5_get_file_size(FILENAME, fapl_id);
+ /* size of empty file */
+ file_sizes[size_index++] = h5_get_file_size(FILENAME, fapl_id);
+
+ /* size of populated file, with different populating behaviors */
+ for (open_close = 0; open_close < 2; open_close++) {
+ file_sizes[size_index++] = getsize_testsize1(
+ FILENAME,
+ fcpl_id,
+ fapl_id,
+ open_close,
+ &oinfo);
+ }
+ oh_sizes[oh_size_index++] = oinfo.hdr.space.total;
+
+ ret = H5Pclose(fcpl_id);
+ CHECK_I(ret, "H5Pclose");
+ } /* for btree/listed messages */
+ } /* for normal/shared messages */
- /* Use the same property list to create a new file. */
- file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id);
- CHECK_I(file, "H5Fcreate");
-
- ret = H5Pclose(fcpl_id);
+ ret = H5Pclose(fapl_id);
CHECK_I(ret, "H5Pclose");
- /* Add the same large datatypes, but keep closing and re-opening the file */
- file = size1_helper(file, FILENAME, fapl_id, 1);
- CHECK_I(file, "size1_helper");
- ret = H5Fclose(file);
- CHECK_I(ret, "H5Fclose");
+ /* sanity-check state of arrays */
+ VERIFY(9, size_index, "size_index");
+ VERIFY(3, oh_size_index, "oh_size_index");
- /* Get the file size */
- sohm_final_filesize2 = h5_get_file_size(FILENAME, fapl_id);
-
-
-
- /* Create FCPL with SOHMs enabled that uses a B-tree index */
- fcpl_id = H5Pcreate(H5P_FILE_CREATE);
- CHECK_I(fcpl_id, "H5Pcreate");
-
- /* Tests one index holding only datatype messages */
- ret = H5Pset_shared_mesg_nindexes(fcpl_id, num_indexes);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
- ret = H5Pset_shared_mesg_index(fcpl_id, 0, index_flags, min_mesg_size);
- CHECK_I(ret, "H5Pset_shared_mesg_index");
- ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0);
- CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
-
- /* Create a file */
- file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id);
- CHECK_I(file, "H5Fcreate");
-
- ret = H5Fclose(file);
- CHECK_I(ret, "H5Fclose");
-
- sohm_btree_empty_filesize = h5_get_file_size(FILENAME, fapl_id);
-
- /* Add a bunch of datatypes to this file */
- file = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_id);
- CHECK_I(file, "H5Fopen");
- file = size1_helper(file, FILENAME, fapl_id, 0);
- CHECK_I(file, "size1_helper");
-
- /* Get the size of a dataset object header */
- ret = H5Oget_info_by_name2(file, DSETNAME[0], &oinfo, H5O_INFO_HDR, H5P_DEFAULT);
- CHECK_I(ret, "H5Oget_info_by_name");
- ret = H5Fclose(file);
- CHECK_I(ret, "H5Fclose");
- sohm_btree_oh_size = oinfo.hdr.space.total;
-
- /* Get the new file size */
- sohm_btree_final_filesize = h5_get_file_size(FILENAME, fapl_id);
-
- /* Use the same property list to create a new file. */
- file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id);
- CHECK_I(file, "H5Fcreate");
-
- ret = H5Pclose(fcpl_id);
- CHECK_I(ret, "H5Pclose");
+ /* ----------------------------------------
+ * Check that all sizes make sense.
+ */
- /* Add the same large datatypes, but keep closing and re-opening the file */
- file = size1_helper(file, FILENAME, fapl_id, 1);
- CHECK_I(file, "size1_helper");
- ret = H5Fclose(file);
- CHECK_I(ret, "H5Fclose");
+ /* Put result sizes into human-readable symbolic names.
+ * Order dependent on loop execution above.
+ */
+ norm_empty_filesize = file_sizes[0];
+ norm_final_filesize = file_sizes[1];
+ norm_final_filesize2 = file_sizes[2];
+ norm_oh_size = oh_sizes[0];
- /* Get the file size */
- sohm_btree_final_filesize2 = h5_get_file_size(FILENAME, fapl_id);
+ sohm_empty_filesize = file_sizes[3];
+ sohm_final_filesize = file_sizes[4];
+ sohm_final_filesize2 = file_sizes[5];
+ sohm_oh_size = oh_sizes[1];
+ sohm_btree_empty_filesize = file_sizes[6];
+ sohm_btree_final_filesize = file_sizes[7];
+ sohm_btree_final_filesize2 = file_sizes[8];
+ sohm_btree_oh_size = oh_sizes[2];
+ /* How the SOHM messages are stored shouldn't affect the
+ * size of the object header.
+ */
+ VERIFY(sohm_btree_oh_size, sohm_oh_size, "H5Oget_info_by_name");
- /* Check that all sizes make sense */
+/* !!ERROR!! either comment lies or implementation is faulty! */
/* Object headers in SOHM files should be smaller than normal object
- * headers. How the SOHM messages are stored shouldn't affect the
- * size of the object header.
+ * headers.
*/
- if(sohm_oh_size != sohm_btree_oh_size)
- VERIFY(sohm_btree_oh_size, 1, "H5Oget_info_by_name");
+ if (sohm_oh_size >= norm_oh_size)
+ VERIFY(norm_oh_size, 1, "H5Oget_info_by_name");
/* Both sohm files should be bigger than a normal file when empty.
* It's hard to say whether a B-tree with no nodes allocated should be
@@ -942,23 +970,137 @@ static void test_sohm_size1(void)
VERIFY(sohm_btree_empty_filesize, 1, "h5_get_file_size");
/* When full, the sohm btree file should be smaller than the normal file.
- * The sohm list file should be at least as small, since it doesn't need the
- * overhead of a B-tree.
+ * The sohm list file should be at least as small, since it doesn't need
+ * the overhead of a B-tree.
*/
if(sohm_btree_final_filesize >= norm_final_filesize)
VERIFY(sohm_btree_final_filesize, 1, "h5_get_file_size");
if(sohm_final_filesize > sohm_btree_final_filesize)
VERIFY(sohm_final_filesize, 1, "h5_get_file_size");
- /* This shouldn't change even if we open and close the file */
+ /* Comparative sizes shouldn't change even if we open and close the file
+ */
if(sohm_btree_final_filesize2 >= norm_final_filesize2)
VERIFY(sohm_btree_final_filesize2, 1, "h5_get_file_size");
if(sohm_final_filesize2 > sohm_btree_final_filesize2)
VERIFY(sohm_final_filesize2, 1, "h5_get_file_size");
+} /* test_sohm_size1 */
+
+
+/*---------------------------------------------------------------------------
+ * Function: test_sohm_size_consistency_open_create
+ *
+ * Purpose: Tests that header size is different depending on file open
+ * procedure?
+ * Uses "size1_helper" for file setup directed to a specific
+ * file handle.
+ *
+ * Programmer: Jacob Smith
+ * 2018 November 1
+ *
+ *---------------------------------------------------------------------------
+ */
+static void
+test_sohm_size_consistency_open_create(void)
+{
+ hid_t file = -1;
+ hid_t fcpl_id = -1;
+ hid_t fapl_id = -1;
+ unsigned use_btree;
+ hsize_t oh_size_open;
+ hsize_t oh_size_create;
+ H5O_info_t oinfo;
+ unsigned num_indexes = 1;
+ unsigned index_flags = H5O_SHMESG_DTYPE_FLAG;
+ unsigned min_mesg_size = 50;
+ unsigned list_max = 11;
+ unsigned btree_min = 10;
+ herr_t ret;
+
+ MESSAGE(5, \
+ ("Testing that header size is consistent between H5Fopen and H5Fcreate\n"));
+
+ /* Create a FAPL with "semi" close degree, to detect dangling IDs */
+ fapl_id = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK_I(fapl_id, "H5Pcreate");
+ ret = H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI);
+ CHECK_I(ret, "H5Pset_fclose_degree");
+
+ for (use_btree = 0; use_btree < 2; use_btree++) {
+ /* Create FCPL with SOHMs enabled
+ */
+ fcpl_id = H5Pcreate(H5P_FILE_CREATE);
+ CHECK_I(fcpl_id, "H5Pcreate");
+ ret = H5Pset_shared_mesg_nindexes(fcpl_id, num_indexes);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ ret = H5Pset_shared_mesg_index(fcpl_id, 0, index_flags, min_mesg_size);
+ CHECK_I(ret, "H5Pset_shared_mesg_index");
+ if (use_btree) {
+ MESSAGE(5, ("----testing with btree index----\n"));
+ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0);
+ CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
+ } else {
+ MESSAGE(5, ("----testing with normal index----\n"));
+ ret = H5Pset_shared_mesg_phase_change(fcpl_id, list_max, btree_min);
+ CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
+ }
+
+ /* Create empty file */
+ file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id);
+ CHECK_I(file, "H5Fcreate");
+ ret = H5Fclose(file);
+ CHECK_I(ret, "H5Fclose");
+
+ /* Test Open/Write
+ * Add messages to previously-created file */
+ file = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_id);
+ CHECK_I(file, "H5Fopen");
+ file = size1_helper(file, FILENAME, fapl_id, 0);
+ CHECK_I(file, "size1_helper");
+
+ /* Get the size of a dataset object header */
+ ret = H5Oget_info_by_name2(
+ file,
+ DSETNAME[0],
+ &oinfo,
+ H5O_INFO_HDR,
+ H5P_DEFAULT);
+ CHECK_I(ret, "H5Oget_info_by_name");
+ oh_size_open = oinfo.hdr.space.total;
+
+ ret = H5Fclose(file);
+ CHECK_I(ret, "H5Fclose");
+
+ /* Test Create/Write
+ * Add messages to a newly-created file */
+ file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id);
+ CHECK_I(file, "H5Fcreate");
+ file = size1_helper(file, FILENAME, fapl_id, 0);
+ CHECK_I(file, "size1_helper");
+
+ /* Get the size of a dataset object header */
+ ret = H5Oget_info_by_name2(
+ file,
+ DSETNAME[0],
+ &oinfo,
+ H5O_INFO_HDR,
+ H5P_DEFAULT);
+ CHECK_I(ret, "H5Oget_info_by_name");
+ oh_size_create = oinfo.hdr.space.total;
+
+ ret = H5Fclose(file);
+ CHECK_I(ret, "H5Fclose");
+
+ VERIFY(oh_size_create, oh_size_open, "H5Oget_info_by_name2");
+
+ ret = H5Pclose(fcpl_id);
+ CHECK_I(ret, "H5Pclose");
+ } /* for normal/btree indexing */
+
ret = H5Pclose(fapl_id);
CHECK_I(ret, "H5Pclose");
-}
+} /* test_sohm_size_consistency_open_create */
/*-------------------------------------------------------------------------
@@ -966,149 +1108,132 @@ static void test_sohm_size1(void)
*
* Purpose: Given an fcpl, tests creating attributes with and without
* committed datatypes.
+ * Verify that an attribute can be written and read back.
+ * Tests attribute on a Group.
+ * Tests committed and non-committed datatypes.
+ * Tests attribute access through `H5Aopen()`.
*
* Programmer: James Laird
* Thursday, November 30, 2006
*
+ * Modifications:
+ * 2018 November 2 - Jacob Smith
+ * Heavily refactored to re-use and loop over patterns of
+ * file creation, setup, and size read.
+ *
*-------------------------------------------------------------------------
*/
-static void sohm_attr_helper(hid_t fcpl_id)
+static void
+sohm_attr_helper(hid_t fcpl_id)
{
hid_t file_id;
- hid_t type_id;
hid_t space_id;
- hid_t group_id;
- hid_t attr_id, attr_id2;
hsize_t dims = 2;
int wdata[2] = {7, 42};
int rdata[2];
herr_t ret;
size_t x;
+ unsigned op_index=0;
+#define TSOHM_SAH_OP_COUNT 3
+ const char *groupnames[TSOHM_SAH_OP_COUNT] = {
+ "group_for_nothing_special",
+ "group_for_commited_dtype",
+ "group_for_commited_dtype_and_other_ID_access",
+ };
- /*----------------------------------------------------------------------------
- * Test attribute with transient datatype
- */
- /* Create a file using the fcpl */
file_id = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT);
CHECK_I(file_id, "H5Fcreate");
- /* Create a normal datatype and dataset */
- type_id = H5Tcopy(H5T_NATIVE_INT);
- CHECK_I(type_id, "H5Tcopy");
space_id = H5Screate_simple(1, &dims, &dims);
CHECK_I(space_id, "H5Screate_simple");
- /* Create and verify an attribute on a group */
- group_id = H5Gcreate2(file_id, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK_I(group_id, "H5Gcreate2");
- attr_id = H5Acreate2(group_id, "attribute", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
- CHECK_I(attr_id, "H5Acreate2");
- ret = H5Awrite(attr_id, H5T_NATIVE_INT, wdata);
- CHECK_I(ret, "H5Awrite");
-
- /* Close the datatype and group */
- ret = H5Tclose(type_id);
- CHECK_I(ret, "H5Tclose");
- ret = H5Gclose(group_id);
- CHECK_I(ret, "H5Gclose");
-
- /* Flush the file to force data to be written */
- ret = H5Fflush(file_id, H5F_SCOPE_GLOBAL);
- CHECK_I(ret, "H5Fflush");
-
- /* Verify */
- HDmemset(rdata, 0, sizeof(rdata));
- ret = H5Aread(attr_id, H5T_NATIVE_INT, rdata);
- CHECK_I(ret, "H5Aread");
- for(x = 0; x < (size_t)dims; ++x)
- VERIFY(rdata[x], wdata[x], "H5Aread");
-
- /* Cleanup */
- ret = H5Aclose(attr_id);
- CHECK_I(ret, "H5Aclose");
-
- /*----------------------------------------------------------------------------
- * Test attribute with committed datatype
- */
- /* Repeat with a committed datatype */
- type_id = H5Tcopy(H5T_NATIVE_INT);
- CHECK_I(type_id, "H5Tcopy");
- ret = H5Tcommit2(file_id, "datatype", type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK_I(ret, "H5Tcommit2");
-
- /* Create and verify an attribute */
- group_id = H5Gcreate2(file_id, "another_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK_I(group_id, "H5Gcreate2");
- attr_id = H5Acreate2(group_id, "attribute", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
- CHECK_I(attr_id, "H5Acreate2");
- ret = H5Awrite(attr_id, H5T_NATIVE_INT, wdata);
- CHECK_I(ret, "H5Awrite");
-
- /* Close the datatype and group */
- ret = H5Tclose(type_id);
- CHECK_I(ret, "H5Tclose");
- ret = H5Gclose(group_id);
- CHECK_I(ret, "H5Gclose");
-
- /* Flush the file to force data to be written */
- ret = H5Fflush(file_id, H5F_SCOPE_GLOBAL);
- CHECK_I(ret, "H5Fflush");
-
- /* Verify */
- HDmemset(rdata, 0, sizeof(rdata));
- ret = H5Aread(attr_id, H5T_NATIVE_INT, rdata);
- CHECK_I(ret, "H5Aread");
- for(x = 0; x < (size_t)dims; ++x)
- VERIFY(rdata[x], wdata[x], "H5Aread");
-
- /* Cleanup */
- ret = H5Aclose(attr_id);
- CHECK_I(ret, "H5Aclose");
-
- /*----------------------------------------------------------------------------
- * Test attribute operation with two ID handles
- */
- /* Create and verify an attribute */
- group_id = H5Gcreate2(file_id, "yet_another_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK_I(group_id, "H5Gcreate2");
-
- attr_id = H5Acreate2(group_id, "attribute", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT);
- CHECK_I(attr_id, "H5Acreate2");
+ /* loop:
+ * 0 - nothing special
+ * 1 - committed datatype
+ * 2 - committed datatype, read through second ID
+ */
+ for (op_index = 0; op_index < TSOHM_SAH_OP_COUNT; op_index++) {
+ hid_t type_id = -1;
+ hid_t group_id = -1;
+ hid_t attr_id = -1;
+ hid_t attr_id2 = -1;
+ hid_t attr_read_id;
+
+ /* create group in file with name unique to op_index */
+ group_id = H5Gcreate2(
+ file_id,
+ groupnames[op_index],
+ H5P_DEFAULT,
+ H5P_DEFAULT,
+ H5P_DEFAULT);
+ CHECK_I(group_id, "H5Gcreate2");
+
+ type_id = H5Tcopy(H5T_NATIVE_INT);
+ CHECK_I(type_id, "H5Tcopy");
+
+ /* Commit the datatype for the latter iterations.
+ * Only do this ONCE.
+ */
+ if (op_index == 1) {
+ ret = H5Tcommit2(
+ file_id,
+ "datatype",
+ type_id,
+ H5P_DEFAULT,
+ H5P_DEFAULT,
+ H5P_DEFAULT);
+ CHECK_I(ret, "H5Tcommit2");
+ }
- /* Open the attribute to get another handle */
- attr_id2 = H5Aopen(group_id, "attribute", H5P_DEFAULT);
- CHECK_I(attr_id2, "H5Aopen");
+ attr_id = H5Acreate2(
+ group_id,
+ "attribute",
+ type_id,
+ space_id,
+ H5P_DEFAULT,
+ H5P_DEFAULT);
+ CHECK_I(attr_id, "H5Acreate2");
- ret = H5Awrite(attr_id, H5T_NATIVE_INT, wdata);
- CHECK_I(ret, "H5Awrite");
+ if (op_index == 2) {
+ /* Open the attribute to get another handle */
+ attr_id2 = H5Aopen(group_id, "attribute", H5P_DEFAULT);
+ CHECK_I(attr_id2, "H5Aopen");
+ }
- /* Close the group */
- ret = H5Gclose(group_id);
- CHECK_I(ret, "H5Gclose");
+ ret = H5Awrite(attr_id, H5T_NATIVE_INT, wdata);
+ CHECK_I(ret, "H5Awrite");
- /* Flush the file to force data to be written */
- ret = H5Fflush(file_id, H5F_SCOPE_GLOBAL);
- CHECK_I(ret, "H5Fflush");
+ ret = H5Gclose(group_id);
+ CHECK_I(ret, "H5Gclose");
+ ret = H5Tclose(type_id);
+ CHECK_I(ret, "H5Tclose");
- /* Verify the data with another ID handle */
- HDmemset(rdata, 0, sizeof(rdata));
- ret = H5Aread(attr_id2, H5T_NATIVE_INT, rdata);
- CHECK_I(ret, "H5Aread");
+ /* Flush the file to force data to be written */
+ ret = H5Fflush(file_id, H5F_SCOPE_GLOBAL);
+ CHECK_I(ret, "H5Fflush");
- for(x = 0; x < (size_t)dims; ++x)
- VERIFY(rdata[x], wdata[x], "H5Aread");
+ /* Verify */
+ attr_read_id = (op_index == 2) ? attr_id2 : attr_id;
+ HDmemset(rdata, 0, sizeof(rdata));
+ ret = H5Aread(attr_read_id, H5T_NATIVE_INT, rdata);
+ CHECK_I(ret, "H5Aread");
+ for(x = 0; x < (size_t)dims; ++x)
+ VERIFY(rdata[x], wdata[x], "H5Aread");
- /* Cleanup */
- ret = H5Aclose(attr_id);
- CHECK_I(ret, "H5Aclose");
- ret = H5Aclose(attr_id2);
- CHECK_I(ret, "H5Aclose");
+ ret = H5Aclose(attr_id);
+ CHECK_I(ret, "H5Aclose");
+ if (attr_id2 > -1 ) {
+ ret = H5Aclose(attr_id2);
+ CHECK_I(ret, "H5Aclose");
+ }
+ } /* for each attribute operation */
ret = H5Sclose(space_id);
CHECK_I(ret, "H5Sclose");
ret = H5Fclose(file_id);
CHECK_I(ret, "H5Fclose");
-}
+#undef TSOHM_SAH_OP_COUNT
+} /* sohm_attr_helper */
/*-------------------------------------------------------------------------
@@ -1123,103 +1248,168 @@ static void sohm_attr_helper(hid_t fcpl_id)
* Programmer: James Laird
* Thursday, November 30, 2006
*
+ * Modifications:
+ * 2018 November 5 - Jacob Smith
+ * Heavy refactoring.
+ * Add test for duplicate flag in separate index.
+ * Add test for 'missing' flag index.
+ *
*-------------------------------------------------------------------------
*/
-static void test_sohm_attrs(void)
+static void
+test_sohm_attrs(void)
{
hid_t fcpl_id;
+ unsigned i = 0;
+#define TSOHM_TSA_NFLAGS_1 7
+ unsigned flags1[TSOHM_TSA_NFLAGS_1] = {
+ H5O_SHMESG_ATTR_FLAG,
+ H5O_SHMESG_SDSPACE_FLAG,
+ H5O_SHMESG_DTYPE_FLAG,
+ H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_SDSPACE_FLAG,
+ H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG,
+ H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_DTYPE_FLAG,
+ H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG,
+ };
+#define TSOHM_TSA_NFLAGS_2 6
+ unsigned flags2[TSOHM_TSA_NFLAGS_2][2] = {
+ { H5O_SHMESG_ATTR_FLAG,
+ H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG,
+ },
+ { H5O_SHMESG_SDSPACE_FLAG,
+ H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_DTYPE_FLAG,
+ },
+ { H5O_SHMESG_DTYPE_FLAG,
+ H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_SDSPACE_FLAG,
+ },
+ { H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG,
+ H5O_SHMESG_ATTR_FLAG,
+ },
+ { H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_DTYPE_FLAG,
+ H5O_SHMESG_SDSPACE_FLAG,
+ },
+ { H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_SDSPACE_FLAG,
+ H5O_SHMESG_DTYPE_FLAG,
+ },
+ };
+#define TSOHM_TSA_NFLAGS_3 5
+ unsigned flags3[TSOHM_TSA_NFLAGS_3][3] = {
+ { H5O_SHMESG_ATTR_FLAG,
+ H5O_SHMESG_SDSPACE_FLAG,
+ H5O_SHMESG_DTYPE_FLAG,
+ },
+ { H5O_SHMESG_DTYPE_FLAG,
+ H5O_SHMESG_ATTR_FLAG,
+ H5O_SHMESG_SDSPACE_FLAG,
+ },
+ { H5O_SHMESG_SDSPACE_FLAG,
+ H5O_SHMESG_DTYPE_FLAG,
+ H5O_SHMESG_ATTR_FLAG,
+ },
+ { 0, /* first index does not hold a shared message type? */
+ H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG,
+ H5O_SHMESG_ATTR_FLAG,
+ },
+ { 0, /* missing SDSPACE flag */
+ H5O_SHMESG_DTYPE_FLAG,
+ H5O_SHMESG_ATTR_FLAG,
+ },
+ };
herr_t ret;
MESSAGE(5, ("Testing that shared messages work with attributes\n"));
- /* Create an fcpl with no shared messages */
+ /* No shared messages
+ */
fcpl_id = H5Pcreate(H5P_FILE_CREATE);
CHECK_I(fcpl_id, "H5Pcreate");
ret = H5Pset_shared_mesg_nindexes(fcpl_id, 0);
CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
- /* Make sure attributes can be read with these settings (they'd better!) */
sohm_attr_helper(fcpl_id);
+ ret = H5Pclose(fcpl_id);
+ CHECK_I(ret, "H5Pclose");
- /* Run tests with only one kind of message to be shared */
- ret = H5Pset_shared_mesg_nindexes(fcpl_id, 1);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
- ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ATTR_FLAG, 2);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
-
- /* Verify */
- sohm_attr_helper(fcpl_id);
-
- ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_SDSPACE_FLAG, 2);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
-
- sohm_attr_helper(fcpl_id);
-
- ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_DTYPE_FLAG, 2);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
-
- sohm_attr_helper(fcpl_id);
-
-
- /* Run with any two types shared */
- ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG, 2);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
-
- sohm_attr_helper(fcpl_id);
-
- ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_DTYPE_FLAG, 2);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
-
- sohm_attr_helper(fcpl_id);
-
- ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_ATTR_FLAG, 2);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
-
- sohm_attr_helper(fcpl_id);
-
-
- /* Run test with all three kinds of message shared */
- ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG | H5O_SHMESG_ATTR_FLAG, 2);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
-
- sohm_attr_helper(fcpl_id);
+ /* One shared message index
+ */
+ for (i=0; i < TSOHM_TSA_NFLAGS_1; i++) {
+ fcpl_id = H5Pcreate(H5P_FILE_CREATE);
+ CHECK_I(fcpl_id, "H5Pcreate");
+ ret = H5Pset_shared_mesg_nindexes(fcpl_id, 1);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ ret = H5Pset_shared_mesg_index(fcpl_id, 0, flags1[i], 2);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ sohm_attr_helper(fcpl_id);
- /* Try using two indexes */
- ret = H5Pset_shared_mesg_nindexes(fcpl_id, 2);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
- ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_DTYPE_FLAG, 2);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
- ret = H5Pset_shared_mesg_index(fcpl_id, 1, H5O_SHMESG_SDSPACE_FLAG, 2);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ ret = H5Pclose(fcpl_id);
+ CHECK_I(ret, "H5Pclose");
+ }
- sohm_attr_helper(fcpl_id);
+ /* two shared message indices
+ */
+ for (i=0; i < TSOHM_TSA_NFLAGS_2; i++) {
+ fcpl_id = H5Pcreate(H5P_FILE_CREATE);
+ CHECK_I(fcpl_id, "H5Pcreate");
+ ret = H5Pset_shared_mesg_nindexes(fcpl_id, 2);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ ret = H5Pset_shared_mesg_index(fcpl_id, 0, flags2[i][0], 2);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ ret = H5Pset_shared_mesg_index(fcpl_id, 1, flags2[i][1], 2);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
- ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_DTYPE_FLAG, 2);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ sohm_attr_helper(fcpl_id);
- sohm_attr_helper(fcpl_id);
+ ret = H5Pclose(fcpl_id);
+ CHECK_I(ret, "H5Pclose");
+ }
- ret = H5Pset_shared_mesg_index(fcpl_id, 1, H5O_SHMESG_ATTR_FLAG, 2);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ /* duplicate flags in separate indices causes problems
+ */
+ H5E_BEGIN_TRY {
+ fcpl_id = H5Pcreate(H5P_FILE_CREATE);
+ CHECK_I(fcpl_id, "H5Pcreate");
+ ret = H5Pset_shared_mesg_nindexes(fcpl_id, 2);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ATTR_FLAG, 2);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ ret = H5Pset_shared_mesg_index(fcpl_id, 1, H5O_SHMESG_ATTR_FLAG, 2);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+
+ ret = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT);
+ VERIFY(ret, -1, "H5Fcreate");
+
+ ret = H5Pclose(fcpl_id);
+ CHECK_I(ret, "H5Pclose");
+ } H5E_END_TRY;
- sohm_attr_helper(fcpl_id);
+ /* three shared message indices
+ */
+ for (i=0; i < TSOHM_TSA_NFLAGS_3; i++) {
+ fcpl_id = H5Pcreate(H5P_FILE_CREATE);
+ CHECK_I(fcpl_id, "H5Pcreate");
+ ret = H5Pset_shared_mesg_nindexes(fcpl_id, 3);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ ret = H5Pset_shared_mesg_index(fcpl_id, 0, flags3[i][0], 2);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ ret = H5Pset_shared_mesg_index(fcpl_id, 1, flags3[i][1], 2);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ ret = H5Pset_shared_mesg_index(fcpl_id, 2, flags3[i][2], 2);
+ CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ sohm_attr_helper(fcpl_id);
- /* One index for each kind of message */
- ret = H5Pset_shared_mesg_nindexes(fcpl_id, 3);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
- ret = H5Pset_shared_mesg_index(fcpl_id, 2, H5O_SHMESG_SDSPACE_FLAG, 2);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ ret = H5Pclose(fcpl_id);
+ CHECK_I(ret, "H5Pclose");
+ }
- sohm_attr_helper(fcpl_id);
+#undef TSOHM_TSA_NFLAGS_1
+#undef TSOHM_TSA_NFLAGS_2
+#undef TSOHM_TSA_NFLAGS_3
+} /* test_sohm_attrs */
- /* Close the FCPL */
- ret = H5Pclose(fcpl_id);
- CHECK_I(ret, "H5Pclose");
-}
/*-------------------------------------------------------------------------
* Function: size2_verify_plist1
@@ -1233,7 +1423,8 @@ static void test_sohm_attrs(void)
*
*-------------------------------------------------------------------------
*/
-static void size2_verify_plist1(hid_t plist)
+static void
+size2_verify_plist1(hid_t plist)
{
size_t cd_nelmts;
unsigned int cd_value;
@@ -1247,23 +1438,34 @@ static void size2_verify_plist1(hid_t plist)
/* Hardcoded to correspond to dcpl1_id created in size2_helper */
/* Check filters */
cd_nelmts = 1;
- filter = H5Pget_filter2(plist, 0, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL);
+ filter = H5Pget_filter2(plist, 0, NULL, &cd_nelmts, &cd_value,
+ (size_t)NAME_BUF_SIZE, name, NULL);
CHECK_I(filter, "H5Pget_filter2");
VERIFY(filter, H5Z_FILTER_SHUFFLE, "H5Pget_filter2");
cd_nelmts = 1;
- filter = H5Pget_filter2(plist, 1, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL);
+ filter = H5Pget_filter2(plist, 1, NULL, &cd_nelmts, &cd_value,
+ (size_t)NAME_BUF_SIZE, name, NULL);
CHECK_I(filter, "H5Pget_filter2");
VERIFY(filter, H5Z_FILTER_DEFLATE, "H5Pget_filter2");
VERIFY(cd_value, 1, "H5Pget_filter2");
cd_nelmts = 1;
- filter = H5Pget_filter2(plist, 2, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL);
+ filter = H5Pget_filter2(
+ plist,
+ 2,
+ NULL,
+ &cd_nelmts,
+ &cd_value,
+ (size_t)NAME_BUF_SIZE,
+ name,
+ NULL);
CHECK_I(filter, "H5Pget_filter2");
VERIFY(filter, H5Z_FILTER_SHUFFLE, "H5Pget_filter2");
cd_nelmts = 1;
- filter = H5Pget_filter2(plist, 3, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL);
+ filter = H5Pget_filter2(plist, 3, NULL, &cd_nelmts, &cd_value,
+ (size_t)NAME_BUF_SIZE, name, NULL);
CHECK_I(filter, "H5Pget_filter2");
VERIFY(filter, H5Z_FILTER_FLETCHER32, "H5Pget_filter2");
@@ -1281,7 +1483,8 @@ static void size2_verify_plist1(hid_t plist)
ret = H5Tclose(dtype1_id);
CHECK_I(ret, "H5Tclose");
-}
+} /* size2_verify_plist1 */
+
/*-------------------------------------------------------------------------
* Function: size2_verify_plist2
@@ -1295,7 +1498,8 @@ static void size2_verify_plist1(hid_t plist)
*
*-------------------------------------------------------------------------
*/
-static void size2_verify_plist2(hid_t plist)
+static void
+size2_verify_plist2(hid_t plist)
{
size_t cd_nelmts;
unsigned int cd_value;
@@ -1309,31 +1513,36 @@ static void size2_verify_plist2(hid_t plist)
/* Hardcoded to correspond to dcpl1_id created in size2_helper */
/* Check filters */
cd_nelmts = 1;
- filter = H5Pget_filter2(plist, 0, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL);
+ filter = H5Pget_filter2(plist, 0, NULL, &cd_nelmts, &cd_value,
+ (size_t)NAME_BUF_SIZE, name, NULL);
CHECK_I(filter, "H5Pget_filter2");
VERIFY(filter, H5Z_FILTER_DEFLATE, "H5Pget_filter2");
VERIFY(cd_value, 1, "H5Pget_filter2");
cd_nelmts = 1;
- filter = H5Pget_filter2(plist, 1, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL);
+ filter = H5Pget_filter2(plist, 1, NULL, &cd_nelmts, &cd_value,
+ (size_t)NAME_BUF_SIZE, name, NULL);
CHECK_I(filter, "H5Pget_filter2");
VERIFY(filter, H5Z_FILTER_DEFLATE, "H5Pget_filter2");
VERIFY(cd_value, 2, "H5Pget_filter2");
cd_nelmts = 1;
- filter = H5Pget_filter2(plist, 2, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL);
+ filter = H5Pget_filter2(plist, 2, NULL, &cd_nelmts, &cd_value,
+ (size_t)NAME_BUF_SIZE, name, NULL);
CHECK_I(filter, "H5Pget_filter2");
VERIFY(filter, H5Z_FILTER_DEFLATE, "H5Pget_filter2");
VERIFY(cd_value, 2, "H5Pget_filter2");
cd_nelmts = 1;
- filter = H5Pget_filter2(plist, 3, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL);
+ filter = H5Pget_filter2(plist, 3, NULL, &cd_nelmts, &cd_value,
+ (size_t)NAME_BUF_SIZE, name, NULL);
CHECK_I(filter, "H5Pget_filter2");
VERIFY(filter, H5Z_FILTER_DEFLATE, "H5Pget_filter2");
VERIFY(cd_value, 1, "H5Pget_filter2");
cd_nelmts = 1;
- filter = H5Pget_filter2(plist, 4, NULL, &cd_nelmts, &cd_value, (size_t)NAME_BUF_SIZE, name, NULL);
+ filter = H5Pget_filter2(plist, 4, NULL, &cd_nelmts, &cd_value,
+ (size_t)NAME_BUF_SIZE, name, NULL);
CHECK_I(filter, "H5Pget_filter2");
VERIFY(filter, H5Z_FILTER_DEFLATE, "H5Pget_filter2");
VERIFY(cd_value, 5, "H5Pget_filter2");
@@ -1352,7 +1561,7 @@ static void size2_verify_plist2(hid_t plist)
ret = H5Tclose(dtype2_id);
CHECK_I(ret, "H5Tclose");
-}
+} /* size2_verify_plist2 */
#ifdef NOT_NOW
@@ -1374,15 +1583,30 @@ static void
size2_dump_struct(const char *name, size2_helper_struct *sizes)
{
puts(name);
- printf(" empty size: %llu\n", (unsigned long long)sizes->empty_size);
- printf(" first dataset: %llu \tdelta: %llu\n", (unsigned long long)sizes->first_dset, (unsigned long long)(sizes->first_dset - sizes->empty_size));
- printf("second dataset: %llu \tdelta: %llu\n", (unsigned long long)sizes->second_dset, (unsigned long long)(sizes->second_dset - sizes->first_dset));
- printf(" dsets 1: %llu \tdelta: %llu\n", (unsigned long long)sizes->dsets1, (unsigned long long)(sizes->dsets1 - sizes->second_dset));
- printf(" dsets 2: %llu \tdelta: %llu\n", (unsigned long long)sizes->dsets2, (unsigned long long)(sizes->dsets2 - sizes->dsets1));
- printf(" interleaved: %llu \tdelta: %llu\n", (unsigned long long)sizes->interleaved, (unsigned long long)(sizes->interleaved - sizes->dsets2));
- printf(" attributes: %llu \tdelta: %llu\n", (unsigned long long)sizes->attrs1, (unsigned long long)(sizes->attrs1 - sizes->interleaved));
- printf(" attributes 2: %llu \tdelta: %llu\n", (unsigned long long)sizes->attrs2, (unsigned long long)(sizes->attrs2 - sizes->attrs1));
-}
+ printf(" empty size: %llu\n",
+ (unsigned long long)sizes->empty_size);
+ printf(" first dataset: %llu \tdelta: %llu\n",
+ (unsigned long long)sizes->first_dset,
+ (unsigned long long)(sizes->first_dset - sizes->empty_size));
+ printf("second dataset: %llu \tdelta: %llu\n",
+ (unsigned long long)sizes->second_dset,
+ (unsigned long long)(sizes->second_dset - sizes->first_dset));
+ printf(" dsets 1: %llu \tdelta: %llu\n",
+ (unsigned long long)sizes->dsets1,
+ (unsigned long long)(sizes->dsets1 - sizes->second_dset));
+ printf(" dsets 2: %llu \tdelta: %llu\n",
+ (unsigned long long)sizes->dsets2,
+ (unsigned long long)(sizes->dsets2 - sizes->dsets1));
+ printf(" interleaved: %llu \tdelta: %llu\n",
+ (unsigned long long)sizes->interleaved,
+ (unsigned long long)(sizes->interleaved - sizes->dsets2));
+ printf(" attributes: %llu \tdelta: %llu\n",
+ (unsigned long long)sizes->attrs1,
+ (unsigned long long)(sizes->attrs1 - sizes->interleaved));
+ printf(" attributes 2: %llu \tdelta: %llu\n",
+ (unsigned long long)sizes->attrs2,
+ (unsigned long long)(sizes->attrs2 - sizes->attrs1));
+} /* size2_dump_struct */
#endif /* NOT_NOW */
@@ -1409,7 +1633,10 @@ size2_dump_struct(const char *name, size2_helper_struct *sizes)
*-------------------------------------------------------------------------
*/
static int
-size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_sizes)
+size2_helper( \
+ hid_t fcpl_id, \
+ int test_file_closing, \
+ size2_helper_struct *ret_sizes)
{
hid_t file_id = -1;
hid_t dtype1_id = -1;
@@ -1573,15 +1800,14 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size
ret_sizes->dsets1 = h5_get_file_size(FILENAME, H5P_DEFAULT);
- /* Now create a new group filled with datasets that use all different messages */
+ /* Create new group filled with datasets that use all different messages */
file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
CHECK_I(file_id, "H5Fopen");
group_id = H5Gcreate2(file_id, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK_I(group_id, "H5Gcreate2");
/* Create NUM_DATASETS datasets in the new group */
- for(x=0; x<NUM_DATASETS; ++x)
- {
+ for(x=0; x<NUM_DATASETS; ++x) {
dset_id = H5Dcreate2(group_id, DSETNAME[x], dtype2_id, dspace2_id, H5P_DEFAULT, dcpl2_id, H5P_DEFAULT);
CHECK_I(dset_id, "H5Dcreate2");
@@ -1768,7 +1994,7 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size
CHECK_I(ret, "H5Pclose");
return 0;
-}
+} /* size2_helper */
/*-------------------------------------------------------------------------
@@ -1785,7 +2011,8 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size
*
*-------------------------------------------------------------------------
*/
-static void size2_verify(void)
+static void
+size2_verify(void)
{
hid_t file_id = -1;
hid_t dset_id=-1;
@@ -1968,7 +2195,7 @@ static void size2_verify(void)
CHECK_I(ret, "H5Gclose");
ret = H5Fclose(file_id);
CHECK_I(ret, "H5Fclose");
-}
+} /* size2_verify */
/*-------------------------------------------------------------------------
@@ -1993,7 +2220,8 @@ static void size2_verify(void)
*
*-------------------------------------------------------------------------
*/
-static void test_sohm_size2(int close_reopen)
+static void
+test_sohm_size2(int close_reopen)
{
hid_t fcpl_id = -1;
/* Sizes for file with no shared messages at all */
@@ -2585,7 +2813,7 @@ static void test_sohm_size2(int close_reopen)
VERIFY(0, 1, "h5_get_file_size");
if((h5_stat_size_t)((float)share_tiny_index.attrs2 * OVERHEAD_ALLOWED) < type_space_index.attrs2)
VERIFY(0, 1, "h5_get_file_size");
-} /* end test_sohm_size2() */
+} /* test_sohm_size2 */
/*-------------------------------------------------------------------------
@@ -2601,27 +2829,41 @@ static void test_sohm_size2(int close_reopen)
*
*-------------------------------------------------------------------------
*/
-static void delete_helper_write(hid_t file_id, hid_t *dspace_id, hid_t *dcpl_id, int x)
+static void
+delete_helper_write(hid_t file_id, hid_t *dspace_id, hid_t *dcpl_id, int x)
{
- hid_t dset_id = -1;
- hid_t attr_id = -1;
- char wdata;
+ hid_t dset_id = -1;
+ hid_t attr_id = -1;
+ char wdata;
herr_t ret;
- /* Create dataset */
- dset_id = H5Dcreate2(file_id, DSETNAME[x], H5T_NATIVE_CHAR, dspace_id[x], H5P_DEFAULT, dcpl_id[x], H5P_DEFAULT);
+ dset_id = H5Dcreate2(
+ file_id,
+ DSETNAME[x],
+ H5T_NATIVE_CHAR,
+ dspace_id[x],
+ H5P_DEFAULT,
+ dcpl_id[x],
+ H5P_DEFAULT);
CHECK_I(dset_id, "H5Dcreate2");
-
- /* Write data to dataset */
wdata = (char)(x + 'a');
- ret = H5Dwrite(dset_id, H5T_NATIVE_CHAR, dspace_id[x], dspace_id[x], H5P_DEFAULT, &wdata);
+ ret = H5Dwrite(
+ dset_id,
+ H5T_NATIVE_CHAR,
+ dspace_id[x],
+ dspace_id[x],
+ H5P_DEFAULT,
+ &wdata);
CHECK_I(ret, "H5Dwrite");
- /* Create an attribute on the dataset. */
- attr_id = H5Acreate2(dset_id, "attr_name", H5T_NATIVE_CHAR, dspace_id[x], H5P_DEFAULT, H5P_DEFAULT);
+ attr_id = H5Acreate2(
+ dset_id,
+ "attr_name",
+ H5T_NATIVE_CHAR,
+ dspace_id[x],
+ H5P_DEFAULT,
+ H5P_DEFAULT);
CHECK_I(attr_id, "H5Acreate2");
-
- /* Write to attribute */
ret = H5Awrite(attr_id, H5T_NATIVE_CHAR, &wdata);
CHECK_I(ret, "H5Awrite");
@@ -2629,7 +2871,7 @@ static void delete_helper_write(hid_t file_id, hid_t *dspace_id, hid_t *dcpl_id,
CHECK_I(ret, "H5Aclose");
ret = H5Dclose(dset_id);
CHECK_I(ret, "H5Dclose");
-}
+} /* delete_helper_write */
/*-------------------------------------------------------------------------
@@ -2645,39 +2887,39 @@ static void delete_helper_write(hid_t file_id, hid_t *dspace_id, hid_t *dcpl_id,
*
*-------------------------------------------------------------------------
*/
-static void delete_helper_read(hid_t file_id, hid_t *dspace_id, int x)
+static void
+delete_helper_read(hid_t file_id, hid_t *dspace_id, int x)
{
hid_t dset_id = -1;
hid_t attr_id = -1;
char rdata;
herr_t ret;
- /* Open dataset */
dset_id = H5Dopen2(file_id, DSETNAME[x], H5P_DEFAULT);
CHECK_I(dset_id, "H5Dopen2");
-
- /* Read */
rdata = '\0';
- ret = H5Dread(dset_id, H5T_NATIVE_CHAR, dspace_id[x], dspace_id[x], H5P_DEFAULT, &rdata);
+ ret = H5Dread(
+ dset_id,
+ H5T_NATIVE_CHAR,
+ dspace_id[x],
+ dspace_id[x],
+ H5P_DEFAULT,
+ &rdata);
CHECK_I(ret, "H5Dread");
VERIFY(rdata, (x + 'a'), "H5Dread");
- /* Open attribute */
attr_id = H5Aopen(dset_id, "attr_name", H5P_DEFAULT);
CHECK_I(attr_id, "H5Aopen");
-
- /* Read */
rdata = '\0';
ret = H5Aread(attr_id, H5T_NATIVE_CHAR, &rdata);
CHECK_I(ret, "H5Dread");
VERIFY(rdata, (x + 'a'), "H5Dread");
- /* Cleanup */
ret = H5Aclose(attr_id);
CHECK_I(ret, "H5Aclose");
ret = H5Dclose(dset_id);
CHECK_I(ret, "H5Dclose");
-}
+} /* delete_helper_read */
/*-------------------------------------------------------------------------
@@ -2701,7 +2943,8 @@ static void delete_helper_read(hid_t file_id, hid_t *dspace_id, int x)
*
*-------------------------------------------------------------------------
*/
-static void delete_helper(hid_t fcpl_id, hid_t *dspace_id, hid_t *dcpl_id)
+static void
+delete_helper(hid_t fcpl_id, hid_t *dspace_id, hid_t *dcpl_id)
{
hid_t file_id=-1;
int x;
@@ -2765,7 +3008,7 @@ static void delete_helper(hid_t fcpl_id, hid_t *dspace_id, hid_t *dcpl_id)
VERIFY(norm_filesize, deleted_filesize, "h5_get_file_size");
if(deleted_filesize > (h5_stat_size_t)((float)norm_filesize * OVERHEAD_ALLOWED))
VERIFY(deleted_filesize, norm_filesize, "h5_get_file_size");
-}
+} /* delete_helper */
/*-------------------------------------------------------------------------
@@ -2799,6 +3042,8 @@ test_sohm_delete(void)
hsize_t dims[] = DELETE_DIMS;
herr_t ret;
+ MESSAGE(5, ("Testing deletion of SOHMs\n"));
+
/* Create a number of different dataspaces.
* For simplicity, each dataspace has only one element.
*/
@@ -2910,17 +3155,18 @@ test_sohm_delete(void)
ret = H5Pclose(dcpl_id[x]);
CHECK_I(ret, "H5Pclose");
} /* end for */
-} /* end test_sohm_delete() */
+} /* test_sohm_delete */
/*-------------------------------------------------------------------------
- * Function: test_sohm_delete_revert_helper
+ * Function: verify_dset_create_and_delete_does_not_grow_file
*
* Purpose: Tests that shared object header message deletion returns
* the file to its previous state using the supplied FCPL.
*
- * Creates shared messages and then deletes them. Ensures
- * that the file has not grown in size.
+ * Creates a file according to the supplied FCPL,
+ * then creates datasets and deletes them.
+ * Done in two passes: once with one dataset, once with two.
*
* Programmer: James Laird
* Wednesday, January 3, 2007
@@ -2930,7 +3176,7 @@ test_sohm_delete(void)
*-------------------------------------------------------------------------
*/
static int
-test_sohm_delete_revert_helper(hid_t fcpl_id)
+verify_dset_create_and_delete_does_not_grow_file(hid_t fcpl_id)
{
hid_t file_id;
hid_t dspace_id;
@@ -3017,13 +3263,14 @@ test_sohm_delete_revert_helper(hid_t fcpl_id)
return(0);
else
return(-1);
-} /* test_sohm_delete_revert_helper() */
+} /* verify_dset_create_and_delete_does_not_grow_file */
/*-------------------------------------------------------------------------
* Function: test_sohm_delete_revert
*
- * Purpose: Calls test_sohm_delete_revert_helper with different FCPLs.
+ * Purpose: Verifies that creation and deletion of datasets with shared
+ * message headers will not increase file size.
*
* Programmer: James Laird
* Wednesday, January 3, 2007
@@ -3038,6 +3285,8 @@ test_sohm_delete_revert(void)
hid_t fcpl_id;
herr_t ret;
+ MESSAGE(5, ("Testing that file reverts to original size on SOHM deletion\n"));
+
/* Create an fcpl with messages in two indexes */
fcpl_id = H5Pcreate(H5P_FILE_CREATE);
CHECK_I(fcpl_id, "H5Pcreate");
@@ -3049,14 +3298,14 @@ test_sohm_delete_revert(void)
CHECK_I(ret, "H5Pset_shared_mesg_index");
/* Call the helper function to test this FCPL. */
- ret = test_sohm_delete_revert_helper(fcpl_id);
- CHECK_I(ret, "test_sohm_delete_revert_helper");
+ ret = verify_dset_create_and_delete_does_not_grow_file(fcpl_id);
+ CHECK_I(ret, "verify_dset_create_and_delete_does_not_grow_file");
/* Try using B-trees */
ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0);
CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
- ret = test_sohm_delete_revert_helper(fcpl_id);
- CHECK_I(ret, "test_sohm_delete_revert_helper");
+ ret = verify_dset_create_and_delete_does_not_grow_file(fcpl_id);
+ CHECK_I(ret, "verify_dset_create_and_delete_does_not_grow_file");
/* Try sharing all messages */
@@ -3067,14 +3316,14 @@ test_sohm_delete_revert(void)
ret = H5Pset_shared_mesg_phase_change(fcpl_id, 10, 5);
CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
- ret = test_sohm_delete_revert_helper(fcpl_id);
- CHECK_I(ret, "test_sohm_delete_revert_helper");
+ ret = verify_dset_create_and_delete_does_not_grow_file(fcpl_id);
+ CHECK_I(ret, "verify_dset_create_and_delete_does_not_grow_file");
/* Try using B-trees */
ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0);
CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
- ret = test_sohm_delete_revert_helper(fcpl_id);
- CHECK_I(ret, "test_sohm_delete_revert_helper");
+ ret = verify_dset_create_and_delete_does_not_grow_file(fcpl_id);
+ CHECK_I(ret, "verify_dset_create_and_delete_does_not_grow_file");
/* There should be at least two messages in the test (datatype and
* dataspace). Use an index that will transition from a list to
@@ -3082,8 +3331,8 @@ test_sohm_delete_revert(void)
*/
ret = H5Pset_shared_mesg_phase_change(fcpl_id, 1, 2);
CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
- ret = test_sohm_delete_revert_helper(fcpl_id);
- CHECK_I(ret, "test_sohm_delete_revert_helper");
+ ret = verify_dset_create_and_delete_does_not_grow_file(fcpl_id);
+ CHECK_I(ret, "verify_dset_create_and_delete_does_not_grow_file");
/* Try with shared messages enabled, but when messages are too big
@@ -3091,16 +3340,16 @@ test_sohm_delete_revert(void)
*/
ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ALL_FLAG, 35);
CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
- ret = test_sohm_delete_revert_helper(fcpl_id);
- CHECK_I(ret, "test_sohm_delete_revert_helper");
+ ret = verify_dset_create_and_delete_does_not_grow_file(fcpl_id);
+ CHECK_I(ret, "verify_dset_create_and_delete_does_not_grow_file");
ret = H5Pclose(fcpl_id);
CHECK_I(ret, "H5Pclose");
-}
+} /* test_sohm_delete_revert */
/*-------------------------------------------------------------------------
- * Function: test_sohm_extlink_helper
+ * Function: verify_dset_create_and_open_through_extlink_with_sohm
*
* Purpose: Tests that a dataset created through an external link can
* be opened (that shared messages were created or not and
@@ -3113,7 +3362,8 @@ test_sohm_delete_revert(void)
*
*-------------------------------------------------------------------------
*/
-static void test_sohm_extlink_helper(hid_t src_fcpl_id, hid_t dst_fcpl_id)
+static void
+verify_dset_create_and_open_through_extlink_with_sohm(hid_t src_fcpl_id, hid_t dst_fcpl_id)
{
hid_t src_file_id = -1;
hid_t dst_file_id = -1;
@@ -3164,7 +3414,7 @@ static void test_sohm_extlink_helper(hid_t src_fcpl_id, hid_t dst_fcpl_id)
CHECK_I(ret, "H5Dclose");
ret = H5Fclose(dst_file_id);
CHECK_I(ret, "H5Fclose");
-}
+} /* verify_dset_create_and_open_through_extlink_with_sohm */
/*-------------------------------------------------------------------------
@@ -3186,7 +3436,8 @@ test_sohm_extlink(void)
hid_t fcpl_id = -1;
herr_t ret;
- /* Create fcpl */
+ MESSAGE(5, ("Testing SOHM creation through external links\n"));
+
fcpl_id = H5Pcreate(H5P_FILE_CREATE);
CHECK_I(fcpl_id, "H5Pcreate");
ret = H5Pset_shared_mesg_nindexes(fcpl_id, 1);
@@ -3194,20 +3445,17 @@ test_sohm_extlink(void)
ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ALL_FLAG, 16);
CHECK_I(ret, "H5Pset_shared_mesg_index");
- /* Test using external links when the source or destination file uses
- * shared messages
- */
- test_sohm_extlink_helper(fcpl_id, H5P_DEFAULT);
- test_sohm_extlink_helper(H5P_DEFAULT, fcpl_id);
- test_sohm_extlink_helper(fcpl_id, fcpl_id);
+ verify_dset_create_and_open_through_extlink_with_sohm(fcpl_id, H5P_DEFAULT);
+ verify_dset_create_and_open_through_extlink_with_sohm(H5P_DEFAULT, fcpl_id);
+ verify_dset_create_and_open_through_extlink_with_sohm(fcpl_id, fcpl_id);
ret = H5Pclose(fcpl_id);
CHECK_I(ret, "H5Pclose");
-}
+} /* test_sohm_extlink */
/*-------------------------------------------------------------------------
- * Function: test_sohm_extend_dset_helper
+ * Function: verify_dataset_extension
*
* Purpose: Tests extending a dataset's dataspace when sharing is
* enabled.
@@ -3223,7 +3471,7 @@ test_sohm_extlink(void)
*-------------------------------------------------------------------------
*/
static int
-test_sohm_extend_dset_helper(hid_t fcpl_id, hbool_t close_reopen)
+verify_dataset_extension(hid_t fcpl_id, hbool_t close_reopen)
{
hid_t file_id = -1;
hid_t orig_space_id = -1;
@@ -3236,13 +3484,98 @@ test_sohm_extend_dset_helper(hid_t fcpl_id, hbool_t close_reopen)
hsize_t out_dims[2];
hsize_t out_maxdims[2];
int x;
- int old_nerrs; /* Number of errors when entering this routine */
+ int old_nerrs; /* Number of errors when entering this routine */
herr_t ret;
- /* Retrieve the current # of reported errors */
+ hsize_t *space_dims[3];
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * Macro: TSOHM_EDH_VERIFY_SPACES
+ *
+ * Purpose: Encapsulate a common pattern
+ * Open, read-verity, and close the dataspaces for datasets 1-3
+ *
+ * Programmer: Jacob Smith
+ * 2018 November 5
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+#define TSOHM_EDH_VERIFY_SPACES(dims) \
+{ \
+ /* Open dataspaces \
+ */ \
+ space1_id = H5Dget_space(dset1_id); \
+ CHECK_I(space1_id, "H5Dget_space"); \
+ space2_id = H5Dget_space(dset2_id); \
+ CHECK_I(space2_id, "H5Dget_space"); \
+ space3_id = H5Dget_space(dset3_id); \
+ CHECK_I(space3_id, "H5Dget_space"); \
+ /* Verify dataspaces \
+ */ \
+ ret = H5Sget_simple_extent_dims(space1_id, out_dims, out_maxdims); \
+ CHECK_I(ret, "H5Sget_simple_extent_dims"); \
+ for(x=0; x<EXTEND_NDIMS; ++x) { \
+ VERIFY(out_dims[x], (dims)[0][x], "H5Sget_simple_extent_dims"); \
+ VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims"); \
+ } \
+ ret = H5Sget_simple_extent_dims(space2_id, out_dims, out_maxdims); \
+ CHECK_I(ret, "H5Sget_simple_extent_dims"); \
+ for(x=0; x<EXTEND_NDIMS; ++x) { \
+ VERIFY(out_dims[x], (dims)[1][x], "H5Sget_simple_extent_dims"); \
+ VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims"); \
+ } \
+ ret = H5Sget_simple_extent_dims(space3_id, out_dims, out_maxdims); \
+ CHECK_I(ret, "H5Sget_simple_extent_dims"); \
+ for(x=0; x<EXTEND_NDIMS; ++x) { \
+ VERIFY(out_dims[x], (dims)[2][x], "H5Sget_simple_extent_dims"); \
+ VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims"); \
+ } \
+ /* Close dataspaces \
+ */ \
+ CHECK_I(H5Sclose(space1_id), "H5Sclose"); \
+ CHECK_I(H5Sclose(space2_id), "H5Sclose"); \
+ CHECK_I(H5Sclose(space3_id), "H5Sclose"); \
+} /* define TSOHM_EDH_VERIFY_SPACES */
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * Macro: TSOHM_EDH_CLOSE_REOPEN_FILE_AND_DSETS()
+ *
+ * Purpose: Encapsulate a common pattern
+ * Wrapper to close and reopen file and datasets:
+ * + "dataset" (dset_id)
+ * + if n > 1 then include "dataset2" (dset_id2)
+ * + if n > 2 then include "dataset3" (dset_id3)
+ * + file (file_id)
+ *
+ * Programmer: Jacob Smith
+ * 2018 November 5
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+#define TSOHM_EDH_CLOSE_REOPEN_FILE_AND_DSETS(n) \
+{ \
+ CHECK_I(H5Dclose(dset1_id), "H5Dclose"); \
+ if ((n) > 1) \
+ CHECK_I(H5Dclose(dset2_id), "H5Dclose"); \
+ if ((n) > 2) \
+ CHECK_I(H5Dclose(dset3_id), "H5Dclose"); \
+ CHECK_I(H5Fclose(file_id), "H5Fclose"); \
+ \
+ file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); \
+ CHECK_I(file_id, "H5Fopen"); \
+ dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT); \
+ CHECK_I(dset1_id, "H5Dopen2"); \
+ if ((n) > 1) { \
+ dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT); \
+ CHECK_I(dset2_id, "H5Dopen2"); \
+ } \
+ if ((n) > 2) { \
+ dset3_id = H5Dopen2(file_id, "dataset3", H5P_DEFAULT); \
+ CHECK_I(dset2_id, "H5Dopen2"); \
+ } \
+} /* define TSOHM_EDH_CLOSE_REOPEN_FILE_AND_DSETS */
+
+ /* Remember the current # of reported errors */
old_nerrs = GetTestNumErrs();
- /* Create file */
file_id = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT);
CHECK_I(file_id, "H5Fcreate");
@@ -3257,251 +3590,49 @@ test_sohm_extend_dset_helper(hid_t fcpl_id, hbool_t close_reopen)
CHECK_I(orig_space_id, "H5Screate_simple");
dset1_id = H5Dcreate2(file_id, "dataset", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
CHECK_I(dset1_id, "H5Dcreate2");
-
- if(close_reopen) {
- /* If requested, close all open IDs and reopen them */
- ret = H5Dclose(dset1_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Fclose(file_id);
- CHECK_I(ret, "H5Fclose");
-
- file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
- CHECK_I(file_id, "H5Fopen");
- dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT);
- CHECK_I(dset1_id, "H5Dopen2");
- }
+ if(close_reopen)
+ TSOHM_EDH_CLOSE_REOPEN_FILE_AND_DSETS(1);
/* Create another dataset starting with the same dataspace */
dset2_id = H5Dcreate2(file_id, "dataset2", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
CHECK_I(dset2_id, "H5Dcreate2");
-
- if(close_reopen) {
- /* If requested, close all open IDs and reopen them */
- ret = H5Dclose(dset1_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Dclose(dset2_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Fclose(file_id);
- CHECK_I(ret, "H5Fclose");
-
- file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
- CHECK_I(file_id, "H5Fopen");
- dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT);
- CHECK_I(dset1_id, "H5Dopen2");
- dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT);
- CHECK_I(dset2_id, "H5Dopen2");
- }
+ if (close_reopen)
+ TSOHM_EDH_CLOSE_REOPEN_FILE_AND_DSETS(2);
/* Create a third dataset with the same dataspace */
dset3_id = H5Dcreate2(file_id, "dataset3", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
CHECK_I(dset3_id, "H5Dcreate2");
-
- if(close_reopen) {
- /* If requested, close all open IDs and reopen them */
- ret = H5Dclose(dset1_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Dclose(dset2_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Dclose(dset3_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Fclose(file_id);
- CHECK_I(ret, "H5Fclose");
-
- file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
- CHECK_I(file_id, "H5Fopen");
- dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT);
- CHECK_I(dset1_id, "H5Dopen2");
- dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT);
- CHECK_I(dset2_id, "H5Dopen2");
- dset3_id = H5Dopen2(file_id, "dataset3", H5P_DEFAULT);
- CHECK_I(dset3_id, "H5Dopen2");
- }
+ if (close_reopen)
+ TSOHM_EDH_CLOSE_REOPEN_FILE_AND_DSETS(3);
/* Extend the first dataset */
ret = H5Dset_extent(dset1_id, dims2);
CHECK_I(ret, "H5Dset_extent");
- if(close_reopen) {
- /* If requested, close all open IDs and reopen them */
- ret = H5Dclose(dset1_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Dclose(dset2_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Dclose(dset3_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Fclose(file_id);
- CHECK_I(ret, "H5Fclose");
-
- file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
- CHECK_I(file_id, "H5Fopen");
- dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT);
- CHECK_I(dset1_id, "H5Dopen2");
- dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT);
- CHECK_I(dset2_id, "H5Dopen2");
- dset3_id = H5Dopen2(file_id, "dataset3", H5P_DEFAULT);
- CHECK_I(dset3_id, "H5Dopen2");
- }
+ if (close_reopen)
+ TSOHM_EDH_CLOSE_REOPEN_FILE_AND_DSETS(3);
- /* Get the dataspaces from the datasets */
- space1_id = H5Dget_space(dset1_id);
- CHECK_I(space1_id, "H5Dget_space");
- space2_id = H5Dget_space(dset2_id);
- CHECK_I(space2_id, "H5Dget_space");
- space3_id = H5Dget_space(dset3_id);
- CHECK_I(space3_id, "H5Dget_space");
-
- /* Verify the dataspaces */
- ret = H5Sget_simple_extent_dims(space1_id, out_dims, out_maxdims);
- CHECK_I(ret, "H5Sget_simple_extent_dims");
- for(x=0; x<EXTEND_NDIMS; ++x) {
- VERIFY(out_dims[x], dims2[x], "H5Sget_simple_extent_dims");
- VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims");
- }
-
- ret = H5Sget_simple_extent_dims(space2_id, out_dims, out_maxdims);
- CHECK_I(ret, "H5Sget_simple_extent_dims");
- for(x=0; x<EXTEND_NDIMS; ++x) {
- VERIFY(out_dims[x], dims1[x], "H5Sget_simple_extent_dims");
- VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims");
- }
-
- ret = H5Sget_simple_extent_dims(space3_id, out_dims, out_maxdims);
- CHECK_I(ret, "H5Sget_simple_extent_dims");
- for(x=0; x<EXTEND_NDIMS; ++x) {
- VERIFY(out_dims[x], dims1[x], "H5Sget_simple_extent_dims");
- VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims");
- }
-
- /* Close all three dataspaces */
- ret = H5Sclose(space1_id);
- CHECK_I(ret, "H5Sclose");
- ret = H5Sclose(space2_id);
- CHECK_I(ret, "H5Sclose");
- ret = H5Sclose(space3_id);
- CHECK_I(ret, "H5Sclose");
+ space_dims[0] = dims2;
+ space_dims[1] = dims1;
+ space_dims[2] = dims1;
+ TSOHM_EDH_VERIFY_SPACES(space_dims);
/* Extend the second dataset */
ret = H5Dset_extent(dset2_id, dims2);
CHECK_I(ret, "H5Dset_extent");
- if(close_reopen) {
- /* If requested, close all open IDs and reopen them */
- ret = H5Dclose(dset1_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Dclose(dset2_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Dclose(dset3_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Fclose(file_id);
- CHECK_I(ret, "H5Fclose");
+ if(close_reopen)
+ TSOHM_EDH_CLOSE_REOPEN_FILE_AND_DSETS(3);
- file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
- CHECK_I(file_id, "H5Fopen");
- dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT);
- CHECK_I(dset1_id, "H5Dopen2");
- dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT);
- CHECK_I(dset2_id, "H5Dopen2");
- dset3_id = H5Dopen2(file_id, "dataset3", H5P_DEFAULT);
- CHECK_I(dset3_id, "H5Dopen2");
- }
-
- /* Get the dataspaces from the datasets */
- space1_id = H5Dget_space(dset1_id);
- CHECK_I(space1_id, "H5Dget_space");
- space2_id = H5Dget_space(dset2_id);
- CHECK_I(space2_id, "H5Dget_space");
- space3_id = H5Dget_space(dset3_id);
- CHECK_I(space3_id, "H5Dget_space");
-
- /* Verify the dataspaces */
- ret = H5Sget_simple_extent_dims(space1_id, out_dims, out_maxdims);
- CHECK_I(ret, "H5Sget_simple_extent_dims");
- for(x=0; x<EXTEND_NDIMS; ++x) {
- VERIFY(out_dims[x], dims2[x], "H5Sget_simple_extent_dims");
- VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims");
- }
-
- ret = H5Sget_simple_extent_dims(space2_id, out_dims, out_maxdims);
- CHECK_I(ret, "H5Sget_simple_extent_dims");
- for(x=0; x<EXTEND_NDIMS; ++x) {
- VERIFY(out_dims[x], dims2[x], "H5Sget_simple_extent_dims");
- VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims");
- }
-
- ret = H5Sget_simple_extent_dims(space3_id, out_dims, out_maxdims);
- CHECK_I(ret, "H5Sget_simple_extent_dims");
- for(x=0; x<EXTEND_NDIMS; ++x) {
- VERIFY(out_dims[x], dims1[x], "H5Sget_simple_extent_dims");
- VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims");
- }
-
- /* Close all three dataspaces */
- ret = H5Sclose(space1_id);
- CHECK_I(ret, "H5Sclose");
- ret = H5Sclose(space2_id);
- CHECK_I(ret, "H5Sclose");
- ret = H5Sclose(space3_id);
- CHECK_I(ret, "H5Sclose");
+ space_dims[1] = dims2;
+ TSOHM_EDH_VERIFY_SPACES(space_dims);
/* Extend the third dataset */
ret = H5Dset_extent(dset3_id, dims2);
CHECK_I(ret, "H5Dset_extent");
- if(close_reopen) {
- /* If requested, close all open IDs and reopen them */
- ret = H5Dclose(dset1_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Dclose(dset2_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Dclose(dset3_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Fclose(file_id);
- CHECK_I(ret, "H5Fclose");
-
- file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
- CHECK_I(file_id, "H5Fopen");
- dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT);
- CHECK_I(dset1_id, "H5Dopen2");
- dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT);
- CHECK_I(dset2_id, "H5Dopen2");
- dset3_id = H5Dopen2(file_id, "dataset3", H5P_DEFAULT);
- CHECK_I(dset3_id, "H5Dopen2");
- }
-
- /* Get the dataspaces from the datasets */
- space1_id = H5Dget_space(dset1_id);
- CHECK_I(space1_id, "H5Dget_space");
- space2_id = H5Dget_space(dset2_id);
- CHECK_I(space2_id, "H5Dget_space");
- space3_id = H5Dget_space(dset3_id);
- CHECK_I(space3_id, "H5Dget_space");
-
- /* Verify the dataspaces */
- ret = H5Sget_simple_extent_dims(space1_id, out_dims, out_maxdims);
- CHECK_I(ret, "H5Sget_simple_extent_dims");
- for(x=0; x<EXTEND_NDIMS; ++x) {
- VERIFY(out_dims[x], dims2[x], "H5Sget_simple_extent_dims");
- VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims");
- }
-
- ret = H5Sget_simple_extent_dims(space2_id, out_dims, out_maxdims);
- CHECK_I(ret, "H5Sget_simple_extent_dims");
- for(x=0; x<EXTEND_NDIMS; ++x) {
- VERIFY(out_dims[x], dims2[x], "H5Sget_simple_extent_dims");
- VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims");
- }
+ if(close_reopen)
+ TSOHM_EDH_CLOSE_REOPEN_FILE_AND_DSETS(3);
- ret = H5Sget_simple_extent_dims(space3_id, out_dims, out_maxdims);
- CHECK_I(ret, "H5Sget_simple_extent_dims");
- for(x=0; x<EXTEND_NDIMS; ++x) {
- VERIFY(out_dims[x], dims2[x], "H5Sget_simple_extent_dims");
- VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims");
- }
-
- /* Close all three dataspaces */
- ret = H5Sclose(space1_id);
- CHECK_I(ret, "H5Sclose");
- ret = H5Sclose(space2_id);
- CHECK_I(ret, "H5Sclose");
- ret = H5Sclose(space3_id);
- CHECK_I(ret, "H5Sclose");
+ space_dims[2] = dims2;
+ TSOHM_EDH_VERIFY_SPACES(space_dims);
/* Close the datasets and file */
ret = H5Dclose(dset1_id);
@@ -3523,164 +3654,44 @@ test_sohm_extend_dset_helper(hid_t fcpl_id, hbool_t close_reopen)
CHECK_I(file_id, "H5Fcreate");
dset1_id = H5Dcreate2(file_id, "dataset", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
CHECK_I(dset1_id, "H5Dcreate2");
- if(close_reopen) {
- /* If requested, close all open IDs and reopen them */
- ret = H5Dclose(dset1_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Fclose(file_id);
- CHECK_I(ret, "H5Fclose");
-
- file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
- CHECK_I(file_id, "H5Fopen");
- dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT);
- CHECK_I(dset1_id, "H5Dopen2");
- }
+ if (close_reopen)
+ TSOHM_EDH_CLOSE_REOPEN_FILE_AND_DSETS(1);
/* Extend the first dataset */
ret = H5Dset_extent(dset1_id, dims2);
CHECK_I(ret, "H5Dset_extent");
- if(close_reopen) {
- /* If requested, close all open IDs and reopen them */
- ret = H5Dclose(dset1_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Fclose(file_id);
- CHECK_I(ret, "H5Fclose");
-
- file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
- CHECK_I(file_id, "H5Fopen");
- dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT);
- CHECK_I(dset1_id, "H5Dopen2");
- }
+ if (close_reopen)
+ TSOHM_EDH_CLOSE_REOPEN_FILE_AND_DSETS(1);
/* Create the second dataset. Its dataspace will be unshared and then
* become shared when extended.
*/
dset2_id = H5Dcreate2(file_id, "dataset2", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
CHECK_I(dset2_id, "H5Dcreate2");
- if(close_reopen) {
- /* If requested, close all open IDs and reopen them */
- ret = H5Dclose(dset1_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Dclose(dset2_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Fclose(file_id);
- CHECK_I(ret, "H5Fclose");
-
- file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
- CHECK_I(file_id, "H5Fopen");
- dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT);
- CHECK_I(dset1_id, "H5Dopen2");
- dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT);
- CHECK_I(dset2_id, "H5Dopen2");
- }
+ if (close_reopen)
+ TSOHM_EDH_CLOSE_REOPEN_FILE_AND_DSETS(2);
/* Extend the second dataset */
ret = H5Dset_extent(dset2_id, dims2);
CHECK_I(ret, "H5Dset_extent");
- if(close_reopen) {
- /* If requested, close all open IDs and reopen them */
- ret = H5Dclose(dset1_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Dclose(dset2_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Fclose(file_id);
- CHECK_I(ret, "H5Fclose");
-
- file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
- CHECK_I(file_id, "H5Fopen");
- dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT);
- CHECK_I(dset1_id, "H5Dopen2");
- dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT);
- CHECK_I(dset2_id, "H5Dopen2");
- }
+ if (close_reopen)
+ TSOHM_EDH_CLOSE_REOPEN_FILE_AND_DSETS(2);
/* Create the third dataset. Its dataspace will be unshared and then
* become shared when extended.
*/
dset3_id = H5Dcreate2(file_id, "dataset3", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
CHECK_I(dset3_id, "H5Dcreate2");
- if(close_reopen) {
- /* If requested, close all open IDs and reopen them */
- ret = H5Dclose(dset1_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Dclose(dset2_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Dclose(dset3_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Fclose(file_id);
- CHECK_I(ret, "H5Fclose");
-
- file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
- CHECK_I(file_id, "H5Fopen");
- dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT);
- CHECK_I(dset1_id, "H5Dopen2");
- dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT);
- CHECK_I(dset2_id, "H5Dopen2");
- dset3_id = H5Dopen2(file_id, "dataset3", H5P_DEFAULT);
- CHECK_I(dset3_id, "H5Dopen2");
- }
+ if(close_reopen)
+ TSOHM_EDH_CLOSE_REOPEN_FILE_AND_DSETS(3);
/* Extend the third dataset */
ret = H5Dset_extent(dset3_id, dims2);
CHECK_I(ret, "H5Dset_extent");
- if(close_reopen) {
- /* If requested, close all open IDs and reopen them */
- ret = H5Dclose(dset1_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Dclose(dset2_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Dclose(dset3_id);
- CHECK_I(ret, "H5Dclose");
- ret = H5Fclose(file_id);
- CHECK_I(ret, "H5Fclose");
-
- file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
- CHECK_I(file_id, "H5Fopen");
- dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT);
- CHECK_I(dset1_id, "H5Dopen2");
- dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT);
- CHECK_I(dset2_id, "H5Dopen2");
- dset3_id = H5Dopen2(file_id, "dataset3", H5P_DEFAULT);
- CHECK_I(dset3_id, "H5Dopen2");
- }
+ if(close_reopen)
+ TSOHM_EDH_CLOSE_REOPEN_FILE_AND_DSETS(3);
- /* Get the dataspaces from the datasets */
- space1_id = H5Dget_space(dset1_id);
- CHECK_I(space1_id, "H5Dget_space");
- space2_id = H5Dget_space(dset2_id);
- CHECK_I(space2_id, "H5Dget_space");
- space3_id = H5Dget_space(dset3_id);
- CHECK_I(space3_id, "H5Dget_space");
-
- /* Verify the dataspaces */
- ret = H5Sget_simple_extent_dims(space1_id, out_dims, out_maxdims);
- CHECK_I(ret, "H5Sget_simple_extent_dims");
- for(x=0; x<EXTEND_NDIMS; ++x) {
- VERIFY(out_dims[x], dims2[x], "H5Sget_simple_extent_dims");
- VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims");
- }
-
- ret = H5Sget_simple_extent_dims(space2_id, out_dims, out_maxdims);
- CHECK_I(ret, "H5Sget_simple_extent_dims");
- for(x=0; x<EXTEND_NDIMS; ++x) {
- VERIFY(out_dims[x], dims2[x], "H5Sget_simple_extent_dims");
- VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims");
- }
-
- ret = H5Sget_simple_extent_dims(space3_id, out_dims, out_maxdims);
- CHECK_I(ret, "H5Sget_simple_extent_dims");
- for(x=0; x<EXTEND_NDIMS; ++x) {
- VERIFY(out_dims[x], dims2[x], "H5Sget_simple_extent_dims");
- VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims");
- }
-
- /* Close all three dataspaces */
- ret = H5Sclose(space1_id);
- CHECK_I(ret, "H5Sclose");
- ret = H5Sclose(space2_id);
- CHECK_I(ret, "H5Sclose");
- ret = H5Sclose(space3_id);
- CHECK_I(ret, "H5Sclose");
+ TSOHM_EDH_VERIFY_SPACES(space_dims);
/* Close the datasets and file */
ret = H5Dclose(dset1_id);
@@ -3698,12 +3709,15 @@ test_sohm_extend_dset_helper(hid_t fcpl_id, hbool_t close_reopen)
ret = H5Pclose(dcpl_id);
CHECK_I(ret, "H5Pclose");
- /* Retrieve current # of errors */
+ /* Complain if this test generated errors */
if(old_nerrs == GetTestNumErrs())
return(0);
else
return(-1);
-} /* end test_sohm_extend_dset_helper() */
+/* macros are exclusive to this function */
+#undef TSOHM_EDH_CLOSE_REOPEN_FILE_AND_DSETS
+#undef TSOHM_EDH_VERIFY_SPACES
+} /* verify_dataset_extension */
/*-------------------------------------------------------------------------
@@ -3726,74 +3740,71 @@ test_sohm_extend_dset(void)
hid_t fcpl_id = -1;
herr_t ret;
- /* Create fcpl */
+ MESSAGE(5, ("Testing extending shared dataspaces\n"));
+
fcpl_id = H5Pcreate(H5P_FILE_CREATE);
CHECK_I(fcpl_id, "H5Pcreate");
-
- /* Test extending datasets with different FCPLs */
ret = H5Pset_shared_mesg_nindexes(fcpl_id, 1);
CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
/* No shared messages */
- ret = test_sohm_extend_dset_helper(fcpl_id, FALSE);
- CHECK_I(ret, "test_sohm_extend_dset_helper");
- ret = test_sohm_extend_dset_helper(fcpl_id, TRUE);
- CHECK_I(ret, "test_sohm_extend_dset_helper");
+ ret = verify_dataset_extension(fcpl_id, FALSE);
+ CHECK_I(ret, "verify_dataset_extension");
+ ret = verify_dataset_extension(fcpl_id, TRUE);
+ CHECK_I(ret, "verify_dataset_extension");
/* Only dataspaces */
ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_SDSPACE_FLAG, 16);
CHECK_I(ret, "H5Pset_shared_mesg_index");
- ret = test_sohm_extend_dset_helper(fcpl_id, FALSE);
- CHECK_I(ret, "test_sohm_extend_dset_helper");
- ret = test_sohm_extend_dset_helper(fcpl_id, TRUE);
- CHECK_I(ret, "test_sohm_extend_dset_helper");
+ ret = verify_dataset_extension(fcpl_id, FALSE);
+ CHECK_I(ret, "verify_dataset_extension");
+ ret = verify_dataset_extension(fcpl_id, TRUE);
+ CHECK_I(ret, "verify_dataset_extension");
/* All messages */
- ret = H5Pset_shared_mesg_nindexes(fcpl_id, 1);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ALL_FLAG, 16);
CHECK_I(ret, "H5Pset_shared_mesg_index");
- ret = test_sohm_extend_dset_helper(fcpl_id, FALSE);
- CHECK_I(ret, "test_sohm_extend_dset_helper");
- ret = test_sohm_extend_dset_helper(fcpl_id, TRUE);
- CHECK_I(ret, "test_sohm_extend_dset_helper");
+ ret = verify_dataset_extension(fcpl_id, FALSE);
+ CHECK_I(ret, "verify_dataset_extension");
+ ret = verify_dataset_extension(fcpl_id, TRUE);
+ CHECK_I(ret, "verify_dataset_extension");
/* All messages in lists */
ret = H5Pset_shared_mesg_phase_change(fcpl_id, 100, 50);
CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
- ret = test_sohm_extend_dset_helper(fcpl_id, FALSE);
- CHECK_I(ret, "test_sohm_extend_dset_helper");
- ret = test_sohm_extend_dset_helper(fcpl_id, TRUE);
- CHECK_I(ret, "test_sohm_extend_dset_helper");
+ ret = verify_dataset_extension(fcpl_id, FALSE);
+ CHECK_I(ret, "verify_dataset_extension");
+ ret = verify_dataset_extension(fcpl_id, TRUE);
+ CHECK_I(ret, "verify_dataset_extension");
/* All messages in lists converted to B-trees */
ret = H5Pset_shared_mesg_phase_change(fcpl_id, 1, 0);
CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
- ret = test_sohm_extend_dset_helper(fcpl_id, FALSE);
- CHECK_I(ret, "test_sohm_extend_dset_helper");
- ret = test_sohm_extend_dset_helper(fcpl_id, TRUE);
- CHECK_I(ret, "test_sohm_extend_dset_helper");
+ ret = verify_dataset_extension(fcpl_id, FALSE);
+ CHECK_I(ret, "verify_dataset_extension");
+ ret = verify_dataset_extension(fcpl_id, TRUE);
+ CHECK_I(ret, "verify_dataset_extension");
/* All messages in B-trees */
ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0);
CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
- ret = test_sohm_extend_dset_helper(fcpl_id, FALSE);
- CHECK_I(ret, "test_sohm_extend_dset_helper");
- ret = test_sohm_extend_dset_helper(fcpl_id, TRUE);
- CHECK_I(ret, "test_sohm_extend_dset_helper");
+ ret = verify_dataset_extension(fcpl_id, FALSE);
+ CHECK_I(ret, "verify_dataset_extension");
+ ret = verify_dataset_extension(fcpl_id, TRUE);
+ CHECK_I(ret, "verify_dataset_extension");
ret = H5Pclose(fcpl_id);
CHECK_I(ret, "H5Pclose");
-}
+} /* test_sohm_extend_dset */
/*-------------------------------------------------------------------------
@@ -3827,141 +3838,119 @@ test_sohm_external_dtype(void)
unsigned x, i;
herr_t ret;
+ MESSAGE(5, ("Testing shared external datatype\n"));
+
fcpl = H5Pcreate(H5P_FILE_CREATE);
CHECK_I(fcpl, "H5Pcreate");
-
- /* Set up index values for sohm */
ret = H5Pset_shared_mesg_nindexes(fcpl, TEST_NUM_INDEXES);
CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
-
- for(x=0; x<TEST_NUM_INDEXES; ++x)
- {
+ for(x=0; x<TEST_NUM_INDEXES; ++x) {
ret = H5Pset_shared_mesg_index(fcpl, x, test_type_flags[x], test_minsizes[x]);
CHECK_I(ret, "H5Pset_shared_mesg_index");
}
-
ret = H5Pset_shared_mesg_phase_change(fcpl, TEST_L2B, TEST_B2L);
CHECK_I(ret, "H5Pset_shared_mesg_phase_change");
- /* Create the data space */
space = H5Screate_simple(2, dims, NULL);
CHECK_I(space, "H5Screate_simple");
- /* Create a data type for s1_t */
s1_tid = H5Tcreate(H5T_COMPOUND, sizeof(s1_t));
CHECK_I(s1_tid, "H5Tcreate");
-
ret = H5Tinsert(s1_tid, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT);
CHECK_I(ret, "H5Tinsert");
-
ret = H5Tinsert (s1_tid, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT);
CHECK_I(ret, "H5Tinsert");
- /* Create the first file for this test */
+ /* Set up dataset in first file
+ */
file1 = H5Fcreate(FILENAME_SRC, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT);
CHECK_I(file1, "H5Fcreate");
- /* Check on datatype storage status. It should be zero now. */
ret = H5F_get_sohm_mesg_count_test(file1, H5O_DTYPE_ID, &dmsg_count);
CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
VERIFY(dmsg_count, 0, "H5F_get_sohm_mesg_count_test");
- /* Create data set */
dataset1 = H5Dcreate2(file1, "dataset_1", s1_tid, space, H5P_DEFAULT, H5P_DEFAULT,
H5P_DEFAULT);
CHECK_I(dataset1, "H5Dcreate2");
- /* Check on datatype storage status. It should be 1 now. */
ret = H5F_get_sohm_mesg_count_test(file1, H5O_DTYPE_ID, &dmsg_count);
CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
VERIFY(dmsg_count, 1, "H5F_get_sohm_mesg_count_test");
- /* Retieve the dataset's datatype */
dset1_tid = H5Dget_type(dataset1);
CHECK_I(dset1_tid, "H5Dget_type");
/* Allocate space and initialize data */
orig = (s1_t*)HDmalloc(NX * NY * sizeof(s1_t));
+ if (orig == NULL)
+ CHECK_I(-1, "HDmalloc");
for(i=0; i<NX*NY; i++) {
s_ptr = (s1_t*)orig + i;
s_ptr->a = (int)(i * 3 + 1);
s_ptr->b = (int)(i * 3 + 2);
}
- /* Write the data to the dataset1 */
ret = H5Dwrite(dataset1, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig);
CHECK_I(ret, "H5Dwrite");
-
ret = H5Dclose(dataset1);
CHECK_I(ret, "H5Dclose");
- /* Create the second file for this test */
+ /* Create dataset in second file using datatype from dataset in the first file
+ */
file2 = H5Fcreate(FILENAME_DST, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT);
CHECK_I(file2, "H5Fcreate");
- /* Check on datatype storage status. It should be zero now. */
ret = H5F_get_sohm_mesg_count_test(file2, H5O_DTYPE_ID, &dmsg_count);
CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
VERIFY(dmsg_count, 0, "H5F_get_sohm_mesg_count_test");
- /* Create a data set using the datatype of the dataset in the first file. */
dataset2 = H5Dcreate2(file2, "dataset_2", dset1_tid, space, H5P_DEFAULT, H5P_DEFAULT,
H5P_DEFAULT);
CHECK_I(dataset2, "H5Dcreate2");
- /* Check on datatype storage status. It should be 1 now. */
ret = H5F_get_sohm_mesg_count_test(file2, H5O_DTYPE_ID, &dmsg_count);
CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
VERIFY(dmsg_count, 1, "H5F_get_sohm_mesg_count_test");
- /* Write the data to the dataset2 */
ret = H5Dwrite(dataset2, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig);
CHECK_I(ret, "H5Dwrite");
+ /* Close references to the first file */
ret = H5Dclose(dataset2);
CHECK_I(ret, "H5Dclose");
-
- /* Close file 1 and the dataset's datatype in file 1. Verify that the datatype in
- * file 2 is still accessible. */
ret = H5Tclose(dset1_tid);
CHECK_I(ret, "H5Tclose");
-
ret = H5Fclose(file1);
CHECK_I(ret, "H5Fclose");
- /* Open the dataset in file 2 */
+ /* Verify that datatype details are still accessible by second file
+ */
dataset2 = H5Dopen2(file2, "dataset_2", H5P_DEFAULT);
CHECK_I(dataset2, "H5Dopen2");
- /* Retieve the dataset's datatype */
dset2_tid = H5Dget_type(dataset2);
CHECK_I(dset2_tid, "H5Dget_type");
- /* Verify the datatype is compound */
dtype_class = H5Tget_class(dset2_tid);
VERIFY(dtype_class, H5T_COMPOUND, "H5Tget_class");
+ /* Cleanup
+ */
ret = H5Tclose(dset2_tid);
CHECK_I(ret, "H5Tclose");
-
ret = H5Dclose(dataset2);
CHECK_I(ret, "H5Dclose");
-
- /* Finishing test and release resources */
ret = H5Sclose(space);
CHECK_I(ret, "H5Sclose");
-
ret = H5Tclose(s1_tid);
CHECK_I(ret, "H5Tclose");
-
ret = H5Pclose(fcpl);
CHECK_I(ret, "H5Pclose");
-
ret = H5Fclose(file2);
CHECK_I(ret, "H5Fclose");
-
HDfree(orig);
-}
+} /* test_sohm_external_dtype */
/****************************************************************
@@ -3972,11 +3961,12 @@ test_sohm_external_dtype(void)
void
test_sohm(void)
{
- /* Output message about test being performed */
MESSAGE(5, ("Testing Shared Object Header Messages\n"));
- test_sohm_fcpl(); /* Test SOHMs and file creation plists */
+ test_sohm_fcpl(); /* Test SOHMs and file creation plists */
+ test_sohm_fcpl_errors(); /* Bogus H5P* calls for SOHMs */
test_sohm_size1(); /* Tests the sizes of files with one SOHM */
+ test_sohm_size_consistency_open_create();
test_sohm_attrs(); /* Tests shared messages in attributes */
test_sohm_size2(0); /* Tests the sizes of files with multiple SOHMs */
test_sohm_size2(1); /* Tests the sizes of files with multiple
@@ -3989,17 +3979,17 @@ test_sohm(void)
test_sohm_extend_dset(); /* Test extending shared datasets */
test_sohm_external_dtype(); /* Test using datatype in another file */
-} /* test_sohm() */
+} /* test_sohm */
/*-------------------------------------------------------------------------
- * Function: cleanup_sohm
+ * Function: cleanup_sohm
*
- * Purpose: Cleanup temporary test files
+ * Purpose: Cleanup temporary test files
*
- * Return: none
+ * Return: none
*
- * Programmer: James Laird
+ * Programmer: James Laird
* October 9, 2006
*
* Modifications:
@@ -4012,5 +4002,5 @@ cleanup_sohm(void)
remove(FILENAME);
remove(FILENAME_SRC);
remove(FILENAME_DST);
-}
+} /* cleanup_sohm */