summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-03-26 19:54:25 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-03-26 19:54:25 (GMT)
commitf5df769bdf43cd58a7e4c7abc7ae61ada98630ed (patch)
tree9355bec40e40cd86a4bc09bb47389649aa0acfc3
parented22e8a5c05771824bf003f77bc4d6b0488cb238 (diff)
downloadhdf5-f5df769bdf43cd58a7e4c7abc7ae61ada98630ed.zip
hdf5-f5df769bdf43cd58a7e4c7abc7ae61ada98630ed.tar.gz
hdf5-f5df769bdf43cd58a7e4c7abc7ae61ada98630ed.tar.bz2
[svn-r5081] 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)
-rw-r--r--test/tselect.c156
1 files changed, 148 insertions, 8 deletions
diff --git a/test/tselect.c b/test/tselect.c
index be254a8..8d34219 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -72,6 +72,14 @@
#define SPACE6_RANK 1
#define SPACE6_DIM1 (SPACE5_DIM1*SPACE5_DIM2*SPACE5_DIM3*SPACE5_DIM4*SPACE5_DIM5)
+/* 4-D dataset with fixed dimensions */
+#define SPACE7_NAME "Space7"
+#define SPACE7_RANK 4
+#define SPACE7_DIM1 11
+#define SPACE7_DIM2 13
+#define SPACE7_DIM3 17
+#define SPACE7_DIM4 19
+
/* Element selection information */
#define POINT1_NPOINTS 10
@@ -1066,7 +1074,7 @@ test_select_hyper_stride(void)
/* Free memory buffers */
free(wbuf);
free(rbuf);
-} /* test_select_hyper() */
+} /* test_select_hyper_stride() */
/****************************************************************
**
@@ -1075,7 +1083,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 */
@@ -1132,10 +1140,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 */
@@ -1163,12 +1171,13 @@ 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 */
if(HDmemcmp(rbuf,wbuf,sizeof(uint16_t)*30*12)) {
- printf("hyperslab values don't match!\n");
+ 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++)
@@ -1195,7 +1204,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[] = {SPACE7_DIM4, SPACE7_DIM3, SPACE7_DIM2, SPACE7_DIM1};
+ hssize_t start[SPACE7_RANK]; /* Starting location of hyperslab */
+ hsize_t stride[SPACE7_RANK]; /* Stride of hyperslab */
+ hsize_t count[SPACE7_RANK]; /* Element count of hyperslab */
+ hsize_t block[SPACE7_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)*SPACE7_DIM1*SPACE7_DIM2*SPACE7_DIM3*SPACE7_DIM4);
+ rbuf=calloc(sizeof(uint16_t),SPACE7_DIM1*SPACE7_DIM2*SPACE7_DIM3*SPACE7_DIM4);
+
+ /* Initialize write buffer */
+ for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
+ for(j=0; j<SPACE7_DIM2; j++)
+ for(k=0; k<SPACE7_DIM3; k++)
+ for(l=0; l<SPACE7_DIM4; l++)
+ *tbuf++=(uint16_t)((i*SPACE7_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(SPACE7_RANK, dims2, NULL);
+ CHECK(sid1, FAIL, "H5Screate_simple");
+
+ /* Create dataspace for writing buffer */
+ sid2 = H5Screate_simple(SPACE7_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]=SPACE7_DIM3; count[2]=SPACE7_DIM2; count[3]=SPACE7_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]=SPACE7_DIM3; count[2]=SPACE7_DIM2; count[3]=SPACE7_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(SPACE7_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]=SPACE7_DIM3; count[2]=SPACE7_DIM2; count[3]=SPACE7_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]=SPACE7_DIM3; count[2]=SPACE7_DIM2; count[3]=SPACE7_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*SPACE7_DIM3*SPACE7_DIM2*SPACE7_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() */
/****************************************************************
**
@@ -3266,7 +3399,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 */