diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2010-09-07 16:24:33 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2010-09-07 16:24:33 (GMT) |
commit | ba35fd9890468f40ed2cd5b38adc2dbb81c82f7e (patch) | |
tree | 75fbb4639fa328702836fe4eaab3736cb7a54f61 /test | |
parent | 071703613374d4e050ccc3ec754eca57368b3d55 (diff) | |
download | hdf5-ba35fd9890468f40ed2cd5b38adc2dbb81c82f7e.zip hdf5-ba35fd9890468f40ed2cd5b38adc2dbb81c82f7e.tar.gz hdf5-ba35fd9890468f40ed2cd5b38adc2dbb81c82f7e.tar.bz2 |
[svn-r19355] Quincey and I made H5Eset_current_stack also close the stack to be set. This is to
avoid H5Eclose_stack clearing the default stack. Please see bug 1799.
Tested on jam - simple change.
The changes to configure.in, tools/lib, config, c++/test, Makefile.am, and fortran
are only property changes from the merge.
Diffstat (limited to 'test')
-rw-r--r-- | test/error_test.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/test/error_test.c b/test/error_test.c index e784eb9..9424957 100644 --- a/test/error_test.c +++ b/test/error_test.c @@ -515,6 +515,68 @@ error: return(-1); } /* end test_create() */ + +/*------------------------------------------------------------------------- + * Function: test_copy + * + * Purpose: Test copyinging an error stack + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Allen Byrne + * February 18, 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_copy(void) +{ + const char *err_func = "test_copy"; /* Function name for pushing error */ + const char *err_msg = "Error message"; /* Error message for pushing error */ + int err_num; /* Number of errors on stack */ + int err_num_copy; /* Number of errors on stack copy */ + hid_t estack_id; /* Error stack ID */ + herr_t ret; /* Generic return value */ + + /* Push an error with a long description */ + if(H5Epush(H5E_DEFAULT, __FILE__, err_func, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, err_msg) < 0) TEST_ERROR; + + /* Check the number of errors on stack */ + err_num = H5Eget_num(H5E_DEFAULT); + if(err_num != 1) TEST_ERROR + + /* Copy error stack, which clears the original */ + if((estack_id = H5Eget_current_stack()) < 0) TEST_ERROR + + /* Check the number of errors on stack copy */ + err_num = H5Eget_num(estack_id); + if(err_num != 1) TEST_ERROR + + /* Check the number of errors on original stack */ + err_num = H5Eget_num(H5E_DEFAULT); + if(err_num != 0) TEST_ERROR + + /* Put the stack copy as the default. It closes the stack copy, too. */ + if(H5Eset_current_stack(estack_id) < 0) TEST_ERROR + + /* Check the number of errors on default stack */ + err_num = H5Eget_num(H5E_DEFAULT); + if(err_num != 1) TEST_ERROR + + /* Try to close error stack copy. Should fail because + * the current H5Eset_current_stack closes the stack to be set.*/ + H5E_BEGIN_TRY { + ret = H5Eclose_stack(estack_id); + } H5E_END_TRY + if(ret >= 0) TEST_ERROR + + return(0); + +error: + return(-1); +} /* end test_copy() */ + /*------------------------------------------------------------------------- * Function: close_error @@ -624,6 +686,9 @@ main(void) /* Test creating a new error stack */ if(test_create() < 0) TEST_ERROR; + /* Test copying a new error stack */ + if(test_copy() < 0) TEST_ERROR; + if(H5Fclose(file) < 0) TEST_ERROR; h5_cleanup(FILENAME, fapl); |