summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorM. Scot Breitenfeld <brtnfld@hdfgroup.org>2018-01-05 15:57:48 (GMT)
committerM. Scot Breitenfeld <brtnfld@hdfgroup.org>2018-01-05 15:57:48 (GMT)
commit8712f3e231a93b6b68822be8ffb2e4fdbf12565f (patch)
treead87ef377e55d4136ffc1610059313974cb14af9 /test
parent3b02f2d03f5c349e341a776af488dfa033902f0a (diff)
parent994611a2d4320358dc5a1c0c721633670ad4833c (diff)
downloadhdf5-8712f3e231a93b6b68822be8ffb2e4fdbf12565f.zip
hdf5-8712f3e231a93b6b68822be8ffb2e4fdbf12565f.tar.gz
hdf5-8712f3e231a93b6b68822be8ffb2e4fdbf12565f.tar.bz2
synced with develop
Diffstat (limited to 'test')
-rw-r--r--test/CMakeTests.cmake1
-rw-r--r--test/filter_plugin.c204
-rw-r--r--test/vds.c452
3 files changed, 579 insertions, 78 deletions
diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake
index ae99be1..fca2f27 100644
--- a/test/CMakeTests.cmake
+++ b/test/CMakeTests.cmake
@@ -581,6 +581,7 @@ set (test_CLEANFILES
cache_logging.out
vds_swmr.h5
vds_swmr_src_*.h5
+ tmp/vds_src_2.h5
)
# Remove any output file left over from previous test run
diff --git a/test/filter_plugin.c b/test/filter_plugin.c
index 8b7e0e4..9897c84 100644
--- a/test/filter_plugin.c
+++ b/test/filter_plugin.c
@@ -134,7 +134,7 @@ allocate_and_init_2D_array(int ***arr, const hsize_t *sizes, int **initial_value
return SUCCEED;
error:
free_2D_array(arr);
-
+
return FAIL;
} /* end allocate_and_init_2D_array() */
@@ -165,7 +165,7 @@ compare_2D_arrays(int **dset1, int **dset2, const hsize_t *sizes, /*OUT*/ hbool_
}
return SUCCEED;
-
+
} /* end compare_2D_arrays() */
@@ -612,7 +612,7 @@ test_read_data(hid_t did, int *origin_data)
free_2D_array(&check);
PASSED();
-
+
return SUCCEED;
error:
@@ -943,14 +943,14 @@ error:
* paths.
*
* Return: SUCCEED/FAIL
- *
+ *
*-------------------------------------------------------------------------
*/
static herr_t
test_path_api_calls(void)
{
unsigned int n_starting_paths;
- unsigned int u;
+ unsigned int u;
unsigned int n_paths;
herr_t ret;
ssize_t path_len = -1;
@@ -1319,7 +1319,7 @@ error:
* Purpose: Turns the chunk cache off
*
* Return: SUCCEED/FAIL
- *
+ *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -1360,37 +1360,36 @@ main(void)
unsigned new_format;
int nerrors = 0;
- /* Testing setup */
- h5_reset();
-
/*******************************************************************/
/* ENSURE THAT WRITING TO DATASETS AND CREATING GROUPS WORKS */
/*******************************************************************/
+ /* Test with old & new format groups */
+ for (new_format = FALSE; new_format <= TRUE; new_format++) {
+ hid_t my_fapl_id;
- /* Get a VFD-dependent filename */
- if ((old_ff_fapl_id = h5_fileaccess()) < 0)
- TEST_ERROR;
-
- /* Turn off the chunk cache, so all the chunks are immediately written to disk */
- if (disable_chunk_cache(old_ff_fapl_id) < 0)
- TEST_ERROR;
+ /* Testing setup */
+ h5_reset();
- /* Copy the file access property list and set the latest file format on it */
- if ((new_ff_fapl_id = H5Pcopy(old_ff_fapl_id)) < 0)
- TEST_ERROR;
- if (H5Pset_libver_bounds(new_ff_fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
- TEST_ERROR;
+ /* Get a VFD-dependent filename */
+ if ((old_ff_fapl_id = h5_fileaccess()) < 0)
+ TEST_ERROR;
- /* Fix up the filename for the VFD */
- h5_fixname(FILENAME[0], old_ff_fapl_id, filename, sizeof(filename));
+ /* Turn off the chunk cache, so all the chunks are immediately written to disk */
+ if (disable_chunk_cache(old_ff_fapl_id) < 0)
+ TEST_ERROR;
- /* Test with old & new format groups */
- for (new_format = FALSE; new_format <= TRUE; new_format++) {
- hid_t my_fapl_id;
+ /* Fix up the filename for the VFD */
+ h5_fixname(FILENAME[0], old_ff_fapl_id, filename, sizeof(filename));
/* Set the FAPL for the type of format */
if (new_format) {
HDputs("\nTesting with new file format:");
+ /* Copy the file access property list and set the latest file format on it */
+ if ((new_ff_fapl_id = H5Pcopy(old_ff_fapl_id)) < 0)
+ TEST_ERROR;
+ if (H5Pset_libver_bounds(new_ff_fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ TEST_ERROR;
+
my_fapl_id = new_ff_fapl_id;
}
else {
@@ -1410,61 +1409,121 @@ main(void)
if (H5Fclose(fid) < 0)
TEST_ERROR;
- } /* end for */
- /* Close FAPLs */
- if (H5Pclose(old_ff_fapl_id) < 0)
- TEST_ERROR;
- if (H5Pclose(new_ff_fapl_id) < 0)
- TEST_ERROR;
+ /* Close FAPLs */
+ if (H5Pclose(old_ff_fapl_id) < 0)
+ TEST_ERROR;
+ if (new_format) {
+ if (H5Pclose(new_ff_fapl_id) < 0)
+ TEST_ERROR;
+ }
- /* Restore the default error handler (set in h5_reset()) */
- h5_restore_err();
+ /* Restore the default error handler (set in h5_reset()) */
+ h5_restore_err();
- /*******************************************************************/
- /* ENSURE THAT READING FROM DATASETS AND OPENING GROUPS WORKS */
- /*******************************************************************/
+ /*******************************************************************/
+ /* ENSURE THAT READING FROM DATASETS AND OPENING GROUPS WORKS */
+ /*******************************************************************/
- HDputs("\nTesting reading data with with dynamic plugin filters:");
+ HDputs("\nTesting reading data with with dynamic plugin filters:");
- /* Close the library so that all loaded plugin libraries are unloaded */
- h5_reset();
- if ((old_ff_fapl_id = h5_fileaccess()) < 0)
- TEST_ERROR;
+ /* Close the library so that all loaded plugin libraries are unloaded */
+ h5_reset();
+ if ((old_ff_fapl_id = h5_fileaccess()) < 0)
+ TEST_ERROR;
- /* Reopen the file for testing data reading */
- if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, old_ff_fapl_id)) < 0)
- TEST_ERROR;
+ /* Set the FAPL for the type of format */
+ if (new_format) {
+ /* Copy the file access property list and set the latest file format on it */
+ if ((new_ff_fapl_id = H5Pcopy(old_ff_fapl_id)) < 0)
+ TEST_ERROR;
+ if (H5Pset_libver_bounds(new_ff_fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ TEST_ERROR;
- /* Read the data with filters */
- nerrors += (test_dataset_read_with_filters(fid) < 0 ? 1 : 0);
+ my_fapl_id = new_ff_fapl_id;
+ }
+ else
+ my_fapl_id = old_ff_fapl_id;
- /* Test creating groups using dynamically-loaded plugin filters */
- nerrors += (test_opening_groups_using_plugins(fid) < 0 ? 1 : 0);
+ /* Reopen the file for testing data reading */
+ if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, my_fapl_id)) < 0)
+ TEST_ERROR;
- /* Restore the default error handler (set in h5_reset()) */
- h5_restore_err();
+ /* Read the data with filters */
+ nerrors += (test_dataset_read_with_filters(fid) < 0 ? 1 : 0);
- /*******************************************************************/
- /* ENSURE THAT DISABLING FILTER PLUGINS VIA THE FILTER FLAGS WORKS */
- /*******************************************************************/
+ /* Test creating groups using dynamically-loaded plugin filters */
+ nerrors += (test_opening_groups_using_plugins(fid) < 0 ? 1 : 0);
- /* Close the library so that all loaded plugin libraries are unloaded */
- h5_reset();
- if ((old_ff_fapl_id = h5_fileaccess()) < 0)
- TEST_ERROR;
+ /* Close FAPLs */
+ if (H5Pclose(old_ff_fapl_id) < 0)
+ TEST_ERROR;
+ if (new_format) {
+ if (H5Pclose(new_ff_fapl_id) < 0)
+ TEST_ERROR;
+ }
- /* Reopen the file for testing data reading */
- if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, old_ff_fapl_id)) < 0)
- TEST_ERROR;
+ /* Restore the default error handler (set in h5_reset()) */
+ h5_restore_err();
- /* When filters are disabled, make sure we can't read data from a
- * dataset that requires a filter plugin.
- */
- nerrors += (test_no_read_when_plugins_disabled(fid) < 0 ? 1 : 0);
+ /*******************************************************************/
+ /* ENSURE THAT DISABLING FILTER PLUGINS VIA THE FILTER FLAGS WORKS */
+ /*******************************************************************/
- if (H5Fclose(fid) < 0)
- TEST_ERROR;
+ /* Close the library so that all loaded plugin libraries are unloaded */
+ h5_reset();
+ if ((old_ff_fapl_id = h5_fileaccess()) < 0)
+ TEST_ERROR;
+
+ /* Set the FAPL for the type of format */
+ if (new_format) {
+ /* Copy the file access property list and set the latest file format on it */
+ if ((new_ff_fapl_id = H5Pcopy(old_ff_fapl_id)) < 0)
+ TEST_ERROR;
+ if (H5Pset_libver_bounds(new_ff_fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ TEST_ERROR;
+
+ my_fapl_id = new_ff_fapl_id;
+ }
+ else
+ my_fapl_id = old_ff_fapl_id;
+
+ /* Reopen the file for testing data reading */
+ if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, my_fapl_id)) < 0)
+ TEST_ERROR;
+
+ /* When filters are disabled, make sure we can't read data from a
+ * dataset that requires a filter plugin.
+ */
+ nerrors += (test_no_read_when_plugins_disabled(fid) < 0 ? 1 : 0);
+
+ if (H5Fclose(fid) < 0)
+ TEST_ERROR;
+
+ /*********************/
+ /* CLEAN UP */
+ /*********************/
+ /* Close FAPLs */
+ if (new_format) {
+ if (H5Pclose(new_ff_fapl_id) < 0)
+ TEST_ERROR;
+ }
+ else {
+ /* Restore the default error handler (set in h5_reset()) */
+ h5_restore_err();
+
+ if (H5Pclose(old_ff_fapl_id) < 0)
+ TEST_ERROR;
+ }
+
+ /* Free up saved arrays */
+ free_2D_array(&orig_deflate_g);
+ free_2D_array(&orig_dynlib1_g);
+ free_2D_array(&orig_dynlib2_g);
+ free_2D_array(&orig_dynlib4_g);
+ } /* end for */
+
+ h5_cleanup(FILENAME, old_ff_fapl_id);
/************************************/
/* TEST THE FILTER PLUGIN API CALLS */
@@ -1473,21 +1532,10 @@ main(void)
/* Test the APIs for access to the filter plugin path table */
nerrors += (test_path_api_calls() < 0 ? 1 : 0);
- /*********************/
- /* CLEAN UP AND EXIT */
- /*********************/
-
- /* Free up saved arrays */
- free_2D_array(&orig_deflate_g);
- free_2D_array(&orig_dynlib1_g);
- free_2D_array(&orig_dynlib2_g);
- free_2D_array(&orig_dynlib4_g);
-
if (nerrors)
TEST_ERROR;
HDprintf("All plugin tests passed.\n");
- h5_cleanup(FILENAME, old_ff_fapl_id);
HDexit(EXIT_SUCCESS);
diff --git a/test/vds.c b/test/vds.c
index 10da0de..7d55c37 100644
--- a/test/vds.c
+++ b/test/vds.c
@@ -36,6 +36,12 @@ const char *FILENAME[] = {
"vds_src_1",
"vds%%_src",
"vds_dapl",
+ "vds_virt_2",
+ "vds_virt_3",
+ "vds_src_2",
+ "vds_src_3",
+ "vds%%_src2",
+ "vds_dapl2",
NULL
};
@@ -49,6 +55,8 @@ const char *FILENAME[] = {
#define FILENAME_BUF_SIZE 1024
+#define TMPDIR "tmp/"
+
/*-------------------------------------------------------------------------
* Function: vds_select_equal
@@ -1110,6 +1118,449 @@ error:
return 1;
} /* end test_api() */
+/*-------------------------------------------------------------------------
+ * Function: vds_link_prefix
+ *
+ * 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
+ * by H5Pset_virtual_prefix()
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *-------------------------------------------------------------------------
+ */
+static int
+test_vds_prefix(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 */
+ hid_t vspace[4] = {-1, -1, -1, -1}; /* Virtual dset dataspaces */
+ hid_t memspace = -1; /* Memory dataspace */
+ hid_t srcdset[4] = {-1, -1, -1, -1}; /* Source datsets */
+ hid_t vdset = -1; /* Virtual dataset */
+ hsize_t dims[4] = {10, 26, 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 */
+ 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 */
+ int evbuf[10][26]; /* Expected VDS "buffer" */
+ int erbuf[10][26]; /* Expected read buffer */
+ int fill = -1; /* Fill value */
+ herr_t ret; /* Generic return value */
+ int i, j;
+ char buffer[1024]; /* buffer to read vds_prefix */
+
+ TESTING("basic virtual dataset I/O via H5Pset_vds_prefix()")
+
+ 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);
+ h5_fixname_printf(srcfilenamepct_map_orig, fapl, srcfilenamepct_map, sizeof srcfilenamepct_map);
+
+ /* create tmp directory and get current working directory path */
+ if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST)
+ 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
+
+ /* Initialize VDS prefix items */
+ if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
+ TEST_ERROR
+
+ if(H5Pset_virtual_prefix(dapl, TMPDIR) < 0)
+ TEST_ERROR
+ if(H5Pget_virtual_prefix(dapl, buffer, sizeof(buffer)) < 0)
+ TEST_ERROR
+
+ 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
+
+ /* 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(vfilename, 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(vfilename, 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(srcdset[0]) < 0)
+ TEST_ERROR
+ srcdset[0] = -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;
+ if(H5Pclose(dapl) < 0)
+ TEST_ERROR
+ dapl = -1;
+ if(H5Pclose(dcpl) < 0)
+ 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;
+
+ error:
+ H5E_BEGIN_TRY {
+ for(i = 0; i < (int)(sizeof(srcdset) / sizeof(srcdset[0])); i++)
+ H5Dclose(srcdset[i]);
+ H5Dclose(vdset);
+ 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++)
+ H5Sclose(vspace[i]);
+ H5Sclose(memspace);
+ H5Pclose(dapl);
+ H5Pclose(dcpl);
+ } H5E_END_TRY;
+
+ if(HDsetenv("HDF5_VDS_PREFIX", "", 1) < 0)
+ TEST_ERROR
+
+ return 1;
+} /* end vds_link_prefix() */
+
/*-------------------------------------------------------------------------
* Function: test_basic_io
@@ -11179,6 +11630,7 @@ main(void)
for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) {
printf("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_unlim(bit_config, fapl);
nerrors += test_printf(bit_config, fapl);
nerrors += test_all(bit_config, fapl);