kernel-netlink: Support extended table IDs for custom routes
[strongswan.git] / src / libcharon / tests / libcharon_tests.c
index 1ed0f0c..3fe5b0e 100644 (file)
@@ -14,7 +14,6 @@
  */
 
 #include <test_runner.h>
  */
 
 #include <test_runner.h>
-#include <hydra.h>
 #include <daemon.h>
 
 /* declare test suite constructors */
 #include <daemon.h>
 
 /* declare test suite constructors */
 static test_configuration_t tests[] = {
 #define TEST_SUITE(x) \
        { .suite = x, },
 static test_configuration_t tests[] = {
 #define TEST_SUITE(x) \
        { .suite = x, },
-#define TEST_SUITE_DEPEND(x, type, args) \
-       { .suite = x, .feature = PLUGIN_DEPENDS(type, args) },
+#define TEST_SUITE_DEPEND(x, type, ...) \
+       { .suite = x, .feature = PLUGIN_DEPENDS(type, __VA_ARGS__) },
 #include "libcharon_tests.h"
        { .suite = NULL, }
 };
 
 #include "libcharon_tests.h"
        { .suite = NULL, }
 };
 
+static void initialize_logging()
+{
+       int level = LEVEL_SILENT;
+       char *verbosity;
+
+       verbosity = getenv("TESTS_VERBOSITY");
+       if (verbosity)
+       {
+               level = atoi(verbosity);
+       }
+       lib->settings->set_int(lib->settings, "%s.filelog.stderr.default",
+                       lib->settings->get_int(lib->settings, "%s.filelog.stderr.default",
+                                                                  level, lib->ns), lib->ns);
+       charon->load_loggers(charon);
+}
+
 static bool test_runner_init(bool init)
 {
        if (init)
        {
 static bool test_runner_init(bool init)
 {
        if (init)
        {
-               libhydra_init();
+               char *plugins, *plugindir;
+
                libcharon_init();
                libcharon_init();
+               initialize_logging();
+
+               plugins = getenv("TESTS_PLUGINS") ?:
+                                       lib->settings->get_str(lib->settings,
+                                                                               "tests.load", PLUGINS);
+               plugindir = lib->settings->get_str(lib->settings,
+                                                                               "tests.plugindir", PLUGINDIR);
+               plugin_loader_add_plugindirs(plugindir, plugins);
+               if (!lib->plugins->load(lib->plugins, plugins))
+               {
+                       return FALSE;
+               }
        }
        else
        {
        }
        else
        {
-               lib->processor->set_threads(lib->processor, 0);
-               lib->processor->cancel(lib->processor);
                libcharon_deinit();
                libcharon_deinit();
-               libhydra_deinit();
        }
        return TRUE;
 }
        }
        return TRUE;
 }