From 7e79a8d71e6a579710e0fc2c677dfc32336d058f Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Wed, 24 Sep 2003 14:26:50 -0500 Subject: [svn-r7507] *** empty log message *** --- perform/overhead.c | 11 +- release_docs/RELEASE.txt | 2 + src/H5.c | 4 + src/H5E.c | 392 +++++++++++++++++++++++++++++++++-- src/H5Epublic.h | 65 +++++- src/H5FDmulti.c | 104 ++++++++++ src/H5FDstdio.c | 50 ++++- test/Dependencies | 4 +- test/Makefile.in | 26 ++- test/dtypes.c | 2 +- test/enum.c | 5 + test/err_compat.c | 295 ++++++++++++++++++++++++++ test/error_test.c | 489 ++++++++++++++++++++++++++++++++++++++++++++ test/errors.c | 481 ------------------------------------------- test/gheap.c | 42 +++- test/h5test.c | 9 + test/lheap.c | 32 ++- test/ohdr.c | 90 +++++++- test/testfiles/err_compat_1 | 20 ++ test/testfiles/err_compat_2 | 4 + test/testfiles/error_test_1 | 31 +++ test/testfiles/error_test_2 | 4 + test/testhdf5.c | 4 + test/testhdf5.h | 77 +++++++ tools/h5dump/h5dump.c | 9 + tools/h5ls/h5ls.c | 4 + 26 files changed, 1728 insertions(+), 528 deletions(-) create mode 100644 test/err_compat.c create mode 100644 test/error_test.c delete mode 100644 test/errors.c create mode 100644 test/testfiles/err_compat_1 create mode 100644 test/testfiles/err_compat_2 create mode 100644 test/testfiles/error_test_1 create mode 100644 test/testfiles/error_test_2 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]' diff --git a/src/H5.c b/src/H5.c index 9fa3186..a9b9859 100644 --- a/src/H5.c +++ b/src/H5.c @@ -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 diff --git a/src/H5E.c b/src/H5E.c index 8bc4803..8b02723 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -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; mtfa.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; mtmemb_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; mtmemb_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; mtmemb[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; mtfa.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; mtmemb_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/error_test.c b/test/error_test.c new file mode 100644 index 0000000..7e45f3d --- /dev/null +++ b/test/error_test.c @@ -0,0 +1,489 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 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 +}; + +#define DIM0 100 +#define DIM1 200 + +int ipoints2[DIM0][DIM1], icheck2[DIM0][DIM1]; + +hid_t ERR_CLS; +hid_t ERR_STACK; + +hid_t ERR_MAJ_TEST; +hid_t ERR_MAJ_IO; +hid_t ERR_MAJ_API; + +hid_t ERR_MIN_SUBROUTINE; +hid_t ERR_MIN_ERRSTACK; +hid_t ERR_MIN_CREATE; +hid_t ERR_MIN_WRITE; +hid_t ERR_MIN_GETNUM; + +#define DSET_NAME "a_dataset" +#define FAKE_ID 0 + +#define ERR_CLS_NAME "Error Test" +#define PROG_NAME "Error Program" +#define PROG_VERS "1.0" + +#define ERR_MAJ_TEST_MSG "Error in test" +#define ERR_MAJ_IO_MSG "Error in IO" +#define ERR_MAJ_API_MSG "Error in API" +#define ERR_MIN_SUBROUTINE_MSG "Error in subroutine" +#define ERR_MIN_ERRSTACK_MSG "Error in error stack" +#define ERR_MIN_CREATE_MSG "Error in H5Dcreate" +#define ERR_MIN_WRITE_MSG "Error in H5Dwrite" +#define ERR_MIN_GETNUM_MSG "Error in H5Eget_num" + +#define MSG_SIZE 64 +#define SPACE1_DIM1 4 +#define SPACE1_RANK 1 +#define SPACE2_RANK 2 +#define SPACE2_DIM1 10 +#define SPACE2_DIM2 10 + +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: + * + *------------------------------------------------------------------------- + */ +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"); + + /* 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(H5E_DEFAULT, __FILE__, FUNC_test_error, __LINE__, ERR_CLS, ERR_MAJ_IO, ERR_MIN_CREATE, + "H5Dcreate failed"); + goto error; + } + + /* Test enabling and disabling default printing */ + if (H5Eget_auto(H5E_DEFAULT, &old_func, &old_data)<0) + TEST_ERROR; + if (old_data != NULL) + TEST_ERROR; + if (old_func != (H5E_auto_t)H5Eprint) + TEST_ERROR; + + if(H5Eset_auto(H5E_DEFAULT, NULL, NULL)<0) + TEST_ERROR; + + /* Make H5Dwrite fail, verify default print is disabled */ + if (H5Dwrite(FAKE_ID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2)>=0) { + H5Epush(H5E_DEFAULT, __FILE__, FUNC_test_error, __LINE__, ERR_CLS, ERR_MAJ_IO, ERR_MIN_WRITE, + "H5Dwrite shouldn't succeed"); + goto error; + } + + if(H5Eset_auto(H5E_DEFAULT, old_func, old_data)<0) + TEST_ERROR; + + /* Test saving and restoring the current error stack */ + if (H5Dwrite(FAKE_ID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2)<0) { + H5Epush(H5E_DEFAULT, __FILE__, FUNC_test_error, __LINE__, ERR_CLS, ERR_MAJ_IO, ERR_MIN_WRITE, + "H5Dwrite failed as supposed to"); + estack_id = H5Eget_current_stack(); + H5Dclose(dataset); + H5Sclose(space); + H5Eset_current_stack(estack_id); + goto error; + } + + /* In case program comes to this point, close dataset */ + if(H5Dclose(dataset)<0) TEST_ERROR; + + TEST_ERROR; + + error: + return -1; +} + + +/*------------------------------------------------------------------------- + * Function: init_error + * + * Purpose: Initialize error information. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Raymond Lu + * July 10, 2003 + * + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +init_error(void) +{ + ssize_t cls_size = strlen(ERR_CLS_NAME)+1; + char *cls_name = malloc(strlen(ERR_CLS_NAME)+1); + ssize_t msg_size = strlen(ERR_MIN_SUBROUTINE_MSG) + 1; + char *msg = malloc(strlen(ERR_MIN_SUBROUTINE_MSG)+1); + H5E_type_t *msg_type= malloc(sizeof(H5E_type_t)); + + if((ERR_CLS = H5Eregister_class(ERR_CLS_NAME, PROG_NAME, PROG_VERS))<0) + TEST_ERROR; + + if(cls_size != H5Eget_class_name(ERR_CLS, cls_name, (size_t)cls_size) + 1) + TEST_ERROR; + if(strcmp(ERR_CLS_NAME, cls_name)) + TEST_ERROR; + + if((ERR_MAJ_TEST = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_TEST_MSG))<0) + TEST_ERROR; + if((ERR_MAJ_IO = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_IO_MSG))<0) + TEST_ERROR; + if((ERR_MAJ_API = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_API_MSG))<0) + TEST_ERROR; + + if((ERR_MIN_SUBROUTINE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_SUBROUTINE_MSG))<0) + TEST_ERROR; + if((ERR_MIN_ERRSTACK = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_ERRSTACK_MSG))<0) + TEST_ERROR; + if((ERR_MIN_CREATE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_CREATE_MSG))<0) + TEST_ERROR; + if((ERR_MIN_WRITE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_WRITE_MSG))<0) + TEST_ERROR; + if((ERR_MIN_GETNUM = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_GETNUM_MSG))<0) + TEST_ERROR; + + if(msg_size != H5Eget_msg(ERR_MIN_SUBROUTINE, msg_type, msg, (size_t)msg_size) + 1) + TEST_ERROR; + if(*msg_type != H5E_MINOR) + TEST_ERROR; + if(strcmp(msg, ERR_MIN_SUBROUTINE_MSG)) + TEST_ERROR; + + free(cls_name); + free(msg); + free(msg_type); + + return 0; + + error: + return -1; +} + + +/*------------------------------------------------------------------------- + * Function: error_stack + * + * Purpose: Manipulates current error stack. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Raymond Lu + * July 14, 2003 + * + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +error_stack(void) +{ + int err_num; + const char *FUNC_error_stack="error_stack"; + + if((err_num = H5Eget_num(H5E_DEFAULT))<0) + TEST_ERROR; + if(err_num) + TEST_ERROR; + + if((ERR_STACK = H5Eget_current_stack())<0) + TEST_ERROR; + + /* Make it push error, force this function to fail */ + if((err_num = H5Eget_num(ERR_STACK))==0) { + H5Epush(ERR_STACK, __FILE__, FUNC_error_stack, __LINE__, ERR_CLS, ERR_MAJ_API, ERR_MIN_GETNUM, + "Get number test failed, returned %d", err_num); + goto error; + } + + /* In case program falls through here, close the stack and let it fail. */ + if(H5Eclose_stack(ERR_STACK)<0) + TEST_ERROR; + + return -1; + + error: + 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(hid_t estack) +{ + /* Print errors in library default way */ + fprintf(stderr, "********* Print error stack in HDF5 default way *********\n"); + if(H5Eprint(estack, stderr)<0) + TEST_ERROR; + + /* Customized way to print errors */ + fprintf(stderr, "\n********* Print error stack in customized way *********\n"); + if(H5Ewalk(estack, 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[MSG_SIZE]; + char min[MSG_SIZE]; + char cls[MSG_SIZE]; + const int indent = 4; + + /* Get descriptions for the major and minor error numbers */ + if(H5Eget_class_name(err_desc->cls_id, cls, MSG_SIZE)<0) + TEST_ERROR; + + if(H5Eget_msg(err_desc->maj_num, NULL, maj, MSG_SIZE)<0) + TEST_ERROR; + + if(H5Eget_msg(err_desc->min_num, NULL, min, MSG_SIZE)<0) + 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, "%*sclass: %s\n", indent*2, "", cls); + fprintf (stream, "%*smajor: %s\n", indent*2, "", maj); + fprintf (stream, "%*sminor: %s\n", indent*2, "", min); + + return 0; + + error: + return -1; +} + + +/*------------------------------------------------------------------------- + * Function: close_error + * + * Purpose: Closes error information. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Raymond Lu + * July 10, 2003 + * + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +close_error(void) +{ + /* Close major errors, let H5Eunregister_class close minor errors */ + if(H5Eclose_msg(ERR_MAJ_TEST)<0) + TEST_ERROR ; + + if(H5Eclose_msg(ERR_MAJ_IO)<0) + TEST_ERROR ; + + if(H5Eclose_msg(ERR_MAJ_API)<0) + TEST_ERROR ; + + if(H5Eunregister_class(ERR_CLS)<0) + TEST_ERROR ; + + 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; + hid_t estack_id; + char filename[1024]; + const char *FUNC_main="main"; + + fprintf(stderr, " This program tests the Error API. There're supposed to be some error messages\n"); + /*h5_reset();*/ + + /* Initialize errors */ + if(init_error()<0) + TEST_ERROR ; + + 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(ERR_STACK, __FILE__, FUNC_main, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_ERRSTACK, + "Error stack test failed"); + + /* Delete an error from the top of error stack */ + H5Epop(ERR_STACK, 1); + + /* Print out the errors on stack */ + dump_error(ERR_STACK); + + /* Empty error stack */ + H5Eclear(ERR_STACK); + + /* Close error stack */ + H5Eclose_stack(ERR_STACK); + } + + /* Test error API */ + if(test_error(file)<0) { + H5Epush(H5E_DEFAULT, __FILE__, FUNC_main, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, + "Error test failed, %s", "it's wrong"); + estack_id = H5Eget_current_stack(); + H5Eprint(estack_id, stderr); + H5Eclose_stack(estack_id); + } + + if (H5Fclose(file)<0) TEST_ERROR ; + h5_cleanup(FILENAME, fapl); + + /* Close error information */ + if(close_error()<0) + TEST_ERROR ; + + 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/errors.c deleted file mode 100644 index 3c40026..0000000 --- a/test/errors.c +++ /dev/null @@ -1,481 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * 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 the H5Tget_native_type function. - */ - -#include "h5test.h" - -const char *FILENAME[] = { - "errors", - NULL -}; - -#define DIM0 100 -#define DIM1 200 - -int ipoints2[DIM0][DIM1], icheck2[DIM0][DIM1]; - -hid_t ERR_CLS; -hid_t ERR_STACK; - -hid_t ERR_MAJ_TEST; -hid_t ERR_MAJ_IO; -hid_t ERR_MAJ_API; - -hid_t ERR_MIN_SUBROUTINE; -hid_t ERR_MIN_ERRSTACK; -hid_t ERR_MIN_CREATE; -hid_t ERR_MIN_WRITE; -hid_t ERR_MIN_GETNUM; - -#define DSET_NAME "a_dataset" -#define FAKE_ID 0 - -#define ERR_CLS_NAME "Error Test" -#define PROG_NAME "Error Program" -#define PROG_VERS "1.0" - -#define ERR_MAJ_TEST_MSG "Error in test" -#define ERR_MAJ_IO_MSG "Error in IO" -#define ERR_MAJ_API_MSG "Error in API" -#define ERR_MIN_SUBROUTINE_MSG "Error in subroutine" -#define ERR_MIN_ERRSTACK_MSG "Error in error stack" -#define ERR_MIN_CREATE_MSG "Error in H5Dcreate" -#define ERR_MIN_WRITE_MSG "Error in H5Dwrite" -#define ERR_MIN_GETNUM_MSG "Error in H5Eget_num" - -#define MSG_SIZE 64 -#define SPACE1_DIM1 4 -#define SPACE1_RANK 1 -#define SPACE2_RANK 2 -#define SPACE2_DIM1 10 -#define SPACE2_DIM2 10 - -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: - * - *------------------------------------------------------------------------- - */ -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"); - - /* 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(H5E_DEFAULT, __FILE__, FUNC_test_error, __LINE__, ERR_CLS, ERR_MAJ_IO, ERR_MIN_CREATE, - "H5Dcreate failed"); - goto error; - } - - /* Test enabling and disabling default printing */ - if (H5Eget_auto(H5E_DEFAULT, &old_func, &old_data)<0) - TEST_ERROR; - if (old_data != NULL) - TEST_ERROR; - if (old_func != (H5E_auto_t)H5Eprint) - TEST_ERROR; - - if(H5Eset_auto(H5E_DEFAULT, NULL, NULL)<0) - TEST_ERROR; - - /* Make H5Dwrite fail, verify default print is disabled */ - if (H5Dwrite(FAKE_ID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2)>=0) { - H5Epush(H5E_DEFAULT, __FILE__, FUNC_test_error, __LINE__, ERR_CLS, ERR_MAJ_IO, ERR_MIN_WRITE, - "H5Dwrite shouldn't succeed"); - goto error; - } - - if(H5Eset_auto(H5E_DEFAULT, old_func, old_data)<0) - TEST_ERROR; - - /* Test saving and restoring the current error stack */ - if (H5Dwrite(FAKE_ID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2)<0) { - H5Epush(H5E_DEFAULT, __FILE__, FUNC_test_error, __LINE__, ERR_CLS, ERR_MAJ_IO, ERR_MIN_WRITE, - "H5Dwrite failed as supposed to"); - estack_id = H5Eget_current_stack(); - H5Dclose(dataset); - H5Sclose(space); - H5Eset_current_stack(estack_id); - goto error; - } - - /* In case program comes to this point, close dataset */ - if(H5Dclose(dataset)<0) TEST_ERROR; - - TEST_ERROR; - - error: - return -1; -} - - -/*------------------------------------------------------------------------- - * Function: init_error - * - * Purpose: Initialize error information. - * - * Return: Success: 0 - * - * Failure: -1 - * - * Programmer: Raymond Lu - * July 10, 2003 - * - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -init_error(void) -{ - ssize_t cls_size = strlen(ERR_CLS_NAME)+1; - char *cls_name = malloc(strlen(ERR_CLS_NAME)+1); - ssize_t msg_size = strlen(ERR_MIN_SUBROUTINE_MSG) + 1; - char *msg = malloc(strlen(ERR_MIN_SUBROUTINE_MSG)+1); - H5E_type_t *msg_type= malloc(sizeof(H5E_type_t)); - - if((ERR_CLS = H5Eregister_class(ERR_CLS_NAME, PROG_NAME, PROG_VERS))<0) - TEST_ERROR; - - if(cls_size != H5Eget_class_name(ERR_CLS, cls_name, (size_t)cls_size) + 1) - TEST_ERROR; - if(strcmp(ERR_CLS_NAME, cls_name)) - TEST_ERROR; - - if((ERR_MAJ_TEST = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_TEST_MSG))<0) - TEST_ERROR; - if((ERR_MAJ_IO = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_IO_MSG))<0) - TEST_ERROR; - if((ERR_MAJ_API = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_API_MSG))<0) - TEST_ERROR; - - if((ERR_MIN_SUBROUTINE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_SUBROUTINE_MSG))<0) - TEST_ERROR; - if((ERR_MIN_ERRSTACK = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_ERRSTACK_MSG))<0) - TEST_ERROR; - if((ERR_MIN_CREATE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_CREATE_MSG))<0) - TEST_ERROR; - if((ERR_MIN_WRITE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_WRITE_MSG))<0) - TEST_ERROR; - if((ERR_MIN_GETNUM = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_GETNUM_MSG))<0) - TEST_ERROR; - - if(msg_size != H5Eget_msg(ERR_MIN_SUBROUTINE, msg_type, msg, (size_t)msg_size) + 1) - TEST_ERROR; - if(*msg_type != H5E_MINOR) - TEST_ERROR; - if(strcmp(msg, ERR_MIN_SUBROUTINE_MSG)) - TEST_ERROR; - - free(cls_name); - free(msg); - free(msg_type); - - return 0; - - error: - return -1; -} - - -/*------------------------------------------------------------------------- - * Function: error_stack - * - * Purpose: Manipulates current error stack. - * - * Return: Success: 0 - * - * Failure: -1 - * - * Programmer: Raymond Lu - * July 14, 2003 - * - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -error_stack(void) -{ - int err_num; - const char *FUNC_error_stack="error_stack"; - - if((err_num = H5Eget_num(H5E_DEFAULT))<0) - TEST_ERROR; - if(err_num) - TEST_ERROR; - - if((ERR_STACK = H5Eget_current_stack())<0) - TEST_ERROR; - - /* Make it push error, force this function to fail */ - if((err_num = H5Eget_num(ERR_STACK))==0) { - H5Epush(ERR_STACK, __FILE__, FUNC_error_stack, __LINE__, ERR_CLS, ERR_MAJ_API, ERR_MIN_GETNUM, - "Get number test failed, returned %d", err_num); - goto error; - } - - /* In case program falls through here, close the stack and let it fail. */ - if(H5Eclose_stack(ERR_STACK)<0) - TEST_ERROR; - - return -1; - - error: - 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(hid_t estack) -{ - /* Print errors in library default way */ - fprintf(stderr, "********* Print error stack in HDF5 default way *********\n"); - if(H5Eprint(estack, stderr)<0) - TEST_ERROR; - - /* Customized way to print errors */ - fprintf(stderr, "\n********* Print error stack in customized way *********\n"); - if(H5Ewalk(estack, 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[MSG_SIZE]; - char min[MSG_SIZE]; - char cls[MSG_SIZE]; - const int indent = 4; - - /* Get descriptions for the major and minor error numbers */ - 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) - TEST_ERROR; - - if(H5Eget_msg(err_desc->min_id, NULL, min, MSG_SIZE)<0) - 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, "%*sclass: %s\n", indent*2, "", cls); - fprintf (stream, "%*smajor: %s\n", indent*2, "", maj); - fprintf (stream, "%*sminor: %s\n", indent*2, "", min); - - return 0; - - error: - return -1; -} - - -/*------------------------------------------------------------------------- - * Function: close_error - * - * Purpose: Closes error information. - * - * Return: Success: 0 - * - * Failure: -1 - * - * Programmer: Raymond Lu - * July 10, 2003 - * - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -close_error(void) -{ - /* Close major errors, let H5Eunregister_class close minor errors */ - if(H5Eclose_msg(ERR_MAJ_TEST)<0) - TEST_ERROR ; - - if(H5Eclose_msg(ERR_MAJ_IO)<0) - TEST_ERROR ; - - if(H5Eclose_msg(ERR_MAJ_API)<0) - TEST_ERROR ; - - if(H5Eunregister_class(ERR_CLS)<0) - TEST_ERROR ; - - 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; - hid_t estack_id; - char filename[1024]; - const char *FUNC_main="main"; - - fprintf(stderr, " This program tests the Error API. There're supposed to be some error messages\n"); - /*h5_reset();*/ - - /* Initialize errors */ - if(init_error()<0) - TEST_ERROR ; - - 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(ERR_STACK, __FILE__, FUNC_main, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_ERRSTACK, - "Error stack test failed"); - - /* Delete an error from the top of error stack */ - H5Epop(ERR_STACK, 1); - - /* Print out the errors on stack */ - dump_error(ERR_STACK); - - /* Empty error stack */ - H5Eclear(ERR_STACK); - - /* Close error stack */ - H5Eclose_stack(ERR_STACK); - } - - /* Test error API */ - if(test_error(file)<0) { - H5Epush(H5E_DEFAULT, __FILE__, FUNC_main, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, - "Error test failed, %s", "it's wrong"); - estack_id = H5Eget_current_stack(); - H5Eprint(estack_id, stderr); - H5Eclose_stack(estack_id); - } - - if (H5Fclose(file)<0) TEST_ERROR ; - h5_cleanup(FILENAME, fapl); - - /* Close error information */ - if(close_error()<0) - TEST_ERROR ; - - printf("All error API tests passed.\n"); - return 0; - - error: - printf("***** ERROR TEST FAILED! *****\n"); - return 1; -} 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; i9) 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 -- cgit v0.12