summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2021-04-07 17:13:12 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2021-04-07 17:13:12 (GMT)
commita96849027a93bd2b8011b763f9e4975676a14965 (patch)
tree9099788a4b3494dbc66137ee40b0b31aa3da9a3d /test
parent17c7cf94755aabd4885a3cbd287e65240ab04b49 (diff)
downloadhdf5-a96849027a93bd2b8011b763f9e4975676a14965.zip
hdf5-a96849027a93bd2b8011b763f9e4975676a14965.tar.gz
hdf5-a96849027a93bd2b8011b763f9e4975676a14965.tar.bz2
Brings thread-safety changes from develop
Diffstat (limited to 'test')
-rw-r--r--test/ttsafe.c4
-rw-r--r--test/ttsafe_attr_vlen.c41
-rw-r--r--test/ttsafe_cancel.c24
-rw-r--r--test/ttsafe_dcreate.c2
4 files changed, 35 insertions, 36 deletions
diff --git a/test/ttsafe.c b/test/ttsafe.c
index ef5ec3c..067a715 100644
--- a/test/ttsafe.c
+++ b/test/ttsafe.c
@@ -70,8 +70,6 @@ tts_is_threadsafe(void)
if (is_ts != should_be)
TestErrPrintf("Thread-safety value incorrect - test failed\n");
-
- return;
}
/* Routine to generate attribute names for numeric values */
@@ -134,7 +132,7 @@ main(int argc, char *argv[])
TestSummary();
/* Clean up test files, if allowed */
- if (GetTestCleanup() && !getenv("HDF5_NOCLEANUP"))
+ if (GetTestCleanup() && !HDgetenv("HDF5_NOCLEANUP"))
TestCleanup();
/* Release test infrastructure */
diff --git a/test/ttsafe_attr_vlen.c b/test/ttsafe_attr_vlen.c
index f9ca1f8..ecd0aa6 100644
--- a/test/ttsafe_attr_vlen.c
+++ b/test/ttsafe_attr_vlen.c
@@ -54,15 +54,15 @@ void *tts_attr_vlen_thread(void *);
void
tts_attr_vlen(void)
{
- pthread_t threads[NUM_THREADS] = {0}; /* Thread declaration */
- hid_t fid = H5I_INVALID_HID; /* File ID */
- hid_t gid = H5I_INVALID_HID; /* Group ID */
- hid_t atid = H5I_INVALID_HID; /* Datatype ID for attribute */
- hid_t asid = H5I_INVALID_HID; /* Dataspace ID for attribute */
- hid_t aid = H5I_INVALID_HID; /* The attribute ID */
- char * string_attr = "2.0"; /* The attribute data */
- int ret; /* Return value */
- int i; /* Local index variable */
+ H5TS_thread_t threads[NUM_THREADS] = {0}; /* Thread declaration */
+ hid_t fid = H5I_INVALID_HID; /* File ID */
+ hid_t gid = H5I_INVALID_HID; /* Group ID */
+ hid_t atid = H5I_INVALID_HID; /* Datatype ID for attribute */
+ hid_t asid = H5I_INVALID_HID; /* Dataspace ID for attribute */
+ hid_t aid = H5I_INVALID_HID; /* The attribute ID */
+ const char * string_attr = "2.0"; /* The attribute data */
+ int ret; /* Return value */
+ int i; /* Local index variable */
/* Create the HDF5 test file */
fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -106,26 +106,27 @@ tts_attr_vlen(void)
CHECK(ret, H5I_INVALID_HID, "H5Tclose");
/* Start multiple threads and execute tts_attr_vlen_thread() for each thread */
- for (i = 0; i < NUM_THREADS; i++)
- pthread_create(&threads[i], NULL, tts_attr_vlen_thread, NULL);
+ for (i = 0; i < NUM_THREADS; i++) {
+ threads[i] = H5TS_create_thread(tts_attr_vlen_thread, NULL, NULL);
+ }
/* Wait for the threads to end */
for (i = 0; i < NUM_THREADS; i++)
- pthread_join(threads[i], NULL);
+ H5TS_wait_for_thread(threads[i]);
} /* end tts_attr_vlen() */
/* Start execution for each thread */
void *
-tts_attr_vlen_thread(void *client_data)
+tts_attr_vlen_thread(void H5_ATTR_UNUSED *client_data)
{
- hid_t fid = H5I_INVALID_HID; /* File ID */
- hid_t gid = H5I_INVALID_HID; /* Group ID */
- hid_t aid = H5I_INVALID_HID; /* Attribute ID */
- hid_t atid = H5I_INVALID_HID; /* Datatype ID for the attribute */
- char * string_attr_check; /* The attribute data being read */
- char * string_attr = "2.0"; /* The expected attribute data */
- herr_t ret; /* Return value */
+ hid_t fid = H5I_INVALID_HID; /* File ID */
+ hid_t gid = H5I_INVALID_HID; /* Group ID */
+ hid_t aid = H5I_INVALID_HID; /* Attribute ID */
+ hid_t atid = H5I_INVALID_HID; /* Datatype ID for the attribute */
+ char * string_attr_check; /* The attribute data being read */
+ const char *string_attr = "2.0"; /* The expected attribute data */
+ herr_t ret; /* Return value */
/* Open the test file */
fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT);
diff --git a/test/ttsafe_cancel.c b/test/ttsafe_cancel.c
index de235c8..acaa9d6 100644
--- a/test/ttsafe_cancel.c
+++ b/test/ttsafe_cancel.c
@@ -65,46 +65,46 @@ tts_cancel(void)
/* make thread scheduling global */
ret = pthread_attr_init(&attribute);
- assert(ret == 0);
+ HDassert(ret == 0);
#ifdef H5_HAVE_SYSTEM_SCOPE_THREADS
ret = pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM);
- assert(ret == 0);
+ HDassert(ret == 0);
#endif /* H5_HAVE_SYSTEM_SCOPE_THREADS */
/* Initialize mutex & condition variables */
ret = pthread_mutex_init(&mutex, NULL);
- assert(ret == 0);
+ HDassert(ret == 0);
ret = pthread_cond_init(&cond, NULL);
- assert(ret == 0);
+ HDassert(ret == 0);
/*
* Create a hdf5 file using H5F_ACC_TRUNC access, default file
* creation plist and default file access plist
*/
cancel_file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- assert(cancel_file >= 0);
+ HDassert(cancel_file >= 0);
ret = pthread_create(&childthread, &attribute, tts_cancel_thread, NULL);
- assert(ret == 0);
+ HDassert(ret == 0);
tts_cancel_barrier();
ret = pthread_cancel(childthread);
- assert(ret == 0);
+ HDassert(ret == 0);
dataset = H5Dopen2(cancel_file, DATASETNAME, H5P_DEFAULT);
- assert(dataset >= 0);
+ HDassert(dataset >= 0);
ret = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &buffer);
- assert(ret >= 0);
+ HDassert(ret >= 0);
if (buffer != 11)
TestErrPrintf("operation unsuccessful with value at %d instead of 11\n", buffer);
ret = H5Dclose(dataset);
- assert(ret >= 0);
+ HDassert(ret >= 0);
ret = H5Fclose(cancel_file);
- assert(ret >= 0);
+ HDassert(ret >= 0);
/* Destroy the thread attribute */
ret = pthread_attr_destroy(&attribute);
- assert(ret == 0);
+ HDassert(ret == 0);
} /* end tts_cancel() */
void *
diff --git a/test/ttsafe_dcreate.c b/test/ttsafe_dcreate.c
index 1d10ad5..6243f5e 100644
--- a/test/ttsafe_dcreate.c
+++ b/test/ttsafe_dcreate.c
@@ -140,7 +140,7 @@ tts_dcreate_creator(void *_thread_data)
hsize_t dimsf[1]; /* dataset dimensions */
struct thread_info thread_data;
- memcpy(&thread_data, _thread_data, sizeof(struct thread_info));
+ HDmemcpy(&thread_data, _thread_data, sizeof(struct thread_info));
/* define dataspace for dataset */
dimsf[0] = 1;