diff options
author | irungentoo <irungentoo@gmail.com> | 2015-07-06 22:20:18 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2015-07-06 22:20:18 -0400 |
commit | 1d4552c3c45ea80373ab73c3485fe53e5a3099be (patch) | |
tree | 019076b6fb4135727e561fcc839ea6954a5e6204 | |
parent | 06f4e8d6b6ad274896d98d9d662b3c1c274d1e84 (diff) |
Test oob responding too.
-rw-r--r-- | auto_tests/TCP_test.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c index 68631d3c..0cf063f1 100644 --- a/auto_tests/TCP_test.c +++ b/auto_tests/TCP_test.c | |||
@@ -619,22 +619,23 @@ _Bool tcp_oobdata_callback_called; | |||
619 | static int tcp_oobdata_callback(void *object, const uint8_t *public_key, unsigned int id, const uint8_t *data, | 619 | static int tcp_oobdata_callback(void *object, const uint8_t *public_key, unsigned int id, const uint8_t *data, |
620 | uint16_t length) | 620 | uint16_t length) |
621 | { | 621 | { |
622 | if (object != (void *)120397) | ||
623 | return -1; | ||
624 | |||
625 | if (length != 6) | 622 | if (length != 6) |
626 | return -1; | 623 | return -1; |
627 | 624 | ||
628 | if (memcmp(data, "Gentoo", length) != 0) | 625 | if (memcmp(data, "Gentoo", length) != 0) |
629 | return -1; | 626 | return -1; |
630 | 627 | ||
631 | tcp_oobdata_callback_called = 1; | 628 | if (tcp_send_oob_packet(object, id, public_key, data, length) == 0) |
629 | tcp_oobdata_callback_called = 1; | ||
630 | |||
632 | return 0; | 631 | return 0; |
633 | } | 632 | } |
634 | 633 | ||
635 | START_TEST(test_tcp_connection2) | 634 | START_TEST(test_tcp_connection2) |
636 | { | 635 | { |
637 | tcp_oobdata_callback_called = 0; | 636 | tcp_oobdata_callback_called = 0; |
637 | tcp_data_callback_called = 0; | ||
638 | |||
638 | unix_time_update(); | 639 | unix_time_update(); |
639 | uint8_t self_public_key[crypto_box_PUBLICKEYBYTES]; | 640 | uint8_t self_public_key[crypto_box_PUBLICKEYBYTES]; |
640 | uint8_t self_secret_key[crypto_box_SECRETKEYBYTES]; | 641 | uint8_t self_secret_key[crypto_box_SECRETKEYBYTES]; |
@@ -683,7 +684,8 @@ START_TEST(test_tcp_connection2) | |||
683 | 684 | ||
684 | int ret = send_packet_tcp_connection(tc_1, 0, "Gentoo", 6); | 685 | int ret = send_packet_tcp_connection(tc_1, 0, "Gentoo", 6); |
685 | ck_assert_msg(ret == 0, "could not send packet."); | 686 | ck_assert_msg(ret == 0, "could not send packet."); |
686 | set_oob_packet_tcp_connection_callback(tc_2, &tcp_oobdata_callback, (void *) 120397); | 687 | set_oob_packet_tcp_connection_callback(tc_2, &tcp_oobdata_callback, tc_2); |
688 | set_packet_tcp_connection_callback(tc_1, &tcp_data_callback, (void *) 120397); | ||
687 | 689 | ||
688 | c_sleep(50); | 690 | c_sleep(50); |
689 | do_TCP_server(tcp_s); | 691 | do_TCP_server(tcp_s); |
@@ -693,6 +695,15 @@ START_TEST(test_tcp_connection2) | |||
693 | do_tcp_connections(tc_2); | 695 | do_tcp_connections(tc_2); |
694 | 696 | ||
695 | ck_assert_msg(tcp_oobdata_callback_called, "could not recv packet."); | 697 | ck_assert_msg(tcp_oobdata_callback_called, "could not recv packet."); |
698 | |||
699 | c_sleep(50); | ||
700 | do_TCP_server(tcp_s); | ||
701 | c_sleep(50); | ||
702 | |||
703 | do_tcp_connections(tc_1); | ||
704 | do_tcp_connections(tc_2); | ||
705 | |||
706 | ck_assert_msg(tcp_data_callback_called, "could not recv packet."); | ||
696 | ck_assert_msg(kill_tcp_connection_to(tc_1, 0) == 0, "could not kill connection to\n"); | 707 | ck_assert_msg(kill_tcp_connection_to(tc_1, 0) == 0, "could not kill connection to\n"); |
697 | 708 | ||
698 | kill_TCP_server(tcp_s); | 709 | kill_TCP_server(tcp_s); |