diff --git a/configure.in b/configure.in index 8df0c2a0b..b366a6a0d 100644 --- a/configure.in +++ b/configure.in @@ -1320,6 +1320,7 @@ AC_CONFIG_FILES([ src/libstrongswan/plugins/gcm/Makefile src/libstrongswan/plugins/af_alg/Makefile src/libstrongswan/plugins/test_vectors/Makefile + src/libstrongswan/tests/Makefile src/libhydra/Makefile src/libhydra/plugins/attr/Makefile src/libhydra/plugins/attr_sql/Makefile diff --git a/src/libstrongswan/Makefile.am b/src/libstrongswan/Makefile.am index 2465fb09d..bde69645f 100644 --- a/src/libstrongswan/Makefile.am +++ b/src/libstrongswan/Makefile.am @@ -455,3 +455,10 @@ if MONOLITHIC libstrongswan_la_LIBADD += plugins/test_vectors/libstrongswan-test-vectors.la endif endif + +if UNITTESTS +if MONOLITHIC + SUBDIRS += . +endif + SUBDIRS += tests +endif diff --git a/src/libstrongswan/tests/.gitignore b/src/libstrongswan/tests/.gitignore new file mode 100644 index 000000000..35429f617 --- /dev/null +++ b/src/libstrongswan/tests/.gitignore @@ -0,0 +1 @@ +test_runner diff --git a/src/libstrongswan/tests/Makefile.am b/src/libstrongswan/tests/Makefile.am new file mode 100644 index 000000000..215cdde8b --- /dev/null +++ b/src/libstrongswan/tests/Makefile.am @@ -0,0 +1,15 @@ +TESTS = test_runner + +check_PROGRAMS = $(TESTS) + +test_runner_SOURCES = \ + test_runner.c test_runner.h + + +test_runner_CFLAGS = \ + -I$(top_srcdir)/src/libstrongswan \ + @CHECK_CFLAGS@ + +test_runner_LDADD = \ + $(top_builddir)/src/libstrongswan/libstrongswan.la \ + @CHECK_LIBS@ diff --git a/src/libstrongswan/tests/test_runner.c b/src/libstrongswan/tests/test_runner.c new file mode 100644 index 000000000..264dd700d --- /dev/null +++ b/src/libstrongswan/tests/test_runner.c @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2013 Tobias Brunner + * Hochschule fuer Technik Rapperswil + * + * 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 . + * + * 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 + +int main() +{ + SRunner *sr; + int nf; + + /* if a test fails there is no cleanup, so disable leak detective */ + setenv("LEAK_DETECTIVE_DISABLE", "1", 1); + + library_init(NULL); + + sr = srunner_create(NULL); + + srunner_run_all(sr, CK_NORMAL); + nf = srunner_ntests_failed(sr); + + srunner_free(sr); + library_deinit(); + + return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/src/libstrongswan/tests/test_runner.h b/src/libstrongswan/tests/test_runner.h new file mode 100644 index 000000000..f7a7d7510 --- /dev/null +++ b/src/libstrongswan/tests/test_runner.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2013 Tobias Brunner + * Hochschule fuer Technik Rapperswil + * + * 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 . + * + * 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. + */ + +#ifndef TEST_RUNNER_H_ +#define TEST_RUNNER_H_ + +#include + +#endif /** TEST_RUNNER_H_ */