summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2015-04-16 20:57:26 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2015-04-16 20:57:26 (GMT)
commitf53cfbe9d66c87b414bb759b91d7c32eb28fa88f (patch)
tree7dc8c3b5a717b8cf03304614efaf1944cd9ffb00 /test
parent11efaf4ff7d49c9242f832db4394376ba2541ab0 (diff)
downloadhdf5-f53cfbe9d66c87b414bb759b91d7c32eb28fa88f.zip
hdf5-f53cfbe9d66c87b414bb759b91d7c32eb28fa88f.tar.gz
hdf5-f53cfbe9d66c87b414bb759b91d7c32eb28fa88f.tar.bz2
[svn-r26828] Implement support for unlimited selections (not supported by VDS code yet).
Add tests for unlimited selections. Various other minor changes. Tested: ummon
Diffstat (limited to 'test')
-rw-r--r--test/tselect.c392
-rw-r--r--test/vds.c12
2 files changed, 398 insertions, 6 deletions
diff --git a/test/tselect.c b/test/tselect.c
index b34d095..df67ff6 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -13230,6 +13230,395 @@ test_hyper_regular(void)
/****************************************************************
**
+** test_hyper_unlim(): Tests unlimited hyperslab selections
+**
+****************************************************************/
+static void
+test_hyper_unlim(void)
+{
+ hid_t sid;
+ hsize_t dims[3] = {4, 4, 7};
+ hsize_t mdims[3] = {4, H5S_UNLIMITED, 7};
+ hsize_t start[3] = {1, 2, 1};
+ hsize_t stride[3] = {1, 1, 3};
+ hsize_t count[3] = {1, 1, 2};
+ hsize_t block[3] = {2, H5S_UNLIMITED, 2};
+ hsize_t blocklist[12];
+ hsize_t eblock1[6] = {1, 2, 1, 2, 3, 2};
+ hsize_t eblock2[6] = {1, 2, 4, 2, 3, 5};
+ hssize_t offset[3] = {0, -1, 0};
+ hssize_t npoints;
+ hssize_t nblocks;
+ herr_t ret;
+
+ /* Output message about test being performed */
+ MESSAGE(6, ("Testing unlimited hyperslab selections\n"));
+
+ /* Create dataspace */
+ sid = H5Screate_simple(3, dims, mdims);
+ CHECK(sid, FAIL, "H5Screate_simple");
+
+ /* Select unlimited hyperslab */
+ ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Check number of elements */
+ npoints = H5Sget_select_npoints(sid);
+ CHECK(npoints, FAIL, "H5Sget_select_npoints");
+ VERIFY(npoints, (hssize_t)16, "H5Sget_select_npoints");
+
+ /* Get blocklist */
+ nblocks = H5Sget_select_hyper_nblocks(sid);
+ CHECK(nblocks, FAIL, "H5Sget_select_hyper_nblocks");
+ VERIFY(nblocks, (hssize_t)2, "H5Sget_select_hyper_nblocks");
+ ret = H5Sget_select_hyper_blocklist(sid, (hsize_t)0, (hsize_t)nblocks, blocklist);
+ CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist");
+
+ /* Verify blocklist */
+ if(HDmemcmp(blocklist, eblock1, sizeof(eblock1))) {
+ if(HDmemcmp(blocklist, eblock2, sizeof(eblock2)))
+ ERROR("H5Sget_select_hyper_blocklist");
+ if(HDmemcmp(&blocklist[6], eblock1, sizeof(eblock1)))
+ ERROR("H5Sget_select_hyper_blocklist");
+ } /* end if */
+ else
+ if(HDmemcmp(&blocklist[6], eblock2, sizeof(eblock2)))
+ ERROR("H5Sget_select_hyper_blocklist");
+
+ /* Shrink dataspace */
+ dims[1] = 3;
+ ret = H5Sset_extent_simple(sid, 3, dims, mdims);
+ CHECK(ret, FAIL, "H5Sset_extent_simple");
+
+ /* Check number of elements */
+ npoints = H5Sget_select_npoints(sid);
+ CHECK(npoints, FAIL, "H5Sget_select_npoints");
+ VERIFY(npoints, (hssize_t)8, "H5Sget_select_npoints");
+
+ /* Get blocklist */
+ nblocks = H5Sget_select_hyper_nblocks(sid);
+ CHECK(nblocks, FAIL, "H5Sget_select_hyper_nblocks");
+ VERIFY(nblocks, (hssize_t)2, "H5Sget_select_hyper_nblocks");
+ ret = H5Sget_select_hyper_blocklist(sid, (hsize_t)0, (hsize_t)nblocks, blocklist);
+ CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist");
+
+ /* Verify blocklist */
+ eblock1[4] = 2;
+ eblock2[4] = 2;
+ if(HDmemcmp(blocklist, eblock1, sizeof(eblock1))) {
+ if(HDmemcmp(blocklist, eblock2, sizeof(eblock2)))
+ ERROR("H5Sget_select_hyper_blocklist");
+ if(HDmemcmp(&blocklist[6], eblock1, sizeof(eblock1)))
+ ERROR("H5Sget_select_hyper_blocklist");
+ } /* end if */
+ else
+ if(HDmemcmp(&blocklist[6], eblock2, sizeof(eblock2)))
+ ERROR("H5Sget_select_hyper_blocklist");
+
+ /* Shrink dataspace */
+ dims[1] = 2;
+ ret = H5Sset_extent_simple(sid, 3, dims, mdims);
+ CHECK(ret, FAIL, "H5Sset_extent_simple");
+
+ /* Check number of elements */
+ npoints = H5Sget_select_npoints(sid);
+ CHECK(npoints, FAIL, "H5Sget_select_npoints");
+ VERIFY(npoints, (hssize_t)0, "H5Sget_select_npoints");
+
+ /* Make sure there are no blocks */
+ nblocks = H5Sget_select_hyper_nblocks(sid);
+ CHECK(nblocks, FAIL, "H5Sget_select_hyper_nblocks");
+ VERIFY(nblocks, (hssize_t)0, "H5Sget_select_hyper_nblocks");
+
+ /* Shrink dataspace */
+ dims[1] = 1;
+ ret = H5Sset_extent_simple(sid, 3, dims, mdims);
+ CHECK(ret, FAIL, "H5Sset_extent_simple");
+
+ /* Check number of elements */
+ npoints = H5Sget_select_npoints(sid);
+ CHECK(npoints, FAIL, "H5Sget_select_npoints");
+ VERIFY(npoints, (hssize_t)0, "H5Sget_select_npoints");
+
+ /* Make sure there are no blocks */
+ nblocks = H5Sget_select_hyper_nblocks(sid);
+ CHECK(nblocks, FAIL, "H5Sget_select_hyper_nblocks");
+ VERIFY(nblocks, (hssize_t)0, "H5Sget_select_hyper_nblocks");
+
+ /* Extend dataspace */
+ dims[1] = 7;
+ ret = H5Sset_extent_simple(sid, 3, dims, mdims);
+ CHECK(ret, FAIL, "H5Sset_extent_simple");
+
+ /* Check number of elements */
+ npoints = H5Sget_select_npoints(sid);
+ CHECK(npoints, FAIL, "H5Sget_select_npoints");
+ VERIFY(npoints, (hssize_t)40, "H5Sget_select_npoints");
+
+ /* Get blocklist */
+ nblocks = H5Sget_select_hyper_nblocks(sid);
+ CHECK(nblocks, FAIL, "H5Sget_select_hyper_nblocks");
+ VERIFY(nblocks, (hssize_t)2, "H5Sget_select_hyper_nblocks");
+ ret = H5Sget_select_hyper_blocklist(sid, (hsize_t)0, (hsize_t)nblocks, blocklist);
+ CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist");
+
+ /* Verify blocklist */
+ eblock1[4] = 6;
+ eblock2[4] = 6;
+ if(HDmemcmp(blocklist, eblock1, sizeof(eblock1))) {
+ if(HDmemcmp(blocklist, eblock2, sizeof(eblock2)))
+ ERROR("H5Sget_select_hyper_blocklist");
+ if(HDmemcmp(&blocklist[6], eblock1, sizeof(eblock1)))
+ ERROR("H5Sget_select_hyper_blocklist");
+ } /* end if */
+ else
+ if(HDmemcmp(&blocklist[6], eblock2, sizeof(eblock2)))
+ ERROR("H5Sget_select_hyper_blocklist");
+
+#if 0 //VDSINC
+ /* Set offset of selection */
+ ret = H5Soffset_simple(sid, offset);
+ CHECK(ret, FAIL, "H5Soffset_simple");
+
+ /* Check number of elements */
+ npoints = H5Sget_select_npoints(sid);
+ CHECK(npoints, FAIL, "H5Sget_select_npoints");
+ VERIFY(npoints, (hssize_t)48, "H5Sget_select_npoints");
+
+ /* Get blocklist */
+ nblocks = H5Sget_select_hyper_nblocks(sid);
+ CHECK(nblocks, FAIL, "H5Sget_select_hyper_nblocks");
+ VERIFY(nblocks, (hssize_t)2, "H5Sget_select_hyper_nblocks");
+ ret = H5Sget_select_hyper_blocklist(sid, (hsize_t)0, (hsize_t)nblocks, blocklist);
+ CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist");
+
+ /* Verify blocklist */
+ eblock1[1] = 1;
+ eblock1[4] = 6;
+ eblock2[1] = 1;
+ eblock2[4] = 6;
+ if(HDmemcmp(blocklist, eblock1, sizeof(eblock1))) {
+ if(HDmemcmp(blocklist, eblock2, sizeof(eblock2)))
+ ERROR("H5Sget_select_hyper_blocklist");
+ if(HDmemcmp(&blocklist[6], eblock1, sizeof(eblock1)))
+ ERROR("H5Sget_select_hyper_blocklist");
+ } /* end if */
+ else
+ if(HDmemcmp(&blocklist[6], eblock2, sizeof(eblock2)))
+ ERROR("H5Sget_select_hyper_blocklist");
+
+ /* Reset offset of selection */
+ ret = H5Soffset_simple(sid, NULL);
+ CHECK(ret, FAIL, "H5Soffset_simple");
+#endif
+
+ /*
+ * Now try with multiple blocks in unlimited dimension
+ */
+ stride[1] = 3;
+ stride[2] = 1;
+ count[1] = H5S_UNLIMITED;
+ count[2] = 1;
+ block[1] = 2;
+
+ /* Select unlimited hyperslab */
+ ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Check number of elements */
+ npoints = H5Sget_select_npoints(sid);
+ CHECK(npoints, FAIL, "H5Sget_select_npoints");
+ VERIFY(npoints, (hssize_t)16, "H5Sget_select_npoints");
+
+ /* Get blocklist */
+ nblocks = H5Sget_select_hyper_nblocks(sid);
+ CHECK(nblocks, FAIL, "H5Sget_select_hyper_nblocks");
+ VERIFY(nblocks, (hssize_t)2, "H5Sget_select_hyper_nblocks");
+ ret = H5Sget_select_hyper_blocklist(sid, (hsize_t)0, (hsize_t)nblocks, blocklist);
+ CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist");
+
+ /* Verify blocklist */
+ eblock1[1] = 2;
+ eblock1[4] = 3;
+ eblock2[1] = 5;
+ eblock2[2] = 1;
+ eblock2[4] = 6;
+ eblock2[5] = 2;
+ if(HDmemcmp(blocklist, eblock1, sizeof(eblock1))) {
+ if(HDmemcmp(blocklist, eblock2, sizeof(eblock2)))
+ ERROR("H5Sget_select_hyper_blocklist");
+ if(HDmemcmp(&blocklist[6], eblock1, sizeof(eblock1)))
+ ERROR("H5Sget_select_hyper_blocklist");
+ } /* end if */
+ else
+ if(HDmemcmp(&blocklist[6], eblock2, sizeof(eblock2)))
+ ERROR("H5Sget_select_hyper_blocklist");
+
+#if 0 //VDSINC
+ /* Shrink dataspace */
+ dims[1] = 3;
+ ret = H5Sset_extent_simple(sid, 3, dims, mdims);
+ CHECK(ret, FAIL, "H5Sset_extent_simple");
+
+ /* Check number of elements */
+ npoints = H5Sget_select_npoints(sid);
+ CHECK(npoints, FAIL, "H5Sget_select_npoints");
+ VERIFY(npoints, (hssize_t)4, "H5Sget_select_npoints");
+
+ /* Get blocklist */
+ nblocks = H5Sget_select_hyper_nblocks(sid);
+ CHECK(nblocks, FAIL, "H5Sget_select_hyper_nblocks");
+ VERIFY(nblocks, (hssize_t)1, "H5Sget_select_hyper_nblocks");
+ ret = H5Sget_select_hyper_blocklist(sid, (hsize_t)0, (hsize_t)nblocks, blocklist);
+ CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist");
+
+ /* Verify blocklist */
+ eblock1[4] = 2;
+ if(HDmemcmp(blocklist, eblock1, sizeof(eblock1)))
+ ERROR("H5Sget_select_hyper_blocklist");
+#endif //VDSINC
+
+ /* Extend dataspace */
+ dims[1] = 4;
+ ret = H5Sset_extent_simple(sid, 3, dims, mdims);
+ CHECK(ret, FAIL, "H5Sset_extent_simple");
+
+ /* Check number of elements */
+ npoints = H5Sget_select_npoints(sid);
+ CHECK(npoints, FAIL, "H5Sget_select_npoints");
+ VERIFY(npoints, (hssize_t)8, "H5Sget_select_npoints");
+
+ /* Get blocklist */
+ nblocks = H5Sget_select_hyper_nblocks(sid);
+ CHECK(nblocks, FAIL, "H5Sget_select_hyper_nblocks");
+ VERIFY(nblocks, (hssize_t)1, "H5Sget_select_hyper_nblocks");
+ ret = H5Sget_select_hyper_blocklist(sid, (hsize_t)0, (hsize_t)nblocks, blocklist);
+ CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist");
+
+ /* Verify blocklist */
+ eblock1[4] = 3;
+ if(HDmemcmp(blocklist, eblock1, sizeof(eblock1)))
+ ERROR("H5Sget_select_hyper_blocklist");
+
+ /* Extend dataspace */
+ dims[1] = 5;
+ ret = H5Sset_extent_simple(sid, 3, dims, mdims);
+ CHECK(ret, FAIL, "H5Sset_extent_simple");
+
+ /* Check number of elements */
+ npoints = H5Sget_select_npoints(sid);
+ CHECK(npoints, FAIL, "H5Sget_select_npoints");
+ VERIFY(npoints, (hssize_t)8, "H5Sget_select_npoints");
+
+ /* Get blocklist */
+ nblocks = H5Sget_select_hyper_nblocks(sid);
+ CHECK(nblocks, FAIL, "H5Sget_select_hyper_nblocks");
+ VERIFY(nblocks, (hssize_t)1, "H5Sget_select_hyper_nblocks");
+ ret = H5Sget_select_hyper_blocklist(sid, (hsize_t)0, (hsize_t)nblocks, blocklist);
+ CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist");
+
+ /* Verify blocklist */
+ if(HDmemcmp(blocklist, eblock1, sizeof(eblock1)))
+ ERROR("H5Sget_select_hyper_blocklist");
+
+#if 0 //VDSINC
+ /* Extend dataspace */
+ dims[1] = 6;
+ ret = H5Sset_extent_simple(sid, 3, dims, mdims);
+ CHECK(ret, FAIL, "H5Sset_extent_simple");
+
+ /* Check number of elements */
+ npoints = H5Sget_select_npoints(sid);
+ CHECK(npoints, FAIL, "H5Sget_select_npoints");
+ VERIFY(npoints, (hssize_t)12, "H5Sget_select_npoints");
+
+ /* Get blocklist */
+ nblocks = H5Sget_select_hyper_nblocks(sid);
+ CHECK(nblocks, FAIL, "H5Sget_select_hyper_nblocks");
+ VERIFY(nblocks, (hssize_t)2, "H5Sget_select_hyper_nblocks");
+ ret = H5Sget_select_hyper_blocklist(sid, (hsize_t)0, (hsize_t)nblocks, blocklist);
+ CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist");
+
+ /* Verify blocklist */
+ eblock2[4] = 5;
+ if(HDmemcmp(blocklist, eblock1, sizeof(eblock1))) {
+ if(HDmemcmp(blocklist, eblock2, sizeof(eblock2)))
+ ERROR("H5Sget_select_hyper_blocklist");
+ if(HDmemcmp(&blocklist[6], eblock1, sizeof(eblock1)))
+ ERROR("H5Sget_select_hyper_blocklist");
+ } /* end if */
+ else
+ if(HDmemcmp(&blocklist[6], eblock2, sizeof(eblock2)))
+ ERROR("H5Sget_select_hyper_blocklist");
+
+ /* Set offset of selection */
+ ret = H5Soffset_simple(sid, offset);
+ CHECK(ret, FAIL, "H5Soffset_simple");
+
+ /* Check number of elements */
+ npoints = H5Sget_select_npoints(sid);
+ CHECK(npoints, FAIL, "H5Sget_select_npoints");
+ VERIFY(npoints, (hssize_t)16, "H5Sget_select_npoints");
+
+ /* Get blocklist */
+ nblocks = H5Sget_select_hyper_nblocks(sid);
+ CHECK(nblocks, FAIL, "H5Sget_select_hyper_nblocks");
+ VERIFY(nblocks, (hssize_t)2, "H5Sget_select_hyper_nblocks");
+ ret = H5Sget_select_hyper_blocklist(sid, (hsize_t)0, (hsize_t)nblocks, blocklist);
+ CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist");
+
+ /* Verify blocklist */
+ eblock1[1] = 1;
+ eblock1[4] = 2;
+ eblock2[1] = 4;
+ eblock2[4] = 5;
+ if(HDmemcmp(blocklist, eblock1, sizeof(eblock1))) {
+ if(HDmemcmp(blocklist, eblock2, sizeof(eblock2)))
+ ERROR("H5Sget_select_hyper_blocklist");
+ if(HDmemcmp(&blocklist[6], eblock1, sizeof(eblock1)))
+ ERROR("H5Sget_select_hyper_blocklist");
+ } /* end if */
+ else
+ if(HDmemcmp(&blocklist[6], eblock2, sizeof(eblock2)))
+ ERROR("H5Sget_select_hyper_blocklist");
+
+ /* Set offset of selection */
+ offset[1] = (hssize_t)3;
+ ret = H5Soffset_simple(sid, offset);
+ CHECK(ret, FAIL, "H5Soffset_simple");
+
+ /* Check number of elements */
+ npoints = H5Sget_select_npoints(sid);
+ CHECK(npoints, FAIL, "H5Sget_select_npoints");
+ VERIFY(npoints, (hssize_t)4, "H5Sget_select_npoints");
+
+ /* Get blocklist */
+ nblocks = H5Sget_select_hyper_nblocks(sid);
+ CHECK(nblocks, FAIL, "H5Sget_select_hyper_nblocks");
+ VERIFY(nblocks, (hssize_t)1, "H5Sget_select_hyper_nblocks");
+ ret = H5Sget_select_hyper_blocklist(sid, (hsize_t)0, (hsize_t)nblocks, blocklist);
+ CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist");
+
+ /* Verify blocklist */
+ eblock1[1] = 5;
+ eblock1[4] = 5;
+ if(HDmemcmp(blocklist, eblock1, sizeof(eblock1)))
+ ERROR("H5Sget_select_hyper_blocklist");
+
+ /* Reset offset of selection */
+ ret = H5Soffset_simple(sid, NULL);
+ CHECK(ret, FAIL, "H5Soffset_simple");
+#endif //VDSINC
+
+ //VDSINC write test saving unlim selection to file as region reference
+
+ /* Close the dataspace */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+} /* end test_hyper_unlim() */
+
+/****************************************************************
+**
** test_select(): Main H5S selection testing routine.
**
****************************************************************/
@@ -13392,6 +13781,9 @@ test_select(void)
/* Test 'regular' hyperslab query routines */
test_hyper_regular();
+ /* Test unlimited hyperslab selections */
+ test_hyper_unlim();
+
} /* test_select() */
diff --git a/test/vds.c b/test/vds.c
index abb52fc..5092d1e 100644
--- a/test/vds.c
+++ b/test/vds.c
@@ -416,11 +416,11 @@ test_api(test_api_config_t config, hid_t fapl)
const char *src_dset[4] = {"src_dset1....", "src_dset2.....", "src_dset3......", "src_dset4......."}; /* Source dataset names (different lengths) */
char tmp_filename[32];
char tmp_dsetname[32];
- hsize_t dims[4] = {10, 20, 0, 0}; /* Data space current size */
- hsize_t start[4]; /* Hyperslab start */
- hsize_t stride[4]; /* Hyperslab stride */
- hsize_t count[4]; /* Hyperslab count */
- hsize_t block[4]; /* Hyperslab block */
+ hsize_t dims[2] = {10, 20}; /* Data space current size */
+ hsize_t start[2]; /* Hyperslab start */
+ hsize_t stride[2]; /* Hyperslab stride */
+ hsize_t count[2]; /* Hyperslab count */
+ hsize_t block[2]; /* Hyperslab block */
hsize_t coord[10]; /* Point selection array */
size_t size_out;
unsigned i;
@@ -2457,7 +2457,7 @@ test_basic_io(unsigned config, hid_t fapl)
if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset1", H5P_DEFAULT)) < 0)
TEST_ERROR
} /* end if */
-#
+
/* Read data directly from source dataset */
/* Select hyperslab in memory space */
start[0] = 0;