summaryrefslogtreecommitdiffstats
path: root/test/gen_bogus.c
diff options
context:
space:
mode:
authorVailin Choi <vchoi@jam.ad.hdfgroup.org>2017-03-07 15:59:39 (GMT)
committerVailin Choi <vchoi@jam.ad.hdfgroup.org>2017-03-07 15:59:39 (GMT)
commitd5fea5b80a2ccc21fb4f187d0efeda80b9134156 (patch)
tree8cc95b236a40ce0567887d189bc077136cf0e2e6 /test/gen_bogus.c
parent503ab9d88d6fb4b0866cb8bb77ee1df68dd735c1 (diff)
downloadhdf5-d5fea5b80a2ccc21fb4f187d0efeda80b9134156.zip
hdf5-d5fea5b80a2ccc21fb4f187d0efeda80b9134156.tar.gz
hdf5-d5fea5b80a2ccc21fb4f187d0efeda80b9134156.tar.bz2
Bring fix for HDFFV-9697 from develop branch.
Populate the fix for HDFFV-9697: Fix for unknown message from develop branch. Tested on ostrich, platypus, kite, quail, osx1010test, emu, mayll, moohan, kituo.
Diffstat (limited to 'test/gen_bogus.c')
-rw-r--r--test/gen_bogus.c72
1 files changed, 57 insertions, 15 deletions
diff --git a/test/gen_bogus.c b/test/gen_bogus.c
index df1e81f..290ec08 100644
--- a/test/gen_bogus.c
+++ b/test/gen_bogus.c
@@ -36,18 +36,21 @@
#define FALSE 0
#endif /* FALSE */
-int main(void)
-{
#ifdef H5O_ENABLE_BOGUS
- hid_t fid = -1; /* File ID */
+
+/*
+ * Create datasets in the location (in "/" or "/group") with
+ * message id: (a) H5O_BOGUS_VALID_ID or (b)H5O_BOGUS_INVALID_ID
+ * and various unknown message flags
+ */
+static int
+generate_datasets(hid_t loc_id, unsigned bogus_id)
+{
hid_t sid = -1; /* Dataspace ID */
hid_t dcpl = -1; /* Dataset creation property list ID */
hid_t did = -1; /* Dataset ID */
uint8_t bogus_flags = 0; /* Flags for bogus message */
- /* Create file for test datasets */
- if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error;
-
/* Create dataspace for datasets */
if((sid = H5Screate(H5S_SCALAR)) < 0) goto error;
@@ -57,24 +60,30 @@ int main(void)
/* Add property for bogus message flags */
if(H5Pinsert2(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, H5O_BOGUS_MSG_FLAGS_SIZE, &bogus_flags, NULL, NULL, NULL, NULL, NULL, NULL) < 0) goto error;
+ /* Add property for bogus message ID */
+ if(H5Pinsert2(dcpl, H5O_BOGUS_MSG_ID_NAME, H5O_BOGUS_MSG_ID_SIZE, &bogus_id, NULL, NULL, NULL, NULL, NULL, NULL) < 0) goto error;
+
/* Create dataset with "bogus" message, but no message flags */
- if((did = H5Dcreate2(fid, "/Dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error;
+ if((did = H5Dcreate2(loc_id, "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;
/* Create second dataset, with "fail if unknown" message flag */
- if((did = H5Dcreate2(fid, "/Dataset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error;
+ if((did = H5Dcreate2(loc_id, "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 */
+ /* There is no H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS, skip creating "Dataset3" */
+
/* 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(loc_id, "Dataset4", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error;
if(H5Dclose(did) < 0) goto error;
/* Close dataset creation property list */
@@ -83,9 +92,6 @@ int main(void)
/* Close dataspace */
if(H5Sclose(sid) < 0) goto error;
- /* Close file */
- if(H5Fclose(fid) < 0) goto error;
-
return 0;
error:
@@ -93,6 +99,43 @@ error:
H5Dclose(did);
H5Sclose(sid);
H5Pclose(dcpl);
+ } H5E_END_TRY;
+
+ return -1;
+} /* generate_datasets() */
+#endif
+
+int main(void)
+{
+#ifdef H5O_ENABLE_BOGUS
+ hid_t fid = -1; /* File ID */
+ hid_t gid = -1; /* Group ID */
+
+ /* Create file for test datasets */
+ if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error;
+
+ /* Create datasets in "/" group with bogus message H5O_BOGUS_VALID_ID */
+ if(generate_datasets(fid, H5O_BOGUS_VALID_ID) < 0)
+ goto error;
+
+ if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+
+ /* Create datasets in "/group" with bogus message H5O_BOGUS_INVALID_ID */
+ if(generate_datasets(gid, H5O_BOGUS_INVALID_ID) < 0)
+ goto error;
+
+ /* Close the group */
+ if(H5Gclose(gid) < 0) goto error;
+
+ /* Close file */
+ if(H5Fclose(fid) < 0) goto error;
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Gclose(gid);
H5Fclose(fid);
} H5E_END_TRY;
#else /* H5O_ENABLE_BOGUS */
@@ -100,4 +143,3 @@ error:
#endif /* H5O_ENABLE_BOGUS */
return 1;
}
-