- Tests are now separated in test files in the tests-directory
[strongswan.git] / Source / charon / tester.h
1 /**
2 * @file tester.h
3 *
4 * @brief Test module for automatic testing
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #ifndef TESTER_H_
24 #define TESTER_H_
25
26 #include <stdio.h>
27 #include <freeswan.h>
28 #include <pluto/constants.h>
29 #include <pluto/defs.h>
30
31 #include "types.h"
32
33 /**
34 * @brief Specifies a test
35 */
36 typedef struct test_s test_t;
37
38 /**
39 * @brief A tester object to perform tests
40 */
41 typedef struct tester_s tester_t;
42
43 struct test_s{
44 void (*test_function) (tester_t * tester);
45 char * test_name;
46 };
47
48 struct tester_s {
49
50 /**
51 * @brief Tests all testcases of specific tester object
52 *
53 * @param tester tester object
54 * @param pointer to a list of tests to perform.
55 * the last list item has to be NULL.
56 * @return SUCCESSFUL if succeeded, FAILED otherwise
57 */
58 status_t (*test_all) (tester_t *tester,test_t **tests);
59
60 /**
61 * @brief is called in a testcase to check a specific situation
62 *
63 * Log-Values to the tester output are protected from multiple access
64 *
65 * @param this tester object
66 * @param to_be_true assert which has to be true
67 * @param Name of the assertion
68 */
69 void (*assert_true) (tester_t *tester, bool to_be_true, char *assert_name);
70
71 /**
72 * @brief run a specific test case
73 *
74 * @param this tester object
75 * @param test_function implements the test case
76 * @param Name of the Test
77 */
78 void (*run_test) (tester_t *this, void (*test_function) (tester_t * tester), char * test_name);
79
80 /**
81 * @brief Destroys a tester object
82 *
83 * @param tester tester object
84 * @param Name of the Test
85 * @return SUCCESSFUL if succeeded, FAILED otherwise
86 */
87 status_t (*destroy) (tester_t *tester);
88 };
89
90 tester_t *tester_create(FILE *output);
91
92 #endif /*TESTER_H_*/