summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2015-09-01 07:12:41 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2015-09-01 07:12:41 (GMT)
commit96360ad86e25159be8ef0647f77f5618012b99e5 (patch)
tree47d7a383e8b8331312c9f8a436795805633a88be /test
parent49ef02b3a11f4757beecf1f4008ec47bd6006f52 (diff)
downloadhdf5-96360ad86e25159be8ef0647f77f5618012b99e5.zip
hdf5-96360ad86e25159be8ef0647f77f5618012b99e5.tar.gz
hdf5-96360ad86e25159be8ef0647f77f5618012b99e5.tar.bz2
[svn-r27643] Merge of r27581, 27587, and 27601 from trunk
Added a new public API call: H5is_library_threadsafe This API call can determine, at runtime, if the library was built with thread-safety enabled. Also fixes a minor bug in the FUNC_ENTER macros. Tested on: h5committest jam w/ threadsafe
Diffstat (limited to 'test')
-rw-r--r--test/ttsafe.c43
-rw-r--r--test/ttsafe.h10
-rw-r--r--test/ttsafe_error.c1
3 files changed, 39 insertions, 15 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*/
+
diff --git a/test/ttsafe.h b/test/ttsafe.h
index b4826fc..f2e9e86 100644
--- a/test/ttsafe.h
+++ b/test/ttsafe.h
@@ -20,8 +20,6 @@
#ifndef TTSAFE_H
#define TTSAFE_H
-#include <string.h>
-
/*
* Include required headers. This file tests internal library functions,
* so we include the private headers here.
@@ -31,16 +29,13 @@
#include "H5Eprivate.h"
#include "testhdf5.h"
-#ifdef H5_HAVE_THREADSAFE
-/* Include pthread library for threadsafe tests */
-#ifdef H5_HAVE_PTHREAD_H
-#include <pthread.h>
-#endif /* H5_HAVE_PTHREAD_H */
/* Prototypes for the support routines */
extern char* gen_name(int);
/* Prototypes for the test routines */
+void tts_is_threadsafe(void);
+#ifdef H5_HAVE_THREADSAFE
void tts_dcreate(void);
void tts_error(void);
void tts_cancel(void);
@@ -54,3 +49,4 @@ void cleanup_acreate(void);
#endif /* H5_HAVE_THREADSAFE */
#endif /* TTSAFE_H */
+
diff --git a/test/ttsafe_error.c b/test/ttsafe_error.c
index e143263..a2f25db 100644
--- a/test/ttsafe_error.c
+++ b/test/ttsafe_error.c
@@ -231,3 +231,4 @@ void cleanup_error(void)
}
#endif /*H5_HAVE_THREADSAFE*/
+