summaryrefslogtreecommitdiffstats
path: root/test/vds.c
diff options
context:
space:
mode:
authorSongyu Lu <songyulu@hdfgroup.org>2019-04-04 16:03:05 (GMT)
committerSongyu Lu <songyulu@hdfgroup.org>2019-04-04 16:03:05 (GMT)
commit50d9a397ab4bcbeaa6466eabe1c2ec6e2cf61f89 (patch)
treee20fb6dd1745060836a29b020dd5d9bfcab84dd7 /test/vds.c
parente09e2fc4ad7aadef1a99573ee6d3cec9bea3becb (diff)
downloadhdf5-50d9a397ab4bcbeaa6466eabe1c2ec6e2cf61f89.zip
hdf5-50d9a397ab4bcbeaa6466eabe1c2ec6e2cf61f89.tar.gz
hdf5-50d9a397ab4bcbeaa6466eabe1c2ec6e2cf61f89.tar.bz2
This commit basically has the following changes:
1. restored the datatype, dataspace, and LCPL of the dataset for VOL connector back to the properties. 2. splitted external.c and vds.c because they called HDsetenv in the program, instead using shell scripts to set the environment variables. 3. changed H5CX_get_vds_prefix and H5CX_get_ext_file_prefix to use H5P_peek instead of H5P_get.
Diffstat (limited to 'test/vds.c')
-rw-r--r--test/vds.c198
1 files changed, 5 insertions, 193 deletions
diff --git a/test/vds.c b/test/vds.c
index 67af8e3..ad77030 100644
--- a/test/vds.c
+++ b/test/vds.c
@@ -1119,7 +1119,7 @@ error:
} /* end test_api() */
/*-------------------------------------------------------------------------
- * Function: vds_link_prefix
+ * Function: test_vds_prefix_first
*
* Purpose: Set up vds link prefix via H5Pset_virtual_prefix() to be "tmp"
* Should be able to access the target source files in tmp directory via the prefix set
@@ -1130,18 +1130,16 @@ error:
*-------------------------------------------------------------------------
*/
static int
-test_vds_prefix(unsigned config, hid_t fapl)
+test_vds_prefix_first(unsigned config, hid_t fapl)
{
char srcfilename[FILENAME_BUF_SIZE];
char srcfilename_map[FILENAME_BUF_SIZE];
char vfilename[FILENAME_BUF_SIZE];
- char vfilename2[FILENAME_BUF_SIZE];
char srcfilenamepct[FILENAME_BUF_SIZE];
char srcfilenamepct_map[FILENAME_BUF_SIZE];
const char *srcfilenamepct_map_orig = "vds%%%%_src";
hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */
hid_t vfile = -1; /* File with virtual dset */
- hid_t vfile2 = -1; /* File with copied virtual dset */
hid_t dcpl = -1; /* Dataset creation property list */
hid_t dapl = -1; /* Dataset access property list */
hid_t srcspace[4] = {-1, -1, -1, -1}; /* Source dataspaces */
@@ -1156,10 +1154,9 @@ test_vds_prefix(unsigned config, hid_t fapl)
int i, j;
char buffer[1024]; /* buffer to read vds_prefix */
- TESTING("basic virtual dataset I/O via H5Pset_vds_prefix()")
+ TESTING("basic virtual dataset I/O via H5Pset_vds_prefix(): all selection")
h5_fixname(FILENAME[0], fapl, vfilename, sizeof vfilename);
- h5_fixname(FILENAME[7], fapl, vfilename2, sizeof vfilename2);
h5_fixname(FILENAME[8], fapl, srcfilename, sizeof srcfilename);
h5_fixname_printf(FILENAME[8], fapl, srcfilename_map, sizeof srcfilename_map);
h5_fixname(FILENAME[10], fapl, srcfilenamepct, sizeof srcfilenamepct);
@@ -1189,9 +1186,6 @@ test_vds_prefix(unsigned config, hid_t fapl)
if(HDstrcmp(buffer, TMPDIR) != 0)
FAIL_PUTS_ERROR("vds prefix not set correctly");
- /*
- * Test 1: All - all selection
- */
/* Create source dataspace */
if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0)
TEST_ERROR
@@ -1344,187 +1338,6 @@ test_vds_prefix(unsigned config, hid_t fapl)
TEST_ERROR
dcpl = -1;
- /*
- * Test 2: All - all selection with ENV prefix
- */
- if(HDsetenv("HDF5_VDS_PREFIX", "${ORIGIN}/tmp", 1))
- TEST_ERROR
-
- /* Create DCPL */
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
- TEST_ERROR
-
- /* Set fill value */
- if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0)
- TEST_ERROR
-
- /* Set prefix to a nonexistent directory, will be overwritten by environment variable */
- if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
- TEST_ERROR
-
- if(H5Pset_virtual_prefix(dapl, "someprefix") < 0)
- TEST_ERROR
- if(H5Pget_virtual_prefix(dapl, buffer, sizeof(buffer)) < 0)
- TEST_ERROR
-
- if(HDstrcmp(buffer, "someprefix") != 0)
- FAIL_PUTS_ERROR("vds prefix not set correctly");
-
- /* Create source dataspace */
- if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0)
- TEST_ERROR
-
- /* Create virtual dataspace */
- if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0)
- TEST_ERROR
-
- /* Select all (should not be necessary, but just to be sure) */
- if(H5Sselect_all(srcspace[0]) < 0)
- TEST_ERROR
- if(H5Sselect_all(vspace[0]) < 0)
- TEST_ERROR
-
- /* Add virtual layout mapping */
- if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset", srcspace[0]) < 0)
- TEST_ERROR
-
- /* Create virtual file */
- if((vfile = H5Fcreate(vfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
- TEST_ERROR
-
- /* Create source file if requested */
- if(config & TEST_IO_DIFFERENT_FILE) {
- HDgetcwd(buffer, 1024);
- HDchdir(TMPDIR);
- if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
- TEST_ERROR
- HDchdir(buffer);
- }
- else {
- srcfile[0] = vfile;
- if(H5Iinc_ref(srcfile[0]) < 0)
- TEST_ERROR
- }
-
- /* Create source dataset */
- if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset", 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, dapl)) < 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 dataset */
- if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0)
- TEST_ERROR
-
- /* Close srcdset and srcfile if config option specified */
- if(config & TEST_IO_CLOSE_SRC) {
- if(H5Dclose(srcdset[0]) < 0)
- TEST_ERROR
- srcdset[0] = -1;
-
- if(config & TEST_IO_DIFFERENT_FILE) {
- if(H5Fclose(srcfile[0]) < 0)
- TEST_ERROR
- srcfile[0] = -1;
- }
- }
-
- /* 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(vfilename2, H5F_ACC_RDWR, fapl)) < 0)
- TEST_ERROR
- if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0)
- TEST_ERROR
- }
-
- /* 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 srcdset and srcfile if config option specified */
- if(config & TEST_IO_CLOSE_SRC) {
- if(config & TEST_IO_DIFFERENT_FILE) {
- HDgetcwd(buffer, 1024);
- HDchdir(TMPDIR);
- if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0)
- TEST_ERROR
- HDchdir(buffer);
- }
- if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset", H5P_DEFAULT)) < 0)
- TEST_ERROR
- }
-
- /* Read data directly from source dataset */
- HDmemset(rbuf[0], 0, sizeof(rbuf));
- if(H5Dread(srcdset[0], 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
-
- /* Close */
- if(H5Dclose(vdset) < 0)
- TEST_ERROR
- vdset = -1;
- if(H5Dclose(srcdset[0]) < 0)
- TEST_ERROR
- srcdset[0] = -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;
- if(H5Pclose(dapl) < 0)
- TEST_ERROR
- dapl = -1;
- if(H5Pclose(dcpl) < 0)
- TEST_ERROR
- dcpl = -1;
-
- if(HDsetenv("HDF5_VDS_PREFIX", "", 1) < 0)
- TEST_ERROR
-
PASSED();
return 0;
@@ -1536,7 +1349,6 @@ test_vds_prefix(unsigned config, hid_t fapl)
for(i = 0; i < (int)(sizeof(srcfile) / sizeof(srcfile[0])); i++)
H5Fclose(srcfile[i]);
H5Fclose(vfile);
- H5Fclose(vfile2);
for(i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++)
H5Sclose(srcspace[i]);
for(i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++)
@@ -1550,7 +1362,7 @@ test_vds_prefix(unsigned config, hid_t fapl)
TEST_ERROR
return 1;
-} /* end vds_link_prefix() */
+} /* end test_vds_prefix */
/*-------------------------------------------------------------------------
@@ -11621,7 +11433,7 @@ main(void)
for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) {
HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : "");
nerrors += test_basic_io(bit_config, fapl);
- nerrors += test_vds_prefix(bit_config, fapl);
+ nerrors += test_vds_prefix_first(bit_config, fapl);
nerrors += test_unlim(bit_config, fapl);
nerrors += test_printf(bit_config, fapl);
nerrors += test_all(bit_config, fapl);