Annotation of embedaddon/strongswan/src/libcharon/tests/libcharon_tests.c, revision 1.1
1.1 ! misho 1: /*
! 2: * Copyright (C) 2014 Martin Willi
! 3: * Copyright (C) 2014 revosec AG
! 4: *
! 5: * This program is free software; you can redistribute it and/or modify it
! 6: * under the terms of the GNU General Public License as published by the
! 7: * Free Software Foundation; either version 2 of the License, or (at your
! 8: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
! 9: *
! 10: * This program is distributed in the hope that it will be useful, but
! 11: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
! 12: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
! 13: * for more details.
! 14: */
! 15:
! 16: #include <test_runner.h>
! 17: #include <daemon.h>
! 18:
! 19: /* declare test suite constructors */
! 20: #define TEST_SUITE(x) test_suite_t* x();
! 21: #define TEST_SUITE_DEPEND(x, ...) TEST_SUITE(x)
! 22: #include "libcharon_tests.h"
! 23: #undef TEST_SUITE
! 24: #undef TEST_SUITE_DEPEND
! 25:
! 26: static test_configuration_t tests[] = {
! 27: #define TEST_SUITE(x) \
! 28: { .suite = x, },
! 29: #define TEST_SUITE_DEPEND(x, type, ...) \
! 30: { .suite = x, .feature = PLUGIN_DEPENDS(type, __VA_ARGS__) },
! 31: #include "libcharon_tests.h"
! 32: { .suite = NULL, }
! 33: };
! 34:
! 35: static void initialize_logging()
! 36: {
! 37: int level = LEVEL_SILENT;
! 38: char *verbosity;
! 39:
! 40: verbosity = getenv("TESTS_VERBOSITY");
! 41: if (verbosity)
! 42: {
! 43: level = atoi(verbosity);
! 44: }
! 45: lib->settings->set_int(lib->settings, "%s.filelog.stderr.default",
! 46: lib->settings->get_int(lib->settings, "%s.filelog.stderr.default",
! 47: level, lib->ns), lib->ns);
! 48: charon->load_loggers(charon);
! 49: }
! 50:
! 51: static bool test_runner_init(bool init)
! 52: {
! 53: if (init)
! 54: {
! 55: char *plugins, *plugindir;
! 56:
! 57: libcharon_init();
! 58: initialize_logging();
! 59:
! 60: plugins = getenv("TESTS_PLUGINS") ?:
! 61: lib->settings->get_str(lib->settings,
! 62: "tests.load", PLUGINS);
! 63: plugindir = lib->settings->get_str(lib->settings,
! 64: "tests.plugindir", PLUGINDIR);
! 65: plugin_loader_add_plugindirs(plugindir, plugins);
! 66: if (!lib->plugins->load(lib->plugins, plugins))
! 67: {
! 68: return FALSE;
! 69: }
! 70: }
! 71: else
! 72: {
! 73: libcharon_deinit();
! 74: }
! 75: return TRUE;
! 76: }
! 77:
! 78: int main(int argc, char *argv[])
! 79: {
! 80: return test_runner_run("libcharon", tests, test_runner_init);
! 81: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>