summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFang Guo <fangguo@ncsa.uiuc.edu>2005-08-19 20:01:41 (GMT)
committerFang Guo <fangguo@ncsa.uiuc.edu>2005-08-19 20:01:41 (GMT)
commit6b181e28a8e67b31b7ba3e9ae8170215235647c1 (patch)
tree3c63cd6ad6d68848dbdfae7facd7e73dbc4de87d
parent9498eb17706b19a88769b8f01b54d07ecf1bd112 (diff)
downloadhdf5-6b181e28a8e67b31b7ba3e9ae8170215235647c1.zip
hdf5-6b181e28a8e67b31b7ba3e9ae8170215235647c1.tar.gz
hdf5-6b181e28a8e67b31b7ba3e9ae8170215235647c1.tar.bz2
[svn-r11268] Purpose:
Improvement Description: Add some assertion statements to locate the errors when they happen Solution: Platforms tested: MSVS 6.0 on windows and heping(with pthread) Misc. update:
-rw-r--r--test/ttsafe_error.c53
1 files changed, 38 insertions, 15 deletions
diff --git a/test/ttsafe_error.c b/test/ttsafe_error.c
index c000a73..c8fdbab 100644
--- a/test/ttsafe_error.c
+++ b/test/ttsafe_error.c
@@ -60,6 +60,7 @@ static void *tts_error_thread(void *);
/* Global variables */
hid_t error_file;
+int ret;
typedef struct err_num_struct {
hid_t maj_num;
@@ -105,12 +106,16 @@ void tts_error(void)
expected[7].min_num = H5E_CANTINSERT;
/* set up mutex for global count of errors */
- pthread_mutex_init(&error_mutex, NULL);
+ ret=pthread_mutex_init(&error_mutex, NULL);
+ assert(ret==0);
/* make thread scheduling global */
- pthread_attr_init(&attribute);
+ ret=pthread_attr_init(&attribute);
+ assert(ret==0);
+
#ifdef H5_HAVE_SYSTEM_SCOPE_THREADS
- pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM);
+ ret=pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM);
+ assert(ret==0);
#endif /* H5_HAVE_SYSTEM_SCOPE_THREADS */
/*
@@ -118,12 +123,17 @@ void tts_error(void)
* creation plist and default file access plist
*/
error_file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ assert(error_file>=0);
- for (i = 0; i < NUM_THREAD; i++)
- pthread_create(&threads[i], &attribute, tts_error_thread, NULL);
+ for (i = 0; i < NUM_THREAD; i++){
+ ret=pthread_create(&threads[i], &attribute, tts_error_thread, NULL);
+ assert(ret==0);
+ }
- for (i = 0; i < NUM_THREAD; i++)
- pthread_join(threads[i],NULL);
+ for (i = 0; i < NUM_THREAD; i++){
+ ret=pthread_join(threads[i],NULL);
+ assert(ret==0);
+ }
if (error_flag)
TestErrPrintf("Threads reporting different error values!\n");
@@ -132,16 +142,22 @@ void tts_error(void)
TestErrPrintf("Error: %d threads failed instead of %d\n", error_count, NUM_THREAD-1);
dataset = H5Dopen(error_file, DATASETNAME);
- H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &value);
+ assert(dataset>=0);
+
+ ret=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &value);
+ assert(ret>=0);
if (value != WRITE_NUMBER)
TestErrPrintf("Error: Successful thread wrote value %d instead of %d\n", value, WRITE_NUMBER);
- H5Dclose(dataset);
- H5Fclose(error_file);
+ ret=H5Dclose(dataset);
+ assert(ret>=0);
+ ret=H5Fclose(error_file);
+ assert(ret>=0);
/* Destroy the thread attribute */
- pthread_attr_destroy(&attribute);
+ ret=pthread_attr_destroy(&attribute);
+ assert(ret==0);
}
static
@@ -162,21 +178,26 @@ void *tts_error_thread(void UNUSED *arg)
/* define dataspace for dataset */
dimsf[0] = 1;
dataspace = H5Screate_simple(1,dimsf,NULL);
+ assert(dataspace>=0);
/* define datatype for the data using native little endian integers */
datatype = H5Tcopy(H5T_NATIVE_INT);
+ assert(datatype>=0);
H5Tset_order(datatype, H5T_ORDER_LE);
/* create a new dataset within the file */
dataset = H5Dcreate(error_file, DATASETNAME, datatype, dataspace, H5P_DEFAULT);
+
if (dataset >= 0) { /* not an error */
value = WRITE_NUMBER;
H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &value);
H5Dclose(dataset);
}
- H5Tclose(datatype);
- H5Sclose(dataspace);
+ ret=H5Tclose(datatype);
+ assert(ret>=0);
+ ret=H5Sclose(dataspace);
+ assert(ret>=0);
/* turn our error stack handler off */
H5Eset_auto_stack(H5E_DEFAULT, old_error_cb, old_error_client_data);
@@ -187,9 +208,11 @@ void *tts_error_thread(void UNUSED *arg)
static
herr_t error_callback(void *client_data)
{
- pthread_mutex_lock(&error_mutex);
+ ret=pthread_mutex_lock(&error_mutex);
+ assert(ret==0);
error_count++;
- pthread_mutex_unlock(&error_mutex);
+ ret=pthread_mutex_unlock(&error_mutex);
+ assert(ret==0);
return H5Ewalk(H5E_WALK_DOWNWARD, walk_error_callback, client_data);
}