summaryrefslogtreecommitdiffstats
path: root/test/istore.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
commitb2d661b508a7fc7a2592c13bc6bdc175551f075d (patch)
tree13baeb0d83a7c2a4c6299993c182b1227c2f6114 /test/istore.c
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'test/istore.c')
-rw-r--r--test/istore.c512
1 files changed, 263 insertions, 249 deletions
diff --git a/test/istore.c b/test/istore.c
index e80f260..a724359 100644
--- a/test/istore.c
+++ b/test/istore.c
@@ -17,7 +17,7 @@
* Purpose: Tests various aspects of indexed raw data storage.
*/
-#define H5F_FRIEND /*suppress error about including H5Fpkg */
+#define H5F_FRIEND /*suppress error about including H5Fpkg */
#include "h5test.h"
@@ -29,26 +29,21 @@
#include "H5Oprivate.h"
#include "H5VMprivate.h"
-const char *FILENAME[] = {
- "istore",
- NULL
-};
+const char *FILENAME[] = {"istore", NULL};
-
-#define TEST_SMALL 0x0001
-#define TEST_MEDIUM 0x0002
-#define TEST_LARGE 0x0004
+#define TEST_SMALL 0x0001
+#define TEST_MEDIUM 0x0002
+#define TEST_LARGE 0x0004
/* The datatype of the dataset operated on by this test */
-#define TEST_DATATYPE H5T_NATIVE_UCHAR
+#define TEST_DATATYPE H5T_NATIVE_UCHAR
-#define TEST_CHUNK_SIZE 50
+#define TEST_CHUNK_SIZE 50
#define TEST_SPARSE_SIZE 1000000
hsize_t chunk_dims[H5O_LAYOUT_NDIMS];
hsize_t zero[H5O_LAYOUT_NDIMS];
-
/*-------------------------------------------------------------------------
* Function: is_sparse
*
@@ -68,23 +63,28 @@ hsize_t zero[H5O_LAYOUT_NDIMS];
static int
is_sparse(void)
{
- int fd;
- h5_stat_t sb;
-
- if ((fd = HDopen("x.h5", O_RDWR|O_TRUNC|O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0) return 0;
- if (HDlseek(fd, (off_t)(1024*1024), SEEK_SET)!=1024*1024) return 0;
- if (5!=HDwrite(fd, "hello", (size_t)5)) return 0;
- if (HDclose(fd) < 0) return 0;
- if (HDstat("x.h5", &sb) < 0) return 0;
- if (HDremove("x.h5") < 0) return 0;
+ int fd;
+ h5_stat_t sb;
+
+ if ((fd = HDopen("x.h5", O_RDWR | O_TRUNC | O_CREAT, H5_POSIX_CREATE_MODE_RW)) < 0)
+ return 0;
+ if (HDlseek(fd, (off_t)(1024 * 1024), SEEK_SET) != 1024 * 1024)
+ return 0;
+ if (5 != HDwrite(fd, "hello", (size_t)5))
+ return 0;
+ if (HDclose(fd) < 0)
+ return 0;
+ if (HDstat("x.h5", &sb) < 0)
+ return 0;
+ if (HDremove("x.h5") < 0)
+ return 0;
#ifdef H5_HAVE_STAT_ST_BLOCKS
- return ((unsigned long)sb.st_blocks*512 < (unsigned long)sb.st_size);
+ return ((unsigned long)sb.st_blocks * 512 < (unsigned long)sb.st_size);
#else
return (0);
#endif
}
-
/*-------------------------------------------------------------------------
* Function: print_array
*
@@ -102,29 +102,29 @@ is_sparse(void)
static void
print_array(uint8_t *array, size_t nx, size_t ny, size_t nz)
{
- size_t i, j, k;
+ size_t i, j, k;
for (i = 0; i < nx; i++) {
- if (nz > 1) {
- HDfprintf(stderr,"i=%lu:\n", (unsigned long)i);
- } else {
- HDfprintf(stderr,"%03lu:", (unsigned long)i);
- }
+ if (nz > 1) {
+ HDfprintf(stderr, "i=%lu:\n", (unsigned long)i);
+ }
+ else {
+ HDfprintf(stderr, "%03lu:", (unsigned long)i);
+ }
- for (j = 0; j < ny; j++) {
- if (nz > 1)
- HDfprintf(stderr,"%03lu:", (unsigned long)j);
- for (k = 0; k < nz; k++) {
- HDfprintf(stderr," %3d", *array++);
+ for (j = 0; j < ny; j++) {
+ if (nz > 1)
+ HDfprintf(stderr, "%03lu:", (unsigned long)j);
+ for (k = 0; k < nz; k++) {
+ HDfprintf(stderr, " %3d", *array++);
+ }
+ if (nz > 1)
+ HDfprintf(stderr, "\n");
}
- if (nz > 1)
- HDfprintf(stderr,"\n");
- }
- HDfprintf(stderr,"\n");
+ HDfprintf(stderr, "\n");
}
}
-
/*-------------------------------------------------------------------------
* Function: new_object
*
@@ -150,29 +150,35 @@ print_array(uint8_t *array, size_t nx, size_t ny, size_t nz)
static hid_t
new_object(hid_t f, const char *name, int ndims, hsize_t dims[], hsize_t cdims[])
{
- hid_t dataset; /* Dataset ID */
- hid_t space; /* Dataspace ID */
- hid_t dcpl; /* Dataset creation property list ID */
+ hid_t dataset; /* Dataset ID */
+ hid_t space; /* Dataspace ID */
+ hid_t dcpl; /* Dataset creation property list ID */
/* Create the dataset creation property list */
- if ((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ TEST_ERROR;
/* Set the chunk dimensions */
- if(H5Pset_chunk(dcpl, ndims, cdims) < 0) TEST_ERROR;
+ if (H5Pset_chunk(dcpl, ndims, cdims) < 0)
+ TEST_ERROR;
/* Create the dataspace */
- if((space = H5Screate_simple(ndims, dims, NULL)) < 0) TEST_ERROR;
+ if ((space = H5Screate_simple(ndims, dims, NULL)) < 0)
+ TEST_ERROR;
/* Create the dataset */
- if((dataset = H5Dcreate2(f, name, TEST_DATATYPE, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR;
+ if ((dataset = H5Dcreate2(f, name, TEST_DATATYPE, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Clean up */
/* Close property lists */
- if(H5Pclose(dcpl) < 0) TEST_ERROR;
+ if (H5Pclose(dcpl) < 0)
+ TEST_ERROR;
/* Close dataspace */
- if(H5Sclose(space) < 0) TEST_ERROR;
+ if (H5Sclose(space) < 0)
+ TEST_ERROR;
return dataset;
@@ -180,7 +186,6 @@ error:
return -1;
}
-
/*-------------------------------------------------------------------------
* Function: test_create
*
@@ -201,11 +206,11 @@ error:
static herr_t
test_create(hid_t f, const char *prefix)
{
- hid_t dataset; /* Dataset ID */
- hsize_t dims[H5O_LAYOUT_NDIMS+1]; /* Dimensions of dataset */
- hsize_t my_chunk_dims[H5O_LAYOUT_NDIMS+1]; /* Dimensions of chunks */
- char name[256]; /* Dataset name */
- unsigned u; /* Local index variable */
+ hid_t dataset; /* Dataset ID */
+ hsize_t dims[H5O_LAYOUT_NDIMS + 1]; /* Dimensions of dataset */
+ hsize_t my_chunk_dims[H5O_LAYOUT_NDIMS + 1]; /* Dimensions of chunks */
+ char name[256]; /* Dataset name */
+ unsigned u; /* Local index variable */
TESTING("istore create");
@@ -216,11 +221,11 @@ test_create(hid_t f, const char *prefix)
/* Create chunked dataset of this dimensionality */
HDsnprintf(name, sizeof name, "%s_%02u", prefix, u);
- if((dataset = new_object(f, name, (int)u, dims, my_chunk_dims)) < 0)
+ if ((dataset = new_object(f, name, (int)u, dims, my_chunk_dims)) < 0)
return FAIL;
/* Close dataset created */
- if(H5Dclose(dataset) < 0)
+ if (H5Dclose(dataset) < 0)
return FAIL;
}
@@ -228,7 +233,6 @@ test_create(hid_t f, const char *prefix)
return SUCCEED;
}
-
/*-------------------------------------------------------------------------
* Function: test_extend
*
@@ -248,41 +252,41 @@ test_create(hid_t f, const char *prefix)
*-------------------------------------------------------------------------
*/
static herr_t
-test_extend(hid_t f, const char *prefix,
- size_t nx, size_t ny, size_t nz)
+test_extend(hid_t f, const char *prefix, size_t nx, size_t ny, size_t nz)
{
- hid_t dataset; /* Dataset ID */
- hid_t fspace; /* Dataset's file dataspace */
- hid_t mspace; /* Dataset's memory dataspace */
- size_t i, j, k, ctr;
- int ndims;
- uint8_t *buf = NULL, *check = NULL, *whole = NULL;
- char dims[64], s[256], name[256];
- hsize_t offset[3];
- hsize_t max_corner[3];
- hsize_t size[3];
- hsize_t whole_size[3];
- hsize_t nelmts;
+ hid_t dataset; /* Dataset ID */
+ hid_t fspace; /* Dataset's file dataspace */
+ hid_t mspace; /* Dataset's memory dataspace */
+ size_t i, j, k, ctr;
+ int ndims;
+ uint8_t *buf = NULL, *check = NULL, *whole = NULL;
+ char dims[64], s[256], name[256];
+ hsize_t offset[3];
+ hsize_t max_corner[3];
+ hsize_t size[3];
+ hsize_t whole_size[3];
+ hsize_t nelmts;
if (!nz) {
- if (!ny) {
- ndims = 1;
- ny = nz = 1;
- HDsprintf(dims, "%lu", (unsigned long) nx);
- } else {
- ndims = 2;
- nz = 1;
- HDsprintf(dims, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
+ if (!ny) {
+ ndims = 1;
+ ny = nz = 1;
+ HDsprintf(dims, "%lu", (unsigned long)nx);
+ }
+ else {
+ ndims = 2;
+ nz = 1;
+ HDsprintf(dims, "%lux%lu", (unsigned long)nx, (unsigned long)ny);
+ }
}
- } else {
- ndims = 3;
- HDsprintf(dims, "%lux%lux%lu",
- (unsigned long) nx, (unsigned long) ny, (unsigned long) nz);
+ else {
+ ndims = 3;
+ HDsprintf(dims, "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz);
}
HDsprintf(s, "istore extend: %s", dims);
TESTING(s);
- buf = (uint8_t *)HDmalloc(nx * ny * nz);
+ buf = (uint8_t *)HDmalloc(nx * ny * nz);
check = (uint8_t *)HDmalloc(nx * ny * nz);
whole = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz);
@@ -295,35 +299,36 @@ test_extend(hid_t f, const char *prefix,
/* Build the new empty object */
HDsprintf(name, "%s_%s", prefix, dims);
- if ((dataset=new_object(f, name, ndims, whole_size, whole_size)) < 0) {
- HDfprintf(stderr," Cannot create %u-d object `%s'\n", ndims, name);
+ if ((dataset = new_object(f, name, ndims, whole_size, whole_size)) < 0) {
+ HDfprintf(stderr, " Cannot create %u-d object `%s'\n", ndims, name);
goto error;
}
/* Get dataset's dataspace */
- if((fspace=H5Dget_space(dataset)) < 0) TEST_ERROR;
-
- for (ctr = 0;
- H5VM_vector_lt_u((unsigned)ndims, max_corner, whole_size);
- ctr++) {
-
- /* Size and location */
- if (0 == ctr) {
- offset[0] = offset[1] = offset[2] = 0;
- size[0] = size[1] = size[2] = 1;
- nelmts = 1;
- } else {
- for (i=0, nelmts=1; i<(size_t)ndims; i++) {
- if (ctr % (size_t)ndims == i) {
- offset[i] = max_corner[i];
- size[i] = MIN(1, whole_size[i] - offset[i]);
- } else {
- offset[i] = 0;
- size[i] = max_corner[i];
+ if ((fspace = H5Dget_space(dataset)) < 0)
+ TEST_ERROR;
+
+ for (ctr = 0; H5VM_vector_lt_u((unsigned)ndims, max_corner, whole_size); ctr++) {
+
+ /* Size and location */
+ if (0 == ctr) {
+ offset[0] = offset[1] = offset[2] = 0;
+ size[0] = size[1] = size[2] = 1;
+ nelmts = 1;
}
- nelmts *= size[i];
+ else {
+ for (i = 0, nelmts = 1; i < (size_t)ndims; i++) {
+ if (ctr % (size_t)ndims == i) {
+ offset[i] = max_corner[i];
+ size[i] = MIN(1, whole_size[i] - offset[i]);
+ }
+ else {
+ offset[i] = 0;
+ size[i] = max_corner[i];
+ }
+ nelmts *= size[i];
+ }
}
- }
#if 0
if (0 == ctr)
@@ -344,89 +349,92 @@ test_extend(hid_t f, const char *prefix,
HDfprintf(stderr,"\n");
#endif
- /* Fill the source array */
- if (0 == nelmts) continue;
- HDmemset(buf, (signed)(128+ctr), (size_t)nelmts);
+ /* Fill the source array */
+ if (0 == nelmts)
+ continue;
+ HDmemset(buf, (signed)(128 + ctr), (size_t)nelmts);
/* Create dataspace for selection in memory */
- if((mspace=H5Screate_simple(1,&nelmts,NULL)) < 0) TEST_ERROR;
+ if ((mspace = H5Screate_simple(1, &nelmts, NULL)) < 0)
+ TEST_ERROR;
/* Select region in file dataspace */
- if(H5Sselect_hyperslab(fspace,H5S_SELECT_SET,offset,NULL,size,NULL) < 0) TEST_ERROR;
+ if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, offset, NULL, size, NULL) < 0)
+ TEST_ERROR;
- /* Write to disk */
- if (H5Dwrite(dataset, TEST_DATATYPE, mspace, fspace, H5P_DEFAULT, buf) < 0) {
- H5_FAILED();
- HDfprintf(stderr," Write failed: ctr=%lu\n", (unsigned long)ctr);
- goto error;
- }
+ /* Write to disk */
+ if (H5Dwrite(dataset, TEST_DATATYPE, mspace, fspace, H5P_DEFAULT, buf) < 0) {
+ H5_FAILED();
+ HDfprintf(stderr, " Write failed: ctr=%lu\n", (unsigned long)ctr);
+ goto error;
+ }
- /* Read from disk */
- HDmemset(check, 0xff, (size_t)nelmts);
- if (H5Dread(dataset, TEST_DATATYPE, mspace, fspace, H5P_DEFAULT, check) < 0) {
- H5_FAILED();
- HDfprintf(stderr," Read failed: ctr=%lu\n", (unsigned long)ctr);
- goto error;
- }
- if (HDmemcmp(buf, check, (size_t)nelmts)) {
- H5_FAILED();
- HDfprintf(stderr," Read check failed: ctr=%lu\n", (unsigned long)ctr);
- HDfprintf(stderr," Wrote:\n");
- print_array(buf, (size_t)size[0], (size_t)size[1],
- (size_t)size[2]);
- HDfprintf(stderr," Read:\n");
- print_array(check, (size_t)size[0], (size_t)size[1],
- (size_t)size[2]);
- goto error;
- }
+ /* Read from disk */
+ HDmemset(check, 0xff, (size_t)nelmts);
+ if (H5Dread(dataset, TEST_DATATYPE, mspace, fspace, H5P_DEFAULT, check) < 0) {
+ H5_FAILED();
+ HDfprintf(stderr, " Read failed: ctr=%lu\n", (unsigned long)ctr);
+ goto error;
+ }
+ if (HDmemcmp(buf, check, (size_t)nelmts)) {
+ H5_FAILED();
+ HDfprintf(stderr, " Read check failed: ctr=%lu\n", (unsigned long)ctr);
+ HDfprintf(stderr, " Wrote:\n");
+ print_array(buf, (size_t)size[0], (size_t)size[1], (size_t)size[2]);
+ HDfprintf(stderr, " Read:\n");
+ print_array(check, (size_t)size[0], (size_t)size[1], (size_t)size[2]);
+ goto error;
+ }
/* Close memory dataspace */
- if(H5Sclose(mspace) < 0) TEST_ERROR;
+ if (H5Sclose(mspace) < 0)
+ TEST_ERROR;
- /* Write to `whole' buffer for later checking */
- H5VM_hyper_copy((unsigned)ndims, size,
- whole_size, offset, whole, /*dst*/
- size, H5VM_ZERO, buf); /*src*/
+ /* Write to `whole' buffer for later checking */
+ H5VM_hyper_copy((unsigned)ndims, size, whole_size, offset, whole, /*dst*/
+ size, H5VM_ZERO, buf); /*src*/
- /* Update max corner */
- for (i=0; i<(size_t)ndims; i++)
- max_corner[i] = MAX(max_corner[i], offset[i]+size[i]);
+ /* Update max corner */
+ for (i = 0; i < (size_t)ndims; i++)
+ max_corner[i] = MAX(max_corner[i], offset[i] + size[i]);
}
/* Now read the entire array back out and check it */
HDmemset(buf, 0xff, nx * ny * nz);
if (H5Dread(dataset, TEST_DATATYPE, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) {
- H5_FAILED();
- HDfprintf(stderr," Read failed for whole array.\n");
- goto error;
+ H5_FAILED();
+ HDfprintf(stderr, " Read failed for whole array.\n");
+ goto error;
}
- for (i=0; i<nx; i++) {
- for (j=0; j<ny; j++) {
- for (k=0; k<nz; k++) {
- if (whole[i*ny*nz + j*nz + k] != buf[i*ny*nz + j*nz + k]) {
- H5_FAILED();
- HDfprintf(stderr," Check failed at i=%lu", (unsigned long)i);
- if (ndims > 1) {
- HDfprintf(stderr,", j=%lu", (unsigned long)j);
- }
- if (ndims > 2) {
- HDfprintf(stderr,", k=%lu", (unsigned long)k);
+ for (i = 0; i < nx; i++) {
+ for (j = 0; j < ny; j++) {
+ for (k = 0; k < nz; k++) {
+ if (whole[i * ny * nz + j * nz + k] != buf[i * ny * nz + j * nz + k]) {
+ H5_FAILED();
+ HDfprintf(stderr, " Check failed at i=%lu", (unsigned long)i);
+ if (ndims > 1) {
+ HDfprintf(stderr, ", j=%lu", (unsigned long)j);
+ }
+ if (ndims > 2) {
+ HDfprintf(stderr, ", k=%lu", (unsigned long)k);
+ }
+ HDfprintf(stderr, "\n Check array is:\n");
+ print_array(whole, nx, ny, nz);
+ HDfprintf(stderr, " Value read is:\n");
+ print_array(buf, nx, ny, nz);
+ goto error;
+ }
}
- HDfprintf(stderr,"\n Check array is:\n");
- print_array(whole, nx, ny, nz);
- HDfprintf(stderr," Value read is:\n");
- print_array(buf, nx, ny, nz);
- goto error;
}
- }
- }
}
/* Close dataset's dataspace */
- if(H5Sclose(fspace) < 0) TEST_ERROR;
+ if (H5Sclose(fspace) < 0)
+ TEST_ERROR;
/* Close dataset */
- if(H5Dclose(dataset) < 0) TEST_ERROR;
+ if (H5Dclose(dataset) < 0)
+ TEST_ERROR;
/* Free memory used */
HDfree(buf);
@@ -443,7 +451,6 @@ error:
return FAIL;
}
-
/*-------------------------------------------------------------------------
* Function: test_sparse
*
@@ -462,40 +469,40 @@ error:
*-------------------------------------------------------------------------
*/
static herr_t
-test_sparse(hid_t f, const char *prefix, size_t nblocks,
- size_t nx, size_t ny, size_t nz, int skip_test)
+test_sparse(hid_t f, const char *prefix, size_t nblocks, size_t nx, size_t ny, size_t nz, int skip_test)
{
- hid_t dataset; /* Dataset ID */
- hid_t fspace; /* Dataset's file dataspace */
- hid_t mspace; /* Dataset's memory dataspace */
- int ndims;
- hsize_t ctr;
- char dims[64], s[256], name[256];
- hsize_t offset[3];
- hsize_t size[3], total = 0;
- uint8_t *buf = NULL;
- hsize_t whole_size[3]; /* Size of dataset's dataspace */
- size_t u; /* Local index variable */
+ hid_t dataset; /* Dataset ID */
+ hid_t fspace; /* Dataset's file dataspace */
+ hid_t mspace; /* Dataset's memory dataspace */
+ int ndims;
+ hsize_t ctr;
+ char dims[64], s[256], name[256];
+ hsize_t offset[3];
+ hsize_t size[3], total = 0;
+ uint8_t *buf = NULL;
+ hsize_t whole_size[3]; /* Size of dataset's dataspace */
+ size_t u; /* Local index variable */
if (!nz) {
- if (!ny) {
- ndims = 1;
- ny = nz = 1;
- HDsprintf(dims, "%lu", (unsigned long) nx);
- } else {
- ndims = 2;
- nz = 1;
- HDsprintf(dims, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
+ if (!ny) {
+ ndims = 1;
+ ny = nz = 1;
+ HDsprintf(dims, "%lu", (unsigned long)nx);
+ }
+ else {
+ ndims = 2;
+ nz = 1;
+ HDsprintf(dims, "%lux%lu", (unsigned long)nx, (unsigned long)ny);
+ }
}
- } else {
- ndims = 3;
- HDsprintf(dims, "%lux%lux%lu",
- (unsigned long) nx, (unsigned long) ny, (unsigned long) nz);
+ else {
+ ndims = 3;
+ HDsprintf(dims, "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz);
}
HDsprintf(s, "istore sparse: %s", dims);
TESTING(s);
- if(skip_test){
+ if (skip_test) {
SKIPPED()
return SUCCEED;
}
@@ -503,8 +510,8 @@ test_sparse(hid_t f, const char *prefix, size_t nblocks,
HDmemset(buf, 128, nx * ny * nz);
/* Set dimensions of dataset */
- for (u=0; u<(size_t)ndims; u++)
- whole_size[u]=TEST_SPARSE_SIZE;
+ for (u = 0; u < (size_t)ndims; u++)
+ whole_size[u] = TEST_SPARSE_SIZE;
/* Set dimensions of selection */
size[0] = nx;
@@ -513,58 +520,64 @@ test_sparse(hid_t f, const char *prefix, size_t nblocks,
/* Build the new empty object */
HDsprintf(name, "%s_%s", prefix, dims);
- if ((dataset=new_object(f, name, ndims, whole_size, chunk_dims)) < 0) {
+ if ((dataset = new_object(f, name, ndims, whole_size, chunk_dims)) < 0) {
HDprintf(" Cannot create %u-d object `%s'\n", ndims, name);
goto error;
}
/* Get dataset's dataspace */
- if((fspace=H5Dget_space(dataset)) < 0) TEST_ERROR;
+ if ((fspace = H5Dget_space(dataset)) < 0)
+ TEST_ERROR;
/* Create dataspace for memory buffer */
- if((mspace=H5Screate_simple(ndims,size,NULL)) < 0) TEST_ERROR;
+ if ((mspace = H5Screate_simple(ndims, size, NULL)) < 0)
+ TEST_ERROR;
- for (ctr=0; ctr<nblocks; ctr++) {
- offset[0] = (hsize_t)(HDrandom() % (int)(TEST_SPARSE_SIZE-nx));
- offset[1] = (hsize_t)(HDrandom() % (int)(TEST_SPARSE_SIZE-ny));
- offset[2] = (hsize_t)(HDrandom() % (int)(TEST_SPARSE_SIZE-nz));
+ for (ctr = 0; ctr < nblocks; ctr++) {
+ offset[0] = (hsize_t)(HDrandom() % (int)(TEST_SPARSE_SIZE - nx));
+ offset[1] = (hsize_t)(HDrandom() % (int)(TEST_SPARSE_SIZE - ny));
+ offset[2] = (hsize_t)(HDrandom() % (int)(TEST_SPARSE_SIZE - nz));
/* Select region in file dataspace */
- if(H5Sselect_hyperslab(fspace,H5S_SELECT_SET,offset,NULL,size,NULL) < 0) TEST_ERROR;
+ if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, offset, NULL, size, NULL) < 0)
+ TEST_ERROR;
- /* write to disk */
- if (H5Dwrite(dataset, TEST_DATATYPE, mspace, fspace, H5P_DEFAULT, buf) < 0) {
- H5_FAILED();
- HDprintf(" Write failed: ctr=%lu\n", (unsigned long)ctr);
- HDprintf(" offset=(%lu", (unsigned long) (offset[0]));
- if (ndims > 1)
- HDprintf(",%lu", (unsigned long) (offset[1]));
- if (ndims > 2)
- HDprintf(",%lu", (unsigned long) (offset[2]));
- HDprintf("), size=(%lu", (unsigned long) (size[0]));
- if (ndims > 1)
- HDprintf(",%lu", (unsigned long) (size[1]));
- if (ndims > 2)
- HDprintf(",%lu", (unsigned long) (size[2]));
- HDprintf(")\n");
- goto error;
- }
- total += nx * ny * nz;
+ /* write to disk */
+ if (H5Dwrite(dataset, TEST_DATATYPE, mspace, fspace, H5P_DEFAULT, buf) < 0) {
+ H5_FAILED();
+ HDprintf(" Write failed: ctr=%lu\n", (unsigned long)ctr);
+ HDprintf(" offset=(%lu", (unsigned long)(offset[0]));
+ if (ndims > 1)
+ HDprintf(",%lu", (unsigned long)(offset[1]));
+ if (ndims > 2)
+ HDprintf(",%lu", (unsigned long)(offset[2]));
+ HDprintf("), size=(%lu", (unsigned long)(size[0]));
+ if (ndims > 1)
+ HDprintf(",%lu", (unsigned long)(size[1]));
+ if (ndims > 2)
+ HDprintf(",%lu", (unsigned long)(size[2]));
+ HDprintf(")\n");
+ goto error;
+ }
+ total += nx * ny * nz;
#if 0
HDfprintf(stderr,"ctr: ctr=%Zu, total=%Zu\n", ctr, total);
#endif
- /* We don't test reading yet.... */
+ /* We don't test reading yet.... */
}
/* Close memory dataspace */
- if(H5Sclose(mspace) < 0) TEST_ERROR;
+ if (H5Sclose(mspace) < 0)
+ TEST_ERROR;
/* Close dataset's dataspace */
- if(H5Sclose(fspace) < 0) TEST_ERROR;
+ if (H5Sclose(fspace) < 0)
+ TEST_ERROR;
/* Close dataset */
- if(H5Dclose(dataset) < 0) TEST_ERROR;
+ if (H5Dclose(dataset) < 0)
+ TEST_ERROR;
HDfree(buf);
PASSED();
@@ -575,7 +588,6 @@ error:
return FAIL;
}
-
/*-------------------------------------------------------------------------
* Function: main
*
@@ -591,28 +603,32 @@ error:
int
main(int argc, char *argv[])
{
- hid_t fapl=-1, file=-1, fcpl=-1;
- herr_t status;
- int nerrors = 0;
- unsigned size_of_test;
- unsigned u; /* Local index variable */
- char filename[1024];
- int skip_test = 0;
- int has_sparse_support = 0;
+ hid_t fapl = -1, file = -1, fcpl = -1;
+ herr_t status;
+ int nerrors = 0;
+ unsigned size_of_test;
+ unsigned u; /* Local index variable */
+ char filename[1024];
+ int skip_test = 0;
+ int has_sparse_support = 0;
/* Parse arguments or assume these tests (`small', `medium' ) */
if (1 == argc) {
size_of_test = TEST_SMALL | TEST_MEDIUM | TEST_LARGE;
- } else {
- int i;
+ }
+ 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")) {
+ }
+ else if (!strcmp(argv[i], "medium")) {
size_of_test |= TEST_MEDIUM;
- } else if (!strcmp(argv[i], "large")) {
+ }
+ else if (!strcmp(argv[i], "large")) {
size_of_test |= TEST_LARGE;
- } else {
+ }
+ else {
HDprintf("unrecognized argument: %s\n", argv[i]);
}
}
@@ -645,19 +661,19 @@ main(int argc, char *argv[])
/* Create the test file */
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) {
+ if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) {
HDprintf("Cannot create file %s; test aborted\n", filename);
HDexit(EXIT_FAILURE);
}
/* Initialize chunk dimensions */
- for(u = 0; u < H5O_LAYOUT_NDIMS; u++)
+ for (u = 0; u < H5O_LAYOUT_NDIMS; u++)
chunk_dims[u] = TEST_CHUNK_SIZE;
/*
- * Creation test: Creates empty objects with various raw data sizes
- * and alignments.
- */
+ * Creation test: Creates empty objects with various raw data sizes
+ * and alignments.
+ */
status = test_create(file, "create");
nerrors += status < 0 ? 1 : 0;
@@ -700,7 +716,7 @@ main(int argc, char *argv[])
* e.g.: Windows NTFS filesystems
*/
status = test_sparse(file, "sparse", (size_t)800, (size_t)50, (size_t)50, (size_t)50, skip_test);
- if(skip_test)
+ if (skip_test)
HDprintf(" The current VFD does not support sparse files on this platform.\n");
nerrors += status < 0 ? 1 : 0;
}
@@ -713,8 +729,7 @@ main(int argc, char *argv[])
nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0);
if (nerrors) {
- HDprintf("***** %d I-STORE TEST%s FAILED! *****\n",
- nerrors, 1 == nerrors ? "" : "S");
+ HDprintf("***** %d I-STORE TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S");
HDexit(EXIT_FAILURE);
}
@@ -724,4 +739,3 @@ main(int argc, char *argv[])
HDexit(EXIT_SUCCESS);
}
-