generation of uint implemented but not tested
[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 "allocator.h"
27 #include "tester.h"
28 #include "job_queue.h"
29 #include "event_queue.h"
30 #include "send_queue.h"
31 #include "socket.h"
32 #include "tests/linked_list_test.h"
33 #include "tests/thread_pool_test.h"
34 #include "tests/job_queue_test.h"
35 #include "tests/event_queue_test.h"
36 #include "tests/send_queue_test.h"
37 #include "tests/socket_test.h"
38 #include "tests/sender_test.h"
39 #include "tests/scheduler_test.h"
40 #include "tests/receiver_test.h"
41 #include "tests/ike_sa_id_test.h"
42 #include "tests/ike_sa_test.h"
43 #include "tests/ike_sa_manager_test.h"
44 #include "tests/generator_test.h"
45
46
47 /* output for test messages */
48 extern FILE * stderr;
49
50 /**
51 * Test for linked_list_t
52 */
53 test_t linked_list_test = {test_linked_list,"Linked List"};
54
55 /**
56 * Test for linked_list_t with iterator
57 */
58 test_t linked_list_iterator_test = {test_linked_list_iterator,"Linked List Iterator"};
59
60 /**
61 * Test for linked_list_t insert and remove
62 */
63 test_t linked_list_insert_and_remove_test = {test_linked_list_insert_and_remove,"Linked List Insert and remove"};
64
65 /**
66 * Test for event_queue_t
67 */
68 test_t event_queue_test = {test_event_queue,"Event-Queue"};
69
70 /**
71 * Test 1 for job_queue_t
72 */
73 test_t job_queue_test1 = {test_job_queue,"Job-Queue"};
74
75 /**
76 * Test 1 for linked_list_t
77 */
78 test_t send_queue_test = {test_send_queue,"Send-Queue"};
79
80 /**
81 * Test for socket_t
82 */
83 test_t socket_test = {test_socket,"Socket"};
84
85 /**
86 * Test for thread_pool_t
87 */
88 test_t thread_pool_test = {test_thread_pool,"Thread Pool"};
89
90 /**
91 * Test for sender_t
92 */
93 test_t sender_test = {test_sender,"Sender"};
94
95 /**
96 * Test for scheduler_t
97 */
98 test_t scheduler_test = {test_scheduler,"Scheduler"};
99
100 /**
101 * Test for receiver_t
102 */
103 test_t receiver_test = {test_receiver,"Receiver"};
104
105 /**
106 * Test for ike_sa_id_t
107 */
108 test_t ike_sa_id_test = {test_ike_sa_id,"IKE_SA-Identifier"};
109
110 /**
111 * Test for ike_sa_t
112 */
113 test_t ike_sa_test = {test_ike_sa,"IKE_SA"};
114
115
116 /**
117 * Test for ike_sa_manager_t
118 */
119 test_t ike_sa_manager_test = {test_ike_sa_manager, "IKE_SA-Manager"};
120
121 /**
122 * Test for generator_t
123 */
124 test_t generator_test1 = {test_generator_with_unsupported_payload,"Generator: unsupported payload"};
125
126 /**
127 * Test 2 for generator_t
128 */
129 test_t generator_test2 = {test_generator_with_header_payload,"Generator: header payload"};
130
131 /**
132 * Global job-queue
133 */
134 job_queue_t *global_job_queue;
135
136 /**
137 * Global event-queue
138 */
139 event_queue_t *global_event_queue;
140
141 /**
142 * Global send-queue
143 */
144 send_queue_t *global_send_queue;
145
146 /**
147 * Global socket
148 */
149 socket_t *global_socket;
150
151 int main()
152 {
153 FILE * test_output = stderr;
154
155 test_t *all_tests[] ={
156 &linked_list_test,
157 &linked_list_iterator_test,
158 &linked_list_insert_and_remove_test,
159 &thread_pool_test,
160 &job_queue_test1,
161 &event_queue_test,
162 &send_queue_test,
163 &scheduler_test,
164 &socket_test,
165 &sender_test,
166 &receiver_test,
167 &ike_sa_id_test,
168 &ike_sa_test,
169 &generator_test1,
170 &generator_test2,
171 &ike_sa_manager_test,
172 NULL
173 };
174
175 global_socket = socket_create(4600);
176
177 global_job_queue = job_queue_create();
178 global_event_queue = event_queue_create();
179 global_send_queue = send_queue_create();
180
181 tester_t *tester = tester_create(test_output, FALSE);
182
183 /*tester->perform_tests(tester,all_tests);*/
184 tester->perform_test(tester,&generator_test2);
185
186 tester->destroy(tester);
187
188 /* Destroy all queues */
189 global_job_queue->destroy(global_job_queue);
190 global_event_queue->destroy(global_event_queue);
191 global_send_queue->destroy(global_send_queue);
192
193 global_socket->destroy(global_socket);
194
195 #ifdef LEAK_DETECTIVE
196 /* Leaks are reported on stderr */
197 report_memory_leaks();
198 #endif
199
200 return 0;
201 }