diff options
-rw-r--r-- | src/H5B2hdr.c | 2 | ||||
-rw-r--r-- | src/H5Doh.c | 6 | ||||
-rw-r--r-- | src/H5HFhdr.c | 2 | ||||
-rw-r--r-- | src/H5HLcache.c | 6 | ||||
-rw-r--r-- | src/H5trace.c | 149 | ||||
-rw-r--r-- | test/dsets.c | 16 | ||||
-rw-r--r-- | test/hyperslab.c | 1715 | ||||
-rw-r--r-- | test/trefstr.c | 1 | ||||
-rw-r--r-- | test/tvlstr.c | 82 |
9 files changed, 1030 insertions, 949 deletions
diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index a4f7d8e..668bce4 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -599,7 +599,7 @@ H5B2_hdr_delete(H5B2_hdr_t *hdr, hid_t dxpl_id) done: /* Unprotect the header with appropriate flags */ - if(hdr && H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_HDR, hdr->addr, hdr, cache_flags) < 0) + if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_HDR, hdr->addr, hdr, cache_flags) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header") FUNC_LEAVE_NOAPI(SUCCEED) diff --git a/src/H5Doh.c b/src/H5Doh.c index 98e9bf3..8ed6644 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -423,11 +423,11 @@ H5O_dset_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info) done: /* Free messages, if they've been read in */ if(layout_read && H5O_msg_reset(H5O_LAYOUT_ID, &layout) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset data storage layout message") + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset data storage layout message") if(pline_read && H5O_msg_reset(H5O_PLINE_ID, &pline) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset I/O pipeline message") + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset I/O pipeline message") if(efl_read && H5O_msg_reset(H5O_EFL_ID, &efl) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset external file list message") + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset external file list message") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_dset_bh_info() */ diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index 8652f90..e55f472 100644 --- a/src/H5HFhdr.c +++ b/src/H5HFhdr.c @@ -1454,7 +1454,7 @@ H5HF_hdr_delete(H5HF_hdr_t *hdr, hid_t dxpl_id) done: /* Unprotect the header with appropriate flags */ - if(hdr && H5AC_unprotect(hdr->f, dxpl_id, H5AC_FHEAP_HDR, hdr->heap_addr, hdr, cache_flags) < 0) + if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_FHEAP_HDR, hdr->heap_addr, hdr, cache_flags) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header") FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5HLcache.c b/src/H5HLcache.c index 6064fe5..47d5d6f 100644 --- a/src/H5HLcache.c +++ b/src/H5HLcache.c @@ -173,12 +173,12 @@ H5HL_fl_deserialize(H5HL_t *heap, hsize_t free_block) if(fl->offset + fl->size > heap->dblk_size) HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "bad heap free list") - /* Insert node into list */ + /* Append node onto list */ if(tail) tail->next = fl; - tail = fl; - if(!heap->freelist) + else heap->freelist = fl; + tail = fl; fl = NULL; } /* end while */ diff --git a/src/H5trace.c b/src/H5trace.c index b554b80..8c83505 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -916,172 +916,189 @@ H5_trace (const double *returning, const char *func, const char *type, ...) break; case 'i': - if (ptr) { - if (vp) { - fprintf (out, "0x%lx", (unsigned long)vp); - } else { + if(ptr) { + if(vp) + fprintf(out, "0x%lx", (unsigned long)vp); + else fprintf(out, "NULL"); - } - } else { + } /* end if */ + else { hid_t obj = va_arg (ap, hid_t); - if (H5P_DEFAULT == obj) { - fprintf (out, "H5P_DEFAULT"); - } else if (obj<0) { - fprintf (out, "FAIL"); - } else { - switch (H5I_TYPE(obj)) { /* Use internal H5I macro instead of function call */ + + if(H5P_DEFAULT == obj) + fprintf(out, "H5P_DEFAULT"); + else if(obj < 0) + fprintf(out, "FAIL"); + else { + switch(H5I_TYPE(obj)) { /* Use internal H5I macro instead of function call */ case H5I_UNINIT: - fprintf (out, "%ld (uninit - error)", (long)obj); + fprintf(out, "%ld (uninit - error)", (long)obj); break; + case H5I_BADID: - fprintf (out, "%ld (error)", (long)obj); + fprintf(out, "%ld (error)", (long)obj); break; + case H5I_FILE: fprintf(out, "%ld (file)", (long)obj); break; + case H5I_GROUP: fprintf(out, "%ld (group)", (long)obj); break; + case H5I_DATATYPE: - if (obj==H5T_NATIVE_SCHAR_g) { + if(obj == H5T_NATIVE_SCHAR_g) fprintf(out, "H5T_NATIVE_SCHAR"); - } else if (obj==H5T_NATIVE_UCHAR_g) { + else if(obj == H5T_NATIVE_UCHAR_g) fprintf(out, "H5T_NATIVE_UCHAR"); - } else if (obj==H5T_NATIVE_SHORT_g) { + else if(obj == H5T_NATIVE_SHORT_g) fprintf(out, "H5T_NATIVE_SHORT"); - } else if (obj==H5T_NATIVE_USHORT_g) { + else if(obj == H5T_NATIVE_USHORT_g) fprintf(out, "H5T_NATIVE_USHORT"); - } else if (obj==H5T_NATIVE_INT_g) { + else if(obj == H5T_NATIVE_INT_g) fprintf(out, "H5T_NATIVE_INT"); - } else if (obj==H5T_NATIVE_UINT_g) { + else if(obj == H5T_NATIVE_UINT_g) fprintf(out, "H5T_NATIVE_UINT"); - } else if (obj==H5T_NATIVE_LONG_g) { + else if(obj == H5T_NATIVE_LONG_g) fprintf(out, "H5T_NATIVE_LONG"); - } else if (obj==H5T_NATIVE_ULONG_g) { + else if(obj == H5T_NATIVE_ULONG_g) fprintf(out, "H5T_NATIVE_ULONG"); - } else if (obj==H5T_NATIVE_LLONG_g) { + else if(obj == H5T_NATIVE_LLONG_g) fprintf(out, "H5T_NATIVE_LLONG"); - } else if (obj==H5T_NATIVE_ULLONG_g) { + else if(obj == H5T_NATIVE_ULLONG_g) fprintf(out, "H5T_NATIVE_ULLONG"); - } else if (obj==H5T_NATIVE_FLOAT_g) { + else if(obj == H5T_NATIVE_FLOAT_g) fprintf(out, "H5T_NATIVE_FLOAT"); - } else if (obj==H5T_NATIVE_DOUBLE_g) { + else if(obj == H5T_NATIVE_DOUBLE_g) fprintf(out, "H5T_NATIVE_DOUBLE"); #if H5_SIZEOF_LONG_DOUBLE !=0 - } else if (obj==H5T_NATIVE_LDOUBLE_g) { + else if(obj == H5T_NATIVE_LDOUBLE_g) fprintf(out, "H5T_NATIVE_LDOUBLE"); #endif - } else if (obj==H5T_IEEE_F32BE_g) { + else if(obj == H5T_IEEE_F32BE_g) fprintf(out, "H5T_IEEE_F32BE"); - } else if (obj==H5T_IEEE_F32LE_g) { + else if(obj == H5T_IEEE_F32LE_g) fprintf(out, "H5T_IEEE_F32LE"); - } else if (obj==H5T_IEEE_F64BE_g) { + else if(obj == H5T_IEEE_F64BE_g) fprintf(out, "H5T_IEEE_F64BE"); - } else if (obj==H5T_IEEE_F64LE_g) { + else if(obj == H5T_IEEE_F64LE_g) fprintf(out, "H5T_IEEE_F64LE"); - } else if (obj==H5T_STD_I8BE_g) { + else if(obj == H5T_STD_I8BE_g) fprintf(out, "H5T_STD_I8BE"); - } else if (obj==H5T_STD_I8LE_g) { + else if(obj == H5T_STD_I8LE_g) fprintf(out, "H5T_STD_I8LE"); - } else if (obj==H5T_STD_I16BE_g) { + else if(obj == H5T_STD_I16BE_g) fprintf(out, "H5T_STD_I16BE"); - } else if (obj==H5T_STD_I16LE_g) { + else if(obj == H5T_STD_I16LE_g) fprintf(out, "H5T_STD_I16LE"); - } else if (obj==H5T_STD_I32BE_g) { + else if(obj == H5T_STD_I32BE_g) fprintf(out, "H5T_STD_I32BE"); - } else if (obj==H5T_STD_I32LE_g) { + else if(obj == H5T_STD_I32LE_g) fprintf(out, "H5T_STD_I32LE"); - } else if (obj==H5T_STD_I64BE_g) { + else if(obj == H5T_STD_I64BE_g) fprintf(out, "H5T_STD_I64BE"); - } else if (obj==H5T_STD_I64LE_g) { + else if(obj == H5T_STD_I64LE_g) fprintf(out, "H5T_STD_I64LE"); - } else if (obj==H5T_STD_U8BE_g) { + else if(obj == H5T_STD_U8BE_g) fprintf(out, "H5T_STD_U8BE"); - } else if (obj==H5T_STD_U8LE_g) { + else if(obj == H5T_STD_U8LE_g) fprintf(out, "H5T_STD_U8LE"); - } else if (obj==H5T_STD_U16BE_g) { + else if(obj == H5T_STD_U16BE_g) fprintf(out, "H5T_STD_U16BE"); - } else if (obj==H5T_STD_U16LE_g) { + else if(obj == H5T_STD_U16LE_g) fprintf(out, "H5T_STD_U16LE"); - } else if (obj==H5T_STD_U32BE_g) { + else if(obj == H5T_STD_U32BE_g) fprintf(out, "H5T_STD_U32BE"); - } else if (obj==H5T_STD_U32LE_g) { + else if(obj == H5T_STD_U32LE_g) fprintf(out, "H5T_STD_U32LE"); - } else if (obj==H5T_STD_U64BE_g) { + else if(obj == H5T_STD_U64BE_g) fprintf(out, "H5T_STD_U64BE"); - } else if (obj==H5T_STD_U64LE_g) { + else if(obj == H5T_STD_U64LE_g) fprintf(out, "H5T_STD_U64LE"); - } else if (obj==H5T_STD_B8BE_g) { + else if(obj == H5T_STD_B8BE_g) fprintf(out, "H5T_STD_B8BE"); - } else if (obj==H5T_STD_B8LE_g) { + else if(obj == H5T_STD_B8LE_g) fprintf(out, "H5T_STD_B8LE"); - } else if (obj==H5T_STD_B16BE_g) { + else if(obj == H5T_STD_B16BE_g) fprintf(out, "H5T_STD_B16BE"); - } else if (obj==H5T_STD_B16LE_g) { + else if(obj == H5T_STD_B16LE_g) fprintf(out, "H5T_STD_B16LE"); - } else if (obj==H5T_STD_B32BE_g) { + else if(obj == H5T_STD_B32BE_g) fprintf(out, "H5T_STD_B32BE"); - } else if (obj==H5T_STD_B32LE_g) { + else if(obj == H5T_STD_B32LE_g) fprintf(out, "H5T_STD_B32LE"); - } else if (obj==H5T_STD_B64BE_g) { + else if(obj == H5T_STD_B64BE_g) fprintf(out, "H5T_STD_B64BE"); - } else if (obj==H5T_STD_B64LE_g) { + else if(obj == H5T_STD_B64LE_g) fprintf(out, "H5T_STD_B64LE"); - } else if (obj==H5T_C_S1_g) { + else if(obj == H5T_C_S1_g) fprintf(out, "H5T_C_S1"); - } else if (obj==H5T_FORTRAN_S1_g) { + else if(obj == H5T_FORTRAN_S1_g) fprintf(out, "H5T_FORTRAN_S1"); - } else { + else fprintf(out, "%ld (dtype)", (long)obj); - } break; + case H5I_DATASPACE: fprintf(out, "%ld (dspace)", (long)obj); /* Save the rank of simple data spaces for arrays */ /* This may generate recursive call to the library... -QAK */ { - H5S_t *space = (H5S_t *)H5I_object(obj); - if (H5S_SIMPLE==H5S_GET_EXTENT_TYPE(space)) { - asize[argno] = H5S_GET_EXTENT_NDIMS(space); - } + H5S_t *space; + + if(NULL != (space = (H5S_t *)H5I_object(obj))) + if(H5S_SIMPLE == H5S_GET_EXTENT_TYPE(space)) + asize[argno] = H5S_GET_EXTENT_NDIMS(space); } break; + case H5I_DATASET: fprintf(out, "%ld (dset)", (long)obj); break; + case H5I_ATTR: fprintf(out, "%ld (attr)", (long)obj); break; + case H5I_REFERENCE: fprintf(out, "%ld (reference)", (long)obj); break; + case H5I_VFL: fprintf(out, "%ld (file driver)", (long)obj); break; + case H5I_GENPROP_CLS: fprintf(out, "%ld (genprop class)", (long)obj); break; + case H5I_GENPROP_LST: fprintf(out, "%ld (genprop list)", (long)obj); break; + case H5I_ERROR_CLASS: fprintf(out, "%ld (err class)", (long)obj); break; + case H5I_ERROR_MSG: fprintf(out, "%ld (err msg)", (long)obj); break; + case H5I_ERROR_STACK: fprintf(out, "%ld (err stack)", (long)obj); break; + case H5I_NTYPES: fprintf (out, "%ld (ntypes - error)", (long)obj); break; + default: fprintf(out, "%ld (unknown class)", (long)obj); break; - } - } - } + } /* end switch */ + } /* end else */ + } /* end else */ break; case 'I': diff --git a/test/dsets.c b/test/dsets.c index 4865ba9..46355c1 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -1274,8 +1274,6 @@ const H5Z_class2_t H5Z_CORRUPT[1] = {{ * Programmer: Raymond Lu * Jan 14, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static size_t @@ -1283,7 +1281,7 @@ filter_corrupt(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf) { - void *data; + void *data = NULL; unsigned char *dst = (unsigned char*)(*buf); unsigned int offset; unsigned int length; @@ -1291,20 +1289,21 @@ filter_corrupt(unsigned int flags, size_t cd_nelmts, size_t ret_value = 0; if(cd_nelmts != 3 || !cd_values) - return 0; + TEST_ERROR offset = cd_values[0]; length = cd_values[1]; value = cd_values[2]; if(offset > nbytes || (offset + length) > nbytes || length < sizeof(unsigned int)) - return 0; + TEST_ERROR - data = HDmalloc((size_t)length); + if(NULL == (data = HDmalloc((size_t)length))) + TEST_ERROR HDmemset(data, (int)value, (size_t)length); if(flags & H5Z_FLAG_REVERSE) { /* Varify data is actually corrupted during read */ dst += offset; if(HDmemcmp(data, dst, (size_t)length) != 0) - ret_value = 0; + TEST_ERROR else { *buf_size = nbytes; ret_value = nbytes; @@ -1317,11 +1316,12 @@ filter_corrupt(unsigned int flags, size_t cd_nelmts, ret_value = *buf_size; } /* end else */ +error: if(data) HDfree(data); return ret_value; -} +} /* end filter_corrupt() */ /*------------------------------------------------------------------------- diff --git a/test/hyperslab.c b/test/hyperslab.c index b756449..e216b95 100644 --- a/test/hyperslab.c +++ b/test/hyperslab.c @@ -48,29 +48,27 @@ * Programmer: Robb Matzke * Friday, October 10, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static unsigned init_full(uint8_t *array, size_t nx, size_t ny, size_t nz) { - size_t i, j, k; uint8_t acc = 128; unsigned total = 0; + size_t i, j, k; - for (i=0; i<nx; i++) { - for (j=0; j<ny; j++) { - for (k=0; k<nz; k++) { + for(i = 0; i < nx; i++) + for(j = 0; j < ny; j++) + for(k = 0; k < nz; k++) { total += acc; *array = acc; acc++; array++; - } - } - } + } /* end for */ + return total; -} +} /* end init_full() */ + /*------------------------------------------------------------------------- * Function: print_array @@ -82,8 +80,6 @@ init_full(uint8_t *array, size_t nx, size_t ny, size_t nz) * Programmer: Robb Matzke * Friday, October 10, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static void @@ -91,25 +87,24 @@ print_array(uint8_t *array, size_t nx, size_t ny, size_t nz) { size_t i, j, k; - for (i=0; i<nx; i++) { - if (nz>1) { + for(i = 0; i < nx; i++) { + if(nz > 1) printf("i=%lu:\n", (unsigned long)i); - } else { + else printf("%03lu:", (unsigned long)i); - } - for (j=0; j<ny; j++) { - if (nz>1) + for(j = 0; j < ny; j++) { + if(nz > 1) printf("%03lu:", (unsigned long)j); - for (k=0; k<nz; k++) { + for(k = 0; k < nz; k++) printf(" %3d", *array++); - } - if (nz>1) + if(nz > 1) printf("\n"); - } + } /* end for */ printf("\n"); - } -} + } /* end for */ +} /* end print_array() */ + /*------------------------------------------------------------------------- * Function: print_ref @@ -123,21 +118,21 @@ print_array(uint8_t *array, size_t nx, size_t ny, size_t nz) * Programmer: Robb Matzke * Friday, October 10, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static void print_ref(size_t nx, size_t ny, size_t nz) { - uint8_t *array; + uint8_t *array; - array = HDcalloc(nx*ny*nz,sizeof(uint8_t)); + if(NULL != (array = HDmalloc(nx * ny * nz))) { + printf("Reference array:\n"); + init_full(array, nx, ny, nz); + print_array(array, nx, ny, nz); + HDfree(array); + } /* end if */ +} /* end print_ref() */ - printf("Reference array:\n"); - init_full(array, nx, ny, nz); - print_array(array, nx, ny, nz); -} /*------------------------------------------------------------------------- * Function: test_fill @@ -151,8 +146,6 @@ print_ref(size_t nx, size_t ny, size_t nz) * Programmer: Robb Matzke * Saturday, October 11, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -160,142 +153,134 @@ test_fill(size_t nx, size_t ny, size_t nz, size_t di, size_t dj, size_t dk, size_t ddx, size_t ddy, size_t ddz) { - uint8_t *dst = NULL; /*destination array */ - hsize_t hs_size[3]; /*hyperslab size */ - hsize_t dst_size[3]; /*destination total size */ - hsize_t dst_offset[3]; /*offset of hyperslab in dest */ - unsigned ref_value; /*reference value */ - unsigned acc; /*accumulator */ - size_t i, j, k, dx, dy, dz; /*counters */ - size_t u, v, w; - unsigned ndims; /*hyperslab dimensionality */ - char dim[64], s[256]; /*temp string */ - unsigned fill_value; /*fill value */ + uint8_t *dst = NULL; /*destination array */ + hsize_t hs_size[3]; /*hyperslab size */ + hsize_t dst_size[3]; /*destination total size */ + hsize_t dst_offset[3]; /*offset of hyperslab in dest */ + unsigned ref_value; /*reference value */ + unsigned acc; /*accumulator */ + size_t i, j, k, dx, dy, dz; /*counters */ + size_t u, v, w; + unsigned ndims; /*hyperslab dimensionality */ + char dim[64], s[256]; /*temp string */ + unsigned fill_value; /*fill value */ /* * Dimensionality. */ - if (0 == nz) { - if (0 == ny) { - ndims = 1; - ny = nz = 1; - sprintf(dim, "%lu", (unsigned long) nx); - } else { - ndims = 2; - nz = 1; - sprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny); - } - } else { - ndims = 3; - sprintf(dim, "%lux%lux%lu", - (unsigned long) nx, (unsigned long) ny, (unsigned long) nz); - } + if(0 == nz) { + if(0 == ny) { + ndims = 1; + ny = nz = 1; + sprintf(dim, "%lu", (unsigned long) nx); + } /* end if */ + else { + ndims = 2; + nz = 1; + sprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny); + } /* end else */ + } /* end if */ + else { + ndims = 3; + sprintf(dim, "%lux%lux%lu", (unsigned long) nx, (unsigned long) ny, + (unsigned long) nz); + } /* end else */ sprintf(s, "Testing hyperslab fill %-11s variable hyperslab", dim); printf("%-70s", s); fflush(stdout); /* Allocate array */ - dst = HDcalloc((size_t)1, nx * ny * nz); + if(NULL == (dst = HDcalloc((size_t)1, nx * ny * nz))) + TEST_ERROR + init_full(dst, nx, ny, nz); - for (i = 0; i < nx; i += di) { - for (j = 0; j < ny; j += dj) { - for (k = 0; k < nz; k += dk) { - for (dx = 1; dx <= nx - i; dx += ddx) { - for (dy = 1; dy <= ny - j; dy += ddy) { - for (dz = 1; dz <= nz - k; dz += ddz) { - - /* Describe the hyperslab */ - dst_size[0] = nx; - dst_size[1] = ny; - dst_size[2] = nz; - dst_offset[0] = i; - dst_offset[1] = j; - dst_offset[2] = k; - hs_size[0] = dx; - hs_size[1] = dy; - hs_size[2] = dz; - - for (fill_value=0; - fill_value<256; - fill_value+=64) { - /* - * Initialize the full array, then subtract the - * original * fill values and add the new ones. - */ - ref_value = init_full(dst, nx, ny, nz); - for (u=(size_t)dst_offset[0]; - u<dst_offset[0]+dx; - u++) { - for (v = (size_t)dst_offset[1]; - v < dst_offset[1] + dy; - v++) { - for (w = (size_t)dst_offset[2]; - w < dst_offset[2] + dz; - w++) { - ref_value -= dst[u*ny*nz+v*nz+w]; - } - } - } - ref_value += fill_value * dx * dy * dz; - - /* Fill the hyperslab with some value */ - H5V_hyper_fill(ndims, hs_size, dst_size, - dst_offset, dst, fill_value); - - /* - * Sum the array and compare it to the - * reference value. - */ - acc = 0; - for (u = 0; u < nx; u++) { - for (v = 0; v < ny; v++) { - for (w = 0; w < nz; w++) { - acc += dst[u*ny*nz + v*nz + w]; - } - } - } - - if (acc != ref_value) { - puts("*FAILED*"); - if (!HDisatty(1)) { - /* - * Print debugging info unless output - * is going directly to a terminal. - */ - AT(); - printf(" acc != ref_value\n"); - printf(" i=%lu, j=%lu, k=%lu, " - "dx=%lu, dy=%lu, dz=%lu, " - "fill=%d\n", - (unsigned long)i, - (unsigned long)j, - (unsigned long)k, - (unsigned long)dx, - (unsigned long)dy, - (unsigned long)dz, - fill_value); - print_ref(nx, ny, nz); - printf("\n Result is:\n"); - print_array(dst, nx, ny, nz); - } - goto error; - } - } - } - } - } - } - } - } - puts(" PASSED"); + for(i = 0; i < nx; i += di) { + for(j = 0; j < ny; j += dj) { + for(k = 0; k < nz; k += dk) { + for(dx = 1; dx <= nx - i; dx += ddx) { + for(dy = 1; dy <= ny - j; dy += ddy) { + for(dz = 1; dz <= nz - k; dz += ddz) { + + /* Describe the hyperslab */ + dst_size[0] = nx; + dst_size[1] = ny; + dst_size[2] = nz; + dst_offset[0] = i; + dst_offset[1] = j; + dst_offset[2] = k; + hs_size[0] = dx; + hs_size[1] = dy; + hs_size[2] = dz; + + for(fill_value = 0; fill_value < 256; fill_value += 64) { + /* + * Initialize the full array, then subtract the + * original * fill values and add the new ones. + */ + ref_value = init_full(dst, nx, ny, nz); + for(u = (size_t)dst_offset[0]; u < dst_offset[0] + dx; u++) + for(v = (size_t)dst_offset[1]; v < dst_offset[1] + dy; v++) + for(w = (size_t)dst_offset[2]; w < dst_offset[2] + dz; w++) + ref_value -= dst[u * ny * nz + v * nz + w]; + ref_value += fill_value * dx * dy * dz; + + /* Fill the hyperslab with some value */ + H5V_hyper_fill(ndims, hs_size, dst_size, dst_offset, dst, fill_value); + + /* + * Sum the array and compare it to the + * reference value. + */ + acc = 0; + for(u = 0; u < nx; u++) + for(v = 0; v < ny; v++) + for(w = 0; w < nz; w++) + acc += dst[u * ny * nz + v * nz + w]; + + if(acc != ref_value) { + H5_FAILED() + if(!HDisatty(1)) { + /* + * Print debugging info unless output + * is going directly to a terminal. + */ + AT(); + printf(" acc != ref_value\n"); + printf(" i=%lu, j=%lu, k=%lu, " + "dx=%lu, dy=%lu, dz=%lu, " + "fill=%d\n", (unsigned long)i, + (unsigned long)j, + (unsigned long)k, + (unsigned long)dx, + (unsigned long)dy, + (unsigned long)dz, fill_value); + print_ref(nx, ny, nz); + printf("\n Result is:\n"); + print_array(dst, nx, ny, nz); + } /* end if */ + goto error; + } /* end if */ + } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ + + PASSED() + HDfree(dst); + return SUCCEED; - error: - HDfree(dst); +error: + if(dst) + HDfree(dst); return FAIL; -} +} /* end test_fill() */ + /*------------------------------------------------------------------------- * Function: test_copy @@ -321,8 +306,6 @@ test_fill(size_t nx, size_t ny, size_t nz, * Programmer: Robb Matzke * Friday, October 10, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -331,66 +314,71 @@ test_copy(int mode, size_t di, size_t dj, size_t dk, size_t ddx, size_t ddy, size_t ddz) { - uint8_t *src = NULL; /*source array */ - uint8_t *dst = NULL; /*destination array */ - hsize_t hs_size[3]; /*hyperslab size */ - hsize_t dst_size[3]; /*destination total size */ - hsize_t src_size[3]; /*source total size */ - hsize_t dst_offset[3]; /*offset of hyperslab in dest */ - hsize_t src_offset[3]; /*offset of hyperslab in source */ - unsigned ref_value; /*reference value */ - unsigned acc; /*accumulator */ - hsize_t i, j, k, dx, dy, dz; /*counters */ - hsize_t u, v, w; - unsigned ndims; /*hyperslab dimensionality */ - char dim[64], s[256]; /*temp string */ - const char *sub; + uint8_t *src = NULL; /*source array */ + uint8_t *dst = NULL; /*destination array */ + hsize_t hs_size[3]; /*hyperslab size */ + hsize_t dst_size[3]; /*destination total size */ + hsize_t src_size[3]; /*source total size */ + hsize_t dst_offset[3]; /*offset of hyperslab in dest */ + hsize_t src_offset[3]; /*offset of hyperslab in source */ + unsigned ref_value; /*reference value */ + unsigned acc; /*accumulator */ + hsize_t i, j, k, dx, dy, dz; /*counters */ + hsize_t u, v, w; + unsigned ndims; /*hyperslab dimensionality */ + char dim[64], s[256]; /*temp string */ + const char *sub; /* * Dimensionality. */ - if (0 == nz) { - if (0 == ny) { - ndims = 1; - ny = nz = 1; - sprintf(dim, "%lu", (unsigned long) nx); - } else { - ndims = 2; - nz = 1; - sprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny); - } - } else { - ndims = 3; - sprintf(dim, "%lux%lux%lu", - (unsigned long) nx, (unsigned long) ny, (unsigned long) nz); - } - - switch (mode) { - case VARIABLE_SRC: - /* - * The hyperslab "travels" through the source array but the - * destination hyperslab is always at the origin of the destination - * array. - */ - sub = "variable source"; - break; - case VARIABLE_DST: - /* - * We always read a hyperslab from the origin of the source and copy it - * to a hyperslab at various locations in the destination. - */ - sub = "variable destination"; - break; - case VARIABLE_BOTH: - /* - * We read the hyperslab from various locations in the source and copy - * it to the same location in the destination. - */ - sub = "sync source & dest "; - break; - default: - abort(); - } + if(0 == nz) { + if(0 == ny) { + ndims = 1; + ny = nz = 1; + sprintf(dim, "%lu", (unsigned long) nx); + } /* end if */ + else { + ndims = 2; + nz = 1; + sprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny); + } /* end else */ + } /* end if */ + else { + ndims = 3; + sprintf(dim, "%lux%lux%lu", (unsigned long) nx, (unsigned long) ny, + (unsigned long) nz); + } /* end else */ + + switch(mode) { + case VARIABLE_SRC: + /* + * The hyperslab "travels" through the source array but the + * destination hyperslab is always at the origin of the destination + * array. + */ + sub = "variable source"; + break; + + case VARIABLE_DST: + /* + * We always read a hyperslab from the origin of the source and copy it + * to a hyperslab at various locations in the destination. + */ + sub = "variable destination"; + break; + + case VARIABLE_BOTH: + /* + * We read the hyperslab from various locations in the source and copy + * it to the same location in the destination. + */ + sub = "sync source & dest "; + break; + + default: + HDabort(); + } /* end switch */ sprintf(s, "Testing hyperslab copy %-11s %s", dim, sub); printf("%-70s", s); @@ -399,192 +387,184 @@ test_copy(int mode, /* * Allocate arrays */ - src = HDcalloc((size_t)1, nx * ny * nz); - dst = HDcalloc((size_t)1, nx * ny * nz); + if(NULL == (src = HDcalloc((size_t)1, nx * ny * nz))) + TEST_ERROR + if(NULL == (dst = HDcalloc((size_t)1, nx * ny * nz))) + TEST_ERROR + init_full(src, nx, ny, nz); - for (i=0; i<nx; i+=di) { - for (j=0; j<ny; j+=dj) { - for (k=0; k<nz; k+=dk) { - for (dx=1; dx<=nx-i; dx+=ddx) { - for (dy=1; dy<=ny-j; dy+=ddy) { - for (dz=1; dz<=nz-k; dz+=ddz) { - - /* - * Describe the source and destination hyperslabs - * and the arrays to which they belong. - */ - hs_size[0] = dx; - hs_size[1] = dy; - hs_size[2] = dz; - dst_size[0] = src_size[0] = nx; - dst_size[1] = src_size[1] = ny; - dst_size[2] = src_size[2] = nz; - switch (mode) { - case VARIABLE_SRC: - dst_offset[0] = 0; - dst_offset[1] = 0; - dst_offset[2] = 0; - src_offset[0] = i; - src_offset[1] = j; - src_offset[2] = k; - break; - case VARIABLE_DST: - dst_offset[0] = i; - dst_offset[1] = j; - dst_offset[2] = k; - src_offset[0] = 0; - src_offset[1] = 0; - src_offset[2] = 0; - break; - case VARIABLE_BOTH: - dst_offset[0] = i; - dst_offset[1] = j; - dst_offset[2] = k; - src_offset[0] = i; - src_offset[1] = j; - src_offset[2] = k; - break; - default: - abort(); - } - - /* - * Sum the main array directly to get a reference - * value to compare against later. - */ - ref_value = 0; - for (u=src_offset[0]; u<src_offset[0]+dx; u++) { - for (v=src_offset[1]; - v<src_offset[1]+dy; - v++) { - for (w=src_offset[2]; - w<src_offset[2]+dz; - w++) { - ref_value += src[u*ny*nz + v*nz + w]; - } - } - } - - /* - * Set all loc values to 1 so we can detect writing - * outside the hyperslab. - */ - for (u=0; u<nx; u++) { - for (v=0; v<ny; v++) { - for (w=0; w<nz; w++) { - dst[u*ny*nz + v*nz + w] = 1; - } - } - } - - /* - * Copy a hyperslab from the global array to the - * local array. - */ - H5V_hyper_copy(ndims, hs_size, - dst_size, dst_offset, dst, - src_size, src_offset, src); - - /* - * Sum the destination hyperslab. It should be - * the same as the reference value. - */ - acc = 0; - for (u=dst_offset[0]; u<dst_offset[0]+dx; u++) { - for (v=dst_offset[1]; - v<dst_offset[1]+dy; - v++) { - for (w=dst_offset[2]; - w<dst_offset[2]+dz; - w++) { - acc += dst[u*ny*nz + v*nz + w]; - } - } - } - if (acc != ref_value) { - puts("*FAILED*"); - if (!HDisatty(1)) { - /* - * Print debugging info unless output is - * going directly to a terminal. - */ - AT(); - printf(" acc != ref_value\n"); - printf(" i=%lu, j=%lu, k=%lu, " - "dx=%lu, dy=%lu, dz=%lu\n", - (unsigned long)i, - (unsigned long)j, - (unsigned long)k, - (unsigned long)dx, - (unsigned long)dy, - (unsigned long)dz); - print_ref(nx, ny, nz); - printf("\n Destination array is:\n"); - print_array(dst, nx, ny, nz); - } - goto error; - } - /* - * Sum the entire array. It should be a fixed - * amount larger than the reference value since - * we added the border of 1's to the hyperslab. - */ - acc = 0; - for (u=0; u<nx; u++) { - for (v=0; v<ny; v++) { - for (w=0; w<nz; w++) { - acc += dst[u*ny*nz + v*nz + w]; - } - } - } - - /* - * The following casts are to work around an - * optimization bug in the Mongoose 7.20 Irix64 - * compiler. - */ - if (acc+(unsigned)dx*(unsigned)dy*(unsigned)dz != - ref_value + nx*ny*nz) { - puts("*FAILED*"); - if (!HDisatty(1)) { - /* - * Print debugging info unless output is - * going directly to a terminal. - */ - AT(); - printf(" acc != ref_value + nx*ny*nz - " - "dx*dy*dz\n"); - printf(" i=%lu, j=%lu, k=%lu, " - "dx=%lu, dy=%lu, dz=%lu\n", - (unsigned long)i, - (unsigned long)j, - (unsigned long)k, - (unsigned long)dx, - (unsigned long)dy, - (unsigned long)dz); - print_ref(nx, ny, nz); - printf("\n Destination array is:\n"); - print_array(dst, nx, ny, nz); - } - goto error; - } - } - } - } - } - } - } - puts(" PASSED"); + for(i = 0; i < nx; i += di) { + for(j = 0; j < ny; j += dj) { + for(k = 0; k < nz; k += dk) { + for(dx = 1; dx <= nx - i; dx += ddx) { + for(dy = 1; dy <= ny - j; dy += ddy) { + for(dz = 1; dz <= nz - k; dz += ddz) { + + /* + * Describe the source and destination hyperslabs + * and the arrays to which they belong. + */ + hs_size[0] = dx; + hs_size[1] = dy; + hs_size[2] = dz; + dst_size[0] = src_size[0] = nx; + dst_size[1] = src_size[1] = ny; + dst_size[2] = src_size[2] = nz; + switch(mode) { + case VARIABLE_SRC: + dst_offset[0] = 0; + dst_offset[1] = 0; + dst_offset[2] = 0; + src_offset[0] = i; + src_offset[1] = j; + src_offset[2] = k; + break; + + case VARIABLE_DST: + dst_offset[0] = i; + dst_offset[1] = j; + dst_offset[2] = k; + src_offset[0] = 0; + src_offset[1] = 0; + src_offset[2] = 0; + break; + + case VARIABLE_BOTH: + dst_offset[0] = i; + dst_offset[1] = j; + dst_offset[2] = k; + src_offset[0] = i; + src_offset[1] = j; + src_offset[2] = k; + break; + + default: + HDabort(); + } /* end switch */ + + /* + * Sum the main array directly to get a reference + * value to compare against later. + */ + ref_value = 0; + for(u = src_offset[0]; u < src_offset[0] + dx; u++) + for(v = src_offset[1]; v < src_offset[1] + dy; v++) + for(w = src_offset[2]; w < src_offset[2] + dz; w++) + ref_value += src[u * ny * nz + v * nz + w]; + + /* + * Set all loc values to 1 so we can detect writing + * outside the hyperslab. + */ + for(u = 0; u < nx; u++) + for(v = 0; v < ny; v++) + for(w = 0; w < nz; w++) + dst[u * ny * nz + v * nz + w] = 1; + + /* + * Copy a hyperslab from the global array to the + * local array. + */ + H5V_hyper_copy(ndims, hs_size, dst_size, dst_offset, dst, src_size, src_offset, src); + + /* + * Sum the destination hyperslab. It should be + * the same as the reference value. + */ + acc = 0; + for(u = dst_offset[0]; u < dst_offset[0] + dx; u++) + for(v = dst_offset[1]; v < dst_offset[1] + dy; v++) + for(w = dst_offset[2]; w < dst_offset[2] + dz; w++) + acc += dst[u * ny * nz + v * nz + w]; + if(acc != ref_value) { + H5_FAILED() + if(!HDisatty(1)) { + /* + * Print debugging info unless output is + * going directly to a terminal. + */ + AT(); + printf(" acc != ref_value\n"); + printf(" i=%lu, j=%lu, k=%lu, " + "dx=%lu, dy=%lu, dz=%lu\n", + (unsigned long)i, + (unsigned long)j, + (unsigned long)k, + (unsigned long)dx, + (unsigned long)dy, + (unsigned long)dz); + print_ref(nx, ny, nz); + printf("\n Destination array is:\n"); + print_array(dst, nx, ny, nz); + } /* end if */ + goto error; + } /* end if */ + + /* + * Sum the entire array. It should be a fixed + * amount larger than the reference value since + * we added the border of 1's to the hyperslab. + */ + acc = 0; + for(u = 0; u < nx; u++) + for(v = 0; v < ny; v++) + for(w = 0; w < nz; w++) + acc += dst[u * ny * nz + v * nz + w]; + + /* + * The following casts are to work around an + * optimization bug in the Mongoose 7.20 Irix64 + * compiler. + */ + if(acc + (unsigned) dx * (unsigned) dy + * (unsigned) dz != ref_value + nx * ny * nz) { + H5_FAILED() + if(!HDisatty(1)) { + /* + * Print debugging info unless output is + * going directly to a terminal. + */ + AT(); + printf(" acc != ref_value + nx*ny*nz - " + "dx*dy*dz\n"); + printf(" i=%lu, j=%lu, k=%lu, " + "dx=%lu, dy=%lu, dz=%lu\n", + (unsigned long)i, + (unsigned long)j, + (unsigned long)k, + (unsigned long)dx, + (unsigned long)dy, + (unsigned long)dz); + print_ref(nx, ny, nz); + printf("\n Destination array is:\n"); + print_array(dst, nx, ny, nz); + } /* end if */ + goto error; + } /* end if */ + } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ + } /* end for */ + + PASSED() + HDfree(src); HDfree(dst); + return SUCCEED; - error: - HDfree(src); - HDfree(dst); +error: + if(src) + HDfree(src); + if(dst) + HDfree(dst); + return FAIL; -} +} /* end test_copy() */ + /*------------------------------------------------------------------------- * Function: test_multifill @@ -602,39 +582,39 @@ test_copy(int mode, * Programmer: Robb Matzke * Saturday, October 11, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t test_multifill(size_t nx) { - hsize_t i, j; hsize_t size; hsize_t src_stride; hsize_t dst_stride; char s[64]; - struct a_struct { - int left; - double mid; - int right; - } fill , *src = NULL, *dst = NULL; + int left; + double mid; + int right; + } fill, *src = NULL, *dst = NULL; + hsize_t i, j; printf("%-70s", "Testing multi-byte fill value"); fflush(stdout); /* Initialize the source and destination */ - src = HDmalloc(nx * sizeof(*src)); - dst = HDmalloc(nx * sizeof(*dst)); - for (i = 0; i < nx; i++) { - src[i].left = 1111111; - src[i].mid = 12345.6789; - src[i].right = 2222222; - dst[i].left = 3333333; - dst[i].mid = 98765.4321; - dst[i].right = 4444444; - } + if(NULL == (src = HDmalloc(nx * sizeof(*src)))) + TEST_ERROR + if(NULL == (dst = HDmalloc(nx * sizeof(*dst)))) + TEST_ERROR + + for(i = 0; i < nx; i++) { + src[i].left = 1111111; + src[i].mid = 12345.6789; + src[i].right = 2222222; + dst[i].left = 3333333; + dst[i].mid = 98765.4321; + dst[i].right = 4444444; + } /* end for */ /* * Describe the fill value. The zero stride says to read the same thing @@ -654,56 +634,58 @@ test_multifill(size_t nx) * Copy the fill value into each element */ size = nx; - H5V_stride_copy(1, (hsize_t)sizeof(double), &size, - &dst_stride, &(dst[0].mid), &src_stride, &(fill.mid)); + H5V_stride_copy(1, (hsize_t)sizeof(double), &size, &dst_stride, + &(dst[0].mid), &src_stride, &(fill.mid)); /* * Check */ s[0] = '\0'; - for (i = 0; i < nx; i++) { - if (dst[i].left != 3333333) { - sprintf(s, "bad dst[%lu].left", (unsigned long)i); - } else if (!DBL_ABS_EQUAL(dst[i].mid, fill.mid)) { + for(i = 0; i < nx; i++) { + if(dst[i].left != 3333333) + sprintf(s, "bad dst[%lu].left", (unsigned long)i); + else if(!DBL_ABS_EQUAL(dst[i].mid, fill.mid)) /* Check if two DOUBLE values are equal. If their difference * is smaller than the EPSILON value for double, they are * considered equal. See the definition in h5test.h. */ - sprintf(s, "bad dst[%lu].mid", (unsigned long)i); - } else if (dst[i].right != 4444444) { - sprintf(s, "bad dst[%lu].right", (unsigned long)i); - } - if (s[0]) { - puts("*FAILED*"); - if (!HDisatty(1)) { - AT(); - printf(" fill={%d,%g,%d}\n ", - fill.left, fill.mid, fill.right); - for (j = 0; j < sizeof(fill); j++) { - printf(" %02x", ((uint8_t *) &fill)[j]); - } - printf("\n dst[%lu]={%d,%g,%d}\n ", - (unsigned long)i, - dst[i].left, dst[i].mid, dst[i].right); - for (j = 0; j < sizeof(dst[i]); j++) { - printf(" %02x", ((uint8_t *) (dst + i))[j]); - } - printf("\n"); - } - goto error; - } - } + sprintf(s, "bad dst[%lu].mid", (unsigned long)i); + else if(dst[i].right != 4444444) + sprintf(s, "bad dst[%lu].right", (unsigned long)i); + if(s[0]) { + H5_FAILED() + if(!HDisatty(1)) { + AT(); + printf(" fill={%d,%g,%d}\n ", fill.left, fill.mid, + fill.right); + for(j = 0; j < sizeof(fill); j++) + printf(" %02x", ((uint8_t *)&fill)[j]); + printf("\n dst[%lu]={%d,%g,%d}\n ", (unsigned long)i, + dst[i].left, dst[i].mid, dst[i].right); + for(j = 0; j < sizeof(dst[i]); j++) + printf(" %02x", ((uint8_t *)(dst + i))[j]); + printf("\n"); + } /* end if */ + goto error; + } /* end if */ + } /* end for */ + + PASSED() - puts(" PASSED"); HDfree(src); HDfree(dst); + return SUCCEED; - error: - HDfree(src); - HDfree(dst); +error: + if(src) + HDfree(src); + if(dst) + HDfree(dst); + return FAIL; -} +} /* end test_multifill() */ + /*------------------------------------------------------------------------- * Function: test_endian @@ -719,27 +701,28 @@ test_multifill(size_t nx) * Programmer: Robb Matzke * Saturday, October 11, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t test_endian(size_t nx) { - uint8_t *src = NULL; /*source array */ - uint8_t *dst = NULL; /*destination array */ + uint8_t *src = NULL; /*source array */ + uint8_t *dst = NULL; /*destination array */ hssize_t src_stride[2]; /*source strides */ hssize_t dst_stride[2]; /*destination strides */ - hsize_t size[2]; /*size vector */ - hsize_t i, j; + hsize_t size[2]; /*size vector */ + hsize_t i, j; printf("%-70s", "Testing endian conversion by stride"); fflush(stdout); /* Initialize arrays */ - src = HDmalloc(nx * 4); - init_full(src, nx, (size_t)4, (size_t)1); - dst = HDcalloc(nx , (size_t)4); + if(NULL == (src = HDmalloc(nx * 4))) + TEST_ERROR + if(NULL == (dst = HDcalloc(nx , (size_t)4))) + TEST_ERROR + + init_full(src, nx, (size_t)4,(size_t)1); /* Initialize strides */ src_stride[0] = 0; @@ -753,38 +736,43 @@ test_endian(size_t nx) H5V_stride_copy_s(2, (hsize_t)1, size, dst_stride, dst + 3, src_stride, src); /* Compare */ - for (i = 0; i < nx; i++) { - for (j = 0; j < 4; j++) { - if (src[i * 4 + j] != dst[i * 4 + 3 - j]) { - puts("*FAILED*"); - if (!HDisatty(1)) { - /* - * Print debugging info unless output is going directly - * to a terminal. - */ - AT(); - printf(" i=%lu, j=%lu\n", - (unsigned long)i, (unsigned long)j); - printf(" Source array is:\n"); - print_array(src, nx, (size_t)4, (size_t)1); - printf("\n Result is:\n"); - print_array(dst, nx, (size_t)4, (size_t)1); - } - goto error; - } - } - } - - puts(" PASSED"); + for(i = 0; i < nx; i++) { + for(j = 0; j < 4; j++) { + if(src[i * 4 + j] != dst[i * 4 + 3 - j]) { + H5_FAILED() + if(!HDisatty(1)) { + /* + * Print debugging info unless output is going directly + * to a terminal. + */ + AT(); + printf(" i=%lu, j=%lu\n", (unsigned long)i, (unsigned long)j); + printf(" Source array is:\n"); + print_array(src, nx, (size_t)4, (size_t)1); + printf("\n Result is:\n"); + print_array(dst, nx, (size_t)4, (size_t)1); + } /* end if */ + goto error; + } /* end if */ + } /* end for */ + } /* end for */ + + PASSED() + HDfree(src); HDfree(dst); + return SUCCEED; - error: - HDfree(src); - HDfree(dst); +error: + if(src) + HDfree(src); + if(dst) + HDfree(dst); + return FAIL; -} +} /* end test_endian() */ + /*------------------------------------------------------------------------- * Function: test_transpose @@ -799,33 +787,32 @@ test_endian(size_t nx) * Programmer: Robb Matzke * Saturday, October 11, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t test_transpose(size_t nx, size_t ny) { - int *src = NULL; - int *dst = NULL; - hsize_t i, j; + int *src = NULL; + int *dst = NULL; hsize_t src_stride[2], dst_stride[2]; hsize_t size[2]; char s[256]; + hsize_t i, j; - sprintf(s, "Testing 2d transpose by stride %4lux%-lud", - (unsigned long) nx, (unsigned long) ny); + sprintf(s, "Testing 2d transpose by stride %4lux%-lud", (unsigned long)nx, + (unsigned long)ny); printf("%-70s", s); fflush(stdout); /* Initialize */ - src = HDmalloc(nx * ny * sizeof(*src)); - for (i = 0; i < nx; i++) { - for (j = 0; j < ny; j++) { - src[i * ny + j] = (int)(i * ny + j); - } - } - dst = HDcalloc(nx*ny,sizeof(*dst)); + if(NULL == (src = HDmalloc(nx * ny * sizeof(*src)))) + TEST_ERROR + if(NULL == (dst = HDcalloc(nx * ny, sizeof(*dst)))) + TEST_ERROR + + for(i = 0; i < nx; i++) + for(j = 0; j < ny; j++) + src[i * ny + j] = (int)(i * ny + j); /* Build stride info */ size[0] = nx; @@ -836,57 +823,57 @@ test_transpose(size_t nx, size_t ny) dst_stride[1] = (ssize_t)(nx * sizeof(*src)); /* Copy and transpose */ - if (nx == ny) { - H5V_stride_copy(2, (hsize_t)sizeof(*src), size, - dst_stride, dst, - src_stride, src); - } else { - H5V_stride_copy(2, (hsize_t)sizeof(*src), size, - dst_stride, dst, - src_stride, src); - } + if(nx == ny) + H5V_stride_copy(2, (hsize_t)sizeof(*src), size, dst_stride, dst, + src_stride, src); + else + H5V_stride_copy(2, (hsize_t)sizeof(*src), size, dst_stride, dst, + src_stride, src); /* Check */ - for (i = 0; i < nx; i++) { - for (j = 0; j < ny; j++) { - if (src[i * ny + j] != dst[j * nx + i]) { - puts("*FAILED*"); - if (!HDisatty(1)) { - AT(); - printf(" diff at i=%lu, j=%lu\n", - (unsigned long)i, (unsigned long)j); - printf(" Source is:\n"); - for (i = 0; i < nx; i++) { - printf("%3lu:", (unsigned long)i); - for (j = 0; j < ny; j++) { - printf(" %6d", src[i * ny + j]); - } - printf("\n"); - } - printf("\n Destination is:\n"); - for (i = 0; i < ny; i++) { - printf("%3lu:", (unsigned long)i); - for (j = 0; j < nx; j++) { - printf(" %6d", dst[i * nx + j]); - } - printf("\n"); - } - } - goto error; - } - } - } - - puts(" PASSED"); + for(i = 0; i < nx; i++) { + for(j = 0; j < ny; j++) { + if(src[i * ny + j] != dst[j * nx + i]) { + H5_FAILED() + if(!HDisatty(1)) { + AT(); + printf(" diff at i=%lu, j=%lu\n", (unsigned long)i, (unsigned long)j); + printf(" Source is:\n"); + for(i = 0; i < nx; i++) { + printf("%3lu:", (unsigned long)i); + for(j = 0; j < ny; j++) + printf(" %6d", src[i * ny + j]); + printf("\n"); + } /* end for */ + printf("\n Destination is:\n"); + for (i = 0; i < ny; i++) { + printf("%3lu:", (unsigned long)i); + for(j = 0; j < nx; j++) + printf(" %6d", dst[i * nx + j]); + printf("\n"); + } /* end for */ + } /* end if */ + goto error; + } /* end if */ + } /* end for */ + } /* end for */ + + PASSED() + HDfree(src); HDfree(dst); + return SUCCEED; - error: - HDfree(src); - HDfree(dst); +error: + if(src) + HDfree(src); + if(dst) + HDfree(dst); + return FAIL; -} +} /* end test_transpose() */ + /*------------------------------------------------------------------------- * Function: test_sub_super @@ -903,33 +890,35 @@ test_transpose(size_t nx, size_t ny) * Programmer: Robb Matzke * Monday, October 13, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t test_sub_super(size_t nx, size_t ny) { - uint8_t *full = NULL; /*original image */ - uint8_t *half = NULL; /*image at 1/2 resolution */ - uint8_t *twice = NULL; /*2x2 pixels */ - hsize_t src_stride[4]; /*source stride info */ - hsize_t dst_stride[4]; /*destination stride info */ - hsize_t size[4]; /*number of sample points */ - hsize_t i, j; - char s[256]; + uint8_t *full = NULL; /*original image */ + uint8_t *half = NULL; /*image at 1/2 resolution */ + uint8_t *twice = NULL; /*2x2 pixels */ + hsize_t src_stride[4]; /*source stride info */ + hsize_t dst_stride[4]; /*destination stride info */ + hsize_t size[4]; /*number of sample points */ + hsize_t i, j; + char s[256]; sprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ", - (unsigned long) (2 * nx), (unsigned long) (2 * ny), - (unsigned long) nx, (unsigned long) ny); + (unsigned long)(2 * nx), (unsigned long)(2 * ny), + (unsigned long)nx, (unsigned long)ny); printf("%-70s", s); fflush(stdout); /* Initialize */ - full = HDmalloc(4 * nx * ny); + if(NULL == (full = HDmalloc(4 * nx * ny))) + TEST_ERROR + if(NULL == (half = HDcalloc((size_t)1, nx * ny))) + TEST_ERROR + if(NULL == (twice = HDcalloc((size_t)4, nx * ny))) + TEST_ERROR + init_full(full, 2 * nx, 2 * ny, (size_t)1); - half = HDcalloc((size_t)1, nx * ny); - twice = HDcalloc((size_t)4, nx * ny); /* Setup */ size[0] = nx; @@ -940,39 +929,37 @@ test_sub_super(size_t nx, size_t ny) dst_stride[1] = 1; /* Copy */ - H5V_stride_copy(2, (hsize_t)sizeof(uint8_t), size, - dst_stride, half, src_stride, full); + H5V_stride_copy(2, (hsize_t)sizeof(uint8_t), size, dst_stride, half, + src_stride, full); /* Check */ - for (i = 0; i < nx; i++) { - for (j = 0; j < ny; j++) { - if (full[4 * i * ny + 2 * j] != half[i * ny + j]) { - puts("*FAILED*"); - if (!HDisatty(1)) { - AT(); - printf(" full[%lu][%lu] != half[%lu][%lu]\n", - (unsigned long)i*2, - (unsigned long)j*2, - (unsigned long)i, - (unsigned long)j); - printf(" full is:\n"); - print_array(full, 2 * nx, 2 * ny, (size_t)1); - printf("\n half is:\n"); - print_array(half, nx, ny, (size_t)1); - } - goto error; - } - } - } - puts(" PASSED"); + for(i = 0; i < nx; i++) { + for(j = 0; j < ny; j++) { + if(full[4 * i * ny + 2 * j] != half[i * ny + j]) { + H5_FAILED() + if(!HDisatty(1)) { + AT(); + printf(" full[%lu][%lu] != half[%lu][%lu]\n", + (unsigned long)i * 2, (unsigned long)j * 2, + (unsigned long)i, (unsigned long)j); + printf(" full is:\n"); + print_array(full, 2 * nx, 2 * ny, (size_t)1); + printf("\n half is:\n"); + print_array(half, nx, ny, (size_t)1); + } /* end if */ + goto error; + } /* end if */ + } /* end for */ + } /* end for */ + PASSED() /* * Test replicating pixels to produce an image twice as large in each * dimension. */ sprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ", - (unsigned long) nx, (unsigned long) ny, - (unsigned long) (2 * nx), (unsigned long) (2 * ny)); + (unsigned long)nx, (unsigned long)ny, (unsigned long)(2 * nx), + (unsigned long)(2 * ny)); printf("%-70s", s); fflush(stdout); @@ -991,64 +978,62 @@ test_sub_super(size_t nx, size_t ny) dst_stride[3] = sizeof(uint8_t); /* Copy */ - H5V_stride_copy(4, (hsize_t)sizeof(uint8_t), size, - dst_stride, twice, src_stride, half); + H5V_stride_copy(4, (hsize_t)sizeof(uint8_t), size, dst_stride, twice, + src_stride, half); /* Check */ s[0] = '\0'; - for (i = 0; i < nx; i++) { - for (j = 0; j < ny; j++) { - if (half[i*ny+j] != twice[4*i*ny + 2*j]) { - sprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", - (unsigned long)i, - (unsigned long)j, - (unsigned long)i*2, - (unsigned long)j*2); - } else if (half[i*ny + j] != twice[4*i*ny + 2*j + 1]) { - sprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", - (unsigned long)i, - (unsigned long)j, - (unsigned long)i*2, - (unsigned long)j*2+1); - } else if (half[i*ny + j] != twice[(2*i +1)*2*ny + 2*j]) { - sprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", - (unsigned long)i, - (unsigned long)j, - (unsigned long)i*2+1, - (unsigned long)j*2); - } else if (half[i*ny + j] != twice[(2*i+1)*2*ny + 2*j+1]) { - sprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", - (unsigned long)i, - (unsigned long)j, - (unsigned long)i*2+1, - (unsigned long)j*2+1); - } - if (s[0]) { - puts("*FAILED*"); - if (!HDisatty(1)) { - AT(); - printf(" %s\n Half is:\n", s); - print_array(half, nx, ny, (size_t)1); - printf("\n Twice is:\n"); - print_array(twice, 2 * nx, 2 * ny, (size_t)1); - } - goto error; - } - } - } - puts(" PASSED"); + for(i = 0; i < nx; i++) { + for(j = 0; j < ny; j++) { + if(half[i * ny + j] != twice[4 * i * ny + 2 * j]) + sprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", + (unsigned long)i, (unsigned long)j, + (unsigned long)i * 2, (unsigned long)j * 2); + else if(half[i * ny + j] != twice[4 * i * ny + 2 * j + 1]) + sprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", + (unsigned long)i, (unsigned long)j, + (unsigned long)i * 2, (unsigned long)j * 2 + 1); + else if(half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j]) + sprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", + (unsigned long)i, (unsigned long)j, + (unsigned long)i * 2 + 1, (unsigned long)j * 2); + else if(half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j + 1]) + sprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", + (unsigned long)i, (unsigned long)j, + (unsigned long)i * 2 + 1, (unsigned long)j * 2 + 1); + if(s[0]) { + H5_FAILED() + if(!HDisatty(1)) { + AT(); + printf(" %s\n Half is:\n", s); + print_array(half, nx, ny, (size_t)1); + printf("\n Twice is:\n"); + print_array(twice, 2 * nx, 2 * ny, (size_t)1); + } /* end if */ + goto error; + } /* end if */ + } /* end for */ + } /* end for */ + + PASSED() HDfree(full); HDfree(half); HDfree(twice); + return SUCCEED; - error: - HDfree(full); - HDfree(half); - HDfree(twice); +error: + if(full) + HDfree(full); + if(half) + HDfree(half); + if(twice) + HDfree(twice); + return FAIL; -} +} /* test_sub_super() */ + /*------------------------------------------------------------------------- * Function: test_array_fill @@ -1064,15 +1049,13 @@ test_sub_super(size_t nx, size_t ny) * Programmer: Quincey Koziol * Monday, April 21, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t test_array_fill(size_t lo, size_t hi) { - int *dst; /* Destination */ - int src[ARRAY_FILL_SIZE]; /* Source to duplicate */ + int *dst = NULL; /* Destination */ + int src[ARRAY_FILL_SIZE]; /* Source to duplicate */ size_t u, v, w; /* Local index variables */ char s[256]; @@ -1080,32 +1063,38 @@ test_array_fill(size_t lo, size_t hi) TESTING(s); /* Initialize */ - dst = HDcalloc(sizeof(int),ARRAY_FILL_SIZE * hi); + if(NULL == (dst = HDcalloc(sizeof(int),ARRAY_FILL_SIZE * hi))) + TEST_ERROR /* Setup */ - for(u=0; u<ARRAY_FILL_SIZE; u++) - src[u]=(char)u; + for(u = 0; u < ARRAY_FILL_SIZE; u++) + src[u] = (char)u; /* Fill */ - for(w=lo; w<=hi; w++) { - H5V_array_fill(dst,src,sizeof(src),w); + for(w = lo; w <= hi; w++) { + H5V_array_fill(dst, src, sizeof(src), w); /* Check */ - for(u=0; u<w; u++) - for(v=0; v<ARRAY_FILL_SIZE; v++) - if(dst[(u*ARRAY_FILL_SIZE)+v]!=src[v]) TEST_ERROR; + for(u = 0; u < w; u++) + for(v = 0; v < ARRAY_FILL_SIZE; v++) + if(dst[(u * ARRAY_FILL_SIZE) + v] != src[v]) + TEST_ERROR - HDmemset(dst,0,sizeof(int)*ARRAY_FILL_SIZE*w); + HDmemset(dst, 0, sizeof(int) * ARRAY_FILL_SIZE * w); } /* end for */ + PASSED(); HDfree(dst); + return SUCCEED; - error: - HDfree(dst); +error: + if(dst) + HDfree(dst); return FAIL; -} +} /* end test_array_fill() */ + /*------------------------------------------------------------------------- * Function: test_array_offset_n_calc @@ -1121,14 +1110,13 @@ test_array_fill(size_t lo, size_t hi) * Programmer: Quincey Koziol * Monday, April 21, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t test_array_offset_n_calc(size_t n, size_t x, size_t y, size_t z) { - hsize_t *a, *temp_a; /* Array for stored calculated offsets */ + hsize_t *a = NULL; + hsize_t *temp_a; /* Array for stored calculated offsets */ hsize_t off; /* Offset in array */ size_t u, v, w; /* Local index variables */ hsize_t dims[ARRAY_OFFSET_NDIMS]; /* X, Y & X coordinates of array to check */ @@ -1140,50 +1128,58 @@ test_array_offset_n_calc(size_t n, size_t x, size_t y, size_t z) TESTING(s); /* Initialize */ - a = HDmalloc(sizeof(hsize_t) * x * y *z); - dims[0]=z; - dims[1]=y; - dims[2]=x; + if(NULL == (a = HDmalloc(sizeof(hsize_t) * x * y *z))) + TEST_ERROR + + dims[0] = z; + dims[1] = y; + dims[2] = x; /* Setup */ - for(u=0, temp_a=a, off=0; u<z; u++) - for(v=0; v<y; v++) - for(w=0; w<x; w++) + for(u = 0, temp_a = a, off = 0; u < z; u++) + for(v = 0; v < y; v++) + for(w = 0; w < x; w++) *temp_a++ = off++; /* Check offsets */ - for(u=0; u<n; u++) { + for(u = 0; u < n; u++) { /* Get random coordinate */ coords[0] = (hssize_t)(HDrandom() % z); coords[1] = (hssize_t)(HDrandom() % y); coords[2] = (hssize_t)(HDrandom() % x); /* Get offset of coordinate */ - off=H5V_array_offset(ARRAY_OFFSET_NDIMS,dims,coords); + off = H5V_array_offset(ARRAY_OFFSET_NDIMS, dims, coords); /* Check offset of coordinate */ - if(a[off]!=off) TEST_ERROR; + if(a[off] != off) + TEST_ERROR /* Get coordinates of offset */ - if(H5V_array_calc(off,ARRAY_OFFSET_NDIMS,dims,new_coords)<0) TEST_ERROR; + if(H5V_array_calc(off, ARRAY_OFFSET_NDIMS, dims, new_coords) < 0) + TEST_ERROR /* Check computed coordinates */ - for(v=0; v<ARRAY_OFFSET_NDIMS; v++) - if(coords[v]!=new_coords[v]) { - HDfprintf(stderr,"coords[%u]=%Hu, new_coords[%u]=%Hu\n",(unsigned)v,coords[v],(unsigned)v,new_coords[v]); + for(v = 0; v < ARRAY_OFFSET_NDIMS; v++) + if(coords[v] != new_coords[v]) { + HDfprintf(stderr,"coords[%u]=%Hu, new_coords[%u]=%Hu\n", (unsigned)v, coords[v], (unsigned)v, new_coords[v]); TEST_ERROR; - } + } /* end if */ } /* end for */ PASSED(); HDfree(a); + return SUCCEED; - error: - HDfree(a); +error: + if(a) + HDfree(a); + return FAIL; -} +} /* end test_array_offset_n_calc() */ + /*------------------------------------------------------------------------- * Function: main @@ -1199,8 +1195,6 @@ test_array_offset_n_calc(size_t n, size_t x, size_t y, size_t z) * Programmer: Robb Matzke * Friday, October 10, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -1208,29 +1202,31 @@ main(int argc, char *argv[]) { herr_t status; int nerrors = 0; - unsigned size_of_test; + unsigned size_of_test; /* Parse arguments or assume `small' & `medium' */ - if (1 == argc) { - size_of_test = TEST_SMALL | TEST_MEDIUM; - } else { - int i; - for (i = 1, size_of_test = 0; i < argc; i++) { - if (!strcmp(argv[i], "small")) { - size_of_test |= TEST_SMALL; - } else if (!strcmp(argv[i], "medium")) { - size_of_test |= TEST_MEDIUM; - } else { - printf("unrecognized argument: %s\n", argv[i]); - exit(1); - } - } - } + if(1 == argc) + size_of_test = TEST_SMALL | TEST_MEDIUM; + else { + int i; + + for(i = 1, size_of_test = 0; i < argc; i++) { + if(!HDstrcmp(argv[i], "small")) + size_of_test |= TEST_SMALL; + else if(!HDstrcmp(argv[i], "medium")) + size_of_test |= TEST_MEDIUM; + else { + printf("unrecognized argument: %s\n", argv[i]); + HDexit(1); + } /* end else */ + } /* end for */ + } /* end else */ + printf("Test sizes: "); - if (size_of_test & TEST_SMALL) - printf(" SMALL"); - if (size_of_test & TEST_MEDIUM) - printf(" MEDIUM"); + if(size_of_test & TEST_SMALL) + printf(" SMALL"); + if(size_of_test & TEST_MEDIUM) + printf(" MEDIUM"); printf("\n"); /* Set the random # seed */ @@ -1249,176 +1245,207 @@ main(int argc, char *argv[]) * TEST HYPERSLAB FILL OPERATION *------------------------------ */ - if (size_of_test & TEST_SMALL) { - status = test_fill((size_t)11, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - status = test_fill((size_t)11, (size_t)10, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - status = test_fill((size_t)3, (size_t)5, (size_t)5, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - } - if (size_of_test & TEST_MEDIUM) { - status = test_fill((size_t)113, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - status = test_fill((size_t)15, (size_t)11, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - status = test_fill((size_t)5, (size_t)7, (size_t)7, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - } - /*------------------------------ - * TEST HYPERSLAB COPY OPERATION - *------------------------------ - */ + if(size_of_test & TEST_SMALL) { + status = test_fill((size_t)11, (size_t)0, (size_t)0, (size_t)1, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + status = test_fill((size_t)11, (size_t)10, (size_t)0, (size_t)1, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + status = test_fill((size_t)3, (size_t)5, (size_t)5, (size_t)1, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + } /* end if */ + if(size_of_test & TEST_MEDIUM) { + status = test_fill((size_t)113, (size_t)0, (size_t)0, (size_t)1, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + status = test_fill((size_t)15, (size_t)11, (size_t)0, (size_t)1, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + status = test_fill((size_t)5, (size_t)7, (size_t)7, (size_t)1, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + } /* end if */ + + /*------------------------------ + * TEST HYPERSLAB COPY OPERATION + *------------------------------ + */ /* exhaustive, one-dimensional test */ - if (size_of_test & TEST_SMALL) { - status = test_copy(VARIABLE_SRC, (size_t)11, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_DST, (size_t)11, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_BOTH, (size_t)11, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - } - if (size_of_test & TEST_MEDIUM) { - status = test_copy(VARIABLE_SRC, (size_t)179, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_DST, (size_t)179, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_BOTH, (size_t)179, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - } + if(size_of_test & TEST_SMALL) { + status = test_copy(VARIABLE_SRC, (size_t)11, (size_t)0, (size_t)0, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + status = test_copy(VARIABLE_DST, (size_t)11, (size_t)0, (size_t)0, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + status = test_copy(VARIABLE_BOTH, (size_t)11, (size_t)0, (size_t)0, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + } /* end if */ + if(size_of_test & TEST_MEDIUM) { + status = test_copy(VARIABLE_SRC, (size_t)179, (size_t)0, (size_t)0, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + status = test_copy(VARIABLE_DST, (size_t)179, (size_t)0, (size_t)0, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + status = test_copy(VARIABLE_BOTH, (size_t)179, (size_t)0, (size_t)0, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + } /* end if */ /* exhaustive, two-dimensional test */ - if (size_of_test & TEST_SMALL) { - status = test_copy(VARIABLE_SRC, (size_t)11, (size_t)10, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_DST, (size_t)11, (size_t)10, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_BOTH, (size_t)11, (size_t)10, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - } - if (size_of_test & TEST_MEDIUM) { - status = test_copy(VARIABLE_SRC, (size_t)13, (size_t)19, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_DST, (size_t)13, (size_t)19, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_BOTH, (size_t)13, (size_t)19, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - } + if(size_of_test & TEST_SMALL) { + status = test_copy(VARIABLE_SRC, (size_t)11, (size_t)10, (size_t)0, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + status = test_copy(VARIABLE_DST, (size_t)11, (size_t)10, (size_t)0, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + status = test_copy(VARIABLE_BOTH, (size_t)11, (size_t)10, (size_t)0, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + } /* end if */ + if(size_of_test & TEST_MEDIUM) { + status = test_copy(VARIABLE_SRC, (size_t)13, (size_t)19, (size_t)0, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + status = test_copy(VARIABLE_DST, (size_t)13, (size_t)19, (size_t)0, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + status = test_copy(VARIABLE_BOTH, (size_t)13, (size_t)19, (size_t)0, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + } /* end if */ /* sparse, two-dimensional test */ - if (size_of_test & TEST_MEDIUM) { - status = test_copy(VARIABLE_SRC, (size_t)73, (size_t)67, (size_t)0, (size_t)7, (size_t)11, (size_t)1, (size_t)13, (size_t)11, (size_t)1); - nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_DST, (size_t)73, (size_t)67, (size_t)0, (size_t)7, (size_t)11, (size_t)1, (size_t)13, (size_t)11, (size_t)1); - nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_BOTH, (size_t)73, (size_t)67, (size_t)0, (size_t)7, (size_t)11, (size_t)1, (size_t)13, (size_t)11, (size_t)1); - nerrors += status < 0 ? 1 : 0; - } + if(size_of_test & TEST_MEDIUM) { + status = test_copy(VARIABLE_SRC, (size_t)73, (size_t)67, (size_t)0, + (size_t)7, (size_t)11, (size_t)1, (size_t)13, (size_t)11, (size_t)1); + nerrors += status < 0 ? 1 : 0; + status = test_copy(VARIABLE_DST, (size_t)73, (size_t)67, (size_t)0, + (size_t)7, (size_t)11, (size_t)1, (size_t)13, (size_t)11, (size_t)1); + nerrors += status < 0 ? 1 : 0; + status = test_copy(VARIABLE_BOTH, (size_t)73, (size_t)67, (size_t)0, + (size_t)7, (size_t)11, (size_t)1, (size_t)13, (size_t)11, (size_t)1); + nerrors += status < 0 ? 1 : 0; + } /* end if */ /* exhaustive, three-dimensional test */ - if (size_of_test & TEST_SMALL) { - status = test_copy(VARIABLE_SRC, (size_t)3, (size_t)5, (size_t)5, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_DST, (size_t)3, (size_t)5, (size_t)5, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_BOTH, (size_t)3, (size_t)5, (size_t)5, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - } - if (size_of_test & TEST_MEDIUM) { - status = test_copy(VARIABLE_SRC, (size_t)7, (size_t)9, (size_t)5, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_DST, (size_t)7, (size_t)9, (size_t)5, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - status = test_copy(VARIABLE_BOTH, (size_t)7, (size_t)9, (size_t)5, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); - nerrors += status < 0 ? 1 : 0; - } - /*--------------------- - * TEST MULTI-BYTE FILL - *--------------------- - */ - - if (size_of_test & TEST_SMALL) { - status = test_multifill((size_t)10); - nerrors += status < 0 ? 1 : 0; - } - if (size_of_test & TEST_MEDIUM) { - status = test_multifill((size_t)500000); - nerrors += status < 0 ? 1 : 0; - } - /*--------------------------- - * TEST TRANSLATION OPERATORS - *--------------------------- - */ - - if (size_of_test & TEST_SMALL) { - status = test_endian((size_t)10); - nerrors += status < 0 ? 1 : 0; - status = test_transpose((size_t)9, (size_t)9); - nerrors += status < 0 ? 1 : 0; - status = test_transpose((size_t)3, (size_t)11); - nerrors += status < 0 ? 1 : 0; - } - if (size_of_test & TEST_MEDIUM) { - status = test_endian((size_t)800000); - nerrors += status < 0 ? 1 : 0; - status = test_transpose((size_t)1200, (size_t)1200); - nerrors += status < 0 ? 1 : 0; - status = test_transpose((size_t)800, (size_t)1800); - nerrors += status < 0 ? 1 : 0; - } - /*------------------------- - * TEST SAMPLING OPERATIONS - *------------------------- - */ - - if (size_of_test & TEST_SMALL) { - status = test_sub_super((size_t)5, (size_t)10); - nerrors += status < 0 ? 1 : 0; - } - if (size_of_test & TEST_MEDIUM) { - status = test_sub_super((size_t)480, (size_t)640); - nerrors += status < 0 ? 1 : 0; - } - /*------------------------- - * TEST ARRAY FILL OPERATIONS - *------------------------- - */ - - if (size_of_test & TEST_SMALL) { - status = test_array_fill((size_t)1, (size_t)9); - nerrors += status < 0 ? 1 : 0; - } - if (size_of_test & TEST_MEDIUM) { - status = test_array_fill((size_t)9, (size_t)257); - nerrors += status < 0 ? 1 : 0; - } - /*------------------------- - * TEST ARRAY OFFSET OPERATIONS - *------------------------- - */ - - if (size_of_test & TEST_SMALL) { - status = test_array_offset_n_calc((size_t)20, (size_t)7, (size_t)11, (size_t)13); - nerrors += status < 0 ? 1 : 0; - } - if (size_of_test & TEST_MEDIUM) { - status = test_array_offset_n_calc((size_t)500, (size_t)71, (size_t)193, (size_t)347); - nerrors += status < 0 ? 1 : 0; - } + if(size_of_test & TEST_SMALL) { + status = test_copy(VARIABLE_SRC, (size_t)3, (size_t)5, (size_t)5, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + status = test_copy(VARIABLE_DST, (size_t)3, (size_t)5, (size_t)5, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + status = test_copy(VARIABLE_BOTH, (size_t)3, (size_t)5, (size_t)5, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + } /* end if */ + if(size_of_test & TEST_MEDIUM) { + status = test_copy(VARIABLE_SRC, (size_t)7, (size_t)9, (size_t)5, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + status = test_copy(VARIABLE_DST, (size_t)7, (size_t)9, (size_t)5, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + status = test_copy(VARIABLE_BOTH, (size_t)7, (size_t)9, (size_t)5, + (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1); + nerrors += status < 0 ? 1 : 0; + } /* end if */ + + /*--------------------- + * TEST MULTI-BYTE FILL + *--------------------- + */ + if(size_of_test & TEST_SMALL) { + status = test_multifill((size_t)10); + nerrors += status < 0 ? 1 : 0; + } /* end if */ + if(size_of_test & TEST_MEDIUM) { + status = test_multifill((size_t)500000); + nerrors += status < 0 ? 1 : 0; + } /* end if */ + + /*--------------------------- + * TEST TRANSLATION OPERATORS + *--------------------------- + */ + if(size_of_test & TEST_SMALL) { + status = test_endian((size_t)10); + nerrors += status < 0 ? 1 : 0; + status = test_transpose((size_t)9, (size_t)9); + nerrors += status < 0 ? 1 : 0; + status = test_transpose((size_t)3, (size_t)11); + nerrors += status < 0 ? 1 : 0; + } /* end if */ + if(size_of_test & TEST_MEDIUM) { + status = test_endian((size_t)800000); + nerrors += status < 0 ? 1 : 0; + status = test_transpose((size_t)1200, (size_t)1200); + nerrors += status < 0 ? 1 : 0; + status = test_transpose((size_t)800, (size_t)1800); + nerrors += status < 0 ? 1 : 0; + } /* end if */ + + /*------------------------- + * TEST SAMPLING OPERATIONS + *------------------------- + */ + if(size_of_test & TEST_SMALL) { + status = test_sub_super((size_t)5, (size_t)10); + nerrors += status < 0 ? 1 : 0; + } /* end if */ + if(size_of_test & TEST_MEDIUM) { + status = test_sub_super((size_t)480, (size_t)640); + nerrors += status < 0 ? 1 : 0; + } /* end if */ + + /*------------------------- + * TEST ARRAY FILL OPERATIONS + *------------------------- + */ + if(size_of_test & TEST_SMALL) { + status = test_array_fill((size_t)1, (size_t)9); + nerrors += status < 0 ? 1 : 0; + } /* end if */ + if(size_of_test & TEST_MEDIUM) { + status = test_array_fill((size_t)9, (size_t)257); + nerrors += status < 0 ? 1 : 0; + } /* end if */ + + /*------------------------- + * TEST ARRAY OFFSET OPERATIONS + *------------------------- + */ + if(size_of_test & TEST_SMALL) { + status = test_array_offset_n_calc((size_t)20, (size_t)7, (size_t)11, + (size_t)13); + nerrors += status < 0 ? 1 : 0; + } /* end if */ + if(size_of_test & TEST_MEDIUM) { + status = test_array_offset_n_calc((size_t)500, (size_t)71, + (size_t)193, (size_t)347); + nerrors += status < 0 ? 1 : 0; + } /* end if */ /*--- END OF TESTS ---*/ - if (nerrors) { - printf("***** %d HYPERSLAB TEST%s FAILED! *****\n", - nerrors, 1 == nerrors ? "" : "S"); - if (HDisatty(1)) { - printf("(Redirect output to a pager or a file to see " - "debug output)\n"); - } - exit(1); - } + if(nerrors) { + printf("***** %d HYPERSLAB TEST%s FAILED! *****\n", nerrors, 1 + == nerrors ? "" : "S"); + if(HDisatty(1)) + printf("(Redirect output to a pager or a file to see debug output)\n"); + HDexit(1); + } /* end if */ + printf("All hyperslab tests passed.\n"); #ifdef H5_HAVE_THREADSAFE H5close(); #endif /* H5_HAVE_THREADSAFE */ + return 0; } + diff --git a/test/trefstr.c b/test/trefstr.c index c39a6eb..dd76cc1 100644 --- a/test/trefstr.c +++ b/test/trefstr.c @@ -301,6 +301,7 @@ test_refstr_own(void) /* Initialize buffer */ s = (char *)H5FL_BLK_MALLOC(str_buf,HDstrlen("foo") + 1); + CHECK(s, NULL, "H5FL_BLK_MALLOC"); HDstrcpy(s, "foo"); /* Transfer ownership of dynamically allocated string to ref-counted string */ diff --git a/test/tvlstr.c b/test/tvlstr.c index a411b86..fbced5f 100644 --- a/test/tvlstr.c +++ b/test/tvlstr.c @@ -573,7 +573,7 @@ static void test_write_vl_string_attribute(void) hid_t file, root, dataspace, att; hid_t type; herr_t ret; - char *string_att_check; + char *string_att_check = NULL; /* Open the file */ file = H5Fopen(DATAFILE, H5F_ACC_RDWR, H5P_DEFAULT); @@ -599,13 +599,21 @@ static void test_write_vl_string_attribute(void) ret = H5Awrite(att, type, &string_att); CHECK(ret, FAIL, "H5Awrite"); - ret = H5Aread(att, type, &string_att_check); - CHECK(ret, FAIL, "H5Aread"); + /* Allocate memory for read buffer */ + if(string_att) + string_att_check = (char*)HDmalloc((strlen(string_att) + 1) * sizeof(char)); + CHECK(string_att_check, NULL, "HDmalloc"); - if(HDstrcmp(string_att_check,string_att)!=0) - TestErrPrintf("VL string attributes don't match!, string_att=%s, string_att_check=%s\n",string_att,string_att_check); + if(string_att_check) { + ret = H5Aread(att, type, &string_att_check); + CHECK(ret, FAIL, "H5Aread"); - HDfree(string_att_check); + if(HDstrcmp(string_att_check,string_att)!=0) + TestErrPrintf("VL string attributes don't match!, string_att=%s, string_att_check=%s\n",string_att,string_att_check); + + HDfree(string_att_check); + string_att_check = NULL; + } ret = H5Aclose(att); CHECK(ret, FAIL, "HAclose"); @@ -620,13 +628,23 @@ static void test_write_vl_string_attribute(void) ret = H5Awrite(att, type, &string_att_write); CHECK(ret, FAIL, "H5Awrite"); - ret = H5Aread(att, type, &string_att_check); - CHECK(ret, FAIL, "H5Aread"); + /* Allocate memory for read buffer */ + if(string_att_write) + string_att_check = (char*)HDmalloc((strlen(string_att_write) + 1) * sizeof(char)); + CHECK(string_att_check, NULL, "HDmalloc"); + + if(string_att_check) { + ret = H5Aread(att, type, &string_att_check); + CHECK(ret, FAIL, "H5Aread"); - if(HDstrcmp(string_att_check,string_att_write)!=0) - TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check); + if(HDstrcmp(string_att_check,string_att_write)!=0) + TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check); + + /* The attribute string written is freed below, in the + *test_read_vl_string_attribute() test */ + HDfree(string_att_check); + } - HDfree(string_att_check); /* The attribute string written is freed below, in the test_read_vl_string_attribute() test */ /* HDfree(string_att_write); */ @@ -659,7 +677,7 @@ static void test_read_vl_string_attribute(void) hid_t file, root, att; hid_t type; herr_t ret; - char *string_att_check; + char *string_att_check = NULL; /* Open file */ file = H5Fopen(DATAFILE, H5F_ACC_RDONLY, H5P_DEFAULT); @@ -679,13 +697,21 @@ static void test_read_vl_string_attribute(void) att = H5Aopen(root, "test_scalar", H5P_DEFAULT); CHECK(att, FAIL, "H5Aopen"); - ret = H5Aread(att, type, &string_att_check); - CHECK(ret, FAIL, "H5Aread"); + /* Allocate memory for read buffer */ + if(string_att) + string_att_check = (char*)HDmalloc((strlen(string_att) + 1) * sizeof(char)); + CHECK(string_att_check, NULL, "HDmalloc"); - if(HDstrcmp(string_att_check,string_att)!=0) - TestErrPrintf("VL string attributes don't match!, string_att=%s, string_att_check=%s\n",string_att,string_att_check); + if(string_att_check) { + ret = H5Aread(att, type, &string_att_check); + CHECK(ret, FAIL, "H5Aread"); - HDfree(string_att_check); + if(HDstrcmp(string_att_check,string_att)!=0) + TestErrPrintf("VL string attributes don't match!, string_att=%s, string_att_check=%s\n",string_att,string_att_check); + + HDfree(string_att_check); + string_att_check = NULL; + } ret = H5Aclose(att); CHECK(ret, FAIL, "HAclose"); @@ -694,14 +720,24 @@ static void test_read_vl_string_attribute(void) att = H5Aopen(root, "test_scalar_large", H5P_DEFAULT); CHECK(att, FAIL, "H5Aopen"); - ret = H5Aread(att, type, &string_att_check); - CHECK(ret, FAIL, "H5Aread"); + /* Allocate memory for read buffer */ + if(string_att_write) + string_att_check = (char*)HDmalloc((strlen(string_att_write) + 1) * sizeof(char)); + CHECK(string_att_check, NULL, "HDmalloc"); + + if(string_att_check) { + ret = H5Aread(att, type, &string_att_check); + CHECK(ret, FAIL, "H5Aread"); - if(HDstrcmp(string_att_check,string_att_write)!=0) - TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check); + if(HDstrcmp(string_att_check,string_att_write)!=0) + TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check); + + HDfree(string_att_check); + } - HDfree(string_att_check); - HDfree(string_att_write); /* Free string allocated in test_write_vl_string_attribute */ + /* Free string allocated in test_write_vl_string_attribute */ + if(string_att_write) + HDfree(string_att_write); ret = H5Aclose(att); CHECK(ret, FAIL, "HAclose"); |