From: Martin Willi Date: Thu, 20 Jun 2013 07:34:18 +0000 (+0200) Subject: unit-tests: load plugins in test-runner from build directory X-Git-Tag: 5.1.0dr1~97^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef687db734d957bac37ee240c94bfe207f822445;p=thirdparty%2Fstrongswan.git unit-tests: load plugins in test-runner from build directory --- diff --git a/src/libstrongswan/tests/Makefile.am b/src/libstrongswan/tests/Makefile.am index 44d797ef41..ca0a8c1ed8 100644 --- a/src/libstrongswan/tests/Makefile.am +++ b/src/libstrongswan/tests/Makefile.am @@ -11,6 +11,7 @@ test_runner_SOURCES = \ test_runner_CFLAGS = \ -I$(top_srcdir)/src/libstrongswan \ + -DPLUGINDIR=\""$(top_builddir)/src/libstrongswan/plugins\"" \ -DPLUGINS=\""${s_plugins}\"" \ @COVERAGE_CFLAGS@ \ @CHECK_CFLAGS@ diff --git a/src/libstrongswan/tests/test_runner.c b/src/libstrongswan/tests/test_runner.c index a30b1067d9..c80f9fc2e5 100644 --- a/src/libstrongswan/tests/test_runner.c +++ b/src/libstrongswan/tests/test_runner.c @@ -20,6 +20,34 @@ #include #include +#include + +/** + * Load plugins from builddir + */ +static bool load_plugins() +{ + enumerator_t *enumerator; + char *name, path[PATH_MAX], dir[64]; + bool success = TRUE; + + enumerator = enumerator_create_token(PLUGINS, " ", ""); + while (enumerator->enumerate(enumerator, &name)) + { + snprintf(dir, sizeof(dir), "%s", name); + translate(dir, "-", "_"); + snprintf(path, sizeof(path), "%s/%s/.libs", PLUGINDIR, dir); + if (!lib->plugins->load(lib->plugins, path, name)) + { + success = FALSE; + break; + } + } + enumerator->destroy(enumerator); + + return success; +} + int main() { SRunner *sr; @@ -39,7 +67,7 @@ int main() lib->settings->get_str(lib->settings, "libstrongswan.plugins.random.urandom", "/dev/urandom")); - if (!lib->plugins->load(lib->plugins, NULL, PLUGINS)) + if (!load_plugins()) { library_deinit(); return EXIT_FAILURE;