diff options
author | Tobias Brunner <tobias@strongswan.org> | 2013-11-28 18:02:18 +0100 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2013-12-04 20:32:59 +0100 |
commit | 4cea186b64c573a2030a66377c51857b401dbea0 (patch) | |
tree | 7b7be2fb451a199365e00cbda7eacd763e823c45 /src/libstrongswan/tests/test_runner.c | |
parent | a24eec464901819d15d19633e13fa139ab24e748 (diff) | |
download | strongswan-4cea186b64c573a2030a66377c51857b401dbea0.tar.bz2 strongswan-4cea186b64c573a2030a66377c51857b401dbea0.tar.xz |
unit-tests: Add facility to register testable functions
These can be defined in plugins, or other parts of the tested libraries.
They can even be static.
Diffstat (limited to 'src/libstrongswan/tests/test_runner.c')
-rw-r--r-- | src/libstrongswan/tests/test_runner.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libstrongswan/tests/test_runner.c b/src/libstrongswan/tests/test_runner.c index 0bb1ab309..bf18f16fb 100644 --- a/src/libstrongswan/tests/test_runner.c +++ b/src/libstrongswan/tests/test_runner.c @@ -20,6 +20,7 @@ #include <library.h> #include <plugins/plugin_feature.h> #include <collections/array.h> +#include <utils/test.h> #include <dirent.h> #include <unistd.h> @@ -31,6 +32,30 @@ #define TTY(color) tty_escape_get(2, TTY_FG_##color) /** + * Initialize the lookup table for testable functions (defined in libstrongswan) + */ +static void testable_functions_create() __attribute__ ((constructor(1000))); +static void testable_functions_create() +{ + 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(1000))); +static void testable_functions_destroy() +{ + testable_functions->destroy(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, even though the priority says differently, make sure this + * does not crash */ + testable_functions = NULL; +} + +/** * Load all available test suites */ static array_t *load_suites(test_configuration_t configs[], |