aboutsummaryrefslogtreecommitdiff
path: root/src/topology
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-09-05 21:18:45 +0000
committerChristian Grothoff <christian@grothoff.org>2011-09-05 21:18:45 +0000
commit563b71afee70ac213a8bb28ce0697fcbae06aac3 (patch)
tree122d6a25630f68a9845651ba2295ef68f7d2af09 /src/topology
parentcf6e2bdb1b9a5aedc4f090df853814b9df817e03 (diff)
downloadgnunet-563b71afee70ac213a8bb28ce0697fcbae06aac3.tar.gz
gnunet-563b71afee70ac213a8bb28ce0697fcbae06aac3.zip
fixing API and clean up issues in testing
Diffstat (limited to 'src/topology')
-rw-r--r--src/topology/test_gnunet_daemon_topology.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/topology/test_gnunet_daemon_topology.c b/src/topology/test_gnunet_daemon_topology.c
index c9a43ecd7..3429f50ec 100644
--- a/src/topology/test_gnunet_daemon_topology.c
+++ b/src/topology/test_gnunet_daemon_topology.c
@@ -49,6 +49,11 @@ static struct GNUNET_TESTING_Daemon *first;
49static struct GNUNET_TESTING_Daemon *last; 49static struct GNUNET_TESTING_Daemon *last;
50 50
51/** 51/**
52 * Active connection attempt.
53 */
54struct GNUNET_TESTING_ConnectContext *cc[NUM_PEERS];
55
56/**
52 * Check whether peers successfully shut down. 57 * Check whether peers successfully shut down.
53 */ 58 */
54static void 59static void
@@ -74,6 +79,16 @@ shutdown_callback (void *cls, const char *emsg)
74static void 79static void
75clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 80clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
76{ 81{
82 unsigned int i;
83
84 for (i=0;i<NUM_PEERS;i++)
85 {
86 if (NULL != cc[i])
87 {
88 GNUNET_TESTING_daemons_connect_cancel (cc[i]);
89 cc[i] = NULL;
90 }
91 }
77 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); 92 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
78 ok = 0; 93 ok = 0;
79} 94}
@@ -89,9 +104,19 @@ notify_connect_complete (void *cls, const struct GNUNET_PeerIdentity *first,
89 struct GNUNET_TESTING_Daemon *second_daemon, 104 struct GNUNET_TESTING_Daemon *second_daemon,
90 const char *emsg) 105 const char *emsg)
91{ 106{
107 struct GNUNET_TESTING_ConnectContext **cc;
108 unsigned int i;
109
110 *cc = NULL;
92 if (NULL != emsg) 111 if (NULL != emsg)
93 { 112 {
94 fprintf (stderr, "Failed to connect two peers: %s\n", emsg); 113 fprintf (stderr, "Failed to connect two peers: %s\n", emsg);
114 for (i=0;i<NUM_PEERS;i++)
115 if (NULL != cc[i])
116 {
117 GNUNET_TESTING_daemons_connect_cancel (cc[i]);
118 cc[i] = NULL;
119 }
95 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); 120 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
96 GNUNET_assert (0); 121 GNUNET_assert (0);
97 return; 122 return;
@@ -120,13 +145,13 @@ my_cb (void *cls, const struct GNUNET_PeerIdentity *id,
120 last = d; 145 last = d;
121 return; 146 return;
122 } 147 }
123 GNUNET_TESTING_daemons_connect (last, d, TIMEOUT, CONNECT_ATTEMPTS, 148 cc[peers_left] = GNUNET_TESTING_daemons_connect (last, d, TIMEOUT, CONNECT_ATTEMPTS,
124 GNUNET_YES, &notify_connect_complete, NULL); 149 GNUNET_YES, &notify_connect_complete, &cc[peers_left]);
125 if (peers_left == 0) 150 if (peers_left == 0)
126 { 151 {
127 /* close circle */ 152 /* close circle */
128 GNUNET_TESTING_daemons_connect (d, first, TIMEOUT, CONNECT_ATTEMPTS, 153 cc[NUM_PEERS-1] = GNUNET_TESTING_daemons_connect (d, first, TIMEOUT, CONNECT_ATTEMPTS,
129 GNUNET_YES, &notify_connect_complete, NULL); 154 GNUNET_YES, &notify_connect_complete, &cc[peers_left]);
130 } 155 }
131} 156}
132 157