aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/tests/test_runner.c
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2014-04-03 12:25:38 +0200
committerMartin Willi <martin@revosec.ch>2014-06-04 15:53:12 +0200
commit0c34c1b3afb82bc4a4fabf6a4b3d90b5906e4885 (patch)
treea4faa209e1520e7a975ad236dc87f0c5037125ef /src/libstrongswan/tests/test_runner.c
parent460adb5d0925f4af807b09434b771545d1f62b47 (diff)
downloadstrongswan-0c34c1b3afb82bc4a4fabf6a4b3d90b5906e4885.tar.bz2
strongswan-0c34c1b3afb82bc4a4fabf6a4b3d90b5906e4885.tar.xz
unit-tests: Support testable functions on Windows, avoid weak GCC symbols
Instead of using weak symbols, we use dlsym() on Windows to find an arbitrary symbol in libtest to detect its linkage. Instead of creating the associated hashtable in the test runner, we maintain it in libstrongswan, making it significantly simpler.
Diffstat (limited to 'src/libstrongswan/tests/test_runner.c')
-rw-r--r--src/libstrongswan/tests/test_runner.c33
1 files changed, 5 insertions, 28 deletions
diff --git a/src/libstrongswan/tests/test_runner.c b/src/libstrongswan/tests/test_runner.c
index 63d79199f..443c0ae13 100644
--- a/src/libstrongswan/tests/test_runner.c
+++ b/src/libstrongswan/tests/test_runner.c
@@ -35,35 +35,12 @@
#define TTY(color) tty_escape_get(2, TTY_FG_##color)
/**
- * Initialize the lookup table for testable functions (defined in
- * libstrongswan). We don't use the constructor attribute as the order can't
- * really be defined (clang does not support it and gcc does not adhere to it in
- * the monolithic build). The function here is a weak symbol in libstrongswan.
+ * A global symbol indicating libtest linkage
*/
-void testable_functions_create()
-{
- if (!testable_functions)
- {
- /* as this is executed before chunk_hash() seed initialization used
- * by hashtables, we enforce seeding it here. */
- chunk_hash_seed();
- testable_functions = hashtable_create(hashtable_hash_str,
- hashtable_equals_str, 8);
- }
-}
-
-/**
- * Destroy the lookup table for testable functions
- */
-static void testable_functions_destroy() __attribute__ ((destructor));
-static void testable_functions_destroy()
-{
- DESTROY_IF(testable_functions);
- /* if leak detective is enabled plugins are not actually unloaded, which
- * means their destructor is called AFTER this one when the process
- * terminates, make sure this does not crash */
- testable_functions = NULL;
-}
+#ifdef WIN32
+__declspec(dllexport)
+#endif
+bool test_runner_available = TRUE;
/**
* Destroy a single test suite and associated data