summaryrefslogtreecommitdiff
path: root/src/libstrongswan/tests/test_runner.h
blob: de87a1f0fe5d67b72a0cb34e9669e3f5a6b5c5c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 * Copyright (C) 2013 Martin Willi
 * Copyright (C) 2013 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.
 */

/**
 * @defgroup libtest libtest
 *
 * @defgroup test_utils test_utils
 * @ingroup libtest
 *
 * @defgroup test_runner test_runner
 * @{ @ingroup libtest
 */

#ifndef TEST_RUNNER_H_
#define TEST_RUNNER_H_

#include "test_suite.h"

#include <plugins/plugin_feature.h>

typedef struct test_configuration_t test_configuration_t;

/**
 * Callback called before and after each test case to de-/initialize the
 * environment (e.g. to load plugins).  It is also called before and after the
 * test suites are loaded.
 *
 * It is called after libstrongswan has been initialized and likewise before it
 * gets deinitialized.
 *
 * @param init			TRUE during initialization
 * @return				FALSE if de-/init failed
 */
typedef bool (*test_runner_init_t)(bool init);

/**
 * Test configuration, suite constructor with plugin dependency
 */
struct test_configuration_t {

	/**
	 * Constructor function to create suite.
	 */
	test_suite_t *(*suite)();

	/**
	 * Plugin feature this test suite depends on
	 */
	plugin_feature_t feature;
};

/**
 * Run test configuration.
 *
 * The configs array must be terminated with a NULL element. The following
 * environment variables are currently supported:
 *
 * - TESTS_VERBOSITY: Numerical loglevel for debug log
 * - TESTS_STRONGSWAN_CONF: Specify a path to a custom strongswan.conf
 * - TESTS_SUITES: Run specific test suites only
 * - TESTS_REDUCED_KEYLENGTHS: Test minimal keylengths for public key tests only
 *
 * @param name			name of test runner
 * @param config		test suite constructors with dependencies
 * @param init_cb		init/deinit callback
 * @return				test result, EXIT_SUCCESS if all tests passed
 */
int test_runner_run(const char *name, test_configuration_t config[],
					test_runner_init_t init_cb);

#endif /** TEST_RUNNER_H_ @}*/