aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-09 22:34:49 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-09 22:34:49 +0000
commitc0b81510ffe194dc662c3a6267d5e66a69873c4b (patch)
tree5ad5cc473d6993523be80bcf1430230e224d9216 /src/transport
parenta7345f7436c421fd15e18e87ec399ea93b6dde03 (diff)
downloadgnunet-c0b81510ffe194dc662c3a6267d5e66a69873c4b.tar.gz
gnunet-c0b81510ffe194dc662c3a6267d5e66a69873c4b.zip
-start to refactor testcases for sanity
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/Makefile.am4
-rw-r--r--src/transport/test_quota_compliance.c49
-rw-r--r--src/transport/test_transport_address_switch.c43
-rw-r--r--src/transport/test_transport_api.c58
-rw-r--r--src/transport/test_transport_api_bidirectional_connect.c78
-rw-r--r--src/transport/test_transport_api_blacklisting.c70
-rw-r--r--src/transport/test_transport_api_disconnect.c77
-rw-r--r--src/transport/test_transport_api_limited_sockets.c59
-rw-r--r--src/transport/test_transport_api_manipulation_cfg.c48
-rw-r--r--src/transport/test_transport_api_manipulation_recv_tcp.c55
-rw-r--r--src/transport/test_transport_api_manipulation_send_tcp.c53
-rw-r--r--src/transport/test_transport_api_monitor_peers.c70
-rw-r--r--src/transport/test_transport_api_reliability.c41
-rw-r--r--src/transport/test_transport_api_restart_1peer.c76
-rw-r--r--src/transport/test_transport_api_restart_2peers.c45
-rw-r--r--src/transport/test_transport_api_timeout.c56
-rw-r--r--src/transport/test_transport_api_unreliability_constant.c10
-rw-r--r--src/transport/test_transport_blacklisting.c208
-rw-r--r--src/transport/test_transport_startonly.c8
-rw-r--r--src/transport/test_transport_testing.c45
-rw-r--r--src/transport/test_transport_testing_restart.c27
-rw-r--r--src/transport/test_transport_testing_startstop.c20
-rw-r--r--src/transport/transport-testing-filenames.c221
-rw-r--r--src/transport/transport-testing-main.c48
-rw-r--r--src/transport/transport-testing.c649
-rw-r--r--src/transport/transport-testing.h208
26 files changed, 1276 insertions, 1050 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index f9a9fe19c..721e05d83 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -150,7 +150,9 @@ lib_LTLIBRARIES = \
150 $(TESTING_LIBS) 150 $(TESTING_LIBS)
151 151
152libgnunettransporttesting_la_SOURCES = \ 152libgnunettransporttesting_la_SOURCES = \
153 transport-testing.c transport-testing.h 153 transport-testing.c transport-testing.h \
154 transport-testing-filenames.c \
155 transport-testing-main.c
154libgnunettransporttesting_la_LIBADD = \ 156libgnunettransporttesting_la_LIBADD = \
155 libgnunettransport.la \ 157 libgnunettransport.la \
156 $(top_builddir)/src/hello/libgnunethello.la \ 158 $(top_builddir)/src/hello/libgnunethello.la \
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c
index e64260969..59dbd45e0 100644
--- a/src/transport/test_quota_compliance.c
+++ b/src/transport/test_quota_compliance.c
@@ -51,13 +51,13 @@ static struct GNUNET_SCHEDULER_Task * die_task;
51 51
52static struct GNUNET_SCHEDULER_Task * measure_task; 52static struct GNUNET_SCHEDULER_Task * measure_task;
53 53
54struct PeerContext *p1; 54struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
55 55
56struct PeerContext *p2; 56struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
57 57
58struct PeerContext *sender; 58struct GNUNET_TRANSPORT_TESTING_PeerContext *sender;
59 59
60struct PeerContext *receiver; 60struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver;
61 61
62struct GNUNET_TRANSPORT_TransmitHandle *th; 62struct GNUNET_TRANSPORT_TransmitHandle *th;
63 63
@@ -71,7 +71,7 @@ char *gen_cfg_p1;
71unsigned long long quota_in_p2; 71unsigned long long quota_in_p2;
72unsigned long long quota_out_p2; 72unsigned long long quota_out_p2;
73 73
74struct GNUNET_TRANSPORT_TESTING_handle *tth; 74struct GNUNET_TRANSPORT_TESTING_Handle *tth;
75 75
76static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; 76static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
77 77
@@ -161,10 +161,10 @@ end ()
161 th = NULL; 161 th = NULL;
162 162
163 if (cc != NULL) 163 if (cc != NULL)
164 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 164 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
165 165
166 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 166 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
167 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 167 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
168 168
169} 169}
170 170
@@ -187,12 +187,12 @@ end_badly ()
187 th = NULL; 187 th = NULL;
188 188
189 if (cc != NULL) 189 if (cc != NULL)
190 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 190 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
191 191
192 if (p1 != NULL) 192 if (p1 != NULL)
193 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 193 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
194 if (p2 != NULL) 194 if (p2 != NULL)
195 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 195 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
196 196
197 test_failed = GNUNET_YES; 197 test_failed = GNUNET_YES;
198} 198}
@@ -214,7 +214,7 @@ notify_receive (void *cls,
214 const struct GNUNET_MessageHeader *message) 214 const struct GNUNET_MessageHeader *message)
215{ 215{
216 const struct TestMessage *hdr; 216 const struct TestMessage *hdr;
217 struct PeerContext *p = cls; 217 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
218 218
219 hdr = (const struct TestMessage *) message; 219 hdr = (const struct TestMessage *) message;
220 if (MTYPE != ntohs (message->type)) 220 if (MTYPE != ntohs (message->type))
@@ -319,7 +319,7 @@ static void
319notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) 319notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
320{ 320{
321 321
322 struct PeerContext *p = cls; 322 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
323 323
324 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 324 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
325 "Peer %u (`%4s') connected to us!\n", 325 "Peer %u (`%4s') connected to us!\n",
@@ -331,7 +331,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
331static void 331static void
332notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 332notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
333{ 333{
334 struct PeerContext *p = cls; 334 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
335 335
336 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 336 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
337 "Peer %u (`%4s') disconnected!\n", 337 "Peer %u (`%4s') disconnected!\n",
@@ -376,7 +376,7 @@ measure (void *cls)
376 376
377 377
378static void 378static void
379testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) 379testing_connect_cb (void *cls)
380{ 380{
381 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); 381 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
382 382
@@ -393,8 +393,9 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
393 393
394} 394}
395 395
396void 396
397start_cb (struct PeerContext *p, void *cls) 397static void
398start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
398{ 399{
399 static int started; 400 static int started;
400 401
@@ -416,7 +417,7 @@ start_cb (struct PeerContext *p, void *cls)
416 "Test tries to send from %u (%s) -> peer %u (%s)\n", sender->no, 417 "Test tries to send from %u (%s) -> peer %u (%s)\n", sender->no,
417 sender_c, receiver->no, GNUNET_i2s (&receiver->id)); 418 sender_c, receiver->no, GNUNET_i2s (&receiver->id));
418 GNUNET_free (sender_c); 419 GNUNET_free (sender_c);
419 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, 420 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb,
420 NULL); 421 NULL);
421 422
422} 423}
@@ -492,6 +493,7 @@ run_measurement (unsigned long long p1_quota_in,
492 } 493 }
493} 494}
494 495
496
495static void 497static void
496run (void *cls, char *const *args, const char *cfgfile, 498run (void *cls, char *const *args, const char *cfgfile,
497 const struct GNUNET_CONFIGURATION_Handle *cfg) 499 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -538,20 +540,19 @@ check ()
538int 540int
539main (int argc, char *argv[]) 541main (int argc, char *argv[])
540{ 542{
541 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 543 test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
542 544
543 GNUNET_log_setup (test_name, 545 GNUNET_log_setup (test_name,
544 "WARNING", 546 "WARNING",
545 NULL); 547 NULL);
546 548
547 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); 549 test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
548 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, 550 test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source);
549 &test_plugin);
550 551
551 tth = GNUNET_TRANSPORT_TESTING_init (); 552 tth = GNUNET_TRANSPORT_TESTING_init ();
552 553
553 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); 554 cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
554 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2); 555 cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
555 556
556 check (); 557 check ();
557 558
diff --git a/src/transport/test_transport_address_switch.c b/src/transport/test_transport_address_switch.c
index a2311f99b..a64dd6172 100644
--- a/src/transport/test_transport_address_switch.c
+++ b/src/transport/test_transport_address_switch.c
@@ -92,21 +92,21 @@ static struct GNUNET_SCHEDULER_Task *delayed_end_task;
92static struct GNUNET_SCHEDULER_Task *measure_task; 92static struct GNUNET_SCHEDULER_Task *measure_task;
93 93
94 94
95static struct PeerContext *p1; 95static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
96static char *cfg_file_p1; 96static char *cfg_file_p1;
97static struct GNUNET_STATISTICS_Handle *p1_stat; 97static struct GNUNET_STATISTICS_Handle *p1_stat;
98 98
99static struct PeerContext *p2; 99static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
100static char *cfg_file_p2; 100static char *cfg_file_p2;
101static struct GNUNET_STATISTICS_Handle *p2_stat; 101static struct GNUNET_STATISTICS_Handle *p2_stat;
102 102
103static struct PeerContext *sender; 103static struct GNUNET_TRANSPORT_TESTING_PeerContext *sender;
104 104
105static struct PeerContext *receiver; 105static struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver;
106 106
107static struct GNUNET_TRANSPORT_TransmitHandle *th; 107static struct GNUNET_TRANSPORT_TransmitHandle *th;
108 108
109static struct GNUNET_TRANSPORT_TESTING_handle *tth; 109static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
110 110
111static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; 111static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
112 112
@@ -312,17 +312,17 @@ clean_up ()
312 } 312 }
313 if (cc != NULL) 313 if (cc != NULL)
314 { 314 {
315 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 315 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
316 cc = NULL; 316 cc = NULL;
317 } 317 }
318 if (p1 != NULL) 318 if (p1 != NULL)
319 { 319 {
320 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 320 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
321 p1 = NULL; 321 p1 = NULL;
322 } 322 }
323 if (p2 != NULL) 323 if (p2 != NULL)
324 { 324 {
325 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 325 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
326 p2 = NULL; 326 p2 = NULL;
327 } 327 }
328} 328}
@@ -435,7 +435,7 @@ notify_receive (void *cls,
435 if (MTYPE != ntohs (message->type)) 435 if (MTYPE != ntohs (message->type))
436 return; 436 return;
437 437
438 struct PeerContext *p = cls; 438 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
439 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); 439 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
440 440
441 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 441 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -521,7 +521,7 @@ static void
521notify_connect (void *cls, 521notify_connect (void *cls,
522 const struct GNUNET_PeerIdentity *peer) 522 const struct GNUNET_PeerIdentity *peer)
523{ 523{
524 struct PeerContext *p = cls; 524 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
525 525
526 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 526 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
527 "Peer %u (`%4s') connected to us!\n", 527 "Peer %u (`%4s') connected to us!\n",
@@ -534,7 +534,7 @@ static void
534notify_disconnect (void *cls, 534notify_disconnect (void *cls,
535 const struct GNUNET_PeerIdentity *peer) 535 const struct GNUNET_PeerIdentity *peer)
536{ 536{
537 struct PeerContext *p = cls; 537 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
538 538
539 if (NULL != p1) 539 if (NULL != p1)
540 { 540 {
@@ -584,9 +584,7 @@ progress_indicator (void *cls)
584 584
585 585
586static void 586static void
587testing_connect_cb (struct PeerContext *p1, 587testing_connect_cb (void *cls)
588 struct PeerContext *p2,
589 void *cls)
590{ 588{
591 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); 589 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
592 590
@@ -612,7 +610,7 @@ testing_connect_cb (struct PeerContext *p1,
612 610
613 611
614static void 612static void
615start_cb (struct PeerContext *p, void *cls) 613start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
616{ 614{
617 static int started; 615 static int started;
618 started++; 616 started++;
@@ -638,7 +636,8 @@ start_cb (struct PeerContext *p, void *cls)
638 GNUNET_free (sender_c); 636 GNUNET_free (sender_c);
639 637
640 /* Connect the peers */ 638 /* Connect the peers */
641 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, 639 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
640 p2,
642 &testing_connect_cb, 641 &testing_connect_cb,
643 NULL); 642 NULL);
644} 643}
@@ -729,19 +728,19 @@ main (int argc, char *argv[])
729 static struct GNUNET_GETOPT_CommandLineOption options[] = { 728 static struct GNUNET_GETOPT_CommandLineOption options[] = {
730 GNUNET_GETOPT_OPTION_END }; 729 GNUNET_GETOPT_OPTION_END };
731 730
732 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 731 test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
733 732
734 GNUNET_log_setup (test_name, "WARNING", NULL ); 733 GNUNET_log_setup (test_name, "WARNING", NULL );
735 734
736 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); 735 test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
737 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, 736 test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
738 &test_plugin); 737 test_source);
739 738
740 tth = GNUNET_TRANSPORT_TESTING_init (); 739 tth = GNUNET_TRANSPORT_TESTING_init ();
741 740
742 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); 741 cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
743 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Using cfg [%u] : %s \n", 1, cfg_file_p1); 742 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Using cfg [%u] : %s \n", 1, cfg_file_p1);
744 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2); 743 cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
745 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Using cfg [%u] : %s \n", 2, cfg_file_p2); 744 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Using cfg [%u] : %s \n", 2, cfg_file_p2);
746 745
747 GNUNET_PROGRAM_run ((sizeof(argv_new) / sizeof(char *)) - 1, argv_new, 746 GNUNET_PROGRAM_run ((sizeof(argv_new) / sizeof(char *)) - 1, argv_new,
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c
index 91d129e24..9983356de 100644
--- a/src/transport/test_transport_api.c
+++ b/src/transport/test_transport_api.c
@@ -62,15 +62,15 @@ static struct GNUNET_SCHEDULER_Task * die_task;
62 62
63static struct GNUNET_SCHEDULER_Task * send_task; 63static struct GNUNET_SCHEDULER_Task * send_task;
64 64
65static struct PeerContext *p1; 65static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
66 66
67static struct PeerContext *p2; 67static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
68 68
69static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; 69static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
70 70
71static struct GNUNET_TRANSPORT_TransmitHandle *th; 71static struct GNUNET_TRANSPORT_TransmitHandle *th;
72 72
73static struct GNUNET_TRANSPORT_TESTING_handle *tth; 73static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
74 74
75static char *cfg_file_p1; 75static char *cfg_file_p1;
76 76
@@ -92,8 +92,8 @@ end ()
92 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); 92 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
93 th = NULL; 93 th = NULL;
94 94
95 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 95 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
96 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 96 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
97} 97}
98 98
99 99
@@ -111,7 +111,7 @@ end_badly (void *cls)
111 if (cc != NULL) 111 if (cc != NULL)
112 { 112 {
113 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n")); 113 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
114 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 114 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
115 cc = NULL; 115 cc = NULL;
116 } 116 }
117 117
@@ -138,11 +138,11 @@ end_badly (void *cls)
138 th = NULL; 138 th = NULL;
139 139
140 if (p1 != NULL) 140 if (p1 != NULL)
141 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 141 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
142 else 142 else
143 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n")); 143 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n"));
144 if (p2 != NULL) 144 if (p2 != NULL)
145 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 145 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
146 else 146 else
147 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n")); 147 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n"));
148 148
@@ -154,8 +154,8 @@ static void
154notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, 154notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
155 const struct GNUNET_MessageHeader *message) 155 const struct GNUNET_MessageHeader *message)
156{ 156{
157 struct PeerContext *p = cls; 157 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
158 struct PeerContext *t = NULL; 158 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
159 159
160 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 160 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
161 t = p1; 161 t = p1;
@@ -189,7 +189,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
189static size_t 189static size_t
190notify_ready (void *cls, size_t size, void *buf) 190notify_ready (void *cls, size_t size, void *buf)
191{ 191{
192 struct PeerContext *p = cls; 192 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
193 struct GNUNET_MessageHeader *hdr; 193 struct GNUNET_MessageHeader *hdr;
194 194
195 th = NULL; 195 th = NULL;
@@ -249,8 +249,8 @@ notify_connect (void *cls,
249 static int c; 249 static int c;
250 250
251 c++; 251 c++;
252 struct PeerContext *p = cls; 252 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
253 struct PeerContext *t = NULL; 253 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
254 254
255 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 255 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
256 t = p1; 256 t = p1;
@@ -271,7 +271,7 @@ static void
271notify_disconnect (void *cls, 271notify_disconnect (void *cls,
272 const struct GNUNET_PeerIdentity *peer) 272 const struct GNUNET_PeerIdentity *peer)
273{ 273{
274 struct PeerContext *p = cls; 274 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
275 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); 275 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
276 276
277 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 277 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -290,9 +290,7 @@ notify_disconnect (void *cls,
290 290
291 291
292static void 292static void
293testing_connect_cb (struct PeerContext *p1, 293testing_connect_cb (void *cls)
294 struct PeerContext *p2,
295 void *cls)
296{ 294{
297 cc = NULL; 295 cc = NULL;
298 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); 296 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -307,7 +305,7 @@ testing_connect_cb (struct PeerContext *p1,
307 305
308 306
309static void 307static void
310start_cb (struct PeerContext *p, 308start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
311 void *cls) 309 void *cls)
312{ 310{
313 static int started; 311 static int started;
@@ -329,8 +327,7 @@ start_cb (struct PeerContext *p,
329 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); 327 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
330 GNUNET_free (sender_c); 328 GNUNET_free (sender_c);
331 } 329 }
332 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, 330 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
333 p1,
334 p2, 331 p2,
335 &testing_connect_cb, 332 &testing_connect_cb,
336 NULL); 333 NULL);
@@ -406,25 +403,20 @@ main (int argc, char *argv[])
406{ 403{
407 int ret; 404 int ret;
408 405
409 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], 406 test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
410 &test_name); 407 test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
411 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, 408 test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
412 &test_source); 409 test_source);
413 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
414 test_source,
415 &test_plugin);
416 410
417 GNUNET_log_setup (test_name, 411 GNUNET_log_setup (test_name,
418 "WARNING", 412 "WARNING",
419 NULL); 413 NULL);
420 tth = GNUNET_TRANSPORT_TESTING_init (); 414 tth = GNUNET_TRANSPORT_TESTING_init ();
421 415
422 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 416 cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0],
423 &cfg_file_p1, 417 1);
424 1); 418 cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0],
425 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 419 2);
426 &cfg_file_p2,
427 2);
428 420
429 ret = check (); 421 ret = check ();
430 422
diff --git a/src/transport/test_transport_api_bidirectional_connect.c b/src/transport/test_transport_api_bidirectional_connect.c
index a5d6b6b71..10b20e21e 100644
--- a/src/transport/test_transport_api_bidirectional_connect.c
+++ b/src/transport/test_transport_api_bidirectional_connect.c
@@ -53,16 +53,16 @@ static struct GNUNET_SCHEDULER_Task * die_task;
53 53
54static struct GNUNET_SCHEDULER_Task * send_task; 54static struct GNUNET_SCHEDULER_Task * send_task;
55 55
56static struct PeerContext *p1; 56static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
57 57
58static struct PeerContext *p2; 58static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
59 59
60static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc1; 60static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc1;
61static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc2; 61static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc2;
62 62
63static struct GNUNET_TRANSPORT_TransmitHandle *th; 63static struct GNUNET_TRANSPORT_TransmitHandle *th;
64 64
65static struct GNUNET_TRANSPORT_TESTING_handle *tth; 65static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
66 66
67static char *cfg_file_p1; 67static char *cfg_file_p1;
68 68
@@ -89,8 +89,8 @@ end ()
89 th = NULL; 89 th = NULL;
90 } 90 }
91 91
92 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 92 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
93 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 93 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
94} 94}
95 95
96 96
@@ -108,13 +108,13 @@ end_badly (void *cls)
108 if (NULL != cc2) 108 if (NULL != cc2)
109 { 109 {
110 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n")); 110 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
111 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc2); 111 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc2);
112 cc2 = NULL; 112 cc2 = NULL;
113 } 113 }
114 if (NULL != cc1) 114 if (NULL != cc1)
115 { 115 {
116 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n")); 116 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
117 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc1); 117 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc1);
118 cc1 = NULL; 118 cc1 = NULL;
119 } 119 }
120 if (NULL != th) 120 if (NULL != th)
@@ -123,9 +123,9 @@ end_badly (void *cls)
123 th = NULL; 123 th = NULL;
124 } 124 }
125 if (p1 != NULL) 125 if (p1 != NULL)
126 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 126 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
127 if (p2 != NULL) 127 if (p2 != NULL)
128 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 128 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
129 129
130 ok = GNUNET_SYSERR; 130 ok = GNUNET_SYSERR;
131} 131}
@@ -135,8 +135,8 @@ static void
135notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, 135notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
136 const struct GNUNET_MessageHeader *message) 136 const struct GNUNET_MessageHeader *message)
137{ 137{
138 struct PeerContext *p = cls; 138 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
139 struct PeerContext *t = NULL; 139 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
140 140
141 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 141 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
142 t = p1; 142 t = p1;
@@ -168,7 +168,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
168static size_t 168static size_t
169notify_ready (void *cls, size_t size, void *buf) 169notify_ready (void *cls, size_t size, void *buf)
170{ 170{
171 struct PeerContext *p = cls; 171 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
172 struct GNUNET_MessageHeader *hdr; 172 struct GNUNET_MessageHeader *hdr;
173 173
174 th = NULL; 174 th = NULL;
@@ -231,8 +231,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
231 static int c; 231 static int c;
232 232
233 c++; 233 c++;
234 struct PeerContext *p = cls; 234 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
235 struct PeerContext *t = NULL; 235 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
236 236
237 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 237 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
238 t = p1; 238 t = p1;
@@ -257,7 +257,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
257static void 257static void
258notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 258notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
259{ 259{
260 struct PeerContext *p = cls; 260 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
261 261
262 { 262 {
263 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); 263 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
@@ -284,17 +284,17 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
284 284
285 285
286static void 286static void
287testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) 287testing_connect_cb (void *cls)
288{ 288{
289 static int connected = GNUNET_NO; 289 static int connected = GNUNET_NO;
290 290
291 if ((cls == cc1) && (NULL != cc2)) 291 if ((cls == cc1) && (NULL != cc2))
292 { 292 {
293 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc2); 293 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc2);
294 } 294 }
295 if ((cls == cc2) && (NULL != cc1)) 295 if ((cls == cc2) && (NULL != cc1))
296 { 296 {
297 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc1); 297 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc1);
298 } 298 }
299 cc1 = NULL; 299 cc1 = NULL;
300 cc2 = NULL; 300 cc2 = NULL;
@@ -321,7 +321,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
321 321
322 322
323static void 323static void
324start_cb (struct PeerContext *p, void *cls) 324start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
325{ 325{
326 static int started; 326 static int started;
327 327
@@ -342,10 +342,14 @@ start_cb (struct PeerContext *p, void *cls)
342 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); 342 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
343 GNUNET_free (sender_c); 343 GNUNET_free (sender_c);
344 cc1 = 344 cc1 =
345 GNUNET_TRANSPORT_TESTING_connect_peers (tth, p2, p1, &testing_connect_cb, 345 GNUNET_TRANSPORT_TESTING_connect_peers (p2,
346 p1,
347 &testing_connect_cb,
346 cc1); 348 cc1);
347 cc2 = 349 cc2 =
348 GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, 350 GNUNET_TRANSPORT_TESTING_connect_peers (p1,
351 p2,
352 &testing_connect_cb,
349 cc2); 353 cc2);
350} 354}
351 355
@@ -356,14 +360,21 @@ run (void *cls, char *const *args, const char *cfgfile,
356{ 360{
357 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); 361 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
358 362
359 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, 363 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
360 &notify_receive, &notify_connect, 364 cfg_file_p1, 1,
361 &notify_disconnect, &start_cb, 365 &notify_receive,
366 &notify_connect,
367 &notify_disconnect,
368 &start_cb,
362 NULL); 369 NULL);
363 370
364 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, 371 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
365 &notify_receive, &notify_connect, 372 cfg_file_p2,
366 &notify_disconnect, &start_cb, 373 2,
374 &notify_receive,
375 &notify_connect,
376 &notify_disconnect,
377 &start_cb,
367 NULL); 378 NULL);
368 379
369 if ((p1 == NULL) || (p2 == NULL)) 380 if ((p1 == NULL) || (p2 == NULL))
@@ -406,20 +417,19 @@ main (int argc, char *argv[])
406{ 417{
407 int ret; 418 int ret;
408 419
409 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 420 test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
410
411 GNUNET_log_setup (test_name, 421 GNUNET_log_setup (test_name,
412 "WARNING", 422 "WARNING",
413 NULL); 423 NULL);
414 424
415 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); 425 test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
416 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, 426 test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
417 &test_plugin); 427 test_source);
418 428
419 tth = GNUNET_TRANSPORT_TESTING_init (); 429 tth = GNUNET_TRANSPORT_TESTING_init ();
420 430
421 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); 431 cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
422 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2); 432 cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
423 433
424 ret = check (); 434 ret = check ();
425 435
diff --git a/src/transport/test_transport_api_blacklisting.c b/src/transport/test_transport_api_blacklisting.c
index 963d3b045..8dce4d48d 100644
--- a/src/transport/test_transport_api_blacklisting.c
+++ b/src/transport/test_transport_api_blacklisting.c
@@ -28,15 +28,15 @@
28#include "gnunet_transport_service.h" 28#include "gnunet_transport_service.h"
29#include "transport-testing.h" 29#include "transport-testing.h"
30 30
31static struct PeerContext *p1; 31static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
32 32
33static struct PeerContext *p2; 33static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
34 34
35static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; 35static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
36 36
37static struct GNUNET_TRANSPORT_TransmitHandle *th; 37static struct GNUNET_TRANSPORT_TransmitHandle *th;
38 38
39static struct GNUNET_TRANSPORT_TESTING_handle *tth; 39static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
40 40
41/** 41/**
42 * How long until we give up on transmitting the message? 42 * How long until we give up on transmitting the message?
@@ -91,7 +91,7 @@ end (void *cls)
91 91
92 if (cc != NULL) 92 if (cc != NULL)
93 { 93 {
94 GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc); 94 GNUNET_TRANSPORT_TESTING_connect_peers_cancel(cc);
95 cc = NULL; 95 cc = NULL;
96 } 96 }
97 97
@@ -113,12 +113,12 @@ end (void *cls)
113 113
114 if (p1 != NULL) 114 if (p1 != NULL)
115 { 115 {
116 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 116 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
117 p1 = NULL; 117 p1 = NULL;
118 } 118 }
119 if (p2 != NULL) 119 if (p2 != NULL)
120 { 120 {
121 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 121 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
122 p2 = NULL; 122 p2 = NULL;
123 } 123 }
124 124
@@ -155,7 +155,7 @@ end_badly (void *cls)
155 if (cc != NULL) 155 if (cc != NULL)
156 { 156 {
157 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n")); 157 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
158 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 158 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
159 cc = NULL; 159 cc = NULL;
160 } 160 }
161 161
@@ -170,9 +170,9 @@ end_badly (void *cls)
170 GNUNET_TRANSPORT_blacklist_cancel (blacklist_p2); 170 GNUNET_TRANSPORT_blacklist_cancel (blacklist_p2);
171 171
172 if (p1 != NULL) 172 if (p1 != NULL)
173 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 173 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
174 if (p2 != NULL) 174 if (p2 != NULL)
175 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 175 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
176 176
177 ok = GNUNET_SYSERR; 177 ok = GNUNET_SYSERR;
178} 178}
@@ -182,8 +182,8 @@ static void
182notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, 182notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
183 const struct GNUNET_MessageHeader *message) 183 const struct GNUNET_MessageHeader *message)
184{ 184{
185 struct PeerContext *p = cls; 185 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
186 struct PeerContext *t = NULL; 186 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
187 187
188 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 188 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
189 t = p1; 189 t = p1;
@@ -217,7 +217,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
217static size_t 217static size_t
218notify_ready (void *cls, size_t size, void *buf) 218notify_ready (void *cls, size_t size, void *buf)
219{ 219{
220 struct PeerContext *p = cls; 220 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
221 struct GNUNET_MessageHeader *hdr; 221 struct GNUNET_MessageHeader *hdr;
222 222
223 th = NULL; 223 th = NULL;
@@ -283,8 +283,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
283 static int c; 283 static int c;
284 284
285 c++; 285 c++;
286 struct PeerContext *p = cls; 286 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
287 struct PeerContext *t = NULL; 287 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
288 288
289 connected = GNUNET_YES; 289 connected = GNUNET_YES;
290 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 290 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
@@ -310,7 +310,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
310static void 310static void
311notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 311notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
312{ 312{
313 struct PeerContext *p = cls; 313 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
314 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); 314 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
315 315
316 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 316 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -326,7 +326,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
326 326
327 327
328static void 328static void
329testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) 329testing_connect_cb (void *cls)
330{ 330{
331 cc = NULL; 331 cc = NULL;
332 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); 332 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -347,7 +347,7 @@ blacklist_cb (void *cls,
347 const struct 347 const struct
348 GNUNET_PeerIdentity * pid) 348 GNUNET_PeerIdentity * pid)
349{ 349{
350 struct PeerContext * p = cls; 350 struct GNUNET_TRANSPORT_TESTING_PeerContext * p = cls;
351 int res = GNUNET_SYSERR; 351 int res = GNUNET_SYSERR;
352 352
353 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 353 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -376,7 +376,7 @@ blacklist_cb (void *cls,
376 376
377 377
378static void 378static void
379start_cb (struct PeerContext *p, void *cls) 379start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
380{ 380{
381 static int started; 381 static int started;
382 382
@@ -395,7 +395,9 @@ start_cb (struct PeerContext *p, void *cls)
395 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); 395 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
396 GNUNET_free (sender_c); 396 GNUNET_free (sender_c);
397 397
398 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, 398 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
399 p2,
400 &testing_connect_cb,
399 NULL); 401 NULL);
400 402
401} 403}
@@ -405,28 +407,36 @@ static void
405run (void *cls, char *const *args, const char *cfgfile, 407run (void *cls, char *const *args, const char *cfgfile,
406 const struct GNUNET_CONFIGURATION_Handle *cfg) 408 const struct GNUNET_CONFIGURATION_Handle *cfg)
407{ 409{
408 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); 410 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
411 &end_badly,
412 NULL);
409 connected = GNUNET_NO; 413 connected = GNUNET_NO;
410 blacklist_request_p1 = GNUNET_NO; 414 blacklist_request_p1 = GNUNET_NO;
411 blacklist_request_p2 = GNUNET_NO; 415 blacklist_request_p2 = GNUNET_NO;
412 416
413 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, "test_transport_api_tcp_peer1.conf", 1, 417 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
414 &notify_receive, &notify_connect, 418 "test_transport_api_tcp_peer1.conf", 1,
415 &notify_disconnect, &start_cb, 419 &notify_receive,
420 &notify_connect,
421 &notify_disconnect,
422 &start_cb,
416 NULL); 423 NULL);
417 424
418 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, "test_transport_api_tcp_peer2.conf", 2, 425 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
419 &notify_receive, &notify_connect, 426 "test_transport_api_tcp_peer2.conf", 2,
420 &notify_disconnect, &start_cb, 427 &notify_receive,
428 &notify_connect,
429 &notify_disconnect,
430 &start_cb,
421 NULL); 431 NULL);
422 432
423 blacklist_p1 = GNUNET_TRANSPORT_blacklist (p1->cfg, 433 blacklist_p1 = GNUNET_TRANSPORT_blacklist (p1->cfg,
424 &blacklist_cb, 434 &blacklist_cb,
425 p1); 435 p1);
426 436
427 blacklist_p2 = GNUNET_TRANSPORT_blacklist (p2->cfg, 437 blacklist_p2 = GNUNET_TRANSPORT_blacklist (p2->cfg,
428 &blacklist_cb, 438 &blacklist_cb,
429 p2); 439 p2);
430 440
431 GNUNET_assert (blacklist_p1 != NULL); 441 GNUNET_assert (blacklist_p1 != NULL);
432 GNUNET_assert (blacklist_p2 != NULL); 442 GNUNET_assert (blacklist_p2 != NULL);
diff --git a/src/transport/test_transport_api_disconnect.c b/src/transport/test_transport_api_disconnect.c
index f52634bde..cf50c97c0 100644
--- a/src/transport/test_transport_api_disconnect.c
+++ b/src/transport/test_transport_api_disconnect.c
@@ -51,15 +51,15 @@ static struct GNUNET_SCHEDULER_Task * die_task;
51 51
52static struct GNUNET_SCHEDULER_Task * send_task; 52static struct GNUNET_SCHEDULER_Task * send_task;
53 53
54struct PeerContext *p1; 54struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
55 55
56struct PeerContext *p2; 56struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
57 57
58static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; 58static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
59 59
60struct GNUNET_TRANSPORT_TransmitHandle *th; 60struct GNUNET_TRANSPORT_TransmitHandle *th;
61 61
62struct GNUNET_TRANSPORT_TESTING_handle *tth; 62struct GNUNET_TRANSPORT_TESTING_Handle *tth;
63 63
64int shutdown_; 64int shutdown_;
65 65
@@ -96,11 +96,11 @@ end ()
96 th = NULL; 96 th = NULL;
97 97
98 if (p1 != NULL) 98 if (p1 != NULL)
99 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 99 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
100 p1 = NULL; 100 p1 = NULL;
101 101
102 if (p2 != NULL) 102 if (p2 != NULL)
103 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 103 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
104 p2 = NULL; 104 p2 = NULL;
105 105
106 /* success */ 106 /* success */
@@ -117,7 +117,7 @@ end_badly (void *cls)
117 117
118 if (cc != NULL) 118 if (cc != NULL)
119 { 119 {
120 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 120 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
121 cc = NULL; 121 cc = NULL;
122 } 122 }
123 123
@@ -132,9 +132,9 @@ end_badly (void *cls)
132 th = NULL; 132 th = NULL;
133 133
134 if (p1 != NULL) 134 if (p1 != NULL)
135 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 135 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
136 if (p2 != NULL) 136 if (p2 != NULL)
137 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 137 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
138 138
139 ok = GNUNET_SYSERR; 139 ok = GNUNET_SYSERR;
140} 140}
@@ -142,7 +142,7 @@ end_badly (void *cls)
142static void 142static void
143notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 143notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
144{ 144{
145 struct PeerContext *p = cls; 145 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
146 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); 146 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
147 147
148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -165,12 +165,12 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
165static void 165static void
166stop_peer (void *cls) 166stop_peer (void *cls)
167{ 167{
168 struct PeerContext *p = cls; 168 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
169 169
170 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down peer %u (`%s')\n", p->no, 170 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down peer %u (`%s')\n", p->no,
171 GNUNET_i2s (&p->id)); 171 GNUNET_i2s (&p->id));
172 shutdown_ = GNUNET_YES; 172 shutdown_ = GNUNET_YES;
173 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 173 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
174 p2 = NULL; 174 p2 = NULL;
175 GNUNET_assert (p2 == NULL); 175 GNUNET_assert (p2 == NULL);
176} 176}
@@ -180,8 +180,8 @@ static void
180notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, 180notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
181 const struct GNUNET_MessageHeader *message) 181 const struct GNUNET_MessageHeader *message)
182{ 182{
183 struct PeerContext *p = cls; 183 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
184 struct PeerContext *t = NULL; 184 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
185 185
186 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 186 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
187 t = p1; 187 t = p1;
@@ -210,7 +210,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
210static size_t 210static size_t
211notify_ready (void *cls, size_t size, void *buf) 211notify_ready (void *cls, size_t size, void *buf)
212{ 212{
213 struct PeerContext *p = cls; 213 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
214 struct GNUNET_MessageHeader *hdr; 214 struct GNUNET_MessageHeader *hdr;
215 215
216 th = NULL; 216 th = NULL;
@@ -268,8 +268,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
268 static int c; 268 static int c;
269 269
270 c++; 270 c++;
271 struct PeerContext *p = cls; 271 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
272 struct PeerContext *t = NULL; 272 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
273 273
274 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 274 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
275 t = p1; 275 t = p1;
@@ -287,7 +287,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
287 287
288 288
289static void 289static void
290testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) 290testing_connect_cb (void *cls)
291{ 291{
292 cc = NULL; 292 cc = NULL;
293 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); 293 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -301,7 +301,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
301 301
302 302
303static void 303static void
304start_cb (struct PeerContext *p, void *cls) 304start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
305{ 305{
306 static int started; 306 static int started;
307 307
@@ -317,7 +317,9 @@ start_cb (struct PeerContext *p, void *cls)
317 "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", 317 "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
318 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); 318 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
319 GNUNET_free (sender_c); 319 GNUNET_free (sender_c);
320 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, 320 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
321 p2,
322 &testing_connect_cb,
321 NULL); 323 NULL);
322 324
323} 325}
@@ -329,19 +331,28 @@ run (void *cls, char *const *args, const char *cfgfile,
329{ 331{
330 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); 332 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
331 333
332 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, 334 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
333 &notify_receive, &notify_connect, 335 cfg_file_p1,
334 &notify_disconnect, &start_cb, 336 1,
337 &notify_receive,
338 &notify_connect,
339 &notify_disconnect,
340 &start_cb,
335 NULL); 341 NULL);
336 342
337 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, 343 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
338 &notify_receive, &notify_connect, 344 cfg_file_p2,
339 &notify_disconnect, &start_cb, 345 2,
346 &notify_receive,
347 &notify_connect,
348 &notify_disconnect,
349 &start_cb,
340 NULL); 350 NULL);
341 351
342 if ((p1 == NULL) || (p2 == NULL)) 352 if ((p1 == NULL) || (p2 == NULL))
343 { 353 {
344 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n"); 354 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
355 "Fail! Could not start peers!\n");
345 if (die_task != NULL) 356 if (die_task != NULL)
346 GNUNET_SCHEDULER_cancel (die_task); 357 GNUNET_SCHEDULER_cancel (die_task);
347 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); 358 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
@@ -376,20 +387,18 @@ main (int argc, char *argv[])
376{ 387{
377 int ret; 388 int ret;
378 389
379 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 390 test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
380
381 GNUNET_log_setup (test_name, 391 GNUNET_log_setup (test_name,
382 "WARNING", 392 "WARNING",
383 NULL); 393 NULL);
384 394
385 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); 395 test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
386 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, 396 test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
387 &test_plugin); 397 test_source);
388
389 tth = GNUNET_TRANSPORT_TESTING_init (); 398 tth = GNUNET_TRANSPORT_TESTING_init ();
390 399
391 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); 400 cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
392 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2); 401 cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
393 402
394 ret = check (); 403 ret = check ();
395 404
diff --git a/src/transport/test_transport_api_limited_sockets.c b/src/transport/test_transport_api_limited_sockets.c
index 1a04ad6fe..be91a5947 100644
--- a/src/transport/test_transport_api_limited_sockets.c
+++ b/src/transport/test_transport_api_limited_sockets.c
@@ -59,15 +59,15 @@ static struct GNUNET_SCHEDULER_Task * die_task;
59 59
60static struct GNUNET_SCHEDULER_Task * send_task; 60static struct GNUNET_SCHEDULER_Task * send_task;
61 61
62static struct PeerContext *p1; 62static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
63 63
64static struct PeerContext *p2; 64static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
65 65
66static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; 66static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
67 67
68static struct GNUNET_TRANSPORT_TransmitHandle *th; 68static struct GNUNET_TRANSPORT_TransmitHandle *th;
69 69
70static struct GNUNET_TRANSPORT_TESTING_handle *tth; 70static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
71 71
72static char *cfg_file_p1; 72static char *cfg_file_p1;
73 73
@@ -95,8 +95,8 @@ end ()
95 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); 95 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
96 th = NULL; 96 th = NULL;
97 97
98 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 98 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
99 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 99 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
100 GNUNET_TRANSPORT_TESTING_done (tth); 100 GNUNET_TRANSPORT_TESTING_done (tth);
101 101
102} 102}
@@ -112,16 +112,16 @@ end_badly (void *cls)
112 GNUNET_SCHEDULER_cancel (send_task); 112 GNUNET_SCHEDULER_cancel (send_task);
113 113
114 if (cc != NULL) 114 if (cc != NULL)
115 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 115 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
116 116
117 if (th != NULL) 117 if (th != NULL)
118 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); 118 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
119 th = NULL; 119 th = NULL;
120 120
121 if (p1 != NULL) 121 if (p1 != NULL)
122 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 122 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
123 if (p2 != NULL) 123 if (p2 != NULL)
124 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 124 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
125 125
126 if (NULL != th) 126 if (NULL != th)
127 GNUNET_TRANSPORT_TESTING_done (tth); 127 GNUNET_TRANSPORT_TESTING_done (tth);
@@ -156,7 +156,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
156static size_t 156static size_t
157notify_ready (void *cls, size_t size, void *buf) 157notify_ready (void *cls, size_t size, void *buf)
158{ 158{
159 struct PeerContext *p = cls; 159 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
160 struct GNUNET_MessageHeader *hdr; 160 struct GNUNET_MessageHeader *hdr;
161 161
162 th = NULL; 162 th = NULL;
@@ -206,7 +206,7 @@ sendtask (void *cls)
206 206
207 207
208static void 208static void
209testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) 209testing_connect_cb (void *cls)
210{ 210{
211 cc = NULL; 211 cc = NULL;
212 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); 212 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -221,7 +221,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
221} 221}
222 222
223static void 223static void
224start_cb (struct PeerContext *p, void *cls) 224start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
225{ 225{
226 static int started; 226 static int started;
227 227
@@ -233,7 +233,9 @@ start_cb (struct PeerContext *p, void *cls)
233 if (started != 2) 233 if (started != 2)
234 return; 234 return;
235 235
236 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p2, p1, &testing_connect_cb, 236 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p2,
237 p1,
238 &testing_connect_cb,
237 NULL); 239 NULL);
238 240
239} 241}
@@ -246,13 +248,21 @@ run (void *cls, char *const *args, const char *cfgfile,
246 248
247 tth = GNUNET_TRANSPORT_TESTING_init (); 249 tth = GNUNET_TRANSPORT_TESTING_init ();
248 250
249 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, 251 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
250 &notify_receive, &notify_connect, 252 cfg_file_p1,
251 &notify_disconnect, &start_cb, 253 1,
254 &notify_receive,
255 &notify_connect,
256 &notify_disconnect,
257 &start_cb,
252 NULL); 258 NULL);
253 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, 259 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
254 &notify_receive, &notify_connect, 260 cfg_file_p2,
255 &notify_disconnect, &start_cb, 261 2,
262 &notify_receive,
263 &notify_connect,
264 &notify_disconnect,
265 &start_cb,
256 NULL); 266 NULL);
257 if ((p1 == NULL) || (p2 == NULL)) 267 if ((p1 == NULL) || (p2 == NULL))
258 { 268 {
@@ -298,11 +308,10 @@ main (int argc, char *argv[])
298 int res; 308 int res;
299 int ret = 0; 309 int ret = 0;
300 310
301 test_plugin = NULL; 311 test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
302 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); 312 test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
303 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, 313 test_source);
304 &test_plugin); 314 test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
305 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
306 GNUNET_log_setup (test_name, 315 GNUNET_log_setup (test_name,
307 "WARNING", 316 "WARNING",
308 NULL); 317 NULL);
@@ -328,8 +337,8 @@ main (int argc, char *argv[])
328 return 0; 337 return 0;
329 } 338 }
330 339
331 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); 340 cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
332 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2); 341 cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
333 ret = check (); 342 ret = check ();
334 343
335 GNUNET_free (cfg_file_p1); 344 GNUNET_free (cfg_file_p1);
diff --git a/src/transport/test_transport_api_manipulation_cfg.c b/src/transport/test_transport_api_manipulation_cfg.c
index fe3d31f7b..a6dc08429 100644
--- a/src/transport/test_transport_api_manipulation_cfg.c
+++ b/src/transport/test_transport_api_manipulation_cfg.c
@@ -71,15 +71,15 @@ static struct GNUNET_SCHEDULER_Task * die_task;
71 71
72static struct GNUNET_SCHEDULER_Task * send_task; 72static struct GNUNET_SCHEDULER_Task * send_task;
73 73
74static struct PeerContext *p1; 74static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
75 75
76static struct PeerContext *p2; 76static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
77 77
78static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; 78static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
79 79
80static struct GNUNET_TRANSPORT_TransmitHandle *th; 80static struct GNUNET_TRANSPORT_TransmitHandle *th;
81 81
82static struct GNUNET_TRANSPORT_TESTING_handle *tth; 82static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
83 83
84static char *cfg_file_p1; 84static char *cfg_file_p1;
85 85
@@ -103,8 +103,8 @@ end ()
103 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); 103 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
104 th = NULL; 104 th = NULL;
105 105
106 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 106 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
107 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 107 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
108} 108}
109 109
110 110
@@ -122,7 +122,7 @@ end_badly (void *cls)
122 if (cc != NULL) 122 if (cc != NULL)
123 { 123 {
124 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n")); 124 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
125 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 125 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
126 cc = NULL; 126 cc = NULL;
127 } 127 }
128 128
@@ -149,11 +149,11 @@ end_badly (void *cls)
149 th = NULL; 149 th = NULL;
150 150
151 if (p1 != NULL) 151 if (p1 != NULL)
152 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 152 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
153 else 153 else
154 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n")); 154 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n"));
155 if (p2 != NULL) 155 if (p2 != NULL)
156 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 156 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
157 else 157 else
158 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n")); 158 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n"));
159 159
@@ -164,7 +164,7 @@ end_badly (void *cls)
164static size_t 164static size_t
165notify_request_ready (void *cls, size_t size, void *buf) 165notify_request_ready (void *cls, size_t size, void *buf)
166{ 166{
167 struct PeerContext *p = cls; 167 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
168 struct GNUNET_MessageHeader *hdr; 168 struct GNUNET_MessageHeader *hdr;
169 169
170 th = NULL; 170 th = NULL;
@@ -225,7 +225,7 @@ sendtask_request_task (void *cls)
225static size_t 225static size_t
226notify_response_ready (void *cls, size_t size, void *buf) 226notify_response_ready (void *cls, size_t size, void *buf)
227{ 227{
228 struct PeerContext *p = cls; 228 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
229 struct GNUNET_MessageHeader *hdr; 229 struct GNUNET_MessageHeader *hdr;
230 230
231 th = NULL; 231 th = NULL;
@@ -296,8 +296,8 @@ static void
296notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, 296notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
297 const struct GNUNET_MessageHeader *message) 297 const struct GNUNET_MessageHeader *message)
298{ 298{
299 struct PeerContext *p = cls; 299 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
300 struct PeerContext *t = NULL; 300 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
301 struct GNUNET_TIME_Relative duration; 301 struct GNUNET_TIME_Relative duration;
302 302
303 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 303 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
@@ -369,8 +369,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
369 static int c; 369 static int c;
370 370
371 c++; 371 c++;
372 struct PeerContext *p = cls; 372 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
373 struct PeerContext *t = NULL; 373 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
374 374
375 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 375 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
376 t = p1; 376 t = p1;
@@ -390,7 +390,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
390static void 390static void
391notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 391notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
392{ 392{
393 struct PeerContext *p = cls; 393 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
394 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); 394 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
395 395
396 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 396 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -406,7 +406,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
406 406
407 407
408static void 408static void
409testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) 409testing_connect_cb (void *cls)
410{ 410{
411 cc = NULL; 411 cc = NULL;
412 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); 412 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -421,7 +421,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
421 421
422 422
423static void 423static void
424start_cb (struct PeerContext *p, void *cls) 424start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
425{ 425{
426 static int started; 426 static int started;
427 started++; 427 started++;
@@ -440,7 +440,7 @@ start_cb (struct PeerContext *p, void *cls)
440 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); 440 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
441 GNUNET_free (sender_c); 441 GNUNET_free (sender_c);
442 442
443 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, 443 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb,
444 NULL); 444 NULL);
445 445
446} 446}
@@ -503,18 +503,18 @@ main (int argc, char *argv[])
503{ 503{
504 int ret; 504 int ret;
505 505
506 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 506 test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
507 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); 507 test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
508 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, 508 test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
509 &test_plugin); 509 test_source);
510 510
511 GNUNET_log_setup (test_name, 511 GNUNET_log_setup (test_name,
512 "WARNING", 512 "WARNING",
513 NULL); 513 NULL);
514 tth = GNUNET_TRANSPORT_TESTING_init (); 514 tth = GNUNET_TRANSPORT_TESTING_init ();
515 515
516 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); 516 cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
517 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2); 517 cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
518 518
519 ret = check (); 519 ret = check ();
520 520
diff --git a/src/transport/test_transport_api_manipulation_recv_tcp.c b/src/transport/test_transport_api_manipulation_recv_tcp.c
index 02c9408a6..03aced539 100644
--- a/src/transport/test_transport_api_manipulation_recv_tcp.c
+++ b/src/transport/test_transport_api_manipulation_recv_tcp.c
@@ -63,15 +63,15 @@ static struct GNUNET_SCHEDULER_Task * die_task;
63 63
64static struct GNUNET_SCHEDULER_Task * send_task; 64static struct GNUNET_SCHEDULER_Task * send_task;
65 65
66static struct PeerContext *p1; 66static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
67 67
68static struct PeerContext *p2; 68static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
69 69
70static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; 70static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
71 71
72static struct GNUNET_TRANSPORT_TransmitHandle *th; 72static struct GNUNET_TRANSPORT_TransmitHandle *th;
73 73
74static struct GNUNET_TRANSPORT_TESTING_handle *tth; 74static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
75 75
76static char *cfg_file_p1; 76static char *cfg_file_p1;
77 77
@@ -100,8 +100,8 @@ end ()
100 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); 100 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
101 th = NULL; 101 th = NULL;
102 102
103 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 103 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
104 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 104 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
105} 105}
106 106
107 107
@@ -119,7 +119,7 @@ end_badly (void *cls)
119 if (cc != NULL) 119 if (cc != NULL)
120 { 120 {
121 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n")); 121 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
122 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 122 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
123 cc = NULL; 123 cc = NULL;
124 } 124 }
125 125
@@ -146,11 +146,11 @@ end_badly (void *cls)
146 th = NULL; 146 th = NULL;
147 147
148 if (p1 != NULL) 148 if (p1 != NULL)
149 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 149 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
150 else 150 else
151 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n")); 151 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n"));
152 if (p2 != NULL) 152 if (p2 != NULL)
153 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 153 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
154 else 154 else
155 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n")); 155 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n"));
156 156
@@ -166,8 +166,8 @@ static void
166notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, 166notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
167 const struct GNUNET_MessageHeader *message) 167 const struct GNUNET_MessageHeader *message)
168{ 168{
169 struct PeerContext *p = cls; 169 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
170 struct PeerContext *t = NULL; 170 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
171 171
172 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 172 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
173 t = p1; 173 t = p1;
@@ -249,7 +249,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
249static size_t 249static size_t
250notify_ready (void *cls, size_t size, void *buf) 250notify_ready (void *cls, size_t size, void *buf)
251{ 251{
252 struct PeerContext *p = cls; 252 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
253 struct GNUNET_MessageHeader *hdr; 253 struct GNUNET_MessageHeader *hdr;
254 254
255 th = NULL; 255 th = NULL;
@@ -327,8 +327,8 @@ notify_connect (void *cls,
327 static int c; 327 static int c;
328 328
329 c++; 329 c++;
330 struct PeerContext *p = cls; 330 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
331 struct PeerContext *t = NULL; 331 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
332 332
333 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 333 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
334 t = p1; 334 t = p1;
@@ -354,7 +354,7 @@ static void
354notify_disconnect (void *cls, 354notify_disconnect (void *cls,
355 const struct GNUNET_PeerIdentity *peer) 355 const struct GNUNET_PeerIdentity *peer)
356{ 356{
357 struct PeerContext *p = cls; 357 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
358 358
359 { 359 {
360 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); 360 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
@@ -376,9 +376,7 @@ notify_disconnect (void *cls,
376 376
377 377
378static void 378static void
379testing_connect_cb (struct PeerContext *p1, 379testing_connect_cb (void *cls)
380 struct PeerContext *p2,
381 void *cls)
382{ 380{
383 cc = NULL; 381 cc = NULL;
384 382
@@ -400,7 +398,7 @@ testing_connect_cb (struct PeerContext *p1,
400 398
401 399
402static void 400static void
403start_cb (struct PeerContext *p, void *cls) 401start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
404{ 402{
405 static int started; 403 static int started;
406 started++; 404 started++;
@@ -426,8 +424,7 @@ start_cb (struct PeerContext *p, void *cls)
426 GNUNET_free (sender_c); 424 GNUNET_free (sender_c);
427 } 425 }
428 426
429 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, 427 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
430 p1,
431 p2, 428 p2,
432 &testing_connect_cb, 429 &testing_connect_cb,
433 NULL); 430 NULL);
@@ -445,12 +442,14 @@ run (void *cls, char *const *args, const char *cfgfile,
445 s_connected = GNUNET_NO; 442 s_connected = GNUNET_NO;
446 s_sending = GNUNET_NO; 443 s_sending = GNUNET_NO;
447 444
448 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, 445 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
446 cfg_file_p1, 1,
449 &notify_receive, &notify_connect, 447 &notify_receive, &notify_connect,
450 &notify_disconnect, &start_cb, 448 &notify_disconnect, &start_cb,
451 NULL); 449 NULL);
452 450
453 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, 451 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
452 cfg_file_p2, 2,
454 &notify_receive, &notify_connect, 453 &notify_receive, &notify_connect,
455 &notify_disconnect, &start_cb, 454 &notify_disconnect, &start_cb,
456 NULL); 455 NULL);
@@ -492,18 +491,18 @@ main (int argc, char *argv[])
492{ 491{
493 int ret; 492 int ret;
494 493
495 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 494 test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
496 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); 495 test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
497 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, 496 test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
498 &test_plugin); 497 test_source);
499 498
500 GNUNET_log_setup (test_name, 499 GNUNET_log_setup (test_name,
501 "WARNING", 500 "WARNING",
502 NULL); 501 NULL);
503 tth = GNUNET_TRANSPORT_TESTING_init (); 502 tth = GNUNET_TRANSPORT_TESTING_init ();
504 503
505 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); 504 cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
506 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2); 505 cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
507 506
508 ret = check (); 507 ret = check ();
509 508
diff --git a/src/transport/test_transport_api_manipulation_send_tcp.c b/src/transport/test_transport_api_manipulation_send_tcp.c
index e031b7111..c5604ff08 100644
--- a/src/transport/test_transport_api_manipulation_send_tcp.c
+++ b/src/transport/test_transport_api_manipulation_send_tcp.c
@@ -63,15 +63,15 @@ static struct GNUNET_SCHEDULER_Task * die_task;
63 63
64static struct GNUNET_SCHEDULER_Task * send_task; 64static struct GNUNET_SCHEDULER_Task * send_task;
65 65
66static struct PeerContext *p1; 66static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
67 67
68static struct PeerContext *p2; 68static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
69 69
70static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; 70static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
71 71
72static struct GNUNET_TRANSPORT_TransmitHandle *th; 72static struct GNUNET_TRANSPORT_TransmitHandle *th;
73 73
74static struct GNUNET_TRANSPORT_TESTING_handle *tth; 74static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
75 75
76static char *cfg_file_p1; 76static char *cfg_file_p1;
77 77
@@ -101,8 +101,8 @@ end ()
101 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); 101 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
102 th = NULL; 102 th = NULL;
103 103
104 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 104 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
105 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 105 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
106} 106}
107 107
108 108
@@ -120,7 +120,7 @@ end_badly (void *cls)
120 if (cc != NULL) 120 if (cc != NULL)
121 { 121 {
122 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n")); 122 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
123 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 123 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
124 cc = NULL; 124 cc = NULL;
125 } 125 }
126 126
@@ -147,11 +147,11 @@ end_badly (void *cls)
147 th = NULL; 147 th = NULL;
148 148
149 if (p1 != NULL) 149 if (p1 != NULL)
150 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 150 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
151 else 151 else
152 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n")); 152 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n"));
153 if (p2 != NULL) 153 if (p2 != NULL)
154 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 154 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
155 else 155 else
156 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n")); 156 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n"));
157 157
@@ -167,8 +167,8 @@ static void
167notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, 167notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
168 const struct GNUNET_MessageHeader *message) 168 const struct GNUNET_MessageHeader *message)
169{ 169{
170 struct PeerContext *p = cls; 170 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
171 struct PeerContext *t = NULL; 171 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
172 172
173 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 173 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
174 t = p1; 174 t = p1;
@@ -244,7 +244,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
244static size_t 244static size_t
245notify_ready (void *cls, size_t size, void *buf) 245notify_ready (void *cls, size_t size, void *buf)
246{ 246{
247 struct PeerContext *p = cls; 247 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
248 struct GNUNET_MessageHeader *hdr; 248 struct GNUNET_MessageHeader *hdr;
249 249
250 th = NULL; 250 th = NULL;
@@ -333,8 +333,8 @@ static void
333notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) 333notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
334{ 334{
335 static int c; 335 static int c;
336 struct PeerContext *p = cls; 336 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
337 struct PeerContext *t = NULL; 337 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
338 338
339 c++; 339 c++;
340 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 340 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
@@ -360,7 +360,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
360static void 360static void
361notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 361notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
362{ 362{
363 struct PeerContext *p = cls; 363 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
364 364
365 { 365 {
366 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); 366 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
@@ -382,7 +382,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
382 382
383 383
384static void 384static void
385testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) 385testing_connect_cb (void *cls)
386{ 386{
387 cc = NULL; 387 cc = NULL;
388 388
@@ -404,7 +404,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
404 404
405 405
406static void 406static void
407start_cb (struct PeerContext *p, void *cls) 407start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
408{ 408{
409 static int started; 409 static int started;
410 started++; 410 started++;
@@ -424,7 +424,8 @@ start_cb (struct PeerContext *p, void *cls)
424 "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", 424 "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
425 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); 425 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
426 GNUNET_free (sender_c); 426 GNUNET_free (sender_c);
427 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, 427 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
428 p2,
428 &testing_connect_cb, 429 &testing_connect_cb,
429 NULL); 430 NULL);
430 431
@@ -441,12 +442,14 @@ run (void *cls, char *const *args, const char *cfgfile,
441 s_connected = GNUNET_NO; 442 s_connected = GNUNET_NO;
442 s_sending = GNUNET_NO; 443 s_sending = GNUNET_NO;
443 444
444 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, 445 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
446 cfg_file_p1, 1,
445 &notify_receive, &notify_connect, 447 &notify_receive, &notify_connect,
446 &notify_disconnect, &start_cb, 448 &notify_disconnect, &start_cb,
447 NULL); 449 NULL);
448 450
449 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, 451 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
452 cfg_file_p2, 2,
450 &notify_receive, &notify_connect, 453 &notify_receive, &notify_connect,
451 &notify_disconnect, &start_cb, 454 &notify_disconnect, &start_cb,
452 NULL); 455 NULL);
@@ -488,18 +491,18 @@ main (int argc, char *argv[])
488{ 491{
489 int ret; 492 int ret;
490 493
491 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 494 test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
492 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); 495 test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
493 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, 496 test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
494 &test_plugin); 497 test_source);
495 498
496 GNUNET_log_setup (test_name, 499 GNUNET_log_setup (test_name,
497 "WARNING", 500 "WARNING",
498 NULL); 501 NULL);
499 tth = GNUNET_TRANSPORT_TESTING_init (); 502 tth = GNUNET_TRANSPORT_TESTING_init ();
500 503
501 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); 504 cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
502 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2); 505 cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
503 506
504 ret = check (); 507 ret = check ();
505 508
diff --git a/src/transport/test_transport_api_monitor_peers.c b/src/transport/test_transport_api_monitor_peers.c
index 90c96829d..4731e41e2 100644
--- a/src/transport/test_transport_api_monitor_peers.c
+++ b/src/transport/test_transport_api_monitor_peers.c
@@ -57,15 +57,15 @@ static struct GNUNET_SCHEDULER_Task * die_task;
57 57
58static struct GNUNET_SCHEDULER_Task * send_task; 58static struct GNUNET_SCHEDULER_Task * send_task;
59 59
60static struct PeerContext *p1; 60static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
61 61
62static struct PeerContext *p2; 62static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
63 63
64static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; 64static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
65 65
66static struct GNUNET_TRANSPORT_TransmitHandle *th; 66static struct GNUNET_TRANSPORT_TransmitHandle *th;
67 67
68static struct GNUNET_TRANSPORT_TESTING_handle *tth; 68static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
69 69
70static char *cfg_file_p1; 70static char *cfg_file_p1;
71 71
@@ -107,10 +107,10 @@ end ()
107 th = NULL; 107 th = NULL;
108 108
109 if (NULL != p1) 109 if (NULL != p1)
110 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 110 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
111 p1 = NULL; 111 p1 = NULL;
112 if (NULL != p2) 112 if (NULL != p2)
113 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 113 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
114 p2 = NULL; 114 p2 = NULL;
115 115
116 if (NULL != pmc_p1) 116 if (NULL != pmc_p1)
@@ -143,7 +143,7 @@ end_badly (void *cls)
143 if (cc != NULL) 143 if (cc != NULL)
144 { 144 {
145 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n")); 145 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
146 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 146 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
147 cc = NULL; 147 cc = NULL;
148 } 148 }
149 149
@@ -181,11 +181,11 @@ end_badly (void *cls)
181 } 181 }
182 182
183 if (p1 != NULL) 183 if (p1 != NULL)
184 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 184 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
185 else 185 else
186 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n")); 186 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n"));
187 if (p2 != NULL) 187 if (p2 != NULL)
188 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 188 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
189 else 189 else
190 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n")); 190 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n"));
191 191
@@ -197,8 +197,8 @@ static void
197notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, 197notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
198 const struct GNUNET_MessageHeader *message) 198 const struct GNUNET_MessageHeader *message)
199{ 199{
200 struct PeerContext *p = cls; 200 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
201 struct PeerContext *t = NULL; 201 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
202 202
203 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 203 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
204 t = p1; 204 t = p1;
@@ -219,7 +219,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
219static size_t 219static size_t
220notify_ready (void *cls, size_t size, void *buf) 220notify_ready (void *cls, size_t size, void *buf)
221{ 221{
222 struct PeerContext *p = cls; 222 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
223 struct GNUNET_MessageHeader *hdr; 223 struct GNUNET_MessageHeader *hdr;
224 224
225 th = NULL; 225 th = NULL;
@@ -294,8 +294,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
294 static int c; 294 static int c;
295 295
296 c++; 296 c++;
297 struct PeerContext *p = cls; 297 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
298 struct PeerContext *t = NULL; 298 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
299 299
300 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 300 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
301 { 301 {
@@ -323,7 +323,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
323static void 323static void
324notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 324notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
325{ 325{
326 struct PeerContext *p = cls; 326 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
327 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); 327 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
328 328
329 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 329 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -339,9 +339,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
339 339
340 340
341static void 341static void
342testing_connect_cb (struct PeerContext *p1, 342testing_connect_cb (void *cls)
343 struct PeerContext *p2,
344 void *cls)
345{ 343{
346 cc = NULL; 344 cc = NULL;
347 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); 345 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -357,7 +355,7 @@ testing_connect_cb (struct PeerContext *p1,
357 355
358 356
359static void 357static void
360start_cb (struct PeerContext *p, void *cls) 358start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
361{ 359{
362 static int started; 360 static int started;
363 361
@@ -378,7 +376,9 @@ start_cb (struct PeerContext *p, void *cls)
378 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); 376 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
379 GNUNET_free (sender_c); 377 GNUNET_free (sender_c);
380 378
381 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, 379 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
380 p2,
381 &testing_connect_cb,
382 NULL); 382 NULL);
383 383
384} 384}
@@ -446,9 +446,13 @@ run (void *cls, char *const *args, const char *cfgfile,
446 s_connected = GNUNET_NO; 446 s_connected = GNUNET_NO;
447 s_sending = GNUNET_NO; 447 s_sending = GNUNET_NO;
448 448
449 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, 449 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
450 &notify_receive, &notify_connect, 450 cfg_file_p1,
451 &notify_disconnect, &start_cb, 451 1,
452 &notify_receive,
453 &notify_connect,
454 &notify_disconnect,
455 &start_cb,
452 NULL); 456 NULL);
453 pmc_p1 = GNUNET_TRANSPORT_monitor_peers (p1->cfg, 457 pmc_p1 = GNUNET_TRANSPORT_monitor_peers (p1->cfg,
454 NULL, 458 NULL,
@@ -457,9 +461,13 @@ run (void *cls, char *const *args, const char *cfgfile,
457 NULL); 461 NULL);
458 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 started\n"); 462 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 started\n");
459 463
460 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, 464 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
461 &notify_receive, &notify_connect, 465 cfg_file_p2,
462 &notify_disconnect, &start_cb, 466 2,
467 &notify_receive,
468 &notify_connect,
469 &notify_disconnect,
470 &start_cb,
463 NULL); 471 NULL);
464 pmc_p2 = GNUNET_TRANSPORT_monitor_peers (p2->cfg, 472 pmc_p2 = GNUNET_TRANSPORT_monitor_peers (p2->cfg,
465 NULL, 473 NULL,
@@ -507,18 +515,18 @@ main (int argc, char *argv[])
507 515
508 ok = 1; 516 ok = 1;
509 517
510 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 518 test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
511 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); 519 test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
512 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, 520 test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
513 &test_plugin); 521 test_source);
514 522
515 GNUNET_log_setup (test_name, 523 GNUNET_log_setup (test_name,
516 "WARNING", 524 "WARNING",
517 NULL); 525 NULL);
518 tth = GNUNET_TRANSPORT_TESTING_init (); 526 tth = GNUNET_TRANSPORT_TESTING_init ();
519 527
520 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); 528 cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
521 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2); 529 cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
522 530
523 ret = check (); 531 ret = check ();
524 532
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c
index 154301656..94865f438 100644
--- a/src/transport/test_transport_api_reliability.c
+++ b/src/transport/test_transport_api_reliability.c
@@ -92,7 +92,7 @@ static int ok;
92/** 92/**
93 * Context of peer 1 93 * Context of peer 1
94 */ 94 */
95static struct PeerContext *p1; 95static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
96 96
97/** 97/**
98 * Configuration file of peer 1 98 * Configuration file of peer 1
@@ -102,7 +102,7 @@ static char *cfg_file_p1;
102/** 102/**
103 * Context of peer 2 103 * Context of peer 2
104 */ 104 */
105static struct PeerContext *p2; 105static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
106 106
107/** 107/**
108 * Configuration file of peer 1 108 * Configuration file of peer 1
@@ -122,7 +122,7 @@ static struct GNUNET_TRANSPORT_TransmitHandle *th;
122/** 122/**
123 * Transport testing handle 123 * Transport testing handle
124 */ 124 */
125static struct GNUNET_TRANSPORT_TESTING_handle *tth; 125static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
126 126
127/* 127/*
128 * Total amount of bytes sent 128 * Total amount of bytes sent
@@ -215,11 +215,11 @@ end ()
215 } 215 }
216 if (cc != NULL) 216 if (cc != NULL)
217 { 217 {
218 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 218 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
219 cc = NULL; 219 cc = NULL;
220 } 220 }
221 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 221 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
222 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 222 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
223 GNUNET_TRANSPORT_TESTING_done (tth); 223 GNUNET_TRANSPORT_TESTING_done (tth);
224 ok = 0; 224 ok = 0;
225 for (i = 0; i < TOTAL_MSGS; i++) 225 for (i = 0; i < TOTAL_MSGS; i++)
@@ -274,13 +274,13 @@ end_badly ()
274 } 274 }
275 if (cc != NULL) 275 if (cc != NULL)
276 { 276 {
277 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 277 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
278 cc = NULL; 278 cc = NULL;
279 } 279 }
280 if (p1 != NULL) 280 if (p1 != NULL)
281 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 281 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
282 if (p2 != NULL) 282 if (p2 != NULL)
283 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 283 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
284 GNUNET_TRANSPORT_TESTING_done (tth); 284 GNUNET_TRANSPORT_TESTING_done (tth);
285 ok = GNUNET_SYSERR; 285 ok = GNUNET_SYSERR;
286} 286}
@@ -542,9 +542,7 @@ sendtask (void *cls)
542 542
543 543
544static void 544static void
545testing_connect_cb (struct PeerContext *p1, 545testing_connect_cb (void *cls)
546 struct PeerContext *p2,
547 void *cls)
548{ 546{
549 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); 547 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
550 548
@@ -562,7 +560,7 @@ testing_connect_cb (struct PeerContext *p1,
562 560
563 561
564static void 562static void
565start_cb (struct PeerContext *p, void *cls) 563start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
566{ 564{
567 static int started; 565 static int started;
568 started++; 566 started++;
@@ -576,7 +574,7 @@ start_cb (struct PeerContext *p, void *cls)
576 return; 574 return;
577 575
578 test_connected = GNUNET_NO; 576 test_connected = GNUNET_NO;
579 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, 577 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb,
580 NULL); 578 NULL);
581 579
582} 580}
@@ -627,21 +625,18 @@ main (int argc, char *argv[])
627 GNUNET_GETOPT_OPTION_END 625 GNUNET_GETOPT_OPTION_END
628 }; 626 };
629 627
630 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], 628 test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
631 &test_name);
632 GNUNET_log_setup (test_name, 629 GNUNET_log_setup (test_name,
633 "WARNING", 630 "WARNING",
634 NULL); 631 NULL);
635 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, 632 test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
636 &test_source); 633 test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
637 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], 634 test_source);
638 test_source,
639 &test_plugin);
640 635
641 tth = GNUNET_TRANSPORT_TESTING_init (); 636 tth = GNUNET_TRANSPORT_TESTING_init ();
642 637
643 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); 638 cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
644 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2); 639 cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
645 640
646#if WRITECONFIG 641#if WRITECONFIG
647 setTransportOptions ("test_transport_api_data.conf"); 642 setTransportOptions ("test_transport_api_data.conf");
diff --git a/src/transport/test_transport_api_restart_1peer.c b/src/transport/test_transport_api_restart_1peer.c
index 50f9ebb9c..e814ad817 100644
--- a/src/transport/test_transport_api_restart_1peer.c
+++ b/src/transport/test_transport_api_restart_1peer.c
@@ -51,11 +51,11 @@ static struct GNUNET_SCHEDULER_Task *send_task;
51 51
52static struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh; 52static struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh;
53 53
54static struct PeerContext *p1; 54static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
55 55
56static int p1_connected; 56static int p1_connected;
57 57
58static struct PeerContext *p2; 58static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
59 59
60static int p2_connected; 60static int p2_connected;
61 61
@@ -63,7 +63,7 @@ static struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
63 63
64static struct GNUNET_TRANSPORT_TransmitHandle *th; 64static struct GNUNET_TRANSPORT_TransmitHandle *th;
65 65
66static struct GNUNET_TRANSPORT_TESTING_handle *tth; 66static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
67 67
68static char *cfg_file_p1; 68static char *cfg_file_p1;
69 69
@@ -100,12 +100,12 @@ end ()
100 } 100 }
101 if (NULL != p1) 101 if (NULL != p1)
102 { 102 {
103 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 103 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
104 p1 = NULL; 104 p1 = NULL;
105 } 105 }
106 if (NULL != p2) 106 if (NULL != p2)
107 { 107 {
108 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 108 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
109 p2 = NULL; 109 p2 = NULL;
110 } 110 }
111} 111}
@@ -130,7 +130,7 @@ end_badly (void *cls)
130 { 130 {
131 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 131 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
132 _("Fail! Could not connect peers\n")); 132 _("Fail! Could not connect peers\n"));
133 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 133 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
134 cc = NULL; 134 cc = NULL;
135 } 135 }
136 end (); 136 end ();
@@ -139,7 +139,7 @@ end_badly (void *cls)
139 139
140 140
141static void 141static void
142restart_cb (struct PeerContext *p, void *cls) 142restart_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
143{ 143{
144 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 144 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
145 "Restarted peer %u (`%4s'), issuing reconnect\n", 145 "Restarted peer %u (`%4s'), issuing reconnect\n",
@@ -152,15 +152,13 @@ restart_cb (struct PeerContext *p, void *cls)
152 152
153 153
154static void 154static void
155restart (struct PeerContext *p, 155restart (struct GNUNET_TRANSPORT_TESTING_PeerContext *p)
156 const char *cfg_file)
157{ 156{
158 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 157 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
159 "Restarting peer %u (`%4s')\n", 158 "Restarting peer %u (`%4s')\n",
160 p->no, 159 p->no,
161 GNUNET_i2s (&p->id)); 160 GNUNET_i2s (&p->id));
162 GNUNET_TRANSPORT_TESTING_restart_peer (p, 161 GNUNET_TRANSPORT_TESTING_restart_peer (p,
163 cfg_file,
164 &restart_cb, 162 &restart_cb,
165 p); 163 p);
166} 164}
@@ -171,8 +169,8 @@ notify_receive (void *cls,
171 const struct GNUNET_PeerIdentity *peer, 169 const struct GNUNET_PeerIdentity *peer,
172 const struct GNUNET_MessageHeader *message) 170 const struct GNUNET_MessageHeader *message)
173{ 171{
174 struct PeerContext *p = cls; 172 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
175 struct PeerContext *t = NULL; 173 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
176 174
177 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 175 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
178 t = p1; 176 t = p1;
@@ -194,7 +192,7 @@ notify_receive (void *cls,
194 if (restarted == GNUNET_NO) 192 if (restarted == GNUNET_NO)
195 { 193 {
196 restarted = GNUNET_YES; 194 restarted = GNUNET_YES;
197 restart (p1, cfg_file_p1); 195 restart (p1);
198 return; 196 return;
199 } 197 }
200 else 198 else
@@ -219,7 +217,7 @@ notify_receive (void *cls,
219static size_t 217static size_t
220notify_ready (void *cls, size_t size, void *buf) 218notify_ready (void *cls, size_t size, void *buf)
221{ 219{
222 struct PeerContext *p = cls; 220 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
223 struct GNUNET_MessageHeader *hdr; 221 struct GNUNET_MessageHeader *hdr;
224 222
225 th = NULL; 223 th = NULL;
@@ -284,8 +282,8 @@ notify_connect (void *cls,
284 static int c; 282 static int c;
285 283
286 c++; 284 c++;
287 struct PeerContext *p = cls; 285 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
288 struct PeerContext *t = NULL; 286 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
289 287
290 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 288 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
291 { 289 {
@@ -306,7 +304,9 @@ notify_connect (void *cls,
306 t->no, GNUNET_i2s (peer)); 304 t->no, GNUNET_i2s (peer));
307 GNUNET_free (ps); 305 GNUNET_free (ps);
308 306
309 if ((restarted == GNUNET_YES) && ((p1_connected == GNUNET_YES) && (p2_connected == GNUNET_YES))) 307 if ( (restarted == GNUNET_YES) &&
308 (p1_connected == GNUNET_YES) &&
309 (p2_connected == GNUNET_YES) )
310 { 310 {
311 /* Peer was restarted and we received 3 connect messages (2 from first connect, 1 from reconnect) */ 311 /* Peer was restarted and we received 3 connect messages (2 from first connect, 1 from reconnect) */
312 send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); 312 send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL);
@@ -317,7 +317,7 @@ notify_connect (void *cls,
317static void 317static void
318notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 318notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
319{ 319{
320 struct PeerContext *p = cls; 320 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
321 321
322 if ( (NULL != p1) && 322 if ( (NULL != p1) &&
323 (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))) 323 (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))))
@@ -344,13 +344,15 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
344 send_task = NULL; 344 send_task = NULL;
345} 345}
346 346
347
347static void 348static void
348testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) 349testing_connect_cb (void *cls)
349{ 350{
350 cc = NULL; 351 cc = NULL;
351 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); 352 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
352 353
353 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", 354 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
355 "Peers connected: %u (%s) <-> %u (%s)\n",
354 p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id)); 356 p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id));
355 GNUNET_free (p1_c); 357 GNUNET_free (p1_c);
356 358
@@ -360,7 +362,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
360 362
361 363
362static void 364static void
363start_cb (struct PeerContext *p, void *cls) 365start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
364{ 366{
365 static int started; 367 static int started;
366 368
@@ -379,7 +381,9 @@ start_cb (struct PeerContext *p, void *cls)
379 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); 381 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
380 GNUNET_free (sender_c); 382 GNUNET_free (sender_c);
381 383
382 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, 384 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
385 p2,
386 &testing_connect_cb,
383 NULL); 387 NULL);
384 388
385} 389}
@@ -391,22 +395,32 @@ run (void *cls, char *const *args, const char *cfgfile,
391 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); 395 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
392 p1_connected = GNUNET_NO; 396 p1_connected = GNUNET_NO;
393 p2_connected = GNUNET_NO; 397 p2_connected = GNUNET_NO;
394 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, 398 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
395 &notify_receive, &notify_connect, 399 cfg_file_p1,
396 &notify_disconnect, &start_cb, 400 1,
401 &notify_receive,
402 &notify_connect,
403 &notify_disconnect,
404 &start_cb,
397 NULL); 405 NULL);
398 406
399 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, 407 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
400 &notify_receive, &notify_connect, 408 cfg_file_p2,
401 &notify_disconnect, &start_cb, 409 2,
410 &notify_receive,
411 &notify_connect,
412 &notify_disconnect,
413 &start_cb,
402 NULL); 414 NULL);
403 415
404 if ((p1 == NULL) || (p2 == NULL)) 416 if ((p1 == NULL) || (p2 == NULL))
405 { 417 {
406 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n"); 418 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
419 "Fail! Could not start peers!\n");
407 if (die_task != NULL) 420 if (die_task != NULL)
408 GNUNET_SCHEDULER_cancel (die_task); 421 GNUNET_SCHEDULER_cancel (die_task);
409 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); 422 die_task = GNUNET_SCHEDULER_add_now (&end_badly,
423 NULL);
410 return; 424 return;
411 } 425 }
412} 426}
@@ -438,7 +452,7 @@ main (int argc, char *argv[])
438{ 452{
439 int ret; 453 int ret;
440 454
441 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 455 test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
442 GNUNET_log_setup (test_name, 456 GNUNET_log_setup (test_name,
443 "WARNING", 457 "WARNING",
444 NULL); 458 NULL);
diff --git a/src/transport/test_transport_api_restart_2peers.c b/src/transport/test_transport_api_restart_2peers.c
index 18cc87c78..876b7209c 100644
--- a/src/transport/test_transport_api_restart_2peers.c
+++ b/src/transport/test_transport_api_restart_2peers.c
@@ -50,15 +50,15 @@ static struct GNUNET_SCHEDULER_Task *send_task;
50 50
51static struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh; 51static struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh;
52 52
53static struct PeerContext *p1; 53static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
54 54
55static struct PeerContext *p2; 55static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
56 56
57static struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc; 57static struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
58 58
59static struct GNUNET_TRANSPORT_TransmitHandle *th; 59static struct GNUNET_TRANSPORT_TransmitHandle *th;
60 60
61static struct GNUNET_TRANSPORT_TESTING_handle *tth; 61static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
62 62
63static char *cfg_file_p1; 63static char *cfg_file_p1;
64 64
@@ -93,12 +93,12 @@ end ()
93 } 93 }
94 if (NULL != p1) 94 if (NULL != p1)
95 { 95 {
96 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 96 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
97 p1 = NULL; 97 p1 = NULL;
98 } 98 }
99 if (NULL != p2) 99 if (NULL != p2)
100 { 100 {
101 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 101 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
102 p2 = NULL; 102 p2 = NULL;
103 } 103 }
104} 104}
@@ -120,7 +120,7 @@ end_badly (void *cls)
120 { 120 {
121 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 121 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
122 _("Fail! Could not connect peers\n")); 122 _("Fail! Could not connect peers\n"));
123 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 123 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
124 cc = NULL; 124 cc = NULL;
125 } 125 }
126 end (); 126 end ();
@@ -129,7 +129,7 @@ end_badly (void *cls)
129 129
130 130
131static void 131static void
132restart_cb (struct PeerContext *p, 132restart_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
133 void *cls) 133 void *cls)
134{ 134{
135 static int c; 135 static int c;
@@ -148,8 +148,7 @@ restart_cb (struct PeerContext *p,
148 148
149 149
150static void 150static void
151restart (struct PeerContext *p, 151restart (struct GNUNET_TRANSPORT_TESTING_PeerContext *p)
152 const char *cfg_file)
153{ 152{
154 GNUNET_assert (NULL != p); 153 GNUNET_assert (NULL != p);
155 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 154 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -157,7 +156,6 @@ restart (struct PeerContext *p,
157 p->no, 156 p->no,
158 GNUNET_i2s (&p->id)); 157 GNUNET_i2s (&p->id));
159 GNUNET_TRANSPORT_TESTING_restart_peer (p, 158 GNUNET_TRANSPORT_TESTING_restart_peer (p,
160 cfg_file,
161 &restart_cb, 159 &restart_cb,
162 p); 160 p);
163} 161}
@@ -168,8 +166,8 @@ notify_receive (void *cls,
168 const struct GNUNET_PeerIdentity *peer, 166 const struct GNUNET_PeerIdentity *peer,
169 const struct GNUNET_MessageHeader *message) 167 const struct GNUNET_MessageHeader *message)
170{ 168{
171 struct PeerContext *p = cls; 169 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
172 struct PeerContext *t = NULL; 170 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
173 171
174 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) 172 if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
175 t = p1; 173 t = p1;
@@ -197,8 +195,8 @@ notify_receive (void *cls,
197 if (restarted == GNUNET_NO) 195 if (restarted == GNUNET_NO)
198 { 196 {
199 restarted = GNUNET_YES; 197 restarted = GNUNET_YES;
200 restart (p1, cfg_file_p1); 198 restart (p1);
201 restart (p2, cfg_file_p2); 199 restart (p2);
202 return; 200 return;
203 } 201 }
204 else 202 else
@@ -225,7 +223,7 @@ notify_ready (void *cls,
225 size_t size, 223 size_t size,
226 void *buf) 224 void *buf)
227{ 225{
228 struct PeerContext *p = cls; 226 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
229 struct GNUNET_MessageHeader *hdr; 227 struct GNUNET_MessageHeader *hdr;
230 228
231 th = NULL; 229 th = NULL;
@@ -292,8 +290,8 @@ static void
292notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) 290notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
293{ 291{
294 static int c; 292 static int c;
295 struct PeerContext *p = cls; 293 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
296 struct PeerContext *t = NULL; 294 struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
297 295
298 c++; 296 c++;
299 if (0 == memcmp (peer, 297 if (0 == memcmp (peer,
@@ -330,7 +328,7 @@ static void
330notify_disconnect (void *cls, 328notify_disconnect (void *cls,
331 const struct GNUNET_PeerIdentity *peer) 329 const struct GNUNET_PeerIdentity *peer)
332{ 330{
333 struct PeerContext *p = cls; 331 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
334 332
335 { 333 {
336 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); 334 char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
@@ -357,9 +355,7 @@ notify_disconnect (void *cls,
357 355
358 356
359static void 357static void
360testing_connect_cb (struct PeerContext *p1, 358testing_connect_cb (void *cls)
361 struct PeerContext *p2,
362 void *cls)
363{ 359{
364 cc = NULL; 360 cc = NULL;
365 361
@@ -380,7 +376,7 @@ testing_connect_cb (struct PeerContext *p1,
380 376
381 377
382static void 378static void
383start_cb (struct PeerContext *p, void *cls) 379start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
384{ 380{
385 static int started; 381 static int started;
386 382
@@ -404,8 +400,7 @@ start_cb (struct PeerContext *p, void *cls)
404 GNUNET_free (sender_c); 400 GNUNET_free (sender_c);
405 } 401 }
406 402
407 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, 403 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
408 p1,
409 p2, 404 p2,
410 &testing_connect_cb, 405 &testing_connect_cb,
411 NULL); 406 NULL);
@@ -477,7 +472,7 @@ main (int argc, char *argv[])
477{ 472{
478 int ret; 473 int ret;
479 474
480 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 475 test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
481 GNUNET_log_setup (test_name, 476 GNUNET_log_setup (test_name,
482 "WARNING", 477 "WARNING",
483 NULL); 478 NULL);
diff --git a/src/transport/test_transport_api_timeout.c b/src/transport/test_transport_api_timeout.c
index 7a8dc36f3..fcc0b044e 100644
--- a/src/transport/test_transport_api_timeout.c
+++ b/src/transport/test_transport_api_timeout.c
@@ -52,11 +52,11 @@ static struct GNUNET_SCHEDULER_Task * die_task;
52 52
53static struct GNUNET_SCHEDULER_Task * timer_task; 53static struct GNUNET_SCHEDULER_Task * timer_task;
54 54
55static struct GNUNET_TRANSPORT_TESTING_handle *tth; 55static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
56 56
57static struct PeerContext *p1; 57static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
58 58
59static struct PeerContext *p2; 59static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
60 60
61static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; 61static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
62 62
@@ -95,8 +95,8 @@ end ()
95 die_task = NULL; 95 die_task = NULL;
96 } 96 }
97 97
98 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 98 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
99 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 99 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
100 100
101 if (disconnects == 0) 101 if (disconnects == 0)
102 ok = 0; 102 ok = 0;
@@ -127,11 +127,11 @@ end_badly (void *cls)
127 timer_task = NULL; 127 timer_task = NULL;
128 } 128 }
129 if (cc != NULL) 129 if (cc != NULL)
130 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 130 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
131 if (p1 != NULL) 131 if (p1 != NULL)
132 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 132 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
133 if (p2 != NULL) 133 if (p2 != NULL)
134 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 134 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
135 ok = GNUNET_SYSERR; 135 ok = GNUNET_SYSERR;
136 136
137 GNUNET_TRANSPORT_TESTING_done (tth); 137 GNUNET_TRANSPORT_TESTING_done (tth);
@@ -197,7 +197,7 @@ timer (void *cls)
197 197
198 198
199static void 199static void
200testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) 200testing_connect_cb (void *cls)
201{ 201{
202 cc = NULL; 202 cc = NULL;
203 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); 203 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -223,7 +223,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
223 223
224 224
225static void 225static void
226start_cb (struct PeerContext *p, void *cls) 226start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
227{ 227{
228 static int started; 228 static int started;
229 229
@@ -242,7 +242,9 @@ start_cb (struct PeerContext *p, void *cls)
242 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); 242 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
243 GNUNET_free (sender_c); 243 GNUNET_free (sender_c);
244 244
245 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, 245 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
246 p2,
247 &testing_connect_cb,
246 NULL); 248 NULL);
247 249
248} 250}
@@ -253,13 +255,21 @@ run (void *cls, char *const *args, const char *cfgfile,
253{ 255{
254 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); 256 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
255 257
256 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, 258 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
257 &notify_receive, &notify_connect, 259 cfg_file_p1,
258 &notify_disconnect, &start_cb, 260 1,
261 &notify_receive,
262 &notify_connect,
263 &notify_disconnect,
264 &start_cb,
259 NULL); 265 NULL);
260 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, 266 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
261 &notify_receive, &notify_connect, 267 cfg_file_p2,
262 &notify_disconnect, &start_cb, 268 2,
269 &notify_receive,
270 &notify_connect,
271 &notify_disconnect,
272 &start_cb,
263 NULL); 273 NULL);
264 274
265 if ((p1 == NULL) || (p2 == NULL)) 275 if ((p1 == NULL) || (p2 == NULL))
@@ -299,20 +309,20 @@ main (int argc, char *argv[])
299{ 309{
300 int ret; 310 int ret;
301 311
302 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 312 test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
303 313
304 GNUNET_log_setup (test_name, 314 GNUNET_log_setup (test_name,
305 "WARNING", 315 "WARNING",
306 NULL); 316 NULL);
307 317
308 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); 318 test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
309 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, 319 test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
310 &test_plugin); 320 test_source);
311 321
312 tth = GNUNET_TRANSPORT_TESTING_init (); 322 tth = GNUNET_TRANSPORT_TESTING_init ();
313 323
314 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); 324 cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
315 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2); 325 cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
316 326
317 ret = check (); 327 ret = check ();
318 328
diff --git a/src/transport/test_transport_api_unreliability_constant.c b/src/transport/test_transport_api_unreliability_constant.c
index 26905a4c3..c0fd91816 100644
--- a/src/transport/test_transport_api_unreliability_constant.c
+++ b/src/transport/test_transport_api_unreliability_constant.c
@@ -51,13 +51,13 @@ static int ok;
51 51
52static struct GNUNET_SCHEDULER_Task * die_task; 52static struct GNUNET_SCHEDULER_Task * die_task;
53 53
54struct PeerContext *p1; 54struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
55 55
56struct PeerContext *p2; 56struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
57 57
58struct GNUNET_TRANSPORT_TransmitHandle *th; 58struct GNUNET_TRANSPORT_TransmitHandle *th;
59 59
60struct GNUNET_TRANSPORT_TESTING_handle *tth; 60struct GNUNET_TRANSPORT_TESTING_Handle *tth;
61 61
62char *cfg_file_p1; 62char *cfg_file_p1;
63 63
@@ -386,7 +386,7 @@ sendtask ()
386} 386}
387 387
388static void 388static void
389testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) 389testing_connect_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p1, struct GNUNET_TRANSPORT_TESTING_PeerContext *p2, void *cls)
390{ 390{
391 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); 391 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
392 392
@@ -400,7 +400,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
400} 400}
401 401
402void 402void
403start_cb (struct PeerContext *p, void *cls) 403start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
404{ 404{
405 static int started; 405 static int started;
406 406
diff --git a/src/transport/test_transport_blacklisting.c b/src/transport/test_transport_blacklisting.c
index 6cb598f2f..3696dc71a 100644
--- a/src/transport/test_transport_blacklisting.c
+++ b/src/transport/test_transport_blacklisting.c
@@ -54,13 +54,13 @@
54 54
55char *test_name; 55char *test_name;
56 56
57struct PeerContext *p1; 57struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
58 58
59struct PeerContext *p2; 59struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
60 60
61static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; 61static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
62 62
63struct GNUNET_TRANSPORT_TESTING_handle *tth; 63struct GNUNET_TRANSPORT_TESTING_Handle *tth;
64 64
65/** 65/**
66 * How long until we give up on transmitting the message? 66 * How long until we give up on transmitting the message?
@@ -115,18 +115,18 @@ end (void *cls)
115 115
116 if (cc != NULL ) 116 if (cc != NULL )
117 { 117 {
118 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 118 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
119 cc = NULL; 119 cc = NULL;
120 } 120 }
121 121
122 if (p1 != NULL ) 122 if (p1 != NULL )
123 { 123 {
124 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 124 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
125 p1 = NULL; 125 p1 = NULL;
126 } 126 }
127 if (p2 != NULL ) 127 if (p2 != NULL )
128 { 128 {
129 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 129 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
130 p2 = NULL; 130 p2 = NULL;
131 } 131 }
132} 132}
@@ -151,19 +151,19 @@ end_badly (void *cls)
151 151
152 if (cc != NULL ) 152 if (cc != NULL )
153 { 153 {
154 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 154 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
155 cc = NULL; 155 cc = NULL;
156 } 156 }
157 if (p1 != NULL ) 157 if (p1 != NULL )
158 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 158 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
159 if (p2 != NULL ) 159 if (p2 != NULL )
160 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 160 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
161 161
162 ok = GNUNET_SYSERR; 162 ok = GNUNET_SYSERR;
163} 163}
164 164
165static void 165static void
166testing_connect_cb(struct PeerContext *p1, struct PeerContext *p2, void *cls) 166testing_connect_cb (void *cls)
167{ 167{
168 cc = NULL; 168 cc = NULL;
169 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); 169 char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -189,7 +189,7 @@ static int started;
189 189
190 190
191static void 191static void
192start_cb(struct PeerContext *p, void *cls) 192start_cb(struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
193{ 193{
194 194
195 started++; 195 started++;
@@ -206,13 +206,17 @@ start_cb(struct PeerContext *p, void *cls)
206 sender_c, p2->no, GNUNET_i2s (&p2->id)); 206 sender_c, p2->no, GNUNET_i2s (&p2->id));
207 GNUNET_free(sender_c); 207 GNUNET_free(sender_c);
208 208
209 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, 209 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
210 NULL ); 210 p2,
211 &testing_connect_cb,
212 NULL);
211 213
212} 214}
213 215
214static int check_blacklist_config (char *cfg_file, 216static int
215 struct GNUNET_PeerIdentity *peer, struct GNUNET_PeerIdentity *bl_peer) 217check_blacklist_config (const char *cfg_file,
218 struct GNUNET_PeerIdentity *peer,
219 struct GNUNET_PeerIdentity *bl_peer)
216{ 220{
217 struct GNUNET_CONFIGURATION_Handle *cfg; 221 struct GNUNET_CONFIGURATION_Handle *cfg;
218 char *section; 222 char *section;
@@ -267,32 +271,47 @@ run_stage (void *cls)
267 { 271 {
268 /* Try to connect peers successfully */ 272 /* Try to connect peers successfully */
269 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, 273 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
270 "test_transport_blacklisting_cfg_peer1.conf", 1, NULL, NULL, NULL, 274 "test_transport_blacklisting_cfg_peer1.conf",
271 &start_cb, NULL ); 275 1,
276 NULL,
277 NULL,
278 NULL,
279 &start_cb,
280 NULL);
272 281
273 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, 282 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
274 "test_transport_blacklisting_cfg_peer2.conf", 2, NULL, NULL, NULL, 283 "test_transport_blacklisting_cfg_peer2.conf",
275 &start_cb, NULL ); 284 2,
285 NULL,
286 NULL,
287 NULL,
288 &start_cb,
289 NULL);
276 } 290 }
277 else if (0 291 else if (0 == strcmp (test_name,
278 == strcmp (test_name, "test_transport_blacklisting_outbound_bl_full")) 292 "test_transport_blacklisting_outbound_bl_full"))
279 { 293 {
280 char * cfg_p1 = "test_transport_blacklisting_cfg_blp_peer1_full.conf"; 294 const char *cfg_p1 = "test_transport_blacklisting_cfg_blp_peer1_full.conf";
281 char * cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_full.conf"; 295 const char *cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_full.conf";
282 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
283 cfg_p1 , 1, NULL, NULL, NULL, &start_cb, NULL );
284 296
297 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
298 cfg_p1,
299 1, NULL, NULL, NULL,
300 &start_cb, NULL);
285 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, 301 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
286 cfg_p2, 2, NULL, NULL, NULL, 302 cfg_p2, 2,
287 &start_cb, NULL ); 303 NULL, NULL, NULL,
304 &start_cb, NULL);
288 305
289 /* check if configuration contain correct blacklist entries */ 306 /* check if configuration contain correct blacklist entries */
290 if ((GNUNET_SYSERR == check_blacklist_config (cfg_p1, &p1->id, &p2->id)) || 307 if ( (GNUNET_SYSERR ==
291 (GNUNET_SYSERR == check_blacklist_config (cfg_p2, &p2->id, &p1->id)) ) 308 check_blacklist_config (cfg_p1, &p1->id, &p2->id)) ||
309 (GNUNET_SYSERR ==
310 check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
292 { 311 {
293 GNUNET_TRANSPORT_TESTING_stop_peer(tth, p1); 312 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
294 p1 = NULL; 313 p1 = NULL;
295 GNUNET_TRANSPORT_TESTING_stop_peer(tth, p2); 314 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
296 p2 = NULL; 315 p2 = NULL;
297 ok = 1; 316 ok = 1;
298 GNUNET_SCHEDULER_add_now (&end, NULL ); 317 GNUNET_SCHEDULER_add_now (&end, NULL );
@@ -302,139 +321,162 @@ run_stage (void *cls)
302 else if (0 321 else if (0
303 == strcmp (test_name, "test_transport_blacklisting_outbound_bl_plugin")) 322 == strcmp (test_name, "test_transport_blacklisting_outbound_bl_plugin"))
304 { 323 {
305 char * cfg_p1 = "test_transport_blacklisting_cfg_blp_peer1_plugin.conf"; 324 const char *cfg_p1 = "test_transport_blacklisting_cfg_blp_peer1_plugin.conf";
306 char * cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_plugin.conf"; 325 const char *cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_plugin.conf";
307 326
308 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, 327 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
309 cfg_p1, 1, NULL, 328 cfg_p1,
310 NULL, NULL, &start_cb, NULL ); 329 1,
330 NULL,
331 NULL,
332 NULL,
333 &start_cb,
334 NULL);
311 335
312 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, 336 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
313 cfg_p2, 2, NULL, NULL, NULL, 337 cfg_p2, 2,
314 &start_cb, NULL ); 338 NULL,
339 NULL,
340 NULL,
341 &start_cb,
342 NULL);
315 343
316 /* check if configuration contain correct blacklist entries */ 344 /* check if configuration contain correct blacklist entries */
317 if ((GNUNET_SYSERR == check_blacklist_config (cfg_p1, &p1->id, &p2->id)) || 345 if ( (GNUNET_SYSERR ==
318 (GNUNET_SYSERR == check_blacklist_config (cfg_p2, &p2->id, &p1->id)) ) 346 check_blacklist_config (cfg_p1, &p1->id, &p2->id)) ||
347 (GNUNET_SYSERR ==
348 check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
319 { 349 {
320 GNUNET_TRANSPORT_TESTING_stop_peer(tth, p1); 350 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
321 p1 = NULL; 351 p1 = NULL;
322 GNUNET_TRANSPORT_TESTING_stop_peer(tth, p2); 352 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
323 p2 = NULL; 353 p2 = NULL;
324 ok = 1; 354 ok = 1;
325 GNUNET_SCHEDULER_add_now (&end, NULL ); 355 GNUNET_SCHEDULER_add_now (&end, NULL );
326 } 356 }
327 } 357 }
328 else if (0 358 else if (0 == strcmp (test_name,
329 == strcmp (test_name, "test_transport_blacklisting_inbound_bl_full")) 359 "test_transport_blacklisting_inbound_bl_full"))
330 { 360 {
331 char * cfg_p1 = "test_transport_blacklisting_cfg_peer1.conf"; 361 const char *cfg_p1 = "test_transport_blacklisting_cfg_peer1.conf";
332 char * cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_full.conf"; 362 const char *cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_full.conf";
333 363
334 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, 364 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
335 cfg_p1, 1, NULL, NULL, NULL, 365 cfg_p1, 1,
336 &start_cb, NULL ); 366 NULL, NULL, NULL,
367 &start_cb, NULL);
337 368
338 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, 369 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
339 cfg_p2, 2, NULL, NULL, 370 cfg_p2, 2,
340 NULL, &start_cb, NULL ); 371 NULL, NULL, NULL,
372 &start_cb, NULL);
341 373
342 /* check if configuration contain correct blacklist entries */ 374 /* check if configuration contain correct blacklist entries */
343 if ((GNUNET_SYSERR == check_blacklist_config (cfg_p2, &p2->id, &p1->id)) ) 375 if ( (GNUNET_SYSERR ==
376 check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
344 { 377 {
345 GNUNET_TRANSPORT_TESTING_stop_peer(tth, p1); 378 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
346 p1 = NULL; 379 p1 = NULL;
347 GNUNET_TRANSPORT_TESTING_stop_peer(tth, p2); 380 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
348 p2 = NULL; 381 p2 = NULL;
349 ok = 1; 382 ok = 1;
350 GNUNET_SCHEDULER_add_now (&end, NULL ); 383 GNUNET_SCHEDULER_add_now (&end, NULL );
351 } 384 }
352 } 385 }
353 else if (0 386 else if (0 == strcmp (test_name,
354 == strcmp (test_name, "test_transport_blacklisting_inbound_bl_plugin")) 387 "test_transport_blacklisting_inbound_bl_plugin"))
355 { 388 {
356 char * cfg_p1 = "test_transport_blacklisting_cfg_peer1.conf"; 389 const char *cfg_p1 = "test_transport_blacklisting_cfg_peer1.conf";
357 char * cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_plugin.conf"; 390 const char *cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_plugin.conf";
358 391
359 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, 392 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
360 cfg_p1, 1, NULL, NULL, NULL, 393 cfg_p1, 1,
361 &start_cb, NULL ); 394 NULL, NULL, NULL,
395 &start_cb, NULL);
362 396
363 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, 397 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
364 cfg_p2, 2, NULL, NULL, 398 cfg_p2, 2,
365 NULL, &start_cb, NULL ); 399 NULL, NULL,
400 NULL,
401 &start_cb, NULL);
366 402
367 /* check if configuration contain correct blacklist entries */ 403 /* check if configuration contain correct blacklist entries */
368 if ((GNUNET_SYSERR == check_blacklist_config (cfg_p2, &p2->id, &p1->id)) ) 404 if ( (GNUNET_SYSERR ==
405 check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
369 { 406 {
370 GNUNET_TRANSPORT_TESTING_stop_peer(tth, p1); 407 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
371 p1 = NULL; 408 p1 = NULL;
372 GNUNET_TRANSPORT_TESTING_stop_peer(tth, p2); 409 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
373 p2 = NULL; 410 p2 = NULL;
374 ok = 1; 411 ok = 1;
375 GNUNET_SCHEDULER_add_now (&end, NULL ); 412 GNUNET_SCHEDULER_add_now (&end, NULL );
376 } 413 }
377 414
378 } 415 }
379 else if (0 416 else if (0 == strcmp (test_name,
380 == strcmp (test_name, "test_transport_blacklisting_multiple_plugins")) 417 "test_transport_blacklisting_multiple_plugins"))
381 { 418 {
382 char * cfg_p1 = "test_transport_blacklisting_cfg_blp_peer1_multiple_plugins.conf"; 419 const char * cfg_p1 = "test_transport_blacklisting_cfg_blp_peer1_multiple_plugins.conf";
383 char * cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_multiple_plugins.conf"; 420 const char * cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_multiple_plugins.conf";
384 421
385 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, 422 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
386 cfg_p1, 1, 423 cfg_p1, 1,
387 NULL, NULL, NULL, &start_cb, NULL ); 424 NULL, NULL, NULL,
425 &start_cb, NULL);
388 426
389 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, 427 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
390 cfg_p2, 2, 428 cfg_p2, 2,
391 NULL, NULL, NULL, &start_cb, NULL ); 429 NULL, NULL, NULL,
430 &start_cb, NULL);
392 431
393 /* check if configuration contain correct blacklist entries */ 432 /* check if configuration contain correct blacklist entries */
394 if ((GNUNET_SYSERR == check_blacklist_config (cfg_p1, &p1->id, &p2->id)) || 433 if ( (GNUNET_SYSERR ==
395 (GNUNET_SYSERR == check_blacklist_config (cfg_p2, &p2->id, &p1->id))) 434 check_blacklist_config (cfg_p1, &p1->id, &p2->id)) ||
435 (GNUNET_SYSERR ==
436 check_blacklist_config (cfg_p2, &p2->id, &p1->id)))
396 { 437 {
397 GNUNET_TRANSPORT_TESTING_stop_peer(tth, p1); 438 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
398 p1 = NULL; 439 p1 = NULL;
399 GNUNET_TRANSPORT_TESTING_stop_peer(tth, p2); 440 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
400 p2 = NULL; 441 p2 = NULL;
401 ok = 1; 442 ok = 1;
402 GNUNET_SCHEDULER_add_now (&end, NULL ); 443 GNUNET_SCHEDULER_add_now (&end, NULL);
403 } 444 }
404 } 445 }
405 else 446 else
406 { 447 {
407 GNUNET_break (0); 448 GNUNET_break (0);
408 GNUNET_SCHEDULER_add_now (&end, NULL ); 449 GNUNET_SCHEDULER_add_now (&end, NULL);
409 } 450 }
410 451
411 if ((NULL == p1) || (NULL == p2)) 452 if ((NULL == p1) || (NULL == p2))
412 { 453 {
413 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to start peers\n"); 454 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to start peers\n");
414 ok = 1; 455 ok = 1;
415 GNUNET_SCHEDULER_add_now (&end, NULL ); 456 GNUNET_SCHEDULER_add_now (&end, NULL);
416 } 457 }
417 458
418 timeout_task = GNUNET_SCHEDULER_add_delayed (CONNECT_TIMEOUT, 459 timeout_task = GNUNET_SCHEDULER_add_delayed (CONNECT_TIMEOUT,
419 &connect_timeout, NULL ); 460 &connect_timeout,
461 NULL);
420 stage++; 462 stage++;
421 return; 463 return;
422 } 464 }
423 465
424 if (cc != NULL ) 466 if (cc != NULL )
425 { 467 {
426 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 468 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
427 cc = NULL; 469 cc = NULL;
428 } 470 }
429 471
430 if (p1 != NULL ) 472 if (p1 != NULL )
431 { 473 {
432 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 474 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
433 p1 = NULL; 475 p1 = NULL;
434 } 476 }
435 if (p2 != NULL ) 477 if (p2 != NULL )
436 { 478 {
437 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 479 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
438 p2 = NULL; 480 p2 = NULL;
439 } 481 }
440 482
@@ -480,7 +522,7 @@ main(int argc, char *argv0[])
480{ 522{
481 ok = 1; 523 ok = 1;
482 524
483 GNUNET_TRANSPORT_TESTING_get_test_name (argv0[0], &test_name); 525 test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv0[0]);
484 526
485 GNUNET_log_setup ("test-transport-api-blacklisting", "WARNING", NULL ); 527 GNUNET_log_setup ("test-transport-api-blacklisting", "WARNING", NULL );
486 528
diff --git a/src/transport/test_transport_startonly.c b/src/transport/test_transport_startonly.c
index 7dd4984e2..6f218f2c6 100644
--- a/src/transport/test_transport_startonly.c
+++ b/src/transport/test_transport_startonly.c
@@ -39,9 +39,9 @@
39 39
40struct GNUNET_SCHEDULER_Task * timeout_task; 40struct GNUNET_SCHEDULER_Task * timeout_task;
41 41
42static struct PeerContext *p1; 42static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
43 43
44struct GNUNET_TRANSPORT_TESTING_handle *tth; 44struct GNUNET_TRANSPORT_TESTING_Handle *tth;
45 45
46static int connected = GNUNET_NO; 46static int connected = GNUNET_NO;
47 47
@@ -71,7 +71,7 @@ end_badly (void *cls)
71 "Fail! Stopping peers\n"); 71 "Fail! Stopping peers\n");
72 timeout_task = NULL; 72 timeout_task = NULL;
73 if (p1 != NULL) 73 if (p1 != NULL)
74 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 74 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
75 if (NULL != tth) 75 if (NULL != tth)
76 GNUNET_TRANSPORT_TESTING_done (tth); 76 GNUNET_TRANSPORT_TESTING_done (tth);
77 ret = GNUNET_SYSERR; 77 ret = GNUNET_SYSERR;
@@ -131,7 +131,7 @@ run (void *cls, char *const *args, const char *cfgfile,
131 GNUNET_assert (p1 != NULL); 131 GNUNET_assert (p1 != NULL);
132 GNUNET_assert (p1->th != NULL); 132 GNUNET_assert (p1->th != NULL);
133 133
134 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 134 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
135 135
136 i++; 136 i++;
137 if (i <= ITERATIONS) 137 if (i <= ITERATIONS)
diff --git a/src/transport/test_transport_testing.c b/src/transport/test_transport_testing.c
index e8d829d37..2f11b5a1a 100644
--- a/src/transport/test_transport_testing.c
+++ b/src/transport/test_transport_testing.c
@@ -36,13 +36,13 @@
36 36
37static struct GNUNET_SCHEDULER_Task * timeout_task; 37static struct GNUNET_SCHEDULER_Task * timeout_task;
38 38
39static struct PeerContext *p1; 39static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
40 40
41static struct PeerContext *p2; 41static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
42 42
43static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; 43static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
44 44
45struct GNUNET_TRANSPORT_TESTING_handle *tth; 45struct GNUNET_TRANSPORT_TESTING_Handle *tth;
46 46
47static int connected = GNUNET_NO; 47static int connected = GNUNET_NO;
48 48
@@ -52,14 +52,14 @@ static int ret = 0;
52static void 52static void
53end () 53end ()
54{ 54{
55 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 55 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
56 "Stopping peers\n"); 56 "Stopping peers\n");
57 57
58 if (timeout_task != NULL) 58 if (timeout_task != NULL)
59 GNUNET_SCHEDULER_cancel (timeout_task); 59 GNUNET_SCHEDULER_cancel (timeout_task);
60 60
61 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 61 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
62 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 62 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
63 63
64 GNUNET_TRANSPORT_TESTING_done (tth); 64 GNUNET_TRANSPORT_TESTING_done (tth);
65} 65}
@@ -69,19 +69,19 @@ static void
69end_badly () 69end_badly ()
70{ 70{
71 timeout_task = NULL; 71 timeout_task = NULL;
72 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 72 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
73 "Timeout! Stopping peers\n"); 73 "Timeout! Stopping peers\n");
74 74
75 if (NULL != cc) 75 if (NULL != cc)
76 { 76 {
77 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 77 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
78 cc = NULL; 78 cc = NULL;
79 } 79 }
80 80
81 if (p1 != NULL) 81 if (p1 != NULL)
82 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 82 GNUNET_TRANSPORT_TESTING_stop_peer (p1);
83 if (p2 != NULL) 83 if (p2 != NULL)
84 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 84 GNUNET_TRANSPORT_TESTING_stop_peer (p2);
85 85
86 if (NULL != tth) 86 if (NULL != tth)
87 GNUNET_TRANSPORT_TESTING_done (tth); 87 GNUNET_TRANSPORT_TESTING_done (tth);
@@ -91,9 +91,7 @@ end_badly ()
91 91
92 92
93static void 93static void
94testing_connect_cb (struct PeerContext *p1, 94testing_connect_cb (void *cls)
95 struct PeerContext *p2,
96 void *cls)
97{ 95{
98 char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id)); 96 char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id));
99 97
@@ -109,7 +107,7 @@ static void
109notify_connect (void *cls, 107notify_connect (void *cls,
110 const struct GNUNET_PeerIdentity *peer) 108 const struct GNUNET_PeerIdentity *peer)
111{ 109{
112 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 110 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
113 "Peer `%s' connected \n", 111 "Peer `%s' connected \n",
114 GNUNET_i2s (peer)); 112 GNUNET_i2s (peer));
115 connected++; 113 connected++;
@@ -117,33 +115,33 @@ notify_connect (void *cls,
117 115
118 116
119static void 117static void
120notify_disconnect (void *cls, 118notify_disconnect (void *cls,
121 const struct GNUNET_PeerIdentity *peer) 119 const struct GNUNET_PeerIdentity *peer)
122{ 120{
123 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 121 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
124 "Peer `%s' disconnected \n", 122 "Peer `%s' disconnected \n",
125 GNUNET_i2s (peer)); 123 GNUNET_i2s (peer));
126} 124}
127 125
128 126
129static void 127static void
130notify_receive (void *cls, 128notify_receive (void *cls,
131 const struct GNUNET_PeerIdentity *peer, 129 const struct GNUNET_PeerIdentity *peer,
132 const struct GNUNET_MessageHeader *message) 130 const struct GNUNET_MessageHeader *message)
133{ 131{
134 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 132 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
135 "Receiving\n"); 133 "Receiving\n");
136} 134}
137 135
138 136
139static void 137static void
140start_cb (struct PeerContext *p, void *cls) 138start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
141{ 139{
142 static int started; 140 static int started;
143 141
144 started++; 142 started++;
145 143
146 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 144 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
147 "Peer %u (`%s') started\n", p->no, 145 "Peer %u (`%s') started\n", p->no,
148 GNUNET_i2s (&p->id)); 146 GNUNET_i2s (&p->id));
149 147
@@ -157,7 +155,8 @@ start_cb (struct PeerContext *p, void *cls)
157 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); 155 p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
158 GNUNET_free (sender_c); 156 GNUNET_free (sender_c);
159 157
160 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, 158 cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
159 p2,
161 &testing_connect_cb, 160 &testing_connect_cb,
162 NULL); 161 NULL);
163} 162}
@@ -201,7 +200,7 @@ run (void *cls, char *const *args, const char *cfgfile,
201int 200int
202main (int argc, char *argv[]) 201main (int argc, char *argv[])
203{ 202{
204 char *const argv_1[] = { 203 char *const argv_1[] = {
205 "test_transport_testing", 204 "test_transport_testing",
206 "-c", 205 "-c",
207 "test_transport_api_data.conf", 206 "test_transport_api_data.conf",
@@ -215,7 +214,7 @@ main (int argc, char *argv[])
215 "WARNING", 214 "WARNING",
216 NULL); 215 NULL);
217 GNUNET_PROGRAM_run ((sizeof (argv_1) / sizeof (char *)) - 1, argv_1, 216 GNUNET_PROGRAM_run ((sizeof (argv_1) / sizeof (char *)) - 1, argv_1,
218 "test_transport_testing", "nohelp", options, 217 "test_transport_testing", "nohelp", options,
219 &run, &ret); 218 &run, &ret);
220 219
221 return ret; 220 return ret;
diff --git a/src/transport/test_transport_testing_restart.c b/src/transport/test_transport_testing_restart.c
index dbbefa774..2f36e080a 100644
--- a/src/transport/test_transport_testing_restart.c
+++ b/src/transport/test_transport_testing_restart.c
@@ -34,9 +34,9 @@
34 34
35struct GNUNET_SCHEDULER_Task * timeout_task; 35struct GNUNET_SCHEDULER_Task * timeout_task;
36 36
37static struct PeerContext *p; 37static struct GNUNET_TRANSPORT_TESTING_PeerContext *p;
38 38
39struct GNUNET_TRANSPORT_TESTING_handle *tth; 39struct GNUNET_TRANSPORT_TESTING_Handle *tth;
40 40
41static int ret = 0; 41static int ret = 0;
42 42
@@ -48,7 +48,7 @@ end ()
48 if (timeout_task != NULL) 48 if (timeout_task != NULL)
49 GNUNET_SCHEDULER_cancel (timeout_task); 49 GNUNET_SCHEDULER_cancel (timeout_task);
50 50
51 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); 51 GNUNET_TRANSPORT_TESTING_stop_peer (p);
52 GNUNET_TRANSPORT_TESTING_done (tth); 52 GNUNET_TRANSPORT_TESTING_done (tth);
53} 53}
54 54
@@ -59,7 +59,7 @@ end_badly ()
59 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n"); 59 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n");
60 60
61 if (NULL != p) 61 if (NULL != p)
62 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); 62 GNUNET_TRANSPORT_TESTING_stop_peer (p);
63 63
64 if (NULL != tth) 64 if (NULL != tth)
65 GNUNET_TRANSPORT_TESTING_done (tth); 65 GNUNET_TRANSPORT_TESTING_done (tth);
@@ -68,12 +68,13 @@ end_badly ()
68} 68}
69 69
70static void 70static void
71restart_cb (struct PeerContext *p, void *cls) 71restart_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
72 void *cls)
72{ 73{
73 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') successfully restarted\n", 74 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
75 "Peer %u (`%s') successfully restarted\n",
74 p->no, 76 p->no,
75 GNUNET_i2s (&p->id)); 77 GNUNET_i2s (&p->id));
76
77 ret = 0; 78 ret = 0;
78 GNUNET_SCHEDULER_add_now (&end, NULL); 79 GNUNET_SCHEDULER_add_now (&end, NULL);
79} 80}
@@ -87,14 +88,13 @@ restart_task ()
87 p->no, 88 p->no,
88 GNUNET_i2s (&p->id)); 89 GNUNET_i2s (&p->id));
89 GNUNET_TRANSPORT_TESTING_restart_peer (p, 90 GNUNET_TRANSPORT_TESTING_restart_peer (p,
90 NULL,
91 &restart_cb, 91 &restart_cb,
92 p); 92 p);
93} 93}
94 94
95 95
96static void 96static void
97start_cb (struct PeerContext *p, void *cls) 97start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
98{ 98{
99 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') successfully started\n", 99 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') successfully started\n",
100 p->no, 100 p->no,
@@ -113,9 +113,12 @@ run (void *cls, char *const *args, const char *cfgfile,
113 GNUNET_assert (NULL != tth); 113 GNUNET_assert (NULL != tth);
114 114
115 timeout_task = 115 timeout_task =
116 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &end_badly, NULL); 116 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
117 117 &end_badly,
118 p = GNUNET_TRANSPORT_TESTING_start_peer(tth, cfgfile, 1, 118 NULL);
119 p = GNUNET_TRANSPORT_TESTING_start_peer(tth,
120 cfgfile,
121 1,
119 NULL, /* receive cb */ 122 NULL, /* receive cb */
120 NULL, /* connect cb */ 123 NULL, /* connect cb */
121 NULL, /* disconnect cb */ 124 NULL, /* disconnect cb */
diff --git a/src/transport/test_transport_testing_startstop.c b/src/transport/test_transport_testing_startstop.c
index b30f8b5ec..6263f4d18 100644
--- a/src/transport/test_transport_testing_startstop.c
+++ b/src/transport/test_transport_testing_startstop.c
@@ -34,9 +34,9 @@
34 34
35struct GNUNET_SCHEDULER_Task * timeout_task; 35struct GNUNET_SCHEDULER_Task * timeout_task;
36 36
37static struct PeerContext *p; 37static struct GNUNET_TRANSPORT_TESTING_PeerContext *p;
38 38
39struct GNUNET_TRANSPORT_TESTING_handle *tth; 39struct GNUNET_TRANSPORT_TESTING_Handle *tth;
40 40
41static int ret = 0; 41static int ret = 0;
42 42
@@ -48,7 +48,7 @@ end ()
48 if (timeout_task != NULL) 48 if (timeout_task != NULL)
49 GNUNET_SCHEDULER_cancel (timeout_task); 49 GNUNET_SCHEDULER_cancel (timeout_task);
50 50
51 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); 51 GNUNET_TRANSPORT_TESTING_stop_peer (p);
52 GNUNET_TRANSPORT_TESTING_done (tth); 52 GNUNET_TRANSPORT_TESTING_done (tth);
53} 53}
54 54
@@ -59,7 +59,7 @@ end_badly ()
59 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n"); 59 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n");
60 60
61 if (NULL != p) 61 if (NULL != p)
62 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); 62 GNUNET_TRANSPORT_TESTING_stop_peer (p);
63 63
64 if (NULL != tth) 64 if (NULL != tth)
65 GNUNET_TRANSPORT_TESTING_done (tth); 65 GNUNET_TRANSPORT_TESTING_done (tth);
@@ -69,7 +69,7 @@ end_badly ()
69 69
70 70
71static void 71static void
72start_cb (struct PeerContext *p, void *cls) 72start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
73{ 73{
74 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') successfully started\n", 74 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') successfully started\n",
75 p->no, 75 p->no,
@@ -89,13 +89,17 @@ run (void *cls, char *const *args, const char *cfgfile,
89 GNUNET_assert (NULL != tth); 89 GNUNET_assert (NULL != tth);
90 90
91 timeout_task = 91 timeout_task =
92 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &end_badly, NULL); 92 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
93 &end_badly,
94 NULL);
93 95
94 p = GNUNET_TRANSPORT_TESTING_start_peer(tth, cfgfile, 1, 96 p = GNUNET_TRANSPORT_TESTING_start_peer(tth,
97 cfgfile,
98 1,
95 NULL, /* receive cb */ 99 NULL, /* receive cb */
96 NULL, /* connect cb */ 100 NULL, /* connect cb */
97 NULL, /* disconnect cb */ 101 NULL, /* disconnect cb */
98 start_cb, /* startup cb */ 102 &start_cb, /* startup cb */
99 NULL); /* closure */ 103 NULL); /* closure */
100 if (NULL == p) 104 if (NULL == p)
101 { 105 {
diff --git a/src/transport/transport-testing-filenames.c b/src/transport/transport-testing-filenames.c
new file mode 100644
index 000000000..0f8076b41
--- /dev/null
+++ b/src/transport/transport-testing-filenames.c
@@ -0,0 +1,221 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2006, 2009, 2015, 2016 GNUnet e.V.
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20/**
21 * @file transport-testing-filenames.c
22 * @brief convenience string manipulation functions for tests
23 * @author Matthias Wachs
24 * @author Christian Grothoff
25 */
26#include "transport-testing.h"
27
28
29/**
30 * Removes all directory separators from absolute filename
31 *
32 * @param file the absolute file name, e.g. as found in argv[0]
33 * @return extracted file name, has to be freed by caller
34 */
35static char *
36extract_filename (const char *file)
37{
38 char *pch = GNUNET_strdup (file);
39 char *backup = pch;
40 char *filename = NULL;
41 char *res;
42
43#if WINDOWS
44 if ((strlen (pch) >= 3) && pch[1] == ':')
45 {
46 if (NULL != strstr (pch, "\\"))
47 {
48 pch = strtok (pch, "\\");
49 while (pch != NULL)
50 {
51 pch = strtok (NULL, "\\");
52 if (pch != NULL)
53 filename = pch;
54 }
55 }
56 }
57 if (filename != NULL)
58 pch = filename; /* If we miss the next condition, filename = pch will
59 * not harm us.
60 */
61#endif
62 if (NULL != strstr (pch, "/"))
63 {
64 pch = strtok (pch, "/");
65 while (pch != NULL)
66 {
67 pch = strtok (NULL, "/");
68 if (pch != NULL)
69 {
70 filename = pch;
71 }
72 }
73 }
74 else
75 filename = pch;
76
77 res = GNUNET_strdup (filename);
78 GNUNET_free (backup);
79 return res;
80}
81
82
83/**
84 * Extracts the test filename from an absolute file name and removes
85 * the extension
86 *
87 * @param file absolute file name
88 * @return the result
89 */
90char *
91GNUNET_TRANSPORT_TESTING_get_test_name (const char *file)
92{
93 char *backup = extract_filename (file);
94 char *filename = backup;
95 char *dotexe;
96 char *ret;
97
98 if (NULL == filename)
99 return NULL;
100
101 /* remove "lt-" */
102 filename = strstr (filename, "test");
103 if (NULL == filename)
104 {
105 GNUNET_free (backup);
106 return NULL;
107 }
108
109 /* remove ".exe" */
110 if (NULL != (dotexe = strstr (filename, ".exe")))
111 dotexe[0] = '\0';
112 ret = GNUNET_strdup (filename);
113 GNUNET_free (backup);
114 return ret;
115}
116
117
118/**
119 * Extracts the filename from an absolute file name and removes the extension
120 *
121 * @param file absolute file name
122 * @return the result
123 */
124char *
125GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file)
126{
127 char *src = extract_filename (file);
128 char *split;
129
130 split = strstr (src, ".");
131 if (NULL != split)
132 split[0] = '\0';
133 return src;
134}
135
136
137/**
138 * Extracts the plugin name from an absolute file name and the test name
139 *
140 * @param file absolute file name
141 * @param test test name
142 * @return the result
143 */
144char *
145GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *file,
146 const char *test)
147{
148 char *filename;
149 char *dotexe;
150 char *e = extract_filename (file);
151 char *t = extract_filename (test);
152 char *ret;
153
154 if (NULL == e)
155 goto fail;
156 /* remove "lt-" */
157 filename = strstr (e, "tes");
158 if (NULL == filename)
159 goto fail;
160 /* remove ".exe" */
161 if (NULL != (dotexe = strstr (filename, ".exe")))
162 dotexe[0] = '\0';
163
164 /* find last _ */
165 filename = strstr (filename, t);
166 if (NULL == filename)
167 goto fail;
168 /* copy plugin */
169 filename += strlen (t);
170 if ('\0' != *filename)
171 filename++;
172 ret = GNUNET_strdup (filename);
173 goto suc;
174fail:
175 ret = NULL;
176suc:
177 GNUNET_free (t);
178 GNUNET_free (e);
179 return ret;
180}
181
182
183/**
184 * This function takes the filename (e.g. argv[0), removes a "lt-"-prefix and
185 * if existing ".exe"-prefix and adds the peer-number
186 *
187 * @param file filename of the test, e.g. argv[0]
188 * @param count peer number
189 * @return the result
190 */
191char *
192GNUNET_TRANSPORT_TESTING_get_config_name (const char *file,
193 int count)
194{
195 char *filename = extract_filename (file);
196 char *backup = filename;
197 char *dotexe;
198 char *ret;
199
200 if (NULL == filename)
201 return NULL;
202 /* remove "lt-" */
203 filename = strstr (filename, "test");
204 if (NULL == filename)
205 goto fail;
206 /* remove ".exe" */
207 if (NULL != (dotexe = strstr (filename, ".exe")))
208 dotexe[0] = '\0';
209 GNUNET_asprintf (&ret,
210 "%s_peer%u.conf",
211 filename,
212 count);
213 GNUNET_free (backup);
214 return ret;
215fail:
216 GNUNET_free (backup);
217 return NULL;
218}
219
220
221/* end of transport-testing-filenames.c */
diff --git a/src/transport/transport-testing-main.c b/src/transport/transport-testing-main.c
new file mode 100644
index 000000000..9cda749fe
--- /dev/null
+++ b/src/transport/transport-testing-main.c
@@ -0,0 +1,48 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2016 GNUnet e.V.
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20/**
21 * @file transport-testing-main.c
22 * @brief convenience main function for tests
23 * @author Christian Grothoff
24 */
25#include "transport-testing.h"
26
27
28/**
29 * Setup testcase. Calls @a check with the data the test needs.
30 *
31 * @param argv0 binary name (argv[0])
32 * @param filename source file name (__FILE__)
33 * @param num_peers number of peers to start
34 * @param check main function to run
35 * @param check_cls closure for @a check
36 * @return #GNUNET_OK on success
37 */
38int
39GNUNET_TRANSPORT_TESTING_main_ (const char *argv0,
40 const char *filename,
41 unsigned int num_peers,
42 GNUNET_TRANSPORT_TESTING_CheckCallback check,
43 void *check_cls)
44{
45 return GNUNET_SYSERR;
46}
47
48/* end of transport-testing-main.c */
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c
index 4a3bf3c3e..a2f91d761 100644
--- a/src/transport/transport-testing.c
+++ b/src/transport/transport-testing.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2006, 2009, 2015 GNUnet e.V. 3 Copyright (C) 2006, 2009, 2015, 2016 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -17,12 +17,11 @@
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA. 18 Boston, MA 02110-1301, USA.
19*/ 19*/
20
21/** 20/**
22 * @file transport-testing.c 21 * @file transport-testing.c
23 * @brief testing lib for transport service 22 * @brief testing lib for transport service
24 *
25 * @author Matthias Wachs 23 * @author Matthias Wachs
24 * @author Christian Grothoff
26 */ 25 */
27#include "transport-testing.h" 26#include "transport-testing.h"
28 27
@@ -30,41 +29,38 @@
30#define LOG(kind,...) GNUNET_log_from(kind, "transport-testing", __VA_ARGS__) 29#define LOG(kind,...) GNUNET_log_from(kind, "transport-testing", __VA_ARGS__)
31 30
32 31
33static struct PeerContext * 32static struct GNUNET_TRANSPORT_TESTING_PeerContext *
34find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, 33find_peer_context (struct GNUNET_TRANSPORT_TESTING_Handle *tth,
35 const struct GNUNET_PeerIdentity *peer) 34 const struct GNUNET_PeerIdentity *peer)
36{ 35{
37 struct PeerContext *t = tth->p_head; 36 struct GNUNET_TRANSPORT_TESTING_PeerContext *t;
38 37
39 while (t != NULL) 38 for (t = tth->p_head; NULL != t; t = t->next)
40 { 39 if (0 == memcmp (&t->id,
41 if (0 == memcmp (&t->id, peer, sizeof (struct GNUNET_PeerIdentity))) 40 peer,
42 break; 41 sizeof (struct GNUNET_PeerIdentity)))
43 t = t->next; 42 return t;
44 } 43 return NULL;
45
46 return t;
47} 44}
48 45
49 46
50static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * 47static struct GNUNET_TRANSPORT_TESTING_ConnectRequest *
51find_connecting_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, 48find_connecting_context (struct GNUNET_TRANSPORT_TESTING_Handle *tth,
52 struct PeerContext *p1, 49 struct GNUNET_TRANSPORT_TESTING_PeerContext *p1,
53 struct PeerContext *p2) 50 struct GNUNET_TRANSPORT_TESTING_PeerContext *p2)
54{ 51{
55 GNUNET_assert (tth != NULL); 52 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
56 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = tth->cc_head;
57 53
58 while (cc != NULL) 54 for (cc = tth->cc_head; NULL != cc; cc = cc->next)
59 { 55 {
60 if ((cc->p1 == p1) && (cc->p2 == p2)) 56 if ( (cc->p1 == p1) &&
61 break; 57 (cc->p2 == p2) )
62 if ((cc->p1 == p2) && (cc->p2 == p1)) 58 return cc;
63 break; 59 if ( (cc->p1 == p2) &&
64 cc = cc->next; 60 (cc->p2 == p1) )
61 return cc;
65 } 62 }
66 63 return NULL;
67 return cc;
68} 64}
69 65
70 66
@@ -72,20 +68,26 @@ static void
72notify_connect (void *cls, 68notify_connect (void *cls,
73 const struct GNUNET_PeerIdentity *peer) 69 const struct GNUNET_PeerIdentity *peer)
74{ 70{
75 struct PeerContext *p = cls; 71 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
76 char *p2_s; 72 char *p2_s;
77 struct PeerContext *p2; 73 struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
74 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
78 75
79 GNUNET_assert (NULL != p); 76 p2 = find_peer_context (p->tth,
80 GNUNET_assert (NULL != p->tth); 77 peer);
81 p2 = find_peer_context (p->tth, peer); 78 if (NULL != p->nc)
82 if (p->nc != NULL) 79 p->nc (p->cb_cls,
83 p->nc (p->cb_cls, peer); 80 peer);
84 81
85 if (p2 != NULL) 82 if (p2 != NULL)
86 GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id)); 83 GNUNET_asprintf (&p2_s,
84 "%u (`%s')",
85 p2->no,
86 GNUNET_i2s (&p2->id));
87 else 87 else
88 GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer)); 88 GNUNET_asprintf (&p2_s,
89 "`%s'",
90 GNUNET_i2s (peer));
89 LOG (GNUNET_ERROR_TYPE_DEBUG, 91 LOG (GNUNET_ERROR_TYPE_DEBUG,
90 "Peers %s connected to peer %u (`%s')\n", 92 "Peers %s connected to peer %u (`%s')\n",
91 p2_s, 93 p2_s,
@@ -94,21 +96,21 @@ notify_connect (void *cls,
94 GNUNET_free (p2_s); 96 GNUNET_free (p2_s);
95 97
96 /* Find ConnectingContext */ 98 /* Find ConnectingContext */
97 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = find_connecting_context (p->tth, p, p2); 99 cc = find_connecting_context (p->tth,
98 100 p,
99 if (cc == NULL) 101 p2);
102 if (NULL == cc)
100 return; 103 return;
101
102 if (p == cc->p1) 104 if (p == cc->p1)
103 cc->p1_c = GNUNET_YES; 105 cc->p1_c = GNUNET_YES;
104
105 if (p == cc->p2) 106 if (p == cc->p2)
106 cc->p2_c = GNUNET_YES; 107 cc->p2_c = GNUNET_YES;
107 108
108 if ((cc->p1_c == GNUNET_YES) && (cc->p2_c == GNUNET_YES)) 109 if ( (cc->p1_c == GNUNET_YES) &&
110 (cc->p2_c == GNUNET_YES) )
109 { 111 {
110 cc->cb (cc->p1, cc->p2, cc->cb_cls); 112 cc->cb (cc->cb_cls);
111 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (p->tth, cc); 113 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
112 } 114 }
113} 115}
114 116
@@ -117,25 +119,28 @@ static void
117notify_disconnect (void *cls, 119notify_disconnect (void *cls,
118 const struct GNUNET_PeerIdentity *peer) 120 const struct GNUNET_PeerIdentity *peer)
119{ 121{
120 struct PeerContext *p = cls; 122 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
121 123 char *p2_s;
122 /* Find PeerContext */ 124 /* Find PeerContext */
123 int no = 0; 125 int no = 0;
124 struct PeerContext *p2 = NULL; 126 struct GNUNET_TRANSPORT_TESTING_PeerContext *p2 = NULL;
125 127
126 if (p != NULL) 128 if (NULL != p)
127 { 129 {
128 GNUNET_assert (p->tth != NULL); 130 p2 = find_peer_context (p->tth,
129 p2 = find_peer_context (p->tth, peer); 131 peer);
130 no = p->no; 132 no = p->no;
131 } 133 }
132 134
133 char *p2_s;
134
135 if (p2 != NULL) 135 if (p2 != NULL)
136 GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id)); 136 GNUNET_asprintf (&p2_s,
137 "%u (`%s')",
138 p2->no,
139 GNUNET_i2s (&p2->id));
137 else 140 else
138 GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer)); 141 GNUNET_asprintf (&p2_s,
142 "`%s'",
143 GNUNET_i2s (peer));
139 LOG (GNUNET_ERROR_TYPE_DEBUG, 144 LOG (GNUNET_ERROR_TYPE_DEBUG,
140 "Peers %s disconnected from peer %u (`%s')\n", 145 "Peers %s disconnected from peer %u (`%s')\n",
141 p2_s, 146 p2_s,
@@ -143,10 +148,11 @@ notify_disconnect (void *cls,
143 GNUNET_i2s (&p->id)); 148 GNUNET_i2s (&p->id));
144 GNUNET_free (p2_s); 149 GNUNET_free (p2_s);
145 150
146 if (p == NULL) 151 if (NULL == p)
147 return; 152 return;
148 if (p->nd != NULL) 153 if (NULL != p->nd)
149 p->nd (p->cb_cls, peer); 154 p->nd (p->cb_cls,
155 peer);
150} 156}
151 157
152 158
@@ -155,12 +161,14 @@ notify_receive (void *cls,
155 const struct GNUNET_PeerIdentity *peer, 161 const struct GNUNET_PeerIdentity *peer,
156 const struct GNUNET_MessageHeader *message) 162 const struct GNUNET_MessageHeader *message)
157{ 163{
158 struct PeerContext *p = cls; 164 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
159 165
160 if (p == NULL) 166 if (NULL == p)
161 return; 167 return;
162 if (p->rec != NULL) 168 if (NULL != p->rec)
163 p->rec (p->cb_cls, peer, message); 169 p->rec (p->cb_cls,
170 peer,
171 message);
164} 172}
165 173
166 174
@@ -168,14 +176,15 @@ static void
168get_hello (void *cb_cls, 176get_hello (void *cb_cls,
169 const struct GNUNET_MessageHeader *message) 177 const struct GNUNET_MessageHeader *message)
170{ 178{
171 struct PeerContext *p = cb_cls; 179 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cb_cls;
172 struct GNUNET_PeerIdentity hello_id; 180 struct GNUNET_PeerIdentity hello_id;
173 181
174 GNUNET_assert (message != NULL);
175 GNUNET_assert (GNUNET_OK == 182 GNUNET_assert (GNUNET_OK ==
176 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) 183 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) message,
177 message, &hello_id)); 184 &hello_id));
178 GNUNET_assert (0 == memcmp (&hello_id, &p->id, sizeof (hello_id))); 185 GNUNET_assert (0 == memcmp (&hello_id,
186 &p->id,
187 sizeof (hello_id)));
179 GNUNET_free_non_null (p->hello); 188 GNUNET_free_non_null (p->hello);
180 p->hello = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (message); 189 p->hello = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (message);
181 190
@@ -185,75 +194,14 @@ get_hello (void *cb_cls,
185 "Peer %u (`%s') successfully started\n", 194 "Peer %u (`%s') successfully started\n",
186 p->no, 195 p->no,
187 GNUNET_i2s (&p->id)); 196 GNUNET_i2s (&p->id));
188 p->start_cb (p, p->cb_cls); 197 p->start_cb (p,
198 p->cb_cls);
189 p->start_cb = NULL; 199 p->start_cb = NULL;
190 } 200 }
191} 201}
192 202
193 203
194/** 204/**
195 * Offer the current HELLO of P2 to P1.
196 *
197 * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequest `
198 */
199static void
200offer_hello (void *cls);
201
202
203/**
204 * Function called after the HELLO was passed to the
205 * transport service.
206 */
207static void
208hello_offered (void *cls)
209{
210 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls;
211
212 cc->oh = NULL;
213 cc->tct =
214 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
215 &offer_hello,
216 cc);
217}
218
219
220/**
221 * Offer the current HELLO of P2 to P1.
222 *
223 * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequest`
224 */
225static void
226offer_hello (void *cls)
227{
228 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls;
229 struct PeerContext *p1 = cc->p1;
230 struct PeerContext *p2 = cc->p2;
231
232 cc->tct = NULL;
233 {
234 char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id));
235
236 LOG (GNUNET_ERROR_TYPE_DEBUG,
237 "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %u bytes\n",
238 p1->no,
239 GNUNET_i2s (&p1->id),
240 p2->no,
241 p2_s,
242 GNUNET_HELLO_size (cc->p2->hello));
243 GNUNET_free (p2_s);
244 }
245
246 if (NULL != cc->oh)
247 GNUNET_TRANSPORT_offer_hello_cancel (cc->oh);
248 cc->oh =
249 GNUNET_TRANSPORT_offer_hello (cc->p1->cfg,
250 (const struct GNUNET_MessageHeader *) cc->p2->hello,
251 &hello_offered,
252 cc);
253}
254
255
256/**
257 * Start a peer with the given configuration 205 * Start a peer with the given configuration
258 * @param tth the testing handle 206 * @param tth the testing handle
259 * @param cfgname configuration file 207 * @param cfgname configuration file
@@ -265,23 +213,21 @@ offer_hello (void *cls)
265 * @param cb_cls closure for callback 213 * @param cb_cls closure for callback
266 * @return the peer context 214 * @return the peer context
267 */ 215 */
268struct PeerContext * 216struct GNUNET_TRANSPORT_TESTING_PeerContext *
269GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, 217GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_Handle *tth,
270 const char *cfgname, 218 const char *cfgname,
271 int peer_id, 219 int peer_id,
272 GNUNET_TRANSPORT_ReceiveCallback rec, 220 GNUNET_TRANSPORT_ReceiveCallback rec,
273 GNUNET_TRANSPORT_NotifyConnect nc, 221 GNUNET_TRANSPORT_NotifyConnect nc,
274 GNUNET_TRANSPORT_NotifyDisconnect nd, 222 GNUNET_TRANSPORT_NotifyDisconnect nd,
275 GNUNET_TRANSPORT_TESTING_start_cb start_cb, 223 GNUNET_TRANSPORT_TESTING_StartCallback start_cb,
276 void *cb_cls) 224 void *cb_cls)
277{ 225{
278 char *emsg = NULL; 226 char *emsg = NULL;
227 struct GNUNET_TRANSPORT_TESTING_PeerContext *p;
279 struct GNUNET_PeerIdentity *dummy; 228 struct GNUNET_PeerIdentity *dummy;
280 229
281 GNUNET_assert (NULL != tth); 230 if (GNUNET_NO == GNUNET_DISK_file_test (cfgname))
282 GNUNET_assert (NULL != tth->tl_system);
283
284 if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO)
285 { 231 {
286 LOG (GNUNET_ERROR_TYPE_ERROR, 232 LOG (GNUNET_ERROR_TYPE_ERROR,
287 "File not found: `%s'\n", 233 "File not found: `%s'\n",
@@ -289,18 +235,32 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth
289 return NULL; 235 return NULL;
290 } 236 }
291 237
292 struct PeerContext *p = GNUNET_new (struct PeerContext); 238 p = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_PeerContext);
293 GNUNET_CONTAINER_DLL_insert (tth->p_head, tth->p_tail, p); 239 p->tth = tth;
240 p->nc = nc;
241 p->nd = nd;
242 p->rec = rec;
243 p->start_cb = start_cb;
244 if (cb_cls != NULL)
245 p->cb_cls = cb_cls;
246 else
247 p->cb_cls = p;
248 GNUNET_CONTAINER_DLL_insert (tth->p_head,
249 tth->p_tail,
250 p);
294 251
295 /* Create configuration and call testing lib to modify it */ 252 /* Create configuration and call testing lib to modify it */
296 p->cfg = GNUNET_CONFIGURATION_create (); 253 p->cfg = GNUNET_CONFIGURATION_create ();
297 GNUNET_assert (GNUNET_OK == 254 GNUNET_assert (GNUNET_OK ==
298 GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 255 GNUNET_CONFIGURATION_load (p->cfg, cfgname));
299 if (GNUNET_SYSERR == GNUNET_TESTING_configuration_create (tth->tl_system, p->cfg)) 256 if (GNUNET_SYSERR ==
257 GNUNET_TESTING_configuration_create (tth->tl_system,
258 p->cfg))
300 { 259 {
301 LOG (GNUNET_ERROR_TYPE_ERROR, 260 LOG (GNUNET_ERROR_TYPE_ERROR,
302 "Testing library failed to create unique configuration based on `%s'\n", 261 "Testing library failed to create unique configuration based on `%s'\n",
303 cfgname); 262 cfgname);
263 GNUNET_CONFIGURATION_destroy (p->cfg);
304 GNUNET_free (p); 264 GNUNET_free (p);
305 return NULL; 265 return NULL;
306 } 266 }
@@ -308,14 +268,17 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth
308 p->no = peer_id; 268 p->no = peer_id;
309 /* Configure peer with configuration */ 269 /* Configure peer with configuration */
310 p->peer = GNUNET_TESTING_peer_configure (tth->tl_system, 270 p->peer = GNUNET_TESTING_peer_configure (tth->tl_system,
311 p->cfg, p->no, NULL, &emsg); 271 p->cfg,
272 p->no,
273 NULL,
274 &emsg);
312 if (NULL == p->peer) 275 if (NULL == p->peer)
313 { 276 {
314 LOG (GNUNET_ERROR_TYPE_ERROR, 277 LOG (GNUNET_ERROR_TYPE_ERROR,
315 "Testing library failed to create unique configuration based on `%s': `%s'\n", 278 "Testing library failed to create unique configuration based on `%s': `%s'\n",
316 cfgname, 279 cfgname,
317 emsg); 280 emsg);
318 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); 281 GNUNET_TRANSPORT_TESTING_stop_peer (p);
319 GNUNET_free_non_null (emsg); 282 GNUNET_free_non_null (emsg);
320 return NULL; 283 return NULL;
321 } 284 }
@@ -325,39 +288,33 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth
325 LOG (GNUNET_ERROR_TYPE_ERROR, 288 LOG (GNUNET_ERROR_TYPE_ERROR,
326 "Testing library failed to create unique configuration based on `%s'\n", 289 "Testing library failed to create unique configuration based on `%s'\n",
327 cfgname); 290 cfgname);
328 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); 291 GNUNET_TRANSPORT_TESTING_stop_peer (p);
329 return NULL; 292 return NULL;
330 } 293 }
331 294
332 memset(&dummy, '\0', sizeof (dummy)); 295 memset (&dummy,
333 GNUNET_TESTING_peer_get_identity (p->peer, &p->id); 296 '\0',
334 if (0 == memcmp (&dummy, &p->id, sizeof (struct GNUNET_PeerIdentity))) 297 sizeof (dummy));
298 GNUNET_TESTING_peer_get_identity (p->peer,
299 &p->id);
300 if (0 == memcmp (&dummy,
301 &p->id,
302 sizeof (struct GNUNET_PeerIdentity)))
335 { 303 {
336 LOG (GNUNET_ERROR_TYPE_ERROR, 304 LOG (GNUNET_ERROR_TYPE_ERROR,
337 "Testing library failed to obtain peer identity for peer %u\n", 305 "Testing library failed to obtain peer identity for peer %u\n",
338 p->no); 306 p->no);
339 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); 307 GNUNET_TRANSPORT_TESTING_stop_peer (p);
340 return NULL; 308 return NULL;
341 } 309 }
342 else 310 LOG (GNUNET_ERROR_TYPE_DEBUG,
343 { 311 "Peer %u configured with identity `%s'\n",
344 LOG (GNUNET_ERROR_TYPE_DEBUG, 312 p->no,
345 "Peer %u configured with identity `%s'\n", 313 GNUNET_i2s_full (&p->id));
346 p->no,
347 GNUNET_i2s_full (&p->id));
348 }
349
350 p->tth = tth;
351 p->nc = nc;
352 p->nd = nd;
353 p->rec = rec;
354 p->start_cb = start_cb;
355 if (cb_cls != NULL)
356 p->cb_cls = cb_cls;
357 else
358 p->cb_cls = p;
359 314
360 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, 315 p->th = GNUNET_TRANSPORT_connect (p->cfg,
316 NULL,
317 p,
361 &notify_receive, 318 &notify_receive,
362 &notify_connect, 319 &notify_connect,
363 &notify_disconnect); 320 &notify_disconnect);
@@ -367,7 +324,7 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth
367 "Failed to connect to transport service for peer `%s': `%s'\n", 324 "Failed to connect to transport service for peer `%s': `%s'\n",
368 cfgname, 325 cfgname,
369 emsg); 326 emsg);
370 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); 327 GNUNET_TRANSPORT_TESTING_stop_peer (p);
371 return NULL; 328 return NULL;
372 } 329 }
373 p->ats = GNUNET_ATS_connectivity_init (p->cfg); 330 p->ats = GNUNET_ATS_connectivity_init (p->cfg);
@@ -377,40 +334,30 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth
377 "Failed to connect to ATS service for peer `%s': `%s'\n", 334 "Failed to connect to ATS service for peer `%s': `%s'\n",
378 cfgname, 335 cfgname,
379 emsg); 336 emsg);
380 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); 337 GNUNET_TRANSPORT_TESTING_stop_peer (p);
381 return NULL; 338 return NULL;
382 } 339 }
383 p->ghh = GNUNET_TRANSPORT_get_hello (p->cfg, 340 p->ghh = GNUNET_TRANSPORT_get_hello (p->cfg,
384 &get_hello, 341 &get_hello,
385 p); 342 p);
386 GNUNET_assert (p->ghh != NULL); 343 GNUNET_assert (p->ghh != NULL);
387
388 return p; 344 return p;
389} 345}
390 346
391 347
392/** 348/**
393 * Restart the given peer 349 * Stops and restarts the given peer, sleeping (!) for 5s in between.
394 * 350 *
395 * @param p the peer 351 * @param p the peer
396 * @param cfgname the cfg file used to restart
397 * @param restart_cb callback to call when restarted 352 * @param restart_cb callback to call when restarted
398 * @param cb_cls callback closure 353 * @param cb_cls callback closure
399 * @return #GNUNET_OK in success otherwise #GNUNET_SYSERR 354 * @return #GNUNET_OK in success otherwise #GNUNET_SYSERR
400 */ 355 */
401int 356int
402GNUNET_TRANSPORT_TESTING_restart_peer (struct PeerContext *p, 357GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
403 const char *cfgname, 358 GNUNET_TRANSPORT_TESTING_StartCallback restart_cb,
404 GNUNET_TRANSPORT_TESTING_start_cb restart_cb,
405 void *cb_cls) 359 void *cb_cls)
406{ 360{
407 GNUNET_assert (NULL != p->peer);
408
409 LOG (GNUNET_ERROR_TYPE_DEBUG,
410 "Restarting peer %u (`%s')\n",
411 p->no,
412 GNUNET_i2s (&p->id));
413
414 /* shutdown */ 361 /* shutdown */
415 LOG (GNUNET_ERROR_TYPE_DEBUG, 362 LOG (GNUNET_ERROR_TYPE_DEBUG,
416 "Stopping peer %u (`%s')\n", 363 "Stopping peer %u (`%s')\n",
@@ -431,8 +378,8 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct PeerContext *p,
431 GNUNET_ATS_connectivity_done (p->ats); 378 GNUNET_ATS_connectivity_done (p->ats);
432 p->ats = NULL; 379 p->ats = NULL;
433 } 380 }
434 381 if (GNUNET_SYSERR ==
435 if (GNUNET_SYSERR == GNUNET_TESTING_peer_stop (p->peer)) 382 GNUNET_TESTING_peer_stop (p->peer))
436 { 383 {
437 LOG (GNUNET_ERROR_TYPE_ERROR, 384 LOG (GNUNET_ERROR_TYPE_ERROR,
438 "Failed to stop peer %u (`%s')\n", 385 "Failed to stop peer %u (`%s')\n",
@@ -443,6 +390,10 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct PeerContext *p,
443 390
444 sleep (5); // YUCK! 391 sleep (5); // YUCK!
445 392
393 LOG (GNUNET_ERROR_TYPE_DEBUG,
394 "Restarting peer %u (`%s')\n",
395 p->no,
396 GNUNET_i2s (&p->id));
446 /* restart */ 397 /* restart */
447 if (GNUNET_SYSERR == GNUNET_TESTING_peer_start (p->peer)) 398 if (GNUNET_SYSERR == GNUNET_TESTING_peer_start (p->peer))
448 { 399 {
@@ -476,13 +427,13 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct PeerContext *p,
476/** 427/**
477 * Shutdown the given peer 428 * Shutdown the given peer
478 * 429 *
479 * @param tth testing handle
480 * @param p the peer 430 * @param p the peer
481 */ 431 */
482void 432void
483GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, 433GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext *p)
484 struct PeerContext *p)
485{ 434{
435 struct GNUNET_TRANSPORT_TESTING_Handle *tth = p->tth;
436
486 if (NULL != p->ghh) 437 if (NULL != p->ghh)
487 { 438 {
488 GNUNET_TRANSPORT_get_hello_cancel (p->ghh); 439 GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
@@ -495,10 +446,12 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
495 } 446 }
496 if (NULL != p->peer) 447 if (NULL != p->peer)
497 { 448 {
498 if (GNUNET_OK != GNUNET_TESTING_peer_stop (p->peer)) 449 if (GNUNET_OK !=
450 GNUNET_TESTING_peer_stop (p->peer))
499 { 451 {
500 LOG (GNUNET_ERROR_TYPE_DEBUG, 452 LOG (GNUNET_ERROR_TYPE_DEBUG,
501 "Testing lib failed to stop peer %u (`%s') \n", p->no, 453 "Testing lib failed to stop peer %u (`%s')\n",
454 p->no,
502 GNUNET_i2s (&p->id)); 455 GNUNET_i2s (&p->id));
503 } 456 }
504 GNUNET_TESTING_peer_destroy (p->peer); 457 GNUNET_TESTING_peer_destroy (p->peer);
@@ -523,7 +476,7 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
523 tth->p_tail, 476 tth->p_tail,
524 p); 477 p);
525 LOG (GNUNET_ERROR_TYPE_DEBUG, 478 LOG (GNUNET_ERROR_TYPE_DEBUG,
526 "Peer %u (`%s') stopped \n", 479 "Peer %u (`%s') stopped\n",
527 p->no, 480 p->no,
528 GNUNET_i2s (&p->id)); 481 GNUNET_i2s (&p->id));
529 GNUNET_free (p); 482 GNUNET_free (p);
@@ -531,6 +484,67 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
531 484
532 485
533/** 486/**
487 * Offer the current HELLO of P2 to P1.
488 *
489 * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequest`
490 */
491static void
492offer_hello (void *cls);
493
494
495/**
496 * Function called after the HELLO was passed to the
497 * transport service.
498 */
499static void
500hello_offered (void *cls)
501{
502 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls;
503
504 cc->oh = NULL;
505 cc->tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
506 &offer_hello,
507 cc);
508}
509
510
511/**
512 * Offer the current HELLO of P2 to P1.
513 *
514 * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequest`
515 */
516static void
517offer_hello (void *cls)
518{
519 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls;
520 struct GNUNET_TRANSPORT_TESTING_PeerContext *p1 = cc->p1;
521 struct GNUNET_TRANSPORT_TESTING_PeerContext *p2 = cc->p2;
522
523 cc->tct = NULL;
524 {
525 char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id));
526
527 LOG (GNUNET_ERROR_TYPE_DEBUG,
528 "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %u bytes\n",
529 p1->no,
530 GNUNET_i2s (&p1->id),
531 p2->no,
532 p2_s,
533 GNUNET_HELLO_size (cc->p2->hello));
534 GNUNET_free (p2_s);
535 }
536
537 if (NULL != cc->oh)
538 GNUNET_TRANSPORT_offer_hello_cancel (cc->oh);
539 cc->oh =
540 GNUNET_TRANSPORT_offer_hello (cc->p1->cfg,
541 (const struct GNUNET_MessageHeader *) cc->p2->hello,
542 &hello_offered,
543 cc);
544}
545
546
547/**
534 * Initiate a connection from p1 to p2 by offering p1 p2's HELLO message 548 * Initiate a connection from p1 to p2 by offering p1 p2's HELLO message
535 * 549 *
536 * Remarks: start_peer's notify_connect callback can be called before. 550 * Remarks: start_peer's notify_connect callback can be called before.
@@ -543,12 +557,12 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
543 * @return a connect request handle 557 * @return a connect request handle
544 */ 558 */
545struct GNUNET_TRANSPORT_TESTING_ConnectRequest * 559struct GNUNET_TRANSPORT_TESTING_ConnectRequest *
546GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *tth, 560GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_PeerContext *p1,
547 struct PeerContext *p1, 561 struct GNUNET_TRANSPORT_TESTING_PeerContext *p2,
548 struct PeerContext *p2, 562 GNUNET_SCHEDULER_TaskCallback cb,
549 GNUNET_TRANSPORT_TESTING_connect_cb cb,
550 void *cls) 563 void *cls)
551{ 564{
565 struct GNUNET_TRANSPORT_TESTING_Handle *tth = p1->tth;
552 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc; 566 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
553 567
554 cc = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_ConnectRequest); 568 cc = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_ConnectRequest);
@@ -567,11 +581,9 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *
567 cc->ats_sh = GNUNET_ATS_connectivity_suggest (cc->p1->ats, 581 cc->ats_sh = GNUNET_ATS_connectivity_suggest (cc->p1->ats,
568 &p2->id, 582 &p2->id,
569 1); 583 1);
570
571 LOG (GNUNET_ERROR_TYPE_DEBUG, 584 LOG (GNUNET_ERROR_TYPE_DEBUG,
572 "New connect request %p\n", 585 "New connect request %p\n",
573 cc); 586 cc);
574
575 return cc; 587 return cc;
576} 588}
577 589
@@ -584,12 +596,12 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *
584 * @param cc a connect request handle 596 * @param cc a connect request handle
585 */ 597 */
586void 598void
587GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_handle *tth, 599GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
588 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
589{ 600{
601 struct GNUNET_TRANSPORT_TESTING_Handle *tth = cc->p1->tth;
602
590 LOG (GNUNET_ERROR_TYPE_DEBUG, 603 LOG (GNUNET_ERROR_TYPE_DEBUG,
591 "Canceling connect request %p!\n", 604 "Canceling connect request!\n");
592 cc);
593 if (NULL != cc->tct) 605 if (NULL != cc->tct)
594 { 606 {
595 GNUNET_SCHEDULER_cancel (cc->tct); 607 GNUNET_SCHEDULER_cancel (cc->tct);
@@ -605,7 +617,6 @@ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_h
605 GNUNET_ATS_connectivity_suggest_cancel (cc->ats_sh); 617 GNUNET_ATS_connectivity_suggest_cancel (cc->ats_sh);
606 cc->ats_sh = NULL; 618 cc->ats_sh = NULL;
607 } 619 }
608
609 GNUNET_CONTAINER_DLL_remove (tth->cc_head, 620 GNUNET_CONTAINER_DLL_remove (tth->cc_head,
610 tth->cc_tail, 621 tth->cc_tail,
611 cc); 622 cc);
@@ -615,57 +626,53 @@ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_h
615 626
616/** 627/**
617 * Clean up the transport testing 628 * Clean up the transport testing
629 *
618 * @param tth transport testing handle 630 * @param tth transport testing handle
619 */ 631 */
620void 632void
621GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth) 633GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_Handle *tth)
622{ 634{
623 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = tth->cc_head; 635 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
624 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ct = NULL; 636 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ct;
625 struct PeerContext *p = tth->p_head; 637 struct GNUNET_TRANSPORT_TESTING_PeerContext *p;
626 struct PeerContext *t = NULL; 638 struct GNUNET_TRANSPORT_TESTING_PeerContext *t;
627 639
628 while (cc != tth->cc_tail) 640 cc = tth->cc_head;
641 while (NULL != cc)
629 { 642 {
630 ct = cc->next; 643 ct = cc->next;
631 LOG (GNUNET_ERROR_TYPE_ERROR, 644 LOG (GNUNET_ERROR_TYPE_ERROR,
632 "Developer forgot to cancel connect request %p!\n", 645 "Developer forgot to cancel connect request!\n");
633 cc); 646 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
634 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth,
635 cc);
636 cc = ct; 647 cc = ct;
637 } 648 }
638 649 p = tth->p_head;
639 while (NULL != p) 650 while (NULL != p)
640 { 651 {
641 t = p->next; 652 t = p->next;
642 LOG (GNUNET_ERROR_TYPE_ERROR, 653 LOG (GNUNET_ERROR_TYPE_ERROR,
643 "Developer forgot to stop peer!\n"); 654 "Developer forgot to stop peer!\n");
644 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); 655 GNUNET_TRANSPORT_TESTING_stop_peer (p);
645 p = t; 656 p = t;
646 } 657 }
647
648 GNUNET_TESTING_system_destroy (tth->tl_system, 658 GNUNET_TESTING_system_destroy (tth->tl_system,
649 GNUNET_YES); 659 GNUNET_YES);
650 660
651 GNUNET_free (tth); 661 GNUNET_free (tth);
652 tth = NULL;
653} 662}
654 663
655 664
656/** 665/**
657 * Initialize the transport testing 666 * Initialize the transport testing
667 *
658 * @return transport testing handle 668 * @return transport testing handle
659 */ 669 */
660struct GNUNET_TRANSPORT_TESTING_handle * 670struct GNUNET_TRANSPORT_TESTING_Handle *
661GNUNET_TRANSPORT_TESTING_init () 671GNUNET_TRANSPORT_TESTING_init ()
662{ 672{
663 struct GNUNET_TRANSPORT_TESTING_handle *tth; 673 struct GNUNET_TRANSPORT_TESTING_Handle *tth;
664
665 /* prepare hostkeys */
666 tth = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_handle);
667 674
668 /* Init testing the testing lib */ 675 tth = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_Handle);
669 tth->tl_system = GNUNET_TESTING_system_create ("transport-testing", 676 tth->tl_system = GNUNET_TESTING_system_create ("transport-testing",
670 NULL, 677 NULL,
671 NULL, 678 NULL,
@@ -673,213 +680,11 @@ GNUNET_TRANSPORT_TESTING_init ()
673 if (NULL == tth->tl_system) 680 if (NULL == tth->tl_system)
674 { 681 {
675 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 682 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
676 _("Failed to initialize testing library!\n")); 683 "Failed to initialize testing library!\n");
677 GNUNET_free (tth); 684 GNUNET_free (tth);
678 return NULL; 685 return NULL;
679 } 686 }
680
681 return tth; 687 return tth;
682} 688}
683 689
684
685/*
686 * Some utility functions
687 */
688
689/**
690 * Removes all directory separators from absolute filename
691 *
692 * @param file the absolute file name, e.g. as found in argv[0]
693 * @return extracted file name, has to be freed by caller
694 */
695static char *
696extract_filename (const char *file)
697{
698 char *pch = GNUNET_strdup (file);
699 char *backup = pch;
700 char *filename = NULL;
701 char *res;
702#if WINDOWS
703 if ((strlen (pch) >= 3) && pch[1] == ':')
704 {
705 if (NULL != strstr (pch, "\\"))
706 {
707 pch = strtok (pch, "\\");
708 while (pch != NULL)
709 {
710 pch = strtok (NULL, "\\");
711 if (pch != NULL)
712 filename = pch;
713 }
714 }
715 }
716 if (filename != NULL)
717 pch = filename; /* If we miss the next condition, filename = pch will
718 * not harm us.
719 */
720#endif
721 if (NULL != strstr (pch, "/"))
722 {
723 pch = strtok (pch, "/");
724 while (pch != NULL)
725 {
726 pch = strtok (NULL, "/");
727 if (pch != NULL)
728 {
729 filename = pch;
730 }
731 }
732 }
733 else
734 filename = pch;
735
736 res = GNUNET_strdup (filename);
737 GNUNET_free (backup);
738 return res;
739}
740
741
742/**
743 * Extracts the test filename from an absolute file name and removes
744 * the extension
745 *
746 * @param file absolute file name
747 * @param dest where to store result
748 */
749void
750GNUNET_TRANSPORT_TESTING_get_test_name (const char *file,
751 char **dest)
752{
753 char *filename = extract_filename (file);
754 char *backup = filename;
755 char *dotexe;
756
757 if (filename == NULL)
758 goto fail;
759
760 /* remove "lt-" */
761 filename = strstr (filename, "tes");
762 if (filename == NULL)
763 goto fail;
764
765 /* remove ".exe" */
766 if (NULL != (dotexe = strstr (filename, ".exe")))
767 dotexe[0] = '\0';
768
769 goto suc;
770
771fail:
772 (*dest) = NULL;
773 return;
774
775suc:
776 /* create filename */
777 GNUNET_asprintf (dest, "%s", filename);
778 GNUNET_free (backup);
779}
780
781
782/**
783 * Extracts the filename from an absolute file name and removes the extension
784 *
785 * @param file absolute file name
786 * @param dest where to store result
787 */
788void
789GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file,
790 char **dest)
791{
792 char *src = extract_filename (file);
793 char *split;
794
795 split = strstr (src, ".");
796 if (split != NULL)
797 {
798 split[0] = '\0';
799 }
800 GNUNET_asprintf (dest, "%s", src);
801 GNUNET_free (src);
802}
803
804
805/**
806 * Extracts the plugin name from an absolute file name and the test name
807 *
808 * @param file absolute file name
809 * @param test test name
810 * @param dest where to store result
811 */
812void
813GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *file,
814 const char *test,
815 char **dest)
816{
817 char *filename;
818 char *dotexe;
819 char *e = extract_filename (file);
820 char *t = extract_filename (test);
821
822 if (NULL == e)
823 goto fail;
824 /* remove "lt-" */
825 filename = strstr (e, "tes");
826 if (NULL == filename)
827 goto fail;
828 /* remove ".exe" */
829 if (NULL != (dotexe = strstr (filename, ".exe")))
830 dotexe[0] = '\0';
831
832 /* find last _ */
833 filename = strstr (filename, t);
834 if (NULL == filename)
835 goto fail;
836 /* copy plugin */
837 filename += strlen (t);
838 if ('\0' != *filename)
839 filename++;
840 GNUNET_asprintf (dest, "%s", filename);
841 goto suc;
842fail:
843 (*dest) = NULL;
844suc:
845 GNUNET_free (t);
846 GNUNET_free (e);
847}
848
849
850/**
851 * This function takes the filename (e.g. argv[0), removes a "lt-"-prefix and
852 * if existing ".exe"-prefix and adds the peer-number
853 *
854 * @param file filename of the test, e.g. argv[0]
855 * @param dest where to write the filename
856 * @param count peer number
857 */
858void
859GNUNET_TRANSPORT_TESTING_get_config_name (const char *file,
860 char **dest,
861 int count)
862{
863 char *filename = extract_filename (file);
864 char *backup = filename;
865 char *dotexe;
866
867 if (NULL == filename)
868 goto fail;
869 /* remove "lt-" */
870 filename = strstr (filename, "tes");
871 if (NULL == filename)
872 goto fail;
873 /* remove ".exe" */
874 if (NULL != (dotexe = strstr (filename, ".exe")))
875 dotexe[0] = '\0';
876 GNUNET_asprintf (dest, "%s_peer%u.conf", filename, count);
877 GNUNET_free (backup);
878 return;
879fail:
880 (*dest) = NULL;
881 GNUNET_free (backup);
882}
883
884
885/* end of transport-testing.c */ 690/* end of transport-testing.c */
diff --git a/src/transport/transport-testing.h b/src/transport/transport-testing.h
index b3d6f2a2b..fc017e377 100644
--- a/src/transport/transport-testing.h
+++ b/src/transport/transport-testing.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2006, 2009, 2015 GNUnet e.V. 3 Copyright (C) 2006, 2009, 2015, 2016 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -21,9 +21,11 @@
21/** 21/**
22 * @file transport-testing.h 22 * @file transport-testing.h
23 * @brief testing lib for transport service 23 * @brief testing lib for transport service
24 *
25 * @author Matthias Wachs 24 * @author Matthias Wachs
25 * @author Christian Grothoff
26 */ 26 */
27#ifndef TRANSPORT_TESTING_H
28#define TRANSPORT_TESTING_H
27#include "platform.h" 29#include "platform.h"
28#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
29#include "gnunet_hello_lib.h" 31#include "gnunet_hello_lib.h"
@@ -31,56 +33,45 @@
31#include "gnunet_testing_lib.h" 33#include "gnunet_testing_lib.h"
32 34
33 35
34struct GNUNET_TRANSPORT_TESTING_ConnectRequest;
35
36
37/** 36/**
38 * Context for a single peer 37 * Context for a single peer
39 */ 38 */
40struct PeerContext; 39struct GNUNET_TRANSPORT_TESTING_PeerContext;
41 40
42/** 41/**
43 * Callback when two peers are connected and both have called the connect callback 42 * Definition for a transport testing handle
44 * to notify clients about a new peer
45 */ 43 */
46typedef void 44struct GNUNET_TRANSPORT_TESTING_Handle;
47(*GNUNET_TRANSPORT_TESTING_start_cb) (struct PeerContext *p, 45
48 void *cls);
49 46
50/** 47/**
51 * Callback when two peers are connected and both have called the connect callback 48 * Callback when two peers are connected and both have called the connect callback
52 * to notify clients about a new peer 49 * to notify clients about a new peer
53 */ 50 */
54typedef void 51typedef void
55(*GNUNET_TRANSPORT_TESTING_connect_cb) (struct PeerContext *p1, 52(*GNUNET_TRANSPORT_TESTING_StartCallback) (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
56 struct PeerContext *p2, 53 void *cls);
57 void *cls);
58
59 54
60/**
61 * Definition for a transport testing handle
62 */
63struct GNUNET_TRANSPORT_TESTING_handle;
64 55
65/** 56/**
66 * Context for a single peer 57 * Context for a single peer
67 */ 58 */
68struct PeerContext 59struct GNUNET_TRANSPORT_TESTING_PeerContext
69{ 60{
70 /** 61 /**
71 * Next element in the DLL 62 * Next element in the DLL
72 */ 63 */
73 struct PeerContext *next; 64 struct GNUNET_TRANSPORT_TESTING_PeerContext *next;
74 65
75 /** 66 /**
76 * Previous element in the DLL 67 * Previous element in the DLL
77 */ 68 */
78 struct PeerContext *prev; 69 struct GNUNET_TRANSPORT_TESTING_PeerContext *prev;
79 70
80 /** 71 /**
81 * Transport testing handle this peer belongs to 72 * Transport testing handle this peer belongs to
82 */ 73 */
83 struct GNUNET_TRANSPORT_TESTING_handle *tth; 74 struct GNUNET_TRANSPORT_TESTING_Handle *tth;
84 75
85 /** 76 /**
86 * Peer's configuration 77 * Peer's configuration
@@ -135,7 +126,7 @@ struct PeerContext
135 /** 126 /**
136 * Startup completed callback 127 * Startup completed callback
137 */ 128 */
138 GNUNET_TRANSPORT_TESTING_start_cb start_cb; 129 GNUNET_TRANSPORT_TESTING_StartCallback start_cb;
139 130
140 /** 131 /**
141 * Peers HELLO Message 132 * Peers HELLO Message
@@ -154,23 +145,29 @@ struct PeerContext
154}; 145};
155 146
156 147
148/**
149 * Handle for a request to connect two peers.
150 */
157struct GNUNET_TRANSPORT_TESTING_ConnectRequest 151struct GNUNET_TRANSPORT_TESTING_ConnectRequest
158{ 152{
159 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *next; 153 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *next;
160 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *prev; 154 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *prev;
161 struct PeerContext *p1; 155 struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
162 struct PeerContext *p2; 156 struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
163 struct GNUNET_SCHEDULER_Task *tct; 157 struct GNUNET_SCHEDULER_Task *tct;
164 struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh; 158 struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh;
165 struct GNUNET_TRANSPORT_OfferHelloHandle *oh; 159 struct GNUNET_TRANSPORT_OfferHelloHandle *oh;
166 GNUNET_TRANSPORT_TESTING_connect_cb cb; 160 GNUNET_SCHEDULER_TaskCallback cb;
167 void *cb_cls; 161 void *cb_cls;
168 int p1_c; 162 int p1_c;
169 int p2_c; 163 int p2_c;
170}; 164};
171 165
172 166
173struct GNUNET_TRANSPORT_TESTING_handle 167/**
168 * Handle for a test run.
169 */
170struct GNUNET_TRANSPORT_TESTING_Handle
174{ 171{
175 /** 172 /**
176 * Testing library system handle 173 * Testing library system handle
@@ -190,16 +187,34 @@ struct GNUNET_TRANSPORT_TESTING_handle
190 /** 187 /**
191 * head DLL of peers 188 * head DLL of peers
192 */ 189 */
193 struct PeerContext *p_head; 190 struct GNUNET_TRANSPORT_TESTING_PeerContext *p_head;
194 191
195 /** 192 /**
196 * tail DLL of peers 193 * tail DLL of peers
197 */ 194 */
198 struct PeerContext *p_tail; 195 struct GNUNET_TRANSPORT_TESTING_PeerContext *p_tail;
199}; 196};
200 197
201 198
202/** 199/**
200 * Initialize the transport testing
201 *
202 * @return transport testing handle
203 */
204struct GNUNET_TRANSPORT_TESTING_Handle *
205GNUNET_TRANSPORT_TESTING_init (void);
206
207
208/**
209 * Clean up the transport testing
210 *
211 * @param tth transport testing handle
212 */
213void
214GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_Handle *tth);
215
216
217/**
203 * Start a peer with the given configuration 218 * Start a peer with the given configuration
204 * 219 *
205 * @param tth the testing handle 220 * @param tth the testing handle
@@ -212,50 +227,46 @@ struct GNUNET_TRANSPORT_TESTING_handle
212 * @param cb_cls closure for callback 227 * @param cb_cls closure for callback
213 * @return the peer context 228 * @return the peer context
214 */ 229 */
215struct PeerContext * 230struct GNUNET_TRANSPORT_TESTING_PeerContext *
216GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, 231GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_Handle *tth,
217 const char *cfgname, 232 const char *cfgname,
218 int peer_id, 233 int peer_id,
219 GNUNET_TRANSPORT_ReceiveCallback rec, 234 GNUNET_TRANSPORT_ReceiveCallback rec,
220 GNUNET_TRANSPORT_NotifyConnect nc, 235 GNUNET_TRANSPORT_NotifyConnect nc,
221 GNUNET_TRANSPORT_NotifyDisconnect nd, 236 GNUNET_TRANSPORT_NotifyDisconnect nd,
222 GNUNET_TRANSPORT_TESTING_start_cb start_cb, 237 GNUNET_TRANSPORT_TESTING_StartCallback start_cb,
223 void *cb_cls); 238 void *cb_cls);
224 239
225 240
226/** 241/**
227 * shutdown the given peer 242 * Shutdown the given peer
228 * 243 *
229 * @param tth the testing handle
230 * @param p the peer 244 * @param p the peer
231 */ 245 */
232void 246void
233GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, 247GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext *pc);
234 struct PeerContext *pc);
235 248
236 249
237/** 250/**
238 * Restart the given peer 251 * Stops and restarts the given peer, sleeping (!) for 5s in between.
239 * 252 *
240 * @param p the peer 253 * @param p the peer
241 * @param cfgname the cfg file used to restart
242 * @param restart_cb restart callback 254 * @param restart_cb restart callback
243 * @param cb_cls callback closure 255 * @param cb_cls callback closure
244 * @return #GNUNET_OK in success otherwise #GNUNET_SYSERR 256 * @return #GNUNET_OK in success otherwise #GNUNET_SYSERR
245 */ 257 */
246int 258int
247GNUNET_TRANSPORT_TESTING_restart_peer (struct PeerContext *p, 259GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
248 const char *cfgname, 260 GNUNET_TRANSPORT_TESTING_StartCallback restart_cb,
249 GNUNET_TRANSPORT_TESTING_start_cb restart_cb,
250 void *cb_cls); 261 void *cb_cls);
251 262
252 263
264
253/** 265/**
254 * Connect the given peers and call the callback when both peers report the 266 * Connect the given peers and call the callback when both peers
255 * inbound connection. Remarks: start_peer's notify_connect callback can be called 267 * report the inbound connection. Remarks: start_peer's notify_connect
256 * before. 268 * callback can be called before.
257 * 269 *
258 * @param tth transport testing handle
259 * @param p1 peer 1 270 * @param p1 peer 1
260 * @param p2 peer 2 271 * @param p2 peer 2
261 * @param cb the callback to call when both peers notified that they are connected 272 * @param cb the callback to call when both peers notified that they are connected
@@ -263,48 +274,85 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct PeerContext *p,
263 * @return a connect request handle 274 * @return a connect request handle
264 */ 275 */
265struct GNUNET_TRANSPORT_TESTING_ConnectRequest * 276struct GNUNET_TRANSPORT_TESTING_ConnectRequest *
266GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *tth, 277GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_PeerContext *p1,
267 struct PeerContext *p1, 278 struct GNUNET_TRANSPORT_TESTING_PeerContext *p2,
268 struct PeerContext *p2, 279 GNUNET_SCHEDULER_TaskCallback cb,
269 GNUNET_TRANSPORT_TESTING_connect_cb cb,
270 void *cls); 280 void *cls);
271 281
272 282
273/** 283/**
274 * Cancel the request to connect two peers 284 * Cancel the request to connect two peers. You MUST cancel the
275 * Tou MUST cancel the request if you stop the peers before the peers connected succesfully 285 * request if you stop the peers before the peers connected
276 * @param tth testing 286 * succesfully.
287 *
277 * @param cc a connect request handle 288 * @param cc a connect request handle
278 */ 289 */
279void 290void
280GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_handle *tth, 291GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc);
281 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc); 292
293/* ********************** high-level process functions *************** */
282 294
283 295
284/** 296/**
285 * Clean up the transport testing 297 * Main function of a testcase. Called with the initial setup data
286 * @param tth transport testing handle 298 * for the test as derived from the source name and the binary name.
299 *
300 * @param cls closure
301 * @param tth initialized testing handle
302 * @param test_plugin name of the plugin (if available)
303 * @param num_peers number of entries in the @a cfg_file array
304 * @param cfg_files array of names of configuration files for the peers
287 */ 305 */
288void 306typedef void
289GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth); 307(*GNUNET_TRANSPORT_TESTING_CheckCallback)(void *cls,
308 struct GNUNET_TRANSPORT_TESTING_Handle *tth,
309 const char *test_plugin,
310 unsigned int num_peers,
311 const char *cfg_files[]);
290 312
291 313
292/** 314/**
293 * Initialize the transport testing 315 * Setup testcase. Calls @a check with the data the test needs.
294 * @return transport testing handle 316 *
317 * @param argv0 binary name (argv[0])
318 * @param filename source file name (__FILE__)
319 * @param num_peers number of peers to start
320 * @param check main function to run
321 * @param check_cls closure for @a check
322 * @return #GNUNET_OK on success
295 */ 323 */
296struct GNUNET_TRANSPORT_TESTING_handle * 324int
297GNUNET_TRANSPORT_TESTING_init (void); 325GNUNET_TRANSPORT_TESTING_main_ (const char *argv0,
326 const char *filename,
327 unsigned int num_peers,
328 GNUNET_TRANSPORT_TESTING_CheckCallback check,
329 void *check_cls);
298 330
299 331
300/** 332/**
301 * Extracts the test filename from an absolute file name and removes the extension 333 * Setup testcase. Calls @a check with the data the test needs.
334 *
335 * @param num_peers number of peers to start
336 * @param check main function to run
337 * @param check_cls closure for @a check
338 * @return #GNUNET_OK on success
339 */
340#define GNUNET_TRANSPORT_TESTING_main(num_peers,check,check_cls) \
341 GNUNET_TRANSPORT_TESTING_main_ (argv[0], __FILE__, num_peers, check, check_cls)
342
343
344/* ********************** low-level filename functions *************** */
345
346
347/**
348 * Extracts the test filename from an absolute file name and removes
349 * the extension.
350 *
302 * @param file absolute file name 351 * @param file absolute file name
303 * @param dest where to store result 352 * @return resulting test name
304 */ 353 */
305void 354char *
306GNUNET_TRANSPORT_TESTING_get_test_name (const char *file, 355GNUNET_TRANSPORT_TESTING_get_test_name (const char *file);
307 char **dest);
308 356
309 357
310/** 358/**
@@ -312,12 +360,11 @@ GNUNET_TRANSPORT_TESTING_get_test_name (const char *file,
312 * if existing ".exe"-prefix and adds the peer-number 360 * if existing ".exe"-prefix and adds the peer-number
313 * 361 *
314 * @param file filename of the test, e.g. argv[0] 362 * @param file filename of the test, e.g. argv[0]
315 * @param dest where to write the filename
316 * @param count peer number 363 * @param count peer number
364 * @return configuration name to use
317 */ 365 */
318void 366char *
319GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, 367GNUNET_TRANSPORT_TESTING_get_config_name (const char *file,
320 char **dest,
321 int count); 368 int count);
322 369
323 370
@@ -325,21 +372,22 @@ GNUNET_TRANSPORT_TESTING_get_config_name (const char *file,
325 * Extracts the plugin anme from an absolute file name and the test name 372 * Extracts the plugin anme from an absolute file name and the test name
326 * @param file absolute file name 373 * @param file absolute file name
327 * @param test test name 374 * @param test test name
328 * @param dest where to store result 375 * @return the plugin name
329 */ 376 */
330void 377char *
331GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *executable, 378GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *executable,
332 const char *testname, 379 const char *testname);
333 char **pluginname);
334 380
335 381
336/** 382/**
337 * Extracts the filename from an absolute file name and removes the extenstion 383 * Extracts the filename from an absolute file name and removes the
384 * extenstion
385 *
338 * @param file absolute file name 386 * @param file absolute file name
339 * @param dest where to store result 387 * @return the source name
340 */ 388 */
341void 389char *
342GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file, 390GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file);
343 char **testname);
344 391
392#endif
345/* end of transport_testing.h */ 393/* end of transport_testing.h */