summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJake Smith <jake.smith@hdfgroup.org>2019-09-24 21:43:30 (GMT)
committerJake Smith <jake.smith@hdfgroup.org>2019-09-24 21:43:30 (GMT)
commitf77d8f04fd703868d016a3ff824829bcb277b80f (patch)
treec541bac166199e47985bf879663bbf256db9bbf1 /test
parent9c73ed788ad620af7b09aaa75a7582ce30fac6be (diff)
parent9a388325ebaec339f67ddd210ca31ddcc3ede973 (diff)
downloadhdf5-f77d8f04fd703868d016a3ff824829bcb277b80f.zip
hdf5-f77d8f04fd703868d016a3ff824829bcb277b80f.tar.gz
hdf5-f77d8f04fd703868d016a3ff824829bcb277b80f.tar.bz2
Merge pull request #1756 in HDFFV/hdf5 from ~JAKE.SMITH/hdf5:bugfix/repack_external_storage to develop
* commit '9a388325ebaec339f67ddd210ca31ddcc3ede973': Update to current external file population. Revert else-if to single line. Change print calls to HD-wrapped. Minor formatting tweaks (inc. regressions and in-file style-matching). Refactor h5repackgentest to have more modular internals, for easier addition of new tests. Update manifest and test script for new hdf5 external-storage .h5 files. Refactoring. Add copyright/disclaimer to repack gentest. Minor formatting tweaks. Minor formatting adjustments. Undo some formatting modifications. Update MANIFEST. Add forgotten files to include from h5repack testfiles for tests. Fix failing automated reporting. Add 8-bit big-endian testfile. First pass at repack consolidating external storage if layout given. Checks out manually, tests still complain. Formatting changes, mostly. Add initial failing test for h5repack copying external data into new file. Modify code comments for clarity. Some minor reformatting. Some minor reformatting. Replace tabs with spaces. Add test that uses the family member FAPL setting. refactor h5repack_main.c -- remove some redundancy, formatting Fit help message to 80 character width and clarify some details.
Diffstat (limited to 'test')
-rw-r--r--test/external.c358
-rw-r--r--test/vfd.c133
2 files changed, 322 insertions, 169 deletions
diff --git a/test/external.c b/test/external.c
index 6c12c93..e2565de 100644
--- a/test/external.c
+++ b/test/external.c
@@ -15,7 +15,7 @@
* Programmer: Robb Matzke <matzke@llnl.gov>
* Tuesday, March 3, 1998
*
- * Purpose: Tests datasets stored in external raw files.
+ * Purpose: Tests datasets stored in external raw files.
*/
#include "external_common.h"
#include "external_fname.h"
@@ -27,7 +27,7 @@
* Purpose: Determines whether two files contain the same data.
*
* Return: Success: nonzero if same, zero if different.
- * Failure: zero
+ * Failure: zero
*
* Programmer: Robb Matzke
* Wednesday, March 4, 1998
@@ -37,14 +37,17 @@
static hbool_t
files_have_same_contents(const char *name1, const char *name2)
{
- int fd1 = 0, fd2 = 0;
- ssize_t n1, n2;
- char buf1[1024], buf2[1024];
+ int fd1 = 0;
+ int fd2 = 0;
+ ssize_t n1 = 0;
+ ssize_t n2 = 0;
+ char buf1[1024];
+ char buf2[1024];
hbool_t ret = FALSE; /* not equal until proven otherwise */
- if((fd1 = HDopen(name1, O_RDONLY)) < 0)
+ if ((fd1 = HDopen(name1, O_RDONLY)) < 0)
goto out;
- if((fd2 = HDopen(name2, O_RDONLY)) < 0)
+ if ((fd2 = HDopen(name2, O_RDONLY)) < 0)
goto out;
/* Loop until files are empty or we encounter a problem */
@@ -97,23 +100,21 @@ out:
static int
test_non_extendible(hid_t file)
{
- hid_t dcpl = -1; /* dataset creation properties */
- hid_t space = -1; /* data space */
- hid_t dset = -1; /* dataset */
- hsize_t cur_size[1]; /* data space current size */
- hsize_t max_size[1]; /* data space maximum size */
- int n; /* number of external files */
- char name[256]; /* external file name */
- off_t file_offset; /* external file offset */
- hsize_t file_size; /* sizeof external file segment */
- haddr_t dset_addr; /* address of dataset */
+ hid_t dcpl = -1; /* dataset creation properties */
+ hid_t space = -1; /* data space */
+ hid_t dset = -1; /* dataset */
+ hsize_t cur_size[1] = {100}; /* data space current size */
+ hsize_t max_size[1] = {100}; /* data space maximum size */
+ int n = 0; /* number of external files */
+ off_t file_offset = 0; /* external file offset */
+ hsize_t file_size = 0; /* sizeof external file segment */
+ haddr_t dset_addr = HADDR_UNDEF; /* address of dataset */
TESTING("fixed-size data space, exact storage");
- /* Create the dataset */
+ /* Create the dataset and close */
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR
- cur_size[0] = max_size[0] = 100;
if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int))) < 0)
FAIL_STACK_ERROR
if((space = H5Screate_simple(1, cur_size, max_size)) < 0)
@@ -148,27 +149,23 @@ test_non_extendible(hid_t file)
HDputs(" Returned external count is wrong.");
HDprintf(" got: %d\n ans: 1\n", n);
goto error;
- } /* end if */
+ }
- HDstrcpy(name + sizeof(name) - 4, "...");
- if(H5Pget_external(dcpl, 0, sizeof(name) - 4, name, &file_offset, &file_size) < 0)
+ /* Verify external file settings */
+ if(H5Pget_external(dcpl, 0, 0, NULL, &file_offset, &file_size) < 0)
FAIL_STACK_ERROR
-
- /* Check file offset */
if(file_offset != 0) {
H5_FAILED();
HDputs(" Wrong file offset.");
HDprintf(" got: %lu\n ans: 0\n", (unsigned long)file_offset);
goto error;
- } /* end if */
-
- /* Check file size */
+ }
if(file_size != (max_size[0] * sizeof(int))) {
H5_FAILED();
HDputs(" Wrong file size.");
HDprintf(" got: %lu\n ans: %lu\n", (unsigned long)file_size, (unsigned long)max_size[0]*sizeof(int));
goto error;
- } /* end if */
+ }
/* Done (dataspace was previously closed) */
if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR
@@ -195,7 +192,7 @@ test_non_extendible(hid_t file)
* Return: Success: 0
* Failure: 1
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, November 23, 1998
*
*-------------------------------------------------------------------------
@@ -203,18 +200,17 @@ test_non_extendible(hid_t file)
static int
test_too_small(hid_t file)
{
- hid_t dcpl = -1; /* dataset creation properties */
- hid_t space = -1; /* data space */
- hid_t dset = -1; /* dataset */
- hsize_t cur_size[1]; /* current data space size */
- hsize_t max_size[1]; /* maximum data space size */
+ hid_t dcpl = -1; /* dataset creation properties */
+ hid_t space = -1; /* data space */
+ hid_t dset = -1; /* dataset */
+ hsize_t cur_size[1] = {100}; /* current data space size */
+ hsize_t max_size[1] = {100}; /* maximum data space size */
TESTING("external storage is too small");
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR
- cur_size[0] = max_size[0] = 100;
- if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < 0)
+ if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < 0) /* note -1 */
FAIL_STACK_ERROR
if((space = H5Screate_simple(1, cur_size, max_size)) < 0)
FAIL_STACK_ERROR
@@ -249,10 +245,10 @@ test_too_small(hid_t file)
* represent the current data and large enough to represent the
* eventual size of the data.
*
- * Return: Success: 0
- * Failure: 1
+ * Return: Success: 0
+ * Failure: 1
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, November 23, 1998
*
*-------------------------------------------------------------------------
@@ -260,18 +256,16 @@ test_too_small(hid_t file)
static int
test_large_enough_current_eventual(hid_t file)
{
- hid_t dcpl = -1; /* dataset creation properties */
- hid_t space = -1; /* data space */
- hid_t dset = -1; /* dataset */
- hsize_t cur_size[1]; /* current data space size */
- hsize_t max_size[1]; /* maximum data space size */
+ hid_t dcpl = -1; /* dataset creation properties */
+ hid_t space = -1; /* data space */
+ hid_t dset = -1; /* dataset */
+ hsize_t cur_size[1] = {100}; /* current data space size */
+ hsize_t max_size[1] = {200}; /* maximum data space size */
TESTING("extendible dataspace, exact external size");
if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR
- cur_size[0] = 100;
- max_size[0] = 200;
if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int))) < 0)
FAIL_STACK_ERROR
if((space = H5Screate_simple(1, cur_size, max_size)) < 0)
@@ -313,19 +307,17 @@ error:
static int
test_large_enough_current_not_eventual(hid_t file)
{
- hid_t dcpl = -1; /* dataset creation properties */
- hid_t space = -1; /* data space */
- hid_t dset = -1; /* dataset */
- hsize_t cur_size[1]; /* current data space size */
- hsize_t max_size[1]; /* maximum data space size */
+ hid_t dcpl = -1; /* dataset creation properties */
+ hid_t space = -1; /* data space */
+ hid_t dset = -1; /* dataset */
+ hsize_t cur_size[1] = {100}; /* current data space size */
+ hsize_t max_size[1] = {200}; /* maximum data space size */
TESTING("extendible dataspace, external storage is too small");
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR
- cur_size[0] = 100;
- max_size[0] = 200;
- if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < 0)
+ if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < 0) /* note -1 */
FAIL_STACK_ERROR
if((space = H5Screate_simple(1, cur_size, max_size)) < 0)
FAIL_STACK_ERROR
@@ -369,15 +361,14 @@ test_large_enough_current_not_eventual(hid_t file)
static int
test_unlimited(hid_t file)
{
- hid_t dcpl = -1; /* dataset creation properties */
- hid_t space = -1; /* data space */
- hid_t dset = -1; /* dataset */
- hsize_t cur_size[1]; /* data space current size */
- hsize_t max_size[1]; /* data space maximum size */
- int n; /* number of external files */
- char name[256]; /* external file name */
- off_t file_offset; /* external file offset */
- hsize_t file_size; /* sizeof external file segment */
+ hid_t dcpl = -1; /* dataset creation properties */
+ hid_t space = -1; /* data space */
+ hid_t dset = -1; /* dataset */
+ hsize_t cur_size[1] = {100}; /* data space current size */
+ hsize_t max_size[1] = {H5S_UNLIMITED}; /* data space maximum size */
+ int n; /* number of external files */
+ off_t file_offset; /* external file offset */
+ hsize_t file_size; /* sizeof external file segment */
TESTING("unlimited dataspace, unlimited external storage");
@@ -386,8 +377,6 @@ test_unlimited(hid_t file)
FAIL_STACK_ERROR
if(H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED) < 0)
FAIL_STACK_ERROR
- cur_size[0] = 100;
- max_size[0] = H5S_UNLIMITED;
if((space = H5Screate_simple(1, cur_size, max_size)) < 0)
FAIL_STACK_ERROR
if((dset = H5Dcreate2(file, "dset5", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
@@ -411,22 +400,20 @@ test_unlimited(hid_t file)
goto error;
} /* end if */
- HDstrcpy(name + sizeof(name) - 4, "...");
- if(H5Pget_external(dcpl, 0, sizeof(name) - 4, name, &file_offset, &file_size) < 0)
+ if(H5Pget_external(dcpl, 0, 0, NULL, &file_offset, &file_size) < 0)
FAIL_STACK_ERROR
if(file_offset != 0) {
H5_FAILED();
HDputs(" Wrong file offset.");
HDprintf(" got: %lu\n ans: 0\n", (unsigned long)file_offset);
goto error;
- } /* end if */
-
+ }
if(H5F_UNLIMITED != file_size) {
H5_FAILED();
HDputs(" Wrong file size.");
HDprintf(" got: %lu\n ans: INF\n", (unsigned long)file_size);
goto error;
- } /* end if */
+ }
if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR
if(H5Dclose(dset) < 0) FAIL_STACK_ERROR
@@ -460,35 +447,67 @@ test_unlimited(hid_t file)
static int
test_multiple_files(hid_t file)
{
- hid_t dcpl = -1; /* dataset creation properties */
- hid_t space = -1; /* dataspace */
- hid_t dset = -1; /* dataset */
- hsize_t cur_size[1]; /* data space current size */
- hsize_t max_size[1]; /* data space maximum size */
+ hid_t dcpl = -1; /* dataset creation properties */
+ hid_t space = -1; /* dataspace */
+ hid_t dset = -1; /* dataset */
+ hsize_t cur_size[1] = {100}; /* data space current size */
+ hsize_t max_size[1] = {100}; /* data space maximum size */
+ hsize_t max_ext_size; /* maximum size of external files */
+ unsigned n_external_files = 4;
TESTING("multiple external files");
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR
- cur_size[0] = max_size[0] = 100;
+ max_ext_size = (hsize_t)(sizeof(int) * max_size[0] / n_external_files);
+
+ for (unsigned i = 0; i < n_external_files; i++) {
+ char exname[9] = "";
+ HDsnprintf(exname, 9, "ext%d.data", i+1);
+ if (H5Pset_external(dcpl, exname, (off_t)0, max_ext_size) < 0) {
+ HDfprintf(stderr, "Problem adding external file %s\n", exname);
+ fflush(stderr);
+ FAIL_STACK_ERROR
+ }
+ }
- if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0]*sizeof(int)/4)) < 0)
- FAIL_STACK_ERROR
- if(H5Pset_external(dcpl, "ext2.data", (off_t)0, (hsize_t)(max_size[0]*sizeof(int)/4)) < 0)
- FAIL_STACK_ERROR
- if(H5Pset_external(dcpl, "ext3.data", (off_t)0, (hsize_t)(max_size[0]*sizeof(int)/4)) < 0)
- FAIL_STACK_ERROR
- if(H5Pset_external(dcpl, "ext4.data", (off_t)0, (hsize_t)(max_size[0]*sizeof(int)/4)) < 0)
- FAIL_STACK_ERROR
if((space = H5Screate_simple(1, cur_size, max_size)) < 0)
FAIL_STACK_ERROR
+
if((dset = H5Dcreate2(file, "dset6", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR
if(H5Dclose(dset) < 0) FAIL_STACK_ERROR
- if(H5Sclose(space) < 0) FAIL_STACK_ERROR
if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR
+ /* Re-use space below */
+
+ /* ----------------------------------------------
+ * Verify that too-small external files will fail
+ */
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ FAIL_STACK_ERROR
+
+ max_ext_size -= 1;
+
+ for (unsigned i = 0; i < n_external_files; i++) {
+ char exname[9] = "";
+ HDsnprintf(exname, 9, "ext%d.data", i+1);
+ if (H5Pset_external(dcpl, exname, (off_t)0, max_ext_size) < 0) {
+ HDfprintf(stderr, "Problem adding external file %s\n", exname);
+ fflush(stderr);
+ FAIL_STACK_ERROR
+ }
+ } /* end for each external file */
+
+ H5E_BEGIN_TRY {
+ dset = H5Dcreate2(file, "dset7", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ } H5E_END_TRY;
+ if(dset >= 0)
+ FAIL_PUTS_ERROR(" Small external files succeeded instead of failing.");
+
+ if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR
+ if(H5Sclose(space) < 0) FAIL_STACK_ERROR
PASSED();
return 0;
@@ -520,9 +539,9 @@ error:
static int
test_add_to_unlimited(void)
{
- hid_t dcpl = -1; /* dataset creation properties */
- herr_t status; /* function return status */
- int n; /* number of external files */
+ hid_t dcpl = -1; /* dataset creation properties */
+ herr_t status = FAIL; /* function return status */
+ int n = 0; /* number of external files */
TESTING("external file following unlimited file");
@@ -571,12 +590,12 @@ test_add_to_unlimited(void)
static int
test_overflow(void)
{
- hid_t dcpl = -1; /* dataset creation properties */
- herr_t status; /* return status */
+ hid_t dcpl = -1; /* dataset creation properties */
+ herr_t status = FAIL; /* return status */
TESTING("address overflow in external files");
- if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR
if(H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED-1) < 0)
FAIL_STACK_ERROR
@@ -616,19 +635,19 @@ test_overflow(void)
static int
test_read_file_set(hid_t fapl)
{
- hid_t file = -1; /* file to write to */
- hid_t dcpl = -1; /* dataset creation properties */
- hid_t space = -1; /* data space */
- hid_t dset = -1; /* dataset */
- hid_t grp = -1; /* group to emit diagnostics */
- size_t i; /* miscellaneous counter */
- char filename[1024]; /* file names */
- int part[PART_SIZE]; /* raw data buffer (partial) */
+ hid_t file = -1; /* file to write to */
+ hid_t dcpl = -1; /* dataset creation properties */
+ hid_t space = -1; /* data space */
+ hid_t dset = -1; /* dataset */
+ hid_t grp = -1; /* group to emit diagnostics */
+ size_t i = 0; /* miscellaneous counter */
+ char filename[1024]; /* file names */
+ int part[PART_SIZE]; /* raw data buffer (partial) */
int whole[TOTAL_SIZE]; /* raw data buffer (total) */
- hsize_t cur_size; /* current data space size */
- hid_t hs_space = -1; /* hyperslab data space */
- hsize_t hs_start = 30; /* hyperslab starting offset */
- hsize_t hs_count = 25; /* hyperslab size */
+ hsize_t cur_size; /* current data space size */
+ hid_t hs_space = -1; /* hyperslab data space */
+ hsize_t hs_start = 30; /* hyperslab starting offset */
+ hsize_t hs_count = 25; /* hyperslab size */
TESTING("read external dataset");
@@ -657,7 +676,7 @@ test_read_file_set(hid_t fapl)
HDsnprintf(filename, sizeof(filename), "extern_%dr.raw", (int) i + 1);
if(H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0)
FAIL_STACK_ERROR
- } /* end for */
+ }
/* Create the dataspace */
cur_size = TOTAL_SIZE;
@@ -734,19 +753,19 @@ test_read_file_set(hid_t fapl)
static int
test_write_file_set(hid_t fapl)
{
- hid_t file = -1; /* file to which to write */
- hid_t dcpl = -1; /* dataset creation properties */
- hid_t mem_space = -1; /* memory data space */
- hid_t file_space = -1; /* file data space */
- hid_t dset = -1; /* dataset */
- unsigned i; /* miscellaneous counter */
- int part[PART_SIZE]; /* raw data buffer (partial) */
- int whole[TOTAL_SIZE]; /* raw data buffer (total) */
- hsize_t cur_size = 100; /* current data space size */
- hsize_t max_size = 200; /* maximum data space size */
- hsize_t hs_start = 100; /* hyperslab starting offset */
- hsize_t hs_count = 100; /* hyperslab size */
- char filename[1024]; /* file name */
+ hid_t file = -1; /* file to which to write */
+ hid_t dcpl = -1; /* dataset creation properties */
+ hid_t mem_space = -1; /* memory data space */
+ hid_t file_space = -1; /* file data space */
+ hid_t dset = -1; /* dataset */
+ unsigned i = 0; /* miscellaneous counter */
+ int part[PART_SIZE]; /* raw data buffer (partial) */
+ int whole[TOTAL_SIZE]; /* raw data buffer (total) */
+ hsize_t cur_size = 100; /* current data space size */
+ hsize_t max_size = 200; /* maximum data space size */
+ hsize_t hs_start = 100; /* hyperslab starting offset */
+ hsize_t hs_count = 100; /* hyperslab size */
+ char filename[1024]; /* file name */
TESTING("write external dataset");
@@ -859,16 +878,16 @@ test_write_file_set(hid_t fapl)
static int
test_path_absolute(hid_t fapl)
{
- hid_t file = -1; /* file to write to */
- hid_t dcpl = -1; /* dataset creation properties */
- hid_t space = -1; /* data space */
- hid_t dset = -1; /* dataset */
- size_t i; /* miscellaneous counter */
- char cwdpath[1024]; /* working directory */
- char filename[1536]; /* file name */
- int part[PART_SIZE]; /* raw data buffer (partial) */
+ hid_t file = -1; /* file to write to */
+ hid_t dcpl = -1; /* dataset creation properties */
+ hid_t space = -1; /* data space */
+ hid_t dset = -1; /* dataset */
+ size_t i = 0; /* miscellaneous counter */
+ char cwdpath[1024]; /* working directory */
+ char filename[1024]; /* file name */
+ int part[PART_SIZE]; /* raw data buffer (partial) */
int whole[TOTAL_SIZE]; /* raw data buffer (total) */
- hsize_t cur_size; /* current data space size */
+ hsize_t cur_size; /* current data space size */
TESTING("absolute filenames for external file");
@@ -949,16 +968,16 @@ error:
static int
test_path_relative(hid_t fapl)
{
- hid_t file = -1; /* file to write to */
- hid_t dcpl = -1; /* dataset creation properties */
- hid_t space = -1; /* data space */
- hid_t dset = -1; /* dataset */
- size_t i; /* miscellaneous counters */
- char cwdpath[1024]; /* working directory */
- char filename[1024]; /* file name */
- int part[PART_SIZE]; /* raw data buffer (partial) */
+ hid_t file = -1; /* file to write to */
+ hid_t dcpl = -1; /* dataset creation properties */
+ hid_t space = -1; /* data space */
+ hid_t dset = -1; /* dataset */
+ size_t i = 0; /* miscellaneous counters */
+ char cwdpath[1024]; /* working directory */
+ char filename[1024]; /* file name */
+ int part[PART_SIZE]; /* raw data buffer (partial) */
int whole[TOTAL_SIZE]; /* raw data buffer (total) */
- hsize_t cur_size; /* current data space size */
+ hsize_t cur_size; /* current data space size */
TESTING("filenames relative to current directory for external file");
@@ -1039,21 +1058,21 @@ error:
static int
test_path_relative_cwd(hid_t fapl)
{
- hid_t file = -1; /* file to write to */
- hid_t dcpl = -1; /* dataset creation properties */
- hid_t space = -1; /* data space */
- hid_t dapl = -1; /* dataset access property list */
- hid_t dapl2 = -1; /* copy of dapl */
- hid_t dset = -1; /* dataset */
- hid_t dset2 = -1; /* dataset, opened a second time */
- hid_t dset3 = -1; /* dataset, opened with different prefix */
- size_t i; /* miscellaneous counters */
- char cwdpath[1024]; /* working directory */
- char filename[1024]; /* file name */
- int part[PART_SIZE]; /* raw data buffer (partial) */
+ hid_t file = -1; /* file to write to */
+ hid_t dcpl = -1; /* dataset creation properties */
+ hid_t space = -1; /* data space */
+ hid_t dapl = -1; /* dataset access property list */
+ hid_t dapl2 = -1; /* copy of dapl */
+ hid_t dset = -1; /* dataset */
+ hid_t dset2 = -1; /* dataset, opened a second time */
+ hid_t dset3 = -1; /* dataset, opened with different prefix */
+ size_t i = 0; /* miscellaneous counters */
+ char cwdpath[1024]; /* working directory */
+ char filename[1024]; /* file name */
+ int part[PART_SIZE]; /* raw data buffer (partial) */
int whole[TOTAL_SIZE]; /* raw data buffer (total) */
- hsize_t cur_size; /* current data space size */
- char buffer[1024]; /* buffer to read efile_prefix */
+ hsize_t cur_size; /* current data space size */
+ char buffer[1024]; /* buffer to read efile_prefix */
TESTING("filenames relative to HDF5 file for external file");
@@ -1195,14 +1214,14 @@ error:
static int
test_h5d_get_access_plist(hid_t fapl_id)
{
- hid_t fid = -1; /* file to write to */
- hid_t dcpl_id = -1; /* dataset creation properties */
- hid_t dapl_id = -1; /* dataset access properties */
- hid_t sid = -1; /* data space */
- hid_t did = -1; /* dataset */
- hsize_t dims = 0; /* dataset size */
- char *buffer = NULL; /* saved prefix name from dapl */
- char filename[1024]; /* file names */
+ hid_t fid = -1; /* file to write to */
+ hid_t dcpl_id = -1; /* dataset creation properties */
+ hid_t dapl_id = -1; /* dataset access properties */
+ hid_t sid = -1; /* data space */
+ hid_t did = -1; /* dataset */
+ hsize_t dims = 0; /* dataset size */
+ char *buffer = NULL; /* saved prefix name from dapl */
+ char filename[1024]; /* file names */
TESTING("H5Dget_access_plist() returns correct prefix");
@@ -1285,7 +1304,7 @@ test_h5d_get_access_plist(hid_t fapl_id)
*
* Return: EXIT_SUCCESS/EXIT_FAILURE
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, March 3, 1998
*
*-------------------------------------------------------------------------
@@ -1293,13 +1312,13 @@ test_h5d_get_access_plist(hid_t fapl_id)
int
main(void)
{
- hid_t fapl_id_old = -1; /* file access properties (old format) */
- hid_t fapl_id_new = -1; /* file access properties (new format) */
- hid_t fid = -1; /* file for test_1* functions */
- hid_t gid = -1; /* group to emit diagnostics */
- char filename[1024]; /* file name for test_1* funcs */
- unsigned latest_format; /* default or latest file format */
- int nerrors = 0; /* number of errors */
+ hid_t fapl_id_old = -1; /* file access properties (old format) */
+ hid_t fapl_id_new = -1; /* file access properties (new format) */
+ hid_t fid = -1; /* file for test_1* functions */
+ hid_t gid = -1; /* group to emit diagnostics */
+ char filename[1024]; /* file name for test_1* funcs */
+ unsigned latest_format; /* default or latest file format */
+ int nerrors = 0; /* number of errors */
h5_reset();
@@ -1325,11 +1344,11 @@ main(void)
if(latest_format) {
HDputs("\nTesting with the latest file format:");
current_fapl_id = fapl_id_new;
- } /* end if */
+ }
else {
HDputs("Testing with the default file format:");
current_fapl_id = fapl_id_old;
- } /* end else */
+ }
/* Create the common file used by some of the tests */
if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, current_fapl_id)) < 0)
@@ -1365,7 +1384,7 @@ main(void)
/* Close the common file */
if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
- } /* end for */
+ } /* end for old and new format */
if(nerrors > 0) goto error;
@@ -1387,7 +1406,7 @@ main(void)
HDremove("extern_4w.raw");
HDrmdir("extern_dir");
- } /* end if */
+ }
return EXIT_SUCCESS;
@@ -1402,3 +1421,4 @@ error:
HDprintf("%d TEST%s FAILED.\n", nerrors, 1 == nerrors ? "" : "s");
return EXIT_FAILURE;
} /* end main() */
+
diff --git a/test/vfd.c b/test/vfd.c
index 68fe0bd..1de7fd5 100644
--- a/test/vfd.c
+++ b/test/vfd.c
@@ -1132,6 +1132,138 @@ error:
/*-------------------------------------------------------------------------
+ * Function: test_family_member_fapl
+ *
+ * Purpose: Actually use the member fapl input to the member vfd.
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Jacob Smith
+ * 21 May 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_family_member_fapl(void)
+{
+ hid_t file = H5I_INVALID_HID;
+ hid_t fapl_id = H5I_INVALID_HID;
+ hid_t memb_fapl_id = H5I_INVALID_HID;
+ hid_t space = H5I_INVALID_HID;
+ hid_t dset = H5I_INVALID_HID;
+ char filename[1024];
+ char dname[] = "dataset";
+ unsigned i = 0;
+ unsigned j = 0;
+ int buf[FAMILY_NUMBER][FAMILY_SIZE];
+ hsize_t dims[2] = {FAMILY_NUMBER, FAMILY_SIZE};
+
+ TESTING("Family member FAPL");
+
+ fapl_id = H5Pcreate(H5P_FILE_ACCESS);
+ if (H5I_INVALID_HID == fapl_id) {
+ TEST_ERROR;
+ }
+ memb_fapl_id = H5Pcreate(H5P_FILE_ACCESS);
+ if (H5I_INVALID_HID == memb_fapl_id) {
+ TEST_ERROR;
+ }
+ if (H5Pset_fapl_sec2(memb_fapl_id) == FAIL) {
+ TEST_ERROR;
+ }
+ if (H5Pset_fapl_family(fapl_id, (hsize_t)FAMILY_SIZE, memb_fapl_id) == FAIL) {
+ TEST_ERROR;
+ }
+ h5_fixname(FILENAME[2], fapl_id, filename, sizeof(filename));
+
+ file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
+ if (H5I_INVALID_HID == file) {
+ TEST_ERROR;
+ }
+
+ space = H5Screate_simple(2, dims, NULL);
+ if (H5I_INVALID_HID == space) {
+ TEST_ERROR;
+ }
+
+ /* Create and write to dataset, then close file.
+ */
+ dset = H5Dcreate2(
+ file,
+ dname,
+ H5T_NATIVE_INT,
+ space,
+ H5P_DEFAULT,
+ H5P_DEFAULT,
+ H5P_DEFAULT);
+ if (H5I_INVALID_HID == dset) {
+ TEST_ERROR;
+ }
+ for (i = 0; i < FAMILY_NUMBER; i++) {
+ for (j = 0; j < FAMILY_SIZE; j++) {
+ buf[i][j] = (int)((i * 10000) + j);
+ }
+ }
+ if (H5Dwrite(dset,
+ H5T_NATIVE_INT,
+ H5S_ALL,
+ H5S_ALL,
+ H5P_DEFAULT,
+ buf)
+ == FAIL)
+ {
+ TEST_ERROR;
+ }
+ if (H5Dclose(dset) == FAIL) {
+ TEST_ERROR;
+ }
+ if (H5Sclose(space) == FAIL) {
+ TEST_ERROR;
+ }
+ if (H5Fclose(file) == FAIL) {
+ TEST_ERROR;
+ }
+
+ /* "Close" member FAPL at top level and re-open file.
+ * Should succeed, with library managing reference count properly
+ */
+ if (H5Pclose(memb_fapl_id) == FAIL) {
+ TEST_ERROR;
+ }
+
+ file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id);
+ if (H5I_INVALID_HID == file) {
+ TEST_ERROR;
+ }
+
+ if (H5Fclose(file) == FAIL) {
+ TEST_ERROR;
+ }
+
+ h5_delete_test_file(FILENAME[2], fapl_id);
+
+ if (H5Pclose(fapl_id) == FAIL) {
+ TEST_ERROR;
+ }
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Dclose(dset);
+ H5Pclose(memb_fapl_id);
+ H5Pclose(fapl_id);
+ H5Fclose(file);
+ } H5E_END_TRY;
+
+ return -1;
+} /* end test_family_member_fapl() */
+
+
+/*-------------------------------------------------------------------------
* Function: test_multi_opens
*
* Purpose: Private function for test_multi() to tests wrong ways of
@@ -2042,6 +2174,7 @@ main(void)
nerrors += test_direct() < 0 ? 1 : 0;
nerrors += test_family() < 0 ? 1 : 0;
nerrors += test_family_compat() < 0 ? 1 : 0;
+ nerrors += test_family_member_fapl() < 0 ? 1 : 0;
nerrors += test_multi() < 0 ? 1 : 0;
nerrors += test_multi_compat() < 0 ? 1 : 0;
nerrors += test_log() < 0 ? 1 : 0;