summaryrefslogtreecommitdiffstats
path: root/test/tselect.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-03-26 19:55:44 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-03-26 19:55:44 (GMT)
commite23792a3f03a2f051bc1c088f853e76c2d9b3d09 (patch)
treed27b0f6f1e729c38eac66dc719d6aa7ae3ba4514 /test/tselect.c
parentccfdf1f9e4aac5da498f919775805f24c800e9ba (diff)
downloadhdf5-e23792a3f03a2f051bc1c088f853e76c2d9b3d09.zip
hdf5-e23792a3f03a2f051bc1c088f853e76c2d9b3d09.tar.gz
hdf5-e23792a3f03a2f051bc1c088f853e76c2d9b3d09.tar.bz2
[svn-r5083] Purpose:
Bug Fix Description: Regression test for following bug: When reading a contiguous hyperslab that spanned the entire dataset and was larger that the type conversion buffer, the hyperslab routines need to fill the type conversion buffer and then return to the I/O routines. When the I/O routines resume the hyperslab operation, it was possible to have a combination of coordinates which caused the hyperslab iterator to incorrectly advance in the file, causing some data to be re-read or re-written. Platforms tested: Linux (eirene)
Diffstat (limited to 'test/tselect.c')
-rw-r--r--test/tselect.c151
1 files changed, 145 insertions, 6 deletions
diff --git a/test/tselect.c b/test/tselect.c
index e26ae64..2a32a78 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -80,6 +80,14 @@
#define SPACE7_DIM1 10
#define SPACE7_DIM2 10
+/* 4-D dataset with fixed dimensions */
+#define SPACE8_NAME "Space8"
+#define SPACE8_RANK 4
+#define SPACE8_DIM1 11
+#define SPACE8_DIM2 13
+#define SPACE8_DIM3 17
+#define SPACE8_DIM4 19
+
/* Element selection information */
#define POINT1_NPOINTS 10
@@ -1082,7 +1090,7 @@ test_select_hyper_stride(void)
**
****************************************************************/
static void
-test_select_hyper_contig(void)
+test_select_hyper_contig(hid_t dset_type, hid_t xfer_plist)
{
hid_t fid1; /* HDF5 File IDs */
hid_t dataset; /* Dataset ID */
@@ -1139,10 +1147,10 @@ test_select_hyper_contig(void)
CHECK(ret, FAIL, "H5Sselect_hyperslab");
/* Create a dataset */
- dataset=H5Dcreate(fid1,"Dataset1",H5T_STD_U16LE,sid1,H5P_DEFAULT);
+ dataset=H5Dcreate(fid1,"Dataset1",dset_type,sid1,H5P_DEFAULT);
/* Write selection to disk */
- ret=H5Dwrite(dataset,H5T_NATIVE_USHORT,sid2,sid1,H5P_DEFAULT,wbuf);
+ ret=H5Dwrite(dataset,H5T_NATIVE_USHORT,sid2,sid1,xfer_plist,wbuf);
CHECK(ret, FAIL, "H5Dwrite");
/* Close memory dataspace */
@@ -1170,7 +1178,7 @@ test_select_hyper_contig(void)
CHECK(ret, FAIL, "H5Sselect_hyperslab");
/* Read selection from disk */
- ret=H5Dread(dataset,H5T_NATIVE_USHORT,sid2,sid1,H5P_DEFAULT,rbuf);
+ ret=H5Dread(dataset,H5T_NATIVE_USHORT,sid2,sid1,xfer_plist,rbuf);
CHECK(ret, FAIL, "H5Dread");
/* Compare data read with data written out */
@@ -1203,7 +1211,131 @@ test_select_hyper_contig(void)
/* Free memory buffers */
free(wbuf);
free(rbuf);
-} /* test_select_hyper() */
+} /* test_select_hyper_contig() */
+
+/****************************************************************
+**
+** test_select_hyper_contig2(): Test H5S (dataspace) selection code.
+** Tests more contiguous hyperslabs of various sizes and dimensionalities.
+**
+****************************************************************/
+static void
+test_select_hyper_contig2(hid_t dset_type, hid_t xfer_plist)
+{
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid1,sid2; /* Dataspace ID */
+ hsize_t dims2[] = {SPACE8_DIM4, SPACE8_DIM3, SPACE8_DIM2, SPACE8_DIM1};
+ hssize_t start[SPACE8_RANK]; /* Starting location of hyperslab */
+ hsize_t stride[SPACE8_RANK]; /* Stride of hyperslab */
+ hsize_t count[SPACE8_RANK]; /* Element count of hyperslab */
+ hsize_t block[SPACE8_RANK]; /* Block size of hyperslab */
+ uint16_t *wbuf, /* buffer to write to disk */
+ *rbuf, /* buffer read from disk */
+ *tbuf; /* temporary buffer pointer */
+ int i,j,k,l; /* Counters */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing More Contiguous Hyperslabs Functionality\n"));
+
+ /* Allocate write & read buffers */
+ wbuf=malloc(sizeof(uint16_t)*SPACE8_DIM1*SPACE8_DIM2*SPACE8_DIM3*SPACE8_DIM4);
+ rbuf=calloc(sizeof(uint16_t),SPACE8_DIM1*SPACE8_DIM2*SPACE8_DIM3*SPACE8_DIM4);
+
+ /* Initialize write buffer */
+ for(i=0, tbuf=wbuf; i<SPACE8_DIM1; i++)
+ for(j=0; j<SPACE8_DIM2; j++)
+ for(k=0; k<SPACE8_DIM3; k++)
+ for(l=0; l<SPACE8_DIM4; l++)
+ *tbuf++=(uint16_t)((i*SPACE8_DIM2)+j);
+
+ /* Create file */
+ fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ /* Create dataspace for dataset */
+ sid1 = H5Screate_simple(SPACE8_RANK, dims2, NULL);
+ CHECK(sid1, FAIL, "H5Screate_simple");
+
+ /* Create dataspace for writing buffer */
+ sid2 = H5Screate_simple(SPACE8_RANK, dims2, NULL);
+ CHECK(sid2, FAIL, "H5Screate_simple");
+
+ /* Select contiguous hyperslab for disk dataset */
+ start[0]=0; start[1]=0; start[2]=0; start[3]=0;
+ count[0]=2; count[1]=SPACE8_DIM3; count[2]=SPACE8_DIM2; count[3]=SPACE8_DIM1;
+ ret = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,NULL,count,NULL);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Select contiguous hyperslab in memory */
+ start[0]=0; start[1]=0; start[2]=0; start[3]=0;
+ count[0]=2; count[1]=SPACE8_DIM3; count[2]=SPACE8_DIM2; count[3]=SPACE8_DIM1;
+ ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,NULL,count,NULL);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Create a dataset */
+ dataset=H5Dcreate(fid1,"Dataset1",dset_type,sid1,H5P_DEFAULT);
+
+ /* Write selection to disk */
+ ret=H5Dwrite(dataset,H5T_NATIVE_USHORT,sid2,sid1,xfer_plist,wbuf);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Close memory dataspace */
+ ret = H5Sclose(sid2);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Create dataspace for reading buffer */
+ sid2 = H5Screate_simple(SPACE8_RANK, dims2, NULL);
+ CHECK(sid2, FAIL, "H5Screate_simple");
+
+ /* Select 6x5 count with a stride of 2x6 & 2x6 block hyperslab for disk dataset */
+ start[0]=0; start[1]=0; start[2]=0; start[3]=0;
+ count[0]=2; count[1]=SPACE8_DIM3; count[2]=SPACE8_DIM2; count[3]=SPACE8_DIM1;
+ ret = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,NULL,count,NULL);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Select 3x15 count with a stride of 4x2 & 4x2 block hyperslab for memory dataset */
+ start[0]=0; start[1]=0; start[2]=0; start[3]=0;
+ count[0]=2; count[1]=SPACE8_DIM3; count[2]=SPACE8_DIM2; count[3]=SPACE8_DIM1;
+ ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,NULL,count,NULL);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Read selection from disk */
+ ret=H5Dread(dataset,H5T_NATIVE_USHORT,sid2,sid1,xfer_plist,rbuf);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Compare data read with data written out */
+ if(HDmemcmp(rbuf,wbuf,sizeof(uint16_t)*2*SPACE8_DIM3*SPACE8_DIM2*SPACE8_DIM1)) {
+ num_errs++;
+ printf("Error: hyperslab values don't match!\n");
+#ifdef QAK
+ for(i=0, tbuf=wbuf; i<12; i++)
+ for(j=0; j<30; j++)
+ printf("i=%d, j=%d, *wbuf=%u, *rbuf=%u\n",i,j,(unsigned)*(wbuf+i*30+j),(unsigned)*(rbuf+i*30+j));
+#endif /* QAK */
+ } /* end if */
+
+ /* Close memory dataspace */
+ ret = H5Sclose(sid2);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close disk dataspace */
+ ret = H5Sclose(sid1);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Free memory buffers */
+ free(wbuf);
+ free(rbuf);
+} /* test_select_hyper_contig2() */
/****************************************************************
**
@@ -4202,7 +4334,14 @@ test_select(void)
/* These next tests use the same file */
test_select_combo(); /* Test combined hyperslab & element selection code */
test_select_hyper_stride(); /* Test strided hyperslab selection code */
- test_select_hyper_contig(); /* Test contiguous hyperslab selection code */
+ test_select_hyper_contig(H5T_STD_U16LE,H5P_DEFAULT); /* Test contiguous hyperslab selection code */
+ test_select_hyper_contig(H5T_STD_U16LE,plist_id); /* Test contiguous hyperslab selection code */
+ test_select_hyper_contig(H5T_STD_U16BE,H5P_DEFAULT); /* Test contiguous hyperslab selection code */
+ test_select_hyper_contig(H5T_STD_U16BE,plist_id); /* Test contiguous hyperslab selection code */
+ test_select_hyper_contig2(H5T_STD_U16LE,H5P_DEFAULT); /* Test more contiguous hyperslab selection cases */
+ test_select_hyper_contig2(H5T_STD_U16LE,plist_id); /* Test more contiguous hyperslab selection cases */
+ test_select_hyper_contig2(H5T_STD_U16BE,H5P_DEFAULT); /* Test more contiguous hyperslab selection cases */
+ test_select_hyper_contig2(H5T_STD_U16BE,plist_id); /* Test more contiguous hyperslab selection cases */
test_select_hyper_copy(); /* Test hyperslab selection copying code */
test_select_point_copy(); /* Test point selection copying code */
test_select_hyper_offset(); /* Test selection offset code with hyperslabs */