aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_address_switch.c
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/test_transport_address_switch.c
parenta7345f7436c421fd15e18e87ec399ea93b6dde03 (diff)
downloadgnunet-c0b81510ffe194dc662c3a6267d5e66a69873c4b.tar.gz
gnunet-c0b81510ffe194dc662c3a6267d5e66a69873c4b.zip
-start to refactor testcases for sanity
Diffstat (limited to 'src/transport/test_transport_address_switch.c')
-rw-r--r--src/transport/test_transport_address_switch.c43
1 files changed, 21 insertions, 22 deletions
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,