summaryrefslogtreecommitdiffstats
path: root/test/ttsafe.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2015-08-26 17:05:57 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2015-08-26 17:05:57 (GMT)
commit606c16e11126bd908e673abefd4f0b7e91562d7f (patch)
treeb00d04aa9badff7a5c747a846b11c0e354a40596 /test/ttsafe.c
parent6635d4c003caf15aadc16b0453d71ca1b0e8ca1f (diff)
downloadhdf5-606c16e11126bd908e673abefd4f0b7e91562d7f.zip
hdf5-606c16e11126bd908e673abefd4f0b7e91562d7f.tar.gz
hdf5-606c16e11126bd908e673abefd4f0b7e91562d7f.tar.bz2
[svn-r27587] Added a new API call (H5is_library_threadsafe) to the library. This call can
be used to determine at runtime if the library was built with thread-safety. Fixes HDFFV-9496 Tested on: h5committest
Diffstat (limited to 'test/ttsafe.c')
-rw-r--r--test/ttsafe.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/test/ttsafe.c b/test/ttsafe.c
index d0ab81a..d3c5cfb 100644
--- a/test/ttsafe.c
+++ b/test/ttsafe.c
@@ -40,13 +40,6 @@
/* ANY new test needs to have a prototype in ttsafe.h */
#include "ttsafe.h"
-#ifndef H5_HAVE_THREADSAFE
-int main(void)
-{
- printf("Test skipped because THREADSAFE not enabled\n");
- return 0;
-}
-#else
#define MAX_NUM_NAME 1000
#define NAME_OFFSET 6 /* offset for "name<num>" */
@@ -66,6 +59,30 @@ num_digits(int num)
return u;
}
+/* Test the H5is_library_threadsafe() function */
+void
+tts_is_threadsafe(void)
+{
+ hbool_t is_ts;
+ hbool_t should_be;
+
+#ifdef H5_HAVE_THREADSAFE
+ is_ts = FALSE;
+ should_be = TRUE;
+#else /* H5_HAVE_THREADSAFE */
+ is_ts = TRUE;
+ should_be = FALSE;
+#endif /* H5_HAVE_THREADSAFE */
+
+ if(H5is_library_threadsafe(&is_ts) != SUCCEED)
+ TestErrPrintf("H5_is_library_threadsafe() call failed - test failed\n");
+
+ if(is_ts != should_be)
+ TestErrPrintf("Thread-safety value incorrect - test failed\n");
+
+ return;
+}
+
/* Routine to generate attribute names for numeric values */
char *gen_name(int value)
{
@@ -88,10 +105,13 @@ char *gen_name(int value)
int main(int argc, char *argv[])
{
+
/* Initialize testing framework */
TestInit(argv[0], NULL, NULL);
/* Tests are generally arranged from least to most complexity... */
+ AddTest("is_threadsafe", tts_is_threadsafe, NULL, "library threadsafe status", NULL);
+#ifdef H5_HAVE_THREADSAFE
AddTest("dcreate", tts_dcreate, cleanup_dcreate, "multi-dataset creation", NULL);
AddTest("error", tts_error, cleanup_error, "per-thread error stacks", NULL);
#ifdef H5_HAVE_PTHREAD_H
@@ -100,6 +120,12 @@ int main(int argc, char *argv[])
#endif /* H5_HAVE_PTHREAD_H */
AddTest("acreate", tts_acreate, cleanup_acreate, "multi-attribute creation", NULL);
+#else /* H5_HAVE_THREADSAFE */
+
+ printf("Most thread-safety tests skipped because THREADSAFE not enabled\n");
+
+#endif /* H5_HAVE_THREADSAFE */
+
/* Display testing information */
TestInfo(argv[0]);
@@ -118,5 +144,6 @@ int main(int argc, char *argv[])
TestCleanup();
return GetTestNumErrs();
+
} /* end main() */
-#endif /*H5_HAVE_THREADSAFE*/
+