diff options
Diffstat (limited to 'src/transport/test_transport_address_switch.c')
-rw-r--r-- | src/transport/test_transport_address_switch.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/transport/test_transport_address_switch.c b/src/transport/test_transport_address_switch.c index d59d5d265..469dfbf55 100644 --- a/src/transport/test_transport_address_switch.c +++ b/src/transport/test_transport_address_switch.c | |||
@@ -97,10 +97,12 @@ static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | |||
97 | static unsigned int p1_switch_attempts; | 97 | static unsigned int p1_switch_attempts; |
98 | static unsigned int p1_switch_success; | 98 | static unsigned int p1_switch_success; |
99 | static unsigned int p1_switch_fail; | 99 | static unsigned int p1_switch_fail; |
100 | static unsigned int p1_addresses_avail; | ||
100 | 101 | ||
101 | static unsigned int p2_switch_attempts; | 102 | static unsigned int p2_switch_attempts; |
102 | static unsigned int p2_switch_success; | 103 | static unsigned int p2_switch_success; |
103 | static unsigned int p2_switch_fail; | 104 | static unsigned int p2_switch_fail; |
105 | static unsigned int p2_addresses_avail; | ||
104 | 106 | ||
105 | static unsigned long long bytes_sent_total; | 107 | static unsigned long long bytes_sent_total; |
106 | static unsigned long long bytes_recv_total; | 108 | static unsigned long long bytes_recv_total; |
@@ -169,6 +171,9 @@ static int | |||
169 | stat_fail_attempt_cb (void *cls, const char *subsystem, const char *name, | 171 | stat_fail_attempt_cb (void *cls, const char *subsystem, const char *name, |
170 | uint64_t value, int is_persistent) | 172 | uint64_t value, int is_persistent) |
171 | { | 173 | { |
174 | if (value == 0) | ||
175 | return GNUNET_OK; | ||
176 | |||
172 | if (cls == p1) | 177 | if (cls == p1) |
173 | { | 178 | { |
174 | p1_switch_fail++; | 179 | p1_switch_fail++; |
@@ -183,6 +188,21 @@ stat_fail_attempt_cb (void *cls, const char *subsystem, const char *name, | |||
183 | return GNUNET_OK; | 188 | return GNUNET_OK; |
184 | } | 189 | } |
185 | 190 | ||
191 | static int | ||
192 | stat_addresses_available (void *cls, const char *subsystem, const char *name, | ||
193 | uint64_t value, int is_persistent) | ||
194 | { | ||
195 | if (cls == p1) | ||
196 | { | ||
197 | p1_addresses_avail++; | ||
198 | } | ||
199 | if (cls == p2) | ||
200 | { | ||
201 | p2_addresses_avail++; | ||
202 | } | ||
203 | |||
204 | return GNUNET_OK; | ||
205 | } | ||
186 | 206 | ||
187 | static void | 207 | static void |
188 | clean_up () | 208 | clean_up () |
@@ -220,6 +240,9 @@ clean_up () | |||
220 | GNUNET_STATISTICS_watch_cancel (p1_stat, "transport", | 240 | GNUNET_STATISTICS_watch_cancel (p1_stat, "transport", |
221 | "# Failed attempts to switch addresses (no response)", | 241 | "# Failed attempts to switch addresses (no response)", |
222 | stat_fail_attempt_cb, p1); | 242 | stat_fail_attempt_cb, p1); |
243 | GNUNET_STATISTICS_watch (p1_stat, "transport", | ||
244 | "# transport addresses", | ||
245 | stat_addresses_available, p1); | ||
223 | GNUNET_STATISTICS_destroy (p1_stat, GNUNET_NO); | 246 | GNUNET_STATISTICS_destroy (p1_stat, GNUNET_NO); |
224 | p1_stat = NULL; | 247 | p1_stat = NULL; |
225 | } | 248 | } |
@@ -238,6 +261,9 @@ clean_up () | |||
238 | GNUNET_STATISTICS_watch_cancel (p2_stat, "transport", | 261 | GNUNET_STATISTICS_watch_cancel (p2_stat, "transport", |
239 | "# Failed attempts to switch addresses (no response)", | 262 | "# Failed attempts to switch addresses (no response)", |
240 | stat_fail_attempt_cb, p2); | 263 | stat_fail_attempt_cb, p2); |
264 | GNUNET_STATISTICS_watch (p1_stat, "transport", | ||
265 | "# transport addresses", | ||
266 | stat_addresses_available, p1); | ||
241 | GNUNET_STATISTICS_destroy (p2_stat, GNUNET_NO); | 267 | GNUNET_STATISTICS_destroy (p2_stat, GNUNET_NO); |
242 | p2_stat = NULL; | 268 | p2_stat = NULL; |
243 | } | 269 | } |
@@ -289,6 +315,11 @@ end () | |||
289 | if (p1_switch_success != p1_switch_attempts) | 315 | if (p1_switch_success != p1_switch_attempts) |
290 | result ++; | 316 | result ++; |
291 | } | 317 | } |
318 | else | ||
319 | { | ||
320 | FPRINTF (stderr, "Peer 1 had %u addresses available, but did not try to switch\n", | ||
321 | p1_addresses_avail); | ||
322 | } | ||
292 | if (p2_switch_attempts > 0) | 323 | if (p2_switch_attempts > 0) |
293 | { | 324 | { |
294 | FPRINTF (stderr, "Peer 2 tried %u times to switch and succeeded %u times, failed %u times\n", | 325 | FPRINTF (stderr, "Peer 2 tried %u times to switch and succeeded %u times, failed %u times\n", |
@@ -296,6 +327,11 @@ end () | |||
296 | if (p2_switch_success != p2_switch_attempts) | 327 | if (p2_switch_success != p2_switch_attempts) |
297 | result ++; | 328 | result ++; |
298 | } | 329 | } |
330 | else | ||
331 | { | ||
332 | FPRINTF (stderr, "Peer 2 had %u addresses available, but did not try to switch\n", | ||
333 | p2_addresses_avail); | ||
334 | } | ||
299 | 335 | ||
300 | if ( ((p1_switch_attempts > 0) || (p2_switch_attempts > 0)) && | 336 | if ( ((p1_switch_attempts > 0) || (p2_switch_attempts > 0)) && |
301 | (bytes_sent_after_switch == 0) ) | 337 | (bytes_sent_after_switch == 0) ) |
@@ -322,6 +358,11 @@ end_badly () | |||
322 | die_task = GNUNET_SCHEDULER_NO_TASK; | 358 | die_task = GNUNET_SCHEDULER_NO_TASK; |
323 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n"); | 359 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n"); |
324 | 360 | ||
361 | FPRINTF (stderr, "Peer 1 had %u addresses available, but did not try to switch\n", | ||
362 | p1_addresses_avail); | ||
363 | FPRINTF (stderr, "Peer 2 had %u addresses available, but did not try to switch\n", | ||
364 | p2_addresses_avail); | ||
365 | |||
325 | if (test_connected == GNUNET_YES) | 366 | if (test_connected == GNUNET_YES) |
326 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Peers got connected\n"); | 367 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Peers got connected\n"); |
327 | else | 368 | else |
@@ -566,6 +607,9 @@ run (void *cls, char * const *args, const char *cfgfile, | |||
566 | GNUNET_STATISTICS_watch (p1_stat, "transport", | 607 | GNUNET_STATISTICS_watch (p1_stat, "transport", |
567 | "# Failed attempts to switch addresses (no response)", | 608 | "# Failed attempts to switch addresses (no response)", |
568 | stat_fail_attempt_cb, p1); | 609 | stat_fail_attempt_cb, p1); |
610 | GNUNET_STATISTICS_watch (p1_stat, "transport", | ||
611 | "# transport addresses", | ||
612 | stat_addresses_available, p1); | ||
569 | 613 | ||
570 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, | 614 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, |
571 | ¬ify_receive, ¬ify_connect, ¬ify_disconnect, &start_cb, NULL ); | 615 | ¬ify_receive, ¬ify_connect, ¬ify_disconnect, &start_cb, NULL ); |
@@ -586,6 +630,9 @@ run (void *cls, char * const *args, const char *cfgfile, | |||
586 | GNUNET_STATISTICS_watch (p2_stat, "transport", | 630 | GNUNET_STATISTICS_watch (p2_stat, "transport", |
587 | "# Failed attempts to switch addresses (no response)", | 631 | "# Failed attempts to switch addresses (no response)", |
588 | stat_fail_attempt_cb, p2); | 632 | stat_fail_attempt_cb, p2); |
633 | GNUNET_STATISTICS_watch (p2_stat, "transport", | ||
634 | "# transport addresses", | ||
635 | stat_addresses_available, p2); | ||
589 | 636 | ||
590 | if ((p1 == NULL )|| (p2 == NULL)) | 637 | if ((p1 == NULL )|| (p2 == NULL)) |
591 | { | 638 | { |