aboutsummaryrefslogtreecommitdiff
path: root/src/dv
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-09-01 15:04:29 +0000
committerChristian Grothoff <christian@grothoff.org>2011-09-01 15:04:29 +0000
commit7e520854fcacaa4991d279919d179f6aff4887cb (patch)
treeb36837c61c1480ed2d845c6ad3a987ef1eff7360 /src/dv
parentd0e15089d37bce6911007c8c0acf8094904d9e75 (diff)
downloadgnunet-7e520854fcacaa4991d279919d179f6aff4887cb.tar.gz
gnunet-7e520854fcacaa4991d279919d179f6aff4887cb.zip
working on DV -- trying to fix bug found by LRN
Diffstat (limited to 'src/dv')
-rw-r--r--src/dv/test_transport_api_dv.c156
1 files changed, 74 insertions, 82 deletions
diff --git a/src/dv/test_transport_api_dv.c b/src/dv/test_transport_api_dv.c
index e66caa4f6..83035911c 100644
--- a/src/dv/test_transport_api_dv.c
+++ b/src/dv/test_transport_api_dv.c
@@ -77,7 +77,7 @@ static struct GNUNET_TESTING_PeerGroup *pg;
77 77
78const struct GNUNET_CONFIGURATION_Handle *main_cfg; 78const struct GNUNET_CONFIGURATION_Handle *main_cfg;
79 79
80GNUNET_SCHEDULER_TaskIdentifier die_task; 80static GNUNET_SCHEDULER_TaskIdentifier die_task;
81 81
82static char *dotOutFileName = "topology.dot"; 82static char *dotOutFileName = "topology.dot";
83 83
@@ -188,7 +188,7 @@ shutdown_callback (void *cls, const char *emsg)
188} 188}
189 189
190static void 190static void
191finish_testing () 191finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
192{ 192{
193 GNUNET_assert (pg != NULL); 193 GNUNET_assert (pg != NULL);
194 struct PeerContext *peer_pos; 194 struct PeerContext *peer_pos;
@@ -196,6 +196,7 @@ finish_testing ()
196 struct TestMessageContext *pos; 196 struct TestMessageContext *pos;
197 struct TestMessageContext *free_pos; 197 struct TestMessageContext *free_pos;
198 198
199 die_task = GNUNET_SCHEDULER_NO_TASK;
199#if VERBOSE 200#if VERBOSE
200 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 201 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
201 "Called finish testing, stopping daemons.\n"); 202 "Called finish testing, stopping daemons.\n");
@@ -308,14 +309,15 @@ static void
308end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 309end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
309{ 310{
310 char *msg = cls; 311 char *msg = cls;
311
312 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
313 "End badly was called (%s)... stopping daemons.\n", msg);
314 struct TestMessageContext *pos; 312 struct TestMessageContext *pos;
315 struct TestMessageContext *free_pos; 313 struct TestMessageContext *free_pos;
316 struct PeerContext *peer_pos; 314 struct PeerContext *peer_pos;
317 struct PeerContext *free_peer_pos; 315 struct PeerContext *free_peer_pos;
318 316
317 die_task = GNUNET_SCHEDULER_NO_TASK;
318 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
319 "End badly was called (%s)... stopping daemons.\n", msg);
320
319 peer_pos = all_peers; 321 peer_pos = all_peers;
320 while (peer_pos != NULL) 322 while (peer_pos != NULL)
321 { 323 {
@@ -474,7 +476,7 @@ process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
474 (total_other_messages == total_other_expected_messages)) 476 (total_other_messages == total_other_expected_messages))
475 { 477 {
476 GNUNET_SCHEDULER_cancel (die_task); 478 GNUNET_SCHEDULER_cancel (die_task);
477 GNUNET_SCHEDULER_add_now (&finish_testing, NULL); 479 die_task = GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
478 } 480 }
479 else 481 else
480 { 482 {
@@ -742,7 +744,8 @@ send_other_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
742#endif 744#endif
743 745
744 GNUNET_SCHEDULER_add_now (&send_test_messages, other_test_messages); 746 GNUNET_SCHEDULER_add_now (&send_test_messages, other_test_messages);
745 GNUNET_SCHEDULER_cancel (die_task); 747 if (GNUNET_SCHEDULER_NO_TASK != die_task)
748 GNUNET_SCHEDULER_cancel (die_task);
746 die_task = 749 die_task =
747 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 750 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
748 (GNUNET_TIME_UNIT_SECONDS, 250), &end_badly, 751 (GNUNET_TIME_UNIT_SECONDS, 250), &end_badly,
@@ -794,8 +797,8 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
794 "Created %u total connections, which is our target number! Calling send messages.\n", 797 "Created %u total connections, which is our target number! Calling send messages.\n",
795 total_connections); 798 total_connections);
796#endif 799#endif
797 800 if (GNUNET_SCHEDULER_NO_TASK != die_task)
798 GNUNET_SCHEDULER_cancel (die_task); 801 GNUNET_SCHEDULER_cancel (die_task);
799 die_task = GNUNET_SCHEDULER_NO_TASK; 802 die_task = GNUNET_SCHEDULER_NO_TASK;
800 GNUNET_SCHEDULER_add_now (&send_test_messages, test_messages); 803 GNUNET_SCHEDULER_add_now (&send_test_messages, test_messages);
801 } 804 }
@@ -806,11 +809,13 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
806 { 809 {
807 GNUNET_SCHEDULER_cancel (die_task); 810 GNUNET_SCHEDULER_cancel (die_task);
808 die_task = GNUNET_SCHEDULER_NO_TASK; 811 die_task = GNUNET_SCHEDULER_NO_TASK;
809 GNUNET_SCHEDULER_add_now (&send_test_messages, test_messages); 812 /* FIXME: ret value!? */ GNUNET_SCHEDULER_add_now (&send_test_messages,
813 test_messages);
810 } 814 }
811 else 815 else
812 { 816 {
813 GNUNET_SCHEDULER_cancel (die_task); 817 if (die_task != GNUNET_SCHEDULER_NO_TASK)
818 GNUNET_SCHEDULER_cancel (die_task);
814 die_task = 819 die_task =
815 GNUNET_SCHEDULER_add_now (&end_badly, 820 GNUNET_SCHEDULER_add_now (&end_badly,
816 "from topology_callback (too many failed connections)"); 821 "from topology_callback (too many failed connections)");
@@ -828,61 +833,6 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
828 } 833 }
829} 834}
830 835
831static void
832connect_topology ()
833{
834 expected_connections = -1;
835 if ((pg != NULL) && (peers_left == 0))
836 {
837 expected_connections =
838 GNUNET_TESTING_connect_topology (pg, connection_topology,
839 connect_topology_option,
840 connect_topology_option_modifier,
841 TIMEOUT, 12, NULL, NULL);
842#if VERBOSE
843 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %d expected connections\n",
844 expected_connections);
845#endif
846 }
847
848 GNUNET_SCHEDULER_cancel (die_task);
849 if (expected_connections == GNUNET_SYSERR)
850 {
851 die_task =
852 GNUNET_SCHEDULER_add_now (&end_badly,
853 "from connect topology (bad return)");
854 }
855
856 die_task =
857 GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly,
858 "from connect topology (timeout)");
859}
860
861static void
862create_topology ()
863{
864 peers_left = num_peers; /* Reset counter */
865 if (GNUNET_TESTING_create_topology
866 (pg, topology, blacklist_topology, blacklist_transports) != GNUNET_SYSERR)
867 {
868#if VERBOSE
869 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
870 "Topology set up, now starting peers!\n");
871#endif
872 GNUNET_TESTING_daemons_continue_startup (pg);
873 }
874 else
875 {
876 GNUNET_SCHEDULER_cancel (die_task);
877 die_task =
878 GNUNET_SCHEDULER_add_now (&end_badly,
879 "from create topology (bad return)");
880 }
881 GNUNET_SCHEDULER_cancel (die_task);
882 die_task =
883 GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly,
884 "from continue startup (timeout)");
885}
886 836
887/** 837/**
888 * Method called whenever a given peer connects. 838 * Method called whenever a given peer connects.
@@ -960,7 +910,8 @@ all_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer,
960 910
961 if (temp_total_other_messages == num_additional_messages) 911 if (temp_total_other_messages == num_additional_messages)
962 { 912 {
963 GNUNET_SCHEDULER_add_now (&send_other_messages, NULL); 913 /* FIXME: ret value!? */ GNUNET_SCHEDULER_add_now (&send_other_messages,
914 NULL);
964 } 915 }
965} 916}
966 917
@@ -1003,14 +954,35 @@ peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id,
1003 "All %d daemons started, now creating topology!\n", num_peers); 954 "All %d daemons started, now creating topology!\n", num_peers);
1004#endif 955#endif
1005 GNUNET_SCHEDULER_cancel (die_task); 956 GNUNET_SCHEDULER_cancel (die_task);
1006 /* Set up task in case topology creation doesn't finish 957 die_task = GNUNET_SCHEDULER_NO_TASK;
1007 * within a reasonable amount of time */ 958 expected_connections = -1;
1008 die_task = 959 if ((pg != NULL) && (peers_left == 0))
1009 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 960 {
1010 (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, 961 expected_connections =
1011 "from peers_started_callback"); 962 GNUNET_TESTING_connect_topology (pg, connection_topology,
963 connect_topology_option,
964 connect_topology_option_modifier,
965 TIMEOUT, 12, NULL, NULL);
966#if VERBOSE
967 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %d expected connections\n",
968 expected_connections);
969#endif
970 }
1012 971
1013 connect_topology (); 972 if (expected_connections == GNUNET_SYSERR)
973 {
974 die_task =
975 GNUNET_SCHEDULER_add_now (&end_badly,
976 "from connect topology (bad return)");
977 }
978 else
979 {
980 /* Set up task in case topology creation doesn't finish
981 * within a reasonable amount of time */
982 die_task =
983 GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly,
984 "from connect topology (timeout)");
985 }
1014 ok = 0; 986 ok = 0;
1015 } 987 }
1016} 988}
@@ -1044,14 +1016,34 @@ hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id,
1044 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1016 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1045 "All %d hostkeys created, now creating topology!\n", num_peers); 1017 "All %d hostkeys created, now creating topology!\n", num_peers);
1046#endif 1018#endif
1047 GNUNET_SCHEDULER_cancel (die_task); 1019 if (GNUNET_SCHEDULER_NO_TASK != die_task)
1048 /* Set up task in case topology creation doesn't finish 1020 {
1049 * within a reasonable amount of time */ 1021 GNUNET_SCHEDULER_cancel (die_task);
1050 die_task = 1022 die_task = GNUNET_SCHEDULER_NO_TASK;
1051 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 1023 }
1052 (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, 1024 /* create topology */
1053 "from hostkey_callback"); 1025 peers_left = num_peers; /* Reset counter */
1054 GNUNET_SCHEDULER_add_now (&create_topology, NULL); 1026 if (GNUNET_TESTING_create_topology
1027 (pg, topology, blacklist_topology,
1028 blacklist_transports) != GNUNET_SYSERR)
1029 {
1030#if VERBOSE
1031 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1032 "Topology set up, now starting peers!\n");
1033#endif
1034 GNUNET_TESTING_daemons_continue_startup (pg);
1035 /* Set up task in case topology creation doesn't finish
1036 * within a reasonable amount of time */
1037 die_task =
1038 GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly,
1039 "from continue startup (timeout)");
1040 }
1041 else
1042 {
1043 die_task =
1044 GNUNET_SCHEDULER_add_now (&end_badly,
1045 "from create topology (bad return)");
1046 }
1055 ok = 0; 1047 ok = 0;
1056 } 1048 }
1057} 1049}