summaryrefslogtreecommitdiffstats
path: root/src/H5Otest.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-05-01 21:00:52 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-05-01 21:00:52 (GMT)
commit2757f75317a07422c9a1d0378f969c3eb802c3a0 (patch)
tree6374d38220529efef51cbeead15f906e1782ebbd /src/H5Otest.c
parent4e243fd5e741fbdeaf92a484d52dbae4b0008268 (diff)
downloadhdf5-2757f75317a07422c9a1d0378f969c3eb802c3a0.zip
hdf5-2757f75317a07422c9a1d0378f969c3eb802c3a0.tar.gz
hdf5-2757f75317a07422c9a1d0378f969c3eb802c3a0.tar.bz2
[svn-r13721] Description:
Add "fail if unknown" and "mark if unknown" flags to object header messages. This gives the library a clean way to tell older libraries that a message should not be just ignored if it's unknown, but that other actions should occur. Tested on: Mac OS X/32 10.4.9 (amazon) FreeBSD/32 6.2 (duty) FreeBSD/64 6.2 (liberty) Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
Diffstat (limited to 'src/H5Otest.c')
-rw-r--r--src/H5Otest.c65
1 files changed, 64 insertions, 1 deletions
diff --git a/src/H5Otest.c b/src/H5Otest.c
index 41c79ef..359c312 100644
--- a/src/H5Otest.c
+++ b/src/H5Otest.c
@@ -16,7 +16,7 @@
/* Programmer: Quincey Koziol <koziol@hdfgroup.org>
* Monday, December 4, 2006
*
- * Purpose: Attribute testing functions.
+ * Purpose: Object header testing functions.
*/
/****************/
@@ -357,3 +357,66 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5O_attr_dense_info_test() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5O_check_msg_marked_test
+ PURPOSE
+ Check if an unknown message with the "mark if unknown" flag actually gets
+ marked.
+ USAGE
+ herr_t H5O_check_msg_marked_test(oid, flag_val)
+ hid_t oid; IN: Object to check
+ hbool_t flag_val; IN: Desired flag value
+ RETURNS
+ Non-negative on success, negative on failure
+ DESCRIPTION
+ Locates the "unknown" message and checks that the "was unknown" flag is set
+ correctly.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5O_check_msg_marked_test(hid_t oid, hbool_t flag_val)
+{
+ H5O_t *oh = NULL; /* Object header */
+ H5O_loc_t *oloc; /* Pointer to object's location */
+ H5O_mesg_t *idx_msg; /* Pointer to message */
+ unsigned idx; /* Index of message */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5O_check_msg_marked_test, FAIL)
+
+ /* Get object location for object */
+ if(NULL == (oloc = H5O_get_loc(oid)))
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found")
+
+ /* Get the object header */
+ if(NULL == (oh = H5AC_protect(oloc->file, H5AC_ind_dxpl_id, H5AC_OHDR, oloc->addr, NULL, NULL, H5AC_READ)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header")
+
+ /* Locate "unknown" message */
+ for(idx = 0, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++)
+ if(idx_msg->type->id == H5O_UNKNOWN_ID) {
+ /* Check for "unknown" message having the correct flags */
+ if(((idx_msg->flags & H5O_MSG_FLAG_WAS_UNKNOWN) > 0) != flag_val)
+ HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "'unknown' message has incorrect 'was unknown' flag value")
+
+ /* Break out of loop, to indicate that the "unknown" message was found */
+ break;
+ } /* end if */
+
+ /* Check for not finding an "unknown" message */
+ if(idx == oh->nmesgs)
+ HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "'unknown' message type not found")
+
+done:
+ if(oh && H5AC_unprotect(oloc->file, H5AC_ind_dxpl_id, H5AC_OHDR, oloc->addr, oh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5O_check_msg_marked_test() */
+