diff options
Diffstat (limited to 'auto_tests/TCP_test.c')
-rw-r--r-- | auto_tests/TCP_test.c | 92 |
1 files changed, 52 insertions, 40 deletions
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c index 8a109317..c09e336c 100644 --- a/auto_tests/TCP_test.c +++ b/auto_tests/TCP_test.c | |||
@@ -48,12 +48,13 @@ static uint16_t ports[NUM_PORTS] = {13215, 33445, 25643}; | |||
48 | START_TEST(test_basic) | 48 | START_TEST(test_basic) |
49 | { | 49 | { |
50 | Mono_Time *mono_time = mono_time_new(); | 50 | Mono_Time *mono_time = mono_time_new(); |
51 | Logger *logger = logger_new(); | ||
51 | 52 | ||
52 | // Attempt to create a new TCP_Server instance. | 53 | // Attempt to create a new TCP_Server instance. |
53 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; | 54 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
54 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; | 55 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; |
55 | crypto_new_keypair(self_public_key, self_secret_key); | 56 | crypto_new_keypair(self_public_key, self_secret_key); |
56 | TCP_Server *tcp_s = new_TCP_server(USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr); | 57 | TCP_Server *tcp_s = new_TCP_server(logger, USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr); |
57 | ck_assert_msg(tcp_s != nullptr, "Failed to create a TCP relay server."); | 58 | ck_assert_msg(tcp_s != nullptr, "Failed to create a TCP relay server."); |
58 | ck_assert_msg(tcp_server_listen_count(tcp_s) == NUM_PORTS, | 59 | ck_assert_msg(tcp_server_listen_count(tcp_s) == NUM_PORTS, |
59 | "Failed to bind a TCP relay server to all %d attempted ports.", NUM_PORTS); | 60 | "Failed to bind a TCP relay server to all %d attempted ports.", NUM_PORTS); |
@@ -170,6 +171,7 @@ START_TEST(test_basic) | |||
170 | kill_sock(sock); | 171 | kill_sock(sock); |
171 | kill_TCP_server(tcp_s); | 172 | kill_TCP_server(tcp_s); |
172 | 173 | ||
174 | logger_kill(logger); | ||
173 | mono_time_free(mono_time); | 175 | mono_time_free(mono_time); |
174 | } | 176 | } |
175 | END_TEST | 177 | END_TEST |
@@ -272,11 +274,12 @@ static int read_packet_sec_TCP(struct sec_TCP_con *con, uint8_t *data, uint16_t | |||
272 | START_TEST(test_some) | 274 | START_TEST(test_some) |
273 | { | 275 | { |
274 | Mono_Time *mono_time = mono_time_new(); | 276 | Mono_Time *mono_time = mono_time_new(); |
277 | Logger *logger = logger_new(); | ||
275 | 278 | ||
276 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; | 279 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
277 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; | 280 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; |
278 | crypto_new_keypair(self_public_key, self_secret_key); | 281 | crypto_new_keypair(self_public_key, self_secret_key); |
279 | TCP_Server *tcp_s = new_TCP_server(USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr); | 282 | TCP_Server *tcp_s = new_TCP_server(logger, USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr); |
280 | ck_assert_msg(tcp_s != nullptr, "Failed to create TCP relay server"); | 283 | ck_assert_msg(tcp_s != nullptr, "Failed to create TCP relay server"); |
281 | ck_assert_msg(tcp_server_listen_count(tcp_s) == NUM_PORTS, "Failed to bind to all ports."); | 284 | ck_assert_msg(tcp_server_listen_count(tcp_s) == NUM_PORTS, "Failed to bind to all ports."); |
282 | 285 | ||
@@ -371,6 +374,7 @@ START_TEST(test_some) | |||
371 | kill_TCP_con(con2); | 374 | kill_TCP_con(con2); |
372 | kill_TCP_con(con3); | 375 | kill_TCP_con(con3); |
373 | 376 | ||
377 | logger_kill(logger); | ||
374 | mono_time_free(mono_time); | 378 | mono_time_free(mono_time); |
375 | } | 379 | } |
376 | END_TEST | 380 | END_TEST |
@@ -459,11 +463,12 @@ static int oob_data_callback(void *object, const uint8_t *public_key, const uint | |||
459 | START_TEST(test_client) | 463 | START_TEST(test_client) |
460 | { | 464 | { |
461 | Mono_Time *mono_time = mono_time_new(); | 465 | Mono_Time *mono_time = mono_time_new(); |
466 | Logger *logger = logger_new(); | ||
462 | 467 | ||
463 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; | 468 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
464 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; | 469 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; |
465 | crypto_new_keypair(self_public_key, self_secret_key); | 470 | crypto_new_keypair(self_public_key, self_secret_key); |
466 | TCP_Server *tcp_s = new_TCP_server(USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr); | 471 | TCP_Server *tcp_s = new_TCP_server(logger, USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr); |
467 | ck_assert_msg(tcp_s != nullptr, "Failed to create a TCP relay server."); | 472 | ck_assert_msg(tcp_s != nullptr, "Failed to create a TCP relay server."); |
468 | ck_assert_msg(tcp_server_listen_count(tcp_s) == NUM_PORTS, "Failed to bind the relay server to all ports."); | 473 | ck_assert_msg(tcp_server_listen_count(tcp_s) == NUM_PORTS, "Failed to bind the relay server to all ports."); |
469 | 474 | ||
@@ -477,7 +482,7 @@ START_TEST(test_client) | |||
477 | 482 | ||
478 | TCP_Client_Connection *conn = new_TCP_connection(mono_time, ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, | 483 | TCP_Client_Connection *conn = new_TCP_connection(mono_time, ip_port_tcp_s, self_public_key, f_public_key, f_secret_key, |
479 | nullptr); | 484 | nullptr); |
480 | do_TCP_connection(mono_time, conn, nullptr); | 485 | do_TCP_connection(logger, mono_time, conn, nullptr); |
481 | c_sleep(50); | 486 | c_sleep(50); |
482 | 487 | ||
483 | // The connection status should be unconfirmed here because we have finished | 488 | // The connection status should be unconfirmed here because we have finished |
@@ -491,7 +496,7 @@ START_TEST(test_client) | |||
491 | 496 | ||
492 | for (uint8_t i = 0; i < LOOP_SIZE; i++) { | 497 | for (uint8_t i = 0; i < LOOP_SIZE; i++) { |
493 | mono_time_update(mono_time); | 498 | mono_time_update(mono_time); |
494 | do_TCP_connection(mono_time, conn, nullptr); // Run the connection loop. | 499 | do_TCP_connection(logger, mono_time, conn, nullptr); // Run the connection loop. |
495 | 500 | ||
496 | // The status of the connection should continue to be TCP_CLIENT_CONFIRMED after multiple subsequent do_TCP_connection() calls. | 501 | // The status of the connection should continue to be TCP_CLIENT_CONFIRMED after multiple subsequent do_TCP_connection() calls. |
497 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONFIRMED, "Wrong connection status. Expected: %d, is: %d", | 502 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONFIRMED, "Wrong connection status. Expected: %d, is: %d", |
@@ -525,13 +530,13 @@ START_TEST(test_client) | |||
525 | // These integers will increment per successful callback. | 530 | // These integers will increment per successful callback. |
526 | oob_data_callback_good = response_callback_good = status_callback_good = data_callback_good = 0; | 531 | oob_data_callback_good = response_callback_good = status_callback_good = data_callback_good = 0; |
527 | 532 | ||
528 | do_TCP_connection(mono_time, conn, nullptr); | 533 | do_TCP_connection(logger, mono_time, conn, nullptr); |
529 | do_TCP_connection(mono_time, conn2, nullptr); | 534 | do_TCP_connection(logger, mono_time, conn2, nullptr); |
530 | 535 | ||
531 | do_TCP_server_delay(tcp_s, mono_time, 50); | 536 | do_TCP_server_delay(tcp_s, mono_time, 50); |
532 | 537 | ||
533 | do_TCP_connection(mono_time, conn, nullptr); | 538 | do_TCP_connection(logger, mono_time, conn, nullptr); |
534 | do_TCP_connection(mono_time, conn2, nullptr); | 539 | do_TCP_connection(logger, mono_time, conn2, nullptr); |
535 | c_sleep(50); | 540 | c_sleep(50); |
536 | 541 | ||
537 | uint8_t data[5] = {1, 2, 3, 4, 5}; | 542 | uint8_t data[5] = {1, 2, 3, 4, 5}; |
@@ -542,8 +547,8 @@ START_TEST(test_client) | |||
542 | 547 | ||
543 | do_TCP_server_delay(tcp_s, mono_time, 50); | 548 | do_TCP_server_delay(tcp_s, mono_time, 50); |
544 | 549 | ||
545 | do_TCP_connection(mono_time, conn, nullptr); | 550 | do_TCP_connection(logger, mono_time, conn, nullptr); |
546 | do_TCP_connection(mono_time, conn2, nullptr); | 551 | do_TCP_connection(logger, mono_time, conn2, nullptr); |
547 | 552 | ||
548 | // All callback methods save data should have run during the above network prodding. | 553 | // All callback methods save data should have run during the above network prodding. |
549 | ck_assert_msg(oob_data_callback_good == 1, "OOB callback not called"); | 554 | ck_assert_msg(oob_data_callback_good == 1, "OOB callback not called"); |
@@ -560,16 +565,16 @@ START_TEST(test_client) | |||
560 | 565 | ||
561 | do_TCP_server_delay(tcp_s, mono_time, 50); | 566 | do_TCP_server_delay(tcp_s, mono_time, 50); |
562 | 567 | ||
563 | do_TCP_connection(mono_time, conn, nullptr); | 568 | do_TCP_connection(logger, mono_time, conn, nullptr); |
564 | do_TCP_connection(mono_time, conn2, nullptr); | 569 | do_TCP_connection(logger, mono_time, conn2, nullptr); |
565 | ck_assert_msg(data_callback_good == 1, "Data callback was not called."); | 570 | ck_assert_msg(data_callback_good == 1, "Data callback was not called."); |
566 | status_callback_good = 0; | 571 | status_callback_good = 0; |
567 | send_disconnect_request(conn2, 0); | 572 | send_disconnect_request(conn2, 0); |
568 | 573 | ||
569 | do_TCP_server_delay(tcp_s, mono_time, 50); | 574 | do_TCP_server_delay(tcp_s, mono_time, 50); |
570 | 575 | ||
571 | do_TCP_connection(mono_time, conn, nullptr); | 576 | do_TCP_connection(logger, mono_time, conn, nullptr); |
572 | do_TCP_connection(mono_time, conn2, nullptr); | 577 | do_TCP_connection(logger, mono_time, conn2, nullptr); |
573 | ck_assert_msg(status_callback_good == 1, "Status callback not called"); | 578 | ck_assert_msg(status_callback_good == 1, "Status callback not called"); |
574 | ck_assert_msg(status_callback_status == 1, "Wrong status callback status."); | 579 | ck_assert_msg(status_callback_status == 1, "Wrong status callback status."); |
575 | 580 | ||
@@ -578,6 +583,7 @@ START_TEST(test_client) | |||
578 | kill_TCP_connection(conn); | 583 | kill_TCP_connection(conn); |
579 | kill_TCP_connection(conn2); | 584 | kill_TCP_connection(conn2); |
580 | 585 | ||
586 | logger_kill(logger); | ||
581 | mono_time_free(mono_time); | 587 | mono_time_free(mono_time); |
582 | } | 588 | } |
583 | END_TEST | 589 | END_TEST |
@@ -586,6 +592,7 @@ END_TEST | |||
586 | START_TEST(test_client_invalid) | 592 | START_TEST(test_client_invalid) |
587 | { | 593 | { |
588 | Mono_Time *mono_time = mono_time_new(); | 594 | Mono_Time *mono_time = mono_time_new(); |
595 | Logger *logger = logger_new(); | ||
589 | 596 | ||
590 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; | 597 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
591 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; | 598 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; |
@@ -603,7 +610,7 @@ START_TEST(test_client_invalid) | |||
603 | 610 | ||
604 | // Run the client's main loop but not the server. | 611 | // Run the client's main loop but not the server. |
605 | mono_time_update(mono_time); | 612 | mono_time_update(mono_time); |
606 | do_TCP_connection(mono_time, conn, nullptr); | 613 | do_TCP_connection(logger, mono_time, conn, nullptr); |
607 | c_sleep(50); | 614 | c_sleep(50); |
608 | 615 | ||
609 | // After 50ms of no response... | 616 | // After 50ms of no response... |
@@ -612,18 +619,19 @@ START_TEST(test_client_invalid) | |||
612 | // After 5s... | 619 | // After 5s... |
613 | c_sleep(5000); | 620 | c_sleep(5000); |
614 | mono_time_update(mono_time); | 621 | mono_time_update(mono_time); |
615 | do_TCP_connection(mono_time, conn, nullptr); | 622 | do_TCP_connection(logger, mono_time, conn, nullptr); |
616 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONNECTING, "Wrong status. Expected: %d, is: %d.", | 623 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_CONNECTING, "Wrong status. Expected: %d, is: %d.", |
617 | TCP_CLIENT_CONNECTING, tcp_con_status(conn)); | 624 | TCP_CLIENT_CONNECTING, tcp_con_status(conn)); |
618 | // 11s... (Should wait for 10 before giving up.) | 625 | // 11s... (Should wait for 10 before giving up.) |
619 | c_sleep(6000); | 626 | c_sleep(6000); |
620 | mono_time_update(mono_time); | 627 | mono_time_update(mono_time); |
621 | do_TCP_connection(mono_time, conn, nullptr); | 628 | do_TCP_connection(logger, mono_time, conn, nullptr); |
622 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_DISCONNECTED, "Wrong status. Expected: %d, is: %d.", | 629 | ck_assert_msg(tcp_con_status(conn) == TCP_CLIENT_DISCONNECTED, "Wrong status. Expected: %d, is: %d.", |
623 | TCP_CLIENT_DISCONNECTED, tcp_con_status(conn)); | 630 | TCP_CLIENT_DISCONNECTED, tcp_con_status(conn)); |
624 | 631 | ||
625 | kill_TCP_connection(conn); | 632 | kill_TCP_connection(conn); |
626 | 633 | ||
634 | logger_kill(logger); | ||
627 | mono_time_free(mono_time); | 635 | mono_time_free(mono_time); |
628 | } | 636 | } |
629 | END_TEST | 637 | END_TEST |
@@ -657,12 +665,13 @@ static int tcp_data_callback(void *object, int id, const uint8_t *data, uint16_t | |||
657 | START_TEST(test_tcp_connection) | 665 | START_TEST(test_tcp_connection) |
658 | { | 666 | { |
659 | Mono_Time *mono_time = mono_time_new(); | 667 | Mono_Time *mono_time = mono_time_new(); |
668 | Logger *logger = logger_new(); | ||
660 | 669 | ||
661 | tcp_data_callback_called = 0; | 670 | tcp_data_callback_called = 0; |
662 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; | 671 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
663 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; | 672 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; |
664 | crypto_new_keypair(self_public_key, self_secret_key); | 673 | crypto_new_keypair(self_public_key, self_secret_key); |
665 | TCP_Server *tcp_s = new_TCP_server(USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr); | 674 | TCP_Server *tcp_s = new_TCP_server(logger, USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr); |
666 | ck_assert_msg(public_key_cmp(tcp_server_public_key(tcp_s), self_public_key) == 0, "Wrong public key"); | 675 | ck_assert_msg(public_key_cmp(tcp_server_public_key(tcp_s), self_public_key) == 0, "Wrong public key"); |
667 | 676 | ||
668 | TCP_Proxy_Info proxy_info; | 677 | TCP_Proxy_Info proxy_info; |
@@ -696,18 +705,18 @@ START_TEST(test_tcp_connection) | |||
696 | 705 | ||
697 | do_TCP_server_delay(tcp_s, mono_time, 50); | 706 | do_TCP_server_delay(tcp_s, mono_time, 50); |
698 | 707 | ||
699 | do_tcp_connections(tc_1, nullptr); | 708 | do_tcp_connections(logger, tc_1, nullptr); |
700 | do_tcp_connections(tc_2, nullptr); | 709 | do_tcp_connections(logger, tc_2, nullptr); |
701 | 710 | ||
702 | do_TCP_server_delay(tcp_s, mono_time, 50); | 711 | do_TCP_server_delay(tcp_s, mono_time, 50); |
703 | 712 | ||
704 | do_tcp_connections(tc_1, nullptr); | 713 | do_tcp_connections(logger, tc_1, nullptr); |
705 | do_tcp_connections(tc_2, nullptr); | 714 | do_tcp_connections(logger, tc_2, nullptr); |
706 | 715 | ||
707 | do_TCP_server_delay(tcp_s, mono_time, 50); | 716 | do_TCP_server_delay(tcp_s, mono_time, 50); |
708 | 717 | ||
709 | do_tcp_connections(tc_1, nullptr); | 718 | do_tcp_connections(logger, tc_1, nullptr); |
710 | do_tcp_connections(tc_2, nullptr); | 719 | do_tcp_connections(logger, tc_2, nullptr); |
711 | 720 | ||
712 | int ret = send_packet_tcp_connection(tc_1, 0, (const uint8_t *)"Gentoo", 6); | 721 | int ret = send_packet_tcp_connection(tc_1, 0, (const uint8_t *)"Gentoo", 6); |
713 | ck_assert_msg(ret == 0, "could not send packet."); | 722 | ck_assert_msg(ret == 0, "could not send packet."); |
@@ -715,8 +724,8 @@ START_TEST(test_tcp_connection) | |||
715 | 724 | ||
716 | do_TCP_server_delay(tcp_s, mono_time, 50); | 725 | do_TCP_server_delay(tcp_s, mono_time, 50); |
717 | 726 | ||
718 | do_tcp_connections(tc_1, nullptr); | 727 | do_tcp_connections(logger, tc_1, nullptr); |
719 | do_tcp_connections(tc_2, nullptr); | 728 | do_tcp_connections(logger, tc_2, nullptr); |
720 | 729 | ||
721 | ck_assert_msg(tcp_data_callback_called, "could not recv packet."); | 730 | ck_assert_msg(tcp_data_callback_called, "could not recv packet."); |
722 | ck_assert_msg(tcp_connection_to_online_tcp_relays(tc_1, 0) == 1, "Wrong number of connected relays"); | 731 | ck_assert_msg(tcp_connection_to_online_tcp_relays(tc_1, 0) == 1, "Wrong number of connected relays"); |
@@ -724,8 +733,8 @@ START_TEST(test_tcp_connection) | |||
724 | 733 | ||
725 | do_TCP_server_delay(tcp_s, mono_time, 50); | 734 | do_TCP_server_delay(tcp_s, mono_time, 50); |
726 | 735 | ||
727 | do_tcp_connections(tc_1, nullptr); | 736 | do_tcp_connections(logger, tc_1, nullptr); |
728 | do_tcp_connections(tc_2, nullptr); | 737 | do_tcp_connections(logger, tc_2, nullptr); |
729 | 738 | ||
730 | ck_assert_msg(send_packet_tcp_connection(tc_1, 0, (const uint8_t *)"Gentoo", 6) == -1, "could send packet."); | 739 | ck_assert_msg(send_packet_tcp_connection(tc_1, 0, (const uint8_t *)"Gentoo", 6) == -1, "could send packet."); |
731 | ck_assert_msg(kill_tcp_connection_to(tc_2, 0) == 0, "could not kill connection to\n"); | 740 | ck_assert_msg(kill_tcp_connection_to(tc_2, 0) == 0, "could not kill connection to\n"); |
@@ -734,6 +743,7 @@ START_TEST(test_tcp_connection) | |||
734 | kill_tcp_connections(tc_1); | 743 | kill_tcp_connections(tc_1); |
735 | kill_tcp_connections(tc_2); | 744 | kill_tcp_connections(tc_2); |
736 | 745 | ||
746 | logger_kill(logger); | ||
737 | mono_time_free(mono_time); | 747 | mono_time_free(mono_time); |
738 | } | 748 | } |
739 | END_TEST | 749 | END_TEST |
@@ -762,6 +772,7 @@ static int tcp_oobdata_callback(void *object, const uint8_t *public_key, unsigne | |||
762 | START_TEST(test_tcp_connection2) | 772 | START_TEST(test_tcp_connection2) |
763 | { | 773 | { |
764 | Mono_Time *mono_time = mono_time_new(); | 774 | Mono_Time *mono_time = mono_time_new(); |
775 | Logger *logger = logger_new(); | ||
765 | 776 | ||
766 | tcp_oobdata_callback_called = 0; | 777 | tcp_oobdata_callback_called = 0; |
767 | tcp_data_callback_called = 0; | 778 | tcp_data_callback_called = 0; |
@@ -769,7 +780,7 @@ START_TEST(test_tcp_connection2) | |||
769 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; | 780 | uint8_t self_public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
770 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; | 781 | uint8_t self_secret_key[CRYPTO_SECRET_KEY_SIZE]; |
771 | crypto_new_keypair(self_public_key, self_secret_key); | 782 | crypto_new_keypair(self_public_key, self_secret_key); |
772 | TCP_Server *tcp_s = new_TCP_server(USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr); | 783 | TCP_Server *tcp_s = new_TCP_server(logger, USE_IPV6, NUM_PORTS, ports, self_secret_key, nullptr); |
773 | ck_assert_msg(public_key_cmp(tcp_server_public_key(tcp_s), self_public_key) == 0, "Wrong public key"); | 784 | ck_assert_msg(public_key_cmp(tcp_server_public_key(tcp_s), self_public_key) == 0, "Wrong public key"); |
774 | 785 | ||
775 | TCP_Proxy_Info proxy_info; | 786 | TCP_Proxy_Info proxy_info; |
@@ -797,18 +808,18 @@ START_TEST(test_tcp_connection2) | |||
797 | 808 | ||
798 | do_TCP_server_delay(tcp_s, mono_time, 50); | 809 | do_TCP_server_delay(tcp_s, mono_time, 50); |
799 | 810 | ||
800 | do_tcp_connections(tc_1, nullptr); | 811 | do_tcp_connections(logger, tc_1, nullptr); |
801 | do_tcp_connections(tc_2, nullptr); | 812 | do_tcp_connections(logger, tc_2, nullptr); |
802 | 813 | ||
803 | do_TCP_server_delay(tcp_s, mono_time, 50); | 814 | do_TCP_server_delay(tcp_s, mono_time, 50); |
804 | 815 | ||
805 | do_tcp_connections(tc_1, nullptr); | 816 | do_tcp_connections(logger, tc_1, nullptr); |
806 | do_tcp_connections(tc_2, nullptr); | 817 | do_tcp_connections(logger, tc_2, nullptr); |
807 | 818 | ||
808 | do_TCP_server_delay(tcp_s, mono_time, 50); | 819 | do_TCP_server_delay(tcp_s, mono_time, 50); |
809 | 820 | ||
810 | do_tcp_connections(tc_1, nullptr); | 821 | do_tcp_connections(logger, tc_1, nullptr); |
811 | do_tcp_connections(tc_2, nullptr); | 822 | do_tcp_connections(logger, tc_2, nullptr); |
812 | 823 | ||
813 | int ret = send_packet_tcp_connection(tc_1, 0, (const uint8_t *)"Gentoo", 6); | 824 | int ret = send_packet_tcp_connection(tc_1, 0, (const uint8_t *)"Gentoo", 6); |
814 | ck_assert_msg(ret == 0, "could not send packet."); | 825 | ck_assert_msg(ret == 0, "could not send packet."); |
@@ -817,15 +828,15 @@ START_TEST(test_tcp_connection2) | |||
817 | 828 | ||
818 | do_TCP_server_delay(tcp_s, mono_time, 50); | 829 | do_TCP_server_delay(tcp_s, mono_time, 50); |
819 | 830 | ||
820 | do_tcp_connections(tc_1, nullptr); | 831 | do_tcp_connections(logger, tc_1, nullptr); |
821 | do_tcp_connections(tc_2, nullptr); | 832 | do_tcp_connections(logger, tc_2, nullptr); |
822 | 833 | ||
823 | ck_assert_msg(tcp_oobdata_callback_called, "could not recv packet."); | 834 | ck_assert_msg(tcp_oobdata_callback_called, "could not recv packet."); |
824 | 835 | ||
825 | do_TCP_server_delay(tcp_s, mono_time, 50); | 836 | do_TCP_server_delay(tcp_s, mono_time, 50); |
826 | 837 | ||
827 | do_tcp_connections(tc_1, nullptr); | 838 | do_tcp_connections(logger, tc_1, nullptr); |
828 | do_tcp_connections(tc_2, nullptr); | 839 | do_tcp_connections(logger, tc_2, nullptr); |
829 | 840 | ||
830 | ck_assert_msg(tcp_data_callback_called, "could not recv packet."); | 841 | ck_assert_msg(tcp_data_callback_called, "could not recv packet."); |
831 | ck_assert_msg(kill_tcp_connection_to(tc_1, 0) == 0, "could not kill connection to\n"); | 842 | ck_assert_msg(kill_tcp_connection_to(tc_1, 0) == 0, "could not kill connection to\n"); |
@@ -834,6 +845,7 @@ START_TEST(test_tcp_connection2) | |||
834 | kill_tcp_connections(tc_1); | 845 | kill_tcp_connections(tc_1); |
835 | kill_tcp_connections(tc_2); | 846 | kill_tcp_connections(tc_2); |
836 | 847 | ||
848 | logger_kill(logger); | ||
837 | mono_time_free(mono_time); | 849 | mono_time_free(mono_time); |
838 | } | 850 | } |
839 | END_TEST | 851 | END_TEST |