diff options
author | mannol <eniz_vukovic@hotmail.com> | 2015-03-22 00:21:49 +0100 |
---|---|---|
committer | mannol <eniz_vukovic@hotmail.com> | 2015-03-22 00:22:40 +0100 |
commit | a4fae8ffd49e298cd87e13be2496faf77e492bd9 (patch) | |
tree | 285ed6e22db90db713dc6938160d24e3857c6e5f /auto_tests | |
parent | 4f76a8c89eea77ebc190a324ad128e3c7dda298c (diff) | |
parent | 4ad76497881ee2a623acdedcf0ac10406208b716 (diff) |
Started testing transfer
Diffstat (limited to 'auto_tests')
-rw-r--r-- | auto_tests/TCP_test.c | 16 | ||||
-rw-r--r-- | auto_tests/assoc_test.c | 2 | ||||
-rw-r--r-- | auto_tests/encryptsave_test.c | 10 | ||||
-rw-r--r-- | auto_tests/onion_test.c | 55 | ||||
-rw-r--r-- | auto_tests/toxav_basic_test.c | 8 |
5 files changed, 84 insertions, 7 deletions
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c index 566013d7..e222cf01 100644 --- a/auto_tests/TCP_test.c +++ b/auto_tests/TCP_test.c | |||
@@ -118,6 +118,7 @@ START_TEST(test_basic) | |||
118 | ck_assert_msg(packet_resp_plain[0] == 1, "wrong packet id %u", packet_resp_plain[0]); | 118 | ck_assert_msg(packet_resp_plain[0] == 1, "wrong packet id %u", packet_resp_plain[0]); |
119 | ck_assert_msg(packet_resp_plain[1] == 0, "connection not refused %u", packet_resp_plain[1]); | 119 | ck_assert_msg(packet_resp_plain[1] == 0, "connection not refused %u", packet_resp_plain[1]); |
120 | ck_assert_msg(memcmp(packet_resp_plain + 2, f_public_key, crypto_box_PUBLICKEYBYTES) == 0, "key in packet wrong"); | 120 | ck_assert_msg(memcmp(packet_resp_plain + 2, f_public_key, crypto_box_PUBLICKEYBYTES) == 0, "key in packet wrong"); |
121 | kill_TCP_server(tcp_s); | ||
121 | } | 122 | } |
122 | END_TEST | 123 | END_TEST |
123 | 124 | ||
@@ -175,6 +176,12 @@ struct sec_TCP_con *new_TCP_con(TCP_Server *tcp_s) | |||
175 | return sec_c; | 176 | return sec_c; |
176 | } | 177 | } |
177 | 178 | ||
179 | void kill_TCP_con(struct sec_TCP_con *con) | ||
180 | { | ||
181 | kill_sock(con->sock); | ||
182 | free(con); | ||
183 | } | ||
184 | |||
178 | int write_packet_TCP_secure_connection(struct sec_TCP_con *con, uint8_t *data, uint16_t length) | 185 | int write_packet_TCP_secure_connection(struct sec_TCP_con *con, uint8_t *data, uint16_t length) |
179 | { | 186 | { |
180 | uint8_t packet[sizeof(uint16_t) + length + crypto_box_MACBYTES]; | 187 | uint8_t packet[sizeof(uint16_t) + length + crypto_box_MACBYTES]; |
@@ -290,6 +297,10 @@ START_TEST(test_some) | |||
290 | ck_assert_msg(len == sizeof(ping_packet), "wrong len %u", len); | 297 | ck_assert_msg(len == sizeof(ping_packet), "wrong len %u", len); |
291 | ck_assert_msg(data[0] == 5, "wrong packet id %u", data[0]); | 298 | ck_assert_msg(data[0] == 5, "wrong packet id %u", data[0]); |
292 | ck_assert_msg(memcmp(ping_packet + 1, data + 1, sizeof(uint64_t)) == 0, "wrong packet data"); | 299 | ck_assert_msg(memcmp(ping_packet + 1, data + 1, sizeof(uint64_t)) == 0, "wrong packet data"); |
300 | kill_TCP_server(tcp_s); | ||
301 | kill_TCP_con(con1); | ||
302 | kill_TCP_con(con2); | ||
303 | kill_TCP_con(con3); | ||
293 | } | 304 | } |
294 | END_TEST | 305 | END_TEST |
295 | 306 | ||
@@ -457,6 +468,9 @@ START_TEST(test_client) | |||
457 | do_TCP_connection(conn2); | 468 | do_TCP_connection(conn2); |
458 | ck_assert_msg(status_callback_good == 1, "status callback not called"); | 469 | ck_assert_msg(status_callback_good == 1, "status callback not called"); |
459 | ck_assert_msg(status_callback_status == 1, "wrong status"); | 470 | ck_assert_msg(status_callback_status == 1, "wrong status"); |
471 | kill_TCP_server(tcp_s); | ||
472 | kill_TCP_connection(conn); | ||
473 | kill_TCP_connection(conn2); | ||
460 | } | 474 | } |
461 | END_TEST | 475 | END_TEST |
462 | 476 | ||
@@ -488,6 +502,8 @@ START_TEST(test_client_invalid) | |||
488 | do_TCP_connection(conn); | 502 | do_TCP_connection(conn); |
489 | ck_assert_msg(conn->status == TCP_CLIENT_DISCONNECTED, "Wrong status. Expected: %u, is: %u", TCP_CLIENT_DISCONNECTED, | 503 | ck_assert_msg(conn->status == TCP_CLIENT_DISCONNECTED, "Wrong status. Expected: %u, is: %u", TCP_CLIENT_DISCONNECTED, |
490 | conn->status); | 504 | conn->status); |
505 | |||
506 | kill_TCP_connection(conn); | ||
491 | } | 507 | } |
492 | END_TEST | 508 | END_TEST |
493 | 509 | ||
diff --git a/auto_tests/assoc_test.c b/auto_tests/assoc_test.c index b377cadf..bcf5d3fa 100644 --- a/auto_tests/assoc_test.c +++ b/auto_tests/assoc_test.c | |||
@@ -55,6 +55,7 @@ START_TEST(test_basics) | |||
55 | 55 | ||
56 | uint8_t found = Assoc_get_close_entries(assoc, &close_entries); | 56 | uint8_t found = Assoc_get_close_entries(assoc, &close_entries); |
57 | ck_assert_msg(found == 1, "get_close_entries(): expected %u, got %u", 1, found); | 57 | ck_assert_msg(found == 1, "get_close_entries(): expected %u, got %u", 1, found); |
58 | kill_Assoc(assoc); | ||
58 | } | 59 | } |
59 | END_TEST | 60 | END_TEST |
60 | 61 | ||
@@ -130,6 +131,7 @@ START_TEST(test_fillup) | |||
130 | 131 | ||
131 | ck_assert_msg(good == 8, "Entries found were not the closest ones. Only %u/8 were.", good); | 132 | ck_assert_msg(good == 8, "Entries found were not the closest ones. Only %u/8 were.", good); |
132 | //printf("good: %u %u %u\n", good, a, ((uint32_t)current_time() - a)); | 133 | //printf("good: %u %u %u\n", good, a, ((uint32_t)current_time() - a)); |
134 | kill_Assoc(assoc); | ||
133 | } | 135 | } |
134 | END_TEST | 136 | END_TEST |
135 | 137 | ||
diff --git a/auto_tests/encryptsave_test.c b/auto_tests/encryptsave_test.c index aa5bef3f..338c9ef1 100644 --- a/auto_tests/encryptsave_test.c +++ b/auto_tests/encryptsave_test.c | |||
@@ -114,6 +114,12 @@ START_TEST(test_save_friend) | |||
114 | test = tox_get_client_id(tox4, 0, address5); | 114 | test = tox_get_client_id(tox4, 0, address5); |
115 | ck_assert_msg(test == 0, "no friends! the third"); | 115 | ck_assert_msg(test == 0, "no friends! the third"); |
116 | ck_assert_msg(memcmp(address, address2, TOX_CLIENT_ID_SIZE) == 0, "addresses don't match! the third"); | 116 | ck_assert_msg(memcmp(address, address2, TOX_CLIENT_ID_SIZE) == 0, "addresses don't match! the third"); |
117 | |||
118 | tox_kill(tox1); | ||
119 | tox_kill(tox2); | ||
120 | tox_kill(tox3); | ||
121 | tox_kill(tox4); | ||
122 | tox_kill(tox5); | ||
117 | } | 123 | } |
118 | END_TEST | 124 | END_TEST |
119 | 125 | ||
@@ -160,8 +166,8 @@ Suite *encryptsave_suite(void) | |||
160 | Suite *s = suite_create("encryptsave"); | 166 | Suite *s = suite_create("encryptsave"); |
161 | 167 | ||
162 | DEFTESTCASE_SLOW(known_kdf, 60); /* is 5-10 seconds on my computer, but is directly dependent on CPU */ | 168 | DEFTESTCASE_SLOW(known_kdf, 60); /* is 5-10 seconds on my computer, but is directly dependent on CPU */ |
163 | DEFTESTCASE(save_friend); | 169 | DEFTESTCASE_SLOW(save_friend, 20); |
164 | DEFTESTCASE(keys); | 170 | DEFTESTCASE_SLOW(keys, 30); |
165 | 171 | ||
166 | return s; | 172 | return s; |
167 | } | 173 | } |
diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c index 8e10eb11..f27fefb8 100644 --- a/auto_tests/onion_test.c +++ b/auto_tests/onion_test.c | |||
@@ -138,12 +138,12 @@ START_TEST(test_basic) | |||
138 | 138 | ||
139 | IP_Port on1 = {ip, onion1->net->port}; | 139 | IP_Port on1 = {ip, onion1->net->port}; |
140 | Node_format n1; | 140 | Node_format n1; |
141 | memcpy(n1.client_id, onion1->dht->self_public_key, crypto_box_PUBLICKEYBYTES); | 141 | memcpy(n1.public_key, onion1->dht->self_public_key, crypto_box_PUBLICKEYBYTES); |
142 | n1.ip_port = on1; | 142 | n1.ip_port = on1; |
143 | 143 | ||
144 | IP_Port on2 = {ip, onion2->net->port}; | 144 | IP_Port on2 = {ip, onion2->net->port}; |
145 | Node_format n2; | 145 | Node_format n2; |
146 | memcpy(n2.client_id, onion2->dht->self_public_key, crypto_box_PUBLICKEYBYTES); | 146 | memcpy(n2.public_key, onion2->dht->self_public_key, crypto_box_PUBLICKEYBYTES); |
147 | n2.ip_port = on2; | 147 | n2.ip_port = on2; |
148 | 148 | ||
149 | Node_format nodes[4]; | 149 | Node_format nodes[4]; |
@@ -180,7 +180,7 @@ START_TEST(test_basic) | |||
180 | randombytes(sb_data, sizeof(sb_data)); | 180 | randombytes(sb_data, sizeof(sb_data)); |
181 | uint64_t s; | 181 | uint64_t s; |
182 | memcpy(&s, sb_data, sizeof(uint64_t)); | 182 | memcpy(&s, sb_data, sizeof(uint64_t)); |
183 | memcpy(test_3_pub_key, nodes[3].client_id, crypto_box_PUBLICKEYBYTES); | 183 | memcpy(test_3_pub_key, nodes[3].public_key, crypto_box_PUBLICKEYBYTES); |
184 | ret = send_announce_request(onion1->net, &path, nodes[3], onion1->dht->self_public_key, | 184 | ret = send_announce_request(onion1->net, &path, nodes[3], onion1->dht->self_public_key, |
185 | onion1->dht->self_secret_key, | 185 | onion1->dht->self_secret_key, |
186 | zeroes, onion1->dht->self_public_key, onion1->dht->self_public_key, s); | 186 | zeroes, onion1->dht->self_public_key, onion1->dht->self_public_key, s); |
@@ -224,6 +224,39 @@ START_TEST(test_basic) | |||
224 | do_onion(onion2); | 224 | do_onion(onion2); |
225 | c_sleep(50); | 225 | c_sleep(50); |
226 | } | 226 | } |
227 | |||
228 | kill_onion_announce(onion1_a); | ||
229 | kill_onion_announce(onion2_a); | ||
230 | |||
231 | { | ||
232 | Onion *onion = onion1; | ||
233 | |||
234 | Networking_Core *net = onion->dht->net; | ||
235 | DHT *dht = onion->dht; | ||
236 | kill_onion(onion); | ||
237 | kill_DHT(dht); | ||
238 | kill_networking(net); | ||
239 | } | ||
240 | |||
241 | { | ||
242 | Onion *onion = onion2; | ||
243 | |||
244 | Networking_Core *net = onion->dht->net; | ||
245 | DHT *dht = onion->dht; | ||
246 | kill_onion(onion); | ||
247 | kill_DHT(dht); | ||
248 | kill_networking(net); | ||
249 | } | ||
250 | |||
251 | { | ||
252 | Onion *onion = onion3; | ||
253 | |||
254 | Networking_Core *net = onion->dht->net; | ||
255 | DHT *dht = onion->dht; | ||
256 | kill_onion(onion); | ||
257 | kill_DHT(dht); | ||
258 | kill_networking(net); | ||
259 | } | ||
227 | } | 260 | } |
228 | END_TEST | 261 | END_TEST |
229 | 262 | ||
@@ -257,6 +290,18 @@ void do_onions(Onions *on) | |||
257 | do_onion_client(on->onion_c); | 290 | do_onion_client(on->onion_c); |
258 | } | 291 | } |
259 | 292 | ||
293 | void kill_onions(Onions *on) | ||
294 | { | ||
295 | Networking_Core *net = on->onion->dht->net; | ||
296 | DHT *dht = on->onion->dht; | ||
297 | kill_onion_client(on->onion_c); | ||
298 | kill_onion_announce(on->onion_a); | ||
299 | kill_onion(on->onion); | ||
300 | kill_DHT(dht); | ||
301 | kill_networking(net); | ||
302 | free(on); | ||
303 | } | ||
304 | |||
260 | #define NUM_ONIONS 50 | 305 | #define NUM_ONIONS 50 |
261 | 306 | ||
262 | START_TEST(test_announce) | 307 | START_TEST(test_announce) |
@@ -334,6 +379,10 @@ START_TEST(test_announce) | |||
334 | } | 379 | } |
335 | 380 | ||
336 | ck_assert_msg(ip_port.port == onions[7]->onion->net->port, "Port in returned ip not correct."); | 381 | ck_assert_msg(ip_port.port == onions[7]->onion->net->port, "Port in returned ip not correct."); |
382 | |||
383 | for (i = 0; i < NUM_ONIONS; ++i) { | ||
384 | kill_onions(onions[i]); | ||
385 | } | ||
337 | } | 386 | } |
338 | END_TEST | 387 | END_TEST |
339 | 388 | ||
diff --git a/auto_tests/toxav_basic_test.c b/auto_tests/toxav_basic_test.c index db1db3fb..3139c844 100644 --- a/auto_tests/toxav_basic_test.c +++ b/auto_tests/toxav_basic_test.c | |||
@@ -595,8 +595,12 @@ START_TEST(test_AV_flows) | |||
595 | printf("\n"); | 595 | printf("\n"); |
596 | } | 596 | } |
597 | 597 | ||
598 | 598 | vpx_img_free(sample_image); | |
599 | 599 | toxav_kill(status_control.Alice.av); | |
600 | toxav_kill(status_control.Bob.av); | ||
601 | tox_kill(bootstrap_node); | ||
602 | tox_kill(Alice); | ||
603 | tox_kill(Bob); | ||
600 | 604 | ||
601 | printf("Calls ended!\n"); | 605 | printf("Calls ended!\n"); |
602 | } | 606 | } |