unit-tests: Support strongswan.conf defined plugin list and base directory
[strongswan.git] / src / libstrongswan / tests / tests.c
index a32f384..d95ddd9 100644 (file)
@@ -31,12 +31,32 @@ static test_configuration_t tests[] = {
        { .suite = NULL, }
 };
 
-static char *plugindirs[] = {
-       PLUGINDIR,
-       NULL,
-};
+static bool test_runner_init(bool init)
+{
+       if (init)
+       {
+               char *plugins, *plugindir;
+
+               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
+       {
+               lib->processor->set_threads(lib->processor, 0);
+               lib->processor->cancel(lib->processor);
+               lib->plugins->unload(lib->plugins);
+       }
+       return TRUE;
+}
 
 int main(int argc, char *argv[])
 {
-       return test_runner_run(tests, plugindirs, PLUGINS);
+       return test_runner_run("libstrongswan", tests, test_runner_init);
 }