diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2003-07-26 02:55:47 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2003-07-26 02:55:47 (GMT) |
commit | 0d22a663df367ada055cb3695186c669e1dd6d5e (patch) | |
tree | 9a3c6588411b63b90ec5d86f65032c0f373eb4e2 /test/ttsafe_error.c | |
parent | b4b2b55d33be1c4f1c33aaf58294281a93b7da39 (diff) | |
download | hdf5-0d22a663df367ada055cb3695186c669e1dd6d5e.zip hdf5-0d22a663df367ada055cb3695186c669e1dd6d5e.tar.gz hdf5-0d22a663df367ada055cb3695186c669e1dd6d5e.tar.bz2 |
[svn-r7265] *** empty log message ***
Diffstat (limited to 'test/ttsafe_error.c')
-rw-r--r-- | test/ttsafe_error.c | 87 |
1 files changed, 59 insertions, 28 deletions
diff --git a/test/ttsafe_error.c b/test/ttsafe_error.c index ba1a394..ae64af2 100644 --- a/test/ttsafe_error.c +++ b/test/ttsafe_error.c @@ -47,7 +47,8 @@ #ifdef H5_HAVE_THREADSAFE -#define NUM_THREAD 16 +/*#define NUM_THREAD 16*/ +#define NUM_THREAD 2 #define FILENAME "ttsafe_error.h5" /* Having a common dataset name is an error */ @@ -55,7 +56,7 @@ #define EXPECTED_ERROR_DEPTH 8 #define WRITE_NUMBER 37 -static herr_t error_callback(void *); +static herr_t error_callback(hid_t, void *); static herr_t walk_error_callback(int, H5E_error_t *, void *); static void *tts_error_thread(void *); @@ -63,20 +64,11 @@ static void *tts_error_thread(void *); hid_t error_file; typedef struct err_num_struct { - int maj_num; - int min_num; + hid_t maj_num; + hid_t min_num; } err_num_t; -err_num_t expected[] = { - {H5E_DATASET, H5E_CANTINIT}, - {H5E_DATASET, H5E_CANTINIT}, - {H5E_SYM, H5E_EXISTS}, - {H5E_SYM, H5E_CANTINSERT}, - {H5E_SYM, H5E_CANTINSERT}, - {H5E_BTREE, H5E_CANTINIT}, - {H5E_BTREE, H5E_CANTINSERT}, - {H5E_SYM, H5E_CANTINSERT}, -}; +err_num_t expected[8]; int error_flag = 0; int error_count = 0; @@ -90,15 +82,40 @@ void tts_error(void) void *old_error_client_data; hid_t dataset; int value, i; - + H5E_t *tmp; + + expected[0].maj_num = H5E_DATASET; + expected[0].min_num = H5E_CANTINIT; + + expected[1].maj_num = H5E_DATASET; + expected[1].min_num = H5E_CANTINIT; + + expected[2].maj_num = H5E_SYM; + expected[2].min_num = H5E_EXISTS; + + expected[3].maj_num = H5E_SYM; + expected[3].min_num = H5E_CANTINSERT; + + expected[4].maj_num = H5E_SYM; + expected[4].min_num = H5E_CANTINSERT; + + expected[5].maj_num = H5E_BTREE; + expected[5].min_num = H5E_CANTINIT; + + expected[6].maj_num = H5E_BTREE; + expected[6].min_num = H5E_CANTINSERT; + + expected[7].maj_num = H5E_SYM; + expected[7].min_num = H5E_CANTINSERT; + /* set up mutex for global count of errors */ pthread_mutex_init(&error_mutex, NULL); /* preserve previous error stack handler */ - H5Eget_auto(&old_error_cb, &old_error_client_data); - + H5Eget_auto(H5E_DEFAULT, &old_error_cb, &old_error_client_data); +fprintf(stderr, "tts_error: error_cb=%p, H5Eprint=%p\n", error_callback, H5Eprint); /* set our own auto error stack handler */ - H5Eset_auto(error_callback, NULL); + H5Eset_auto(H5E_DEFAULT, error_callback, NULL); /* make thread scheduling global */ pthread_attr_init(&attribute); @@ -111,6 +128,10 @@ void tts_error(void) * creation plist and default file access plist */ error_file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); +tmp = pthread_getspecific(H5TS_errstk_key_g); +HDfprintf(stderr, "tts_error: tmp=%p, ", tmp); +if(tmp) +HDfprintf(stderr, "tmp->func=%p\n", tmp->func); for (i = 0; i < NUM_THREAD; i++) pthread_create(&threads[i], &attribute, tts_error_thread, NULL); @@ -143,7 +164,7 @@ void tts_error(void) H5Fclose(error_file); /* turn our error stack handler off */ - H5Eset_auto(old_error_cb, old_error_client_data); + H5Eset_auto(H5E_DEFAULT, old_error_cb, old_error_client_data); /* Destroy the thread attribute */ pthread_attr_destroy(&attribute); @@ -155,7 +176,11 @@ void *tts_error_thread(void *arg) hid_t dataspace, datatype, dataset; hsize_t dimsf[1]; /* dataset dimensions */ int value; - + H5E_t *tmp; +tmp = pthread_getspecific(H5TS_errstk_key_g); +HDfprintf(stderr, "tts_error_thread: tmp=%p, ", tmp); +if(tmp) +HDfprintf(stderr, "tmp->func=%p\n", tmp->func); /* define dataspace for dataset */ dimsf[0] = 1; dataspace = H5Screate_simple(1,dimsf,NULL); @@ -163,7 +188,7 @@ void *tts_error_thread(void *arg) /* define datatype for the data using native little endian integers */ datatype = H5Tcopy(H5T_NATIVE_INT); H5Tset_order(datatype, H5T_ORDER_LE); - + /* create a new dataset within the file */ dataset = H5Dcreate(error_file, DATASETNAME, datatype, dataspace, H5P_DEFAULT); @@ -181,24 +206,30 @@ void *tts_error_thread(void *arg) } static -herr_t error_callback(void *client_data) +herr_t error_callback(hid_t estack, void *client_data) { + +fprintf(stderr, "err_cb\n"); pthread_mutex_lock(&error_mutex); error_count++; pthread_mutex_unlock(&error_mutex); client_data = client_data; /* gets rid of annoying warning message */ - return H5Ewalk(H5E_WALK_DOWNWARD, walk_error_callback, NULL); + return H5Ewalk(estack, H5E_WALK_DOWNWARD, walk_error_callback, NULL); } static herr_t walk_error_callback(int n, H5E_error_t *err_desc, void *client_data) { - int maj_num, min_num; - + hid_t maj_num, min_num; +fprintf(stderr, "walk_err_cb\n"); if (err_desc) { - maj_num = err_desc->maj_num; - min_num = err_desc->min_num; - + maj_num = err_desc->maj_id; + min_num = err_desc->min_id; + + if (n < EXPECTED_ERROR_DEPTH && maj_num != expected[n].maj_num && + min_num != expected[n].min_num) +fprintf(stderr, "walk_err_cb: maj_num=%d, expected[%d].maj=%d, min=%d, expected[%d].min=%d\n", + maj_num, n, expected[n].maj_num, min_num, n, expected[n].min_num); if (n < EXPECTED_ERROR_DEPTH && maj_num == expected[n].maj_num && min_num == expected[n].min_num) return SUCCEED; |