[svn-r16835] Allow an error class to use other class's major or minor errors. Added a test for it, too.

Tested on jam - simple change.
This commit is contained in:
Raymond Lu 2009-04-22 13:39:10 -05:00
parent 37906de73c
commit be8cb6411a
3 changed files with 34 additions and 15 deletions

View File

@ -362,8 +362,9 @@ H5E_walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data)
if(min_ptr->msg)
min_str = min_ptr->msg;
/* Get error class info */
cls_ptr = maj_ptr->cls;
/* Get error class info. Don't use the class of the major or minor error because
* they might be different. */
cls_ptr = (H5E_cls_t *)H5I_object_verify(err_desc->cls_id, H5I_ERROR_CLASS);
/* Print error class header if new class */
if(eprint->cls.lib_name == NULL || HDstrcmp(cls_ptr->lib_name, eprint->cls.lib_name)) {

View File

@ -40,6 +40,7 @@ const char *FILENAME[] = {
int ipoints2[DIM0][DIM1], icheck2[DIM0][DIM1];
hid_t ERR_CLS;
hid_t ERR_CLS2;
hid_t ERR_STACK;
hid_t ERR_MAJ_TEST;
@ -56,7 +57,9 @@ hid_t ERR_MIN_GETNUM;
#define FAKE_ID 0
#define ERR_CLS_NAME "Error Test"
#define ERR_CLS2_NAME "Second Test"
#define PROG_NAME "Error Program"
#define PROG2_NAME "Second Program"
#define PROG_VERS "1.0"
#define ERR_MAJ_TEST_MSG "Error in test"
@ -69,12 +72,6 @@ hid_t ERR_MIN_GETNUM;
#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
#define LONG_DESC_SIZE 8192
static herr_t custom_print_cb(unsigned n, const H5E_error2_t *err_desc,
@ -106,6 +103,7 @@ test_error(hid_t file)
void *old_data;
TESTING("error API based on data I/O");
printf("\n");
/* Create the data space */
dims[0] = DIM0;
@ -189,10 +187,10 @@ static herr_t
init_error(void)
{
ssize_t cls_size = (ssize_t)HDstrlen(ERR_CLS_NAME)+1;
char *cls_name = HDmalloc(HDstrlen(ERR_CLS_NAME)+1);
char *cls_name = (char*)HDmalloc(HDstrlen(ERR_CLS_NAME)+1);
ssize_t msg_size = (ssize_t)HDstrlen(ERR_MIN_SUBROUTINE_MSG) + 1;
char *msg = HDmalloc(HDstrlen(ERR_MIN_SUBROUTINE_MSG)+1);
H5E_type_t *msg_type= HDmalloc(sizeof(H5E_type_t));
char *msg = (char*)HDmalloc(HDstrlen(ERR_MIN_SUBROUTINE_MSG)+1);
H5E_type_t *msg_type= (H5E_type_t *)HDmalloc(sizeof(H5E_type_t));
if((ERR_CLS = H5Eregister_class(ERR_CLS_NAME, PROG_NAME, PROG_VERS)) < 0)
TEST_ERROR;
@ -231,6 +229,10 @@ init_error(void)
HDfree(msg);
HDfree(msg_type);
/* Register another class for later testing. */
if((ERR_CLS2 = H5Eregister_class(ERR_CLS2_NAME, PROG2_NAME, PROG_VERS)) < 0)
TEST_ERROR;
return 0;
error:
@ -334,8 +336,8 @@ test_long_desc(void)
const char *test_FUNC = "test_long_desc";
/* Allocate space for the error description info */
if(NULL == (long_desc = HDmalloc(LONG_DESC_SIZE))) TEST_ERROR;
if(NULL == (full_desc = HDmalloc(LONG_DESC_SIZE + 128))) TEST_ERROR;
if(NULL == (long_desc = (char*)HDmalloc(LONG_DESC_SIZE))) TEST_ERROR;
if(NULL == (full_desc = (char*)HDmalloc(LONG_DESC_SIZE + 128))) TEST_ERROR;
/* Create the long part of the error description */
for(u = 0; u < LONG_DESC_SIZE; u++)
@ -535,6 +537,9 @@ close_error(void)
if(H5Eunregister_class(ERR_CLS) < 0)
TEST_ERROR;
if(H5Eunregister_class(ERR_CLS2) < 0)
TEST_ERROR;
return 0;
error:
@ -581,6 +586,10 @@ main(void)
/* Delete an error from the top of error stack */
H5Epop(ERR_STACK, 1);
/* Make sure we can use other class's major or minor errors. */
H5Epush(ERR_STACK, __FILE__, FUNC_main, __LINE__, ERR_CLS2, ERR_MAJ_TEST, ERR_MIN_ERRSTACK,
"Error stack test failed");
/* Print out the errors on stack */
dump_error(ERR_STACK);

View File

@ -1,11 +1,16 @@
#############################
Expected output for error_test
#############################
Testing error API based on data I/O All error API tests passed.
Testing error API based on data I/O
All error API tests passed.
This program tests the Error API. There're supposed to be some error messages
********* Print error stack in HDF5 default way *********
Second Test-DIAG: Error detected in Second Program (1.0) thread (IDs):
#000: (file name) line (number) in main(): Error stack test failed
major: Error in test
minor: Error in error stack
Error Test-DIAG: Error detected in Error Program (1.0) thread (IDs):
#000: (file name) line (number) in error_stack(): Get number test failed, returned 0
#001: (file name) line (number) in error_stack(): Get number test failed, returned 0
major: Error in API
minor: Error in H5Eget_num
@ -14,6 +19,10 @@ Error Test-DIAG: Error detected in Error Program (1.0) thread (IDs):
class: Error Test
major: Error in API
minor: Error in H5Eget_num
error #001: (file name) in main(): line (number)
class: Second Test
major: Error in test
minor: Error in error stack
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
#000: (file name) line (number) in H5Dwrite(): not a dataset
major: Invalid arguments to routine