summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@lbl.gov>2016-09-29 20:17:55 (GMT)
committerQuincey Koziol <koziol@lbl.gov>2016-09-29 20:17:55 (GMT)
commit5a7880183025f56421cf6f2274d9f1ac36f59641 (patch)
tree0cdce0036d5b02df97b3a2fcdf875184b6886e67 /test
parent1853868fdc9433f29adae5418d1fd0d65a45fabe (diff)
downloadhdf5-5a7880183025f56421cf6f2274d9f1ac36f59641.zip
hdf5-5a7880183025f56421cf6f2274d9f1ac36f59641.tar.gz
hdf5-5a7880183025f56421cf6f2274d9f1ac36f59641.tar.bz2
Clean up hardcoded constants and check return values better. (Comments from
group code review)
Diffstat (limited to 'test')
-rw-r--r--test/dsets.c16
-rw-r--r--test/dt_arith.c11
-rw-r--r--test/gheap.c41
-rw-r--r--test/h5test.c7
-rw-r--r--test/theap.c15
-rw-r--r--test/tskiplist.c15
6 files changed, 62 insertions, 43 deletions
diff --git a/test/dsets.c b/test/dsets.c
index 4a52539..8aa073f 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -240,6 +240,10 @@ double points_dbl[DSET_DIM1][DSET_DIM2], check_dbl[DSET_DIM1][DSET_DIM2];
size_t count_nbytes_read = 0;
size_t count_nbytes_written = 0;
+/* Temporary buffer dimensions */
+#define DSET_TMP_DIM1 50
+#define DSET_TMP_DIM2 100
+
/* Declarations for test_idx_compatible() */
#define DSET "dset"
#define DSET_FILTER "dset_filter"
@@ -9682,7 +9686,7 @@ test_single_chunk(hid_t fapl)
hid_t sid = -1, sid_max = -1; /* Dataspace ID for dataset with fixed dimensions */
hid_t did = -1, did_max = -1; /* Dataset ID for dataset with fixed dimensions */
hsize_t dim2[2] = {DSET_DIM1, DSET_DIM2}; /* Dataset dimensions */
- hsize_t t_dim2[2] = {50, 100}; /* Dataset dimensions */
+ hsize_t t_dim2[2] = {DSET_TMP_DIM1, DSET_TMP_DIM2}; /* Dataset dimensions */
int *wbuf = NULL; /* write buffer */
int *t_wbuf = NULL; /* write buffer */
int *rbuf = NULL; /* read buffer */
@@ -9723,15 +9727,15 @@ test_single_chunk(hid_t fapl)
TEST_ERROR
if(NULL == (rbuf = (int *)HDmalloc(sizeof(int) * (DSET_DIM1 * DSET_DIM2))))
TEST_ERROR
- if(NULL == (t_wbuf = (int *)HDmalloc(sizeof(int) * (50 * 100))))
+ if(NULL == (t_wbuf = (int *)HDmalloc(sizeof(int) * (DSET_TMP_DIM1 * DSET_TMP_DIM2))))
TEST_ERROR
- if(NULL == (t_rbuf = (int *)HDmalloc(sizeof(int) * (50 * 100))))
+ if(NULL == (t_rbuf = (int *)HDmalloc(sizeof(int) * (DSET_TMP_DIM1 * DSET_TMP_DIM2))))
TEST_ERROR
for(i = n = 0; i < (DSET_DIM1 * DSET_DIM2); i++)
wbuf[i] = (int)n++;
- for(i = n = 0; i < (50* 100); i++)
+ for(i = n = 0; i < (DSET_TMP_DIM1* DSET_TMP_DIM2); i++)
t_wbuf[i] = (int)n++;
#ifdef H5_HAVE_FILTER_DEFLATE
@@ -9848,8 +9852,8 @@ test_single_chunk(hid_t fapl)
if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, t_rbuf) < 0) TEST_ERROR;
/* Verify that written and read data are the same */
- for(i = 0; i < (50* 100); i++)
- if(t_rbuf[i] != t_wbuf[i]){
+ for(i = 0; i < (DSET_TMP_DIM1* DSET_TMP_DIM2); i++)
+ if(t_rbuf[i] != t_wbuf[i]) {
printf(" Line %d: Incorrect value, t_wbuf[%u]=%d, t_rbuf[%u]=%d\n",
__LINE__,(unsigned)i,t_wbuf[i],(unsigned)i,t_rbuf[i]);
TEST_ERROR;
diff --git a/test/dt_arith.c b/test/dt_arith.c
index cdfe182..1ebcf74 100644
--- a/test/dt_arith.c
+++ b/test/dt_arith.c
@@ -94,6 +94,9 @@ static int skip_overflow_tests_g = 0;
#define TEST_DENORM 2
#define TEST_SPECIAL 3
+/* Temporary buffer sizes */
+#define TMP_BUF_DIM1 32
+#define TMP_BUF_DIM2 100
/* Don't use hardware conversions if set */
static int without_hardware_g = 0;
@@ -2678,11 +2681,11 @@ test_conv_int_2(void)
printf("%-70s", "Testing overlap calculations");
HDfflush(stdout);
- buf = (char *)HDcalloc(32, 100);
+ buf = (char *)HDcalloc(TMP_BUF_DIM1, TMP_BUF_DIM2);
HDassert(buf);
- for (i=1; i<=32; i++) {
- for (j=1; j<=32; j++) {
+ for(i = 1; i <= TMP_BUF_DIM1; i++) {
+ for(j = 1; j <= TMP_BUF_DIM1; j++) {
/* Source type */
src_type = H5Tcopy(H5T_NATIVE_CHAR);
@@ -2696,7 +2699,7 @@ test_conv_int_2(void)
* Conversion. If overlap calculations aren't right then an
* assertion will fail in H5T__conv_i_i()
*/
- H5Tconvert(src_type, dst_type, (size_t)100, buf, NULL, H5P_DEFAULT);
+ H5Tconvert(src_type, dst_type, (size_t)TMP_BUF_DIM2, buf, NULL, H5P_DEFAULT);
H5Tclose(src_type);
H5Tclose(dst_type);
}
diff --git a/test/gheap.c b/test/gheap.c
index 3e88ca6..eafc49d 100644
--- a/test/gheap.c
+++ b/test/gheap.c
@@ -35,6 +35,9 @@
* GHEAP_REPEATED_ERR_LIM errors, and suppress the rest */
#define GHEAP_REPEATED_ERR_LIM 20
+/* Number of heap objects to test */
+#define GHEAP_TEST_NOBJS 1024
+
#define GHEAP_REPEATED_ERR(MSG) \
{ \
nerrors++; \
@@ -79,8 +82,8 @@ test_1 (hid_t fapl)
hid_t file = -1;
H5F_t *f = NULL;
H5HG_t *obj = NULL;
- uint8_t out[1024];
- uint8_t in[1024];
+ uint8_t out[GHEAP_TEST_NOBJS];
+ uint8_t in[GHEAP_TEST_NOBJS];
size_t u;
size_t size;
herr_t status;
@@ -90,7 +93,7 @@ test_1 (hid_t fapl)
TESTING("monotonically increasing lengths");
/* Allocate buffer for H5HG_t */
- if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * 1024)))
+ if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * GHEAP_TEST_NOBJS)))
goto error;
/* Open a clean file */
@@ -108,7 +111,7 @@ test_1 (hid_t fapl)
* a clean file, the addresses allocated for the collections should also
* be monotonically increasing.
*/
- for(u = 0; u < 1024; u++) {
+ for(u = 0; u < GHEAP_TEST_NOBJS; u++) {
size = u + 1;
HDmemset(out, (int)('A' + u % 26), size);
H5Eclear2(H5E_DEFAULT);
@@ -127,7 +130,7 @@ test_1 (hid_t fapl)
/*
* Now try to read each object back.
*/
- for(u = 0; u < 1024; u++) {
+ for(u = 0; u < GHEAP_TEST_NOBJS; u++) {
size = u + 1;
HDmemset(out, (int)('A' + u % 26), size);
H5Eclear2(H5E_DEFAULT);
@@ -185,8 +188,8 @@ test_2 (hid_t fapl)
hid_t file = -1;
H5F_t *f = NULL;
H5HG_t *obj = NULL;
- uint8_t out[1024];
- uint8_t in[1024];
+ uint8_t out[GHEAP_TEST_NOBJS];
+ uint8_t in[GHEAP_TEST_NOBJS];
size_t u;
size_t size;
int nerrors = 0;
@@ -195,7 +198,7 @@ test_2 (hid_t fapl)
TESTING("monotonically decreasing lengths");
/* Allocate buffer for H5HG_t */
- if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * 1024)))
+ if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * GHEAP_TEST_NOBJS)))
goto error;
/* Open a clean file */
@@ -211,8 +214,8 @@ test_2 (hid_t fapl)
/*
* Write the objects, monotonically decreasing in length.
*/
- for(u = 0; u < 1024; u++) {
- size = 1024 - u;
+ for(u = 0; u < GHEAP_TEST_NOBJS; u++) {
+ size = GHEAP_TEST_NOBJS - u;
HDmemset(out, (int)('A' + u % 26), size);
H5Eclear2(H5E_DEFAULT);
if (H5HG_insert (f, H5AC_ind_read_dxpl_id, size, out, obj + u) < 0) {
@@ -225,8 +228,8 @@ test_2 (hid_t fapl)
/*
* Now try to read each object back.
*/
- for(u = 0; u < 1024; u++) {
- size = 1024 - u;
+ for(u = 0; u < GHEAP_TEST_NOBJS; u++) {
+ size = GHEAP_TEST_NOBJS - u;
HDmemset(out, (int)('A' + u % 26), size);
H5Eclear2(H5E_DEFAULT);
if (NULL==H5HG_read (f, H5AC_ind_read_dxpl_id, obj + u, in, NULL)) {
@@ -283,7 +286,7 @@ test_3 (hid_t fapl)
hid_t file = -1;
H5F_t *f = NULL;
H5HG_t *obj = NULL;
- uint8_t out[1024];
+ uint8_t out[GHEAP_TEST_NOBJS];
size_t u;
size_t size;
herr_t status;
@@ -293,7 +296,7 @@ test_3 (hid_t fapl)
TESTING("complete object removal");
/* Allocate buffer for H5HG_t */
- if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * 1024)))
+ if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * GHEAP_TEST_NOBJS)))
goto error;
/* Open a clean file */
@@ -307,7 +310,7 @@ test_3 (hid_t fapl)
}
/* Create some stuff */
- for(u = 0; u < 1024; u++) {
+ for(u = 0; u < GHEAP_TEST_NOBJS; u++) {
size = u % 30 + 100;
HDmemset(out, (int)('A' + u % 26), size);
H5Eclear2(H5E_DEFAULT);
@@ -320,7 +323,7 @@ test_3 (hid_t fapl)
}
/* Remove everything */
- for(u = 0; u < 1024; u++) {
+ for(u = 0; u < GHEAP_TEST_NOBJS; u++) {
status = H5HG_remove (f, H5AC_ind_read_dxpl_id, obj + u);
if (status<0) {
H5_FAILED();
@@ -373,7 +376,7 @@ test_4 (hid_t fapl)
hid_t file = -1;
H5F_t *f = NULL;
H5HG_t *obj = NULL;
- uint8_t out[1024];
+ uint8_t out[GHEAP_TEST_NOBJS];
size_t u;
size_t size;
herr_t status;
@@ -383,7 +386,7 @@ test_4 (hid_t fapl)
TESTING("partial object removal");
/* Allocate buffer for H5HG_t */
- if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * 1024)))
+ if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * GHEAP_TEST_NOBJS)))
goto error;
/* Open a clean file */
@@ -396,7 +399,7 @@ test_4 (hid_t fapl)
goto error;
}
- for(u = 0; u < 1024; u++) {
+ for(u = 0; u < GHEAP_TEST_NOBJS; u++) {
/* Insert */
size = u % 30 + 100;
HDmemset(out, (int)('A' + u % 26), size);
diff --git a/test/h5test.c b/test/h5test.c
index 92b90c5..2ab8855 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -90,6 +90,9 @@ MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */
*/
static const char *multi_letters = "msbrglo";
+/* Length of multi-file VFD filename buffers */
+#define H5TEST_MULTI_FILENAME_LEN 1024
+
/* Previous error reporting function */
static H5E_auto2_t err_func = NULL;
@@ -867,7 +870,7 @@ h5_fileaccess(void)
HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES);
for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) {
memb_fapl[mt] = H5P_DEFAULT;
- if(NULL == (sv[mt] = (char *)HDmalloc(1024)))
+ if(NULL == (sv[mt] = (char *)HDmalloc(H5TEST_MULTI_FILENAME_LEN)))
return -1;
HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]);
memb_name[mt] = sv[mt];
@@ -1006,7 +1009,7 @@ h5_get_vfd_fapl(void)
HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES);
for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) {
memb_fapl[mt] = H5P_DEFAULT;
- sv[mt] = (char *)HDmalloc(1024);
+ sv[mt] = (char *)HDmalloc(H5TEST_MULTI_FILENAME_LEN);
HDassert(sv[mt]);
HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]);
memb_name[mt] = sv[mt];
diff --git a/test/theap.c b/test/theap.c
index b19e08f..9c509a1 100644
--- a/test/theap.c
+++ b/test/theap.c
@@ -90,11 +90,11 @@ test_heap_init(void)
/* Allocate arrays */
rand_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS);
- HDassert(rand_num);
+ CHECK(rand_num, NULL, "HDmalloc");
inc_sort_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS);
- HDassert(inc_sort_num);
+ CHECK(inc_sort_num, NULL, "HDmalloc");
dec_sort_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS);
- HDassert(dec_sort_num);
+ CHECK(dec_sort_num, NULL, "HDmalloc");
/* Create randomized set of numbers */
curr_time = HDtime(NULL);
@@ -1039,9 +1039,12 @@ static void
test_heap_term(void)
{
/* Release arrays */
- HDfree(rand_num);
- HDfree(inc_sort_num);
- HDfree(dec_sort_num);
+ if(rand_num)
+ HDfree(rand_num);
+ if(inc_sort_num)
+ HDfree(inc_sort_num);
+ if(dec_sort_num)
+ HDfree(dec_sort_num);
} /* end test_tst_term() */
/****************************************************************
diff --git a/test/tskiplist.c b/test/tskiplist.c
index 5738aad..f30948e 100644
--- a/test/tskiplist.c
+++ b/test/tskiplist.c
@@ -68,11 +68,11 @@ test_skiplist_init(void)
/* Allocate arrays */
rand_num = (int *)HDmalloc(sizeof(int) * NUM_ELEMS);
- HDassert(rand_num);
+ CHECK(rand_num, NULL, "HDmalloc");
sort_rand_num = (int *)HDmalloc(sizeof(int) * NUM_ELEMS);
- HDassert(sort_rand_num);
+ CHECK(sort_rand_num, NULL, "HDmalloc");
rev_sort_rand_num = (int *)HDmalloc(sizeof(int) * NUM_ELEMS);
- HDassert(rev_sort_rand_num);
+ CHECK(rev_sort_rand_num, NULL, "HDmalloc");
/* Initialize random number seed */
curr_time = HDtime(NULL);
@@ -1762,9 +1762,12 @@ static void
test_skiplist_term(void)
{
/* Release arrays */
- HDfree(rand_num);
- HDfree(sort_rand_num);
- HDfree(rev_sort_rand_num);
+ if(rand_num)
+ HDfree(rand_num);
+ if(sort_rand_num)
+ HDfree(sort_rand_num);
+ if(rev_sort_rand_num)
+ HDfree(rev_sort_rand_num);
} /* end test_skiplist_term() */
/****************************************************************