summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2015-08-07 20:06:56 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2015-08-07 20:06:56 (GMT)
commit0c4ec00cba82a900d22c3ba9bb0403a6b4cf8208 (patch)
tree8bcff59908f166b3a138ea6ae56ae841c28bcdec /test
parent98f947ceaedbae472efbebad505680d2ca62b403 (diff)
downloadhdf5-0c4ec00cba82a900d22c3ba9bb0403a6b4cf8208.zip
hdf5-0c4ec00cba82a900d22c3ba9bb0403a6b4cf8208.tar.gz
hdf5-0c4ec00cba82a900d22c3ba9bb0403a6b4cf8208.tar.bz2
[svn-r27481] Add support for offset selections passed to H5Pset_virtual.
Add test for this. Tested: ummon
Diffstat (limited to 'test')
-rw-r--r--test/vds.c197
1 files changed, 193 insertions, 4 deletions
diff --git a/test/vds.c b/test/vds.c
index 547f775..64a72f5 100644
--- a/test/vds.c
+++ b/test/vds.c
@@ -1104,6 +1104,7 @@ test_basic_io(unsigned config, hid_t fapl)
hsize_t stride[4]; /* Hyperslab stride */
hsize_t count[4]; /* Hyperslab count */
hsize_t block[4]; /* Hyperslab block */
+ hssize_t offset[2] = {0, 0}; /* Selection offset */
int buf[10][26]; /* Write and expected read buffer */
int rbuf[10][26]; /* Read buffer */
int rbuf99[9][9]; /* 9x9 Read buffer */
@@ -1606,7 +1607,195 @@ test_basic_io(unsigned config, hid_t fapl)
/*
- * Test 3: 2 Source datasets, hyperslab virtual mappings on one mapping at a
+ * Test 3: 2 Source datasets, hyperslab virtual mappings with offsets
+ */
+ /* Clear virtual layout in DCPL */
+ if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0)
+ TEST_ERROR
+
+ /* Create virtual dataspaces */
+ if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0)
+ TEST_ERROR
+
+ /* Create source dataspace */
+ dims[1] = 13;
+ if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0)
+ TEST_ERROR
+
+ /* Select all in source space (should not be necessary, but just to be sure)
+ */
+ if(H5Sselect_all(srcspace[0]) < 0)
+ TEST_ERROR
+
+ /* Select hyperslabs in virtual spaces */
+ start[0] = 0;
+ start[1] = 3;
+ if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, dims, NULL) < 0)
+ TEST_ERROR
+
+ /* Add virtual layout mappings */
+ offset[1] = -3;
+ if(H5Soffset_simple(vspace[0], offset) < 0)
+ TEST_ERROR
+ if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "%%src_dset1", srcspace[0]) < 0)
+ TEST_ERROR
+ offset[1] = 10;
+ if(H5Soffset_simple(vspace[0], offset) < 0)
+ TEST_ERROR
+ if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2%%", srcspace[0]) < 0)
+ TEST_ERROR
+
+ /* Reset dims */
+ dims[1] = 26;
+
+ /* Create virtual file */
+ if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Create source file if requested */
+ if(config & TEST_IO_DIFFERENT_FILE) {
+ if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+ } /* end if */
+ else {
+ srcfile[0] = vfile;
+ if(H5Iinc_ref(srcfile[0]) < 0)
+ TEST_ERROR
+ } /* end if */
+
+ /* Create source datasets */
+ if((srcdset[0] = H5Dcreate2(srcfile[0], "%src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2%", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Create virtual dataset */
+ if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Populate write buffer */
+ for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++)
+ for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++)
+ buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j;
+
+ /* Write data directly to source datasets */
+ offset[1] = -3;
+ if(H5Soffset_simple(vspace[0], offset) < 0)
+ TEST_ERROR
+ if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, buf[0]) < 0)
+ TEST_ERROR
+ offset[1] = 10;
+ if(H5Soffset_simple(vspace[0], offset) < 0)
+ TEST_ERROR
+ if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, buf[0]) < 0)
+ TEST_ERROR
+
+ /* Close srcdsets and srcfile if config option specified */
+ if(config & TEST_IO_CLOSE_SRC) {
+ if(H5Dclose(srcdset[0]) < 0)
+ TEST_ERROR
+ srcdset[0] = -1;
+ if(H5Dclose(srcdset[1]) < 0)
+ TEST_ERROR
+ srcdset[1] = -1;
+
+ if(config & TEST_IO_DIFFERENT_FILE) {
+ if(H5Fclose(srcfile[0]) < 0)
+ TEST_ERROR
+ srcfile[0] = -1;
+ } /* end if */
+ } /* end if */
+
+ /* Reopen virtual dataset and file if config option specified */
+ if(config & TEST_IO_REOPEN_VIRT) {
+ if(H5Dclose(vdset) < 0)
+ TEST_ERROR
+ vdset = -1;
+ if(H5Fclose(vfile) < 0)
+ TEST_ERROR
+ vfile = -1;
+ if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0)
+ TEST_ERROR
+ if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ } /* end if */
+
+ /* Read data through virtual dataset */
+ HDmemset(rbuf[0], 0, sizeof(rbuf));
+ if(H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0)
+ TEST_ERROR
+
+ /* Verify read data */
+ for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++)
+ for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++)
+ if(rbuf[i][j] != buf[i][j])
+ TEST_ERROR
+
+ /* Adjust write buffer */
+ for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++)
+ for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++)
+ buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0]));
+
+ /* Write data through virtual dataset */
+ if(H5Dwrite(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0)
+ TEST_ERROR
+
+ /* Reopen srcdsets and srcfile if config option specified */
+ if(config & TEST_IO_CLOSE_SRC) {
+ if(config & TEST_IO_DIFFERENT_FILE)
+ if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0)
+ TEST_ERROR
+ if((srcdset[0] = H5Dopen2(srcfile[0], "%src_dset1", H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2%", H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ } /* end if */
+
+ /* Read data directly from source datasets */
+ HDmemset(rbuf[0], 0, sizeof(rbuf));
+ offset[1] = -3;
+ if(H5Soffset_simple(vspace[0], offset) < 0)
+ TEST_ERROR
+ if(H5Dread(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0)
+ TEST_ERROR
+ offset[1] = 10;
+ if(H5Soffset_simple(vspace[0], offset) < 0)
+ TEST_ERROR
+ if(H5Dread(srcdset[1], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0)
+ TEST_ERROR
+
+ /* Verify read data */
+ for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++)
+ for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++)
+ if(rbuf[i][j] != buf[i][j])
+ TEST_ERROR
+
+ /* Close */
+ if(H5Dclose(srcdset[0]) < 0)
+ TEST_ERROR
+ srcdset[0] = -1;
+ if(H5Dclose(srcdset[1]) < 0)
+ TEST_ERROR
+ srcdset[1] = -1;
+ if(H5Dclose(vdset) < 0)
+ TEST_ERROR
+ vdset = -1;
+ if(H5Fclose(srcfile[0]) < 0)
+ TEST_ERROR
+ srcfile[0] = -1;
+ if(H5Fclose(vfile) < 0)
+ TEST_ERROR
+ vfile = -1;
+ if(H5Sclose(srcspace[0]) < 0)
+ TEST_ERROR
+ srcspace[0] = -1;
+ if(H5Sclose(vspace[0]) < 0)
+ TEST_ERROR
+ vspace[0] = -1;
+
+
+ /*
+ * Test 4: 2 Source datasets, hyperslab virtual mappings on one mapping at a
* time, '%' in source file name
*/
/* Clear virtual layout in DCPL */
@@ -1809,7 +1998,7 @@ test_basic_io(unsigned config, hid_t fapl)
/*
- * Test 4: 2 Source datasets, hyperslab virtual mappings and selections
+ * Test 5: 2 Source datasets, hyperslab virtual mappings and selections
*/
/* Clear virtual layout in DCPL */
if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0)
@@ -2090,7 +2279,7 @@ test_basic_io(unsigned config, hid_t fapl)
/*
- * Test 5: 2 Source datasets, checkerboard/stripe pattern to trigger
+ * Test 6: 2 Source datasets, checkerboard/stripe pattern to trigger
* sequence list refresh internally
*/
/* Clear virtual layout in DCPL */
@@ -2383,7 +2572,7 @@ test_basic_io(unsigned config, hid_t fapl)
/*
- * Test 6: 1 Source dataset, two mappings, 4 dimensional virtual dataset
+ * Test 7: 1 Source dataset, two mappings, 4 dimensional virtual dataset
* and 3 dimensional source dataset
*/
/* Clear virtual layout in DCPL */