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