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