diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2010-10-11 22:15:54 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2010-10-11 22:15:54 (GMT) |
commit | 233741567405cb6a983399b19ae298fd9211e124 (patch) | |
tree | b66bc71f7fde9dc125718b58978b6eb85b1bbc78 | |
parent | 293e541644a9c5bc98067d8050f70c8e629eea5d (diff) | |
parent | 9df4fe0a8787dd2e7a24c0b8fa5624dc00a18676 (diff) | |
download | hdf5-233741567405cb6a983399b19ae298fd9211e124.zip hdf5-233741567405cb6a983399b19ae298fd9211e124.tar.gz hdf5-233741567405cb6a983399b19ae298fd9211e124.tar.bz2 |
[svn-r19578] Bug fix for 1707 - H5Eset_auto causes a seg fault when an application uses -DH5_USE_16_API
with the 1.8 library to compile. The cause is from the mismatch of H5Eprint1 and H5Eprint2
set through H5Eset_auto. I changed the structure H5E_auto_t. I added a IS_DEDAULT flag in
it. Both H5Eprint1/2 are the default now. If the user sets his/her own printing function.
Then a call to H5Eget_auto1/2 will have to match H5Eset_auto1/2.
Tested on heiwa, jam, and amani.
The property change in configure.in, config, and Makefile.am came from the merge of the 1.8
library change.
-rw-r--r-- | src/H5E.c | 51 | ||||
-rw-r--r-- | src/H5Edeprec.c | 26 | ||||
-rw-r--r-- | src/H5Eint.c | 18 | ||||
-rw-r--r-- | src/H5Epkg.h | 19 | ||||
-rw-r--r-- | test/err_compat.c | 394 | ||||
-rw-r--r-- | test/testerror.sh.in | 2 | ||||
-rw-r--r-- | test/testfiles/err_compat_1 | 40 |
7 files changed, 446 insertions, 104 deletions
@@ -170,13 +170,21 @@ H5E_set_default_auto(H5E_t *stk) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_set_default_auto) -#ifdef H5_USE_16_API +#ifndef H5_NO_DEPRECATED_SYMBOLS +#ifdef H5_USE_16_API_DEFAULT stk->auto_op.vers = 1; stk->auto_op.u.func1 = (H5E_auto1_t)H5Eprint1; #else /* H5_USE_16_API */ stk->auto_op.vers = 2; - stk->auto_op.u.func2 = (H5E_auto2_t)H5Eprint2; -#endif /* H5_USE_16_API */ +#endif /* H5_USE_16_API_DEFAULT */ + + stk->auto_op.func1 = stk->auto_op.func1_default = (H5E_auto1_t)H5Eprint1; + stk->auto_op.func2 = stk->auto_op.func2_default = (H5E_auto2_t)H5Eprint2; + stk->auto_op.is_default = TRUE; +#else /* H5_NO_DEPRECATED_SYMBOLS */ + stk->auto_op.func2 = (H5E_auto2_t)H5Eprint2; +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + stk->auto_data = NULL; FUNC_LEAVE_NOAPI(SUCCEED) @@ -1555,6 +1563,11 @@ done: * Programmer: Robb Matzke * Saturday, February 28, 1998 * + * Modification:Raymond Lu + * 4 October 2010 + * If the printing function isn't the default H5Eprint1 or 2, + * and H5Eset_auto1 has been called to set the old style + * printing function, a call to H5Eget_auto2 should fail. *------------------------------------------------------------------------- */ herr_t @@ -1578,8 +1591,15 @@ H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data) /* Get the automatic error reporting information */ if(H5E_get_auto(estack, &op, client_data) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") + +#ifndef H5_NO_DEPRECATED_SYMBOLS + /* Fail if the printing function isn't the default(user-set) and set through H5Eset_auto1 */ + if(!op.is_default && op.vers == 1) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "wrong API function, H5Eset_auto1 has been called") +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + if(func) - *func = op.u.func2; + *func = op.func2; done: FUNC_LEAVE_API(ret_value) @@ -1606,6 +1626,9 @@ done: * Programmer: Robb Matzke * Friday, February 27, 1998 * + * Modification:Raymond Lu + * 4 October 2010 + * If the FUNC is H5Eprint2, put the IS_DEFAULT flag on. *------------------------------------------------------------------------- */ herr_t @@ -1627,9 +1650,23 @@ H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data) if(NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") +#ifndef H5_NO_DEPRECATED_SYMBOLS + /* Get the automatic error reporting information */ + if(H5E_get_auto(estack, &op, NULL) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") + /* Set the automatic error reporting information */ + if(func != op.func2_default) + op.is_default = FALSE; + else + op.is_default = TRUE; + op.vers = 2; - op.u.func2 = func; +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + /* Set the automatic error reporting function */ + op.func2 = func; + if(H5E_set_auto(estack, &op, client_data) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set automatic error info") @@ -1672,7 +1709,11 @@ H5Eauto_is_v2(hid_t estack_id, unsigned *is_stack) /* Check if the error stack reporting function is the "newer" stack type */ if(is_stack) +#ifndef H5_NO_DEPRECATED_SYMBOLS *is_stack = estack->auto_op.vers > 1; +#else + *is_stack = 1; +#endif done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Edeprec.c b/src/H5Edeprec.c index 30f3ae9..0a028d9 100644 --- a/src/H5Edeprec.c +++ b/src/H5Edeprec.c @@ -370,6 +370,11 @@ done: * Programmer: Raymond Lu * Sep 16, 2003 * + * Modification:Raymond Lu + * 4 October 2010 + * If the printing function isn't the default H5Eprint1 or 2, + * and H5Eset_auto2 has been called to set the new style + * printing function, a call to H5Eget_auto1 should fail. *------------------------------------------------------------------------- */ herr_t @@ -389,8 +394,13 @@ H5Eget_auto1(H5E_auto1_t *func, void **client_data) /* Get the automatic error reporting information */ if(H5E_get_auto(estack, &auto_op, client_data) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") + + /* Fail if the printing function isn't the default(user-set) and set through H5Eset_auto2 */ + if(!auto_op.is_default && auto_op.vers == 2) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "wrong API function, H5Eset_auto2 has been called") + if(func) - *func = auto_op.u.func1; + *func = auto_op.func1; done: FUNC_LEAVE_API(ret_value) @@ -418,6 +428,9 @@ done: * Programmer: Raymond Lu * Sep 16, 2003 * + * Modification:Raymond Lu + * 4 October 2010 + * If the FUNC is H5Eprint2, put the IS_DEFAULT flag on. *------------------------------------------------------------------------- */ herr_t @@ -434,9 +447,18 @@ H5Eset_auto1(H5E_auto1_t func, void *client_data) if(NULL == (estack = H5E_get_my_stack())) /*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, &auto_op, NULL) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info") + /* Set the automatic error reporting information */ auto_op.vers = 1; - auto_op.u.func1 = func; + if(func != auto_op.func1_default) + auto_op.is_default = FALSE; + else + auto_op.is_default = TRUE; + auto_op.func1 = func; + if(H5E_set_auto(estack, &auto_op, client_data) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set automatic error info") diff --git a/src/H5Eint.c b/src/H5Eint.c index 584ba40..f650581 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -1011,18 +1011,20 @@ H5E_dump_api_stack(hbool_t is_api) H5E_t *estack = H5E_get_my_stack(); HDassert(estack); + +#ifdef H5_NO_DEPRECATED_SYMBOLS + if(estack->auto_op.func2) + (void)((estack->auto_op.func2)(H5E_DEFAULT, estack->auto_data)); +#else /* H5_NO_DEPRECATED_SYMBOLS */ if(estack->auto_op.vers == 1) { -#ifndef H5_NO_DEPRECATED_SYMBOLS - if(estack->auto_op.u.func1) - (void)((estack->auto_op.u.func1)(estack->auto_data)); -#else /* H5_NO_DEPRECATED_SYMBOLS */ - HDassert(0 && "version 1 error stack dump without deprecated symbols!"); -#endif /* H5_NO_DEPRECATED_SYMBOLS */ + if(estack->auto_op.func1) + (void)((estack->auto_op.func1)(estack->auto_data)); } /* end if */ else { - if(estack->auto_op.u.func2) - (void)((estack->auto_op.u.func2)(H5E_DEFAULT, estack->auto_data)); + if(estack->auto_op.func2) + (void)((estack->auto_op.func2)(H5E_DEFAULT, estack->auto_data)); } /* end else */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ } /* end if */ done: diff --git a/src/H5Epkg.h b/src/H5Epkg.h index a85ddc9..9a1163a 100644 --- a/src/H5Epkg.h +++ b/src/H5Epkg.h @@ -68,15 +68,20 @@ /****************************/ /* Some syntactic sugar to make the compiler happy with two different kinds of callbacks */ -typedef struct { - unsigned vers; /* Which version callback to use */ - union { #ifndef H5_NO_DEPRECATED_SYMBOLS - H5E_auto1_t func1; /* Old-style callback, NO error stack param. */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - H5E_auto2_t func2; /* New-style callback, with error stack param. */ - }u; +typedef struct { + unsigned vers; /* Which version callback to use */ + hbool_t is_default; /* If the printing function is the library's own. */ + H5E_auto1_t func1; /* Old-style callback, NO error stack param. */ + H5E_auto2_t func2; /* New-style callback, with error stack param. */ + H5E_auto1_t func1_default; /* The saved library's default function - old style. */ + H5E_auto2_t func2_default; /* The saved library's default function - new style. */ +} H5E_auto_op_t; +#else /* H5_NO_DEPRECATED_SYMBOLS */ +typedef struct { + H5E_auto_t func2; /* Only the new style callback function is available. */ } H5E_auto_op_t; +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Some syntactic sugar to make the compiler happy with two different kinds of callbacks */ typedef struct { diff --git a/test/err_compat.c b/test/err_compat.c index be86a2d..c08e259 100644 --- a/test/err_compat.c +++ b/test/err_compat.c @@ -42,20 +42,187 @@ int ipoints2[DIM0][DIM1], icheck2[DIM0][DIM1]; #define DSET_NAME "a_dataset" #define FAKE_ID -1 -herr_t custom_print_cb(int n, H5E_error1_t *err_desc, void* client_data); +herr_t custom_print_cb1(int n, H5E_error1_t *err_desc, void* client_data); +herr_t custom_print_cb2(int n, H5E_error2_t *err_desc, void* client_data); /*------------------------------------------------------------------------- - * Function: test_error + * Function: user_print1 * - * Purpose: Test error API functions + * Purpose: This function is a user-defined old-style printing function. + * This is just a convenience function for H5Ewalk1() with a + * function that prints error messages. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * 4 October 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +user_print1(FILE *stream) +{ + /* Customized way to print errors */ + fprintf(stderr, "\n********* Print error stack in customized way *********\n"); + if(H5Ewalk1(H5E_WALK_UPWARD, (H5E_walk1_t)custom_print_cb1, stream) < 0) + TEST_ERROR; + + return 0; + + error: + return -1; + +} + + +/*------------------------------------------------------------------------- + * Function: user_print2 + * + * Purpose: This function is a user-defined new-style printing function. + * This is just a convenience function for H5Ewalk2() with a + * function that prints error messages. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * 4 October 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +user_print2(hid_t err_stack, FILE *stream) +{ + /* Customized way to print errors */ + fprintf(stderr, "\n********* Print error stack in customized way *********\n"); + if(H5Ewalk2(err_stack, H5E_WALK_UPWARD, (H5E_walk2_t)custom_print_cb2, stream) < 0) + TEST_ERROR; + + return 0; + + error: + return -1; + +} + + +/*------------------------------------------------------------------------- + * Function: custom_print_cb1 + * + * Purpose: Callback function to print error stack in customized way + * for H5Ewalk1. * * Return: Success: 0 * * Failure: -1 * * Programmer: Raymond Lu - * July 10, 2003 + * 4 October 2010 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +custom_print_cb1(int n, H5E_error1_t *err_desc, void* client_data) +{ + FILE *stream = (FILE *)client_data; + char *maj = NULL; + char *min = NULL; + const int indent = 4; + + if(NULL == (min = H5Eget_minor(err_desc->min_num))) + TEST_ERROR; + + if(NULL == (maj = H5Eget_major(err_desc->maj_num))) + 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); + + HDfree(maj); + HDfree(min); + + return 0; + +error: + if(maj) + HDfree(maj); + if(min) + HDfree(min); + + return -1; +} + + +/*------------------------------------------------------------------------- + * Function: custom_print_cb2 + * + * Purpose: Callback function to print error stack in customized way + * for H5Ewalk1. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Raymond Lu + * 4 October 2010 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +custom_print_cb2(int n, H5E_error2_t *err_desc, void* client_data) +{ + FILE *stream = (FILE *)client_data; + char *maj = NULL; + char *min = NULL; + const int indent = 4; + + if(NULL == (min = H5Eget_minor(err_desc->min_num))) + TEST_ERROR; + + if(NULL == (maj = H5Eget_major(err_desc->maj_num))) + 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); + + HDfree(maj); + HDfree(min); + + return 0; + +error: + if(maj) + HDfree(maj); + if(min) + HDfree(min); + + return -1; +} + + +/*------------------------------------------------------------------------- + * Function: test_error1 + * + * Purpose: Test the backward compatibility of H5Eset/get_auto. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Raymond Lu + * 17 September 2010 * * * Modifications: @@ -63,13 +230,143 @@ herr_t custom_print_cb(int n, H5E_error1_t *err_desc, void* client_data); *------------------------------------------------------------------------- */ static herr_t -test_error(hid_t file) +test_error1(void) { hid_t dataset, space; hsize_t dims[2]; - const char *FUNC_test_error="test_error"; - H5E_auto1_t old_func; + H5E_auto1_t old_func1; + H5E_auto2_t old_func2; void *old_data; + herr_t ret; + + TESTING("error API H5Eset/get_auto"); + fprintf(stderr, "\n"); + + /* Create the data space */ + dims[0] = DIM0; + dims[1] = DIM1; + if ((space = H5Screate_simple(2, dims, NULL))<0) TEST_ERROR; + + /* Use H5Eget_auto2 to query the default printing function. The library + *should indicate H5Eprint2 as the default. */ + if (H5Eget_auto2(H5E_DEFAULT, &old_func2, &old_data)<0) + TEST_ERROR; + if (old_data != NULL) + TEST_ERROR; + if (!old_func2 || (H5E_auto2_t)H5Eprint2 != old_func2) + TEST_ERROR; + + /* This function sets the default printing function to be H5Eprint2. */ + if(H5Eset_auto2(H5E_DEFAULT, old_func2, old_data)<0) + TEST_ERROR; + + /* Try the printing function. Dataset creation should fail because the file + * doesn't exist. */ + dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); + if(dataset >= 0) + TEST_ERROR; + + /* This call should work. It simply returns H5Eprint1. */ + if((ret = H5Eget_auto1(&old_func1, &old_data))<0) + TEST_ERROR; + if (old_data != NULL) + TEST_ERROR; + if (!old_func1 || (H5E_auto1_t)H5Eprint1 != old_func1) + TEST_ERROR; + + /* This function changes the old-style printing function to be user_print1. */ + if(H5Eset_auto1((H5E_auto1_t)user_print1, stderr)<0) + TEST_ERROR; + + /* Try the printing function. Dataset creation should fail because the file + * doesn't exist. */ + dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); + if(dataset >= 0) + TEST_ERROR; + + /* This call should fail because the test mixes H5Eget_auto2 with H5Eset_auto1. + * Once the H5Eset_auto1 is called with a user-defined printing function, + * a call to H5Eget_auto2 will fail. But keep in mind the printing function is + * user_print1. */ + if((ret = H5Eget_auto2(H5E_DEFAULT, &old_func2, &old_data))>=0) + TEST_ERROR; + + /* This function changes the new-style printing function to be user_print2. */ + if(H5Eset_auto2(H5E_DEFAULT, (H5E_auto2_t)user_print2, stderr)<0) + TEST_ERROR; + + /* Try the printing function. Dataset creation should fail because the file + * doesn't exist. */ + dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); + if(dataset >= 0) + TEST_ERROR; + + /* This function changes the new-style printing function back to the default H5Eprint2. */ + if(H5Eset_auto2(H5E_DEFAULT, (H5E_auto2_t)H5Eprint2, NULL)<0) + TEST_ERROR; + + /* This call should work because the H5Eset_auto2 above restored the default printing + * function H5Eprint2. It simply returns user_print1. */ + if((ret = H5Eget_auto1(&old_func1, &old_data))<0) + TEST_ERROR; + if (old_data != NULL) + TEST_ERROR; + if (!old_func1 || (H5E_auto1_t)user_print1 != old_func1) + TEST_ERROR; + + /* This function changes the new-style printing function back to the default H5Eprint1. */ + if(H5Eset_auto1((H5E_auto1_t)H5Eprint1, NULL)<0) + TEST_ERROR; + + /* This call should work because the H5Eset_auto1 above restored the default printing + * function H5Eprint1. It simply returns H5Eprint2. */ + if((ret = H5Eget_auto2(H5E_DEFAULT, &old_func2, &old_data))<0) + TEST_ERROR; + if (old_data != NULL) + TEST_ERROR; + if (!old_func2 || (H5E_auto2_t)H5Eprint2 != old_func2) + TEST_ERROR; + + /* Try the printing function. Dataset creation should fail because the file + * doesn't exist. */ + dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); + if(dataset >= 0) + TEST_ERROR; + + return 0; + + error: + return -1; +} + + +/*------------------------------------------------------------------------- + * Function: test_error2 + * + * Purpose: Test error API functions, mainly on H5Epush1. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Raymond Lu + * July 10, 2003 + * + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +test_error2(hid_t file) +{ + hid_t dataset, space; + hsize_t dims[2]; + const char *FUNC_test_error="test_error2"; TESTING("error API based on data I/O"); fprintf(stderr, "\n"); @@ -92,22 +389,12 @@ test_error(hid_t file) goto error; } - /* Test enabling and disabling default printing */ - if (H5Eget_auto1(&old_func, &old_data)<0) - TEST_ERROR; - if (old_data != NULL) - TEST_ERROR; - if (!old_func) - TEST_ERROR; -#ifdef H5_USE_16_API - if (old_func != (H5E_auto1_t)H5Eprint1) - TEST_ERROR; -#else /* H5_USE_16_API */ - if (old_func != (H5E_auto1_t)H5Eprint2) - TEST_ERROR; -#endif /* H5_USE_16_API */ - - if(H5Eset_auto1(NULL, NULL)<0) + /* Disable the library's default printing function */ +#ifdef H5_USE_16_API_DEFAULT + if(H5Eset_auto(NULL, NULL)<0) +#else + if(H5Eset_auto(H5E_DEFAULT, NULL, NULL)<0) +#endif TEST_ERROR; /* Make H5Dwrite fail, verify default print is disabled */ @@ -117,9 +404,6 @@ test_error(hid_t file) goto error; } - if(H5Eset_auto1(old_func, old_data)<0) - TEST_ERROR; - /* In case program comes to this point, close dataset */ if(H5Dclose(dataset)<0) TEST_ERROR; @@ -157,7 +441,7 @@ dump_error(void) /* Customized way to print errors */ fprintf(stderr, "\n********* Print error stack in customized way *********\n"); - if(H5Ewalk1(H5E_WALK_UPWARD, custom_print_cb, stderr) < 0) + if(H5Ewalk1(H5E_WALK_UPWARD, custom_print_cb1, stderr) < 0) TEST_ERROR; return 0; @@ -166,57 +450,6 @@ dump_error(void) 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(int n, H5E_error1_t *err_desc, void* client_data) -{ - FILE *stream = (FILE *)client_data; - char *maj = NULL; - char *min = NULL; - const int indent = 4; - - if(NULL == (min = H5Eget_minor(err_desc->min_num))) - TEST_ERROR; - - if(NULL == (maj = H5Eget_major(err_desc->maj_num))) - 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); - - HDfree(maj); - HDfree(min); - - return 0; - -error: - if(maj) - HDfree(maj); - if(min) - HDfree(min); - - return -1; -} /*------------------------------------------------------------------------- @@ -258,7 +491,9 @@ main(void) H5Eclear1(); /* Test error API */ - if(test_error(file) < 0) { + if(test_error1() < 0) TEST_ERROR ; + + if(test_error2(file) < 0) { H5Epush1(__FILE__, FUNC_main, __LINE__, H5E_ERROR, H5E_BADMESG, "Error test failed"); H5Eprint1(stderr); @@ -275,4 +510,3 @@ main(void) return 1; } #endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/test/testerror.sh.in b/test/testerror.sh.in index 7f9657a..440be4f 100644 --- a/test/testerror.sh.in +++ b/test/testerror.sh.in @@ -71,6 +71,8 @@ TEST() { -e 's/line [0-9]*/line (number)/' \ -e 's/v[1-9]*\.[0-9]*\./version (number)\./' \ -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \ + -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ + -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ $actual_err > $actual_ext cat $actual_ext >> $actual diff --git a/test/testfiles/err_compat_1 b/test/testfiles/err_compat_1 index 032e7bc..e2b37ab 100644 --- a/test/testfiles/err_compat_1 +++ b/test/testfiles/err_compat_1 @@ -1,7 +1,7 @@ ############################# Expected output for err_compat ############################# -Testing error API based on data I/O All error API tests passed. +Testing error API H5Eset/get_auto Testing error API based on data I/O All error API tests passed. This program tests the Error API compatible with HDF5 version (number). There're supposed to be some error messages ********* Print error stack in HDF5 default way ********* HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): @@ -15,10 +15,46 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Bad value HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): + #000: (file name) line (number) in H5Dcreate2(): not a location ID + major: Invalid arguments to routine + minor: Inappropriate type + #001: (file name) line (number) in H5G_loc(): invalid object ID + major: Invalid arguments to routine + minor: Bad value + +********* Print error stack in customized way ********* + error #000: (file name) in H5G_loc(): line (number) + major: Invalid arguments to routine + minor: Bad value + error #001: (file name) in H5Dcreate2(): line (number) + major: Invalid arguments to routine + minor: Inappropriate type + +********* Print error stack in customized way ********* + error #000: (file name) in H5Eget_auto(1 or 2)(): line (number) + major: Error API + minor: Can't get value + +********* Print error stack in customized way ********* + error #000: (file name) in H5G_loc(): line (number) + major: Invalid arguments to routine + minor: Bad value + error #001: (file name) in H5Dcreate2(): line (number) + major: Invalid arguments to routine + minor: Inappropriate type +HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): + #000: (file name) line (number) in H5Dcreate2(): not a location ID + major: Invalid arguments to routine + minor: Inappropriate type + #001: (file name) line (number) in H5G_loc(): invalid object ID + major: Invalid arguments to routine + minor: Bad value + +HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in main(): Error test failed major: Error API minor: Unrecognized message - #001: (file name) line (number) in test_error(): H5Dwrite shouldn't succeed + #001: (file name) line (number) in test_error2(): H5Dwrite shouldn't succeed major: Error API minor: Write failed #002: (file name) line (number) in H5Dwrite(): not a dataset |