summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2015-09-13 02:53:33 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2015-09-13 02:53:33 (GMT)
commit32e30e06a2554ab549bb61a10c9e4b023741bee3 (patch)
treef1b844c2e677246ee8fe2350580fb4727f56e5a9 /test
parentb3b06d2703eea051b0025c075f8c6742fcca1200 (diff)
downloadhdf5-32e30e06a2554ab549bb61a10c9e4b023741bee3.zip
hdf5-32e30e06a2554ab549bb61a10c9e4b023741bee3.tar.gz
hdf5-32e30e06a2554ab549bb61a10c9e4b023741bee3.tar.bz2
[svn-r27766] Merge of r27292 from trunk:
Bring 'fail if unknown always' object header message flag from the avoid_truncate branch, strengthen error checking for unknown messages, and try to catch object header code configurations at compile time (instead of runtime). Tested on: koala
Diffstat (limited to 'test')
-rw-r--r--test/gen_bogus.c14
-rw-r--r--test/ohdr.c42
-rw-r--r--test/tbogus.h5bin1944 -> 2216 bytes
3 files changed, 47 insertions, 9 deletions
diff --git a/test/gen_bogus.c b/test/gen_bogus.c
index df1e81f..e9ce686 100644
--- a/test/gen_bogus.c
+++ b/test/gen_bogus.c
@@ -61,7 +61,7 @@ int main(void)
if((did = H5Dcreate2(fid, "/Dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error;
if(H5Dclose(did) < 0) goto error;
- /* Set "fail if unknown" message flag for bogus message */
+ /* Set "fail if unknown and open for write" message flag for bogus message */
bogus_flags = H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE;
if(H5Pset(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) goto error;
@@ -69,12 +69,20 @@ int main(void)
if((did = H5Dcreate2(fid, "/Dataset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error;
if(H5Dclose(did) < 0) goto error;
+ /* Set "fail if unknown always" message flag for bogus message */
+ bogus_flags = H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS;
+ if(H5Pset(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) goto error;
+
+ /* Create third dataset, with "fail if unknown always" message flag */
+ if((did = H5Dcreate2(fid, "/Dataset3", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error;
+ if(H5Dclose(did) < 0) goto error;
+
/* Set "mark if unknown" message flag for bogus message */
bogus_flags = H5O_MSG_FLAG_MARK_IF_UNKNOWN;
if(H5Pset(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) goto error;
- /* Create second dataset, with "mark if unknown" message flag */
- if((did = H5Dcreate2(fid, "/Dataset3", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error;
+ /* Create fourth dataset, with "mark if unknown" message flag */
+ if((did = H5Dcreate2(fid, "/Dataset4", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error;
if(H5Dclose(did) < 0) goto error;
/* Close dataset creation property list */
diff --git a/test/ohdr.c b/test/ohdr.c
index ecc692b..8d1c6ad 100644
--- a/test/ohdr.c
+++ b/test/ohdr.c
@@ -793,7 +793,9 @@ main(void)
PASSED();
- /* Test reading datasets with undefined object header messages */
+ /* Test reading datasets with undefined object header messages
+ * and the various "fail/mark if unknown" object header message flags
+ */
HDputs("Accessing objects with unknown header messages:");
{
hid_t file2; /* File ID for 'bogus' object file */
@@ -815,7 +817,7 @@ main(void)
PASSED();
- TESTING("object with unknown header message & 'fail if unknown and open for write' flag set");
+ TESTING("object in r/o file with unknown header message & 'fail if unknown and open for write' flag set");
/* Open the dataset with the unknown header message, and "fail if unknown and open for write" flag */
if((dset = H5Dopen2(file2, "/Dataset2", H5P_DEFAULT)) < 0)
@@ -825,10 +827,23 @@ main(void)
PASSED();
+ TESTING("object in r/o file with unknown header message & 'fail if unknown always' flag set");
+
+ /* Attempt to open the dataset with the unknown header message, and "fail if unknown always" flag */
+ H5E_BEGIN_TRY {
+ dset = H5Dopen2(file2, "/Dataset3", H5P_DEFAULT);
+ } H5E_END_TRY;
+ if(dset >= 0) {
+ H5Dclose(dset);
+ TEST_ERROR
+ } /* end if */
+
+ PASSED();
+
TESTING("object with unknown header message & 'mark if unknown' flag set");
/* Copy object with "mark if unknown" flag on message into file that can be modified */
- if(H5Ocopy(file2, "/Dataset3", file, "/Dataset3", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ if(H5Ocopy(file2, "/Dataset4", file, "/Dataset4", H5P_DEFAULT, H5P_DEFAULT) < 0)
TEST_ERROR
/* Close the file we created (to flush changes to file) */
@@ -840,7 +855,7 @@ main(void)
TEST_ERROR
/* Open the dataset with the "mark if unknown" message */
- if((dset = H5Dopen2(file, "/Dataset3", H5P_DEFAULT)) < 0)
+ if((dset = H5Dopen2(file, "/Dataset4", H5P_DEFAULT)) < 0)
TEST_ERROR
/* Check that the "unknown" message was _NOT_ marked */
@@ -860,7 +875,7 @@ main(void)
TEST_ERROR
/* Open the dataset with the "mark if unknown" message */
- if((dset = H5Dopen2(file, "/Dataset3", H5P_DEFAULT)) < 0)
+ if((dset = H5Dopen2(file, "/Dataset4", H5P_DEFAULT)) < 0)
TEST_ERROR
/* Create data space */
@@ -892,7 +907,7 @@ main(void)
TEST_ERROR
/* Re-open the dataset with the "mark if unknown" message */
- if((dset = H5Dopen2(file, "/Dataset3", H5P_DEFAULT)) < 0)
+ if((dset = H5Dopen2(file, "/Dataset4", H5P_DEFAULT)) < 0)
TEST_ERROR
/* Check that the "unknown" message was marked */
@@ -915,6 +930,8 @@ main(void)
if((file2 = H5Fopen(testfile, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
TEST_ERROR
+ TESTING("object in r/w file with unknown header message & 'fail if unknown and open for write' flag set");
+
/* Attempt to open the dataset with the unknown header message, and "fail if unknown and open for write" flag */
H5E_BEGIN_TRY {
dset = H5Dopen2(file2, "/Dataset2", H5P_DEFAULT);
@@ -924,6 +941,19 @@ main(void)
TEST_ERROR
} /* end if */
+ PASSED();
+
+ TESTING("object in r/w file with unknown header message & 'fail if unknown always' flag set");
+
+ /* Attempt to open the dataset with the unknown header message, and "fail if unknown always" flag */
+ H5E_BEGIN_TRY {
+ dset = H5Dopen2(file2, "/Dataset3", H5P_DEFAULT);
+ } H5E_END_TRY;
+ if(dset >= 0) {
+ H5Dclose(dset);
+ TEST_ERROR
+ } /* end if */
+
/* Close the file with the bogus objects */
if(H5Fclose(file2) < 0)
TEST_ERROR
diff --git a/test/tbogus.h5 b/test/tbogus.h5
index 906921c..875fbd8 100644
--- a/test/tbogus.h5
+++ b/test/tbogus.h5
Binary files differ