summaryrefslogtreecommitdiffstats
path: root/test/tsohm.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/tsohm.c')
-rw-r--r--test/tsohm.c1783
1 files changed, 825 insertions, 958 deletions
diff --git a/test/tsohm.c b/test/tsohm.c
index d00a03a..93ba14f 100644
--- a/test/tsohm.c
+++ b/test/tsohm.c
@@ -178,40 +178,41 @@ static void test_sohm_extlink(void);
/****************************************************************
**
-** check_fcpl_values(): Helper function for test_sohm_fcpl.
+** verify_fcpl_values(): Helper function for test_sohm_fcpl.
** Verifies that the *_in and *_out parameters are equal.
**
****************************************************************/
-static void check_fcpl_values(hid_t fcpl_id, const unsigned nindexes_in,
- const unsigned *flags_in, const unsigned *minsizes_in,
+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 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);
+ VERIFY(nindexes_actual, nindexes_expected, "H5Pget_shared_mesg_nindexes");
+ /* 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,7 +220,8 @@ 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;
@@ -227,14 +229,12 @@ static void test_sohm_fcpl(void)
unsigned x;
herr_t ret; /* Generic return value */
- /* 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 +245,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 +261,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 +287,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 +295,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 +311,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,6 +319,72 @@ static void test_sohm_fcpl(void)
ret = H5Fclose(fid);
CHECK_I(ret, "H5Fclose");
+ /* 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 */
+
+
+
+/****************************************************************
+**
+** 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);
+
/* Test giving bogus values to H5P* functions */
H5E_BEGIN_TRY {
/* Trying to create too many indexes should fail */
@@ -370,40 +432,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 +484,8 @@ error:
H5Tclose(dtype1_id);
} H5E_END_TRY
return -1;
-}
+} /* make_dtype_1 */
+
/*-------------------------------------------------------------------------
* Function: make_dtype_2
@@ -518,9 +548,9 @@ error:
H5Tclose(int_id);
} H5E_END_TRY
return -1;
-}
-
+} /* make_dtype2 */
+
/*-------------------------------------------------------------------------
* Function: close_reopen_file
*
@@ -540,16 +570,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 +587,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 +600,7 @@ 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 +610,32 @@ 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.
*/
@@ -614,96 +669,55 @@ size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_clos
/* 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
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 +731,42 @@ 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
@@ -727,17 +776,26 @@ size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_clos
* Programmer: James Laird
* Monday, April 10, 2006
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
-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 +805,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,7 +816,6 @@ 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");
@@ -765,169 +823,97 @@ static void test_sohm_size1(void)
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");
+ /* ----------------------------------------
+ * 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 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;
+ /* size of empty file */
+ file_sizes[size_index++] = h5_get_file_size(FILENAME, fapl_id);
- /* Get the new file size */
- sohm_final_filesize = 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;
- /* 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");
+ } /* for btree/listed messages */
+ } /* for normal/shared messages */
- 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");
-
- /* 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");
+ /* sanity-check state of arrays */
+ VERIFY(9, size_index, "size_index");
+ VERIFY(3, oh_size_index, "oh_size_index");
- 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 */
+#if 0 /* TBD: lying comment or bug. See Jira HDFFV-10646 */
/* 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");
+#endif /* Jira HDFFV-10646 */
/* 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
@@ -950,15 +936,118 @@ static void test_sohm_size1(void)
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 +1055,110 @@ 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
*
*-------------------------------------------------------------------------
*/
-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
+ /* loop:
+ * 0 - nothing special
+ * 1 - committed datatype
+ * 2 - committed datatype, read through second ID
*/
- /* 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");
+ 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;
- /* 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");
+ /* 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");
- /* Cleanup */
- ret = H5Aclose(attr_id);
- CHECK_I(ret, "H5Aclose");
+ type_id = H5Tcopy(H5T_NATIVE_INT);
+ CHECK_I(type_id, "H5Tcopy");
- /*----------------------------------------------------------------------------
- * 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");
+ /* 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 */
/*-------------------------------------------------------------------------
@@ -1125,101 +1175,160 @@ static void sohm_attr_helper(hid_t fcpl_id)
*
*-------------------------------------------------------------------------
*/
-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);
-
-
- /* 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);
+ ret = H5Pclose(fcpl_id);
+ CHECK_I(ret, "H5Pclose");
- /* 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");
+ /* 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);
+ sohm_attr_helper(fcpl_id);
+ ret = H5Pclose(fcpl_id);
+ CHECK_I(ret, "H5Pclose");
+ }
- /* 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");
+ /* 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");
- sohm_attr_helper(fcpl_id);
+ 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");
+ ret = H5Pclose(fcpl_id);
+ CHECK_I(ret, "H5Pclose");
+ }
- sohm_attr_helper(fcpl_id);
+ /* 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;
- ret = H5Pset_shared_mesg_index(fcpl_id, 1, H5O_SHMESG_ATTR_FLAG, 2);
- CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
+ /* 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);
+ sohm_attr_helper(fcpl_id);
+ ret = H5Pclose(fcpl_id);
+ CHECK_I(ret, "H5Pclose");
+ }
- /* 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");
+#undef TSOHM_TSA_NFLAGS_1
+#undef TSOHM_TSA_NFLAGS_2
+#undef TSOHM_TSA_NFLAGS_3
- sohm_attr_helper(fcpl_id);
+} /* test_sohm_attrs */
- /* Close the FCPL */
- ret = H5Pclose(fcpl_id);
- CHECK_I(ret, "H5Pclose");
-}
/*-------------------------------------------------------------------------
* Function: size2_verify_plist1
@@ -1233,7 +1342,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;
@@ -1281,7 +1391,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 +1406,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;
@@ -1352,7 +1464,7 @@ static void size2_verify_plist2(hid_t plist)
ret = H5Tclose(dtype2_id);
CHECK_I(ret, "H5Tclose");
-}
+} /* size2_verify_plist2 */
#ifdef NOT_NOW
@@ -1382,7 +1494,7 @@ size2_dump_struct(const char *name, size2_helper_struct *sizes)
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 */
@@ -1573,15 +1685,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");
@@ -1604,7 +1715,7 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size
group_id = H5Gopen2(file_id, "group", H5P_DEFAULT);
CHECK_I(group_id, "H5Gopen2");
}
- }
+ } /* for each dataset */
/* Close file and get its size now */
ret = H5Gclose(group_id);
@@ -1621,8 +1732,7 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size
CHECK_I(group_id, "H5Gcreate2");
/* Create NUM_DATASETS datasets in the new group */
- for(x=0; x<NUM_DATASETS; x+=2)
- {
+ for(x=0; x<NUM_DATASETS; x+=2) {
dset_id = H5Dcreate2(group_id, DSETNAME[x], dtype1_id, dspace1_id, H5P_DEFAULT, dcpl1_id, H5P_DEFAULT);
CHECK_I(dset_id, "H5Dcreate2");
@@ -1658,7 +1768,7 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size
group_id = H5Gopen2(file_id, "interleaved group", H5P_DEFAULT);
CHECK_I(group_id, "H5Gopen2");
}
- }
+ } /* for each even dataset */
/* Close file and get its size now */
ret = H5Gclose(group_id);
@@ -1700,7 +1810,7 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size
group_id = H5Gopen2(file_id, "group", H5P_DEFAULT);
CHECK_I(group_id, "H5Gopen2");
}
- }
+ } /* for each attribute */
/* Close file and get its size now */
ret = H5Gclose(group_id);
@@ -1716,8 +1826,7 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size
group_id = H5Gopen2(file_id, "interleaved group", H5P_DEFAULT);
CHECK_I(group_id, "H5Gopen2");
- for(x=0; x<NUM_ATTRIBUTES; ++x)
- {
+ for(x=0; x<NUM_ATTRIBUTES; ++x) {
/* Create the same name and value for each attribute as before */
attr_string1[0] = attr_name[0] = (char)((x / 10) + '0');
attr_string1[1] = attr_name[1] = (char)((x % 10) + '0');
@@ -1740,7 +1849,8 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size
group_id = H5Gopen2(file_id, "interleaved group", H5P_DEFAULT);
CHECK_I(group_id, "H5Gopen2");
}
- }
+ } /* for each attribute */
+
/* Close file and get its size now */
ret = H5Gclose(group_id);
CHECK_I(ret, "H5Gclose");
@@ -1768,7 +1878,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 +1895,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;
@@ -1957,7 +2068,7 @@ static void size2_verify(void)
CHECK_I(attr1_id, "H5Aclose");
ret = H5Aclose(attr2_id);
CHECK_I(attr2_id, "H5Aclose");
- }
+ } /* for each attribute */
/* Close everything */
ret = H5Tclose(attr_type_id);
@@ -1968,7 +2079,7 @@ static void size2_verify(void)
CHECK_I(ret, "H5Gclose");
ret = H5Fclose(file_id);
CHECK_I(ret, "H5Fclose");
-}
+} /* size2_verify */
/*-------------------------------------------------------------------------
@@ -1993,7 +2104,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 +2697,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() */
+} /* end test_sohm_size2() */
/*-------------------------------------------------------------------------
@@ -2601,27 +2713,24 @@ 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;
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);
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);
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);
CHECK_I(attr_id, "H5Acreate2");
- /* Write to attribute */
ret = H5Awrite(attr_id, H5T_NATIVE_CHAR, &wdata);
CHECK_I(ret, "H5Awrite");
@@ -2629,7 +2738,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,28 +2754,25 @@ 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);
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");
@@ -2677,7 +2783,7 @@ static void delete_helper_read(hid_t file_id, hid_t *dspace_id, int x)
CHECK_I(ret, "H5Aclose");
ret = H5Dclose(dset_id);
CHECK_I(ret, "H5Dclose");
-}
+} /* delete_helper_read */
/*-------------------------------------------------------------------------
@@ -2701,7 +2807,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 +2872,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 +2906,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.
*/
@@ -2914,13 +3023,14 @@ test_sohm_delete(void)
/*-------------------------------------------------------------------------
- * 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 +3040,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 +3127,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 +3149,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 +3162,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 +3180,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 +3195,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 +3204,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 +3226,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 +3278,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 +3300,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 +3309,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 +3335,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;
@@ -3239,10 +3351,95 @@ test_sohm_extend_dset_helper(hid_t fcpl_id, hbool_t close_reopen)
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_VDE_VERIFY_SPACES
+ *
+ * Purpose: Encapsulate a common pattern
+ * Open, read-verify, and close the dataspaces for datasets 1-3
+ *
+ * Programmer: Jacob Smith
+ * 2018 November 5
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+#define TSOHM_VDE_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_VDE_VERIFY_SPACES */
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * Macro: TSOHM_VDE_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_VDE_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(dset3_id, "H5Dopen2"); \
+ } \
+} /* define TSOHM_VDE_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");
@@ -3258,250 +3455,52 @@ test_sohm_extend_dset_helper(hid_t fcpl_id, hbool_t close_reopen)
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_VDE_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_VDE_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_VDE_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");
- }
-
- /* 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");
- }
+ if(close_reopen)
+ TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(3);
- /* 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_VDE_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");
-
- 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_VDE_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], 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_VDE_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");
- }
+ if(close_reopen)
+ TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(3);
- 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");
+ space_dims[2] = dims2;
+ TSOHM_VDE_VERIFY_SPACES(space_dims);
/* Close the datasets and file */
ret = H5Dclose(dset1_id);
@@ -3523,164 +3522,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_VDE_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_VDE_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_VDE_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_VDE_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_VDE_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");
- }
-
- /* 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");
- }
+ if (close_reopen)
+ TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(3);
- /* 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_VDE_VERIFY_SPACES(space_dims);
/* Close the datasets and file */
ret = H5Dclose(dset1_id);
@@ -3698,12 +3577,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 */
+ /* Complaini 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_VDE_CLOSE_REOPEN_FILE_AND_DSETS
+#undef TSOHM_VDE_VERIFY_SPACES
+} /* verify_dataset_extension */
/*-------------------------------------------------------------------------
@@ -3726,7 +3608,8 @@ 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");
@@ -3735,20 +3618,20 @@ test_sohm_extend_dset(void)
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);
@@ -3756,44 +3639,44 @@ test_sohm_extend_dset(void)
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,37 +3710,30 @@ 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");
@@ -3866,7 +3742,6 @@ test_sohm_external_dtype(void)
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");
@@ -3876,26 +3751,25 @@ test_sohm_external_dtype(void)
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");
@@ -3904,7 +3778,6 @@ test_sohm_external_dtype(void)
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");
@@ -3914,30 +3787,25 @@ test_sohm_external_dtype(void)
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");
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");
@@ -3947,21 +3815,17 @@ test_sohm_external_dtype(void)
ret = H5Dclose(dataset2);
CHECK_I(ret, "H5Dclose");
- /* Finishing test and release resources */
+ /* Cleanup */
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 +3836,14 @@ 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_errors(); /* Bogus H5P* calls for SOHMs */
test_sohm_size1(); /* Tests the sizes of files with one SOHM */
+#if 0 /* TODO: REVEALS BUG TO BE FIXED - SEE JIRA HDFFV-10645 */
+ test_sohm_size_consistency_open_create();
+#endif /* Jira HDFFV-10645 */
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
@@ -4012,5 +3879,5 @@ cleanup_sohm(void)
remove(FILENAME);
remove(FILENAME_SRC);
remove(FILENAME_DST);
-}
+} /* cleanup_sohm */