summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2018-02-13 17:05:08 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2018-02-13 17:05:08 (GMT)
commit0a61befddc6f93cec1aa669e3c348e40e83ff0e7 (patch)
tree9d604314d09ee1dce7ce5255ed72ccd9b3a14b07 /test
parent96c656ae3fa02721cddf5f570d7372f38b886d76 (diff)
downloadhdf5-0a61befddc6f93cec1aa669e3c348e40e83ff0e7.zip
hdf5-0a61befddc6f93cec1aa669e3c348e40e83ff0e7.tar.gz
hdf5-0a61befddc6f93cec1aa669e3c348e40e83ff0e7.tar.bz2
Additional tests
Description: - Revised and add more variety to version bound tests per review - Revised gen_bounds.c per review Platforms tested: Linux/64 (jelly) Linux/32 (jam) Darwin (osx1010test)
Diffstat (limited to 'test')
-rw-r--r--test/dsets.c419
-rw-r--r--test/objcopy.c199
-rw-r--r--test/ohdr.c86
-rw-r--r--test/set_extent.c31
-rw-r--r--test/tfile.c130
-rw-r--r--test/th5o.c191
-rw-r--r--test/th5s.c149
7 files changed, 1026 insertions, 179 deletions
diff --git a/test/dsets.c b/test/dsets.c
index 0fff2d1..09f553e 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -24,8 +24,31 @@
#define H5Z_FRIEND /*suppress error about including H5Zpkg */
-#include "h5test.h"
+#include "hdf5.h"
+#include "testhdf5.h"
#include "H5srcdir.h"
+
+#include "H5Bprivate.h"
+#include "H5Iprivate.h"
+#include "H5Pprivate.h"
+
+#define H5F_FRIEND /*suppress error about including H5Fpkg */
+#define H5F_TESTING
+#include "H5Fpkg.h" /* File access */
+
+#define H5S_FRIEND /*suppress error about including H5Spkg */
+#include "H5Spkg.h" /* Dataspace */
+
+#define H5T_FRIEND /*suppress error about including H5Tpkg */
+#include "H5Tpkg.h" /* Datatype */
+
+#define H5A_FRIEND /*suppress error about including H5Apkg */
+#include "H5Apkg.h" /* Attributes */
+
+/* Use in version bound test */
+#define H5O_FRIEND /*suppress error about including H5Opkg */
+#include "H5Opkg.h" /* Object headers */
+
#include "H5Dpkg.h"
#include "H5FDpkg.h"
#include "H5VMprivate.h"
@@ -60,8 +83,10 @@ const char *FILENAME[] = {
"storage_size", /* 22 */
"dls_01_strings", /* 23 */
"power2up", /* 24 */
+ "version_bounds", /* 25 */
NULL
};
+
#define FILENAME_BUF_SIZE 1024
#define KB 1024
@@ -722,10 +747,15 @@ static herr_t
test_compact_io(hid_t fapl)
{
hid_t file, dataset, space, plist;
+ hid_t verfile = -1, new_fapl = -1;
hsize_t dims[2];
int wbuf[16][8], rbuf[16][8];
char filename[FILENAME_BUF_SIZE];
+ H5F_libver_t low, high; /* File format bounds */
+ H5F_t *fp; /* Internal file pointer */
+ H5D_t *dsetp; /* Internal dataset pointer */
int i, j, n;
+ herr_t ret; /* Generic return value */
TESTING("compact dataset I/O");
@@ -764,8 +794,6 @@ test_compact_io(hid_t fapl)
if(H5Dget_offset(dataset)!=HADDR_UNDEF) TEST_ERROR
/* Close file */
- if(H5Sclose(space) < 0) TEST_ERROR
- if(H5Pclose(plist) < 0) TEST_ERROR
if(H5Dclose(dataset) < 0) TEST_ERROR
if(H5Fclose(file) < 0) TEST_ERROR
@@ -789,16 +817,110 @@ test_compact_io(hid_t fapl)
printf(" wbuf[%d][%d]=%d\n", i, j, wbuf[i][j]);
printf(" rbuf[%d][%d]=%d\n", i, j, rbuf[i][j]);
goto error;
- } /* end if */
+ } /* end */
if(H5Dclose(dataset) < 0) TEST_ERROR
if(H5Fclose(file) < 0) TEST_ERROR
- PASSED();
- return 0;
+ /**************************************
+ * Additional test for version bounds *
+ **************************************/
+
+ /* Create a copy of file access property list */
+ if((new_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR
+
+ /* Loop through all the combinations of low/high library format bounds,
+ skipping invalid combinations.
+ - Create a file, create and write a compact dataset, and verify its data
+ - Verify the dataset's layout and fill message versions */
+ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) {
+ for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) {
+
+ /* Set version bounds */
+ H5E_BEGIN_TRY {
+ ret = H5Pset_libver_bounds(new_fapl, low, high);
+ } H5E_END_TRY;
+
+ if (ret < 0) /* Invalid low/high combinations */
+ continue;
+
+ /* Create a file */
+ h5_fixname(FILENAME[25], new_fapl, filename, sizeof filename);
+ if((verfile = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, new_fapl)) < 0)
+ TEST_ERROR
+
+ /* Create the compact dataset */
+ dataset = H5Dcreate2(verfile, DSET_DEFAULT_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, plist, H5P_DEFAULT);
+ if(dataset < 0) TEST_ERROR
+
+ /* Write the same data as of DSET_COMPACT_IO_NAME */
+ if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0)
+ TEST_ERROR
+
+ /* Close DSET_DEFAULT_NAME, then reopen it to read and verify
+ the data */
+ if(H5Dclose(dataset) < 0) TEST_ERROR
+ if((dataset = H5Dopen2(verfile, DSET_DEFAULT_NAME, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ TEST_ERROR
+
+ /* Check that the values read are the same as the values written */
+ for(i = 0; i < 16; i++)
+ for(j = 0; j < 8; j++)
+ if(rbuf[i][j] != wbuf[i][j]) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
+ printf(" wbuf[%d][%d]=%d\n", i, j, wbuf[i][j]);
+ printf(" rbuf[%d][%d]=%d\n", i, j, rbuf[i][j]);
+ goto error;
+ } /* end */
+
+ /* Get the internal file pointer */
+ if((fp = (H5F_t *)H5I_object(verfile)) == NULL) TEST_ERROR
+
+ /* Get the internal dataset pointer */
+ if((dsetp = (H5D_t *)H5I_object(dataset)) == NULL) TEST_ERROR
+
+ /* Verify the dataset's layout and fill message versions */
+ if(fp->shared->low_bound == H5F_LIBVER_EARLIEST) {
+ VERIFY(dsetp->shared->layout.version, H5O_LAYOUT_VERSION_DEFAULT, "layout_ver_bounds");
+ VERIFY(dsetp->shared->dcpl_cache.fill.version, H5O_FILL_VERSION_2, "fill_ver_bounds");
+ } else {
+ VERIFY(dsetp->shared->layout.version, H5O_layout_ver_bounds[fp->shared->low_bound], "layout_ver_bounds");
+ VERIFY(dsetp->shared->dcpl_cache.fill.version, H5O_fill_ver_bounds[fp->shared->low_bound], "fill_ver_bounds");
+ }
+
+ /* Close the dataset and delete from the file */
+ if(H5Dclose(dataset) < 0) TEST_ERROR
+ if(H5Ldelete(verfile, DSET_DEFAULT_NAME, H5P_DEFAULT) < 0)
+ TEST_ERROR
+
+ /* Close the file */
+ if(H5Fclose(verfile) < 0) TEST_ERROR
+
+ } /* end for high */
+ } /* end for low */
+
+ if(H5Pclose(new_fapl) < 0) TEST_ERROR
+ if(H5Sclose(space) < 0) TEST_ERROR
+ if(H5Pclose(plist) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
error:
- return -1;
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Pclose(plist);
+ H5Pclose(new_fapl);
+ H5Dclose(dataset);
+ H5Fclose(file);
+ H5Fclose(verfile);
+ } H5E_END_TRY;
+
+ return -1;
}
@@ -5045,16 +5167,16 @@ error:
/*-------------------------------------------------------------------------
* Function: test_multiopen
*
- * Purpose: Tests that a bug no longer exists. If a dataset is opened
- * twice and one of the handles is used to extend the dataset,
- * then the other handle should return the new size when
- * queried.
+ * Purpose: Tests that a bug no longer exists. If a dataset is opened
+ * twice and one of the handles is used to extend the dataset,
+ * then the other handle should return the new size when
+ * queried.
*
- * Return: Success: 0
+ * Return: Success: 0
*
- * Failure: -1
+ * Failure: -1
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, June 9, 1998
*
*-------------------------------------------------------------------------
@@ -5062,10 +5184,10 @@ error:
static herr_t
test_multiopen (hid_t file)
{
- hid_t dcpl = -1, space = -1, dset1 = -1, dset2 = -1;
- hsize_t cur_size[1] = {10};
- static hsize_t max_size[1] = {H5S_UNLIMITED};
- hsize_t tmp_size[1];
+ hid_t dcpl = -1, space = -1, dset1 = -1, dset2 = -1;
+ hsize_t cur_size[1] = {10};
+ hsize_t tmp_size[1];
+ static hsize_t max_size[1] = {H5S_UNLIMITED};
TESTING("multi-open with extending");
@@ -5085,9 +5207,9 @@ test_multiopen (hid_t file)
if((space = H5Dget_space(dset2)) < 0) goto error;
if(H5Sget_simple_extent_dims(space, tmp_size, NULL) < 0) goto error;
if(cur_size[0] != tmp_size[0]) {
- H5_FAILED();
- printf(" Got %d instead of %d!\n", (int)tmp_size[0], (int)cur_size[0]);
- goto error;
+ H5_FAILED();
+ printf(" Got %d instead of %d!\n", (int)tmp_size[0], (int)cur_size[0]);
+ goto error;
} /* end if */
if(H5Dclose(dset1) < 0) goto error;
@@ -9790,6 +9912,7 @@ test_single_chunk(hid_t fapl)
} /* end for */
#endif /* H5_HAVE_FILTER_DEFLATE */
+
/* Release buffers */
HDfree(wbuf);
HDfree(rbuf);
@@ -10152,7 +10275,7 @@ error:
/*-------------------------------------------------------------------------
* Function: test_zero_dim_dset
*
- * Purpose: Tests support for reading a 1D chunled dataset with
+ * Purpose: Tests support for reading a 1D chunked dataset with
* dimension size = 0.
*
* Return: Success: 0
@@ -10173,40 +10296,59 @@ test_zero_dim_dset(hid_t fapl)
hid_t dsid = -1; /* Dataset ID */
hsize_t dim, chunk_dim; /* Dataset and chunk dimensions */
int data[1];
+ H5F_libver_t low, high; /* File format bounds */
+ herr_t ret; /* Generic return value */
- TESTING("shrinking large chunk");
+ TESTING("chunked dataset with zero dimension");
- h5_fixname(FILENAME[16], fapl, filename, sizeof filename);
+ /* Loop through all the combinations of low/high library format bounds,
+ skipping invalid combination, and verify support for reading a 1D
+ chunked dataset with dimension size = 0 */
+ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) {
+ for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) {
- /* Create file */
- if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR
+ /* Set version bounds before opening the file */
+ H5E_BEGIN_TRY {
+ ret = H5Pset_libver_bounds(fapl, low, high);
+ } H5E_END_TRY;
- /* Create dataset creation property list */
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR
+ if (ret < 0) /* Invalid low/high combinations */
+ continue;
- /* Set 1 chunk size */
- chunk_dim = 1;
- if(H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) FAIL_STACK_ERROR
+ h5_fixname(FILENAME[16], fapl, filename, sizeof filename);
- /* Create 1D dataspace with 0 dim size */
- dim = 0;
- if((sid = H5Screate_simple(1, &dim, NULL)) < 0) FAIL_STACK_ERROR
+ /* Create file */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR
- /* Create chunked dataset */
- if((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ /* Create dataset creation property list */
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR
- /* write 0 elements from dataset */
- if(H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR
+ /* Set 1 chunk size */
+ chunk_dim = 1;
+ if(H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) FAIL_STACK_ERROR
- /* Read 0 elements from dataset */
- if(H5Dread(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR
+ /* Create 1D dataspace with 0 dim size */
+ dim = 0;
+ if((sid = H5Screate_simple(1, &dim, NULL)) < 0) FAIL_STACK_ERROR
- /* Close everything */
- if(H5Sclose(sid) < 0) FAIL_STACK_ERROR
- if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR
- if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR
- if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+ /* Create chunked dataset */
+ if((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* write 0 elements from dataset */
+ if(H5Dwrite(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR
+
+ /* Read 0 elements from dataset */
+ if(H5Dread(dsid, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR
+
+ /* Close everything */
+ if(H5Sclose(sid) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+
+ } /* end for high */
+ } /* end for low */
PASSED();
@@ -12728,34 +12870,186 @@ error:
/*-------------------------------------------------------------------------
- * Function: main
+ * Function: test_versionbounds
*
- * Purpose: Tests the dataset interface (H5D)
+ * Purpose: Tests various format versions.
+ * (Currently, only virtual dataset feature)
+ *
+ * Return: Success: 0
+ * Failure: -1
+ * Description:
+ * This function attempts to create a virtual dataset in all
+ * valid combinations of low/high library format bounds. Creation
+ * of virtual dataset should only succeed in H5F_LIBVER_V110.
+ * -BMR, January 2018
+ *
+ *-------------------------------------------------------------------------
+ */
+#define VDS_FNAME1 "virtual_file1"
+#define VDS_FNAME2 "virtual_file2"
+#define SRC_FNAME "source_file"
+#define SRC_DSET "src_dset"
+#define V_DSET "v_dset"
+static herr_t
+test_versionbounds()
+{
+ hid_t fapl = -1;
+ hid_t srcfile = -1; /* Files with source dsets */
+ hid_t vfile = -1; /* File with virtual dset */
+ hid_t dcpl = -1; /* Dataset creation property list */
+ hid_t srcspace = -1; /* Source dataspaces */
+ hid_t vspace = -1; /* Virtual dset dataspaces */
+ hid_t srcdset = -1; /* Source datset */
+ hid_t vdset = -1; /* Virtual dataset */
+ hid_t null_dspace = -1; /* Data space of H5S_NULL */
+ hsize_t dims[1] = {3}; /* Data space current size */
+ char srcfilename[FILENAME_BUF_SIZE];
+ char vfilename1[FILENAME_BUF_SIZE];
+ char vfilename2[FILENAME_BUF_SIZE];
+ H5F_libver_t low, high; /* File format bounds */
+ herr_t ret; /* Generic return value */
+
+ TESTING("version bounds of datasets");
+
+ /* Create a copy of file access property list */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR
+
+ h5_fixname(VDS_FNAME1, fapl, vfilename1, sizeof vfilename1);
+ h5_fixname(VDS_FNAME2, fapl, vfilename2, sizeof vfilename2);
+ h5_fixname(SRC_FNAME, fapl, srcfilename, sizeof srcfilename);
+
+ /* Create DCPL */
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ TEST_ERROR
+
+ /* Clear virtual layout in DCPL */
+ if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0)
+ TEST_ERROR
+
+ /* Create source dataspace */
+ if((srcspace = H5Screate_simple(1, dims, NULL)) < 0)
+ TEST_ERROR
+
+ /* Create virtual dataspace */
+ if((vspace = H5Screate_simple(1, dims, NULL)) < 0)
+ TEST_ERROR
+
+ /* Add virtual layout mapping */
+ if(H5Pset_virtual(dcpl, vspace, srcfilename, SRC_DSET, srcspace) < 0)
+ TEST_ERROR
+
+ /* Loop through all the combinations of low/high library format bounds */
+ /* Create a source file and a dataset in it. Create a virtual file and
+ virtual dataset. Creation of virtual dataset should only succeed in
+ H5F_LIBVER_V110 */
+ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) {
+ for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) {
+
+ /* Set version bounds, skip for invalid low/high combination */
+ H5E_BEGIN_TRY {
+ ret = H5Pset_libver_bounds(fapl, low, high);
+ } H5E_END_TRY;
+
+ if (ret < 0) /* Invalid low/high combinations */
+ continue;
+
+ /* Create a source file and dataset */
+ if((srcfile = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+ if((srcdset = H5Dcreate2(srcfile, SRC_DSET, H5T_NATIVE_INT, srcspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Create a virtual file */
+ if((vfile = H5Fcreate(vfilename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Create the virtual dataset */
+ H5E_BEGIN_TRY {
+ vdset = H5Dcreate2(vfile, V_DSET, H5T_NATIVE_INT, vspace, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ } H5E_END_TRY;
+
+ if (vdset > 0) /* dataset created successfully */
+ {
+ /* Virtual dataset is only available starting in V110 */
+ VERIFY(high, H5F_LIBVER_V110, "virtual dataset");
+
+ if(H5Dclose(vdset) < 0) TEST_ERROR
+ vdset = -1;
+ }
+
+ /* Close virtual file */
+ if(H5Fclose(vfile) < 0) TEST_ERROR
+ vfile = -1;
+
+ /* Close srcdset and srcfile */
+ if(H5Dclose(srcdset) < 0) TEST_ERROR
+ srcdset = -1;
+
+ if(H5Fclose(srcfile) < 0) TEST_ERROR
+ srcfile = -1;
+
+ } /* for high */
+ } /* for low */
+
+ /* Close dataspaces and properties */
+ if(H5Sclose(srcspace) < 0)
+ TEST_ERROR
+ srcspace = -1;
+ if(H5Sclose(vspace) < 0)
+ TEST_ERROR
+ vspace = -1;
+ if(H5Pclose(fapl) < 0)
+ TEST_ERROR
+ fapl = -1;
+ if(H5Pclose(dcpl) < 0)
+ TEST_ERROR
+ dcpl = -1;
+ PASSED();
+ return 0;
+
+ error:
+ H5E_BEGIN_TRY {
+ H5Sclose(srcspace);
+ H5Sclose(vspace);
+ H5Pclose(dcpl);
+ H5Pclose(fapl);
+ H5Dclose(srcdset);
+ H5Dclose(vdset);
+ H5Fclose(srcfile);
+ H5Fclose(vfile);
+ } H5E_END_TRY;
+ return -1;
+} /* test_versionbounds() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
*
- * Return: Success: exit(EXIT_SUCCESS)
+ * Purpose: Tests the dataset interface (H5D)
*
- * Failure: exit(EXIT_FAILURE)
+ * Return: Success: exit(EXIT_SUCCESS)
+ * Failure: exit(EXIT_FAILURE)
*
- * Programmer: Robb Matzke
- * Tuesday, December 9, 1997
+ * Programmer: Robb Matzke
+ * Tuesday, December 9, 1997
*
*-------------------------------------------------------------------------
*/
int
main(void)
{
- char filename[FILENAME_BUF_SIZE];
- hid_t file, grp, fapl, fapl2;
- hid_t fcpl = -1, fcpl2 = -1;
+ char filename[FILENAME_BUF_SIZE];
+ hid_t file, grp, fapl, fapl2;
+ hid_t fcpl = -1, fcpl2 = -1;
unsigned new_format;
unsigned paged;
- int mdc_nelmts;
- size_t rdcc_nelmts;
- size_t rdcc_nbytes;
- double rdcc_w0;
- int nerrors = 0;
+ int mdc_nelmts;
+ size_t rdcc_nelmts;
+ size_t rdcc_nbytes;
+ double rdcc_w0;
+ int nerrors = 0;
const char *envval;
- hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */
+ hbool_t contig_addr_vfd; /* Whether VFD used has a contigous address space */
/* Don't run this test using certain file drivers */
envval = HDgetenv("HDF5_DRIVER");
@@ -12924,6 +13218,9 @@ main(void)
nerrors += (test_scatter_error() < 0 ? 1 : 0);
nerrors += (test_gather_error() < 0 ? 1 : 0);
+ /* Tests version bounds using its own file */
+ nerrors += (test_versionbounds() < 0 ? 1 : 0);
+
/* Run misc tests */
nerrors += dls_01_main();
diff --git a/test/objcopy.c b/test/objcopy.c
index 216d111..c4bcbf3 100644
--- a/test/objcopy.c
+++ b/test/objcopy.c
@@ -18,9 +18,18 @@
* Purpose: Test H5Ocopy().
*/
+#include "hdf5.h"
#include "testhdf5.h"
#include "H5srcdir.h"
+#include "H5Bprivate.h"
+#include "H5Iprivate.h"
+#include "H5Pprivate.h"
+
+#define H5F_FRIEND /*suppress error about including H5Fpkg */
+#define H5F_TESTING
+#include "H5Fpkg.h" /* File access */
+
/*
* This file needs to access private information from the H5S package.
* This file also needs to access the dataspace testing code.
@@ -45,12 +54,22 @@
#define H5D_TESTING
#include "H5Dpkg.h" /* Datasets */
+/*
+ * This file needs to access private information from the H5O package.
+ * This file also needs to access the dataspace testing code.
+ */
+#define H5O_FRIEND /*suppress error about including H5Opkg */
+#define H5O_TESTING
+#include "H5Opkg.h" /* Object header */
+
const char *FILENAME[] = {
"objcopy_src",
"objcopy_dst",
"objcopy_ext",
"objcopy_src2",
+ "verbound_src",
+ "verbound_dst",
NULL
};
@@ -127,6 +146,7 @@ const char *FILENAME[] = {
#define NAME_LINK_EXTERN_DANGLE "/g_links/external_link_to_nowhere"
#define NAME_LINK_EXTERN_DANGLE2 "/g_links2/external_link_to_nowhere"
#define NAME_OLD_FORMAT "/dset1"
+#define NAME_DSET_NULL "DSET_NULL"
#define NAME_BUF_SIZE 1024
#define ATTR_NAME_LEN 80
@@ -2089,6 +2109,184 @@ error:
/*-------------------------------------------------------------------------
+ * Function: test_copy_dataset_versionbounds
+ *
+ * Purpose: Verify copying dataset works as expected in various version
+ * bound combination.
+ *
+ * Description:
+ * Create a simple dataset in SRC file using default versions.
+ * For each valid version bound combination, create a DST file,
+ * and attempt to copy the SRC dataset to the DST file.
+ * When copying fails, verify that the failure is a result of
+ * the invalid bounds, that is, DST has lower bounds than SRC.
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_dataset_versionbounds(hid_t fcpl_src, hid_t fapl_src)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* Source and destination file IDs */
+ hid_t fapl_dst = -1; /* File access plist for dest file */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did_src = -1, did_dst = -1; /* Source and destination dataset IDs */
+ int buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */
+ hsize_t dim2d[2]; /* Dataset dimensions */
+ char src_fname[NAME_BUF_SIZE]; /* Name of source file */
+ char dst_fname[NAME_BUF_SIZE]; /* Name of destination file */
+ H5F_libver_t low, high; /* File format bounds */
+ H5F_libver_t low_src, high_src; /* Source file format bounds */
+ unsigned srcdset_fillversion; /* Fill version of source dataset */
+ hbool_t valid_high = FALSE; /* TRUE if high bound is valid */
+ int i, j; /* Local index variables */
+ H5D_t *dsetp = NULL; /* Pointer to internal dset structure */
+ herr_t ret; /* Generic return value */
+
+ TESTING("H5Ocopy(): simple dataset with version bounds");
+
+ /* Initialize write buffer */
+ for (i=0; i<DIM_SIZE_1; i++)
+ for (j=0; j<DIM_SIZE_2; j++)
+ buf[i][j] = 10000 + 100*i+j;
+
+ /* Create a file access property list for destination file */
+ if ((fapl_dst = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[4], fapl_src, src_fname, sizeof src_fname);
+ h5_fixname(FILENAME[5], fapl_dst, dst_fname, sizeof dst_fname);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* Create source file */
+ fid_src = H5Fcreate(src_fname, H5F_ACC_TRUNC, fcpl_src, fapl_src);
+ if (fid_src < 0) TEST_ERROR
+
+ /* Set dataspace dimensions */
+ dim2d[0] = DIM_SIZE_1;
+ dim2d[1] = DIM_SIZE_2;
+
+ /* Create 2D dataspace */
+ if((sid = H5Screate_simple(2, dim2d, NULL)) < 0) TEST_ERROR
+
+ /* Create 2D int dataset in SRC file */
+ did_src = H5Dcreate2(fid_src, NAME_DATASET_SIMPLE, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (did_src < 0) TEST_ERROR
+
+ /* Write data into SRC file */
+ ret = H5Dwrite(did_src, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
+ if (ret < 0) TEST_ERROR
+
+ /* Get the internal dset ptr to get the fill version for verifying later */
+ if ((dsetp = (H5D_t *)H5I_object(did_src)) == NULL) TEST_ERROR
+ srcdset_fillversion = dsetp->shared->dcpl_cache.fill.version;
+
+ /* Close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR
+
+ /* Close the dataset */
+ if(H5Dclose(did_src) < 0) TEST_ERROR
+
+ /* Close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /* Open the source file with read-only */
+ fid_src = H5Fopen(src_fname, H5F_ACC_RDONLY, fapl_src);
+ if (fid_src < 0) TEST_ERROR
+
+ /* Loop through all the combinations of low/high library format bounds,
+ skipping invalid combinations. Create a destination file and copy the
+ source dataset to it, then verify */
+ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) {
+ for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) {
+
+ /* Set version bounds */
+ H5E_BEGIN_TRY {
+ ret = H5Pset_libver_bounds(fapl_dst, low, high);
+ } H5E_END_TRY;
+
+ if (ret < 0) /* Invalid low/high combinations */
+ continue;
+
+ /* Create destination file */
+ fid_dst = H5Fcreate(dst_fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_dst);
+ if (fid_dst < 0) TEST_ERROR
+
+ /* Create an uncopied object in destination file so that addresses
+ in source and destination files aren't the same */
+ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Try to copy the dataset */
+ H5E_BEGIN_TRY {
+ ret = H5Ocopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT);
+ } H5E_END_TRY;
+
+ /* If copy failed, check if the failure is expected */
+ if (ret < 0)
+ {
+ /* Failure is valid if fill version of source dataset is
+ greater than destination */
+ if (srcdset_fillversion <= H5O_fill_ver_bounds[high])
+ TEST_ERROR
+
+ /* Close the DST file before continue */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+ continue;
+ }
+
+ /* Close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ /* Open destination file */
+ fid_dst = H5Fopen(dst_fname, H5F_ACC_RDWR, fapl_dst);
+ if (fid_dst < 0) TEST_ERROR
+
+ /* Open the datasets to compare */
+ did_src = H5Dopen2(fid_src, NAME_DATASET_SIMPLE, H5P_DEFAULT);
+ if (did_src < 0) TEST_ERROR
+ did_dst = H5Dopen2(fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT);
+ if (did_dst < 0) TEST_ERROR
+
+ /* Check if the datasets are equal */
+ if (compare_datasets(did_src, did_dst, H5P_DEFAULT, buf) != TRUE)
+ TEST_ERROR
+
+ /* Close the datasets */
+ if(H5Dclose(did_dst) < 0) TEST_ERROR
+ if(H5Dclose(did_src) < 0) TEST_ERROR
+
+ /* Close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ } /* for high */
+ } /* for low */
+
+ /* Close property list and source file */
+ if (H5Pclose(fapl_dst) < 0) TEST_ERROR
+ if (H5Fclose(fid_src) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(did_dst);
+ H5Dclose(did_src);
+ H5Sclose(sid);
+ H5Pclose(fapl_dst);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+
+ return 1;
+} /* end test_copy_dataset_versionbounds */
+
+
+/*-------------------------------------------------------------------------
* Function: test_copy_dataset_simple_samefile
*
* Purpose: Create a simple dataset in SRC file and copy it to SRC file
@@ -14017,6 +14215,7 @@ main(void)
/* The tests... */
nerrors += test_copy_dataset_simple(fcpl_src, fcpl_dst, src_fapl, dst_fapl);
+ nerrors += test_copy_dataset_versionbounds(fcpl_src, src_fapl);
nerrors += test_copy_dataset_simple_samefile(fcpl_src, src_fapl);
/* Test with dataset opened in the file or not */
diff --git a/test/ohdr.c b/test/ohdr.c
index 3915b38..43346a5 100644
--- a/test/ohdr.c
+++ b/test/ohdr.c
@@ -738,6 +738,42 @@ error:
return FAIL;
} /* test_unknown() */
+#define STR_EARLIEST "earliest"
+#define STR_V18 "v18"
+#define STR_LATEST "latest"
+char *version_string(H5F_libver_t libver)
+{
+ char *str = NULL;
+
+ str = (char *) malloc(20 * sizeof(char));
+ if (str == NULL)
+ {
+ fprintf(stderr, "Allocation failed\n");
+ exit(1);
+ }
+
+ switch(libver) {
+ case H5F_LIBVER_EARLIEST:
+ strcpy(str, STR_EARLIEST);
+ break;
+
+ case H5F_LIBVER_V18:
+ strcpy(str, STR_V18);
+ break;
+
+ case H5F_LIBVER_V110:
+ HDassert(H5F_LIBVER_LATEST == H5F_LIBVER_V110);
+ strcpy(str, STR_LATEST);
+ break;
+
+ case H5F_LIBVER_ERROR:
+ case H5F_LIBVER_NBOUNDS:
+ default:
+ sprintf(str, "%ld", (long)libver);
+ break;
+ } /* end switch */
+} /* end of version_string */
+
/*-------------------------------------------------------------------------
* Function: main
@@ -755,32 +791,40 @@ error:
int
main(void)
{
- hid_t fapl = -1, file = -1;
- H5F_t *f = NULL;
- char filename[1024];
- H5O_hdr_info_t hdr_info; /* Object info */
- H5O_loc_t oh_loc; /* Object header locations */
- time_t time_new, ro;
- int i; /* Local index variable */
- unsigned b; /* Index for "new format" loop */
- herr_t ret; /* Generic return value */
+ hid_t fapl = -1;
+ hid_t file = -1;
+ H5F_t *f = NULL;
+ char filename[1024];
+ H5O_hdr_info_t hdr_info; /* Object info */
+ H5O_loc_t oh_loc; /* Object header locations */
+ H5F_libver_t low, high; /* File format bounds */
+ time_t time_new, ro;
+ unsigned b; /* Index for "new format" loop */
+ char msg[80]; /* Message for file format version */
+ int i; /* Local index variable */
+ herr_t ret; /* Generic return value */
/* Reset library */
h5_reset();
fapl = h5_fileaccess();
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
- /* Loop over old & new formats */
- for(b = FALSE; b <= TRUE; b++) {
- /* Display info about testing */
- if(b)
- HDputs("Using new file format:");
- else
- HDputs("Using default file format:");
+ /* Loop through all the combinations of low/high library format bounds */
+ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) {
+ for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) {
- /* Set the format to use for the file */
- if(H5Pset_libver_bounds(fapl, (b ? H5F_LIBVER_LATEST : H5F_LIBVER_EARLIEST), H5F_LIBVER_LATEST) < 0)
- FAIL_STACK_ERROR
+ /* Set version bounds before opening the file */
+ H5E_BEGIN_TRY {
+ ret = H5Pset_libver_bounds(fapl, low, high);
+ } H5E_END_TRY;
+
+ if (ret < 0) /* Invalid low/high combinations */
+ continue;
+
+ /* Display info about testing */
+ sprintf(msg, "Using file format version: (%s, %s)", version_string(low),
+ version_string(high));
+ HDputs(msg);
/* test on object continuation block */
if(test_cont(filename, fapl) < 0)
@@ -977,7 +1021,9 @@ main(void)
/* Test object header creation metadata cache issues */
if(test_ohdr_cache(filename, fapl) < 0)
TEST_ERROR
- } /* end for */
+
+ } /* high */
+ } /* low */
/* Verify symbol table messages are cached */
if(h5_verify_cached_stabs(FILENAME, fapl) < 0) TEST_ERROR
diff --git a/test/set_extent.c b/test/set_extent.c
index b9536e5..0467073 100644
--- a/test/set_extent.c
+++ b/test/set_extent.c
@@ -427,14 +427,35 @@ error:
*/
static int do_layouts( hid_t fapl )
{
+ H5F_libver_t low, high; /* Low and high bounds */
+ herr_t ret; /* Generic return value */
- TESTING("storage layout use");
+ TESTING("storage layout use - tested with all low/high library format bounds");
+ /* Loop through all the combinations of low/high library format bounds */
+ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) {
+ for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) {
- if (test_layouts( H5D_COMPACT, fapl ) < 0)
- goto error;
+ hid_t new_fapl;
- if (test_layouts( H5D_CONTIGUOUS, fapl ) < 0)
- goto error;
+ /* Copy plist to use locally to avoid modifying the original */
+ new_fapl = H5Pcopy(fapl);
+
+ /* Set version bounds */
+ H5E_BEGIN_TRY {
+ ret = H5Pset_libver_bounds(new_fapl, low, high);
+ } H5E_END_TRY;
+
+ if (ret < 0) /* Invalid low/high combinations */
+ continue;
+
+ if (test_layouts( H5D_COMPACT, new_fapl ) < 0)
+ goto error;
+
+ if (test_layouts( H5D_CONTIGUOUS, new_fapl ) < 0)
+ goto error;
+
+ } /* end for high */
+ } /* end for low */
PASSED();
diff --git a/test/tfile.c b/test/tfile.c
index 03a5233..8b66603 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -4953,6 +4953,134 @@ test_libver_bounds_real(H5F_libver_t libver_create, unsigned oh_vers_create,
CHECK(ret, FAIL, "H5Pclose");
} /* end test_libver_bounds_real() */
+
+/*-------------------------------------------------------------------------
+ * Function: test_libver_bounds_open
+ *
+ * Purpose: Tests opening latest file with various low/high bounds.
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ *-------------------------------------------------------------------------
+ */
+#define VERBFNAME "tverbounds_dspace.h5"
+#define VERBDSNAME "dataset 1"
+#define SPACE1_DIM1 3
+static int
+test_libver_bounds_open(void)
+{
+ hid_t file = -1; /* File ID */
+ hid_t space = -1; /* Dataspace ID */
+ hid_t dset = -1; /* Dataset ID */
+ hid_t fapl = -1; /* File access property list ID */
+ hid_t new_fapl = -1;/* File access property list ID for reopened file */
+ hid_t dcpl = -1; /* Dataset creation property list ID */
+ hsize_t dim[1] = {SPACE1_DIM1}; /* Dataset dimensions */
+ H5F_libver_t low, high; /* File format bounds */
+ hsize_t chunk_dim[1] = {SPACE1_DIM1}; /* Chunk dimensions */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Opening File in Various Version Bounds\n"));
+
+ /* Create a file access property list */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Create dataspace */
+ space = H5Screate_simple(1, dim, NULL);
+ CHECK(space, FAIL, "H5Screate_simple");
+
+ /* Create a dataset creation property list */
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+
+ /* Create and set chunk plist */
+ ret = H5Pset_chunk(dcpl, 1, chunk_dim);
+ CHECK(ret, FAIL, "H5Pset_chunk");
+ ret = H5Pset_deflate(dcpl, 9);
+ CHECK(ret, FAIL, "H5Pset_deflate");
+ ret = H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS);
+ CHECK(ret, FAIL, "H5Pset_chunk_opts");
+
+ /* Create a file with (LATEST, LATEST) bounds, create a layout version 4
+ dataset, then close the file */
+
+ /* Set version bounds to (LATEST, LATEST) */
+ low = H5F_LIBVER_LATEST;
+ high = H5F_LIBVER_LATEST;
+ ret = H5Pset_libver_bounds(fapl, low, high);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
+ /* Create the file */
+ file = H5Fcreate(VERBFNAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
+ CHECK(file, FAIL, "H5Fcreate");
+
+ /* Create dataset */
+ dset = H5Dcreate2(file, VERBDSNAME, H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ CHECK(dset, FAIL, "H5Dcreate2");
+
+ /* Close dataset and file */
+ ret = H5Dclose(dset);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Fclose(file);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Attempt to open latest file with (earliest, v18), should fail */
+ ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_V18);
+ H5E_BEGIN_TRY {
+ file = H5Fopen(VERBFNAME, H5F_ACC_RDONLY, fapl);
+ } H5E_END_TRY;
+ VERIFY(file, FAIL, "Attempted to open latest file with earliest version");
+
+ /* Attempt to open latest file with (v18, v18), should fail */
+ ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_V18);
+ H5E_BEGIN_TRY {
+ file = H5Fopen(VERBFNAME, H5F_ACC_RDONLY, fapl);
+ } H5E_END_TRY;
+ VERIFY(file, FAIL, "Attempted to open latest file with v18 bounds");
+
+ /* Opening VERBFNAME in these combination should succeed.
+ For each low bound, verify that it is upgraded properly */
+ high = H5F_LIBVER_LATEST;
+ for (low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++)
+ {
+ H5F_libver_t new_low = H5F_LIBVER_EARLIEST;
+
+ /* Set version bounds for opening file */
+ ret = H5Pset_libver_bounds(fapl, low, high);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
+ /* Open the file */
+ file = H5Fopen(VERBFNAME, H5F_ACC_RDONLY, fapl);
+ CHECK(file, FAIL, "H5Fopen");
+
+ /* Get the new file access property */
+ new_fapl = H5Fget_access_plist(file);
+ CHECK(new_fapl, FAIL, "H5Fget_access_plist");
+
+ /* Get new low bound and verify that it has been upgraded properly */
+ ret = H5Pget_libver_bounds(new_fapl, &new_low, NULL);
+ CHECK(ret, FAIL, "H5Pget_libver_bounds");
+ VERIFY(new_low, H5F_LIBVER_LATEST, "Low bound should be upgraded to H5F_LIBVER_LATEST");
+
+ ret = H5Pclose(new_fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Fclose(file);
+ CHECK(ret, FAIL, "H5Fclose");
+ } /* for low */
+
+ /* Close dataspace and property lists */
+ ret = H5Sclose(space);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Pclose(dcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+} /* end test_libver_bounds_open() */
+
+
/****************************************************************
**
** test_libver_bounds():
@@ -4970,6 +5098,7 @@ test_libver_bounds(void)
/* Run the tests */
test_libver_bounds_real(H5F_LIBVER_EARLIEST, 1, H5F_LIBVER_LATEST, 2);
test_libver_bounds_real(H5F_LIBVER_LATEST, 2, H5F_LIBVER_EARLIEST, 2);
+ test_libver_bounds_open();
} /* end test_libver_bounds() */
/**************************************************************************************
@@ -6249,6 +6378,7 @@ test_libver_bounds_datatype_check(hid_t fapl, hid_t tid)
* H5T_INTEGER, H5T_FLOAT, H5T_TIME, H5T_STRING, H5T_BITFIELD, H5T_OPAQUE, H5T_REFERENCE:
* --the library will only use basic version
*/
+
if(dtype->shared->type == H5T_COMPOUND ||
dtype->shared->type == H5T_ENUM ||
dtype->shared->type == H5T_ARRAY) {
diff --git a/test/th5o.c b/test/th5o.c
index 144ea4c..00d706c 100644
--- a/test/th5o.c
+++ b/test/th5o.c
@@ -774,7 +774,7 @@ test_h5o_link(void)
hid_t lcpl_id=-1;
hsize_t dims[2] = {TEST6_DIM1, TEST6_DIM2};
htri_t committed; /* Whether the named datatype is committed */
- unsigned new_format; /* Whether to use the new format or not */
+ H5F_libver_t low, high; /* File format bounds */
int *wdata;
int *rdata;
int i, n;
@@ -801,98 +801,103 @@ test_h5o_link(void)
ret = H5Pset_create_intermediate_group(lcpl_id, TRUE);
CHECK(ret, FAIL, "H5Pset_create_intermediate_group");
- /* Loop over using new group format */
- for(new_format = FALSE; new_format <= TRUE; new_format++) {
-
- /* Make a FAPL that uses the "use the latest version of the format" bounds */
- fapl_id = H5Pcreate(H5P_FILE_ACCESS);
- CHECK(fapl_id, FAIL, "H5Pcreate");
-
- /* Set the "use the latest version of the format" bounds for creating objects in the file */
- ret = H5Pset_libver_bounds(fapl_id, (new_format ? H5F_LIBVER_LATEST : H5F_LIBVER_EARLIEST), H5F_LIBVER_LATEST);
- CHECK(ret, FAIL, "H5Pset_libver_bounds");
-
- /* Create a new HDF5 file */
- file_id = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
- CHECK(file_id, FAIL, "H5Fcreate");
-
- /* Close the FAPL */
- ret = H5Pclose(fapl_id);
- CHECK(ret, FAIL, "H5Pclose");
-
-
- /* Create and commit a datatype with no name */
- type_id = H5Tcopy(H5T_NATIVE_INT);
- CHECK(type_id, FAIL, "H5Fcreate");
- ret = H5Tcommit_anon(file_id, type_id, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Tcommit_anon");
- committed = H5Tcommitted(type_id);
- VERIFY(committed, TRUE, "H5Tcommitted");
-
- /* Create a dataset with no name using the committed datatype*/
- dset_id = H5Dcreate_anon(file_id, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(dset_id, FAIL, "H5Dcreate_anon");
-
- /* Verify that we can write to and read from the dataset */
-
- /* Write the data to the dataset */
- ret = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
- CHECK(ret, FAIL, "H5Dwrite");
-
- /* Read the data back */
- ret = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
- CHECK(ret, FAIL, "H5Dread");
-
- /* Verify the data */
- for(i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++)
- VERIFY(wdata[i], rdata[i], "H5Dread");
-
- /* Create a group with no name*/
- group_id = H5Gcreate_anon(file_id, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(group_id, FAIL, "H5Gcreate_anon");
-
- /* Link nameless datatype into nameless group */
- ret = H5Olink(type_id, group_id, "datatype", H5P_DEFAULT, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Olink");
-
- /* Link nameless dataset into nameless group with intermediate group */
- ret = H5Olink(dset_id, group_id, "inter_group/dataset", lcpl_id, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Olink");
-
- /* Close IDs for dataset and datatype */
- ret = H5Dclose(dset_id);
- CHECK(ret, FAIL, "H5Dclose");
- ret = H5Tclose(type_id);
- CHECK(ret, FAIL, "H5Tclose");
-
- /* Re-open datatype using new link */
- type_id = H5Topen2(group_id, "datatype", H5P_DEFAULT);
- CHECK(type_id, FAIL, "H5Topen2");
-
- /* Link nameless group to root group and close the group ID*/
- ret = H5Olink(group_id, file_id, "/group", H5P_DEFAULT, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Olink");
- ret = H5Gclose(group_id);
- CHECK(ret, FAIL, "H5Gclose");
-
- /* Open dataset through root group and verify its data */
- dset_id = H5Dopen2(file_id, "/group/inter_group/dataset", H5P_DEFAULT);
- CHECK(dset_id, FAIL, "H5Dopen2");
-
- /* Read data from dataset */
- ret = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
- CHECK(ret, FAIL, "H5Dread");
- for(i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++)
- VERIFY(wdata[i], rdata[i], "H5Dread");
-
- /* Close open IDs */
- ret = H5Dclose(dset_id);
- CHECK(ret, FAIL, "H5Dclose");
- ret = H5Tclose(type_id);
- CHECK(ret, FAIL, "H5Tclose");
- ret = H5Fclose(file_id);
- CHECK(ret, FAIL, "H5Fclose");
- } /* end for */
+ /* Create a file access property list */
+ fapl_id = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl_id, FAIL, "H5Pcreate");
+
+ /* Loop through all the combinations of low/high library format bounds */
+ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) {
+ for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) {
+
+ /* Set version bounds */
+ H5E_BEGIN_TRY {
+ ret = H5Pset_libver_bounds(fapl_id, low, high);
+ } H5E_END_TRY;
+
+ if (ret < 0) /* Invalid low/high combinations */
+ continue;
+
+ /* Create a new HDF5 file */
+ file_id = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
+ CHECK(file_id, FAIL, "H5Fcreate");
+
+ /* Close the FAPL */
+ ret = H5Pclose(fapl_id);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* Create and commit a datatype with no name */
+ type_id = H5Tcopy(H5T_NATIVE_INT);
+ CHECK(type_id, FAIL, "H5Fcreate");
+ ret = H5Tcommit_anon(file_id, type_id, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Tcommit_anon");
+ committed = H5Tcommitted(type_id);
+ VERIFY(committed, TRUE, "H5Tcommitted");
+
+ /* Create a dataset with no name using the committed datatype*/
+ dset_id = H5Dcreate_anon(file_id, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(dset_id, FAIL, "H5Dcreate_anon");
+
+ /* Verify that we can write to and read from the dataset */
+
+ /* Write the data to the dataset */
+ ret = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Read the data back */
+ ret = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Verify the data */
+ for(i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++)
+ VERIFY(wdata[i], rdata[i], "H5Dread");
+
+ /* Create a group with no name*/
+ group_id = H5Gcreate_anon(file_id, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(group_id, FAIL, "H5Gcreate_anon");
+
+ /* Link nameless datatype into nameless group */
+ ret = H5Olink(type_id, group_id, "datatype", H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Olink");
+
+ /* Link nameless dataset into nameless group with intermediate group */
+ ret = H5Olink(dset_id, group_id, "inter_group/dataset", lcpl_id, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Olink");
+
+ /* Close IDs for dataset and datatype */
+ ret = H5Dclose(dset_id);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Tclose(type_id);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Re-open datatype using new link */
+ type_id = H5Topen2(group_id, "datatype", H5P_DEFAULT);
+ CHECK(type_id, FAIL, "H5Topen2");
+
+ /* Link nameless group to root group and close the group ID*/
+ ret = H5Olink(group_id, file_id, "/group", H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Olink");
+ ret = H5Gclose(group_id);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ /* Open dataset through root group and verify its data */
+ dset_id = H5Dopen2(file_id, "/group/inter_group/dataset", H5P_DEFAULT);
+ CHECK(dset_id, FAIL, "H5Dopen2");
+
+ /* Read data from dataset */
+ ret = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
+ CHECK(ret, FAIL, "H5Dread");
+ for(i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++)
+ VERIFY(wdata[i], rdata[i], "H5Dread");
+
+ /* Close open IDs */
+ ret = H5Dclose(dset_id);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Tclose(type_id);
+ CHECK(ret, FAIL, "H5Tclose");
+ ret = H5Fclose(file_id);
+ CHECK(ret, FAIL, "H5Fclose");
+ } /* for high */
+ } /* for low */
/* Close remaining IDs */
ret = H5Sclose(space_id);
diff --git a/test/th5s.c b/test/th5s.c
index c63320a..81ac2ac 100644
--- a/test/th5s.c
+++ b/test/th5s.c
@@ -19,9 +19,29 @@
*
*************************************************************/
+#include "hdf5.h"
#include "testhdf5.h"
#include "H5srcdir.h"
+#include "H5Bprivate.h"
+#include "H5Iprivate.h"
+#include "H5Pprivate.h"
+
+/*
+ * This file needs to access private information from the H5S package.
+ * This file also needs to access the dataspace testing code.
+ */
+#define H5S_FRIEND /*suppress error about including H5Spkg */
+#include "H5Spkg.h" /* Dataspaces */
+
+/*
+ * This file needs to access private information from the H5O package.
+ * This file also needs to access the dataspace testing code.
+ */
+#define H5O_FRIEND /*suppress error about including H5Opkg */
+#define H5O_TESTING
+#include "H5Opkg.h" /* Object header */
+
#include "H5private.h"
#include "H5Bprivate.h"
#include "H5Sprivate.h"
@@ -2364,6 +2384,133 @@ test_h5s_bug1(void)
CHECK(ret, FAIL, "H5Sclose");
} /* test_h5s_bug1() */
+
+/*-------------------------------------------------------------------------
+ * Function: test_versionbounds
+ *
+ * Purpose: Tests version bounds with dataspace.
+ *
+ * Description:
+ * This function creates a file with lower bounds then later
+ * reopens it with higher bounds to show that the dataspace
+ * version is upgraded appropriately.
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ *-------------------------------------------------------------------------
+ */
+#define VERBFNAME "tverbounds_dspace.h5"
+#define BASIC_DSET "Basic Dataset"
+#define LATEST_DSET "Latest Dataset"
+static void
+test_versionbounds(void)
+{
+ hid_t file = -1; /* File ID */
+ hid_t space = -1; /* Dataspace ID */
+ hid_t dset = -1; /* Dataset ID */
+ hid_t fapl = -1; /* File access property list ID */
+ hid_t dset_space = -1; /* Retrieved dataset's dataspace ID */
+ hsize_t dim[1]; /* Dataset dimensions */
+ H5F_libver_t low, high; /* File format bounds */
+ H5S_t *spacep = NULL; /* Pointer to internal dataspace */
+ herr_t ret = 0; /* Generic return value */
+hid_t sid = -1;
+H5S_t *spaceptr = NULL;
+
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Version Bounds\n"));
+
+ /* Create a file access property list */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Create dataspace */
+ dim[0] = 10;
+ space = H5Screate_simple(1, dim, NULL);
+ CHECK(space, FAIL, "H5Screate");
+
+ /* Its version should be H5O_SDSPACE_VERSION_1 */
+ spacep = (H5S_t *)H5I_object(space);
+ CHECK(spacep, NULL, "H5I_object");
+ VERIFY(spacep->extent.version, H5O_SDSPACE_VERSION_1, "basic dataspace version bound");
+
+ /* Set high bound to V18 */
+ low = H5F_LIBVER_EARLIEST;
+ high = H5F_LIBVER_V18;
+ ret = H5Pset_libver_bounds(fapl, low, high);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
+ /* Create the file */
+ file = H5Fcreate(VERBFNAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
+ CHECK(file, FAIL, "H5Fcreate");
+
+ /* Create a basic dataset */
+ dset = H5Dcreate2(file, BASIC_DSET, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ if (dset > 0) /* dataset created successfully */
+ {
+ /* Get the internal dataspace pointer */
+ dset_space = H5Dget_space(dset);
+ CHECK(dset_space, FAIL, "H5Dget_space");
+ spacep = (H5S_t *)H5I_object(dset_space);
+ CHECK(spacep, NULL, "H5I_object");
+
+ /* Dataspace version should remain as H5O_SDSPACE_VERSION_1 */
+ VERIFY(spacep->extent.version, H5O_SDSPACE_VERSION_1, "basic dataspace version bound");
+
+ /* Close dataspace */
+ ret = H5Sclose(dset_space);
+ CHECK(ret, FAIL, "H5Sclose");
+ }
+
+ /* Close basic dataset and the file */
+ ret = H5Dclose(dset);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Fclose(file);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Set low and high bounds to latest to trigger the increment of the
+ dataspace version */
+ low = H5F_LIBVER_LATEST;
+ high = H5F_LIBVER_LATEST;
+ ret = H5Pset_libver_bounds(fapl, low, high);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
+ /* Reopen the file with new version bounds, LATEST/LATEST */
+ file = H5Fopen(VERBFNAME, H5F_ACC_RDWR, fapl);
+
+ /* Create another dataset using the same dspace as the previous dataset */
+ dset = H5Dcreate2(file, LATEST_DSET, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(dset, FAIL, "H5Dcreate2");
+
+ /* Dataset created successfully. Verify that dataspace version has been
+ upgraded per the low bound */
+
+ /* Get the internal dataspace pointer */
+ dset_space = H5Dget_space(dset);
+ CHECK(dset_space, FAIL, "H5Dget_space");
+ spacep = (H5S_t *)H5I_object(dset_space);
+ CHECK(spacep, NULL, "H5I_object");
+
+ /* Verify the dataspace version */
+ VERIFY(spacep->extent.version, H5O_sdspace_ver_bounds[low], "upgraded dataspace version");
+
+ /* Close everything */
+ ret = H5Sclose(dset_space);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Dclose(dset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ ret = H5Sclose(space);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Fclose(file);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* end test_versionbounds() */
+
+
/****************************************************************
**
** test_h5s(): Main H5S (dataspace) testing routine.
@@ -2391,6 +2538,7 @@ test_h5s(void)
test_h5s_extent_equal(); /* Test extent comparison code */
test_h5s_extent_copy(); /* Test extent copy code */
test_h5s_bug1(); /* Test bug in offset initialization */
+ test_versionbounds(); /* Test version bounds with dataspace */
} /* test_h5s() */
@@ -2415,4 +2563,5 @@ cleanup_h5s(void)
remove(NULLFILE);
remove(BASICFILE);
remove(ZEROFILE);
+ remove(VERBFNAME);
}