summaryrefslogtreecommitdiffstats
path: root/hl
diff options
context:
space:
mode:
authorVailin Choi <vchoi@jam.ad.hdfgroup.org>2017-04-03 22:45:25 (GMT)
committerVailin Choi <vchoi@jam.ad.hdfgroup.org>2017-04-03 22:45:25 (GMT)
commite7c1ef33425e7cdcf4486b79e0b95e77a6110f30 (patch)
tree502cef6e53cc8c8eafddbeff9a75322130c876d2 /hl
parentea1bb348c5da7195e7767bad66707a0dd1c18de1 (diff)
downloadhdf5-e7c1ef33425e7cdcf4486b79e0b95e77a6110f30.zip
hdf5-e7c1ef33425e7cdcf4486b79e0b95e77a6110f30.tar.gz
hdf5-e7c1ef33425e7cdcf4486b79e0b95e77a6110f30.tar.bz2
Made corrections according to code review.
1) Change fprintf to HDfprintf in hl/test/test_dset_opt.c 2) Remove extra line in src/H5Dpkg.h 3) Add one more test to hl/test/test_dset_opt.c Tested on mayll and osx1010test.
Diffstat (limited to 'hl')
-rw-r--r--hl/src/H5DO.c2
-rw-r--r--hl/test/test_dset_opt.c105
2 files changed, 78 insertions, 29 deletions
diff --git a/hl/src/H5DO.c b/hl/src/H5DO.c
index 151481e..be5f658 100644
--- a/hl/src/H5DO.c
+++ b/hl/src/H5DO.c
@@ -63,7 +63,7 @@ H5DOwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *o
/* If the user passed in a default DXPL, create one to pass to H5Dwrite() */
if(H5P_DEFAULT == dxpl_id) {
- if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
goto done;
created_dxpl = TRUE;
} /* end if */
diff --git a/hl/test/test_dset_opt.c b/hl/test/test_dset_opt.c
index 1e7c8e8..bec0ae3 100644
--- a/hl/test/test_dset_opt.c
+++ b/hl/test/test_dset_opt.c
@@ -161,22 +161,71 @@ test_direct_chunk_write (hid_t file)
cparms, H5P_DEFAULT)) < 0)
goto error;
- /* Initialize the dataset */
- for(i = n = 0; i < NX; i++)
- for(j = 0; j < NY; j++)
- data[i][j] = n++;
-
if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0)
goto error;
- /*
- * Write the data for the dataset. It should stay in the chunk cache.
- * It will be evicted from the cache by the H5DOwrite_chunk calls.
- */
+ HDmemset(data, 0, sizeof(data));
+ /* Initialize data for the first chunk */
+ for(i = n = 0; i < CHUNK_NX; i++)
+ for(j = 0; j < CHUNK_NY; j++)
+ data[i][j] = n++;
+
+ /* Write the data to the dataset. */
if((status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
dxpl, data)) < 0)
goto error;
+ if(H5Fflush(dataset, H5F_SCOPE_LOCAL) < 0)
+ goto error;
+
+ if(H5Dclose(dataset) < 0)
+ goto error;
+
+ if((dataset = H5Dopen2(file, DATASETNAME1, H5P_DEFAULT)) < 0)
+ goto error;
+
+ offset[0] = offset[1] = 0;
+
+ /* Get the size of the compressed chunk */
+ ret = H5Dget_chunk_storage_size(dataset, offset, &read_chunk_nbytes);
+
+ readbuf = HDmalloc(read_chunk_nbytes);
+ pt_readbuf = (const Bytef *)readbuf;
+
+ /* Test to use H5DOread_chunk() to read the chunk back */
+ if((status = H5DOread_chunk(dataset, H5P_DEFAULT, offset, &read_filter_mask, readbuf)) < 0)
+ goto error;
+
+ /* uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) */
+ ret = uncompress((Bytef *)read_dst_buf, (uLongf *)&buf_size, pt_readbuf, (uLong)read_chunk_nbytes);
+
+ /* Check for various zlib errors */
+ if(Z_BUF_ERROR == ret) {
+ HDfprintf(stderr, "error: not enough room in output buffer");
+ goto error;
+ } else if(Z_MEM_ERROR == ret) {
+ HDfprintf(stderr, "error: not enough memory");
+ goto error;
+ } else if(Z_OK != ret) {
+ HDfprintf(stderr, "error: corrupted input data");
+ goto error;
+ }
+
+ /* Check that the values read are the same as the values written */
+ for(i = 0; i < CHUNK_NX; i++) {
+ for(j = 0; j < CHUNK_NY; j++) {
+ if(data[i][j] != read_dst_buf[i][j]) {
+ printf(" 1. Read different values than written.");
+ printf(" At index %d,%d\n", i, j);
+ printf(" data=%d, read_dst_buf=%d\n", data[i][j], read_dst_buf[i][j]);
+ goto error;
+ }
+ }
+ }
+
+ if(readbuf)
+ HDfree(readbuf);
+
/* Initialize data for one chunk */
for(i = n = 0; i < CHUNK_NX; i++)
for(j = 0; j < CHUNK_NY; j++)
@@ -191,13 +240,13 @@ test_direct_chunk_write (hid_t file)
/* Check for various zlib errors */
if(Z_BUF_ERROR == ret) {
- fprintf(stderr, "overflow");
+ HDfprintf(stderr, "overflow");
goto error;
} else if(Z_MEM_ERROR == ret) {
- fprintf(stderr, "deflate memory error");
+ HDfprintf(stderr, "deflate memory error");
goto error;
} else if(Z_OK != ret) {
- fprintf(stderr, "other deflate error");
+ HDfprintf(stderr, "other deflate error");
goto error;
}
@@ -231,7 +280,7 @@ test_direct_chunk_write (hid_t file)
ret = H5Dget_chunk_storage_size(dataset, offset, &read_chunk_nbytes);
if(read_chunk_nbytes != (hsize_t)z_dst_nbytes) {
- fprintf(stderr, "Read/write chunk size not the same.");
+ HDfprintf(stderr, "Read/write chunk size not the same.");
goto error;
}
@@ -243,7 +292,7 @@ test_direct_chunk_write (hid_t file)
goto error;
if(read_filter_mask != filter_mask) {
- fprintf(stderr, " Read/write filter mask not the same.");
+ HDfprintf(stderr, " Read/write filter mask not the same.");
goto error;
}
@@ -252,13 +301,13 @@ test_direct_chunk_write (hid_t file)
/* Check for various zlib errors */
if(Z_BUF_ERROR == ret) {
- fprintf(stderr, "error: not enough room in output buffer");
+ HDfprintf(stderr, "error: not enough room in output buffer");
goto error;
} else if(Z_MEM_ERROR == ret) {
- fprintf(stderr, "error: not enough memory");
+ HDfprintf(stderr, "error: not enough memory");
goto error;
} else if(Z_OK != ret) {
- fprintf(stderr, "error: corrupted input data");
+ HDfprintf(stderr, "error: corrupted input data");
goto error;
}
@@ -318,13 +367,13 @@ test_direct_chunk_write (hid_t file)
/* Check for various zlib errors */
if(Z_BUF_ERROR == ret) {
- fprintf(stderr, "overflow");
+ HDfprintf(stderr, "overflow");
goto error;
} else if(Z_MEM_ERROR == ret) {
- fprintf(stderr, "deflate memory error");
+ HDfprintf(stderr, "deflate memory error");
goto error;
} else if(Z_OK != ret) {
- fprintf(stderr, "other deflate error");
+ HDfprintf(stderr, "other deflate error");
goto error;
}
@@ -359,7 +408,7 @@ test_direct_chunk_write (hid_t file)
ret = H5Dget_chunk_storage_size(dataset, offset, &read_chunk_nbytes);
if(read_chunk_nbytes != (hsize_t)z_dst_nbytes) {
- fprintf(stderr, "Read/write chunk size not the same.");
+ HDfprintf(stderr, "Read/write chunk size not the same.");
goto error;
}
@@ -371,7 +420,7 @@ test_direct_chunk_write (hid_t file)
goto error;
if(read_filter_mask != filter_mask) {
- fprintf(stderr, " Read/write filter mask not the same.");
+ HDfprintf(stderr, " Read/write filter mask not the same.");
goto error;
}
@@ -380,13 +429,13 @@ test_direct_chunk_write (hid_t file)
/* Check for various zlib errors */
if(Z_BUF_ERROR == ret) {
- fprintf(stderr, "error: not enough room in output buffer");
+ HDfprintf(stderr, "error: not enough room in output buffer");
goto error;
} else if(Z_MEM_ERROR == ret) {
- fprintf(stderr, "error: not enough memory");
+ HDfprintf(stderr, "error: not enough memory");
goto error;
} else if(Z_OK != ret) {
- fprintf(stderr, "error: corrupted input data");
+ HDfprintf(stderr, "error: corrupted input data");
goto error;
}
@@ -449,7 +498,7 @@ error:
return 1;
} /* test_direct_chunk_write() */
-#endif /* H5_HAVE_FILTER_DEFLATE */
+#endif
/*-------------------------------------------------------------------------
* Function: test_skip_compress_write1
@@ -554,7 +603,7 @@ test_skip_compress_write1(hid_t file)
goto error;
if(read_filter_mask != filter_mask) {
- fprintf(stderr, " Read/write filter mask not the same.");
+ HDfprintf(stderr, " Read/write filter mask not the same.");
goto error;
}
@@ -819,7 +868,7 @@ test_skip_compress_write2(hid_t file)
goto error;
if(read_filter_mask != filter_mask) {
- fprintf(stderr, " Read/write filter mask not the same.");
+ HDfprintf(stderr, " Read/write filter mask not the same.");
goto error;
}