summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2013-03-25 15:25:22 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2013-03-25 15:25:22 (GMT)
commitdbdedfdd2e5812b3c1d97e2f1f7361684db2d8e4 (patch)
tree963a5b4952cbb88253df8850d1cc19d70b6f614c /test
parentebb80dbae183e75ccf90f899f3ee1491946f93ec (diff)
parent6e1122dda4e446f6e9ad9ce4a9c2da8d40e441e3 (diff)
downloadhdf5-dbdedfdd2e5812b3c1d97e2f1f7361684db2d8e4.zip
hdf5-dbdedfdd2e5812b3c1d97e2f1f7361684db2d8e4.tar.gz
hdf5-dbdedfdd2e5812b3c1d97e2f1f7361684db2d8e4.tar.bz2
[svn-r23443] merged from trunk
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt20
-rw-r--r--test/Makefile.in2
-rw-r--r--test/accum.c22
-rw-r--r--test/dsets.c1028
-rw-r--r--test/stab.c9
-rw-r--r--test/testframe.c4
-rw-r--r--test/testhdf5.h2
-rw-r--r--test/testlibinfo.sh.in5
-rw-r--r--test/tfile.c23
-rw-r--r--test/th5o.c4
-rw-r--r--test/th5s.c11
-rw-r--r--test/tsohm.c14
-rw-r--r--test/vfd.c219
13 files changed, 1234 insertions, 129 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index aa92371..6af1e94 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -223,8 +223,24 @@ ADD_TEST (
tsohm_dst.h5
tsohm_src.h5
)
-ADD_TEST (NAME testhdf5 COMMAND $<TARGET_FILE:testhdf5>)
-SET_TESTS_PROPERTIES(testhdf5 PROPERTIES DEPENDS h5test-clear-testhdf5-objects)
+
+IF (HDF5_ENABLE_USING_MEMCHECKER)
+ ADD_TEST (NAME testhdf5-base COMMAND $<TARGET_FILE:testhdf5> -x heap -x file -x select)
+ SET_TESTS_PROPERTIES(testhdf5-base PROPERTIES DEPENDS h5test-clear-testhdf5-objects)
+ SET_TESTS_PROPERTIES(testhdf5-base PROPERTIES ENVIRONMENT HDF5_ALARM_SECONDS=3600)
+ ADD_TEST (NAME testhdf5-heap COMMAND $<TARGET_FILE:testhdf5> -o heap)
+ SET_TESTS_PROPERTIES(testhdf5-heap PROPERTIES DEPENDS h5test-clear-testhdf5-objects)
+ SET_TESTS_PROPERTIES(testhdf5-heap PROPERTIES ENVIRONMENT HDF5_ALARM_SECONDS=3600)
+ ADD_TEST (NAME testhdf5-file COMMAND $<TARGET_FILE:testhdf5> -o file)
+ SET_TESTS_PROPERTIES(testhdf5-file PROPERTIES DEPENDS h5test-clear-testhdf5-objects)
+ SET_TESTS_PROPERTIES(testhdf5-file PROPERTIES ENVIRONMENT HDF5_ALARM_SECONDS=3600)
+ ADD_TEST (NAME testhdf5-select COMMAND $<TARGET_FILE:testhdf5> -o select)
+ SET_TESTS_PROPERTIES(testhdf5-select PROPERTIES DEPENDS h5test-clear-testhdf5-objects)
+ SET_TESTS_PROPERTIES(testhdf5-select PROPERTIES ENVIRONMENT HDF5_ALARM_SECONDS=3600)
+ELSE (HDF5_ENABLE_USING_MEMCHECKER)
+ ADD_TEST (NAME testhdf5 COMMAND $<TARGET_FILE:testhdf5>)
+ SET_TESTS_PROPERTIES(testhdf5 PROPERTIES DEPENDS h5test-clear-testhdf5-objects)
+ENDIF (HDF5_ENABLE_USING_MEMCHECKER)
##############################################################################
##############################################################################
diff --git a/test/Makefile.in b/test/Makefile.in
index 6632526..e736e59 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -585,6 +585,7 @@ H5_VERSION = @H5_VERSION@
HADDR_T = @HADDR_T@
HAVE_DMALLOC = @HAVE_DMALLOC@
HAVE_FORTRAN_2003 = @HAVE_FORTRAN_2003@
+HAVE_PTHREAD = @HAVE_PTHREAD@
HDF5_HL = @HDF5_HL@
HDF5_INTERFACES = @HDF5_INTERFACES@
HDF_CXX = @HDF_CXX@
@@ -636,7 +637,6 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PARALLEL = @PARALLEL@
PATH_SEPARATOR = @PATH_SEPARATOR@
PERL = @PERL@
-PTHREAD = @PTHREAD@
RANLIB = @RANLIB@
ROOT = @ROOT@
RUNPARALLEL = @RUNPARALLEL@
diff --git a/test/accum.c b/test/accum.c
index 7f65151..c170388 100644
--- a/test/accum.c
+++ b/test/accum.c
@@ -470,8 +470,11 @@ test_free(void)
if(HDmemcmp(expect + 76, rbuf, 116 * sizeof(int32_t)) != 0) TEST_ERROR;
HDfree(wbuf);
+ wbuf = NULL;
HDfree(rbuf);
+ rbuf = NULL;
HDfree(expect);
+ expect = NULL;
if(accum_reset() < 0) FAIL_STACK_ERROR;
@@ -480,9 +483,12 @@ test_free(void)
return 0;
error:
- HDfree(wbuf);
- HDfree(rbuf);
- HDfree(expect);
+ if(wbuf)
+ HDfree(wbuf);
+ if(rbuf)
+ HDfree(rbuf);
+ if(expect)
+ HDfree(expect);
return 1;
} /* test_free */
@@ -1646,7 +1652,7 @@ unsigned
test_random_write(void)
{
uint8_t *wbuf, *rbuf; /* Buffers for reading & writing */
- unsigned long seed = 0; /* Random # seed */
+ unsigned seed = 0; /* Random # seed */
size_t *off; /* Offset of buffer segments to write */
size_t *len; /* Size of buffer segments to write */
size_t cur_off; /* Current offset */
@@ -1667,10 +1673,10 @@ test_random_write(void)
TESTING("random writes to accumulator");
/* Choose random # seed */
- seed = (unsigned long)HDtime(NULL);
+ seed = (unsigned)HDtime(NULL);
#ifdef QAK
-/* seed = (unsigned long)1155438845; */
-HDfprintf(stderr, "Random # seed was: %lu\n", seed);
+/* seed = (unsigned)1155438845; */
+HDfprintf(stderr, "Random # seed was: %u\n", seed);
#endif /* QAK */
HDsrandom(seed);
@@ -1762,7 +1768,7 @@ error:
HDfree(off);
HDfree(len);
- HDfprintf(stderr, "Random # seed was: %lu\n", seed);
+ HDfprintf(stderr, "Random # seed was: %u\n", seed);
return 1;
} /* end test_random_write() */
diff --git a/test/dsets.c b/test/dsets.c
index 838ef48..7abe818 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -8181,6 +8181,1028 @@ error:
/*-------------------------------------------------------------------------
+ * Function: test_scatter
+ *
+ * Purpose: Tests H5Dscatter with a variety of different selections
+ * and source buffer sizes.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Neil Fortner
+ * Wednesday, January 16, 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+typedef struct scatter_info_t {
+ int *src_buf; /* Source data buffer */
+ size_t block; /* Maximum number of elements to return to H5Dscatter() */
+ size_t size; /* Remaining number of elements to return */
+} scatter_info_t;
+
+#define TEST_SCATTER_CHECK_ARR(ARR, EXP) \
+ for(i=0; i<(int)(sizeof(ARR)/sizeof(ARR[0])); i++) \
+ for(j=0; j<(int)(sizeof(ARR[0])/sizeof(ARR[0][0])); j++) \
+ for(k=0; k<(int)(sizeof(ARR[0][0])/sizeof(ARR[0][0][0])); k++) \
+ if(ARR[i][j][k] != EXP[i][j][k]) { \
+ H5_FAILED(); AT(); \
+ printf(" " #ARR "[%d][%d][%d] == %d, " #EXP "[%d][%d][%d] == %d\n", i, j, k, ARR[i][j][k], i, j, k, EXP[i][j][k]); \
+ goto error; \
+ }
+
+static herr_t
+scatter_cb(void **src_buf/*out*/, size_t *src_buf_bytes_used/*out*/,
+ void *_scatter_info)
+{
+ scatter_info_t *scatter_info = (scatter_info_t *)_scatter_info;
+ size_t nelmts; /* Number of elements to return in src_buf */
+
+ /* Calculate number of elements */
+ nelmts = MIN(scatter_info->block, scatter_info->size);
+ HDassert(nelmts > 0);
+
+ /* Set output variables */
+ *src_buf = (void *)scatter_info->src_buf;
+ *src_buf_bytes_used = nelmts * sizeof(scatter_info->src_buf[0]);
+
+ /* Update scatter_info */
+ scatter_info->src_buf += nelmts;
+ scatter_info->size -= nelmts;
+
+ return SUCCEED;
+}
+
+static herr_t
+test_scatter(void)
+{
+ hid_t sid = -1; /* Dataspace ID */
+ hsize_t dim[3] = {8, 5, 8}; /* Dataspace dimensions */
+ hsize_t start[3] = {0, 0, 0};
+ hsize_t stride[3] = {0, 0, 0};
+ hsize_t count[3] = {0, 0, 0};
+ hsize_t block[3] = {0, 0, 0};
+ hsize_t start2[3] = {0, 0, 0};
+ hsize_t count2[3] = {0, 0, 0};
+ hsize_t point[4][3] = {{2, 3, 2}, {3, 0, 2}, {7, 2, 0}, {0, 1, 5}};
+ size_t src_buf_size;
+ int src_buf[36]; /* Source data buffer */
+ int dst_buf[8][5][8]; /* Destination data buffer */
+ int expect_dst_buf[8][5][8]; /* Expected destination data buffer */
+ scatter_info_t scatter_info; /* Operator data for callback */
+ int i, j, k, src_i; /* Local index variables */
+
+ TESTING("H5Dscatter()");
+
+ /* Create dataspace */
+ if((sid = H5Screate_simple(3, dim, NULL)) < 0) TEST_ERROR
+
+ /* Initialize src_buf */
+ for(i=0; i<(int)(sizeof(src_buf)/sizeof(src_buf[0])); i++)
+ src_buf[i] = i + 1;
+
+
+ /*
+ * Test 1: Simple case
+ */
+ /* Select hyperslab */
+ count[0] = 1;
+ count[1] = 1;
+ count[2] = 8;
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL ,count, NULL) < 0)
+ TEST_ERROR
+
+ /* Initialize dst_buf and expect_dst_buf */
+ (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf));
+ for(i=0; i<8; i++)
+ expect_dst_buf[0][0][i] = src_buf[i];
+
+ /* Loop over buffer sizes */
+ for(src_buf_size=1; src_buf_size<=9; src_buf_size++) {
+ /* Reset dst_buf */
+ (void)HDmemset(dst_buf, 0, sizeof(dst_buf));
+
+ /* Set up scatter info */
+ scatter_info.src_buf = src_buf;
+ scatter_info.block = src_buf_size;
+ scatter_info.size = 8;
+
+ /* Scatter data */
+ if(H5Dscatter(scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf) < 0)
+ TEST_ERROR
+
+ /* Verify data */
+ TEST_SCATTER_CHECK_ARR(dst_buf, expect_dst_buf)
+ } /* end for */
+
+
+ /*
+ * Test 2: Single block in dataset
+ */
+ /* Select hyperslab */
+ start[0] = 3;
+ start[1] = 2;
+ start[2] = 4;
+ count[0] = 2;
+ count[1] = 3;
+ count[2] = 2;
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL ,count, NULL) < 0)
+ TEST_ERROR
+
+ /* Initialize expect_dst_buf */
+ (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf));
+ src_i = 0;
+ for(i=3; i<5; i++)
+ for(j=2; j<5; j++)
+ for(k=4; k<6; k++)
+ expect_dst_buf[i][j][k] = src_buf[src_i++];
+
+ /* Loop over buffer sizes */
+ for(src_buf_size=1; src_buf_size<=13; src_buf_size++) {
+ /* Reset dst_buf */
+ (void)HDmemset(dst_buf, 0, sizeof(dst_buf));
+
+ /* Set up scatter info */
+ scatter_info.src_buf = src_buf;
+ scatter_info.block = src_buf_size;
+ scatter_info.size = 12;
+
+ /* Scatter data */
+ if(H5Dscatter(scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf) < 0)
+ TEST_ERROR
+
+ /* Verify data */
+ TEST_SCATTER_CHECK_ARR(dst_buf, expect_dst_buf)
+ } /* end for */
+
+
+ /*
+ * Test 3: Multiple blocks
+ */
+ /* Select hyperslab */
+ start[0] = 1;
+ start[1] = 1;
+ start[2] = 1;
+ stride[0] = 3;
+ stride[1] = 4;
+ stride[2] = 5;
+ count[0] = 3;
+ count[1] = 1;
+ count[2] = 2;
+ block[0] = 1;
+ block[1] = 3;
+ block[2] = 2;
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride ,count, block) < 0)
+ TEST_ERROR
+
+ /* Initialize expect_dst_buf */
+ /* Iterate over block containing selection, checking if each element is in
+ * selection. Note that the algorithm used here (if statement) would not
+ * work for overlapping hyperslabs. */
+ (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf));
+ src_i = 0;
+ for(i=1; i<8; i++)
+ for(j=1; j<4; j++)
+ for(k=1; k<8; k++)
+ if((hsize_t)i >= start[0]
+ && ((hsize_t)i - start[0]) % stride[0] < block[0]
+ && ((hsize_t)i - start[0]) / stride[0] < count[0]
+ && (hsize_t)j >= start[1]
+ && ((hsize_t)j - start[1]) % stride[1] < block[1]
+ && ((hsize_t)j - start[1]) / stride[1] < count[1]
+ && (hsize_t)k >= start[2]
+ && ((hsize_t)k - start[2]) % stride[2] < block[2]
+ && ((hsize_t)k - start[2]) / stride[2] < count[2])
+ expect_dst_buf[i][j][k] = src_buf[src_i++];
+
+ /* Loop over buffer sizes */
+ for(src_buf_size=1; src_buf_size<=37; src_buf_size++) {
+ /* Reset dst_buf */
+ (void)HDmemset(dst_buf, 0, sizeof(dst_buf));
+
+ /* Set up scatter info */
+ scatter_info.src_buf = src_buf;
+ scatter_info.block = src_buf_size;
+ scatter_info.size = 36;
+
+ /* Scatter data */
+ if(H5Dscatter(scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf) < 0)
+ TEST_ERROR
+
+ /* Verify data */
+ TEST_SCATTER_CHECK_ARR(dst_buf, expect_dst_buf)
+ } /* end for */
+
+
+ /*
+ * Test 4: Compound selection
+ */
+ /* Select hyperslabs */
+ start[0] = 2;
+ start[1] = 1;
+ start[2] = 1;
+ count[0] = 2;
+ count[1] = 3;
+ count[2] = 2;
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL ,count, NULL) < 0)
+ TEST_ERROR
+ start2[0] = 1;
+ start2[1] = 2;
+ start2[2] = 2;
+ count2[0] = 3;
+ count2[1] = 2;
+ count2[2] = 2;
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_XOR, start2, NULL ,count2, NULL) < 0)
+ TEST_ERROR
+
+ /* Initialize expect_dst_buf */
+ /* Iterate over block containing selection, checking if each element is in
+ * selection. */
+ (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf));
+ src_i = 0;
+ for(i=1; i<4; i++)
+ for(j=1; j<4; j++)
+ for(k=1; k<4; k++)
+ if(!(((hsize_t)i >= start[0] && (hsize_t)i < start[0] + count[0])
+ && ((hsize_t)j >= start[1] && (hsize_t)j < start[1] + count[1])
+ && ((hsize_t)k >= start[2] && (hsize_t)k < start[2] + count[2]))
+ != !(((hsize_t)i >= start2[0] && (hsize_t)i < start2[0] + count2[0])
+ && ((hsize_t)j >= start2[1] && (hsize_t)j < start2[1] + count2[1])
+ && ((hsize_t)k >= start2[2] && (hsize_t)k < start2[2] + count2[2])))
+ expect_dst_buf[i][j][k] = src_buf[src_i++];
+
+ /* Loop over buffer sizes */
+ for(src_buf_size=1; src_buf_size<=17; src_buf_size++) {
+ /* Reset dst_buf */
+ (void)HDmemset(dst_buf, 0, sizeof(dst_buf));
+
+ /* Set up scatter info */
+ scatter_info.src_buf = src_buf;
+ scatter_info.block = src_buf_size;
+ scatter_info.size = 16;
+
+ /* Scatter data */
+ if(H5Dscatter(scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf) < 0)
+ TEST_ERROR
+
+ /* Verify data */
+ TEST_SCATTER_CHECK_ARR(dst_buf, expect_dst_buf)
+ } /* end for */
+
+
+ /*
+ * Test 5: Point selection
+ */
+ /* Select hyperslabs */
+ if(H5Sselect_elements(sid, H5S_SELECT_SET, sizeof(point) / sizeof(point[0]), (hsize_t *)point) < 0)
+ TEST_ERROR
+
+ /* Initialize expect_dst_buf */
+ /* Iterate over block containing selection, checking if each element is in
+ * selection. */
+ (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf));
+ for(i=0; i<(int)(sizeof(point) / sizeof(point[0])); i++)
+ expect_dst_buf[point[i][0]][point[i][1]][point[i][2]]
+ = src_buf[i];
+
+ /* Loop over buffer sizes */
+ for(src_buf_size=1; src_buf_size<=5; src_buf_size++) {
+ /* Reset dst_buf */
+ (void)HDmemset(dst_buf, 0, sizeof(dst_buf));
+
+ /* Set up scatter info */
+ scatter_info.src_buf = src_buf;
+ scatter_info.block = src_buf_size;
+ scatter_info.size = 4;
+
+ /* Scatter data */
+ if(H5Dscatter(scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf) < 0)
+ TEST_ERROR
+
+ /* Verify data */
+ TEST_SCATTER_CHECK_ARR(dst_buf, expect_dst_buf)
+ } /* end for */
+
+
+ /* Close everything */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ PASSED();
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Sclose(sid);
+ } H5E_END_TRY;
+ return -1;
+} /* end test_scatter() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_gather
+ *
+ * Purpose: Tests H5Dgather with a variety of different selections and
+ * destination buffer sizes.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Neil Fortner
+ * Wednesday, January 16, 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+typedef struct gather_info_t {
+ int *expect_dst_buf; /* Expected destination data buffer */
+ size_t max_nelmts; /* Maximum number of elements passed to callback */
+ hbool_t last_call; /* Whether this should be the last time the callback is called */
+} gather_info_t;
+
+static herr_t
+gather_cb(const void *dst_buf, size_t dst_buf_bytes_used,
+ void *_gather_info)
+{
+ gather_info_t *gather_info = (gather_info_t *)_gather_info;
+ size_t nelmts; /* Number of elements in src_buf */
+ int i; /* Local index variable */
+
+ HDassert(dst_buf_bytes_used > 0);
+
+ /* Calculate number of elements */
+ nelmts = dst_buf_bytes_used / sizeof(gather_info->expect_dst_buf[0]);
+
+ /* Make sure the number of bytes is a multiple of the number of elements */
+ if(nelmts * sizeof(gather_info->expect_dst_buf[0]) != dst_buf_bytes_used)
+ TEST_ERROR
+
+ /* Make sure we weren't passed more data than we requested to be passed at
+ * once */
+ if(nelmts > gather_info->max_nelmts)
+ TEST_ERROR
+
+ /* If we were passed less data than requested, make sure this is the last
+ * time the callback was called */
+ if(gather_info->last_call)
+ TEST_ERROR
+ if(nelmts < gather_info->max_nelmts)
+ gather_info->last_call = TRUE;
+
+ /* Compare data and expected data */
+ for(i=0; i<(int)nelmts; i++)
+ if(((const int *)dst_buf)[i] != *((gather_info->expect_dst_buf)++))
+ TEST_ERROR
+
+ return SUCCEED;
+
+error:
+ return FAIL;
+}
+
+static herr_t
+test_gather(void)
+{
+ hid_t sid = -1; /* Dataspace ID */
+ hsize_t dim[3] = {8, 5, 8}; /* Dataspace dimensions */
+ hsize_t start[3] = {0, 0, 0};
+ hsize_t stride[3] = {0, 0, 0};
+ hsize_t count[3] = {0, 0, 0};
+ hsize_t block[3] = {0, 0, 0};
+ hsize_t start2[3] = {0, 0, 0};
+ hsize_t count2[3] = {0, 0, 0};
+ hsize_t point[4][3] = {{2, 3, 2}, {3, 0, 2}, {7, 2, 0}, {0, 1, 5}};
+ size_t dst_buf_size;
+ int src_buf[8][5][8]; /* Source data buffer */
+ int dst_buf[36]; /* Destination data buffer */
+ int expect_dst_buf[36]; /* Expected destination data buffer */
+ gather_info_t gather_info; /* Operator data for callback */
+ int i, j, k, dst_i; /* Local index variables */
+
+ TESTING("H5Dgather()");
+
+ /* Create dataspace */
+ if((sid = H5Screate_simple(3, dim, NULL)) < 0) TEST_ERROR
+
+ /* Initialize src_buf */
+ for(i=0; i<(int)(sizeof(src_buf)/sizeof(src_buf[0])); i++)
+ for(j=0; j<(int)(sizeof(src_buf[0])/sizeof(src_buf[0][0])); j++)
+ for(k=0; k<(int)(sizeof(src_buf[0][0])/sizeof(src_buf[0][0][0])); k++)
+ src_buf[i][j][k] = 1 + k
+ + (int)(sizeof(src_buf[0][0]) / sizeof(src_buf[0][0][0])) * j
+ + (int)(sizeof(src_buf[0]) / sizeof(src_buf[0][0][0])) * i;
+
+
+ /*
+ * Test 1: Simple case
+ */
+ /* Select hyperslab */
+ count[0] = 1;
+ count[1] = 1;
+ count[2] = 8;
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL ,count, NULL) < 0)
+ TEST_ERROR
+
+ /* Initialize expect_dst_buf */
+ (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf));
+ for(i=0; i<8; i++)
+ expect_dst_buf[i] = src_buf[0][0][i];
+
+ /* Loop over buffer sizes */
+ for(dst_buf_size=1; dst_buf_size<=9; dst_buf_size++) {
+ /* Reset dst_buf */
+ (void)HDmemset(dst_buf, 0, sizeof(dst_buf));
+
+ /* Initialize gather_info */
+ gather_info.expect_dst_buf = expect_dst_buf;
+ gather_info.max_nelmts = dst_buf_size;
+ gather_info.last_call = FALSE;
+
+ /* Gather data */
+ if(H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info) < 0)
+ TEST_ERROR
+
+ /* Verify that all data has been gathered (and verified) */
+ if(gather_info.expect_dst_buf - expect_dst_buf != 8) TEST_ERROR
+ } /* end for */
+
+ /* Test without a callback */
+ /* Loop over buffer sizes */
+ for(dst_buf_size=8; dst_buf_size<=9; dst_buf_size++) {
+ /* Reset dst_buf */
+ (void)HDmemset(dst_buf, 0, sizeof(dst_buf));
+
+ /* Gather data */
+ if(H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]), dst_buf, NULL, NULL) < 0)
+ TEST_ERROR
+
+ /* Verify data */
+ for(i=0; i<(int)(sizeof(dst_buf)/sizeof(dst_buf[0])); i++)
+ if(dst_buf[i] != expect_dst_buf[i])
+ TEST_ERROR
+ } /* end for */
+
+ /* Test with a dst_buf_size that is not a multiple of the datatype size */
+ /* Reset dst_buf */
+ dst_buf_size = 7;
+ (void)HDmemset(dst_buf, 0, sizeof(dst_buf));
+
+ /* Initialize gather_info */
+ gather_info.expect_dst_buf = expect_dst_buf;
+ gather_info.max_nelmts = dst_buf_size - 1;
+ gather_info.last_call = FALSE;
+
+ /* Gather data */
+ if(H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]) - 1, dst_buf, gather_cb, &gather_info) < 0)
+ TEST_ERROR
+
+ /* Verify that all data has been gathered (and verified) */
+ if(gather_info.expect_dst_buf - expect_dst_buf != 8) TEST_ERROR
+
+
+ /*
+ * Test 2: Single block in dataset
+ */
+ /* Select hyperslab */
+ start[0] = 3;
+ start[1] = 2;
+ start[2] = 4;
+ count[0] = 2;
+ count[1] = 3;
+ count[2] = 2;
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL ,count, NULL) < 0)
+ TEST_ERROR
+
+ /* Initialize expect_dst_buf */
+ (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf));
+ dst_i = 0;
+ for(i=3; i<5; i++)
+ for(j=2; j<5; j++)
+ for(k=4; k<6; k++)
+ expect_dst_buf[dst_i++] = src_buf[i][j][k];
+
+ /* Loop over buffer sizes */
+ for(dst_buf_size=1; dst_buf_size<=13; dst_buf_size++) {
+ /* Reset dst_buf */
+ (void)HDmemset(dst_buf, 0, sizeof(dst_buf));
+
+ /* Initialize gather_info */
+ gather_info.expect_dst_buf = expect_dst_buf;
+ gather_info.max_nelmts = dst_buf_size;
+ gather_info.last_call = FALSE;
+
+ /* Gather data */
+ if(H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info) < 0)
+ TEST_ERROR
+
+ /* Verify that all data has been gathered (and verified) */
+ if(gather_info.expect_dst_buf - expect_dst_buf != 12) TEST_ERROR
+ } /* end for */
+
+
+ /*
+ * Test 3: Multiple blocks
+ */
+ /* Select hyperslab */
+ start[0] = 1;
+ start[1] = 1;
+ start[2] = 1;
+ stride[0] = 3;
+ stride[1] = 4;
+ stride[2] = 5;
+ count[0] = 3;
+ count[1] = 1;
+ count[2] = 2;
+ block[0] = 1;
+ block[1] = 3;
+ block[2] = 2;
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride ,count, block) < 0)
+ TEST_ERROR
+
+ /* Initialize expect_dst_buf */
+ /* Iterate over block containing selection, checking if each element is in
+ * selection. Note that the algorithm used here (if statement) would not
+ * work for overlapping hyperslabs. */
+ (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf));
+ dst_i = 0;
+ for(i=1; i<8; i++)
+ for(j=1; j<4; j++)
+ for(k=1; k<8; k++)
+ if((hsize_t)i >= start[0]
+ && ((hsize_t)i - start[0]) % stride[0] < block[0]
+ && ((hsize_t)i - start[0]) / stride[0] < count[0]
+ && (hsize_t)j >= start[1]
+ && ((hsize_t)j - start[1]) % stride[1] < block[1]
+ && ((hsize_t)j - start[1]) / stride[1] < count[1]
+ && (hsize_t)k >= start[2]
+ && ((hsize_t)k - start[2]) % stride[2] < block[2]
+ && ((hsize_t)k - start[2]) / stride[2] < count[2])
+ expect_dst_buf[dst_i++] = src_buf[i][j][k];
+
+ /* Loop over buffer sizes */
+ for(dst_buf_size=1; dst_buf_size<=37; dst_buf_size++) {
+ /* Reset dst_buf */
+ (void)HDmemset(dst_buf, 0, sizeof(dst_buf));
+
+ /* Initialize gather_info */
+ gather_info.expect_dst_buf = expect_dst_buf;
+ gather_info.max_nelmts = dst_buf_size;
+ gather_info.last_call = FALSE;
+
+ /* Gather data */
+ if(H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info) < 0)
+ TEST_ERROR
+
+ /* Verify that all data has been gathered (and verified) */
+ if(gather_info.expect_dst_buf - expect_dst_buf != 36) TEST_ERROR
+ } /* end for */
+
+
+ /*
+ * Test 4: Compound selection
+ */
+ /* Select hyperslabs */
+ start[0] = 2;
+ start[1] = 1;
+ start[2] = 1;
+ count[0] = 2;
+ count[1] = 3;
+ count[2] = 2;
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL ,count, NULL) < 0)
+ TEST_ERROR
+ start2[0] = 1;
+ start2[1] = 2;
+ start2[2] = 2;
+ count2[0] = 3;
+ count2[1] = 2;
+ count2[2] = 2;
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_XOR, start2, NULL ,count2, NULL) < 0)
+ TEST_ERROR
+
+ /* Initialize expect_dst_buf */
+ /* Iterate over block containing selection, checking if each element is in
+ * selection. */
+ (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf));
+ dst_i = 0;
+ for(i=1; i<4; i++)
+ for(j=1; j<4; j++)
+ for(k=1; k<4; k++)
+ if(!(((hsize_t)i >= start[0] && (hsize_t)i < start[0] + count[0])
+ && ((hsize_t)j >= start[1] && (hsize_t)j < start[1] + count[1])
+ && ((hsize_t)k >= start[2] && (hsize_t)k < start[2] + count[2]))
+ != !(((hsize_t)i >= start2[0] && (hsize_t)i < start2[0] + count2[0])
+ && ((hsize_t)j >= start2[1] && (hsize_t)j < start2[1] + count2[1])
+ && ((hsize_t)k >= start2[2] && (hsize_t)k < start2[2] + count2[2])))
+ expect_dst_buf[dst_i++] = src_buf[i][j][k];
+
+ /* Loop over buffer sizes */
+ for(dst_buf_size=1; dst_buf_size<=17; dst_buf_size++) {
+ /* Reset dst_buf */
+ (void)HDmemset(dst_buf, 0, sizeof(dst_buf));
+
+ /* Initialize gather_info */
+ gather_info.expect_dst_buf = expect_dst_buf;
+ gather_info.max_nelmts = dst_buf_size;
+ gather_info.last_call = FALSE;
+
+ /* Gather data */
+ if(H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info) < 0)
+ TEST_ERROR
+
+ /* Verify that all data has been gathered (and verified) */
+ if(gather_info.expect_dst_buf - expect_dst_buf != 16) TEST_ERROR
+ } /* end for */
+
+
+ /*
+ * Test 5: Point selection
+ */
+ /* Select hyperslabs */
+ if(H5Sselect_elements(sid, H5S_SELECT_SET, sizeof(point) / sizeof(point[0]), (hsize_t *)point) < 0)
+ TEST_ERROR
+
+ /* Initialize expect_dst_buf */
+ /* Iterate over block containing selection, checking if each element is in
+ * selection. */
+ (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf));
+ for(i=0; i<(int)(sizeof(point) / sizeof(point[0])); i++)
+ expect_dst_buf[i] = src_buf[point[i][0]][point[i][1]][point[i][2]];
+
+ /* Loop over buffer sizes */
+ for(dst_buf_size=1; dst_buf_size<=5; dst_buf_size++) {
+ /* Reset dst_buf */
+ (void)HDmemset(dst_buf, 0, sizeof(dst_buf));
+
+ /* Initialize gather_info */
+ gather_info.expect_dst_buf = expect_dst_buf;
+ gather_info.max_nelmts = dst_buf_size;
+ gather_info.last_call = FALSE;
+
+ /* Gather data */
+ if(H5Dgather(sid, src_buf, H5T_NATIVE_INT, dst_buf_size * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info) < 0)
+ TEST_ERROR
+
+ /* Verify that all data has been gathered (and verified) */
+ if(gather_info.expect_dst_buf - expect_dst_buf != 4) TEST_ERROR
+ } /* end for */
+
+
+ /* Close everything */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ PASSED();
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Sclose(sid);
+ } H5E_END_TRY;
+ return -1;
+} /* end test_gather() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_scatter_error
+ *
+ * Purpose: Tests H5Dscatter with a variety of different conditions
+ * that should cause errors.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Neil Fortner
+ * Monday, February 4, 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+scatter_error_cb_fail(void **src_buf/*out*/, size_t *src_buf_bytes_used/*out*/,
+ void *_scatter_info)
+{
+ scatter_info_t *scatter_info = (scatter_info_t *)_scatter_info;
+ size_t nelmts; /* Number of elements to return in src_buf */
+
+ /* Calculate number of elements */
+ nelmts = MIN(scatter_info->block, scatter_info->size);
+ HDassert(nelmts > 0);
+
+ /* Set output variables */
+ *src_buf = (void *)scatter_info->src_buf;
+ *src_buf_bytes_used = nelmts * sizeof(scatter_info->src_buf[0]);
+
+ return FAIL;
+}
+
+static herr_t
+scatter_error_cb_null(void **src_buf/*out*/, size_t *src_buf_bytes_used/*out*/,
+ void *_scatter_info)
+{
+ scatter_info_t *scatter_info = (scatter_info_t *)_scatter_info;
+ size_t nelmts; /* Number of elements to return in src_buf */
+
+ /* Calculate number of elements */
+ nelmts = MIN(scatter_info->block, scatter_info->size);
+ HDassert(nelmts > 0);
+
+ /* Set output variables */
+ *src_buf = NULL;
+ *src_buf_bytes_used = nelmts * sizeof(scatter_info->src_buf[0]);
+
+ return SUCCEED;
+}
+
+static herr_t
+scatter_error_cb_unalign(void **src_buf/*out*/, size_t *src_buf_bytes_used/*out*/,
+ void *_src_buf_bytes_used)
+{
+ /* Set output variables */
+ *src_buf = _src_buf_bytes_used;
+ *src_buf_bytes_used = *(size_t *)_src_buf_bytes_used;
+
+ return SUCCEED;
+}
+
+static herr_t
+test_scatter_error(void)
+{
+ hid_t sid = -1; /* Dataspace ID */
+ hsize_t dim[1] = {10}; /* Dataspace dimensions */
+ hsize_t start[3] = {2};
+ hsize_t count[3] = {6};
+ int src_buf[7]; /* Source data buffer */
+ int dst_buf[10]; /* Destination data buffer */
+ scatter_info_t scatter_info; /* Operator data for callback */
+ size_t cb_unalign_nbytes; /* Number of bytes to return for unaligned test */
+ herr_t ret; /* Return value */
+ int i; /* Local index variable */
+
+ TESTING("H5Dscatter() error conditions");
+
+ /* Create dataspace */
+ if((sid = H5Screate_simple(1, dim, NULL)) < 0) TEST_ERROR
+
+ /* Initialize src_buf */
+ for(i=0; i<(int)(sizeof(src_buf)/sizeof(src_buf[0])); i++)
+ src_buf[i] = i + 1;
+
+ /* Select hyperslab */
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL ,count, NULL) < 0)
+ TEST_ERROR
+
+ /* Verify that base configuration passes */
+ scatter_info.src_buf = src_buf;
+ scatter_info.block = sizeof(src_buf)/sizeof(src_buf[0]);
+ scatter_info.size = 6;
+ if(H5Dscatter(scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf) < 0)
+ TEST_ERROR
+
+
+ /*
+ * Test invalid parameters
+ */
+ scatter_info.src_buf = src_buf;
+ scatter_info.size = 6;
+ H5E_BEGIN_TRY {
+ ret = H5Dscatter(NULL, NULL, H5T_NATIVE_INT, sid, dst_buf);
+ } H5E_END_TRY
+ if(ret >= 0) TEST_ERROR
+
+ scatter_info.src_buf = src_buf;
+ scatter_info.size = 6;
+ H5E_BEGIN_TRY {
+ ret = H5Dscatter(scatter_cb, &scatter_info, sid, sid, dst_buf);
+ } H5E_END_TRY
+ if(ret >= 0) TEST_ERROR
+
+ scatter_info.src_buf = src_buf;
+ scatter_info.size = 6;
+ H5E_BEGIN_TRY {
+ ret = H5Dscatter(scatter_cb, &scatter_info, H5T_NATIVE_INT, H5T_NATIVE_INT, dst_buf);
+ } H5E_END_TRY
+ if(ret >= 0) TEST_ERROR
+
+ scatter_info.src_buf = src_buf;
+ scatter_info.size = 6;
+ H5E_BEGIN_TRY {
+ ret = H5Dscatter(scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, NULL);
+ } H5E_END_TRY
+ if(ret >= 0) TEST_ERROR
+
+
+ /*
+ * Test returning too many elements in callback
+ */
+ scatter_info.src_buf = src_buf;
+ scatter_info.size = 7;
+ H5E_BEGIN_TRY {
+ ret = H5Dscatter(scatter_cb, &scatter_info, H5T_NATIVE_INT, sid, dst_buf);
+ } H5E_END_TRY
+ if(ret >= 0) TEST_ERROR
+
+
+ /*
+ * Test callback returns failure
+ */
+ scatter_info.src_buf = src_buf;
+ scatter_info.size = 6;
+ H5E_BEGIN_TRY {
+ ret = H5Dscatter(scatter_error_cb_fail, &scatter_info, H5T_NATIVE_INT, sid, dst_buf);
+ } H5E_END_TRY
+ if(ret >= 0) TEST_ERROR
+
+
+ /*
+ * Test callback returns NULL buffer
+ */
+ scatter_info.src_buf = src_buf;
+ scatter_info.size = 6;
+ H5E_BEGIN_TRY {
+ ret = H5Dscatter(scatter_error_cb_null, &scatter_info, H5T_NATIVE_INT, sid, dst_buf);
+ } H5E_END_TRY
+ if(ret >= 0) TEST_ERROR
+
+
+ /*
+ * Test callback returns 0 for src_buf_bytes_used
+ */
+ cb_unalign_nbytes = 0;
+ H5E_BEGIN_TRY {
+ ret = H5Dscatter(scatter_error_cb_unalign, &cb_unalign_nbytes, H5T_NATIVE_INT, sid, dst_buf);
+ } H5E_END_TRY
+ if(ret >= 0) TEST_ERROR
+
+
+ /*
+ * Test callback returns src_buf_bytes_used that is not a multiple of
+ * datatype size
+ */
+ cb_unalign_nbytes = sizeof(src_buf[0]) - 1;
+ H5E_BEGIN_TRY {
+ ret = H5Dscatter(scatter_error_cb_unalign, &cb_unalign_nbytes, H5T_NATIVE_INT, sid, dst_buf);
+ } H5E_END_TRY
+ if(ret >= 0) TEST_ERROR
+
+ cb_unalign_nbytes = sizeof(src_buf[0]) + 1;
+ H5E_BEGIN_TRY {
+ ret = H5Dscatter(scatter_error_cb_unalign, &cb_unalign_nbytes, H5T_NATIVE_INT, sid, dst_buf);
+ } H5E_END_TRY
+ if(ret >= 0) TEST_ERROR
+
+
+ /* Close everything */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ PASSED();
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Sclose(sid);
+ } H5E_END_TRY;
+ return -1;
+} /* end test_scatter_error() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_gather_error
+ *
+ * Purpose: Tests H5Dgather with a variety of different conditions
+ * that should cause errors.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Neil Fortner
+ * Monday, February 4, 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+gather_error_cb_fail(const void UNUSED *dst_buf,
+ size_t UNUSED dst_buf_bytes_used, void UNUSED *op_data)
+{
+ return FAIL;
+}
+
+static herr_t
+test_gather_error(void)
+{
+ hid_t sid = -1; /* Dataspace ID */
+ hsize_t dim[1] = {10}; /* Dataspace dimensions */
+ hsize_t start[1] = {2};
+ hsize_t count[1] = {6};
+ int src_buf[10]; /* Source data buffer */
+ int dst_buf[6]; /* Destination data buffer */
+ int expect_dst_buf[6]; /* Expected destination data buffer */
+ gather_info_t gather_info; /* Operator data for callback */
+ herr_t ret; /* Return value */
+ int i; /* Local index variable */
+
+ TESTING("H5Dgather() error conditions");
+
+ /* Create dataspace */
+ if((sid = H5Screate_simple(1, dim, NULL)) < 0) TEST_ERROR
+
+ /* Initialize src_buf */
+ for(i=0; i<(int)(sizeof(src_buf)/sizeof(src_buf[0])); i++)
+ src_buf[i] = 1 + i;
+
+ /* Select hyperslab */
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL ,count, NULL) < 0)
+ TEST_ERROR
+
+ /* Initialize expect_dst_buf */
+ (void)HDmemset(expect_dst_buf, 0, sizeof(expect_dst_buf));
+ for(i=0; i<6; i++)
+ expect_dst_buf[i] = src_buf[i + 2];
+
+ /* Verify that base configuration passes */
+ gather_info.expect_dst_buf = expect_dst_buf;
+ gather_info.max_nelmts = 6;
+ gather_info.last_call = FALSE;
+ if(H5Dgather(sid, src_buf, H5T_NATIVE_INT, 6 * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info) < 0)
+ TEST_ERROR
+
+ /*
+ * Test invalid parameters
+ */
+ gather_info.expect_dst_buf = expect_dst_buf;
+ gather_info.last_call = FALSE;
+ H5E_BEGIN_TRY {
+ ret = H5Dgather(H5T_NATIVE_INT, src_buf, H5T_NATIVE_INT, 6 * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info);
+ } H5E_END_TRY
+ if(ret >= 0) TEST_ERROR
+
+ gather_info.expect_dst_buf = expect_dst_buf;
+ gather_info.last_call = FALSE;
+ H5E_BEGIN_TRY {
+ ret = H5Dgather(sid, NULL, H5T_NATIVE_INT, 6 * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info);
+ } H5E_END_TRY
+ if(ret >= 0) TEST_ERROR
+
+ gather_info.expect_dst_buf = expect_dst_buf;
+ gather_info.last_call = FALSE;
+ H5E_BEGIN_TRY {
+ ret = H5Dgather(sid, src_buf, sid, 6 * sizeof(dst_buf[0]), dst_buf, gather_cb, &gather_info);
+ } H5E_END_TRY
+ if(ret >= 0) TEST_ERROR
+
+ gather_info.expect_dst_buf = expect_dst_buf;
+ gather_info.last_call = FALSE;
+ H5E_BEGIN_TRY {
+ ret = H5Dgather(sid, src_buf, H5T_NATIVE_INT, 0, dst_buf, gather_cb, &gather_info);
+ } H5E_END_TRY
+ if(ret >= 0) TEST_ERROR
+
+ gather_info.expect_dst_buf = expect_dst_buf;
+ gather_info.last_call = FALSE;
+ H5E_BEGIN_TRY {
+ ret = H5Dgather(sid, src_buf, H5T_NATIVE_INT, 1, dst_buf, gather_cb, &gather_info);
+ } H5E_END_TRY
+ if(ret >= 0) TEST_ERROR
+
+ gather_info.expect_dst_buf = expect_dst_buf;
+ gather_info.last_call = FALSE;
+ H5E_BEGIN_TRY {
+ ret = H5Dgather(sid, src_buf, H5T_NATIVE_INT, 6 * sizeof(dst_buf[0]), NULL, gather_cb, &gather_info);
+ } H5E_END_TRY
+ if(ret >= 0) TEST_ERROR
+
+ gather_info.expect_dst_buf = expect_dst_buf;
+ gather_info.last_call = FALSE;
+ H5E_BEGIN_TRY {
+ ret = H5Dgather(sid, src_buf, H5T_NATIVE_INT, 5 * sizeof(dst_buf[0]), dst_buf, NULL, &gather_info);
+ } H5E_END_TRY
+ if(ret >= 0) TEST_ERROR
+
+
+ /*
+ * Test callback returns failure
+ */
+ gather_info.expect_dst_buf = expect_dst_buf;
+ gather_info.last_call = FALSE;
+ H5E_BEGIN_TRY {
+ ret = H5Dgather(sid, src_buf, H5T_NATIVE_INT, 6 * sizeof(dst_buf[0]), dst_buf, gather_error_cb_fail, NULL);
+ } H5E_END_TRY
+ if(ret >= 0) TEST_ERROR
+
+
+ /* Close everything */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ PASSED();
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Sclose(sid);
+ } H5E_END_TRY;
+ return -1;
+} /* end test_gather_error() */
+
+
+/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Tests the dataset interface (H5D)
@@ -8315,6 +9337,12 @@ main(void)
/* Close 2nd FAPL */
if(H5Pclose(fapl2) < 0) TEST_ERROR
+ /* Tests that do not use files */
+ nerrors += (test_scatter() < 0 ? 1 : 0);
+ nerrors += (test_gather() < 0 ? 1 : 0);
+ nerrors += (test_scatter_error() < 0 ? 1 : 0);
+ nerrors += (test_gather_error() < 0 ? 1 : 0);
+
/* Verify symbol table messages are cached */
nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0);
diff --git a/test/stab.c b/test/stab.c
index a42ee5e..48b58b1 100644
--- a/test/stab.c
+++ b/test/stab.c
@@ -539,7 +539,7 @@ long_compact(hid_t fapl2)
hid_t fid = (-1); /* File ID */
hid_t gid = (-1); /* Group ID */
hid_t gid2 = (-1); /* Group ID */
- char *objname; /* Object name */
+ char *objname = NULL; /* Object name */
char filename[NAME_BUF_SIZE];
h5_stat_size_t empty_size; /* Size of an empty file */
h5_stat_size_t file_size; /* Size of each file created */
@@ -557,7 +557,7 @@ long_compact(hid_t fapl2)
if((empty_size = h5_get_file_size(filename, fapl2)) < 0) TEST_ERROR
/* Construct very long object name template */
- if((objname = (char *)HDmalloc((size_t)(LONG_COMPACT_LENGTH + 1))) == NULL) TEST_ERROR
+ if(NULL == (objname = (char *)HDmalloc((size_t)(LONG_COMPACT_LENGTH + 1)))) TEST_ERROR
HDmemset(objname, 'a', (size_t)LONG_COMPACT_LENGTH);
objname[LONG_COMPACT_LENGTH] = '\0';
@@ -620,6 +620,7 @@ long_compact(hid_t fapl2)
/* Free object name */
HDfree(objname);
+ objname = NULL;
/* Close top group */
if(H5Gclose(gid) < 0) TEST_ERROR
@@ -645,6 +646,10 @@ error:
H5Gclose(gid);
H5Fclose(fid);
} H5E_END_TRY;
+
+ if(objname)
+ HDfree(objname);
+
return 1;
} /* end long_compact() */
diff --git a/test/testframe.c b/test/testframe.c
index 5835b73..8ab7a5b 100644
--- a/test/testframe.c
+++ b/test/testframe.c
@@ -155,8 +155,8 @@ void TestUsage(void)
print_func("Usage: %s [-v[erbose] (l[ow]|m[edium]|h[igh]|0-9)] %s\n",
TestProgName, (TestPrivateUsage ? "<extra options>" : ""));
- print_func(" [-[e]x[clude] name+] \n");
- print_func(" [-o[nly] name+] \n");
+ print_func(" [-[e]x[clude] name]+ \n");
+ print_func(" [-o[nly] name]+ \n");
print_func(" [-b[egin] name] \n");
print_func(" [-s[ummary]] \n");
print_func(" [-c[leanoff]] \n");
diff --git a/test/testhdf5.h b/test/testhdf5.h
index c92c0f0..907fce9 100644
--- a/test/testhdf5.h
+++ b/test/testhdf5.h
@@ -142,7 +142,7 @@
if(VERBOSE_HI) \
print_func(" Call to routine: %15s at line %4d in %s returned " \
"invalid result\n", where, (int)__LINE__, __FILE__); \
- TestErrPrintf("*** UNEXPECTED RESULT from %s at line %4d in %s\n" \
+ TestErrPrintf("*** UNEXPECTED RESULT from %s at line %4d in %s\n", \
where, (int)__LINE__, __FILE__); \
} while(0)
diff --git a/test/testlibinfo.sh.in b/test/testlibinfo.sh.in
index fba1794..b7aa6c4 100644
--- a/test/testlibinfo.sh.in
+++ b/test/testlibinfo.sh.in
@@ -53,7 +53,10 @@ SKIP() {
# Function definitions
CHECK_LIBINFO(){
LINEMSG $1
- if strings $1 | grep "SUMMARY OF THE HDF5 CONFIGURATION" > /dev/null; then
+ # Some systems, like Mac, the strings command inspects library files. Older
+ # versions of strings may not know newer library format, resulting in
+ # command errors. Make it read the file as stdin to avoid the problem.
+ if strings < $1 | grep "SUMMARY OF THE HDF5 CONFIGURATION" > /dev/null; then
echo " PASSED"
else
echo " FAILED"
diff --git a/test/tfile.c b/test/tfile.c
index b04f42b..ff397a0 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -526,6 +526,9 @@ test_file_open(void)
/* Close dataset from first open */
ret = H5Dclose(did);
CHECK(ret, FAIL, "H5Dclose");
+
+ ret = H5Pclose(fapl_id);
+ CHECK(ret, FAIL, "H5Pclose");
} /* test_file_open() */
/****************************************************************
@@ -1059,6 +1062,9 @@ test_get_file_id(void)
VERIFY(fid2, FAIL, "H5Iget_file_id");
/* Close objects */
+ ret = H5Pclose(plist);
+ CHECK(ret, FAIL, "H5Pclose");
+
ret = H5Tclose(datatype_id);
CHECK(ret, FAIL, "H5Tclose");
@@ -2852,7 +2858,7 @@ test_filespace_sects(void)
test_free_sections(fapl_stdio, filename);
/* close fapl and remove the file */
- h5_cleanup(FILENAME, fapl_split);
+ h5_cleanup(FILENAME, fapl_stdio);
/* CORE */
MESSAGE(5, ("Testing File free space information for a core file\n"));
@@ -3075,7 +3081,7 @@ test_filespace_compatible(void)
VERIFY(free_space, (hssize_t)0, "H5Fget_freespace");
/* Get the file's file creation property list */
- /* Retrieve the file space handling stretegy and threshold */
+ /* Retrieve the file space handling strategy and threshold */
fcpl = H5Fget_create_plist(fid);
CHECK(fcpl, FAIL, "H5Fget_create_plist");
ret = H5Pget_file_space(fcpl, &strategy, &threshold);
@@ -3108,9 +3114,13 @@ test_filespace_compatible(void)
ret = H5Ldelete(fid, DSETNAME, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Ldelete");
- /* Close the file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
+ /* Close the plist */
+ ret = H5Pclose(fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* Close the file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
/* Re-Open the file */
fid = H5Fopen(FILE5, H5F_ACC_RDONLY, H5P_DEFAULT);
@@ -3220,6 +3230,9 @@ test_libver_bounds_real(H5F_libver_t libver_create, unsigned oh_vers_create,
ret = H5Fclose(file);
CHECK(ret, FAIL, "H5Fclose");
+
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
} /* end test_libver_bounds_real() */
/****************************************************************
diff --git a/test/th5o.c b/test/th5o.c
index 7dc21b1..257c227 100644
--- a/test/th5o.c
+++ b/test/th5o.c
@@ -111,6 +111,8 @@ test_h5o_open(void)
CHECK(dspace, FAIL, "H5Dget_space");
/* Close the IDs */
+ ret = H5Sclose(dspace);
+ CHECK(ret, FAIL, "H5Sclose");
ret = H5Gclose(grp);
CHECK(ret, FAIL, "H5Gclose");
ret = H5Tclose(dtype);
@@ -324,6 +326,8 @@ test_h5o_open_by_addr(void)
CHECK(dspace, FAIL, "H5Dget_space");
/* Close the IDs */
+ ret = H5Sclose(dspace);
+ CHECK(ret, FAIL, "H5Sclose");
ret = H5Gclose(grp);
CHECK(ret, FAIL, "H5Gclose");
ret = H5Tclose(dtype);
diff --git a/test/th5s.c b/test/th5s.c
index a026545..ebbaa37 100644
--- a/test/th5s.c
+++ b/test/th5s.c
@@ -182,14 +182,13 @@ test_h5s_basic(void)
fid1 = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT);
CHECK_I(fid1, "H5Fopen");
if (fid1 >= 0){
- dset1 = H5Dopen2(fid1, "dset", H5P_DEFAULT);
- VERIFY(dset1, FAIL, "H5Dopen2");
- ret = H5Fclose(fid1);
- CHECK_I(ret, "H5Fclose");
+ dset1 = H5Dopen2(fid1, "dset", H5P_DEFAULT);
+ VERIFY(dset1, FAIL, "H5Dopen2");
+ ret = H5Fclose(fid1);
+ CHECK_I(ret, "H5Fclose");
}
else
- printf("***cannot open the pre-created H5S_MAX_RANK test file (%s)\n",
- testfile);
+ printf("***cannot open the pre-created H5S_MAX_RANK test file (%s)\n", testfile);
}
/* Verify that incorrect dimensions don't work */
diff --git a/test/tsohm.c b/test/tsohm.c
index fddb552..eb5f7c5 100644
--- a/test/tsohm.c
+++ b/test/tsohm.c
@@ -1280,6 +1280,9 @@ static void size2_verify_plist1(hid_t plist)
ret = memcmp(&fill1, &fill1_correct, sizeof(fill1_correct));
VERIFY(ret, 0, memcmp);
+
+ ret = H5Tclose(dtype1_id);
+ CHECK_I(ret, "H5Tclose");
}
/*-------------------------------------------------------------------------
@@ -1348,6 +1351,9 @@ static void size2_verify_plist2(hid_t plist)
ret = HDmemcmp(&fill2, &fill2_correct, (size_t)DTYPE2_SIZE);
VERIFY(ret, 0, memcmp);
+
+ ret = H5Tclose(dtype2_id);
+ CHECK_I(ret, "H5Tclose");
}
#ifdef NOT_NOW
@@ -3138,6 +3144,8 @@ static void test_sohm_extlink_helper(hid_t src_fcpl_id, hid_t dst_fcpl_id)
/* Close the dataset and both files to make sure everything gets flushed
* out of memory
*/
+ ret = H5Sclose(space_id);
+ CHECK_I(ret, "H5Sclose");
ret = H5Dclose(dset_id);
CHECK_I(ret, "H5Dclose");
ret = H5Fclose(src_file_id);
@@ -3195,6 +3203,9 @@ test_sohm_extlink(void)
test_sohm_extlink_helper(fcpl_id, H5P_DEFAULT);
test_sohm_extlink_helper(H5P_DEFAULT, fcpl_id);
test_sohm_extlink_helper(fcpl_id, fcpl_id);
+
+ ret = H5Pclose(fcpl_id);
+ CHECK_I(ret, "H5Pclose");
}
@@ -3782,6 +3793,9 @@ test_sohm_extend_dset(void)
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 = H5Pclose(fcpl_id);
+ CHECK_I(ret, "H5Pclose");
}
diff --git a/test/vfd.c b/test/vfd.c
index ca354d9..b85c054 100644
--- a/test/vfd.c
+++ b/test/vfd.c
@@ -28,17 +28,20 @@
#define FAMILY_SIZE2 (5*KB)
#define MULTI_SIZE 128
#define CORE_INCREMENT (4*KB)
+#define DSET1_NAME "dset1"
+#define DSET1_DIM1 1024
+#define DSET1_DIM2 32
+#define DSET3_NAME "dset3"
-/*Macros for Direct VFD*/
+/* Macros for Direct VFD */
+#ifdef H5_HAVE_DIRECT
#define MBOUNDARY 512
#define FBSIZE (4*KB)
#define CBSIZE (8*KB)
#define THRESHOLD 1
-#define DSET1_NAME "dset1"
-#define DSET1_DIM1 1024
-#define DSET1_DIM2 32
#define DSET2_NAME "dset2"
#define DSET2_DIM 4
+#endif /* H5_HAVE_DIRECT */
const char *FILENAME[] = {
"sec2_file", /*0*/
@@ -165,7 +168,7 @@ test_direct(void)
size_t mbound;
size_t fbsize;
size_t cbsize;
- int *points, *check, *p1, *p2;
+ int *points = NULL, *check = NULL, *p1, *p2;
int wdata2[DSET2_DIM] = {11,12,13,14};
int rdata2[DSET2_DIM];
int i, j, n;
@@ -189,10 +192,10 @@ test_direct(void)
if(H5Pget_fapl_direct(fapl, &mbound, &fbsize, &cbsize) < 0)
TEST_ERROR;
if(mbound != MBOUNDARY || fbsize != FBSIZE || cbsize != CBSIZE)
- TEST_ERROR;
+ TEST_ERROR;
if(H5Pset_alignment(fapl, (hsize_t)THRESHOLD, (hsize_t)FBSIZE) < 0)
- TEST_ERROR;
+ TEST_ERROR;
H5E_BEGIN_TRY {
file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
@@ -235,17 +238,16 @@ test_direct(void)
/* Allocate aligned memory for data set 1. For data set 1, everything is aligned including
* memory address, size of data, and file address. */
- if(posix_memalign(&points, (size_t)FBSIZE, (size_t)(DSET1_DIM1*DSET1_DIM2*sizeof(int)))!=0)
+ if(0 != HDposix_memalign(&points, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int))))
TEST_ERROR;
-
- if(posix_memalign(&check, (size_t)FBSIZE, (size_t)(DSET1_DIM1*DSET1_DIM2*sizeof(int)))!=0)
+ if(0 != HDposix_memalign(&check, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int))))
TEST_ERROR;
/* Initialize the dset1 */
p1 = points;
for(i = n = 0; i < DSET1_DIM1; i++)
- for(j = 0; j < DSET1_DIM2; j++)
- *p1++ = n++;
+ for(j = 0; j < DSET1_DIM2; j++)
+ *p1++ = n++;
/* Create the data space1 */
dims1[0] = DSET1_DIM1;
@@ -275,13 +277,13 @@ test_direct(void)
p1 = points;
p2 = check;
for(i = 0; i < DSET1_DIM1; i++)
- for(j = 0; j < DSET1_DIM2; j++)
- if(*p1++ != *p2++) {
- H5_FAILED();
- printf(" Read different values than written in data set 1.\n");
- printf(" At index %d,%d\n", i, j);
- TEST_ERROR;
- } /* end if */
+ for(j = 0; j < DSET1_DIM2; j++)
+ if(*p1++ != *p2++) {
+ H5_FAILED();
+ printf(" Read different values than written in data set 1.\n");
+ printf(" At index %d,%d\n", i, j);
+ TEST_ERROR;
+ } /* end if */
/* Create the data space2. For data set 2, memory address and data size are not aligned. */
dims2[0] = DSET2_DIM;
@@ -308,12 +310,12 @@ test_direct(void)
/* Check that the values read are the same as the values written */
for(i = 0; i < DSET2_DIM; i++)
- if(wdata2[i] != rdata2[i]) {
- H5_FAILED();
- printf(" Read different values than written in data set 2.\n");
- printf(" At index %d\n", i);
+ if(wdata2[i] != rdata2[i]) {
+ H5_FAILED();
+ printf(" Read different values than written in data set 2.\n");
+ printf(" At index %d\n", i);
TEST_ERROR;
- } /* end if */
+ } /* end if */
if(H5Sclose(space1) < 0)
TEST_ERROR;
@@ -325,10 +327,10 @@ test_direct(void)
TEST_ERROR;
if(H5Fclose(file) < 0)
TEST_ERROR;
- if(points)
- free(points);
- if(check)
- free(check);
+ HDassert(points);
+ HDfree(points);
+ HDassert(check);
+ HDfree(check);
h5_cleanup(FILENAME, fapl);
PASSED();
@@ -336,13 +338,19 @@ test_direct(void)
error:
H5E_BEGIN_TRY {
- H5Pclose (fapl);
+ H5Pclose(fapl);
H5Sclose(space1);
H5Dclose(dset1);
H5Sclose(space2);
H5Dclose(dset2);
H5Fclose(file);
} H5E_END_TRY;
+
+ if(points)
+ HDfree(points);
+ if(check)
+ HDfree(check);
+
return -1;
#endif /*H5_HAVE_DIRECT*/
}
@@ -368,7 +376,7 @@ test_core(void)
char filename[1024];
void *fhandle=NULL;
hsize_t file_size;
- int *points, *check, *p1, *p2;
+ int *points = NULL, *check = NULL, *p1, *p2;
hid_t dset1=-1, space1=-1;
hsize_t dims1[2];
int i, j, n;
@@ -427,14 +435,16 @@ test_core(void)
TEST_ERROR;
/* Allocate memory for data set. */
- points=(int*)malloc(DSET1_DIM1*DSET1_DIM2*sizeof(int));
- check=(int*)malloc(DSET1_DIM1*DSET1_DIM2*sizeof(int));
+ if(NULL == (points = (int *)HDmalloc(DSET1_DIM1 * DSET1_DIM2 * sizeof(int))))
+ TEST_ERROR;
+ if(NULL == (check = (int *)HDmalloc(DSET1_DIM1 * DSET1_DIM2 * sizeof(int))))
+ TEST_ERROR;
/* Initialize the dset1 */
p1 = points;
for(i = n = 0; i < DSET1_DIM1; i++)
- for(j = 0; j < DSET1_DIM2; j++)
- *p1++ = n++;
+ for(j = 0; j < DSET1_DIM2; j++)
+ *p1++ = n++;
/* Create the data space1 */
dims1[0] = DSET1_DIM1;
@@ -464,13 +474,13 @@ test_core(void)
p1 = points;
p2 = check;
for(i = 0; i < DSET1_DIM1; i++)
- for(j = 0; j < DSET1_DIM2; j++)
- if(*p1++ != *p2++) {
- H5_FAILED();
- printf(" Read different values than written in data set 1.\n");
- printf(" At index %d,%d\n", i, j);
- TEST_ERROR;
- } /* end if */
+ for(j = 0; j < DSET1_DIM2; j++)
+ if(*p1++ != *p2++) {
+ H5_FAILED();
+ printf(" Read different values than written in data set 1.\n");
+ printf(" At index %d,%d\n", i, j);
+ TEST_ERROR;
+ } /* end if */
if(H5Dclose(dset1) < 0)
TEST_ERROR;
@@ -501,10 +511,10 @@ test_core(void)
TEST_ERROR;
/* Reallocate memory for reading buffer. */
- if(check)
- free(check);
-
- check = (int*)malloc(DSET1_DIM1 * DSET1_DIM2 * sizeof(int));
+ HDassert(check);
+ HDfree(check);
+ if(NULL == (check = (int *)HDmalloc(DSET1_DIM1 * DSET1_DIM2 * sizeof(int))))
+ TEST_ERROR;
/* Read the data back from dset1 */
if(H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0)
@@ -514,13 +524,13 @@ test_core(void)
p1 = points;
p2 = check;
for(i = 0; i < DSET1_DIM1; i++)
- for(j = 0; j < DSET1_DIM2; j++)
- if(*p1++ != *p2++) {
- H5_FAILED();
- printf(" Read different values than written in data set 1.\n");
- printf(" At index %d,%d\n", i, j);
- TEST_ERROR;
- } /* end if */
+ for(j = 0; j < DSET1_DIM2; j++)
+ if(*p1++ != *p2++) {
+ H5_FAILED();
+ printf(" Read different values than written in data set 1.\n");
+ printf(" At index %d,%d\n", i, j);
+ TEST_ERROR;
+ } /* end if */
/* Check file size API */
if(H5Fget_filesize(file, &file_size) < 0)
@@ -537,10 +547,10 @@ test_core(void)
TEST_ERROR;
if(H5Fclose(file) < 0)
TEST_ERROR;
- if(points)
- free(points);
- if(check)
- free(check);
+ HDassert(points);
+ HDfree(points);
+ HDassert(check);
+ HDfree(check);
h5_cleanup(FILENAME, fapl);
@@ -549,9 +559,15 @@ test_core(void)
error:
H5E_BEGIN_TRY {
- H5Pclose (fapl);
+ H5Pclose(fapl);
H5Fclose(file);
} H5E_END_TRY;
+
+ if(points)
+ HDfree(points);
+ if(check)
+ HDfree(check);
+
return -1;
}
@@ -579,27 +595,30 @@ test_family_opens(char *fname, hid_t fa_pl)
int i;
/* Case 1: reopen file with 1st member file name and default property list */
- sprintf(first_name, fname, 0);
+ HDsnprintf(first_name, sizeof(first_name), fname, 0);
H5E_BEGIN_TRY {
- file=H5Fopen(first_name, H5F_ACC_RDWR, H5P_DEFAULT);
+ file = H5Fopen(first_name, H5F_ACC_RDWR, H5P_DEFAULT);
} H5E_END_TRY;
- if(file >= 0) TEST_ERROR
+ if(file >= 0)
+ TEST_ERROR
/* Case 2: reopen file with correct name template but default property list */
H5E_BEGIN_TRY {
- file=H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT);
+ file = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT);
} H5E_END_TRY;
- if(file >= 0) TEST_ERROR
+ if(file >= 0)
+ TEST_ERROR
/* Case 3: reopen file with wrong member size */
if(H5Pset_fapl_family(fa_pl, (hsize_t)128, H5P_DEFAULT) < 0)
TEST_ERROR;
H5E_BEGIN_TRY {
- file=H5Fopen(fname, H5F_ACC_RDWR, fa_pl);
+ file = H5Fopen(fname, H5F_ACC_RDWR, fa_pl);
} H5E_END_TRY;
- if(file >= 0) TEST_ERROR
+ if(file >= 0)
+ TEST_ERROR
/* Case 4: reopen file with wrong name template */
HDstrcpy(wrong_name, fname);
@@ -613,9 +632,10 @@ test_family_opens(char *fname, hid_t fa_pl)
TEST_ERROR;
H5E_BEGIN_TRY {
- file=H5Fopen(wrong_name, H5F_ACC_RDWR, fa_pl);
+ file = H5Fopen(wrong_name, H5F_ACC_RDWR, fa_pl);
} H5E_END_TRY;
- if(file >= 0) TEST_ERROR
+ if(file >= 0)
+ TEST_ERROR
return 0;
@@ -704,44 +724,44 @@ test_family(void)
if((dset=H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
- for(i=0; i<FAMILY_NUMBER; i++)
- for(j=0; j<FAMILY_SIZE; j++)
- buf[i][j] = i*10000+j;
+ for(i = 0; i < FAMILY_NUMBER; i++)
+ for(j = 0; j < FAMILY_SIZE; j++)
+ buf[i][j] = (int)((i * 10000) + j);
if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
TEST_ERROR;
/* check file handle API */
- if((fapl2=H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ if((fapl2 = H5Pcreate(H5P_FILE_ACCESS)) < 0)
TEST_ERROR;
if(H5Pset_family_offset(fapl2, (hsize_t)0) < 0)
TEST_ERROR;
if(H5Fget_vfd_handle(file, fapl2, (void **)&fhandle) < 0)
TEST_ERROR;
- if(*fhandle<0)
+ if(*fhandle < 0)
TEST_ERROR;
if(H5Pset_family_offset(fapl2, (hsize_t)(FAMILY_SIZE*2)) < 0)
TEST_ERROR;
if(H5Fget_vfd_handle(file, fapl2, (void **)&fhandle2) < 0)
TEST_ERROR;
- if(*fhandle2<0)
+ if(*fhandle2 < 0)
TEST_ERROR;
/* Check file size API */
if(H5Fget_filesize(file, &file_size) < 0)
TEST_ERROR;
- /* Some data has been written. The file size should be bigger(18KB+976
+ /* Some data has been written. The file size should be bigger (18KB+976)
* bytes if int size is 4 bytes) now. */
- if(sizeof(int)<=4) {
- if(file_size<18*KB || file_size>20*KB)
- TEST_ERROR;
- } else if(sizeof(int)>=8) {
- if(file_size<32*KB || file_size>40*KB)
- TEST_ERROR;
- }
+#if H5_SIZEOF_INT <= 4
+ if(file_size < (18 * KB) || file_size > (20 * KB))
+ TEST_ERROR;
+#elif H5_SIZEOF_INT >= 8
+ if(file_size < (32 * KB) || file_size > (40 * KB))
+ TEST_ERROR;
+#endif
if(H5Sclose(space) < 0)
TEST_ERROR;
@@ -761,7 +781,7 @@ test_family(void)
if(H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0)
TEST_ERROR;
- if((file=H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
TEST_ERROR;
if(H5Fclose(file) < 0)
@@ -829,13 +849,13 @@ test_family_compat(void)
* Since we're going to open the files with write mode, this protects the original
* files.
*/
- sprintf(newname_individual, newname, counter);
- sprintf(pathname_individual, pathname, counter);
+ HDsnprintf(newname_individual, sizeof(newname_individual), newname, counter);
+ HDsnprintf(pathname_individual, sizeof(pathname_individual), pathname, counter);
- while (h5_make_local_copy(pathname_individual, newname_individual) >= 0) {
+ while(h5_make_local_copy(pathname_individual, newname_individual) >= 0) {
counter++;
- sprintf(newname_individual, newname, counter);
- sprintf(pathname_individual, pathname, counter);
+ HDsnprintf(newname_individual, sizeof(newname_individual), newname, counter);
+ HDsnprintf(pathname_individual, sizeof(pathname_individual), pathname, counter);
}
/* Make sure we can open the file. Use the read and write mode to flush the
@@ -888,7 +908,7 @@ error:
* reopening multi file.
*
* Return: Success: 0
- * Failure: 1
+ * Failure: -1
*
* Programmer: Raymond Lu
* Thursday, May 19, 2005
@@ -903,14 +923,14 @@ test_multi_opens(char *fname)
char sf_name[1024]; /*name string "multi_file-s.h5"*/
/* Case: reopen with the name of super file and default property list */
- sprintf(super_name, "%%s-%c.h5", 's');
- sprintf(sf_name, super_name, fname);
+ HDsnprintf(super_name, sizeof(super_name), "%%s-%c.h5", 's');
+ HDsnprintf(sf_name, sizeof(sf_name), super_name, fname);
H5E_BEGIN_TRY {
- file=H5Fopen(sf_name, H5F_ACC_RDWR, H5P_DEFAULT);
+ file = H5Fopen(sf_name, H5F_ACC_RDWR, H5P_DEFAULT);
} H5E_END_TRY;
- return 0;
+ return(file >= 0 ? -1 : 0);
}
@@ -999,11 +1019,11 @@ test_multi(void)
TEST_ERROR;
/* Reopen the file */
- if((file=H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
TEST_ERROR;
/* Create and write data set */
- if((space=H5Screate_simple(2, dims, NULL)) < 0)
+ if((space = H5Screate_simple(2, dims, NULL)) < 0)
TEST_ERROR;
/* Retrieve the access property list... */
@@ -1146,19 +1166,16 @@ error:
static herr_t
test_multi_compat(void)
{
- hid_t file=(-1), fapl, fapl2=(-1), dset=(-1), space=(-1);
- hid_t access_fapl = -1;
+ hid_t file=(-1), fapl, dset=(-1), space=(-1);
char newname[1024];
char filename_s[1024], newname_s[1024];
char filename_r[1024], newname_r[1024];
- int *fhandle2=NULL, *fhandle=NULL;
H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES];
hid_t memb_fapl[H5FD_MEM_NTYPES];
haddr_t memb_addr[H5FD_MEM_NTYPES];
const char *memb_name[H5FD_MEM_NTYPES];
char sv[H5FD_MEM_NTYPES][32];
hsize_t dims[2]={MULTI_SIZE, MULTI_SIZE};
- char dname[]="dataset2";
int i, j;
int buf[MULTI_SIZE][MULTI_SIZE];
@@ -1238,7 +1255,7 @@ test_multi_compat(void)
if((space=H5Screate_simple(2, dims, NULL)) < 0)
TEST_ERROR;
- if((dset=H5Dcreate2(file, DSET2_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if((dset=H5Dcreate2(file, DSET3_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
for(i=0; i<MULTI_SIZE; i++)
@@ -1267,7 +1284,7 @@ test_multi_compat(void)
if(H5Dclose(dset) < 0)
TEST_ERROR;
- if((dset = H5Dopen2(file, DSET2_NAME, H5P_DEFAULT)) < 0)
+ if((dset = H5Dopen2(file, DSET3_NAME, H5P_DEFAULT)) < 0)
TEST_ERROR;
if(H5Dclose(dset) < 0)
@@ -1315,13 +1332,13 @@ test_log(void)
int *fhandle = NULL;
hsize_t file_size = 0;
unsigned int flags = H5FD_LOG_ALL;
- size_t buf_size = 0;
+ size_t buf_size = 4 * KB;
TESTING("LOG file driver");
/* Set property list and file name for log driver. */
fapl = h5_fileaccess();
- if(H5Pset_fapl_log(fapl, LOG_FILENAME, 0, buf_size) < 0)
+ if(H5Pset_fapl_log(fapl, LOG_FILENAME, flags, buf_size) < 0)
TEST_ERROR;
h5_fixname(FILENAME[6], fapl, filename, sizeof filename);