summaryrefslogtreecommitdiffstats
path: root/test/ttsafe.c
diff options
context:
space:
mode:
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*/
+