4 * @brief Main for all tests
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
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>.
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
26 #include <queues/job_queue.h>
27 #include <queues/event_queue.h>
28 #include <queues/send_queue.h>
29 #include <config/configuration_manager.h>
30 #include <sa/ike_sa_manager.h>
31 #include <network/socket.h>
32 #include <utils/logger_manager.h>
33 #include <utils/allocator.h>
34 #include <utils/tester.h>
35 #include <testcases/linked_list_test.h>
36 #include <testcases/thread_pool_test.h>
37 #include <testcases/job_queue_test.h>
38 #include <testcases/event_queue_test.h>
39 #include <testcases/send_queue_test.h>
40 #include <testcases/socket_test.h>
41 #include <testcases/sender_test.h>
42 #include <testcases/scheduler_test.h>
43 #include <testcases/receiver_test.h>
44 #include <testcases/ike_sa_id_test.h>
45 #include <testcases/ike_sa_test.h>
46 #include <testcases/ike_sa_manager_test.h>
47 #include <testcases/generator_test.h>
48 #include <testcases/parser_test.h>
49 #include <testcases/packet_test.h>
50 #include <testcases/diffie_hellman_test.h>
51 #include <testcases/hasher_sha1_test.h>
52 #include <testcases/hasher_md5_test.h>
53 #include <testcases/hmac_test.h>
54 #include <testcases/prf_plus_test.h>
57 /* output for test messages */
61 * Test for linked_list_t
63 test_t linked_list_test
= {test_linked_list
,"Linked List"};
66 * Test for linked_list_t with iterator
68 test_t linked_list_iterator_test
= {test_linked_list_iterator
,"Linked List Iterator"};
71 * Test for linked_list_t insert and remove
73 test_t linked_list_insert_and_remove_test
= {test_linked_list_insert_and_remove
,"Linked List Insert and remove"};
76 * Test for event_queue_t
78 test_t event_queue_test
= {test_event_queue
,"Event-Queue"};
81 * Test 1 for job_queue_t
83 test_t job_queue_test1
= {test_job_queue
,"Job-Queue"};
86 * Test 1 for linked_list_t
88 test_t send_queue_test
= {test_send_queue
,"Send-Queue"};
93 test_t socket_test
= {test_socket
,"Socket"};
96 * Test for thread_pool_t
98 test_t thread_pool_test
= {test_thread_pool
,"Thread Pool"};
103 test_t sender_test
= {test_sender
,"Sender"};
106 * Test for scheduler_t
108 test_t scheduler_test
= {test_scheduler
,"Scheduler"};
111 * Test for receiver_t
113 test_t receiver_test
= {test_receiver
,"Receiver"};
116 * Test for ike_sa_id_t
118 test_t ike_sa_id_test
= {test_ike_sa_id
,"IKE_SA-Identifier"};
123 test_t ike_sa_test
= {test_ike_sa
,"IKE_SA"};
127 * Test for ike_sa_manager_t
129 test_t ike_sa_manager_test
= {test_ike_sa_manager
, "IKE_SA-Manager"};
131 test_t generator_test1
= {test_generator_with_header_payload
,"Generator: header payload"};
132 test_t generator_test2
= {test_generator_with_transform_attribute
,"Generator: transform attribute"};
133 test_t generator_test3
= {test_generator_with_transform_substructure
,"Generator: transform substructure"};
134 test_t generator_test4
= {test_generator_with_proposal_substructure
,"Generator: proposal substructure"};
135 test_t generator_test5
= {test_generator_with_sa_payload
,"Generator: Message with SA Payload"};
136 test_t generator_test6
= {test_generator_with_ke_payload
,"Generator: KE Payload"};
137 test_t generator_test7
= {test_generator_with_notify_payload
,"Generator: Notify Payload"};
138 test_t generator_test8
= {test_generator_with_nonce_payload
,"Generator: Nonce Payload"};
142 * Parser test for ike header
144 test_t parser_test1
= {test_parser_with_header_payload
, "Parser: header payload"};
148 * Parser test for ike security association
150 test_t parser_test2
= {test_parser_with_sa_payload
, "Parser: sa payload"};
153 * Parser test for ike nonce payload
155 test_t parser_test3
= {test_parser_with_nonce_payload
, "Parser: nonce payload"};
158 * Parser test for ike nonce payload
160 test_t parser_test4
= {test_parser_with_ke_payload
, "Parser: key exchange payload"};
163 * Parser test for ike notify payload
165 test_t parser_test5
= {test_parser_with_notify_payload
, "Parser: notify payload"};
171 test_t packet_test
= {test_packet
,"Packet"};
177 test_t diffie_hellman_test
= {test_diffie_hellman
,"Diffie Hellman"};
180 * Test for sha1 hasher
182 test_t hasher_sha1_test
= {test_hasher_sha1
,"SHA1 hasher"};
185 * Test for md5 hasher
187 test_t hasher_md5_test
= {test_hasher_md5
,"MD5 hasher"};
192 test_t hmac_test1
= {test_hmac_sha1
, "HMAC using SHA1"};
193 test_t hmac_test2
= {test_hmac_md5
, "HMAC using MD5"};
198 test_t prf_plus_test
= {test_prf_plus
, "prf+"};
207 job_queue_t
*global_job_queue
;
212 event_queue_t
*global_event_queue
;
217 send_queue_t
*global_send_queue
;
220 * Global configuration_manager
222 configuration_manager_t
*global_configuration_manager
;
225 * Global configuration_manager
227 ike_sa_manager_t
*global_ike_sa_manager
;
232 socket_t
*global_socket
;
238 logger_manager_t
*global_logger_manager
;
242 FILE * test_output
= stderr
;
244 test_t
*all_tests
[] ={
246 &linked_list_iterator_test
,
247 &linked_list_insert_and_remove_test
,
271 &ike_sa_manager_test
,
273 &diffie_hellman_test
,
281 global_logger_manager
= logger_manager_create(FULL
);
283 global_socket
= socket_create(4600);
285 global_job_queue
= job_queue_create();
286 global_event_queue
= event_queue_create();
287 global_send_queue
= send_queue_create();
288 global_configuration_manager
= configuration_manager_create();
289 global_ike_sa_manager
= ike_sa_manager_create();
291 global_logger_manager
->disable_logger_level(global_logger_manager
,TESTER
,FULL
);
293 tester_t
*tester
= tester_create(test_output
, FALSE
);
296 tester
->perform_tests(tester
,all_tests
);
297 //tester->perform_test(tester,&hmac_test2);
301 tester
->destroy(tester
);
304 /* Destroy all queues */
305 global_job_queue
->destroy(global_job_queue
);
306 global_event_queue
->destroy(global_event_queue
);
307 global_send_queue
->destroy(global_send_queue
);
309 global_socket
->destroy(global_socket
);
311 global_logger_manager
->destroy(global_logger_manager
);
313 #ifdef LEAK_DETECTIVE
314 /* Leaks are reported on stderr */
315 report_memory_leaks(void);