aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_communicator_basic.c
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2021-01-05 13:19:57 +0100
committert3sserakt <t3ss@posteo.de>2021-01-05 13:19:57 +0100
commit5affc9ad078e8d90c47a2972d67cd9d65529792d (patch)
treefe02ace1af4d386044c64ddbb78ad6db0d791d09 /src/transport/test_communicator_basic.c
parent561596641606ecc0b5f71658c34eab1312ad8f18 (diff)
downloadgnunet-5affc9ad078e8d90c47a2972d67cd9d65529792d.tar.gz
gnunet-5affc9ad078e8d90c47a2972d67cd9d65529792d.zip
- started making tng communicator test code more resilient
Diffstat (limited to 'src/transport/test_communicator_basic.c')
-rw-r--r--src/transport/test_communicator_basic.c46
1 files changed, 29 insertions, 17 deletions
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c
index 10c942daa..0eeaecb6c 100644
--- a/src/transport/test_communicator_basic.c
+++ b/src/transport/test_communicator_basic.c
@@ -61,6 +61,8 @@ static char *cfg_peers_name[NUM_PEERS];
61 61
62static int ret; 62static int ret;
63 63
64static int bidirect = GNUNET_NO;
65
64static size_t long_message_size; 66static size_t long_message_size;
65 67
66static struct GNUNET_TIME_Absolute start_short; 68static struct GNUNET_TIME_Absolute start_short;
@@ -71,6 +73,8 @@ static struct GNUNET_TIME_Absolute timeout;
71 73
72static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *my_tc; 74static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *my_tc;
73 75
76static char *communicator_name;
77
74static char *test_name; 78static char *test_name;
75 79
76static struct GNUNET_STATISTICS_GetHandle *box_stats; 80static struct GNUNET_STATISTICS_GetHandle *box_stats;
@@ -343,11 +347,8 @@ long_test_cb (void *cls)
343 payload = make_payload (long_message_size); 347 payload = make_payload (long_message_size);
344 num_sent_long++; 348 num_sent_long++;
345 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, 349 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
346 ((BURST_PACKETS 350 (BURST_PACKETS ==
347 * 0.91 == 351 num_sent_long)
348 num_received_long) ||
349 (BURST_PACKETS ==
350 num_sent_long))
351 ? NULL 352 ? NULL
352 : &long_test, 353 : &long_test,
353 NULL, 354 NULL,
@@ -385,11 +386,8 @@ short_test_cb (void *cls)
385 payload = make_payload (SHORT_MESSAGE_SIZE); 386 payload = make_payload (SHORT_MESSAGE_SIZE);
386 num_sent_short++; 387 num_sent_short++;
387 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, 388 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
388 ((BURST_PACKETS 389 (BURST_PACKETS ==
389 * 0.91 == 390 num_sent_short)
390 num_received_short) ||
391 (BURST_PACKETS ==
392 num_sent_short))
393 ? NULL 391 ? NULL
394 : &short_test, 392 : &short_test,
395 NULL, 393 NULL,
@@ -625,7 +623,8 @@ incoming_message_cb (void *cls,
625 num_received_short++; 623 num_received_short++;
626 duration = GNUNET_TIME_absolute_get_duration (start_short); 624 duration = GNUNET_TIME_absolute_get_duration (start_short);
627 update_avg_latency (payload); 625 update_avg_latency (payload);
628 if (num_received_short == BURST_PACKETS * 0.91) 626 if ((num_sent_short == BURST_PACKETS) && (num_received_short >
627 BURST_PACKETS * 0.91) )
629 { 628 {
630 LOG (GNUNET_ERROR_TYPE_MESSAGE, 629 LOG (GNUNET_ERROR_TYPE_MESSAGE,
631 "Short size packet test done.\n"); 630 "Short size packet test done.\n");
@@ -647,6 +646,9 @@ incoming_message_cb (void *cls,
647 // num_sent_short = 0; 646 // num_sent_short = 0;
648 avg_latency = 0; 647 avg_latency = 0;
649 // num_received = 0; 648 // num_received = 0;
649 /*LOG (GNUNET_ERROR_TYPE_DEBUG,
650 "Finished\n");
651 GNUNET_SCHEDULER_shutdown ();*/
650 long_test (NULL); 652 long_test (NULL);
651 } 653 }
652 break; 654 break;
@@ -662,7 +664,8 @@ incoming_message_cb (void *cls,
662 num_received_long++; 664 num_received_long++;
663 duration = GNUNET_TIME_absolute_get_duration (start_long); 665 duration = GNUNET_TIME_absolute_get_duration (start_long);
664 update_avg_latency (payload); 666 update_avg_latency (payload);
665 if (num_received_long == BURST_PACKETS * 0.91) 667 if ((num_sent_long == BURST_PACKETS) && (num_received_long > BURST_PACKETS
668 * 0.91) )
666 { 669 {
667 LOG (GNUNET_ERROR_TYPE_MESSAGE, 670 LOG (GNUNET_ERROR_TYPE_MESSAGE,
668 "Long size packet test done.\n"); 671 "Long size packet test done.\n");
@@ -723,8 +726,11 @@ incoming_message_cb (void *cls,
723 short_test (NULL); 726 short_test (NULL);
724 break; 727 break;
725 } 728 }
726 if ((0 == strcmp ("rekey", test_name))||(0 == strcmp ("backchannel", 729 if ((0 == strcmp ("udp", communicator_name)) && ((0 == strcmp ("rekey",
727 test_name)) ) 730 test_name))
731 ||(0 == strcmp (
732 "backchannel",
733 test_name))) )
728 { 734 {
729 if (NULL != box_stats) 735 if (NULL != box_stats)
730 GNUNET_STATISTICS_get_cancel (box_stats); 736 GNUNET_STATISTICS_get_cancel (box_stats);
@@ -810,12 +816,19 @@ run (void *cls)
810 &handle_backchannel_cb, 816 &handle_backchannel_cb,
811 cfg_peers_name[i]); /* cls */ 817 cfg_peers_name[i]); /* cls */
812 818
813 if ((0 == strcmp ("rekey", test_name))||(0 == strcmp ("backchannel", 819 if ((0 == strcmp ("udp", communicator_name)) && ((0 == strcmp ("rekey",
814 test_name)) ) 820 test_name))||
821 (0 == strcmp (
822 "backchannel",
823 test_name))) )
815 { 824 {
816 stats[i] = GNUNET_STATISTICS_create ("C-UDP", 825 stats[i] = GNUNET_STATISTICS_create ("C-UDP",
817 cfg_peers[i]); 826 cfg_peers[i]);
818 } 827 }
828 else if ((0 == strcmp ("bidirect", test_name)))
829 {
830 bidirect = GNUNET_YES;
831 }
819 } 832 }
820 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, 833 GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
821 NULL); 834 NULL);
@@ -827,7 +840,6 @@ main (int argc,
827 char *const *argv) 840 char *const *argv)
828{ 841{
829 struct GNUNET_CRYPTO_EddsaPrivateKey *private_key; 842 struct GNUNET_CRYPTO_EddsaPrivateKey *private_key;
830 char *communicator_name;
831 char *test_mode; 843 char *test_mode;
832 char *cfg_peer; 844 char *cfg_peer;
833 845