aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_communicator_basic.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_communicator_basic.c')
-rw-r--r--src/transport/test_communicator_basic.c129
1 files changed, 109 insertions, 20 deletions
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c
index df3c73b20..46eee2299 100644
--- a/src/transport/test_communicator_basic.c
+++ b/src/transport/test_communicator_basic.c
@@ -73,6 +73,10 @@ static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *my_tc;
73 73
74static char *test_name; 74static char *test_name;
75 75
76static struct GNUNET_STATISTICS_GetHandle *box_stats;
77
78static struct GNUNET_STATISTICS_GetHandle *rekey_stats;
79
76#define SHORT_MESSAGE_SIZE 128 80#define SHORT_MESSAGE_SIZE 128
77 81
78#define LONG_MESSAGE_SIZE 32000 /* FIXME */ 82#define LONG_MESSAGE_SIZE 32000 /* FIXME */
@@ -90,7 +94,7 @@ static unsigned int iterations_left = TOTAL_ITERATIONS;
90#define TIMEOUT_MULTIPLIER 1 94#define TIMEOUT_MULTIPLIER 1
91 95
92#define DELAY \ 96#define DELAY \
93 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,50) 97 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,200)
94 98
95#define SHORT_BURST_WINDOW \ 99#define SHORT_BURST_WINDOW \
96 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2) 100 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2)
@@ -514,6 +518,30 @@ update_avg_latency (const char*payload)
514 518
515} 519}
516 520
521process_statistics_box_done (void *cls, int success)
522{
523 if (NULL != box_stats)
524 box_stats = NULL;
525 if (NULL == rekey_stats)
526 {
527 LOG (GNUNET_ERROR_TYPE_DEBUG,
528 "Finished\n");
529 GNUNET_SCHEDULER_shutdown ();
530 }
531}
532
533process_statistics_rekey_done (void *cls, int success)
534{
535 if (NULL != rekey_stats)
536 rekey_stats = NULL;
537 if (NULL == box_stats)
538 {
539 LOG (GNUNET_ERROR_TYPE_DEBUG,
540 "Finished\n");
541 GNUNET_SCHEDULER_shutdown ();
542 }
543}
544
517static int 545static int
518process_statistics (void *cls, 546process_statistics (void *cls,
519 const char *subsystem, 547 const char *subsystem,
@@ -521,6 +549,41 @@ process_statistics (void *cls,
521 uint64_t value, 549 uint64_t value,
522 int is_persistent) 550 int is_persistent)
523{ 551{
552 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
553 "Statistic: Name %s and value %lu\n",
554 name,
555 value);
556 if ((0 == strcmp ("rekey", test_name)) && (0 == strcmp (
557 "# rekeying successful",
558 name)) && (0 == value))
559 {
560 ret = 2;
561 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
562 "No successful rekeying!\n");
563 GNUNET_SCHEDULER_shutdown ();
564 }
565 if ((0 == strcmp ("backchannel", test_name)) &&
566 (0 == strcmp (
567 "# messages decrypted with BOX",
568 name))
569 && (9000 > value))
570 {
571 ret = 2;
572 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
573 "Not enough BOX messages!\n");
574 GNUNET_SCHEDULER_shutdown ();
575 }
576 if ((0 == strcmp ("rekey", test_name)) &&
577 (0 == strcmp (
578 "# messages decrypted with BOX",
579 name))
580 && (6000 > value))
581 {
582 ret = 2;
583 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
584 "Not enough BOX messages!\n");
585 GNUNET_SCHEDULER_shutdown ();
586 }
524 return GNUNET_OK; 587 return GNUNET_OK;
525} 588}
526 589
@@ -660,18 +723,29 @@ incoming_message_cb (void *cls,
660 short_test (NULL); 723 short_test (NULL);
661 break; 724 break;
662 } 725 }
663 /* if (("rekey" == test_name) || ("backchannel" == test_name)) */ 726 if ((0 == strcmp ("rekey", test_name))||(0 == strcmp ("backchannel",
664 /* { */ 727 test_name)) )
665 /* GNUNET_STATISTICS_get (stats[1], */ 728 {
666 /* "C-UDP", */ 729 if (NULL != box_stats)
667 /* "# bytes decrypted with Rekey", */ 730 GNUNET_STATISTICS_get_cancel (box_stats);
668 /* NULL, */ 731 box_stats = GNUNET_STATISTICS_get (stats[1],
669 /* &process_statistics, */ 732 "C-UDP",
670 /* NULL); */ 733 "# messages decrypted with BOX",
671 /* } */ 734 process_statistics_box_done,
672 LOG (GNUNET_ERROR_TYPE_DEBUG, 735 &process_statistics,
673 "Finished\n"); 736 NULL);
674 GNUNET_SCHEDULER_shutdown (); 737 if (NULL != rekey_stats)
738 GNUNET_STATISTICS_get_cancel (rekey_stats);
739 rekey_stats = GNUNET_STATISTICS_get (stats[0],
740 "C-UDP",
741 "# rekeying successful",
742 process_statistics_rekey_done,
743 &process_statistics,
744 NULL);
745 }
746 /* LOG (GNUNET_ERROR_TYPE_DEBUG, */
747 /* "Finished\n"); */
748 /* GNUNET_SCHEDULER_shutdown (); */
675 } 749 }
676 break; 750 break;
677 } 751 }
@@ -682,6 +756,19 @@ incoming_message_cb (void *cls,
682static void 756static void
683do_shutdown (void *cls) 757do_shutdown (void *cls)
684{ 758{
759 LOG (GNUNET_ERROR_TYPE_DEBUG,
760 "shuting down test.\”");
761
762 if (NULL != box_stats)
763 {
764 GNUNET_STATISTICS_get_cancel (box_stats);
765 box_stats = NULL;
766 }
767 if (NULL != rekey_stats)
768 {
769 GNUNET_STATISTICS_get_cancel (rekey_stats);
770 rekey_stats = NULL;
771 }
685 if (NULL != to_task) 772 if (NULL != to_task)
686 { 773 {
687 GNUNET_SCHEDULER_cancel (to_task); 774 GNUNET_SCHEDULER_cancel (to_task);
@@ -690,6 +777,7 @@ do_shutdown (void *cls)
690 for (unsigned int i = 0; i < NUM_PEERS; i++) 777 for (unsigned int i = 0; i < NUM_PEERS; i++)
691 { 778 {
692 GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop (tc_hs[i]); 779 GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop (tc_hs[i]);
780 GNUNET_STATISTICS_destroy (stats[i], GNUNET_NO);
693 } 781 }
694} 782}
695 783
@@ -697,7 +785,7 @@ do_shutdown (void *cls)
697/** 785/**
698 * @brief Main function called by the scheduler 786 * @brief Main function called by the scheduler
699 * 787 *
700 * @param cls Closure - Handle to configuration 788 * @param cls Closure - Handle to confiation
701 */ 789 */
702static void 790static void
703run (void *cls) 791run (void *cls)
@@ -707,6 +795,13 @@ run (void *cls)
707 // num_sent = 0; 795 // num_sent = 0;
708 for (unsigned int i = 0; i < NUM_PEERS; i++) 796 for (unsigned int i = 0; i < NUM_PEERS; i++)
709 { 797 {
798 if ((0 == strcmp ("rekey", test_name))||(0 == strcmp ("backchannel",
799 test_name)) )
800 {
801 stats[i] = GNUNET_STATISTICS_create ("C-UDP",
802 cfg_peers[i]);
803 }
804
710 tc_hs[i] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( 805 tc_hs[i] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
711 "transport", 806 "transport",
712 communicator_binary, 807 communicator_binary,
@@ -719,12 +814,6 @@ run (void *cls)
719 &incoming_message_cb, 814 &incoming_message_cb,
720 &handle_backchannel_cb, 815 &handle_backchannel_cb,
721 cfg_peers_name[i]); /* cls */ 816 cfg_peers_name[i]); /* cls */
722
723 /* if (("rekey" == test_name) || ("backchannel" == test_name)) */
724 /* { */
725 /* stats[i] = GNUNET_STATISTICS_create ("C-UDP", */
726 /* cfg_peers[i]); */
727 /* } */
728 } 817 }
729 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, 818 GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
730 NULL); 819 NULL);