- added test of receiver
[strongswan.git] / Source / charon / tests.c
1 /**
2 * @file tests.c
3 *
4 * @brief Main for all tests
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 <stdio.h>
25 #
26 #include "tester.h"
27 #include "job_queue.h"
28 #include "event_queue.h"
29 #include "send_queue.h"
30 #include "socket.h"
31 #include "tests/linked_list_test.h"
32 #include "tests/thread_pool_test.h"
33 #include "tests/job_queue_test.h"
34 #include "tests/event_queue_test.h"
35 #include "tests/send_queue_test.h"
36 #include "tests/socket_test.h"
37 #include "tests/sender_test.h"
38 #include "tests/receiver_test.h"
39
40
41 /* output for test messages */
42 extern FILE * stderr;
43
44 /**
45 * Test for linked_list_t
46 */
47 test_t linked_list_test = {test_linked_list,"Linked List"};
48
49 /**
50 * Test for linked_list_t with iterator
51 */
52 test_t linked_list_iterator_test = {test_linked_list_iterator,"Linked List Iterator"};
53
54 /**
55 * Test for linked_list_t insert and remove
56 */
57 test_t linked_list_insert_and_remove_test = {test_linked_list_insert_and_remove,"Linked List Insert and remove"};
58
59 /**
60 * Test for event_queue_t
61 */
62 test_t event_queue_test = {test_event_queue,"Event-Queue"};
63
64 /**
65 * Test 1 for job_queue_t
66 */
67 test_t job_queue_test1 = {test_job_queue,"Job-Queue"};
68
69 /**
70 * Test 1 for linked_list_t
71 */
72 test_t send_queue_test = {test_send_queue,"Send-Queue"};
73
74 /**
75 * Test for socket_t
76 */
77 test_t socket_test = {test_socket,"Socket"};
78
79 /**
80 * Test for thread_pool_t
81 */
82 test_t thread_pool_test = {test_thread_pool,"Thread Pool"};
83
84 /**
85 * Test for sender_t
86 */
87 test_t sender_test = {test_sender,"Sender"};
88
89 /**
90 * Test for receiver_t
91 */
92 test_t receiver_test = {test_receiver,"Receiver"};
93
94 /**
95 * Global job-queue
96 */
97 job_queue_t *global_job_queue;
98
99 /**
100 * Global event-queue
101 */
102 event_queue_t *global_event_queue;
103
104 /**
105 * Global send-queue
106 */
107 send_queue_t *global_send_queue;
108
109 /**
110 * Global socket
111 */
112 socket_t *global_socket;
113
114 int main()
115 {
116 FILE * test_output = stderr;
117
118 test_t *all_tests[] ={
119 &linked_list_test,
120 &linked_list_iterator_test,
121 &linked_list_insert_and_remove_test,
122 &thread_pool_test,
123 &job_queue_test1,
124 &event_queue_test,
125 &send_queue_test,
126 &socket_test,
127 &sender_test,
128 &receiver_test,
129 NULL
130 };
131
132 global_socket = socket_create(4600);
133
134 global_job_queue = job_queue_create();
135 global_event_queue = event_queue_create();
136 global_send_queue = send_queue_create();
137
138 tester_t *tester = tester_create(test_output, FALSE);
139
140 tester->perform_tests(tester,all_tests);
141 /* tester->perform_test(tester,&receiver_test); */
142
143 tester->destroy(tester);
144
145 /* Destroy all queues */
146 global_job_queue->destroy(global_job_queue);
147 global_event_queue->destroy(global_event_queue);
148 global_send_queue->destroy(global_send_queue);
149
150 global_socket->destroy(global_socket);
151
152 #ifdef LEAK_DETECTIVE
153 /* Leaks are reported in log file */
154 report_leaks();
155 #endif
156
157 return 0;
158 }