- prf_plus test
[strongswan.git] / Source / charon / testcases / testcases.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 "../queues/job_queue.h"
27 #include "../queues/event_queue.h"
28 #include "../queues/send_queue.h"
29 #include "../configuration_manager.h"
30 #include "../ike_sa_manager.h"
31 #include "../socket.h"
32 #include "../utils/logger_manager.h"
33 #include "../utils/allocator.h"
34 #include "../utils/tester.h"
35 #include "linked_list_test.h"
36 #include "thread_pool_test.h"
37 #include "job_queue_test.h"
38 #include "event_queue_test.h"
39 #include "send_queue_test.h"
40 #include "socket_test.h"
41 #include "sender_test.h"
42 #include "scheduler_test.h"
43 #include "receiver_test.h"
44 #include "ike_sa_id_test.h"
45 #include "ike_sa_test.h"
46 #include "ike_sa_manager_test.h"
47 #include "generator_test.h"
48 #include "parser_test.h"
49 #include "packet_test.h"
50 #include "diffie_hellman_test.h"
51 #include "hasher_sha1_test.h"
52 #include "hmac_test.h"
53 #include "prf_plus_test.h"
54
55
56 /* output for test messages */
57 extern FILE * stderr;
58
59 /**
60 * Test for linked_list_t
61 */
62 test_t linked_list_test = {test_linked_list,"Linked List"};
63
64 /**
65 * Test for linked_list_t with iterator
66 */
67 test_t linked_list_iterator_test = {test_linked_list_iterator,"Linked List Iterator"};
68
69 /**
70 * Test for linked_list_t insert and remove
71 */
72 test_t linked_list_insert_and_remove_test = {test_linked_list_insert_and_remove,"Linked List Insert and remove"};
73
74 /**
75 * Test for event_queue_t
76 */
77 test_t event_queue_test = {test_event_queue,"Event-Queue"};
78
79 /**
80 * Test 1 for job_queue_t
81 */
82 test_t job_queue_test1 = {test_job_queue,"Job-Queue"};
83
84 /**
85 * Test 1 for linked_list_t
86 */
87 test_t send_queue_test = {test_send_queue,"Send-Queue"};
88
89 /**
90 * Test for socket_t
91 */
92 test_t socket_test = {test_socket,"Socket"};
93
94 /**
95 * Test for thread_pool_t
96 */
97 test_t thread_pool_test = {test_thread_pool,"Thread Pool"};
98
99 /**
100 * Test for sender_t
101 */
102 test_t sender_test = {test_sender,"Sender"};
103
104 /**
105 * Test for scheduler_t
106 */
107 test_t scheduler_test = {test_scheduler,"Scheduler"};
108
109 /**
110 * Test for receiver_t
111 */
112 test_t receiver_test = {test_receiver,"Receiver"};
113
114 /**
115 * Test for ike_sa_id_t
116 */
117 test_t ike_sa_id_test = {test_ike_sa_id,"IKE_SA-Identifier"};
118
119 /**
120 * Test for ike_sa_t
121 */
122 test_t ike_sa_test = {test_ike_sa,"IKE_SA"};
123
124
125 /**
126 * Test for ike_sa_manager_t
127 */
128 test_t ike_sa_manager_test = {test_ike_sa_manager, "IKE_SA-Manager"};
129
130 test_t generator_test1 = {test_generator_with_header_payload,"Generator: header payload"};
131 test_t generator_test2 = {test_generator_with_transform_attribute,"Generator: transform attribute"};
132 test_t generator_test3 = {test_generator_with_transform_substructure,"Generator: transform substructure"};
133 test_t generator_test4 = {test_generator_with_proposal_substructure,"Generator: proposal substructure"};
134 test_t generator_test5 = {test_generator_with_sa_payload,"Generator: Message with SA Payload"};
135 test_t generator_test6 = {test_generator_with_ke_payload,"Generator: KE Payload"};
136 test_t generator_test7 = {test_generator_with_notify_payload,"Generator: Notify Payload"};
137 test_t generator_test8 = {test_generator_with_nonce_payload,"Generator: Nonce Payload"};
138
139
140 /**
141 * Parser test for ike header
142 */
143 test_t parser_test1 = {test_parser_with_header_payload, "Parser: header payload"};
144
145
146 /**
147 * Parser test for ike security association
148 */
149 test_t parser_test2 = {test_parser_with_sa_payload, "Parser: sa payload"};
150
151 /**
152 * Parser test for ike nonce payload
153 */
154 test_t parser_test3 = {test_parser_with_nonce_payload, "Parser: nonce payload"};
155
156 /**
157 * Parser test for ike nonce payload
158 */
159 test_t parser_test4 = {test_parser_with_ke_payload, "Parser: key exchange payload"};
160
161 /**
162 * Parser test for ike notify payload
163 */
164 test_t parser_test5 = {test_parser_with_notify_payload, "Parser: notify payload"};
165
166
167 /**
168 * Test for packet_t
169 */
170 test_t packet_test = {test_packet,"Packet"};
171
172
173 /**
174 * Test for packet_t
175 */
176 test_t diffie_hellman_test = {test_diffie_hellman,"Diffie Hellman"};
177
178 /**
179 * Test for sha1 hasher
180 */
181 test_t hasher_sha1_test = {test_hasher_sha1,"SHA1 hasher"};
182
183 /**
184 * Test for hmac
185 */
186 test_t hmac_test1 = {test_hmac_sha1, "HMAC-SHA1"};
187
188 /**
189 * Test for prf_plus
190 */
191 test_t prf_plus_test = {test_prf_plus, "prf+"};
192
193
194
195
196
197 /**
198 * Global job-queue
199 */
200 job_queue_t *global_job_queue;
201
202 /**
203 * Global event-queue
204 */
205 event_queue_t *global_event_queue;
206
207 /**
208 * Global send-queue
209 */
210 send_queue_t *global_send_queue;
211
212 /**
213 * Global configuration_manager
214 */
215 configuration_manager_t *global_configuration_manager;
216
217 /**
218 * Global configuration_manager
219 */
220 ike_sa_manager_t *global_ike_sa_manager;
221
222 /**
223 * Global socket
224 */
225 socket_t *global_socket;
226
227
228 /**
229 * Global logger
230 */
231 logger_manager_t *global_logger_manager;
232
233 int main()
234 {
235 FILE * test_output = stderr;
236
237 test_t *all_tests[] ={
238 &linked_list_test,
239 &linked_list_iterator_test,
240 &linked_list_insert_and_remove_test,
241 &thread_pool_test,
242 &job_queue_test1,
243 &event_queue_test,
244 &send_queue_test,
245 &scheduler_test,
246 &socket_test,
247 &sender_test,
248 &receiver_test,
249 &ike_sa_id_test,
250 &ike_sa_test,
251 &generator_test1,
252 &generator_test2,
253 &parser_test1,
254 &parser_test2,
255 &parser_test3,
256 &parser_test4,
257 &parser_test5,
258 &generator_test3,
259 &generator_test4,
260 &generator_test5,
261 &generator_test6,
262 &generator_test7,
263 &generator_test8,
264 &ike_sa_manager_test,
265 &packet_test,
266 &diffie_hellman_test,
267 &hasher_sha1_test,
268 NULL
269 };
270 global_logger_manager = logger_manager_create(FULL);
271
272 global_socket = socket_create(4600);
273
274 global_job_queue = job_queue_create();
275 global_event_queue = event_queue_create();
276 global_send_queue = send_queue_create();
277 global_configuration_manager = configuration_manager_create();
278 global_ike_sa_manager = ike_sa_manager_create();
279
280 global_logger_manager->disable_logger_level(global_logger_manager,TESTER,FULL);
281
282 tester_t *tester = tester_create(test_output, FALSE);
283
284
285 //tester->perform_tests(tester,all_tests);
286 tester->perform_test(tester,&prf_plus_test);
287
288
289
290 tester->destroy(tester);
291
292
293 /* Destroy all queues */
294 global_job_queue->destroy(global_job_queue);
295 global_event_queue->destroy(global_event_queue);
296 global_send_queue->destroy(global_send_queue);
297
298 global_socket->destroy(global_socket);
299
300 global_logger_manager->destroy(global_logger_manager);
301
302 #ifdef LEAK_DETECTIVE
303 /* Leaks are reported on stderr */
304 report_memory_leaks(void);
305 #endif
306
307 return 0;
308 }