diff options
Diffstat (limited to 'auto_tests/TCP_test.c')
-rw-r--r-- | auto_tests/TCP_test.c | 16 |
1 files changed, 16 insertions, 0 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 | ||