From e23792a3f03a2f051bc1c088f853e76c2d9b3d09 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 26 Mar 2002 14:55:44 -0500 Subject: [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) --- test/tselect.c | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file 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