diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2003-09-24 19:26:50 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2003-09-24 19:26:50 (GMT) |
commit | 7e79a8d71e6a579710e0fc2c677dfc32336d058f (patch) | |
tree | d9b4f93046b8c2930fd35b3ec75953eccf1c1a47 | |
parent | 52f3545bde417a7eaeb996bfc97b58ab32075c73 (diff) | |
download | hdf5-7e79a8d71e6a579710e0fc2c677dfc32336d058f.zip hdf5-7e79a8d71e6a579710e0fc2c677dfc32336d058f.tar.gz hdf5-7e79a8d71e6a579710e0fc2c677dfc32336d058f.tar.bz2 |
[svn-r7507] *** empty log message ***
-rw-r--r-- | perform/overhead.c | 11 | ||||
-rw-r--r-- | release_docs/RELEASE.txt | 2 | ||||
-rw-r--r-- | src/H5.c | 4 | ||||
-rw-r--r-- | src/H5E.c | 392 | ||||
-rw-r--r-- | src/H5Epublic.h | 65 | ||||
-rw-r--r-- | src/H5FDmulti.c | 104 | ||||
-rw-r--r-- | src/H5FDstdio.c | 50 | ||||
-rw-r--r-- | test/Dependencies | 4 | ||||
-rw-r--r-- | test/Makefile.in | 26 | ||||
-rw-r--r-- | test/dtypes.c | 2 | ||||
-rw-r--r-- | test/enum.c | 5 | ||||
-rw-r--r-- | test/err_compat.c | 295 | ||||
-rw-r--r-- | test/error_test.c (renamed from test/errors.c) | 14 | ||||
-rw-r--r-- | test/gheap.c | 42 | ||||
-rw-r--r-- | test/h5test.c | 9 | ||||
-rw-r--r-- | test/lheap.c | 32 | ||||
-rw-r--r-- | test/ohdr.c | 90 | ||||
-rw-r--r-- | test/testfiles/err_compat_1 | 20 | ||||
-rw-r--r-- | test/testfiles/err_compat_2 | 4 | ||||
-rw-r--r-- | test/testfiles/error_test_1 | 31 | ||||
-rw-r--r-- | test/testfiles/error_test_2 | 4 | ||||
-rw-r--r-- | test/testhdf5.c | 4 | ||||
-rw-r--r-- | test/testhdf5.h | 77 | ||||
-rw-r--r-- | tools/h5dump/h5dump.c | 9 | ||||
-rw-r--r-- | tools/h5ls/h5ls.c | 4 |
25 files changed, 1250 insertions, 50 deletions
diff --git a/perform/overhead.c b/perform/overhead.c index 72d65c7..efedb4c 100644 --- a/perform/overhead.c +++ b/perform/overhead.c @@ -165,7 +165,12 @@ static herr_t display_error_cb (hid_t estack, void UNUSED *client_data) { puts ("*FAILED*"); - H5Eprint (estack, stdout); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else + H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ + return 0; } @@ -370,7 +375,11 @@ main(int argc, char *argv[]) int i, j, nerrors=0; /* Default split ratios */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eset_auto(display_error_cb, NULL); +#else H5Eset_auto(H5E_DEFAULT, display_error_cb, NULL); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if ((xfer=H5Pcreate(H5P_DATASET_XFER))<0) goto error; if (H5Pget_btree_ratios(xfer, splits+0, splits+1, splits+2)<0) { goto error; diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 38406d9..30dfc9b 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -41,6 +41,8 @@ New Features Library: -------- + - Added backward compatbility with v1.6 for new Error API. SLU - + 2003/09/24 - Changed 'objno' field in H5G_stat_t structure from 'unsigned long[2]' to 'haddr_t'. QAK - 2003/08/08 - Changed 'fileno' field in H5G_stat_t structure from 'unsigned long[2]' @@ -196,7 +196,11 @@ H5_term_library(void) goto done; /* Check if we should display error output */ +#ifdef H5_WANT_H5_V1_6_COMPAT + (void)H5Eget_auto(&func,NULL); +#else (void)H5Eget_auto(H5E_DEFAULT,&func,NULL); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* * Terminate each interface. The termination functions return a positive @@ -735,6 +735,108 @@ done: FUNC_LEAVE_NOAPI(ret_value) } +#ifdef H5_WANT_H5_V1_6_COMPAT + +/*------------------------------------------------------------------------- + * Function: H5Eget_major + * + * Purpose: Retrieves a major error message. + * + * Return: Returns message if succeeds. + * otherwise returns NULL. + * + * Programmer: Raymond Lu + * Friday, July 14, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +const char * +H5Eget_major(H5E_major_t maj) +{ + H5E_msg_t *msg; /* Pointer to error message */ + ssize_t size = 0; /* Return value */ + H5E_type_t type; + char *msg_str; + char *ret_value = NULL; + + FUNC_ENTER_API_NOINIT(H5Eget_major) + + /* Get the message object */ + if((msg = H5I_object_verify(maj, H5I_ERROR_MSG))==NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a error message ID") + + /* Get the message's text */ + if((size = H5E_get_msg(msg, &type, NULL, 0))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text"); + + if(type != H5E_MAJOR) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "Error message isn't a major one"); + + /* Don't know who is going to free it */ + msg_str = (char*)HDmalloc((++size)*sizeof(char)); + + if(H5E_get_msg(msg, NULL, msg_str, size)<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") + + ret_value = msg_str; + +done: + FUNC_LEAVE_API(ret_value) +} + + +/*------------------------------------------------------------------------- + * Function: H5Eget_minor + * + * Purpose: Retrieves a minor error message. + * + * Return: Returns message if succeeds. + * otherwise returns NULL. + * + * Programmer: Raymond Lu + * Friday, July 14, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +const char * +H5Eget_minor(H5E_minor_t min) +{ + H5E_msg_t *msg; /* Pointer to error message */ + ssize_t size = 0; /* Return value */ + H5E_type_t type; + char *msg_str; + char *ret_value = NULL; + + FUNC_ENTER_API_NOINIT(H5Eget_minor) + + /* Get the message object */ + if((msg = H5I_object_verify(min, H5I_ERROR_MSG))==NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a error message ID") + + /* Get the message's text */ + if((size = H5E_get_msg(msg, &type, NULL, 0))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text"); + + if(type != H5E_MINOR) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "Error message isn't a minor one"); + + /* Don't know who is going to free it */ + msg_str = (char*)HDmalloc((++size)*sizeof(char)); + + if(H5E_get_msg(msg, NULL, msg_str, size)<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, NULL, "can't get error message text") + + ret_value = msg_str; + +done: + FUNC_LEAVE_API(ret_value) +} + +#else /*------------------------------------------------------------------------- * Function: H5Eget_msg @@ -770,6 +872,7 @@ H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg_str, size_t size) done: FUNC_LEAVE_API(ret_value) } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /*------------------------------------------------------------------------- @@ -903,12 +1006,12 @@ H5E_get_current_stack(void) if(H5I_inc_ref(current_error->cls_id)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, NULL, "unable to increment ref count on error class") new_error->cls_id = current_error->cls_id; - if(H5I_inc_ref(current_error->maj_id)<0) + if(H5I_inc_ref(current_error->maj_num)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, NULL, "unable to increment ref count on error message") - new_error->maj_id = current_error->maj_id; - if(H5I_inc_ref(current_error->min_id)<0) + new_error->maj_num = current_error->maj_num; + if(H5I_inc_ref(current_error->min_num)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, NULL, "unable to increment ref count on error message") - new_error->min_id = current_error->min_id; + new_error->min_num = current_error->min_num; if((new_error->func_name = HDstrdup(current_error->func_name))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") if((new_error->file_name = HDstrdup(current_error->file_name))==NULL) @@ -1017,12 +1120,12 @@ H5E_set_current_stack(H5E_t *estack) if(H5I_inc_ref(new_error->cls_id)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to decrement ref count on error class") current_error->cls_id = new_error->cls_id; - if(H5I_inc_ref(new_error->maj_id)<0) + if(H5I_inc_ref(new_error->maj_num)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to decrement ref count on error class") - current_error->maj_id = new_error->maj_id; - if(H5I_inc_ref(new_error->min_id)<0) + current_error->maj_num = new_error->maj_num; + if(H5I_inc_ref(new_error->min_num)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "unable to decrement ref count on error class") - current_error->min_id = new_error->min_id; + current_error->min_num = new_error->min_num; if((current_error->func_name = HDstrdup(new_error->func_name))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") if((current_error->file_name = HDstrdup(new_error->file_name))==NULL) @@ -1270,6 +1373,47 @@ done: FUNC_LEAVE_NOAPI(ret_value) } +#ifdef H5_WANT_H5_V1_6_COMPAT + +/*------------------------------------------------------------------------- + * Function: H5Epush + * + * Purpose: This function definition is for backward compatibility only. + * It doesn't have error stack and error class as parameters. + * The old definition of major and minor is casted as HID_T + * in H5Epublic.h + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Tuesday, Sep 16, 2003 + * + * Notes: Basically a public API wrapper around the H5E_push function. + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Epush(const char *file, const char *func, unsigned line, + H5E_major_t maj, H5E_minor_t min, const char *str) +{ + H5E_t *estack = NULL; /* Default error stack */ + herr_t ret_value=SUCCEED; /* Return value */ + + /* Don't clear the error stack! :-) */ + FUNC_ENTER_API_NOCLEAR(H5Epush, FAIL) + H5TRACE6("e","ssIuiis",file,func,line,maj,min,str); + + /* Push the error on the stack */ + if(H5E_push(estack, file, func, line, H5E_ERR_CLS_g, maj, min, str)<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't push error on stack") + +done: + FUNC_LEAVE_API(ret_value) +} +#else /* H5_WANT_H5_V1_6_COMPAT */ + /*------------------------------------------------------------------------- * Function: H5Epush @@ -1313,7 +1457,6 @@ H5Epush(hid_t err_stack, const char *file, const char *func, unsigned line, FUNC_ENTER_API_NOCLEAR(H5Epush, FAIL) H5TRACE7("e","issIuiis",err_stack,file,func,line,maj_id,min_id,fmt); - /* Need to check for errors */ if(err_stack == H5E_DEFAULT) estack = NULL; else { @@ -1345,6 +1488,7 @@ H5Epush(hid_t err_stack, const char *file, const char *func, unsigned line, done: FUNC_LEAVE_API(ret_value) } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /*------------------------------------------------------------------------- @@ -1420,10 +1564,10 @@ H5E_push(H5E_t *estack, const char *file, const char *func, unsigned line, estack->slot[estack->nused].cls_id = cls_id; if(H5I_inc_ref(maj_id)<0) HGOTO_DONE(FAIL) - estack->slot[estack->nused].maj_id = maj_id; + estack->slot[estack->nused].maj_num = maj_id; if(H5I_inc_ref(min_id)<0) HGOTO_DONE(FAIL) - estack->slot[estack->nused].min_id = min_id; + estack->slot[estack->nused].min_num = min_id; if((estack->slot[estack->nused].func_name = HDstrdup(func))==NULL) HGOTO_DONE(FAIL) if((estack->slot[estack->nused].file_name = HDstrdup(file))==NULL) @@ -1438,6 +1582,42 @@ done: FUNC_LEAVE_NOAPI(ret_value) } +#ifdef H5_WANT_H5_V1_6_COMPAT + +/*------------------------------------------------------------------------- + * Function: H5Eclear + * + * Purpose: This function is for backward compatbility. + * Clears the error stack for the specified error stack. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Wednesday, July 16, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Eclear(void) +{ + H5E_t *estack = NULL; /* Default error stack to operate on */ + herr_t ret_value=SUCCEED; /* Return value */ + + /* Don't clear the error stack! :-) */ + FUNC_ENTER_API_NOCLEAR(H5Eclear, FAIL) + H5TRACE0("e",""); + + /* Clear the error stack */ + if(H5E_clear(estack)<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't clear error stack") + +done: + FUNC_LEAVE_API(ret_value) +} +#else + /*------------------------------------------------------------------------- * Function: H5Eclear @@ -1481,6 +1661,7 @@ H5Eclear(hid_t err_stack) done: FUNC_LEAVE_API(ret_value) } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /*------------------------------------------------------------------------- @@ -1517,9 +1698,9 @@ H5E_clear_entries(H5E_t *estack, unsigned nentries) /* Decrement the IDs to indicate that they are no longer used by this stack */ /* (In reverse order that they were incremented, so that reference counts work well) */ - if(H5I_dec_ref(error->min_id)<0) + if(H5I_dec_ref(error->min_num)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") - if(H5I_dec_ref(error->maj_id)<0) + if(H5I_dec_ref(error->maj_num)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") if(H5I_dec_ref(error->cls_id)<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error class") @@ -1578,6 +1759,51 @@ done: FUNC_LEAVE_NOAPI(ret_value) } +#ifdef H5_WANT_H5_V1_6_COMPAT +/*------------------------------------------------------------------------- + * Function: H5Eprint + * + * Purpose: This function is for backward compatbility. + * Prints the error stack in some default way. This is just a + * convenience function for H5Ewalk() with a function that + * prints error messages. Users are encouraged to write there + * own more specific error handlers. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Sep 16, 2003 + * + * Modifications: + * Albert Cheng, 2000/12/02 + * Show MPI process rank id if applicable. + * Albert Cheng, 2001/07/14 + * Show HDF5 library version information string too. + * + *------------------------------------------------------------------------- + */ +herr_t +H5Eprint(FILE *stream) +{ + H5E_t *estack = NULL; /* Error stack to operate on */ + herr_t ret_value=SUCCEED; /* Return value */ + + /* Don't clear the error stack! :-) */ + FUNC_ENTER_API_NOCLEAR(H5Eprint, FAIL) + /*NO TRACE*/ + + if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") + + /* Print error stack */ + if(H5E_print(estack, stream)<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't display error stack") + +done: + FUNC_LEAVE_API(ret_value) +} +#else + /*------------------------------------------------------------------------- * Function: H5Eprint @@ -1635,6 +1861,7 @@ H5Eprint(hid_t err_stack, FILE *stream) done: FUNC_LEAVE_API(ret_value) } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /*------------------------------------------------------------------------- @@ -1692,6 +1919,46 @@ done: FUNC_LEAVE_NOAPI(ret_value) } +#ifdef H5_WANT_H5_V1_6_COMPAT + +/*------------------------------------------------------------------------- + * Function: H5Ewalk + * + * Purpose: This function is for backward compatbility. + * Walks the error stack for the current thread and calls some + * function for each error along the way. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Sep 16, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Ewalk(H5E_direction_t direction, H5E_walk_t func, void *client_data) +{ + H5E_t *estack; /* Error stack to operate on */ + herr_t ret_value=SUCCEED; /* Return value */ + + /* Don't clear the error stack! :-) */ + FUNC_ENTER_API_NOCLEAR(H5Ewalk, FAIL) + /*NO TRACE*/ + + if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") + + /* Walk the error stack */ + if(H5E_walk (estack, direction, func, client_data)<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't walk error stack") + +done: + FUNC_LEAVE_API(ret_value) +} +#else + /*------------------------------------------------------------------------- * Function: H5Ewalk @@ -1742,6 +2009,7 @@ H5Ewalk(hid_t err_stack, H5E_direction_t direction, H5E_walk_t func, void *clien done: FUNC_LEAVE_API(ret_value) } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /*------------------------------------------------------------------------- @@ -1866,8 +2134,8 @@ H5E_walk_cb(unsigned n, const H5E_error_t *err_desc, void *client_data) else stream = eprint->stream; /* Get descriptions for the major and minor error numbers */ - maj_ptr = H5I_object_verify(err_desc->maj_id, H5I_ERROR_MSG); - min_ptr = H5I_object_verify(err_desc->min_id, H5I_ERROR_MSG); + maj_ptr = H5I_object_verify(err_desc->maj_num, H5I_ERROR_MSG); + min_ptr = H5I_object_verify(err_desc->min_num, H5I_ERROR_MSG); assert(maj_ptr && min_ptr); if(maj_ptr->msg) maj_str = maj_ptr->msg; @@ -1919,6 +2187,48 @@ H5E_walk_cb(unsigned n, const H5E_error_t *err_desc, void *client_data) FUNC_LEAVE_NOAPI(SUCCEED) } +#ifdef H5_WANT_H5_V1_6_COMPAT + +/*------------------------------------------------------------------------- + * Function: H5Eget_auto + * + * Purpose: This function is for backward compatbility. + * Returns the current settings for the automatic error stack + * traversal function and its data for specific error stack. + * Either (or both) arguments may be null in which case the + * value is not returned. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Sep 16, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Eget_auto(H5E_auto_t *func, void **client_data) +{ + H5E_t *estack; /* Error stack to operate on */ + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_API(H5Eget_auto, FAIL) + H5TRACE2("e","*x*x",func,client_data); + + /* Retieve default error stack */ + if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") + + /* Get the automatic error reporting information */ + if(H5E_get_auto(estack, func, client_data)<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") + +done: + FUNC_LEAVE_API(ret_value) +} + +#else /*------------------------------------------------------------------------- * Function: H5Eget_auto @@ -1965,6 +2275,7 @@ H5Eget_auto(hid_t estack_id, H5E_auto_t *func, void **client_data) done: FUNC_LEAVE_API(ret_value) } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /*------------------------------------------------------------------------- @@ -2001,6 +2312,56 @@ done: FUNC_LEAVE_NOAPI(ret_value) } +#ifdef H5_WANT_H5_V1_6_COMPAT + +/*------------------------------------------------------------------------- + * Function: H5Eset_auto + * + * Purpose: This function is for backward compatbility. + * Turns on or off automatic printing of errors for certain + * error stack. When turned on (non-null FUNC pointer) any + * API function which returns an error indication will first + * call FUNC passing it CLIENT_DATA as an argument. + * + * The default values before this function is called are + * H5Eprint() with client data being the standard error stream, + * stderr. + * + * Automatic stack traversal is always in the H5E_WALK_DOWNWARD + * direction. + * + * See Also: H5Ewalk() + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Sep 16, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Eset_auto(H5E_auto_t func, void *client_data) +{ + H5E_t *estack; /* Error stack to operate on */ + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_API(H5Eset_auto, FAIL) + H5TRACE2("e","xx",func,client_data); + + if((estack = H5E_get_my_stack())==NULL) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */ + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") + + /* Set the automatic error reporting information */ + if(H5E_set_auto(estack, func, client_data)<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set automatic error info") + +done: + FUNC_LEAVE_API(ret_value) +} + +#else /*------------------------------------------------------------------------- * Function: H5Eset_auto @@ -2052,6 +2413,7 @@ H5Eset_auto(hid_t estack_id, H5E_auto_t func, void *client_data) done: FUNC_LEAVE_API(ret_value) } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /*------------------------------------------------------------------------- diff --git a/src/H5Epublic.h b/src/H5Epublic.h index 5afd5a7..99fccd8 100644 --- a/src/H5Epublic.h +++ b/src/H5Epublic.h @@ -36,11 +36,16 @@ typedef enum H5E_type_t { H5E_MINOR } H5E_type_t; +#ifdef H5_WANT_H5_V1_6_COMPAT +typedef hid_t H5E_major_t; +typedef hid_t H5E_minor_t; +#endif /* H5_WANT_H5_V1_6_COMPAT */ + /* Information about an error; element of error stack */ typedef struct H5E_error_t { hid_t cls_id; /*class ID */ - hid_t maj_id; /*major error ID */ - hid_t min_id; /*minor error number */ + hid_t maj_num; /*major error ID */ + hid_t min_num; /*minor error number */ const char *func_name; /*function in which error occurred */ const char *file_name; /*file in which error occurred */ unsigned line; /*line in file where error occurs */ @@ -77,38 +82,68 @@ H5_DLLVAR hid_t H5E_ERR_CLS_g; * Warning: don't break, return, or longjmp() from the body of the loop or * the error reporting won't be properly restored! */ +#ifdef H5_WANT_H5_V1_6_COMPAT #define H5E_BEGIN_TRY { \ H5E_auto_t H5E_saved_efunc; \ void *H5E_saved_edata; \ - (void)H5Eget_auto(H5E_DEFAULT, &H5E_saved_efunc, &H5E_saved_edata); \ + (void)H5Eget_auto(&H5E_saved_efunc, &H5E_saved_edata); \ + (void)H5Eset_auto(NULL, NULL); + +#define H5E_END_TRY \ + (void)H5Eset_auto (H5E_saved_efunc, H5E_saved_edata); \ +} +#else /* H5_WANT_H5_V1_6_COMPAT */ +#define H5E_BEGIN_TRY { \ + H5E_auto_t H5E_saved_efunc; \ + void *H5E_saved_edata; \ + (void)H5Eget_auto(H5E_DEFAULT, &H5E_saved_efunc, &H5E_saved_edata); \ (void)H5Eset_auto(H5E_DEFAULT, NULL, NULL); #define H5E_END_TRY \ - (void)H5Eset_auto (H5E_DEFAULT, H5E_saved_efunc, H5E_saved_edata); \ + (void)H5Eset_auto (H5E_DEFAULT, H5E_saved_efunc, H5E_saved_edata); \ } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* * Public API Convenience Macros for Error reporting - Documented */ /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */ +#ifdef H5_WANT_H5_V1_6_COMPAT +#define H5Epush_sim(func,cls,maj,min,str) H5Epush(__FILE__,func,__LINE__,maj,min,str) +#else #define H5Epush_sim(func,cls,maj,min,str) H5Epush(H5E_DEFAULT,__FILE__,func,__LINE__,cls,maj,min,str) +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* * Public API Convenience Macros for Error reporting - Undocumented */ /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */ /* And return after pushing error onto stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT +#define H5Epush_ret(func,cls,maj,min,str,ret) { \ + H5Epush(__FILE__,func,__LINE__,maj,min,str); \ + return(ret); \ +} +#else #define H5Epush_ret(func,cls,maj,min,str,ret) { \ H5Epush(H5E_DEFAULT,__FILE__,func,__LINE__,cls,maj,min,str); \ return(ret); \ } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Use the Standard C __FILE__ & __LINE__ macros instead of typing them in */ /* And goto a label after pushing error onto stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT +#define H5Epush_goto(func,cls,maj,min,str,label) { \ + H5Epush(__FILE__,func,__LINE__,maj,min,str); \ + goto label; \ +} +#else #define H5Epush_goto(func,cls,maj,min,str,label) { \ H5Epush(H5E_DEFAULT,__FILE__,func,__LINE__,cls,maj,min,str); \ goto label; \ } +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Error stack traversal direction */ typedef enum H5E_direction_t { @@ -133,19 +168,31 @@ H5_DLL hid_t H5Ecreate_msg(hid_t cls, H5E_type_t msg_type, const char *msg); H5_DLL hid_t H5Eget_current_stack(void); H5_DLL herr_t H5Eclose_stack(hid_t stack_id); H5_DLL ssize_t H5Eget_class_name(hid_t class_id, char *name, size_t size); -H5_DLL ssize_t H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg, size_t size); H5_DLL int H5Eget_num(hid_t error_stack_id); H5_DLL herr_t H5Eset_current_stack(hid_t err_stack_id); -H5_DLL herr_t H5Epush(hid_t err_stack, const char *file, const char *func, unsigned line, - hid_t cls_id, hid_t maj_id, hid_t min_id, const char *msg, ...); H5_DLL herr_t H5Epop(hid_t err_stack, size_t count); -H5_DLL herr_t H5Eclear(hid_t err_stack); +#ifdef H5_WANT_H5_V1_6_COMPAT +H5_DLL herr_t H5Epush(const char *file, const char *func, unsigned line, + H5E_major_t maj, H5E_minor_t min, const char *str); +H5_DLL herr_t H5Eprint(FILE *stream); +H5_DLL herr_t H5Ewalk(H5E_direction_t direction, H5E_walk_t func, + void *client_data); +H5_DLL herr_t H5Eget_auto(H5E_auto_t *func, void **client_data); +H5_DLL herr_t H5Eset_auto(H5E_auto_t func, void *client_data); +H5_DLL herr_t H5Eclear(void); +H5_DLL const char * H5Eget_major(H5E_major_t maj); +H5_DLL const char * H5Eget_minor(H5E_minor_t min); +#else +H5_DLL herr_t H5Epush(hid_t err_stack, const char *file, const char *func, unsigned line, + hid_t cls_id, hid_t maj_id, hid_t min_id, const char *msg, ...); H5_DLL herr_t H5Eprint(hid_t err_stack, FILE *stream); H5_DLL herr_t H5Ewalk(hid_t err_stack, H5E_direction_t direction, H5E_walk_t func, void *client_data); H5_DLL herr_t H5Eget_auto(hid_t estack_id, H5E_auto_t *func, void **client_data); H5_DLL herr_t H5Eset_auto(hid_t estack_id, H5E_auto_t func, void *client_data); - +H5_DLL herr_t H5Eclear(hid_t err_stack); +H5_DLL ssize_t H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg, size_t size); +#endif /* H5_WANT_H5_V1_6_COMPAT */ #ifdef __cplusplus } #endif diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index d4ada22..d16421e 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -231,7 +231,11 @@ hid_t H5FD_multi_init(void) { /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if (H5I_VFL!=H5Iget_type(H5FD_MULTI_g)) { H5FD_MULTI_g = H5FDregister(&H5FD_multi_g); @@ -277,7 +281,11 @@ H5Pset_fapl_split(hid_t fapl, const char *meta_ext, hid_t meta_plist_id, /*NO TRACE*/ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Initialize */ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt=(H5FD_mem_t)(mt+1)) { @@ -421,7 +429,11 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, /*NO TRACE*/ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Check arguments and supply default values */ if(H5I_GENPROP_LST != H5Iget_type(fapl_id) || @@ -522,7 +534,11 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map/*out*/, /*NO TRACE*/ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if(H5I_GENPROP_LST != H5Iget_type(fapl_id) || TRUE != H5Pisa_class(fapl_id, H5P_FILE_ACCESS)) @@ -589,7 +605,11 @@ H5Pset_dxpl_multi(hid_t dxpl_id, const hid_t *memb_dxpl) /*NO TRACE*/ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Check arguments */ if (TRUE!=H5Pisa_class(dxpl_id, H5P_DATASET_XFER)) @@ -641,7 +661,11 @@ H5Pget_dxpl_multi(hid_t dxpl_id, hid_t *memb_dxpl/*out*/) /*NO TRACE*/ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if (TRUE!=H5Pisa_class(dxpl_id, H5P_DATASET_XFER)) H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADTYPE, "not a file access property list", -1) @@ -688,7 +712,11 @@ H5FD_multi_sb_size(H5FD_t *_file) hsize_t nbytes = 8; /*size of header*/ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* How many unique files? */ UNIQUE_MEMBERS(file->fa.memb_map, mt) { @@ -746,7 +774,11 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/, static const char *func="H5FD_multi_sb_encode"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Name and version number */ strcpy(name, "NCSAmulti"); @@ -830,7 +862,11 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) static const char *func="H5FD_multi_sb_decode"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Make sure the name/version number is correct */ if (strcmp(name, "NCSAmult")) @@ -973,7 +1009,11 @@ H5FD_multi_fapl_get(H5FD_t *_file) H5FD_multi_t *file = (H5FD_multi_t*)_file; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ return H5FD_multi_fapl_copy(&(file->fa)); } @@ -1007,7 +1047,11 @@ H5FD_multi_fapl_copy(const void *_old_fa) assert(new_fa); /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ memcpy(new_fa, old_fa, sizeof(H5FD_multi_fapl_t)); for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt=(H5FD_mem_t)(mt+1)) { @@ -1058,7 +1102,11 @@ H5FD_multi_fapl_free(void *_fa) static const char *func="H5FD_multi_fapl_free"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt=(H5FD_mem_t)(mt+1)) { if (fa->memb_fapl[mt]>=0) @@ -1101,7 +1149,11 @@ H5FD_multi_dxpl_copy(const void *_old_dx) assert(new_dx); /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ memcpy(new_dx, old_dx, sizeof(H5FD_multi_dxpl_t)); for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt=(H5FD_mem_t)(mt+1)) { @@ -1145,7 +1197,11 @@ H5FD_multi_dxpl_free(void *_dx) static const char *func="H5FD_multi_dxpl_free"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt=(H5FD_mem_t)(mt+1)) if (dx->memb_dxpl[mt]>=0) @@ -1185,7 +1241,11 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, static const char *func="H5FD_multi_open"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Check arguments */ if (!name || !*name) @@ -1280,7 +1340,11 @@ H5FD_multi_close(H5FD_t *_file) static const char *func="H5FD_multi_close"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Close as many members as possible */ ALL_MEMBERS(mt) { @@ -1346,7 +1410,11 @@ H5FD_multi_cmp(const H5FD_t *_f1, const H5FD_t *_f2) int cmp=0; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt=(H5FD_mem_t)(mt+1)) { if (f1->memb[mt] && f2->memb[mt]) break; @@ -1420,7 +1488,11 @@ H5FD_multi_get_eoa(H5FD_t *_file) H5FD_multi_t *file = (H5FD_multi_t*)_file; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ return file->eoa; } @@ -1454,7 +1526,11 @@ H5FD_multi_set_eoa(H5FD_t *_file, haddr_t eoa) static const char *func="H5FD_multi_set_eoa"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Find the subfile in which the new EOA value falls */ for (mt=H5FD_MEM_SUPER; mt<H5FD_MEM_NTYPES; mt=(H5FD_mem_t)(mt+1)) { @@ -1510,7 +1586,11 @@ H5FD_multi_get_eof(H5FD_t *_file) static const char *func="H5FD_multi_eof"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ UNIQUE_MEMBERS(file->fa.memb_map, mt) { if (file->memb[mt]) { @@ -1632,7 +1712,11 @@ H5FD_multi_free(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsi H5FD_mem_t mmt; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ mmt = file->fa.memb_map[type]; if (H5FD_MEM_DEFAULT==mmt) mmt = type; @@ -1672,7 +1756,11 @@ H5FD_multi_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, siz haddr_t start_addr=0; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Get the data transfer properties */ if (H5P_FILE_ACCESS_DEFAULT!=dxpl_id && H5FD_MULTI==H5Pget_driver(dxpl_id)) { @@ -1727,7 +1815,11 @@ H5FD_multi_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, si haddr_t start_addr=0; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Get the data transfer properties */ if (H5P_FILE_ACCESS_DEFAULT!=dxpl_id && H5FD_MULTI==H5Pget_driver(dxpl_id)) { @@ -1811,7 +1903,11 @@ H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing) #endif /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Flush each file */ for (mt=H5FD_MEM_SUPER; mt<H5FD_MEM_NTYPES; mt=(H5FD_mem_t)(mt+1)) { @@ -1849,7 +1945,11 @@ static int compute_next(H5FD_multi_t *file) { /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ ALL_MEMBERS(mt) { file->memb_next[mt] = HADDR_UNDEF; @@ -1896,7 +1996,11 @@ open_members(H5FD_multi_t *file) static const char *func="(H5FD_multi)open_members"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ UNIQUE_MEMBERS(file->fa.memb_map, mt) { if (file->memb[mt]) continue; /*already open*/ diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 20350f1..ea53da9 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -216,7 +216,11 @@ hid_t H5FD_stdio_init(void) { /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if (H5I_VFL!=H5Iget_type(H5FD_STDIO_g)) H5FD_STDIO_g = H5FDregister(&H5FD_stdio_g); @@ -249,7 +253,11 @@ H5Pset_fapl_stdio(hid_t fapl_id) /*NO TRACE*/ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if(0 == H5Pisa_class(fapl_id, H5P_FILE_ACCESS)) H5Epush_ret(func, H5E_ERR_CLS, H5E_PLIST, H5E_BADTYPE, "not a file access property list", -1) @@ -309,7 +317,11 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id, fapl_id=fapl_id; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Check arguments */ if (!name || !*name) @@ -397,7 +409,11 @@ H5FD_stdio_close(H5FD_t *_file) static const char *func="H5FD_stdio_close"; /* Function Name for error reporting */ /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if (fclose(file->fp) < 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_CLOSEERROR, "fclose failed", -1) @@ -434,7 +450,11 @@ H5FD_stdio_cmp(const H5FD_t *_f1, const H5FD_t *_f2) const H5FD_stdio_t *f2 = (const H5FD_stdio_t*)_f2; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ #ifdef WIN32 if (f1->fileindexhi < f2->fileindexhi) return -1; @@ -524,7 +544,11 @@ H5FD_stdio_get_eoa(H5FD_t *_file) H5FD_stdio_t *file = (H5FD_stdio_t*)_file; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ return(file->eoa); } @@ -555,7 +579,11 @@ H5FD_stdio_set_eoa(H5FD_t *_file, haddr_t addr) H5FD_stdio_t *file = (H5FD_stdio_t*)_file; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ file->eoa = addr; @@ -590,7 +618,11 @@ H5FD_stdio_get_eof(H5FD_t *_file) H5FD_stdio_t *file = (H5FD_stdio_t*)_file; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ return(MAX(file->eof, file->eoa)); } @@ -620,8 +652,12 @@ H5FD_stdio_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) fapl=fapl; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); - +#endif /* H5_WANT_H5_V1_6_COMPAT */ + *file_handle = &(file->fp); if(*file_handle==NULL) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_WRITEERROR, "get handle failed", -1) @@ -666,7 +702,11 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, siz dxpl_id=dxpl_id; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Check for overflow */ if (HADDR_UNDEF==addr) @@ -764,7 +804,11 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, type=type; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Check for overflow conditions */ if (HADDR_UNDEF==addr) @@ -841,7 +885,11 @@ H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing) dxpl_id=dxpl_id; /* Clear the error stack */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Only try to flush the file if we have write access */ if(file->write_access) { diff --git a/test/Dependencies b/test/Dependencies index 7de8ea9..262fac7 100644 --- a/test/Dependencies +++ b/test/Dependencies @@ -2724,8 +2724,8 @@ dangle.lo: \ $(top_srcdir)/src/H5Oprivate.h \ $(top_srcdir)/src/H5HGprivate.h \ $(top_srcdir)/src/H5Zprivate.h -errors.lo: \ - $(top_srcdir)/test/errors.c \ +error_test.lo: \ + $(top_srcdir)/test/error_test.c \ $(top_srcdir)/test/h5test.h \ $(top_srcdir)/src/hdf5.h \ $(top_srcdir)/src/H5public.h \ diff --git a/test/Makefile.in b/test/Makefile.in index 4a89e03..d46d90e 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -22,14 +22,21 @@ srcdir=@srcdir@ ## libraries to the library list. CPPFLAGS=-I. -I$(srcdir) -I../src -I$(top_srcdir)/src @CPPFLAGS@ +## Test script for error_test and err_compat +TEST_SCRIPTS=$(srcdir)/testerror.sh + ## These are our main targets. They should be listed in the order to be ## executed, generally most specific tests to least specific tests. TEST_PROGS=testhdf5 lheap ohdr stab gheap hyperslab istore bittests dtypes \ dsets cmpd_dset extend external links unlink big mtime fillval mount \ flush1 flush2 enum gass_write gass_read gass_append set_extent \ srb_write srb_append srb_read ttsafe stream_test getname file_handle \ - ntypes dangle errors + ntypes dangle + +## Test programs for Error API +ERR_PROGS=error_test err_compat +PROGS=$(ERR_PROGS) $(TEST_PROGS) TIMINGS=testmeta ## The libh5test.a library provides common support code for the tests. We link @@ -57,7 +64,7 @@ MOSTLYCLEAN=cmpd_dset.h5 compact_dataset.h5 dataset.h5 extend.h5 istore.h5 \ set_extent_read.h5 set_extent_create.h5 getname.h5 \ getname[1-3].h5 sec2_file.h5 family_file000[0-3][0-9].h5 \ multi_file-[rs].h5 core_file new_move_[ab].h5 ntypes.h5 \ - dangle.h5 errors.h5 + dangle.h5 error_test.h5 err_compat.h5 CLEAN=$(TIMINGS) @@ -75,7 +82,7 @@ TEST_SRC=big.c bittests.c cmpd_dset.c dsets.c dtypes.c extend.c \ ttsafe_dcreate.c ttsafe_error.c ttsafe_cancel.c ttsafe_acreate.c \ gass_write.c gass_read.c gass_append.c srb_read.c srb_write.c \ srb_append.c stream_test.c set_extent.c getname.c file_handle.c \ - ntypes.c dangle.c errors.c + ntypes.c dangle.c error_test.c err_compat.c TEST_OBJ=$(TEST_SRC:.c=.lo) @@ -94,8 +101,12 @@ timings _timings: $(TIMINGS) fi; \ done; +## Programs have to be built before they can be tested! +## +check test _test: $(PROGS) + ## How to build the tests... They all depend on the test and hdf5 libraries. -$(TEST_PROGS): $(LIB) $(LIBHDF5) +$(PROGS): $(LIB) $(LIBHDF5) TESTHDF5_OBJ=testhdf5.lo tarray.lo tattr.lo tconfig.lo tfile.lo tgenprop.lo \ th5s.lo theap.lo titerate.lo tmeta.lo ttime.lo trefer.lo trefstr.lo \ @@ -212,7 +223,10 @@ ntypes: ntypes.lo dangle: dangle.lo @$(LT_LINK_EXE) $(CFLAGS) -o $@ dangle.lo $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS) -errors: errors.lo - @$(LT_LINK_EXE) $(CFLAGS) -o $@ errors.lo $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS) +error_test: error_test.lo + @$(LT_LINK_EXE) $(CFLAGS) -o $@ error_test.lo $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS) + +err_compat: err_compat.lo + @$(LT_LINK_EXE) $(CFLAGS) -o $@ err_compat.lo $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS) @CONCLUDE@ diff --git a/test/dtypes.c b/test/dtypes.c index d8a6229..2c13b3d 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -1239,7 +1239,7 @@ test_compound_7(void) /* Increase compound type size and try inserting field again */ if(H5Tset_size(tid2, sizeof(struct s2))<0) { H5_FAILED(); - printf("Incorrect size for struct 2\n"); + printf("Can't increase size for compound type\n"); goto error; } /* end if */ diff --git a/test/enum.c b/test/enum.c index 9e454c2..bd8397b 100644 --- a/test/enum.c +++ b/test/enum.c @@ -376,7 +376,12 @@ test_value_dsnt_exist(void) TESTING("for non-existing name and value"); /* Turn off error reporting since we expect failure in this test */ +#ifdef H5_WANT_H5_V1_6_COMPAT + if (H5Eset_auto(NULL, NULL) < 0) goto error; +#else if (H5Eset_auto(H5E_DEFAULT, NULL, NULL) < 0) goto error; +#endif /* H5_WANT_H5_V1_6_COMPAT */ + if ((datatype_id = H5Tenum_create(H5T_NATIVE_INT))< 0) goto error; /* These calls should fail, since no memebrs exist yet */ diff --git a/test/err_compat.c b/test/err_compat.c new file mode 100644 index 0000000..fd84824 --- /dev/null +++ b/test/err_compat.c @@ -0,0 +1,295 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Raymond Lu + * October 14, 2001 + * + * Purpose: Tests Error API + */ +#include "h5test.h" + +#ifndef H5_WANT_H5_V1_6_COMPAT +int main(void) +{ + printf("Test skipped because backward compatbility with v1.6 is NOT configured in\n"); + return 0; +} +#else + +const char *FILENAME[] = { + "errors_compat", + NULL +}; + +#define DIM0 100 +#define DIM1 200 + +int ipoints2[DIM0][DIM1], icheck2[DIM0][DIM1]; + +#define DSET_NAME "a_dataset" +#define FAKE_ID -1 + +herr_t custom_print_cb(unsigned n, const H5E_error_t *err_desc, void* client_data); + + +/*------------------------------------------------------------------------- + * Function: test_error + * + * Purpose: Test error API functions + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Raymond Lu + * July 10, 2003 + * + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +#ifndef TMP +static herr_t +test_error(hid_t file) +{ + hid_t dataset, space; + hid_t estack_id; + hsize_t dims[2]; + const char *FUNC_test_error="test_error"; + H5E_auto_t old_func; + void *old_data; + + TESTING("error API based on data I/O"); + fprintf(stderr, "\n"); + + /* Create the data space */ + dims[0] = DIM0; + dims[1] = DIM1; + if ((space = H5Screate_simple(2, dims, NULL))<0) TEST_ERROR; + + /* Test H5E_BEGIN_TRY */ + H5E_BEGIN_TRY { + dataset = H5Dcreate(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT); + } H5E_END_TRY; + + /* Create the dataset */ + if ((dataset = H5Dcreate(file, DSET_NAME, H5T_STD_I32BE, space, + H5P_DEFAULT))<0) { + H5Epush(__FILE__, FUNC_test_error, __LINE__, H5E_ERROR, H5E_CANTCREATE, + "H5Dcreate failed"); + goto error; + } + + /* Test enabling and disabling default printing */ +#ifndef TMP + if (H5Eget_auto(&old_func, &old_data)<0) + TEST_ERROR; + if (old_data != NULL) + TEST_ERROR; + if (!old_func) + TEST_ERROR; + if (old_func != (H5E_auto_t)H5Eprint) + TEST_ERROR; + + if(H5Eset_auto(NULL, NULL)<0) + TEST_ERROR; +#endif + + /* Make H5Dwrite fail, verify default print is disabled */ + if (H5Dwrite(FAKE_ID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2)<0) { + H5Epush(__FILE__, FUNC_test_error, __LINE__, H5E_ERROR, H5E_WRITEERROR, + "H5Dwrite shouldn't succeed"); + goto error; + } + + if(H5Eset_auto(old_func, old_data)<0) + TEST_ERROR; + + /* In case program comes to this point, close dataset */ + if(H5Dclose(dataset)<0) TEST_ERROR; + + TEST_ERROR; + + error: + return -1; +} +#endif + + +/*------------------------------------------------------------------------- + * Function: error_stack + * + * Purpose: Dummy function. Simply make it fail. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Raymond Lu + * July 14, 2003 + * + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +error_stack(void) +{ + return -1; +} + + +/*------------------------------------------------------------------------- + * Function: dump_error + * + * Purpose: Prints error stack in default and customized ways. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Raymond Lu + * July 17, 2003 + * + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +dump_error(void) +{ + /* Print errors in library default way */ + fprintf(stderr, "********* Print error stack in HDF5 default way *********\n"); + if(H5Eprint(stderr)<0) + TEST_ERROR; + + /* Customized way to print errors */ + fprintf(stderr, "\n********* Print error stack in customized way *********\n"); + if(H5Ewalk(H5E_WALK_UPWARD, custom_print_cb, stderr)<0) + TEST_ERROR; + + return 0; + + error: + return -1; +} + +/*------------------------------------------------------------------------- + * Function: custom_print_cb + * + * Purpose: Callback function to print error stack in customized way. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Raymond Lu + * July 17, 2003 + * + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +custom_print_cb(unsigned n, const H5E_error_t *err_desc, void* client_data) +{ + FILE *stream = (FILE *)client_data; + char *maj; + char *min; + const int indent = 4; + + if((min = H5Eget_minor(err_desc->min_num))==NULL) + TEST_ERROR; + + if((maj = H5Eget_major(err_desc->maj_num))==NULL) + TEST_ERROR; + + fprintf (stream, "%*serror #%03d: %s in %s(): line %u\n", + indent, "", n, err_desc->file_name, + err_desc->func_name, err_desc->line); + fprintf (stream, "%*smajor: %s\n", indent*2, "", maj); + fprintf (stream, "%*sminor: %s\n", indent*2, "", min); + + return 0; + + error: + return -1; +} + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Test error API. + * + * Programmer: Raymond Lu + * July 10, 2003 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + hid_t file, fapl; + char filename[1024]; + const char *FUNC_main="main"; + H5E_auto_t old_func; + void *old_data; + + fprintf(stderr, " This program tests the Error API compatible with HDF5 v1.6. There're supposed to be some error messages\n"); + /*h5_reset();*/ + fapl = h5_fileaccess(); + + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) + TEST_ERROR ; + + /* Test error stack */ + if(error_stack()<0) { + /* Push an error onto error stack */ + H5Epush(__FILE__, FUNC_main, __LINE__, H5E_ERROR, H5E_BADVALUE, + "Error test failed"); + + /* Print out the errors on stack */ + dump_error(); + + /* Empty error stack */ + H5Eclear(); + } + + /* Test error API */ + if(test_error(file)<0) { + H5Epush(__FILE__, FUNC_main, __LINE__, H5E_ERROR, H5E_BADMESG, + "Error test failed"); + H5Eprint(stderr); + } + + if (H5Fclose(file)<0) TEST_ERROR ; + h5_cleanup(FILENAME, fapl); + + printf("All error API tests passed.\n"); + return 0; + + error: + printf("***** ERROR TEST FAILED! *****\n"); + return 1; +} +#endif /* H5_WANT_H5_V1_6_COMPAT */ diff --git a/test/errors.c b/test/error_test.c index 3c40026..7e45f3d 100644 --- a/test/errors.c +++ b/test/error_test.c @@ -18,9 +18,16 @@ * * Purpose: Tests the H5Tget_native_type function. */ - #include "h5test.h" +#ifdef H5_WANT_H5_V1_6_COMPAT +int main(void) +{ + printf("Test skipped because backward compatbility with v1.6 is configured in\n"); + return 0; +} +#else + const char *FILENAME[] = { "errors", NULL @@ -344,10 +351,10 @@ custom_print_cb(unsigned n, const H5E_error_t *err_desc, void* client_data) if(H5Eget_class_name(err_desc->cls_id, cls, MSG_SIZE)<0) TEST_ERROR; - if(H5Eget_msg(err_desc->maj_id, NULL, maj, MSG_SIZE)<0) + if(H5Eget_msg(err_desc->maj_num, NULL, maj, MSG_SIZE)<0) TEST_ERROR; - if(H5Eget_msg(err_desc->min_id, NULL, min, MSG_SIZE)<0) + if(H5Eget_msg(err_desc->min_num, NULL, min, MSG_SIZE)<0) TEST_ERROR; fprintf (stream, "%*serror #%03d: %s in %s(): line %u\n", @@ -479,3 +486,4 @@ main(void) printf("***** ERROR TEST FAILED! *****\n"); return 1; } +#endif /* H5_WANT_H5_V1_6_COMPAT */ diff --git a/test/gheap.c b/test/gheap.c index b6b0b4c..d7098ea 100644 --- a/test/gheap.c +++ b/test/gheap.c @@ -89,7 +89,11 @@ test_1 (hid_t fapl) for (i=0; i<1024; i++) { size = i+1; memset (out, 'A'+i%26, size); - H5Eclear (H5E_DEFAULT); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else + H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ status = H5HG_insert (f, H5P_DATASET_XFER_DEFAULT, size, out, obj+i); if (status<0) { H5_FAILED(); @@ -108,7 +112,11 @@ test_1 (hid_t fapl) for (i=0; i<1024; i++) { size = i+1; memset (out, 'A'+i%26, size); - H5Eclear (H5E_DEFAULT); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else + H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if (NULL==H5HG_read (f, H5P_DATASET_XFER_DEFAULT, obj+i, in)) { H5_FAILED(); puts(" Unable to read object"); @@ -181,7 +189,11 @@ test_2 (hid_t fapl) for (i=0; i<1024; i++) { size = 1024-i; memset (out, 'A'+i%26, size); - H5Eclear (H5E_DEFAULT); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else + H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if (H5HG_insert (f, H5P_DATASET_XFER_DEFAULT, size, out, obj+i)<0) { H5_FAILED(); puts(" Unable to insert object into global heap"); @@ -195,7 +207,11 @@ test_2 (hid_t fapl) for (i=0; i<1024; i++) { size = 1024-i; memset (out, 'A'+i%26, size); - H5Eclear (H5E_DEFAULT); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else + H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ if (NULL==H5HG_read (f, H5P_DATASET_XFER_DEFAULT, obj+i, in)) { H5_FAILED(); puts(" Unable to read object"); @@ -266,7 +282,11 @@ test_3 (hid_t fapl) for (i=0; i<1024; i++) { size = i%30+100; memset (out, 'A'+i%26, size); - H5Eclear (H5E_DEFAULT); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else + H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ status = H5HG_insert (f, H5P_DATASET_XFER_DEFAULT, size, out, obj+i); if (status<0) { H5_FAILED(); @@ -345,7 +365,11 @@ test_4 (hid_t fapl) /* Insert */ size = i%30+100; memset (out, 'A'+i%26, size); - H5Eclear (H5E_DEFAULT); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else + H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ status = H5HG_insert (f, H5P_DATASET_XFER_DEFAULT, size, out, obj+i); if (status<0) { H5_FAILED(); @@ -359,7 +383,11 @@ test_4 (hid_t fapl) * remove B, insert D, E, F; remove E; etc. */ if (1==i%3) { - H5Eclear (H5E_DEFAULT); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else + H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ status = H5HG_remove (f, H5P_DATASET_XFER_DEFAULT, obj+i-1); if (status<0) { H5_FAILED(); diff --git a/test/h5test.c b/test/h5test.c index f583e4e..a3d4abf 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -112,7 +112,12 @@ static herr_t h5_errors(hid_t err_stack, void UNUSED *client_data) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint (stdout); +#else H5Eprint (err_stack, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ + return 0; } @@ -214,7 +219,11 @@ h5_reset(void) HDfflush(stdout); HDfflush(stderr); H5close(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eset_auto (h5_errors, NULL); +#else H5Eset_auto (H5E_DEFAULT, h5_errors, NULL); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* * Cause the library to emit some diagnostics early so they don't diff --git a/test/lheap.c b/test/lheap.c index 6389a33..9e70848 100644 --- a/test/lheap.c +++ b/test/lheap.c @@ -74,12 +74,20 @@ main(void) goto error; if (NULL==(f=H5I_object(file))) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5HL_create(f, H5P_DATASET_XFER_DEFAULT, 0, &heap_addr/*out*/)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } for (i = 0; i < NOBJS; i++) { @@ -90,7 +98,11 @@ main(void) if ((size_t)(-1)==(obj[i]=H5HL_insert(f, H5P_DATASET_XFER_DEFAULT, heap_addr, strlen(buf)+1, buf))) { H5_FAILED(); - H5Eprint(H5E_DEFAULT, stdout); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else + H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } } @@ -106,7 +118,11 @@ main(void) if ((file=H5Fopen(filename, H5F_ACC_RDONLY, fapl))<0) goto error; if (NULL==(f=H5I_object(file))) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } for (i=0; i<NOBJS; i++) { @@ -118,13 +134,21 @@ main(void) if (NULL == (heap = H5HL_protect(f, H5P_DATASET_XFER_DEFAULT, heap_addr))) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (NULL == (s = H5HL_offset_into(f, heap, obj[i]))) { H5_FAILED(); - H5Eprint(H5E_DEFAULT, stdout); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else + H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } @@ -138,7 +162,11 @@ main(void) if (H5HL_unprotect(f, H5P_DATASET_XFER_DEFAULT, heap, heap_addr) < 0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } } diff --git a/test/ohdr.c b/test/ohdr.c index 3d679f0..1e60e2d 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -74,7 +74,11 @@ main(void) if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) goto error; if (NULL==(f=H5I_object(file))) { +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } @@ -85,7 +89,11 @@ main(void) HDmemset(&oh_ent,0,sizeof(H5G_entry_t)); if (H5O_create(f, H5P_DATASET_XFER_DEFAULT, 64, &oh_ent/*out*/)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } PASSED(); @@ -96,17 +104,29 @@ main(void) stab.heap_addr = 22222222; if (H5O_modify(&oh_ent, H5O_STAB_ID, H5O_NEW_MESG, 0, 1, &stab, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, TRUE)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (NULL==H5O_read(&oh_ent, H5O_STAB_ID, 0, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5F_addr_ne(ro.btree_addr, stab.btree_addr) || @@ -128,17 +148,29 @@ main(void) stab.heap_addr = 44444444; if (H5O_modify(&oh_ent, H5O_STAB_ID, 0, 0, 1, &stab, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, TRUE)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (NULL==H5O_read(&oh_ent, H5O_STAB_ID, 0, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5F_addr_ne(ro.btree_addr, stab.btree_addr) || @@ -161,17 +193,29 @@ main(void) stab.heap_addr = 66666666; if (H5O_modify(&oh_ent, H5O_STAB_ID, H5O_NEW_MESG, 0, 1, &stab, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, TRUE)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (NULL==H5O_read(&oh_ent, H5O_STAB_ID, 1, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5F_addr_ne(ro.btree_addr, stab.btree_addr) || @@ -193,17 +237,29 @@ main(void) stab.heap_addr = 88888888; if (H5O_modify(&oh_ent, H5O_STAB_ID, 1, 0, 1, &stab, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, TRUE)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (NULL==H5O_read(&oh_ent, H5O_STAB_ID, 1, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5F_addr_ne(ro.btree_addr, stab.btree_addr) || @@ -227,13 +283,21 @@ main(void) stab.heap_addr = (i+1)*1000+2; if (H5O_modify(&oh_ent, H5O_STAB_ID, H5O_NEW_MESG, 0, 1, &stab, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); - H5Eprint(H5E_DEFAULT, stdout); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else + H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } } if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, TRUE)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } PASSED(); @@ -248,12 +312,20 @@ main(void) stab.heap_addr = (i + 1) * 1000 + 20; if (H5O_modify(&oh_ent, H5O_STAB_ID, H5O_NEW_MESG, 0, 1, &stab, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); - H5Eprint(H5E_DEFAULT, stdout); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else + H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, TRUE)<0) { H5_FAILED(); - H5Eprint(H5E_DEFAULT, stdout); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else + H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } } @@ -265,13 +337,21 @@ main(void) TESTING("message deletion"); if (H5O_remove(&oh_ent, H5O_STAB_ID, H5O_ALL, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5O_read(&oh_ent, H5O_STAB_ID, 0, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); puts(" H5O_read() should have failed but didn't"); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } PASSED(); @@ -281,7 +361,11 @@ main(void) TESTING("object header closing"); if (H5O_close(&oh_ent)<0) { H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } if (H5Fclose(file)<0) goto error; diff --git a/test/testfiles/err_compat_1 b/test/testfiles/err_compat_1 new file mode 100644 index 0000000..2fd82e2 --- /dev/null +++ b/test/testfiles/err_compat_1 @@ -0,0 +1,20 @@ +############################# +Expected output for err_compat +############################# +Testing error API based on data I/O All error API tests passed. + This program tests the Error API compatible with HDF5 v1.6. There're supposed to be some error messages +********* Print error stack in HDF5 default way ********* +HDF5-DIAG: Error detected in HDF5 (1.7.5) thread 0: + #000: ../../hdf5/test/err_compat.c line 268 in main(): Error test failed + major: Error API + minor: Bad value + +********* Print error stack in customized way ********* + error #000: ../../hdf5/test/err_compat.c in main(): line 268 + major: Error API + minor: Bad value + +HDF5-DIAG: Error detected in HDF5 (1.7.5) thread 0: + #000: ../../hdf5/test/err_compat.c line 280 in main(): Error test failed + major: Error API + minor: Unrecognized message diff --git a/test/testfiles/err_compat_2 b/test/testfiles/err_compat_2 new file mode 100644 index 0000000..be6c40d --- /dev/null +++ b/test/testfiles/err_compat_2 @@ -0,0 +1,4 @@ +############################# +Expected output for err_compat +############################# +Test skipped because backward compatbility with v1.6 is NOT configured in diff --git a/test/testfiles/error_test_1 b/test/testfiles/error_test_1 new file mode 100644 index 0000000..9a23e53 --- /dev/null +++ b/test/testfiles/error_test_1 @@ -0,0 +1,31 @@ +############################# +Expected output for error_test +############################# +Testing error API based on data I/O All error API tests passed. + This program tests the Error API. There're supposed to be some error messages +********* Print error stack in HDF5 default way ********* +Error Test-DIAG: Error detected in Error Program (1.0) thread 0: + #000: ../../hdf5/test/error_test.c line 272 in error_stack(): Get number test failed, returned 0 + major: Error in API + minor: Error in H5Eget_num + +********* Print error stack in customized way ********* + error #000: ../../hdf5/test/error_test.c in error_stack(): line 272 + class: Error Test + major: Error in API + minor: Error in H5Eget_num +HDF5-DIAG: Error detected in HDF5 (1.7.5) thread 0: + #000: ../../hdf5/src/H5Dio.c line 420 in H5Dwrite(): not a dataset + major: Invalid arguments to routine + minor: Inappropriate type +Error Test-DIAG: Error detected in Error Program (1.0) thread 0: + #000: ../../hdf5/test/error_test.c line 468 in main(): Error test failed, it's wrong + major: Error in test + minor: Error in subroutine + #001: ../../hdf5/test/error_test.c line 150 in test_error(): H5Dwrite failed as supposed to + major: Error in IO + minor: Error in H5Dwrite +HDF5-DIAG: Error detected in HDF5 (1.7.5) thread 0: + #002: ../../hdf5/src/H5Dio.c line 420 in H5Dwrite(): not a dataset + major: Invalid arguments to routine + minor: Inappropriate type diff --git a/test/testfiles/error_test_2 b/test/testfiles/error_test_2 new file mode 100644 index 0000000..f9d7317 --- /dev/null +++ b/test/testfiles/error_test_2 @@ -0,0 +1,4 @@ +############################# +Expected output for error_test +############################# +Test skipped because backward compatbility with v1.6 is configured in diff --git a/test/testhdf5.c b/test/testhdf5.c index 72c513d..175f711 100644 --- a/test/testhdf5.c +++ b/test/testhdf5.c @@ -153,7 +153,11 @@ main(int argc, char *argv[]) * half the functions this test calls are private, so automatic error * reporting wouldn't do much good since it's triggered at the API layer. */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eset_auto (NULL, NULL); +#else H5Eset_auto (H5E_DEFAULT, NULL, NULL); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Tests are generally arranged from least to most complexity... */ InitTest("configure", test_configure, cleanup_configure, "Configure definitions"); diff --git a/test/testhdf5.h b/test/testhdf5.h index 32cbaaa..f5e51e3 100644 --- a/test/testhdf5.h +++ b/test/testhdf5.h @@ -33,6 +33,81 @@ extern int Verbosity; /* Use %ld to print the value because long should cover most cases. */ /* Used to make certain a return value _is_not_ a value */ +#ifdef H5_WANT_H5_V1_6_COMPAT +#define CHECK(ret, val, where) do { \ + if (Verbosity>9) print_func(" Call to routine: %15s at line %4d " \ + "in %s returned %ld \n", \ + where, (int)__LINE__, __FILE__, \ + (long)(ret)); \ + if ((ret) == (val)) { \ + print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ + "in %s\n", where, (long)(ret), (int)__LINE__, __FILE__); \ + num_errs++; \ + H5Eprint (stdout); \ + } \ + H5Eclear(); \ +} while(0) + +#define CHECK_I(ret,where) { \ + if (Verbosity>9) { \ + print_func(" Call to routine: %15s at line %4d in %s returned %ld\n", \ + (where), (int)__LINE__, __FILE__, (long)(ret)); \ + } \ + if ((ret)<0) { \ + print_func ("*** UNEXPECTED RETURN from %s is %ld line %4d in %s\n", \ + (where), (long)(ret), (int)__LINE__, __FILE__); \ + H5Eprint (stdout); \ + num_errs++; \ + } \ + H5Eclear (); \ +} + +#define CHECK_PTR(ret,where) { \ + if (Verbosity>9) { \ + print_func(" Call to routine: %15s at line %4d in %s returned %p\n", \ + (where), (int)__LINE__, __FILE__, (ret)); \ + } \ + if (!(ret)) { \ + print_func ("*** UNEXPECTED RETURN from %s is NULL line %4d in %s\n", \ + (where), (int)__LINE__, __FILE__); \ + H5Eprint (stdout); \ + num_errs++; \ + } \ + H5Eclear (); \ +} + +/* Used to make certain a return value _is_ a value */ +#define VERIFY(x, val, where) do { \ + if (Verbosity>9) { \ + print_func(" Call to routine: %15s at line %4d in %s had value " \ + "%ld \n", (where), (int)__LINE__, __FILE__, (long)(x)); \ + } \ + if ((x) != (val)) { \ + print_func("*** UNEXPECTED VALUE from %s should be %ld, but is %ld at line %4d " \ + "in %s\n", (where), (long)(val), (long)(x), (int)__LINE__, __FILE__); \ + H5Eprint (stdout); \ + num_errs++; \ + } \ + H5Eclear(); \ +} while(0) + +/* Used to document process through a test and to check for errors */ +#define RESULT(ret,func) do { \ + if (Verbosity>8) { \ + print_func(" Call to routine: %15s at line %4d in %s returned " \ + "%ld\n", func, (int)__LINE__, __FILE__, (long)(ret)); \ + } \ + if (Verbosity>9) HEprint(stdout, 0); \ + if ((ret) == FAIL) { \ + print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ + "in %s\n", func, (long)(ret), (int)__LINE__, __FILE__); \ + H5Eprint (stdout); \ + num_errs++; \ + } \ + H5Eclear(); \ +} while(0) + +#else #define CHECK(ret, val, where) do { \ if (Verbosity>9) print_func(" Call to routine: %15s at line %4d " \ "in %s returned %ld \n", \ @@ -106,6 +181,8 @@ extern int Verbosity; H5Eclear(H5E_DEFAULT); \ } while(0) +#endif /* H5_WANT_H5_V1_6_COMPAT */ + /* Used to document process through a test */ #define MESSAGE(V,A) {if (Verbosity>(V)) print_func A;} diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index c0841cc..37c67a2 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -2767,8 +2767,13 @@ main(int argc, const char *argv[]) dump_function_table = &ddl_function_table; /* Disable error reporting */ +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eget_auto(&func, &edata); + H5Eset_auto(NULL, NULL); +#else H5Eget_auto(H5E_DEFAULT, &func, &edata); H5Eset_auto(H5E_DEFAULT, NULL, NULL); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Initialize h5tools lib */ h5tools_init(); @@ -2981,7 +2986,11 @@ done: /* To Do: clean up XML table */ h5tools_close(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eset_auto(func, edata); +#else H5Eset_auto(H5E_DEFAULT, func, edata); +#endif /* H5_WANT_H5_V1_6_COMPAT */ return d_status; } diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index 0cb64fe..0ee57ed 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -2137,7 +2137,11 @@ main (int argc, char *argv[]) } /* Turn off HDF5's automatic error printing unless you're debugging h5ls */ +#ifdef H5_WANT_H5_V1_6_COMPAT + if (!show_errors_g) H5Eset_auto(NULL, NULL); +#else if (!show_errors_g) H5Eset_auto(H5E_DEFAULT, NULL, NULL); +#endif /* H5_WANT_H5_V1_6_COMPAT */ /* Each remaining argument is an hdf5 file followed by an optional slash |