summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>1998-07-20 20:14:55 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>1998-07-20 20:14:55 (GMT)
commitd45c20d71312d5c8e2111c7229b1b47d11fb1e69 (patch)
tree62f87d1854d48141450c74e62872ce4c5a351ef8 /test
parentc3caa3f2690eca4430022af129c0a1530b613fa6 (diff)
downloadhdf5-d45c20d71312d5c8e2111c7229b1b47d11fb1e69.zip
hdf5-d45c20d71312d5c8e2111c7229b1b47d11fb1e69.tar.gz
hdf5-d45c20d71312d5c8e2111c7229b1b47d11fb1e69.tar.bz2
[svn-r520] Added test for strided hyperslabs.
Diffstat (limited to 'test')
-rw-r--r--test/.distdep282
-rw-r--r--test/tselect.c173
2 files changed, 313 insertions, 142 deletions
diff --git a/test/.distdep b/test/.distdep
index acce30e..107ac08 100644
--- a/test/.distdep
+++ b/test/.distdep
@@ -1,3 +1,33 @@
+testhdf5.o: \
+ testhdf5.c \
+ testhdf5.h \
+ ../src/H5private.h \
+ ../src/H5public.h \
+ ../src/H5config.h
+tattr.o: \
+ tattr.c \
+ testhdf5.h \
+ ../src/H5private.h \
+ ../src/H5public.h \
+ ../src/H5config.h \
+ ../src/H5Eprivate.h \
+ ../src/H5Epublic.h \
+ ../src/H5Ipublic.h \
+ ../src/hdf5.h \
+ ../src/H5Apublic.h \
+ ../src/H5ACpublic.h \
+ ../src/H5Bpublic.h \
+ ../src/H5Dpublic.h \
+ ../src/H5Fpublic.h \
+ ../src/H5Gpublic.h \
+ ../src/H5HGpublic.h \
+ ../src/H5HLpublic.h \
+ ../src/H5MFpublic.h \
+ ../src/H5MMpublic.h \
+ ../src/H5Opublic.h \
+ ../src/H5Ppublic.h \
+ ../src/H5Zpublic.h \
+ ../src/H5Spublic.h
tfile.o: \
tfile.c \
testhdf5.h \
@@ -70,6 +100,30 @@ tohdr.o: \
../src/H5Tpublic.h \
../src/H5Sprivate.h \
../src/H5Spublic.h
+tselect.o: \
+ tselect.c \
+ testhdf5.h \
+ ../src/H5private.h \
+ ../src/H5public.h \
+ ../src/H5config.h \
+ ../src/H5Eprivate.h \
+ ../src/H5Epublic.h \
+ ../src/H5Ipublic.h \
+ ../src/hdf5.h \
+ ../src/H5Apublic.h \
+ ../src/H5ACpublic.h \
+ ../src/H5Bpublic.h \
+ ../src/H5Dpublic.h \
+ ../src/H5Fpublic.h \
+ ../src/H5Gpublic.h \
+ ../src/H5HGpublic.h \
+ ../src/H5HLpublic.h \
+ ../src/H5MFpublic.h \
+ ../src/H5MMpublic.h \
+ ../src/H5Opublic.h \
+ ../src/H5Ppublic.h \
+ ../src/H5Zpublic.h \
+ ../src/H5Spublic.h
tstab.o: \
tstab.c \
testhdf5.h \
@@ -100,39 +154,35 @@ tstab.o: \
../src/H5Tpublic.h \
../src/H5Sprivate.h \
../src/H5Spublic.h
-hyperslab.o: \
- hyperslab.c \
- ../src/H5private.h \
- ../src/H5public.h \
- ../src/H5config.h
-istore.o: \
- istore.c \
+th5s.o: \
+ th5s.c \
+ testhdf5.h \
../src/H5private.h \
../src/H5public.h \
../src/H5config.h \
- ../src/H5Iprivate.h \
+ ../src/H5Eprivate.h \
+ ../src/H5Epublic.h \
../src/H5Ipublic.h \
- ../src/H5Pprivate.h \
- ../src/H5Ppublic.h \
- ../src/H5Dpublic.h \
- ../src/H5Fpublic.h \
- ../src/H5Zpublic.h \
+ ../src/H5Bprivate.h \
+ ../src/H5Bpublic.h \
../src/H5Fprivate.h \
+ ../src/H5Fpublic.h \
+ ../src/H5Dpublic.h \
+ ../src/H5Sprivate.h \
+ ../src/H5Spublic.h \
../src/H5Gprivate.h \
../src/H5Gpublic.h \
- ../src/H5Bprivate.h \
- ../src/H5Bpublic.h \
- ../src/H5MMprivate.h \
- ../src/H5MMpublic.h \
../src/H5Oprivate.h \
../src/H5Opublic.h \
../src/H5HGprivate.h \
../src/H5HGpublic.h \
../src/H5Tprivate.h \
../src/H5Tpublic.h \
- ../src/H5Sprivate.h
-cmpd_dset.o: \
- cmpd_dset.c \
+ ../src/H5Zprivate.h \
+ ../src/H5Zpublic.h \
+ ../src/H5Pprivate.h
+dtypes.o: \
+ dtypes.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
@@ -151,30 +201,47 @@ cmpd_dset.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
- ../src/H5Spublic.h
-extend.o: \
- extend.c \
- ../src/hdf5.h \
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h \
+ ../src/H5Tpkg.h \
+ ../src/H5HGprivate.h \
+ ../src/H5Fprivate.h \
+ ../src/H5private.h \
+ ../src/H5Tprivate.h \
+ ../src/H5Gprivate.h
+hyperslab.o: \
+ hyperslab.c \
+ ../src/H5private.h \
+ ../src/H5public.h \
+ ../src/H5config.h
+istore.o: \
+ istore.c \
+ ../src/H5private.h \
../src/H5public.h \
../src/H5config.h \
+ ../src/H5Iprivate.h \
../src/H5Ipublic.h \
- ../src/H5Apublic.h \
- ../src/H5ACpublic.h \
- ../src/H5Bpublic.h \
+ ../src/H5Pprivate.h \
+ ../src/H5Ppublic.h \
../src/H5Dpublic.h \
- ../src/H5Epublic.h \
../src/H5Fpublic.h \
+ ../src/H5Zpublic.h \
+ ../src/H5Fprivate.h \
+ ../src/H5Gprivate.h \
../src/H5Gpublic.h \
- ../src/H5HGpublic.h \
- ../src/H5HLpublic.h \
- ../src/H5MFpublic.h \
+ ../src/H5Bprivate.h \
+ ../src/H5Bpublic.h \
+ ../src/H5MMprivate.h \
../src/H5MMpublic.h \
+ ../src/H5Oprivate.h \
../src/H5Opublic.h \
- ../src/H5Ppublic.h \
- ../src/H5Zpublic.h \
- ../src/H5Spublic.h
-external.o: \
- external.c \
+ ../src/H5HGprivate.h \
+ ../src/H5HGpublic.h \
+ ../src/H5Tprivate.h \
+ ../src/H5Tpublic.h \
+ ../src/H5Sprivate.h
+dsets.o: \
+ dsets.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
@@ -195,8 +262,8 @@ external.o: \
../src/H5Zpublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h
-iopipe.o: \
- iopipe.c \
+cmpd_dset.o: \
+ cmpd_dset.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
@@ -215,27 +282,9 @@ iopipe.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
- ../src/H5Spublic.h \
- ../src/H5Tpublic.h
-gheap.o: \
- gheap.c \
- ../src/H5private.h \
- ../src/H5public.h \
- ../src/H5config.h \
- ../src/H5Eprivate.h \
- ../src/H5Epublic.h \
- ../src/H5Ipublic.h \
- ../src/H5Fprivate.h \
- ../src/H5Fpublic.h \
- ../src/H5Dpublic.h \
- ../src/H5Gprivate.h \
- ../src/H5Gpublic.h \
- ../src/H5Bprivate.h \
- ../src/H5Bpublic.h \
- ../src/H5HGprivate.h \
- ../src/H5HGpublic.h
-shtype.o: \
- shtype.c \
+ ../src/H5Spublic.h
+extend.o: \
+ extend.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
@@ -255,8 +304,8 @@ shtype.o: \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Spublic.h
-links.o: \
- links.c \
+external.o: \
+ external.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
@@ -277,8 +326,8 @@ links.o: \
../src/H5Zpublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h
-chunk.o: \
- chunk.c \
+iopipe.o: \
+ iopipe.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
@@ -299,76 +348,25 @@ chunk.o: \
../src/H5Zpublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h
-bittests.o: \
- bittests.c \
- ../src/H5Tpkg.h \
- ../src/H5HGprivate.h \
- ../src/H5HGpublic.h \
- ../src/H5public.h \
- ../src/H5config.h \
- ../src/H5Fprivate.h \
- ../src/H5Fpublic.h \
- ../src/H5Ipublic.h \
- ../src/H5private.h \
- ../src/H5Dpublic.h \
- ../src/H5Tprivate.h \
- ../src/H5Tpublic.h \
- ../src/H5Gprivate.h \
- ../src/H5Gpublic.h \
- ../src/H5Bprivate.h
-tattr.o: \
- tattr.c \
- testhdf5.h \
- ../src/H5private.h \
- ../src/H5public.h \
- ../src/H5config.h \
- ../src/H5Eprivate.h \
- ../src/H5Epublic.h \
- ../src/H5Ipublic.h \
- ../src/hdf5.h \
- ../src/H5Apublic.h \
- ../src/H5ACpublic.h \
- ../src/H5Bpublic.h \
- ../src/H5Dpublic.h \
- ../src/H5Fpublic.h \
- ../src/H5Gpublic.h \
- ../src/H5HGpublic.h \
- ../src/H5HLpublic.h \
- ../src/H5MFpublic.h \
- ../src/H5MMpublic.h \
- ../src/H5Opublic.h \
- ../src/H5Ppublic.h \
- ../src/H5Zpublic.h \
- ../src/H5Spublic.h
-th5s.o: \
- th5s.c \
- testhdf5.h \
+gheap.o: \
+ gheap.c \
../src/H5private.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Eprivate.h \
../src/H5Epublic.h \
../src/H5Ipublic.h \
- ../src/H5Bprivate.h \
- ../src/H5Bpublic.h \
../src/H5Fprivate.h \
../src/H5Fpublic.h \
../src/H5Dpublic.h \
- ../src/H5Sprivate.h \
- ../src/H5Spublic.h \
../src/H5Gprivate.h \
../src/H5Gpublic.h \
- ../src/H5Oprivate.h \
- ../src/H5Opublic.h \
+ ../src/H5Bprivate.h \
+ ../src/H5Bpublic.h \
../src/H5HGprivate.h \
- ../src/H5HGpublic.h \
- ../src/H5Tprivate.h \
- ../src/H5Tpublic.h \
- ../src/H5Zprivate.h \
- ../src/H5Zpublic.h \
- ../src/H5Pprivate.h
-dsets.o: \
- dsets.c \
+ ../src/H5HGpublic.h
+shtype.o: \
+ shtype.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
@@ -387,8 +385,7 @@ dsets.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
- ../src/H5Spublic.h \
- ../src/H5Tpublic.h
+ ../src/H5Spublic.h
big.o: \
big.c \
../src/hdf5.h \
@@ -412,20 +409,17 @@ big.o: \
../src/H5Spublic.h \
../src/H5Tpublic.h \
../src/H5private.h
-tselect.o: \
- tselect.c \
- testhdf5.h \
- ../src/H5private.h \
+links.o: \
+ links.c \
+ ../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
- ../src/H5Eprivate.h \
- ../src/H5Epublic.h \
../src/H5Ipublic.h \
- ../src/hdf5.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Dpublic.h \
+ ../src/H5Epublic.h \
../src/H5Fpublic.h \
../src/H5Gpublic.h \
../src/H5HGpublic.h \
@@ -435,15 +429,10 @@ tselect.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
- ../src/H5Spublic.h
-testhdf5.o: \
- testhdf5.c \
- testhdf5.h \
- ../src/H5private.h \
- ../src/H5public.h \
- ../src/H5config.h
-dtypes.o: \
- dtypes.c \
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h
+chunk.o: \
+ chunk.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
@@ -463,10 +452,21 @@ dtypes.o: \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Spublic.h \
- ../src/H5Tpublic.h \
+ ../src/H5Tpublic.h
+bittests.o: \
+ bittests.c \
../src/H5Tpkg.h \
../src/H5HGprivate.h \
+ ../src/H5HGpublic.h \
+ ../src/H5public.h \
+ ../src/H5config.h \
../src/H5Fprivate.h \
+ ../src/H5Fpublic.h \
+ ../src/H5Ipublic.h \
../src/H5private.h \
+ ../src/H5Dpublic.h \
../src/H5Tprivate.h \
- ../src/H5Gprivate.h
+ ../src/H5Tpublic.h \
+ ../src/H5Gprivate.h \
+ ../src/H5Gpublic.h \
+ ../src/H5Bprivate.h
diff --git a/test/tselect.c b/test/tselect.c
index b8b899b..bdea4f4 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -52,6 +52,9 @@ static char RcsId[] = "$Revision$";
/* Element selection information */
#define POINT1_NPOINTS 10
+/* Location comparison function */
+int compare_size_t(const void *s1, const void *s2);
+
/****************************************************************
**
** test_select_hyper(): Test basic H5S (dataspace) selection code.
@@ -152,6 +155,7 @@ test_select_hyper(void)
for(j=0; j<SPACE3_DIM2; j++, tbuf++, tbuf2++) {
if(*tbuf!=*tbuf2) {
printf("hyperslab values don't match!, i=%d, j=%d\n",i,j);
+exit(-1);
} /* end if */
} /* end for */
} /* end for */
@@ -449,6 +453,172 @@ test_select_combo(void)
free(rbuf);
} /* test_select_combo() */
+int
+compare_size_t(const void *s1, const void *s2)
+{
+ if(*(const size_t *)s1<*(const size_t *)s2)
+ return(-1);
+ else
+ if(*(const size_t *)s1>*(const size_t *)s2)
+ return(1);
+ else
+ return(0);
+}
+
+/****************************************************************
+**
+** test_select_hyper_stride(): Test H5S (dataspace) selection code.
+** Tests strided hyperslabs of various sizes and dimensionalities.
+**
+****************************************************************/
+static void
+test_select_hyper_stride(void)
+{
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid1,sid2; /* Dataspace ID */
+ hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
+ hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2};
+ hsize_t dims3[] = {SPACE3_DIM1, SPACE3_DIM2};
+ hsize_t start[SPACE1_RANK]; /* Starting location of hyperslab */
+ hsize_t stride[SPACE1_RANK]; /* Stride of hyperslab */
+ hsize_t count[SPACE1_RANK]; /* Element count of hyperslab */
+ hsize_t block[SPACE1_RANK]; /* Block size of hyperslab */
+ uint16 *wbuf, /* buffer to write to disk */
+ *rbuf, /* buffer read from disk */
+ *tbuf, /* temporary buffer pointer */
+ *tbuf2; /* temporary buffer pointer */
+ size_t loc1[72]={ /* Gruesomely ugly way to make certain hyperslab locations are checked correctly */
+ 27, 28, 29, 53, 54, 55, 79, 80, 81, /* Block #1 */
+ 32, 33, 34, 58, 59, 60, 84, 85, 86, /* Block #2 */
+ 157,158,159,183,184,185,209,210,211, /* Block #3 */
+ 162,163,164,188,189,190,214,215,216, /* Block #4 */
+ 287,288,289,313,314,315,339,340,341, /* Block #5 */
+ 292,293,294,318,319,320,344,345,346, /* Block #6 */
+ 417,418,419,443,444,445,469,470,471, /* Block #7 */
+ 422,423,424,448,449,450,474,475,476, /* Block #8 */
+ };
+ size_t loc2[72]={
+ 0, 1, 2, 26, 27, 28, /* Block #1 */
+ 4, 5, 6, 30, 31, 32, /* Block #2 */
+ 8, 9, 10, 34, 35, 36, /* Block #3 */
+ 12, 13, 14, 38, 39, 40, /* Block #4 */
+ 104,105,106,130,131,132, /* Block #5 */
+ 108,109,110,134,135,136, /* Block #6 */
+ 112,113,114,138,139,140, /* Block #7 */
+ 116,117,118,142,143,144, /* Block #8 */
+ 208,209,210,234,235,236, /* Block #9 */
+ 212,213,214,238,239,240, /* Block #10 */
+ 216,217,218,242,243,244, /* Block #11 */
+ 220,221,222,246,247,248, /* Block #12 */
+ };
+ intn i,j; /* Counters */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Hyperslabs with Strides Functionality\n"));
+
+ /* Allocate write & read buffers */
+ wbuf=malloc(sizeof(uint16)*SPACE2_DIM1*SPACE2_DIM2);
+ rbuf=calloc(sizeof(uint16),SPACE3_DIM1*SPACE3_DIM2);
+
+ /* Initialize write buffer */
+ for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++)
+ for(j=0; j<SPACE2_DIM2; j++)
+ *tbuf++=(uint16)((i*SPACE2_DIM2)+j);
+
+ /* Create file */
+ fid1 = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ /* Create dataspace for dataset */
+ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
+ CHECK(sid1, FAIL, "H5Screate_simple");
+
+ /* Create dataspace for writing buffer */
+ sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL);
+ CHECK(sid2, FAIL, "H5Screate_simple");
+
+ /* Select 2x3x3 count with a stride of 2x4x3 & 1x2x2 block hyperslab for disk dataset */
+ start[0]=0; start[1]=0; start[2]=0;
+ stride[0]=2; stride[1]=4; stride[2]=3;
+ count[0]=2; count[1]=3; count[2]=3;
+ block[0]=1; block[1]=2; block[2]=2;
+ ret = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,stride,count,block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Select 4x2 count with a stride of 5x5 & 3x3 block hyperslab for memory dataset */
+ start[0]=1; start[1]=1;
+ stride[0]=5; stride[1]=5;
+ count[0]=4; count[1]=2;
+ block[0]=3; block[1]=3;
+ ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,stride,count,block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Create a dataset */
+ dataset=H5Dcreate(fid1,"Dataset1",H5T_STD_U16LE,sid1,H5P_DEFAULT);
+
+ /* Write selection to disk */
+ ret=H5Dwrite(dataset,H5T_STD_U16LE,sid2,sid1,H5P_DEFAULT,wbuf);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Close memory dataspace */
+ ret = H5Sclose(sid2);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Create dataspace for reading buffer */
+ sid2 = H5Screate_simple(SPACE3_RANK, dims3, NULL);
+ CHECK(sid2, FAIL, "H5Screate_simple");
+
+ /* Select 3x4 count with a stride of 4x4 & 2x3 block hyperslab for memory dataset */
+ start[0]=0; start[1]=0;
+ stride[0]=4; stride[1]=4;
+ count[0]=3; count[1]=4;
+ block[0]=2; block[1]=3;
+ ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,stride,count,block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Read selection from disk */
+ ret=H5Dread(dataset,H5T_STD_U16LE,sid2,sid1,H5P_DEFAULT,rbuf);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Sort the locations into the proper order */
+ qsort(loc1,72,sizeof(size_t),compare_size_t);
+ qsort(loc2,72,sizeof(size_t),compare_size_t);
+ /* Compare data read with data written out */
+ for(i=0; i<72; i++) {
+ tbuf=wbuf+loc1[i];
+ tbuf2=rbuf+loc2[i];
+ if(*tbuf!=*tbuf2) {
+ printf("hyperslab values don't match!, loc1[%d]=%d, loc2[%d]=%d\n",i,(int)loc1[i],i,(int)loc2[i]);
+#ifdef QAK
+ printf("wbuf=%p, *tbuf=%p, rbuf=%p, tbuf2=%p\n",wbuf,tbuf,rbuf,tbuf2);
+ printf("*tbuf=%d, *tbuf2=%d\n",(int)*tbuf,(int)*tbuf2);
+#endif /* QAK */
+ } /* end if */
+ } /* end for */
+
+ /* 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() */
+
/****************************************************************
**
** test_select(): Main H5S selection testing routine.
@@ -460,10 +630,11 @@ test_select(void)
/* Output message about test being performed */
MESSAGE(5, ("Testing Selections\n"));
- /* These next two tests use the same file information */
+ /* These next tests use the same file */
test_select_hyper(); /* Test basic H5S hyperslab selection code */
test_select_point(); /* Test basic H5S element selection code */
test_select_combo(); /* Test combined hyperslab & element selection code */
+ test_select_hyper_stride(); /* Test strided hyperslab selection code */
} /* test_select() */