]>
Commit | Line | Data |
---|---|---|
fd9cabd4 JH |
1 | /** |
2 | * @file tests.c | |
3 | * | |
ed37dee6 | 4 | * @brief Main for all testcases. |
fd9cabd4 JH |
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 | |
0e96f7d8 MW |
26 | #include <daemon.h> |
27 | ||
94852e75 JH |
28 | #include <queues/job_queue.h> |
29 | #include <queues/event_queue.h> | |
30 | #include <queues/send_queue.h> | |
face0be4 MW |
31 | #include <config/configuration_manager.h> |
32 | #include <sa/ike_sa_manager.h> | |
33 | #include <network/socket.h> | |
94852e75 JH |
34 | #include <utils/logger_manager.h> |
35 | #include <utils/allocator.h> | |
36 | #include <utils/tester.h> | |
37 | #include <testcases/linked_list_test.h> | |
38 | #include <testcases/thread_pool_test.h> | |
39 | #include <testcases/job_queue_test.h> | |
40 | #include <testcases/event_queue_test.h> | |
41 | #include <testcases/send_queue_test.h> | |
42 | #include <testcases/socket_test.h> | |
43 | #include <testcases/sender_test.h> | |
44 | #include <testcases/scheduler_test.h> | |
45 | #include <testcases/receiver_test.h> | |
46 | #include <testcases/ike_sa_id_test.h> | |
47 | #include <testcases/ike_sa_test.h> | |
48 | #include <testcases/ike_sa_manager_test.h> | |
49 | #include <testcases/generator_test.h> | |
50 | #include <testcases/parser_test.h> | |
51 | #include <testcases/packet_test.h> | |
52 | #include <testcases/diffie_hellman_test.h> | |
b2410480 | 53 | #include <testcases/hasher_test.h> |
94852e75 JH |
54 | #include <testcases/hmac_test.h> |
55 | #include <testcases/prf_plus_test.h> | |
7b0dafeb | 56 | #include <testcases/aes_cbc_crypter_test.h> |
42e69fbd | 57 | #include <testcases/hmac_signer_test.h> |
fd9cabd4 JH |
58 | |
59 | /* output for test messages */ | |
60 | extern FILE * stderr; | |
61 | ||
fd9cabd4 | 62 | test_t linked_list_test = {test_linked_list,"Linked List"}; |
bdb141cb | 63 | test_t iterator_test = {test_linked_list_iterator,"Linked List Iterator"}; |
fd9cabd4 | 64 | test_t linked_list_insert_and_remove_test = {test_linked_list_insert_and_remove,"Linked List Insert and remove"}; |
6962f6c9 | 65 | test_t event_queue_test = {test_event_queue,"Event-Queue"}; |
6962f6c9 | 66 | test_t job_queue_test1 = {test_job_queue,"Job-Queue"}; |
6962f6c9 | 67 | test_t send_queue_test = {test_send_queue,"Send-Queue"}; |
fd9cabd4 | 68 | test_t socket_test = {test_socket,"Socket"}; |
fd9cabd4 | 69 | test_t thread_pool_test = {test_thread_pool,"Thread Pool"}; |
6962f6c9 | 70 | test_t sender_test = {test_sender,"Sender"}; |
6d4f09bc | 71 | test_t scheduler_test = {test_scheduler,"Scheduler"}; |
50fffcc4 | 72 | test_t receiver_test = {test_receiver,"Receiver"}; |
c9473633 | 73 | test_t ike_sa_id_test = {test_ike_sa_id,"IKE_SA-Identifier"}; |
4acf505a | 74 | test_t ike_sa_test = {test_ike_sa,"IKE_SA"}; |
d4425c1b | 75 | test_t ike_sa_manager_test = {test_ike_sa_manager, "IKE_SA-Manager"}; |
f3c01a28 | 76 | test_t generator_test1 = {test_generator_with_header_payload,"Generator: header payload"}; |
f3c01a28 | 77 | test_t generator_test2 = {test_generator_with_transform_attribute,"Generator: transform attribute"}; |
f3c01a28 | 78 | test_t generator_test3 = {test_generator_with_transform_substructure,"Generator: transform substructure"}; |
2b9dd467 | 79 | test_t generator_test4 = {test_generator_with_proposal_substructure,"Generator: proposal substructure"}; |
7f613a4b | 80 | test_t generator_test5 = {test_generator_with_sa_payload,"Generator: Message with SA Payload"}; |
113f461e | 81 | test_t generator_test6 = {test_generator_with_ke_payload,"Generator: KE Payload"}; |
8166bcec | 82 | test_t generator_test7 = {test_generator_with_notify_payload,"Generator: Notify Payload"}; |
2a489f33 | 83 | test_t generator_test8 = {test_generator_with_nonce_payload,"Generator: Nonce Payload"}; |
db6e7645 | 84 | test_t generator_test9 = {test_generator_with_id_payload,"Generator: ID Payload"}; |
23266335 | 85 | test_t generator_test10 = {test_generator_with_auth_payload,"Generator: AUTH Payload"}; |
260f3338 | 86 | test_t parser_test1 = {test_parser_with_header_payload, "Parser: header payload"}; |
260f3338 | 87 | test_t parser_test2 = {test_parser_with_sa_payload, "Parser: sa payload"}; |
260f3338 | 88 | test_t parser_test3 = {test_parser_with_nonce_payload, "Parser: nonce payload"}; |
22a5e2b8 | 89 | test_t parser_test4 = {test_parser_with_ke_payload, "Parser: key exchange payload"}; |
cb4f26c5 | 90 | test_t parser_test5 = {test_parser_with_notify_payload, "Parser: notify payload"}; |
db6e7645 | 91 | test_t parser_test6 = {test_parser_with_id_payload, "Parser: ID payload"}; |
23266335 | 92 | test_t parser_test7 = {test_parser_with_auth_payload, "Parser: AUTH payload"}; |
110dc83a | 93 | test_t packet_test = {test_packet,"Packet"}; |
4750f6c6 | 94 | test_t diffie_hellman_test = {test_diffie_hellman,"Diffie Hellman"}; |
b2410480 | 95 | test_t sha1_hasher_test = {test_sha1_hasher,"SHA1 hasher"}; |
b2410480 | 96 | test_t md5_hasher_test = {test_md5_hasher,"MD5 hasher"}; |
bfa4b218 | 97 | test_t hmac_test1 = {test_hmac_sha1, "HMAC using SHA1"}; |
2018a40a | 98 | test_t hmac_test2 = {test_hmac_md5, "HMAC using MD5"}; |
5e280720 | 99 | test_t prf_plus_test = {test_prf_plus, "prf+"}; |
7b0dafeb | 100 | test_t aes_cbc_crypter_test = {test_aes_cbc_crypter, "AES CBC"}; |
42e69fbd | 101 | test_t hmac_signer_test1 = {test_hmac_md5_signer, "HMAC MD5 signer test"}; |
42e69fbd | 102 | test_t hmac_signer_test2 = {test_hmac_sha1_signer, "HMAC SHA1 signer test"}; |
5e280720 | 103 | |
4750f6c6 | 104 | |
0e96f7d8 | 105 | daemon_t* charon; |
da6f7756 | 106 | |
0e96f7d8 MW |
107 | static void daemon_destroy(daemon_t *this, char* none) |
108 | { | |
109 | this->logger_manager->destroy(this->logger_manager); | |
110 | this->socket->destroy(this->socket); | |
111 | this->ike_sa_manager->destroy(this->ike_sa_manager); | |
112 | this->job_queue->destroy(this->job_queue); | |
113 | this->event_queue->destroy(this->event_queue); | |
114 | this->send_queue->destroy(this->send_queue); | |
115 | this->configuration_manager->destroy(this->configuration_manager); | |
116 | allocator_free(charon); | |
117 | } | |
9b4f5ef8 MW |
118 | |
119 | /** | |
0e96f7d8 MW |
120 | * @brief Create the dummy daemon for testing. |
121 | * | |
122 | * @return created daemon_t | |
9b4f5ef8 | 123 | */ |
0e96f7d8 MW |
124 | daemon_t *daemon_create() |
125 | { | |
126 | charon = allocator_alloc_thing(daemon_t); | |
127 | ||
128 | /* assign methods */ | |
129 | charon->destroy = daemon_destroy; | |
130 | ||
131 | charon->logger_manager = logger_manager_create(0); | |
132 | charon->socket = socket_create(4600); | |
133 | charon->ike_sa_manager = ike_sa_manager_create(); | |
134 | charon->job_queue = job_queue_create(); | |
135 | charon->event_queue = event_queue_create(); | |
136 | charon->send_queue = send_queue_create(); | |
137 | charon->configuration_manager = configuration_manager_create(); | |
138 | charon->sender = NULL; | |
139 | charon->receiver = NULL; | |
140 | charon->scheduler = NULL; | |
141 | charon->thread_pool = NULL; | |
142 | ||
143 | return charon; | |
144 | } | |
7d995669 JH |
145 | |
146 | ||
0e96f7d8 | 147 | int main() |
fd9cabd4 | 148 | { |
0e96f7d8 MW |
149 | FILE * test_output = stderr; |
150 | ||
151 | test_t *all_tests[] ={ | |
bfa4b218 | 152 | &linked_list_test, |
bdb141cb | 153 | &iterator_test, |
bfa4b218 MW |
154 | &linked_list_insert_and_remove_test, |
155 | &thread_pool_test, | |
156 | &job_queue_test1, | |
157 | &event_queue_test, | |
158 | &send_queue_test, | |
159 | &scheduler_test, | |
160 | &socket_test, | |
161 | &sender_test, | |
162 | &receiver_test, | |
163 | &ike_sa_id_test, | |
2018a40a | 164 | &ike_sa_test, |
bfa4b218 MW |
165 | &generator_test1, |
166 | &generator_test2, | |
167 | &parser_test1, | |
168 | &parser_test2, | |
169 | &parser_test3, | |
170 | &parser_test4, | |
171 | &parser_test5, | |
db6e7645 | 172 | &parser_test6, |
23266335 | 173 | &parser_test7, |
bfa4b218 MW |
174 | &generator_test3, |
175 | &generator_test4, | |
176 | &generator_test5, | |
177 | &generator_test6, | |
178 | &generator_test7, | |
179 | &generator_test8, | |
db6e7645 | 180 | &generator_test9, |
23266335 | 181 | &generator_test10, |
2018a40a | 182 | &ike_sa_manager_test, |
bfa4b218 MW |
183 | &packet_test, |
184 | &diffie_hellman_test, | |
b2410480 MW |
185 | &sha1_hasher_test, |
186 | &md5_hasher_test, | |
bfa4b218 | 187 | &hmac_test1, |
2018a40a | 188 | &hmac_test2, |
bfa4b218 | 189 | &prf_plus_test, |
7b0dafeb | 190 | &aes_cbc_crypter_test, |
42e69fbd JH |
191 | &hmac_signer_test1, |
192 | &hmac_signer_test2, | |
bfa4b218 | 193 | NULL |
fd9cabd4 | 194 | }; |
0e96f7d8 MW |
195 | |
196 | daemon_create(); | |
197 | ||
198 | charon->logger_manager->disable_logger_level(charon->logger_manager,TESTER,FULL); | |
199 | //charon->logger_manager->enable_logger_level(charon->logger_manager,TESTER,RAW); | |
200 | ||
201 | tester_t *tester = tester_create(test_output, FALSE); | |
202 | ||
203 | ||
42e69fbd | 204 | tester->perform_tests(tester,all_tests); |
db6e7645 | 205 | //tester->perform_test(tester,&generator_test9); |
1f9c9180 | 206 | |
fd9cabd4 | 207 | |
0e96f7d8 | 208 | tester->destroy(tester); |
fd9cabd4 | 209 | |
0e96f7d8 | 210 | charon->destroy(charon, NULL); |
7d995669 | 211 | |
fd9cabd4 | 212 | #ifdef LEAK_DETECTIVE |
6c4b815f | 213 | /* Leaks are reported on stderr */ |
283ac6ef | 214 | report_memory_leaks(void); |
fd9cabd4 JH |
215 | #endif |
216 | ||
217 | return 0; | |
218 | } |