aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api_unreliability.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_transport_api_unreliability.c')
-rw-r--r--src/transport/test_transport_api_unreliability.c49
1 files changed, 41 insertions, 8 deletions
diff --git a/src/transport/test_transport_api_unreliability.c b/src/transport/test_transport_api_unreliability.c
index a8c8d14e9..20b05a50f 100644
--- a/src/transport/test_transport_api_unreliability.c
+++ b/src/transport/test_transport_api_unreliability.c
@@ -78,6 +78,8 @@ char *cfg_file_p2;
78uint32_t max_bps_p1; 78uint32_t max_bps_p1;
79uint32_t max_bps_p2; 79uint32_t max_bps_p2;
80 80
81struct TransportTestingHandle * tth;
82
81/* 83/*
82 * Testcase specific declarations 84 * Testcase specific declarations
83 */ 85 */
@@ -150,8 +152,10 @@ end ()
150 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); 152 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
151 th = NULL; 153 th = NULL;
152 154
153 GNUNET_TRANSPORT_TESTING_stop_peer (p1); 155 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
154 GNUNET_TRANSPORT_TESTING_stop_peer (p2); 156 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
157
158 GNUNET_TRANSPORT_TESTING_done (tth);
155 159
156 ok = 0; 160 ok = 0;
157 161
@@ -190,9 +194,11 @@ end_badly ()
190 th = NULL; 194 th = NULL;
191 195
192 if (p1 != NULL) 196 if (p1 != NULL)
193 GNUNET_TRANSPORT_TESTING_stop_peer (p1); 197 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
194 if (p2 != NULL) 198 if (p2 != NULL)
195 GNUNET_TRANSPORT_TESTING_stop_peer (p2); 199 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
200
201 GNUNET_TRANSPORT_TESTING_done (tth);
196 202
197 ok = GNUNET_SYSERR; 203 ok = GNUNET_SYSERR;
198} 204}
@@ -456,19 +462,44 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
456 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &sendtask, NULL); 462 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &sendtask, NULL);
457} 463}
458 464
465void start_cb (struct PeerContext * p,
466 void *cls)
467{
468 static int started;
469 started++;
470
471 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n",
472 p->no,
473 GNUNET_i2s (&p->id));
474
475 if (started != 2)
476 return;
477
478 test_connected = GNUNET_NO;
479
480 test_connected = GNUNET_NO;
481 GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, NULL);
482
483}
484
459static void 485static void
460run (void *cls, char *const *args, const char *cfgfile, 486run (void *cls, char *const *args, const char *cfgfile,
461 const struct GNUNET_CONFIGURATION_Handle *cfg) 487 const struct GNUNET_CONFIGURATION_Handle *cfg)
462{ 488{
463 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); 489 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
464 490
465 p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, &notify_receive, 491 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
492 &notify_receive,
466 &notify_connect, &notify_disconnect, 493 &notify_connect, &notify_disconnect,
494 &start_cb,
467 NULL); 495 NULL);
468 p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, &notify_receive, 496 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
497 &notify_receive,
469 &notify_connect, &notify_disconnect, 498 &notify_connect, &notify_disconnect,
499 &start_cb,
470 NULL); 500 NULL);
471 501
502
472 if ((p1 == NULL) || (p2 == NULL)) 503 if ((p1 == NULL) || (p2 == NULL))
473 { 504 {
474 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n"); 505 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n");
@@ -478,8 +509,7 @@ run (void *cls, char *const *args, const char *cfgfile,
478 return; 509 return;
479 } 510 }
480 511
481 test_connected = GNUNET_NO; 512
482 GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, NULL);
483} 513}
484 514
485static int 515static int
@@ -514,6 +544,8 @@ main (int argc, char *argv[])
514 int ret; 544 int ret;
515 int nat_res; 545 int nat_res;
516 546
547 tth = GNUNET_TRANSPORT_TESTING_init ();
548
517 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); 549 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
518 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, 550 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
519 &test_plugin); 551 &test_plugin);
@@ -557,6 +589,7 @@ main (int argc, char *argv[])
557 GNUNET_free (test_plugin); 589 GNUNET_free (test_plugin);
558 GNUNET_free (test_name); 590 GNUNET_free (test_name);
559 591
592
560 return ret; 593 return ret;
561} 594}
562 595