summaryrefslogtreecommitdiffstats
path: root/test/trefer.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/trefer.c')
-rw-r--r--test/trefer.c238
1 files changed, 146 insertions, 92 deletions
diff --git a/test/trefer.c b/test/trefer.c
index 4f76cb3..4bf9caf 100644
--- a/test/trefer.c
+++ b/test/trefer.c
@@ -490,43 +490,48 @@ test_reference_obj(void)
** test_reference_region(): Test basic H5R (reference) object reference code.
** Tests references to various kinds of objects
**
+** Note: The libver_low/libver_high parameters are added to create the file
+** with the low and high bounds setting in fapl.
+** Please see the RFC for "H5Sencode/H5Sdecode Format Change".
+**
****************************************************************/
static void
-test_reference_region(void)
+test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high)
{
- hid_t fid1; /* HDF5 File IDs */
- hid_t dset1, /* Dataset ID */
- dset2; /* Dereferenced dataset ID */
- hid_t sid1, /* Dataspace ID #1 */
- sid2; /* Dataspace ID #2 */
- hid_t dapl_id; /* Dataset access property list */
- hsize_t dims1[] = {SPACE1_DIM1},
- dims2[] = {SPACE2_DIM1, SPACE2_DIM2};
- hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */
- hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */
- hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */
- hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */
- hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */
- hsize_t * coords; /* Coordinate buffer */
- hsize_t low[SPACE2_RANK]; /* Selection bounds */
- hsize_t high[SPACE2_RANK]; /* Selection bounds */
- hdset_reg_ref_t *wbuf, /* buffer to write to disk */
- *rbuf; /* buffer read from disk */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t fapl = -1; /* File access property list */
+ hid_t dset1, /* Dataset ID */
+ dset2; /* Dereferenced dataset ID */
+ hid_t sid1, /* Dataspace ID #1 */
+ sid2; /* Dataspace ID #2 */
+ hid_t dapl_id; /* Dataset access property list */
+ hsize_t dims1[] = {SPACE1_DIM1},
+ dims2[] = {SPACE2_DIM1, SPACE2_DIM2};
+ hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */
+ hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */
+ hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */
+ hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */
+ hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */
+ hsize_t *coords; /* Coordinate buffer */
+ hsize_t low[SPACE2_RANK]; /* Selection bounds */
+ hsize_t high[SPACE2_RANK]; /* Selection bounds */
+ hdset_reg_ref_t *wbuf, /* buffer to write to disk */
+ *rbuf; /* buffer read from disk */
hdset_reg_ref_t nvrbuf[3]={{0},{101},{255}}; /* buffer with non-valid refs */
- uint8_t *dwbuf, /* Buffer for writing numeric data to disk */
- *drbuf; /* Buffer for reading numeric data from disk */
- uint8_t *tu8; /* Temporary pointer to uint8 data */
- H5O_type_t obj_type; /* Type of object */
- int i, j; /* counting variables */
- hssize_t hssize_ret; /* hssize_t return value */
- htri_t tri_ret; /* htri_t return value */
- herr_t ret; /* Generic return value */
- haddr_t addr = HADDR_UNDEF; /* test for undefined reference */
- hid_t dset_NA; /* Dataset id for undefined reference */
- hid_t space_NA; /* Dataspace id for undefined reference */
- hsize_t dims_NA[1] = {1}; /* Dims array for undefined reference */
- hdset_reg_ref_t wdata_NA[1], /* Write buffer */
- rdata_NA[1]; /* Read buffer */
+ uint8_t *dwbuf, /* Buffer for writing numeric data to disk */
+ *drbuf; /* Buffer for reading numeric data from disk */
+ uint8_t *tu8; /* Temporary pointer to uint8 data */
+ H5O_type_t obj_type; /* Type of object */
+ int i, j; /* counting variables */
+ hssize_t hssize_ret; /* hssize_t return value */
+ htri_t tri_ret; /* htri_t return value */
+ herr_t ret; /* Generic return value */
+ haddr_t addr = HADDR_UNDEF; /* test for undefined reference */
+ hid_t dset_NA; /* Dataset id for undefined reference */
+ hid_t space_NA; /* Dataspace id for undefined reference */
+ hsize_t dims_NA[1] = {1}; /* Dims array for undefined reference */
+ hdset_reg_ref_t wdata_NA[1], /* Write buffer */
+ rdata_NA[1]; /* Read buffer */
/* Output message about test being performed */
MESSAGE(5, ("Testing Dataset Region Reference Functions\n"));
@@ -537,8 +542,16 @@ test_reference_region(void)
dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2);
drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2));
- /* Create file */
- fid1 = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ /* Create file access property list */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Set the low/high version bounds in fapl */
+ ret = H5Pset_libver_bounds(fapl, libver_low, libver_high);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
+ /* Create file with the fapl */
+ fid1 = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
CHECK(fid1, FAIL, "H5Fcreate");
/* Create dataspace for datasets */
@@ -625,8 +638,15 @@ test_reference_region(void)
VERIFY(hssize_ret, (hssize_t)H5S_UNLIMITED, "H5Sget_select_npoints");
/* Store third dataset region */
- ret = H5Rcreate(&wbuf[2], fid1, "/Dataset2", H5R_DATASET_REGION, sid2);
- CHECK(ret, FAIL, "H5Rcreate");
+ H5E_BEGIN_TRY {
+ ret = H5Rcreate(&wbuf[2], fid1, "/Dataset2", H5R_DATASET_REGION, sid2);
+ } H5E_END_TRY;
+
+ if(libver_high < H5F_LIBVER_V110)
+ VERIFY(ret, FAIL, "H5Rcreate");
+ else
+ CHECK(ret, FAIL, "H5Rcreate");
+
ret = H5Rget_obj_type2(dset1, H5R_DATASET_REGION, &wbuf[0], &obj_type);
CHECK(ret, FAIL, "H5Rget_obj_type2");
VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type2");
@@ -677,7 +697,7 @@ test_reference_region(void)
CHECK(ret, FAIL, "H5Fclose");
/* Re-open the file */
- fid1 = H5Fopen(FILE2, H5F_ACC_RDWR, H5P_DEFAULT);
+ fid1 = H5Fopen(FILE2, H5F_ACC_RDWR, fapl);
CHECK(fid1, FAIL, "H5Fopen");
/*
@@ -822,30 +842,32 @@ test_reference_region(void)
ret = H5Sclose(sid2);
CHECK(ret, FAIL, "H5Sclose");
- /* Get the unlimited selection */
- sid2 = H5Rget_region(dset1, H5R_DATASET_REGION, &rbuf[2]);
- CHECK(sid2, FAIL, "H5Rget_region");
-
- /* Verify correct hyperslab selected */
- hssize_ret = H5Sget_select_npoints(sid2);
- VERIFY(hssize_ret, (hssize_t)H5S_UNLIMITED, "H5Sget_select_npoints");
- tri_ret = H5Sis_regular_hyperslab(sid2);
- CHECK(tri_ret, FAIL, "H5Sis_regular_hyperslab");
- VERIFY(tri_ret, TRUE, "H5Sis_regular_hyperslab Result");
- ret = H5Sget_regular_hyperslab(sid2, start, stride, count, block);
- CHECK(ret, FAIL, "H5Sget_regular_hyperslab");
- VERIFY(start[0], (hsize_t)1, "Hyperslab Coordinates");
- VERIFY(start[1], (hsize_t)8, "Hyperslab Coordinates");
- VERIFY(stride[0], (hsize_t)4, "Hyperslab Coordinates");
- VERIFY(stride[1], (hsize_t)1, "Hyperslab Coordinates");
- VERIFY(count[0], H5S_UNLIMITED, "Hyperslab Coordinates");
- VERIFY(count[1], (hsize_t)1, "Hyperslab Coordinates");
- VERIFY(block[0], (hsize_t)2, "Hyperslab Coordinates");
- VERIFY(block[1], (hsize_t)2, "Hyperslab Coordinates");
-
- /* Close region space */
- ret = H5Sclose(sid2);
- CHECK(ret, FAIL, "H5Sclose");
+ if(libver_high >= H5F_LIBVER_V110) {
+ /* Get the unlimited selection */
+ sid2 = H5Rget_region(dset1, H5R_DATASET_REGION, &rbuf[2]);
+ CHECK(sid2, FAIL, "H5Rget_region");
+
+ /* Verify correct hyperslab selected */
+ hssize_ret = H5Sget_select_npoints(sid2);
+ VERIFY(hssize_ret, (hssize_t)H5S_UNLIMITED, "H5Sget_select_npoints");
+ tri_ret = H5Sis_regular_hyperslab(sid2);
+ CHECK(tri_ret, FAIL, "H5Sis_regular_hyperslab");
+ VERIFY(tri_ret, TRUE, "H5Sis_regular_hyperslab Result");
+ ret = H5Sget_regular_hyperslab(sid2, start, stride, count, block);
+ CHECK(ret, FAIL, "H5Sget_regular_hyperslab");
+ VERIFY(start[0], (hsize_t)1, "Hyperslab Coordinates");
+ VERIFY(start[1], (hsize_t)8, "Hyperslab Coordinates");
+ VERIFY(stride[0], (hsize_t)4, "Hyperslab Coordinates");
+ VERIFY(stride[1], (hsize_t)1, "Hyperslab Coordinates");
+ VERIFY(count[0], H5S_UNLIMITED, "Hyperslab Coordinates");
+ VERIFY(count[1], (hsize_t)1, "Hyperslab Coordinates");
+ VERIFY(block[0], (hsize_t)2, "Hyperslab Coordinates");
+ VERIFY(block[1], (hsize_t)2, "Hyperslab Coordinates");
+
+ /* Close region space */
+ ret = H5Sclose(sid2);
+ CHECK(ret, FAIL, "H5Sclose");
+ }
/* Close first space */
ret = H5Sclose(sid1);
@@ -887,34 +909,39 @@ test_reference_region(void)
** test_reference_region_1D(): Test H5R (reference) object reference code.
** Tests 1-D references to various kinds of objects
**
+** Note: The libver_low/libver_high parameters are added to create the file
+** with the low and high bounds setting in fapl.
+** Please see the RFC for "H5Sencode/H5Sdecode Format Change".
+**
****************************************************************/
static void
-test_reference_region_1D(void)
+test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high)
{
- hid_t fid1; /* HDF5 File IDs */
- hid_t dset1, /* Dataset ID */
- dset3; /* Dereferenced dataset ID */
- hid_t sid1, /* Dataspace ID #1 */
- sid3; /* Dataspace ID #3 */
- hid_t dapl_id; /* Dataset access property list */
- hsize_t dims1[] = {SPACE1_DIM1},
- dims3[] = {SPACE3_DIM1};
- hsize_t start[SPACE3_RANK]; /* Starting location of hyperslab */
- hsize_t stride[SPACE3_RANK]; /* Stride of hyperslab */
- hsize_t count[SPACE3_RANK]; /* Element count of hyperslab */
- hsize_t block[SPACE3_RANK]; /* Block size of hyperslab */
- hsize_t coord1[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */
- hsize_t * coords; /* Coordinate buffer */
- hsize_t low[SPACE3_RANK]; /* Selection bounds */
- hsize_t high[SPACE3_RANK]; /* Selection bounds */
- hdset_reg_ref_t *wbuf, /* buffer to write to disk */
- *rbuf; /* buffer read from disk */
- uint8_t *dwbuf, /* Buffer for writing numeric data to disk */
- *drbuf; /* Buffer for reading numeric data from disk */
- uint8_t *tu8; /* Temporary pointer to uint8 data */
- H5O_type_t obj_type; /* Object type */
- int i; /* counting variables */
- herr_t ret; /* Generic return value */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t fapl = -1; /* File access property list */
+ hid_t dset1, /* Dataset ID */
+ dset3; /* Dereferenced dataset ID */
+ hid_t sid1, /* Dataspace ID #1 */
+ sid3; /* Dataspace ID #3 */
+ hid_t dapl_id; /* Dataset access property list */
+ hsize_t dims1[] = {SPACE1_DIM1},
+ dims3[] = {SPACE3_DIM1};
+ hsize_t start[SPACE3_RANK]; /* Starting location of hyperslab */
+ hsize_t stride[SPACE3_RANK]; /* Stride of hyperslab */
+ hsize_t count[SPACE3_RANK]; /* Element count of hyperslab */
+ hsize_t block[SPACE3_RANK]; /* Block size of hyperslab */
+ hsize_t coord1[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */
+ hsize_t *coords; /* Coordinate buffer */
+ hsize_t low[SPACE3_RANK]; /* Selection bounds */
+ hsize_t high[SPACE3_RANK]; /* Selection bounds */
+ hdset_reg_ref_t *wbuf, /* buffer to write to disk */
+ *rbuf; /* buffer read from disk */
+ uint8_t *dwbuf, /* Buffer for writing numeric data to disk */
+ *drbuf; /* Buffer for reading numeric data from disk */
+ uint8_t *tu8; /* Temporary pointer to uint8 data */
+ H5O_type_t obj_type; /* Object type */
+ int i; /* counting variables */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing 1-D Dataset Region Reference Functions\n"));
@@ -925,8 +952,16 @@ test_reference_region_1D(void)
dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE3_DIM1);
drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)SPACE3_DIM1);
- /* Create file */
- fid1 = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ /* Create the file access property list */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Set the low/high version bounds in fapl */
+ ret = H5Pset_libver_bounds(fapl, libver_low, libver_high);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
+ /* Create file with the fapl */
+ fid1 = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
CHECK(fid1, FAIL, "H5Fcreate");
/* Create dataspace for datasets */
@@ -1022,7 +1057,7 @@ test_reference_region_1D(void)
CHECK(ret, FAIL, "H5Fclose");
/* Re-open the file */
- fid1 = H5Fopen(FILE2, H5F_ACC_RDWR, H5P_DEFAULT);
+ fid1 = H5Fopen(FILE2, H5F_ACC_RDWR, fapl);
CHECK(fid1, FAIL, "H5Fopen");
/* Open the dataset */
@@ -1156,6 +1191,10 @@ test_reference_region_1D(void)
ret = H5Pclose(dapl_id);
CHECK(ret, FAIL, "H5Pclose");
+ /* Close file access property list */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
/* Close file */
ret = H5Fclose(fid1);
CHECK(ret, FAIL, "H5Fclose");
@@ -1733,13 +1772,28 @@ test_reference_compat(void)
void
test_reference(void)
{
+ H5F_libver_t low, high; /* Low and high bounds */
+
/* Output message about test being performed */
MESSAGE(5, ("Testing References\n"));
test_reference_params(); /* Test for correct parameter checking */
test_reference_obj(); /* Test basic H5R object reference code */
- test_reference_region(); /* Test basic H5R dataset region reference code */
- test_reference_region_1D(); /* Test H5R dataset region reference code for 1-D datasets */
+
+ /* Loop through all the combinations of low/high version bounds */
+ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) {
+ for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) {
+
+ /* Invalid combinations, just continue */
+ if(high == H5F_LIBVER_EARLIEST || high < low)
+ continue;
+
+ test_reference_region(low, high); /* Test basic H5R dataset region reference code */
+ test_reference_region_1D(low, high); /* Test H5R dataset region reference code for 1-D datasets */
+
+ } /* end high bound */
+ } /* end low bound */
+
test_reference_obj_deleted(); /* Test H5R object reference code for deleted objects */
test_reference_group(); /* Test operations on dereferenced groups */
#ifndef H5_NO_DEPRECATED_SYMBOLS