test_all now counts number of tests
[strongswan.git] / Source / charon / tester.c
1 /**
2 * @file tester.c
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
24 #include <stdlib.h>
25 #include <freeswan.h>
26 #include <pluto/constants.h>
27 #include <pluto/defs.h>
28
29 #include "tester.h"
30 #include "linked_list.h"
31
32 typedef struct {
33 tester_t tester;
34
35 FILE* output;
36 } private_tester_t;
37
38 /**
39 * @brief Test function to test the linked list class
40 */
41 static status_t test_linked_list(private_tester_t * this){
42 fprintf(this->output,"Test linked list class...\n");
43 linked_list_t * linked_list_create();
44
45 return FAILED;
46 }
47
48 static status_t test_all(tester_t *tester)
49 {
50 private_tester_t *this =(private_tester_t*) tester;
51 int tests_failed = 0;
52 int test_count = 0;
53
54 fprintf(this->output,"Start testing\n");
55
56 if (test_linked_list(this) != SUCCESS){ tests_failed++; } test_count++;
57
58 fprintf(this->output,"End testing. %d tests failed of %d tests\n",tests_failed,test_count);
59 //report_leaks();
60 return SUCCESS;
61 }
62
63 static status_t destroy(tester_t *this)
64 {
65 pfree(this);
66 return SUCCESS;
67 }
68
69
70 tester_t *tester_create(FILE *output)
71 {
72 private_tester_t *this = alloc_thing(private_tester_t, "private_tester_t");
73
74 this->tester.destroy = destroy;
75 this->tester.test_all = test_all;
76
77 this->output = output;
78
79 return &(this->tester);
80 }