diff options
| author | Martin Willi <martin@revosec.ch> | 2014-01-21 14:39:35 +0100 |
|---|---|---|
| committer | Martin Willi <martin@revosec.ch> | 2014-05-07 14:13:34 +0200 |
| commit | 1e39454214b2091b2fea92aa71fa16aa9efe04df (patch) | |
| tree | f9a1111b0279ec6721f731afb8b7b369e9490f1c /src/libcharon/plugins | |
| parent | 6770cfe34aea20ce970dbc35fad4bd4685a2b58d (diff) | |
| download | strongswan-1e39454214b2091b2fea92aa71fa16aa9efe04df.tar.bz2 strongswan-1e39454214b2091b2fea92aa71fa16aa9efe04df.tar.xz | |
vici: Add a test runner for plugin
Diffstat (limited to 'src/libcharon/plugins')
| -rw-r--r-- | src/libcharon/plugins/vici/.gitignore | 1 | ||||
| -rw-r--r-- | src/libcharon/plugins/vici/Makefile.am | 19 | ||||
| -rw-r--r-- | src/libcharon/plugins/vici/vici_tests.c | 53 | ||||
| -rw-r--r-- | src/libcharon/plugins/vici/vici_tests.h | 14 |
4 files changed, 87 insertions, 0 deletions
diff --git a/src/libcharon/plugins/vici/.gitignore b/src/libcharon/plugins/vici/.gitignore new file mode 100644 index 000000000..a78cc13cf --- /dev/null +++ b/src/libcharon/plugins/vici/.gitignore @@ -0,0 +1 @@ +vici_tests diff --git a/src/libcharon/plugins/vici/Makefile.am b/src/libcharon/plugins/vici/Makefile.am index 93de45add..f27fb09c8 100644 --- a/src/libcharon/plugins/vici/Makefile.am +++ b/src/libcharon/plugins/vici/Makefile.am @@ -17,3 +17,22 @@ libstrongswan_vici_la_SOURCES = \ vici_plugin.h vici_plugin.c libstrongswan_vici_la_LDFLAGS = -module -avoid-version + +TESTS = vici_tests + +check_PROGRAMS = $(TESTS) + +vici_tests_SOURCES = \ + vici_tests.h vici_tests.c + +vici_tests_CFLAGS = \ + -I$(top_srcdir)/src/libstrongswan \ + -I$(top_srcdir)/src/libstrongswan/tests \ + @COVERAGE_CFLAGS@ + +vici_tests_LDFLAGS = @COVERAGE_LDFLAGS@ +vici_tests_LDADD = \ + $(top_builddir)/src/libcharon/libcharon.la \ + $(top_builddir)/src/libhydra/libhydra.la \ + $(top_builddir)/src/libstrongswan/libstrongswan.la \ + $(top_builddir)/src/libstrongswan/tests/libtest.la diff --git a/src/libcharon/plugins/vici/vici_tests.c b/src/libcharon/plugins/vici/vici_tests.c new file mode 100644 index 000000000..ec5afa45d --- /dev/null +++ b/src/libcharon/plugins/vici/vici_tests.c @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2014 Martin Willi + * Copyright (C) 2014 revosec AG + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include <test_runner.h> + +#include <daemon.h> +#include <hydra.h> + +/* declare test suite constructors */ +#define TEST_SUITE(x) test_suite_t* x(); +#include "vici_tests.h" +#undef TEST_SUITE + +static test_configuration_t tests[] = { +#define TEST_SUITE(x) \ + { .suite = x, }, +#include "vici_tests.h" + { .suite = NULL, } +}; + +static bool test_runner_init(bool init) +{ + if (init) + { + libhydra_init("vici-tests"); + libcharon_init("vici-tests"); + } + else + { + lib->processor->set_threads(lib->processor, 0); + lib->processor->cancel(lib->processor); + libcharon_deinit(); + libhydra_deinit(); + } + return TRUE; +} + +int main(int argc, char *argv[]) +{ + return test_runner_run("vici", tests, test_runner_init); +} diff --git a/src/libcharon/plugins/vici/vici_tests.h b/src/libcharon/plugins/vici/vici_tests.h new file mode 100644 index 000000000..05502f18e --- /dev/null +++ b/src/libcharon/plugins/vici/vici_tests.h @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2014 Martin Willi + * Copyright (C) 2014 revosec AG + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ |
