summaryrefslogtreecommitdiff
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)
-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 = \
$(TESTING_LIBS)
libgnunettransporttesting_la_SOURCES = \
- transport-testing.c transport-testing.h
+ transport-testing.c transport-testing.h \
+ transport-testing-filenames.c \
+ transport-testing-main.c
libgnunettransporttesting_la_LIBADD = \
libgnunettransport.la \
$(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;
static struct GNUNET_SCHEDULER_Task * measure_task;
-struct PeerContext *p1;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-struct PeerContext *p2;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
-struct PeerContext *sender;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *sender;
-struct PeerContext *receiver;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver;
struct GNUNET_TRANSPORT_TransmitHandle *th;
@@ -71,7 +71,7 @@ char *gen_cfg_p1;
unsigned long long quota_in_p2;
unsigned long long quota_out_p2;
-struct GNUNET_TRANSPORT_TESTING_handle *tth;
+struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
@@ -161,10 +161,10 @@ end ()
th = NULL;
if (cc != NULL)
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
}
@@ -187,12 +187,12 @@ end_badly ()
th = NULL;
if (cc != NULL)
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
test_failed = GNUNET_YES;
}
@@ -214,7 +214,7 @@ notify_receive (void *cls,
const struct GNUNET_MessageHeader *message)
{
const struct TestMessage *hdr;
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
hdr = (const struct TestMessage *) message;
if (MTYPE != ntohs (message->type))
@@ -319,7 +319,7 @@ static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%4s') connected to us!\n",
@@ -331,7 +331,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%4s') disconnected!\n",
@@ -376,7 +376,7 @@ measure (void *cls)
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -393,8 +393,9 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
}
-void
-start_cb (struct PeerContext *p, void *cls)
+
+static void
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
@@ -416,7 +417,7 @@ start_cb (struct PeerContext *p, void *cls)
"Test tries to send from %u (%s) -> peer %u (%s)\n", sender->no,
sender_c, receiver->no, GNUNET_i2s (&receiver->id));
GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb,
NULL);
}
@@ -492,6 +493,7 @@ run_measurement (unsigned long long p1_quota_in,
}
}
+
static void
run (void *cls, char *const *args, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -538,20 +540,19 @@ check ()
int
main (int argc, char *argv[])
{
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
check ();
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;
static struct GNUNET_SCHEDULER_Task *measure_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
static char *cfg_file_p1;
static struct GNUNET_STATISTICS_Handle *p1_stat;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static char *cfg_file_p2;
static struct GNUNET_STATISTICS_Handle *p2_stat;
-static struct PeerContext *sender;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *sender;
-static struct PeerContext *receiver;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
@@ -312,17 +312,17 @@ clean_up ()
}
if (cc != NULL)
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
if (p1 != NULL)
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
}
if (p2 != NULL)
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
}
}
@@ -435,7 +435,7 @@ notify_receive (void *cls,
if (MTYPE != ntohs (message->type))
return;
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -521,7 +521,7 @@ static void
notify_connect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%4s') connected to us!\n",
@@ -534,7 +534,7 @@ static void
notify_disconnect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
if (NULL != p1)
{
@@ -584,9 +584,7 @@ progress_indicator (void *cls)
static void
-testing_connect_cb (struct PeerContext *p1,
- struct PeerContext *p2,
- void *cls)
+testing_connect_cb (void *cls)
{
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -612,7 +610,7 @@ testing_connect_cb (struct PeerContext *p1,
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
started++;
@@ -638,7 +636,8 @@ start_cb (struct PeerContext *p, void *cls)
GNUNET_free (sender_c);
/* Connect the peers */
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
&testing_connect_cb,
NULL);
}
@@ -729,19 +728,19 @@ main (int argc, char *argv[])
static struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END };
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
GNUNET_log_setup (test_name, "WARNING", NULL );
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Using cfg [%u] : %s \n", 1, cfg_file_p1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Using cfg [%u] : %s \n", 2, cfg_file_p2);
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;
static struct GNUNET_SCHEDULER_Task * send_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
@@ -92,8 +92,8 @@ end ()
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
th = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
}
@@ -111,7 +111,7 @@ end_badly (void *cls)
if (cc != NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
@@ -138,11 +138,11 @@ end_badly (void *cls)
th = NULL;
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n"));
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n"));
@@ -154,8 +154,8 @@ static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
@@ -189,7 +189,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
@@ -249,8 +249,8 @@ notify_connect (void *cls,
static int c;
c++;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
@@ -271,7 +271,7 @@ static void
notify_disconnect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -290,9 +290,7 @@ notify_disconnect (void *cls,
static void
-testing_connect_cb (struct PeerContext *p1,
- struct PeerContext *p2,
- void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -307,7 +305,7 @@ testing_connect_cb (struct PeerContext *p1,
static void
-start_cb (struct PeerContext *p,
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
void *cls)
{
static int started;
@@ -329,8 +327,7 @@ start_cb (struct PeerContext *p,
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
}
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth,
- p1,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
p2,
&testing_connect_cb,
NULL);
@@ -406,25 +403,20 @@ main (int argc, char *argv[])
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0],
- &test_name);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__,
- &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
- test_source,
- &test_plugin);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0],
- &cfg_file_p1,
- 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0],
- &cfg_file_p2,
- 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0],
+ 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0],
+ 2);
ret = check ();
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;
static struct GNUNET_SCHEDULER_Task * send_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc1;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc2;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
@@ -89,8 +89,8 @@ end ()
th = NULL;
}
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
}
@@ -108,13 +108,13 @@ end_badly (void *cls)
if (NULL != cc2)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc2);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc2);
cc2 = NULL;
}
if (NULL != cc1)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc1);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc1);
cc1 = NULL;
}
if (NULL != th)
@@ -123,9 +123,9 @@ end_badly (void *cls)
th = NULL;
}
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
ok = GNUNET_SYSERR;
}
@@ -135,8 +135,8 @@ static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
@@ -168,7 +168,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
@@ -231,8 +231,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
static int c;
c++;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
@@ -257,7 +257,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
{
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
@@ -284,17 +284,17 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
static int connected = GNUNET_NO;
if ((cls == cc1) && (NULL != cc2))
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc2);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc2);
}
if ((cls == cc2) && (NULL != cc1))
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc1);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc1);
}
cc1 = NULL;
cc2 = NULL;
@@ -321,7 +321,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
@@ -342,10 +342,14 @@ start_cb (struct PeerContext *p, void *cls)
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
cc1 =
- GNUNET_TRANSPORT_TESTING_connect_peers (tth, p2, p1, &testing_connect_cb,
+ GNUNET_TRANSPORT_TESTING_connect_peers (p2,
+ p1,
+ &testing_connect_cb,
cc1);
cc2 =
- GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
+ &testing_connect_cb,
cc2);
}
@@ -356,14 +360,21 @@ run (void *cls, char *const *args, const char *cfgfile,
{
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- &notify_receive, &notify_connect,
- &notify_disconnect, &start_cb,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p1, 1,
+ &notify_receive,
+ &notify_connect,
+ &notify_disconnect,
+ &start_cb,
NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- &notify_receive, &notify_connect,
- &notify_disconnect, &start_cb,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p2,
+ 2,
+ &notify_receive,
+ &notify_connect,
+ &notify_disconnect,
+ &start_cb,
NULL);
if ((p1 == NULL) || (p2 == NULL))
@@ -406,20 +417,19 @@ main (int argc, char *argv[])
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
-
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
ret = check ();
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 @@
#include "gnunet_transport_service.h"
#include "transport-testing.h"
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
/**
* How long until we give up on transmitting the message?
@@ -91,7 +91,7 @@ end (void *cls)
if (cc != NULL)
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel(cc);
cc = NULL;
}
@@ -113,12 +113,12 @@ end (void *cls)
if (p1 != NULL)
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
}
if (p2 != NULL)
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
}
@@ -155,7 +155,7 @@ end_badly (void *cls)
if (cc != NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
@@ -170,9 +170,9 @@ end_badly (void *cls)
GNUNET_TRANSPORT_blacklist_cancel (blacklist_p2);
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
ok = GNUNET_SYSERR;
}
@@ -182,8 +182,8 @@ static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
@@ -217,7 +217,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
@@ -283,8 +283,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
static int c;
c++;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
connected = GNUNET_YES;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
@@ -310,7 +310,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -326,7 +326,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -347,7 +347,7 @@ blacklist_cb (void *cls,
const struct
GNUNET_PeerIdentity * pid)
{
- struct PeerContext * p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext * p = cls;
int res = GNUNET_SYSERR;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -376,7 +376,7 @@ blacklist_cb (void *cls,
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
@@ -395,7 +395,9 @@ start_cb (struct PeerContext *p, void *cls)
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
+ &testing_connect_cb,
NULL);
}
@@ -405,28 +407,36 @@ static void
run (void *cls, char *const *args, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
+ die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
+ &end_badly,
+ NULL);
connected = GNUNET_NO;
blacklist_request_p1 = GNUNET_NO;
blacklist_request_p2 = GNUNET_NO;
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, "test_transport_api_tcp_peer1.conf", 1,
- &notify_receive, &notify_connect,
- &notify_disconnect, &start_cb,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ "test_transport_api_tcp_peer1.conf", 1,
+ &notify_receive,
+ &notify_connect,
+ &notify_disconnect,
+ &start_cb,
NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, "test_transport_api_tcp_peer2.conf", 2,
- &notify_receive, &notify_connect,
- &notify_disconnect, &start_cb,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ "test_transport_api_tcp_peer2.conf", 2,
+ &notify_receive,
+ &notify_connect,
+ &notify_disconnect,
+ &start_cb,
NULL);
blacklist_p1 = GNUNET_TRANSPORT_blacklist (p1->cfg,
- &blacklist_cb,
- p1);
+ &blacklist_cb,
+ p1);
blacklist_p2 = GNUNET_TRANSPORT_blacklist (p2->cfg,
- &blacklist_cb,
- p2);
+ &blacklist_cb,
+ p2);
GNUNET_assert (blacklist_p1 != NULL);
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;
static struct GNUNET_SCHEDULER_Task * send_task;
-struct PeerContext *p1;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-struct PeerContext *p2;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
struct GNUNET_TRANSPORT_TransmitHandle *th;
-struct GNUNET_TRANSPORT_TESTING_handle *tth;
+struct GNUNET_TRANSPORT_TESTING_Handle *tth;
int shutdown_;
@@ -96,11 +96,11 @@ end ()
th = NULL;
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
/* success */
@@ -117,7 +117,7 @@ end_badly (void *cls)
if (cc != NULL)
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
@@ -132,9 +132,9 @@ end_badly (void *cls)
th = NULL;
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
ok = GNUNET_SYSERR;
}
@@ -142,7 +142,7 @@ end_badly (void *cls)
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -165,12 +165,12 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
static void
stop_peer (void *cls)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down peer %u (`%s')\n", p->no,
GNUNET_i2s (&p->id));
shutdown_ = GNUNET_YES;
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
GNUNET_assert (p2 == NULL);
}
@@ -180,8 +180,8 @@ static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
@@ -210,7 +210,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
@@ -268,8 +268,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
static int c;
c++;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
@@ -287,7 +287,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -301,7 +301,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
@@ -317,7 +317,9 @@ start_cb (struct PeerContext *p, void *cls)
"Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
+ &testing_connect_cb,
NULL);
}
@@ -329,19 +331,28 @@ run (void *cls, char *const *args, const char *cfgfile,
{
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- &notify_receive, &notify_connect,
- &notify_disconnect, &start_cb,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p1,
+ 1,
+ &notify_receive,
+ &notify_connect,
+ &notify_disconnect,
+ &start_cb,
NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- &notify_receive, &notify_connect,
- &notify_disconnect, &start_cb,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p2,
+ 2,
+ &notify_receive,
+ &notify_connect,
+ &notify_disconnect,
+ &start_cb,
NULL);
if ((p1 == NULL) || (p2 == NULL))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Fail! Could not start peers!\n");
if (die_task != NULL)
GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
@@ -376,20 +387,18 @@ main (int argc, char *argv[])
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
-
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
-
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
ret = check ();
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;
static struct GNUNET_SCHEDULER_Task * send_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
@@ -95,8 +95,8 @@ end ()
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
th = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
GNUNET_TRANSPORT_TESTING_done (tth);
}
@@ -112,16 +112,16 @@ end_badly (void *cls)
GNUNET_SCHEDULER_cancel (send_task);
if (cc != NULL)
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
if (th != NULL)
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
th = NULL;
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
if (NULL != th)
GNUNET_TRANSPORT_TESTING_done (tth);
@@ -156,7 +156,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
@@ -206,7 +206,7 @@ sendtask (void *cls)
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -221,7 +221,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
}
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
@@ -233,7 +233,9 @@ start_cb (struct PeerContext *p, void *cls)
if (started != 2)
return;
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p2, p1, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p2,
+ p1,
+ &testing_connect_cb,
NULL);
}
@@ -246,13 +248,21 @@ run (void *cls, char *const *args, const char *cfgfile,
tth = GNUNET_TRANSPORT_TESTING_init ();
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- &notify_receive, &notify_connect,
- &notify_disconnect, &start_cb,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p1,
+ 1,
+ &notify_receive,
+ &notify_connect,
+ &notify_disconnect,
+ &start_cb,
NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- &notify_receive, &notify_connect,
- &notify_disconnect, &start_cb,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p2,
+ 2,
+ &notify_receive,
+ &notify_connect,
+ &notify_disconnect,
+ &start_cb,
NULL);
if ((p1 == NULL) || (p2 == NULL))
{
@@ -298,11 +308,10 @@ main (int argc, char *argv[])
int res;
int ret = 0;
- test_plugin = NULL;
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
@@ -328,8 +337,8 @@ main (int argc, char *argv[])
return 0;
}
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
ret = check ();
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;
static struct GNUNET_SCHEDULER_Task * send_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
@@ -103,8 +103,8 @@ end ()
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
th = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
}
@@ -122,7 +122,7 @@ end_badly (void *cls)
if (cc != NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
@@ -149,11 +149,11 @@ end_badly (void *cls)
th = NULL;
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n"));
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n"));
@@ -164,7 +164,7 @@ end_badly (void *cls)
static size_t
notify_request_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
@@ -225,7 +225,7 @@ sendtask_request_task (void *cls)
static size_t
notify_response_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
@@ -296,8 +296,8 @@ static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
struct GNUNET_TIME_Relative duration;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
@@ -369,8 +369,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
static int c;
c++;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
@@ -390,7 +390,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -406,7 +406,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -421,7 +421,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
started++;
@@ -440,7 +440,7 @@ start_cb (struct PeerContext *p, void *cls)
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb,
NULL);
}
@@ -503,18 +503,18 @@ main (int argc, char *argv[])
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
ret = check ();
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;
static struct GNUNET_SCHEDULER_Task * send_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
@@ -100,8 +100,8 @@ end ()
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
th = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
}
@@ -119,7 +119,7 @@ end_badly (void *cls)
if (cc != NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
@@ -146,11 +146,11 @@ end_badly (void *cls)
th = NULL;
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n"));
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n"));
@@ -166,8 +166,8 @@ static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
@@ -249,7 +249,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
@@ -327,8 +327,8 @@ notify_connect (void *cls,
static int c;
c++;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
@@ -354,7 +354,7 @@ static void
notify_disconnect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
{
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
@@ -376,9 +376,7 @@ notify_disconnect (void *cls,
static void
-testing_connect_cb (struct PeerContext *p1,
- struct PeerContext *p2,
- void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
@@ -400,7 +398,7 @@ testing_connect_cb (struct PeerContext *p1,
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
started++;
@@ -426,8 +424,7 @@ start_cb (struct PeerContext *p, void *cls)
GNUNET_free (sender_c);
}
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth,
- p1,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
p2,
&testing_connect_cb,
NULL);
@@ -445,12 +442,14 @@ run (void *cls, char *const *args, const char *cfgfile,
s_connected = GNUNET_NO;
s_sending = GNUNET_NO;
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p1, 1,
&notify_receive, &notify_connect,
&notify_disconnect, &start_cb,
NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p2, 2,
&notify_receive, &notify_connect,
&notify_disconnect, &start_cb,
NULL);
@@ -492,18 +491,18 @@ main (int argc, char *argv[])
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
ret = check ();
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;
static struct GNUNET_SCHEDULER_Task * send_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
@@ -101,8 +101,8 @@ end ()
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
th = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
}
@@ -120,7 +120,7 @@ end_badly (void *cls)
if (cc != NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
@@ -147,11 +147,11 @@ end_badly (void *cls)
th = NULL;
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n"));
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n"));
@@ -167,8 +167,8 @@ static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
@@ -244,7 +244,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
@@ -333,8 +333,8 @@ static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
static int c;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
c++;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
@@ -360,7 +360,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
{
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
@@ -382,7 +382,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
@@ -404,7 +404,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
started++;
@@ -424,7 +424,8 @@ start_cb (struct PeerContext *p, void *cls)
"Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
&testing_connect_cb,
NULL);
@@ -441,12 +442,14 @@ run (void *cls, char *const *args, const char *cfgfile,
s_connected = GNUNET_NO;
s_sending = GNUNET_NO;
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p1, 1,
&notify_receive, &notify_connect,
&notify_disconnect, &start_cb,
NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p2, 2,
&notify_receive, &notify_connect,
&notify_disconnect, &start_cb,
NULL);
@@ -488,18 +491,18 @@ main (int argc, char *argv[])
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
ret = check ();
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;
static struct GNUNET_SCHEDULER_Task * send_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
@@ -107,10 +107,10 @@ end ()
th = NULL;
if (NULL != p1)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
if (NULL != p2)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
if (NULL != pmc_p1)
@@ -143,7 +143,7 @@ end_badly (void *cls)
if (cc != NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
@@ -181,11 +181,11 @@ end_badly (void *cls)
}
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n"));
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n"));
@@ -197,8 +197,8 @@ static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
@@ -219,7 +219,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
@@ -294,8 +294,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
static int c;
c++;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
{
@@ -323,7 +323,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -339,9 +339,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
static void
-testing_connect_cb (struct PeerContext *p1,
- struct PeerContext *p2,
- void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -357,7 +355,7 @@ testing_connect_cb (struct PeerContext *p1,
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
@@ -378,7 +376,9 @@ start_cb (struct PeerContext *p, void *cls)
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
+ &testing_connect_cb,
NULL);
}
@@ -446,9 +446,13 @@ run (void *cls, char *const *args, const char *cfgfile,
s_connected = GNUNET_NO;
s_sending = GNUNET_NO;
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- &notify_receive, &notify_connect,
- &notify_disconnect, &start_cb,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p1,
+ 1,
+ &notify_receive,
+ &notify_connect,
+ &notify_disconnect,
+ &start_cb,
NULL);
pmc_p1 = GNUNET_TRANSPORT_monitor_peers (p1->cfg,
NULL,
@@ -457,9 +461,13 @@ run (void *cls, char *const *args, const char *cfgfile,
NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 started\n");
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- &notify_receive, &notify_connect,
- &notify_disconnect, &start_cb,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p2,
+ 2,
+ &notify_receive,
+ &notify_connect,
+ &notify_disconnect,
+ &start_cb,
NULL);
pmc_p2 = GNUNET_TRANSPORT_monitor_peers (p2->cfg,
NULL,
@@ -507,18 +515,18 @@ main (int argc, char *argv[])
ok = 1;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
ret = check ();
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;
/**
* Context of peer 1
*/
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
/**
* Configuration file of peer 1
@@ -102,7 +102,7 @@ static char *cfg_file_p1;
/**
* Context of peer 2
*/
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
/**
* Configuration file of peer 1
@@ -122,7 +122,7 @@ static struct GNUNET_TRANSPORT_TransmitHandle *th;
/**
* Transport testing handle
*/
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
/*
* Total amount of bytes sent
@@ -215,11 +215,11 @@ end ()
}
if (cc != NULL)
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
GNUNET_TRANSPORT_TESTING_done (tth);
ok = 0;
for (i = 0; i < TOTAL_MSGS; i++)
@@ -274,13 +274,13 @@ end_badly ()
}
if (cc != NULL)
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
GNUNET_TRANSPORT_TESTING_done (tth);
ok = GNUNET_SYSERR;
}
@@ -542,9 +542,7 @@ sendtask (void *cls)
static void
-testing_connect_cb (struct PeerContext *p1,
- struct PeerContext *p2,
- void *cls)
+testing_connect_cb (void *cls)
{
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -562,7 +560,7 @@ testing_connect_cb (struct PeerContext *p1,
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
started++;
@@ -576,7 +574,7 @@ start_cb (struct PeerContext *p, void *cls)
return;
test_connected = GNUNET_NO;
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb,
NULL);
}
@@ -627,21 +625,18 @@ main (int argc, char *argv[])
GNUNET_GETOPT_OPTION_END
};
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0],
- &test_name);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__,
- &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
- test_source,
- &test_plugin);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
#if WRITECONFIG
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;
static struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
static int p1_connected;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static int p2_connected;
@@ -63,7 +63,7 @@ static struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
@@ -100,12 +100,12 @@ end ()
}
if (NULL != p1)
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
}
if (NULL != p2)
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
}
}
@@ -130,7 +130,7 @@ end_badly (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
end ();
@@ -139,7 +139,7 @@ end_badly (void *cls)
static void
-restart_cb (struct PeerContext *p, void *cls)
+restart_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Restarted peer %u (`%4s'), issuing reconnect\n",
@@ -152,15 +152,13 @@ restart_cb (struct PeerContext *p, void *cls)
static void
-restart (struct PeerContext *p,
- const char *cfg_file)
+restart (struct GNUNET_TRANSPORT_TESTING_PeerContext *p)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Restarting peer %u (`%4s')\n",
p->no,
GNUNET_i2s (&p->id));
GNUNET_TRANSPORT_TESTING_restart_peer (p,
- cfg_file,
&restart_cb,
p);
}
@@ -171,8 +169,8 @@ notify_receive (void *cls,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
@@ -194,7 +192,7 @@ notify_receive (void *cls,
if (restarted == GNUNET_NO)
{
restarted = GNUNET_YES;
- restart (p1, cfg_file_p1);
+ restart (p1);
return;
}
else
@@ -219,7 +217,7 @@ notify_receive (void *cls,
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
@@ -284,8 +282,8 @@ notify_connect (void *cls,
static int c;
c++;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
{
@@ -306,7 +304,9 @@ notify_connect (void *cls,
t->no, GNUNET_i2s (peer));
GNUNET_free (ps);
- if ((restarted == GNUNET_YES) && ((p1_connected == GNUNET_YES) && (p2_connected == GNUNET_YES)))
+ if ( (restarted == GNUNET_YES) &&
+ (p1_connected == GNUNET_YES) &&
+ (p2_connected == GNUNET_YES) )
{
/* Peer was restarted and we received 3 connect messages (2 from first connect, 1 from reconnect) */
send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL);
@@ -317,7 +317,7 @@ notify_connect (void *cls,
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
if ( (NULL != p1) &&
(0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))))
@@ -344,13 +344,15 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
send_task = NULL;
}
+
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peers connected: %u (%s) <-> %u (%s)\n",
p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (p1_c);
@@ -360,7 +362,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
@@ -379,7 +381,9 @@ start_cb (struct PeerContext *p, void *cls)
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
+ &testing_connect_cb,
NULL);
}
@@ -391,22 +395,32 @@ run (void *cls, char *const *args, const char *cfgfile,
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
p1_connected = GNUNET_NO;
p2_connected = GNUNET_NO;
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- &notify_receive, &notify_connect,
- &notify_disconnect, &start_cb,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p1,
+ 1,
+ &notify_receive,
+ &notify_connect,
+ &notify_disconnect,
+ &start_cb,
NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- &notify_receive, &notify_connect,
- &notify_disconnect, &start_cb,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p2,
+ 2,
+ &notify_receive,
+ &notify_connect,
+ &notify_disconnect,
+ &start_cb,
NULL);
if ((p1 == NULL) || (p2 == NULL))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Fail! Could not start peers!\n");
if (die_task != NULL)
GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
+ die_task = GNUNET_SCHEDULER_add_now (&end_badly,
+ NULL);
return;
}
}
@@ -438,7 +452,7 @@ main (int argc, char *argv[])
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
GNUNET_log_setup (test_name,
"WARNING",
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;
static struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
static struct GNUNET_TRANSPORT_TransmitHandle *th;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static char *cfg_file_p1;
@@ -93,12 +93,12 @@ end ()
}
if (NULL != p1)
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
}
if (NULL != p2)
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
}
}
@@ -120,7 +120,7 @@ end_badly (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Fail! Could not connect peers\n"));
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
end ();
@@ -129,7 +129,7 @@ end_badly (void *cls)
static void
-restart_cb (struct PeerContext *p,
+restart_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
void *cls)
{
static int c;
@@ -148,8 +148,7 @@ restart_cb (struct PeerContext *p,
static void
-restart (struct PeerContext *p,
- const char *cfg_file)
+restart (struct GNUNET_TRANSPORT_TESTING_PeerContext *p)
{
GNUNET_assert (NULL != p);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -157,7 +156,6 @@ restart (struct PeerContext *p,
p->no,
GNUNET_i2s (&p->id));
GNUNET_TRANSPORT_TESTING_restart_peer (p,
- cfg_file,
&restart_cb,
p);
}
@@ -168,8 +166,8 @@ notify_receive (void *cls,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
@@ -197,8 +195,8 @@ notify_receive (void *cls,
if (restarted == GNUNET_NO)
{
restarted = GNUNET_YES;
- restart (p1, cfg_file_p1);
- restart (p2, cfg_file_p2);
+ restart (p1);
+ restart (p2);
return;
}
else
@@ -225,7 +223,7 @@ notify_ready (void *cls,
size_t size,
void *buf)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
@@ -292,8 +290,8 @@ static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
static int c;
- struct PeerContext *p = cls;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL;
c++;
if (0 == memcmp (peer,
@@ -330,7 +328,7 @@ static void
notify_disconnect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
{
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
@@ -357,9 +355,7 @@ notify_disconnect (void *cls,
static void
-testing_connect_cb (struct PeerContext *p1,
- struct PeerContext *p2,
- void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
@@ -380,7 +376,7 @@ testing_connect_cb (struct PeerContext *p1,
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
@@ -404,8 +400,7 @@ start_cb (struct PeerContext *p, void *cls)
GNUNET_free (sender_c);
}
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth,
- p1,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
p2,
&testing_connect_cb,
NULL);
@@ -477,7 +472,7 @@ main (int argc, char *argv[])
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
GNUNET_log_setup (test_name,
"WARNING",
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;
static struct GNUNET_SCHEDULER_Task * timer_task;
-static struct GNUNET_TRANSPORT_TESTING_handle *tth;
+static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
@@ -95,8 +95,8 @@ end ()
die_task = NULL;
}
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
if (disconnects == 0)
ok = 0;
@@ -127,11 +127,11 @@ end_badly (void *cls)
timer_task = NULL;
}
if (cc != NULL)
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
ok = GNUNET_SYSERR;
GNUNET_TRANSPORT_TESTING_done (tth);
@@ -197,7 +197,7 @@ timer (void *cls)
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -223,7 +223,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
@@ -242,7 +242,9 @@ start_cb (struct PeerContext *p, void *cls)
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
+ &testing_connect_cb,
NULL);
}
@@ -253,13 +255,21 @@ run (void *cls, char *const *args, const char *cfgfile,
{
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
- &notify_receive, &notify_connect,
- &notify_disconnect, &start_cb,
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p1,
+ 1,
+ &notify_receive,
+ &notify_connect,
+ &notify_disconnect,
+ &start_cb,
NULL);
- p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
- &notify_receive, &notify_connect,
- &notify_disconnect, &start_cb,
+ p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_file_p2,
+ 2,
+ &notify_receive,
+ &notify_connect,
+ &notify_disconnect,
+ &start_cb,
NULL);
if ((p1 == NULL) || (p2 == NULL))
@@ -299,20 +309,20 @@ main (int argc, char *argv[])
{
int ret;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]);
GNUNET_log_setup (test_name,
"WARNING",
NULL);
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
+ test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__);
+ test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0],
+ test_source);
tth = GNUNET_TRANSPORT_TESTING_init ();
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
- GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+ cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1);
+ cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2);
ret = check ();
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;
static struct GNUNET_SCHEDULER_Task * die_task;
-struct PeerContext *p1;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-struct PeerContext *p2;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
struct GNUNET_TRANSPORT_TransmitHandle *th;
-struct GNUNET_TRANSPORT_TESTING_handle *tth;
+struct GNUNET_TRANSPORT_TESTING_Handle *tth;
char *cfg_file_p1;
@@ -386,7 +386,7 @@ sendtask ()
}
static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p1, struct GNUNET_TRANSPORT_TESTING_PeerContext *p2, void *cls)
{
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -400,7 +400,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
}
void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
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 @@
char *test_name;
-struct PeerContext *p1;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-struct PeerContext *p2;
+struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
-struct GNUNET_TRANSPORT_TESTING_handle *tth;
+struct GNUNET_TRANSPORT_TESTING_Handle *tth;
/**
* How long until we give up on transmitting the message?
@@ -115,18 +115,18 @@ end (void *cls)
if (cc != NULL )
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
if (p1 != NULL )
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
}
if (p2 != NULL )
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
}
}
@@ -151,19 +151,19 @@ end_badly (void *cls)
if (cc != NULL )
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
if (p1 != NULL )
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (p2 != NULL )
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
ok = GNUNET_SYSERR;
}
static void
-testing_connect_cb(struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (void *cls)
{
cc = NULL;
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -189,7 +189,7 @@ static int started;
static void
-start_cb(struct PeerContext *p, void *cls)
+start_cb(struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
started++;
@@ -206,13 +206,17 @@ start_cb(struct PeerContext *p, void *cls)
sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free(sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
- NULL );
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
+ &testing_connect_cb,
+ NULL);
}
-static int check_blacklist_config (char *cfg_file,
- struct GNUNET_PeerIdentity *peer, struct GNUNET_PeerIdentity *bl_peer)
+static int
+check_blacklist_config (const char *cfg_file,
+ struct GNUNET_PeerIdentity *peer,
+ struct GNUNET_PeerIdentity *bl_peer)
{
struct GNUNET_CONFIGURATION_Handle *cfg;
char *section;
@@ -267,32 +271,47 @@ run_stage (void *cls)
{
/* Try to connect peers successfully */
p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- "test_transport_blacklisting_cfg_peer1.conf", 1, NULL, NULL, NULL,
- &start_cb, NULL );
+ "test_transport_blacklisting_cfg_peer1.conf",
+ 1,
+ NULL,
+ NULL,
+ NULL,
+ &start_cb,
+ NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- "test_transport_blacklisting_cfg_peer2.conf", 2, NULL, NULL, NULL,
- &start_cb, NULL );
+ "test_transport_blacklisting_cfg_peer2.conf",
+ 2,
+ NULL,
+ NULL,
+ NULL,
+ &start_cb,
+ NULL);
}
- else if (0
- == strcmp (test_name, "test_transport_blacklisting_outbound_bl_full"))
+ else if (0 == strcmp (test_name,
+ "test_transport_blacklisting_outbound_bl_full"))
{
- char * cfg_p1 = "test_transport_blacklisting_cfg_blp_peer1_full.conf";
- char * cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_full.conf";
- p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p1 , 1, NULL, NULL, NULL, &start_cb, NULL );
+ const char *cfg_p1 = "test_transport_blacklisting_cfg_blp_peer1_full.conf";
+ const char *cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_full.conf";
+ p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
+ cfg_p1,
+ 1, NULL, NULL, NULL,
+ &start_cb, NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p2, 2, NULL, NULL, NULL,
- &start_cb, NULL );
+ cfg_p2, 2,
+ NULL, NULL, NULL,
+ &start_cb, NULL);
/* check if configuration contain correct blacklist entries */
- if ((GNUNET_SYSERR == check_blacklist_config (cfg_p1, &p1->id, &p2->id)) ||
- (GNUNET_SYSERR == check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
+ if ( (GNUNET_SYSERR ==
+ check_blacklist_config (cfg_p1, &p1->id, &p2->id)) ||
+ (GNUNET_SYSERR ==
+ check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
{
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
ok = 1;
GNUNET_SCHEDULER_add_now (&end, NULL );
@@ -302,139 +321,162 @@ run_stage (void *cls)
else if (0
== strcmp (test_name, "test_transport_blacklisting_outbound_bl_plugin"))
{
- char * cfg_p1 = "test_transport_blacklisting_cfg_blp_peer1_plugin.conf";
- char * cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_plugin.conf";
+ const char *cfg_p1 = "test_transport_blacklisting_cfg_blp_peer1_plugin.conf";
+ const char *cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_plugin.conf";
p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p1, 1, NULL,
- NULL, NULL, &start_cb, NULL );
+ cfg_p1,
+ 1,
+ NULL,
+ NULL,
+ NULL,
+ &start_cb,
+ NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p2, 2, NULL, NULL, NULL,
- &start_cb, NULL );
+ cfg_p2, 2,
+ NULL,
+ NULL,
+ NULL,
+ &start_cb,
+ NULL);
/* check if configuration contain correct blacklist entries */
- if ((GNUNET_SYSERR == check_blacklist_config (cfg_p1, &p1->id, &p2->id)) ||
- (GNUNET_SYSERR == check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
+ if ( (GNUNET_SYSERR ==
+ check_blacklist_config (cfg_p1, &p1->id, &p2->id)) ||
+ (GNUNET_SYSERR ==
+ check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
{
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
ok = 1;
GNUNET_SCHEDULER_add_now (&end, NULL );
}
}
- else if (0
- == strcmp (test_name, "test_transport_blacklisting_inbound_bl_full"))
+ else if (0 == strcmp (test_name,
+ "test_transport_blacklisting_inbound_bl_full"))
{
- char * cfg_p1 = "test_transport_blacklisting_cfg_peer1.conf";
- char * cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_full.conf";
+ const char *cfg_p1 = "test_transport_blacklisting_cfg_peer1.conf";
+ const char *cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_full.conf";
p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p1, 1, NULL, NULL, NULL,
- &start_cb, NULL );
+ cfg_p1, 1,
+ NULL, NULL, NULL,
+ &start_cb, NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p2, 2, NULL, NULL,
- NULL, &start_cb, NULL );
+ cfg_p2, 2,
+ NULL, NULL, NULL,
+ &start_cb, NULL);
/* check if configuration contain correct blacklist entries */
- if ((GNUNET_SYSERR == check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
+ if ( (GNUNET_SYSERR ==
+ check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
{
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
ok = 1;
GNUNET_SCHEDULER_add_now (&end, NULL );
}
}
- else if (0
- == strcmp (test_name, "test_transport_blacklisting_inbound_bl_plugin"))
+ else if (0 == strcmp (test_name,
+ "test_transport_blacklisting_inbound_bl_plugin"))
{
- char * cfg_p1 = "test_transport_blacklisting_cfg_peer1.conf";
- char * cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_plugin.conf";
+ const char *cfg_p1 = "test_transport_blacklisting_cfg_peer1.conf";
+ const char *cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_plugin.conf";
p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p1, 1, NULL, NULL, NULL,
- &start_cb, NULL );
+ cfg_p1, 1,
+ NULL, NULL, NULL,
+ &start_cb, NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p2, 2, NULL, NULL,
- NULL, &start_cb, NULL );
+ cfg_p2, 2,
+ NULL, NULL,
+ NULL,
+ &start_cb, NULL);
/* check if configuration contain correct blacklist entries */
- if ((GNUNET_SYSERR == check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
+ if ( (GNUNET_SYSERR ==
+ check_blacklist_config (cfg_p2, &p2->id, &p1->id)) )
{
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
ok = 1;
GNUNET_SCHEDULER_add_now (&end, NULL );
}
}
- else if (0
- == strcmp (test_name, "test_transport_blacklisting_multiple_plugins"))
+ else if (0 == strcmp (test_name,
+ "test_transport_blacklisting_multiple_plugins"))
{
- char * cfg_p1 = "test_transport_blacklisting_cfg_blp_peer1_multiple_plugins.conf";
- char * cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_multiple_plugins.conf";
+ const char * cfg_p1 = "test_transport_blacklisting_cfg_blp_peer1_multiple_plugins.conf";
+ const char * cfg_p2 = "test_transport_blacklisting_cfg_blp_peer2_multiple_plugins.conf";
p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p1, 1,
- NULL, NULL, NULL, &start_cb, NULL );
+ cfg_p1, 1,
+ NULL, NULL, NULL,
+ &start_cb, NULL);
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
- cfg_p2, 2,
- NULL, NULL, NULL, &start_cb, NULL );
+ cfg_p2, 2,
+ NULL, NULL, NULL,
+ &start_cb, NULL);
/* check if configuration contain correct blacklist entries */
- if ((GNUNET_SYSERR == check_blacklist_config (cfg_p1, &p1->id, &p2->id)) ||
- (GNUNET_SYSERR == check_blacklist_config (cfg_p2, &p2->id, &p1->id)))
+ if ( (GNUNET_SYSERR ==
+ check_blacklist_config (cfg_p1, &p1->id, &p2->id)) ||
+ (GNUNET_SYSERR ==
+ check_blacklist_config (cfg_p2, &p2->id, &p1->id)))
{
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
- GNUNET_TRANSPORT_TESTING_stop_peer(tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
ok = 1;
- GNUNET_SCHEDULER_add_now (&end, NULL );
+ GNUNET_SCHEDULER_add_now (&end, NULL);
}
}
else
{
GNUNET_break (0);
- GNUNET_SCHEDULER_add_now (&end, NULL );
+ GNUNET_SCHEDULER_add_now (&end, NULL);
}
if ((NULL == p1) || (NULL == p2))
{
GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to start peers\n");
ok = 1;
- GNUNET_SCHEDULER_add_now (&end, NULL );
+ GNUNET_SCHEDULER_add_now (&end, NULL);
}
timeout_task = GNUNET_SCHEDULER_add_delayed (CONNECT_TIMEOUT,
- &connect_timeout, NULL );
+ &connect_timeout,
+ NULL);
stage++;
return;
}
if (cc != NULL )
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
if (p1 != NULL )
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
p1 = NULL;
}
if (p2 != NULL )
{
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
p2 = NULL;
}
@@ -480,7 +522,7 @@ main(int argc, char *argv0[])
{
ok = 1;
- GNUNET_TRANSPORT_TESTING_get_test_name (argv0[0], &test_name);
+ test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv0[0]);
GNUNET_log_setup ("test-transport-api-blacklisting", "WARNING", NULL );
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 @@
struct GNUNET_SCHEDULER_Task * timeout_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-struct GNUNET_TRANSPORT_TESTING_handle *tth;
+struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static int connected = GNUNET_NO;
@@ -71,7 +71,7 @@ end_badly (void *cls)
"Fail! Stopping peers\n");
timeout_task = NULL;
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (NULL != tth)
GNUNET_TRANSPORT_TESTING_done (tth);
ret = GNUNET_SYSERR;
@@ -131,7 +131,7 @@ run (void *cls, char *const *args, const char *cfgfile,
GNUNET_assert (p1 != NULL);
GNUNET_assert (p1->th != NULL);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
i++;
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 @@
static struct GNUNET_SCHEDULER_Task * timeout_task;
-static struct PeerContext *p1;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
-static struct PeerContext *p2;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc;
-struct GNUNET_TRANSPORT_TESTING_handle *tth;
+struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static int connected = GNUNET_NO;
@@ -52,14 +52,14 @@ static int ret = 0;
static void
end ()
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Stopping peers\n");
if (timeout_task != NULL)
GNUNET_SCHEDULER_cancel (timeout_task);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
GNUNET_TRANSPORT_TESTING_done (tth);
}
@@ -69,19 +69,19 @@ static void
end_badly ()
{
timeout_task = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Timeout! Stopping peers\n");
if (NULL != cc)
{
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = NULL;
}
if (p1 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p1);
if (p2 != NULL)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p2);
if (NULL != tth)
GNUNET_TRANSPORT_TESTING_done (tth);
@@ -91,9 +91,7 @@ end_badly ()
static void
-testing_connect_cb (struct PeerContext *p1,
- struct PeerContext *p2,
- void *cls)
+testing_connect_cb (void *cls)
{
char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id));
@@ -109,7 +107,7 @@ static void
notify_connect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer `%s' connected \n",
GNUNET_i2s (peer));
connected++;
@@ -117,33 +115,33 @@ notify_connect (void *cls,
static void
-notify_disconnect (void *cls,
+notify_disconnect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer `%s' disconnected \n",
GNUNET_i2s (peer));
}
static void
-notify_receive (void *cls,
+notify_receive (void *cls,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Receiving\n");
}
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
static int started;
started++;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%s') started\n", p->no,
GNUNET_i2s (&p->id));
@@ -157,7 +155,8 @@ start_cb (struct PeerContext *p, void *cls)
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
- cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2,
+ cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1,
+ p2,
&testing_connect_cb,
NULL);
}
@@ -201,7 +200,7 @@ run (void *cls, char *const *args, const char *cfgfile,
int
main (int argc, char *argv[])
{
- char *const argv_1[] = {
+ char *const argv_1[] = {
"test_transport_testing",
"-c",
"test_transport_api_data.conf",
@@ -215,7 +214,7 @@ main (int argc, char *argv[])
"WARNING",
NULL);
GNUNET_PROGRAM_run ((sizeof (argv_1) / sizeof (char *)) - 1, argv_1,
- "test_transport_testing", "nohelp", options,
+ "test_transport_testing", "nohelp", options,
&run, &ret);
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 @@
struct GNUNET_SCHEDULER_Task * timeout_task;
-static struct PeerContext *p;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p;
-struct GNUNET_TRANSPORT_TESTING_handle *tth;
+struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static int ret = 0;
@@ -48,7 +48,7 @@ end ()
if (timeout_task != NULL)
GNUNET_SCHEDULER_cancel (timeout_task);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
GNUNET_TRANSPORT_TESTING_done (tth);
}
@@ -59,7 +59,7 @@ end_badly ()
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n");
if (NULL != p)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
if (NULL != tth)
GNUNET_TRANSPORT_TESTING_done (tth);
@@ -68,12 +68,13 @@ end_badly ()
}
static void
-restart_cb (struct PeerContext *p, void *cls)
+restart_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
+ void *cls)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') successfully restarted\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u (`%s') successfully restarted\n",
p->no,
GNUNET_i2s (&p->id));
-
ret = 0;
GNUNET_SCHEDULER_add_now (&end, NULL);
}
@@ -87,14 +88,13 @@ restart_task ()
p->no,
GNUNET_i2s (&p->id));
GNUNET_TRANSPORT_TESTING_restart_peer (p,
- NULL,
&restart_cb,
p);
}
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') successfully started\n",
p->no,
@@ -113,9 +113,12 @@ run (void *cls, char *const *args, const char *cfgfile,
GNUNET_assert (NULL != tth);
timeout_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &end_badly, NULL);
-
- p = GNUNET_TRANSPORT_TESTING_start_peer(tth, cfgfile, 1,
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
+ &end_badly,
+ NULL);
+ p = GNUNET_TRANSPORT_TESTING_start_peer(tth,
+ cfgfile,
+ 1,
NULL, /* receive cb */
NULL, /* connect cb */
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 @@
struct GNUNET_SCHEDULER_Task * timeout_task;
-static struct PeerContext *p;
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *p;
-struct GNUNET_TRANSPORT_TESTING_handle *tth;
+struct GNUNET_TRANSPORT_TESTING_Handle *tth;
static int ret = 0;
@@ -48,7 +48,7 @@ end ()
if (timeout_task != NULL)
GNUNET_SCHEDULER_cancel (timeout_task);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
GNUNET_TRANSPORT_TESTING_done (tth);
}
@@ -59,7 +59,7 @@ end_badly ()
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n");
if (NULL != p)
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
if (NULL != tth)
GNUNET_TRANSPORT_TESTING_done (tth);
@@ -69,7 +69,7 @@ end_badly ()
static void
-start_cb (struct PeerContext *p, void *cls)
+start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') successfully started\n",
p->no,
@@ -89,13 +89,17 @@ run (void *cls, char *const *args, const char *cfgfile,
GNUNET_assert (NULL != tth);
timeout_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &end_badly, NULL);
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
+ &end_badly,
+ NULL);
- p = GNUNET_TRANSPORT_TESTING_start_peer(tth, cfgfile, 1,
+ p = GNUNET_TRANSPORT_TESTING_start_peer(tth,
+ cfgfile,
+ 1,
NULL, /* receive cb */
NULL, /* connect cb */
NULL, /* disconnect cb */
- start_cb, /* startup cb */
+ &start_cb, /* startup cb */
NULL); /* closure */
if (NULL == p)
{
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 @@
+/*
+ This file is part of GNUnet.
+ Copyright (C) 2006, 2009, 2015, 2016 GNUnet e.V.
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file transport-testing-filenames.c
+ * @brief convenience string manipulation functions for tests
+ * @author Matthias Wachs
+ * @author Christian Grothoff
+ */
+#include "transport-testing.h"
+
+
+/**
+ * Removes all directory separators from absolute filename
+ *
+ * @param file the absolute file name, e.g. as found in argv[0]
+ * @return extracted file name, has to be freed by caller
+ */
+static char *
+extract_filename (const char *file)
+{
+ char *pch = GNUNET_strdup (file);
+ char *backup = pch;
+ char *filename = NULL;
+ char *res;
+
+#if WINDOWS
+ if ((strlen (pch) >= 3) && pch[1] == ':')
+ {
+ if (NULL != strstr (pch, "\\"))
+ {
+ pch = strtok (pch, "\\");
+ while (pch != NULL)
+ {
+ pch = strtok (NULL, "\\");
+ if (pch != NULL)
+ filename = pch;
+ }
+ }
+ }
+ if (filename != NULL)
+ pch = filename; /* If we miss the next condition, filename = pch will
+ * not harm us.
+ */
+#endif
+ if (NULL != strstr (pch, "/"))
+ {
+ pch = strtok (pch, "/");
+ while (pch != NULL)
+ {
+ pch = strtok (NULL, "/");
+ if (pch != NULL)
+ {
+ filename = pch;
+ }
+ }
+ }
+ else
+ filename = pch;
+
+ res = GNUNET_strdup (filename);
+ GNUNET_free (backup);
+ return res;
+}
+
+
+/**
+ * Extracts the test filename from an absolute file name and removes
+ * the extension
+ *
+ * @param file absolute file name
+ * @return the result
+ */
+char *
+GNUNET_TRANSPORT_TESTING_get_test_name (const char *file)
+{
+ char *backup = extract_filename (file);
+ char *filename = backup;
+ char *dotexe;
+ char *ret;
+
+ if (NULL == filename)
+ return NULL;
+
+ /* remove "lt-" */
+ filename = strstr (filename, "test");
+ if (NULL == filename)
+ {
+ GNUNET_free (backup);
+ return NULL;
+ }
+
+ /* remove ".exe" */
+ if (NULL != (dotexe = strstr (filename, ".exe")))
+ dotexe[0] = '\0';
+ ret = GNUNET_strdup (filename);
+ GNUNET_free (backup);
+ return ret;
+}
+
+
+/**
+ * Extracts the filename from an absolute file name and removes the extension
+ *
+ * @param file absolute file name
+ * @return the result
+ */
+char *
+GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file)
+{
+ char *src = extract_filename (file);
+ char *split;
+
+ split = strstr (src, ".");
+ if (NULL != split)
+ split[0] = '\0';
+ return src;
+}
+
+
+/**
+ * Extracts the plugin name from an absolute file name and the test name
+ *
+ * @param file absolute file name
+ * @param test test name
+ * @return the result
+ */
+char *
+GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *file,
+ const char *test)
+{
+ char *filename;
+ char *dotexe;
+ char *e = extract_filename (file);
+ char *t = extract_filename (test);
+ char *ret;
+
+ if (NULL == e)
+ goto fail;
+ /* remove "lt-" */
+ filename = strstr (e, "tes");
+ if (NULL == filename)
+ goto fail;
+ /* remove ".exe" */
+ if (NULL != (dotexe = strstr (filename, ".exe")))
+ dotexe[0] = '\0';
+
+ /* find last _ */
+ filename = strstr (filename, t);
+ if (NULL == filename)
+ goto fail;
+ /* copy plugin */
+ filename += strlen (t);
+ if ('\0' != *filename)
+ filename++;
+ ret = GNUNET_strdup (filename);
+ goto suc;
+fail:
+ ret = NULL;
+suc:
+ GNUNET_free (t);
+ GNUNET_free (e);
+ return ret;
+}
+
+
+/**
+ * This function takes the filename (e.g. argv[0), removes a "lt-"-prefix and
+ * if existing ".exe"-prefix and adds the peer-number
+ *
+ * @param file filename of the test, e.g. argv[0]
+ * @param count peer number
+ * @return the result
+ */
+char *
+GNUNET_TRANSPORT_TESTING_get_config_name (const char *file,
+ int count)
+{
+ char *filename = extract_filename (file);
+ char *backup = filename;
+ char *dotexe;
+ char *ret;
+
+ if (NULL == filename)
+ return NULL;
+ /* remove "lt-" */
+ filename = strstr (filename, "test");
+ if (NULL == filename)
+ goto fail;
+ /* remove ".exe" */
+ if (NULL != (dotexe = strstr (filename, ".exe")))
+ dotexe[0] = '\0';
+ GNUNET_asprintf (&ret,
+ "%s_peer%u.conf",
+ filename,
+ count);
+ GNUNET_free (backup);
+ return ret;
+fail:
+ GNUNET_free (backup);
+ return NULL;
+}
+
+
+/* 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 @@
+/*
+ This file is part of GNUnet.
+ Copyright (C) 2016 GNUnet e.V.
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file transport-testing-main.c
+ * @brief convenience main function for tests
+ * @author Christian Grothoff
+ */
+#include "transport-testing.h"
+
+
+/**
+ * Setup testcase. Calls @a check with the data the test needs.
+ *
+ * @param argv0 binary name (argv[0])
+ * @param filename source file name (__FILE__)
+ * @param num_peers number of peers to start
+ * @param check main function to run
+ * @param check_cls closure for @a check
+ * @return #GNUNET_OK on success
+ */
+int
+GNUNET_TRANSPORT_TESTING_main_ (const char *argv0,
+ const char *filename,
+ unsigned int num_peers,
+ GNUNET_TRANSPORT_TESTING_CheckCallback check,
+ void *check_cls)
+{
+ return GNUNET_SYSERR;
+}
+
+/* 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 @@
/*
This file is part of GNUnet.
- Copyright (C) 2006, 2009, 2015 GNUnet e.V.
+ Copyright (C) 2006, 2009, 2015, 2016 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -17,12 +17,11 @@
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
-
/**
* @file transport-testing.c
* @brief testing lib for transport service
- *
* @author Matthias Wachs
+ * @author Christian Grothoff
*/
#include "transport-testing.h"
@@ -30,41 +29,38 @@
#define LOG(kind,...) GNUNET_log_from(kind, "transport-testing", __VA_ARGS__)
-static struct PeerContext *
-find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth,
+static struct GNUNET_TRANSPORT_TESTING_PeerContext *
+find_peer_context (struct GNUNET_TRANSPORT_TESTING_Handle *tth,
const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *t = tth->p_head;
-
- while (t != NULL)
- {
- if (0 == memcmp (&t->id, peer, sizeof (struct GNUNET_PeerIdentity)))
- break;
- t = t->next;
- }
-
- return t;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t;
+
+ for (t = tth->p_head; NULL != t; t = t->next)
+ if (0 == memcmp (&t->id,
+ peer,
+ sizeof (struct GNUNET_PeerIdentity)))
+ return t;
+ return NULL;
}
static struct GNUNET_TRANSPORT_TESTING_ConnectRequest *
-find_connecting_context (struct GNUNET_TRANSPORT_TESTING_handle *tth,
- struct PeerContext *p1,
- struct PeerContext *p2)
+find_connecting_context (struct GNUNET_TRANSPORT_TESTING_Handle *tth,
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p1,
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p2)
{
- GNUNET_assert (tth != NULL);
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = tth->cc_head;
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
- while (cc != NULL)
+ for (cc = tth->cc_head; NULL != cc; cc = cc->next)
{
- if ((cc->p1 == p1) && (cc->p2 == p2))
- break;
- if ((cc->p1 == p2) && (cc->p2 == p1))
- break;
- cc = cc->next;
+ if ( (cc->p1 == p1) &&
+ (cc->p2 == p2) )
+ return cc;
+ if ( (cc->p1 == p2) &&
+ (cc->p2 == p1) )
+ return cc;
}
-
- return cc;
+ return NULL;
}
@@ -72,20 +68,26 @@ static void
notify_connect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
char *p2_s;
- struct PeerContext *p2;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
- GNUNET_assert (NULL != p);
- GNUNET_assert (NULL != p->tth);
- p2 = find_peer_context (p->tth, peer);
- if (p->nc != NULL)
- p->nc (p->cb_cls, peer);
+ p2 = find_peer_context (p->tth,
+ peer);
+ if (NULL != p->nc)
+ p->nc (p->cb_cls,
+ peer);
if (p2 != NULL)
- GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id));
+ GNUNET_asprintf (&p2_s,
+ "%u (`%s')",
+ p2->no,
+ GNUNET_i2s (&p2->id));
else
- GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer));
+ GNUNET_asprintf (&p2_s,
+ "`%s'",
+ GNUNET_i2s (peer));
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Peers %s connected to peer %u (`%s')\n",
p2_s,
@@ -94,21 +96,21 @@ notify_connect (void *cls,
GNUNET_free (p2_s);
/* Find ConnectingContext */
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = find_connecting_context (p->tth, p, p2);
-
- if (cc == NULL)
+ cc = find_connecting_context (p->tth,
+ p,
+ p2);
+ if (NULL == cc)
return;
-
if (p == cc->p1)
cc->p1_c = GNUNET_YES;
-
if (p == cc->p2)
cc->p2_c = GNUNET_YES;
- if ((cc->p1_c == GNUNET_YES) && (cc->p2_c == GNUNET_YES))
+ if ( (cc->p1_c == GNUNET_YES) &&
+ (cc->p2_c == GNUNET_YES) )
{
- cc->cb (cc->p1, cc->p2, cc->cb_cls);
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (p->tth, cc);
+ cc->cb (cc->cb_cls);
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
}
}
@@ -117,25 +119,28 @@ static void
notify_disconnect (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- struct PeerContext *p = cls;
-
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
+ char *p2_s;
/* Find PeerContext */
int no = 0;
- struct PeerContext *p2 = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p2 = NULL;
- if (p != NULL)
+ if (NULL != p)
{
- GNUNET_assert (p->tth != NULL);
- p2 = find_peer_context (p->tth, peer);
+ p2 = find_peer_context (p->tth,
+ peer);
no = p->no;
}
- char *p2_s;
-
if (p2 != NULL)
- GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id));
+ GNUNET_asprintf (&p2_s,
+ "%u (`%s')",
+ p2->no,
+ GNUNET_i2s (&p2->id));
else
- GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer));
+ GNUNET_asprintf (&p2_s,
+ "`%s'",
+ GNUNET_i2s (peer));
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Peers %s disconnected from peer %u (`%s')\n",
p2_s,
@@ -143,10 +148,11 @@ notify_disconnect (void *cls,
GNUNET_i2s (&p->id));
GNUNET_free (p2_s);
- if (p == NULL)
+ if (NULL == p)
return;
- if (p->nd != NULL)
- p->nd (p->cb_cls, peer);
+ if (NULL != p->nd)
+ p->nd (p->cb_cls,
+ peer);
}
@@ -155,12 +161,14 @@ notify_receive (void *cls,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
- if (p == NULL)
+ if (NULL == p)
return;
- if (p->rec != NULL)
- p->rec (p->cb_cls, peer, message);
+ if (NULL != p->rec)
+ p->rec (p->cb_cls,
+ peer,
+ message);
}
@@ -168,14 +176,15 @@ static void
get_hello (void *cb_cls,
const struct GNUNET_MessageHeader *message)
{
- struct PeerContext *p = cb_cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cb_cls;
struct GNUNET_PeerIdentity hello_id;
- GNUNET_assert (message != NULL);
GNUNET_assert (GNUNET_OK ==
- GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
- message, &hello_id));
- GNUNET_assert (0 == memcmp (&hello_id, &p->id, sizeof (hello_id)));
+ GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) message,
+ &hello_id));
+ GNUNET_assert (0 == memcmp (&hello_id,
+ &p->id,
+ sizeof (hello_id)));
GNUNET_free_non_null (p->hello);
p->hello = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (message);
@@ -185,75 +194,14 @@ get_hello (void *cb_cls,
"Peer %u (`%s') successfully started\n",
p->no,
GNUNET_i2s (&p->id));
- p->start_cb (p, p->cb_cls);
+ p->start_cb (p,
+ p->cb_cls);
p->start_cb = NULL;
}
}
/**
- * Offer the current HELLO of P2 to P1.
- *
- * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequest `
- */
-static void
-offer_hello (void *cls);
-
-
-/**
- * Function called after the HELLO was passed to the
- * transport service.
- */
-static void
-hello_offered (void *cls)
-{
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls;
-
- cc->oh = NULL;
- cc->tct =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- &offer_hello,
- cc);
-}
-
-
-/**
- * Offer the current HELLO of P2 to P1.
- *
- * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequest`
- */
-static void
-offer_hello (void *cls)
-{
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls;
- struct PeerContext *p1 = cc->p1;
- struct PeerContext *p2 = cc->p2;
-
- cc->tct = NULL;
- {
- char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id));
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %u bytes\n",
- p1->no,
- GNUNET_i2s (&p1->id),
- p2->no,
- p2_s,
- GNUNET_HELLO_size (cc->p2->hello));
- GNUNET_free (p2_s);
- }
-
- if (NULL != cc->oh)
- GNUNET_TRANSPORT_offer_hello_cancel (cc->oh);
- cc->oh =
- GNUNET_TRANSPORT_offer_hello (cc->p1->cfg,
- (const struct GNUNET_MessageHeader *) cc->p2->hello,
- &hello_offered,
- cc);
-}
-
-
-/**
* Start a peer with the given configuration
* @param tth the testing handle
* @param cfgname configuration file
@@ -265,23 +213,21 @@ offer_hello (void *cls)
* @param cb_cls closure for callback
* @return the peer context
*/
-struct PeerContext *
-GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
+struct GNUNET_TRANSPORT_TESTING_PeerContext *
+GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_Handle *tth,
const char *cfgname,
int peer_id,
GNUNET_TRANSPORT_ReceiveCallback rec,
GNUNET_TRANSPORT_NotifyConnect nc,
GNUNET_TRANSPORT_NotifyDisconnect nd,
- GNUNET_TRANSPORT_TESTING_start_cb start_cb,
+ GNUNET_TRANSPORT_TESTING_StartCallback start_cb,
void *cb_cls)
{
char *emsg = NULL;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p;
struct GNUNET_PeerIdentity *dummy;
- GNUNET_assert (NULL != tth);
- GNUNET_assert (NULL != tth->tl_system);
-
- if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO)
+ if (GNUNET_NO == GNUNET_DISK_file_test (cfgname))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
"File not found: `%s'\n",
@@ -289,18 +235,32 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth
return NULL;
}
- struct PeerContext *p = GNUNET_new (struct PeerContext);
- GNUNET_CONTAINER_DLL_insert (tth->p_head, tth->p_tail, p);
+ p = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_PeerContext);
+ p->tth = tth;
+ p->nc = nc;
+ p->nd = nd;
+ p->rec = rec;
+ p->start_cb = start_cb;
+ if (cb_cls != NULL)
+ p->cb_cls = cb_cls;
+ else
+ p->cb_cls = p;
+ GNUNET_CONTAINER_DLL_insert (tth->p_head,
+ tth->p_tail,
+ p);
/* Create configuration and call testing lib to modify it */
p->cfg = GNUNET_CONFIGURATION_create ();
GNUNET_assert (GNUNET_OK ==
GNUNET_CONFIGURATION_load (p->cfg, cfgname));
- if (GNUNET_SYSERR == GNUNET_TESTING_configuration_create (tth->tl_system, p->cfg))
+ if (GNUNET_SYSERR ==
+ GNUNET_TESTING_configuration_create (tth->tl_system,
+ p->cfg))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
"Testing library failed to create unique configuration based on `%s'\n",
cfgname);
+ GNUNET_CONFIGURATION_destroy (p->cfg);
GNUNET_free (p);
return NULL;
}
@@ -308,14 +268,17 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth
p->no = peer_id;
/* Configure peer with configuration */
p->peer = GNUNET_TESTING_peer_configure (tth->tl_system,
- p->cfg, p->no, NULL, &emsg);
+ p->cfg,
+ p->no,
+ NULL,
+ &emsg);
if (NULL == p->peer)
{
LOG (GNUNET_ERROR_TYPE_ERROR,
"Testing library failed to create unique configuration based on `%s': `%s'\n",
cfgname,
emsg);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
GNUNET_free_non_null (emsg);
return NULL;
}
@@ -325,39 +288,33 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth
LOG (GNUNET_ERROR_TYPE_ERROR,
"Testing library failed to create unique configuration based on `%s'\n",
cfgname);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
return NULL;
}
- memset(&dummy, '\0', sizeof (dummy));
- GNUNET_TESTING_peer_get_identity (p->peer, &p->id);
- if (0 == memcmp (&dummy, &p->id, sizeof (struct GNUNET_PeerIdentity)))
+ memset (&dummy,
+ '\0',
+ sizeof (dummy));
+ GNUNET_TESTING_peer_get_identity (p->peer,
+ &p->id);
+ if (0 == memcmp (&dummy,
+ &p->id,
+ sizeof (struct GNUNET_PeerIdentity)))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
"Testing library failed to obtain peer identity for peer %u\n",
p->no);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
return NULL;
}
- else
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u configured with identity `%s'\n",
- p->no,
- GNUNET_i2s_full (&p->id));
- }
-
- p->tth = tth;
- p->nc = nc;
- p->nd = nd;
- p->rec = rec;
- p->start_cb = start_cb;
- if (cb_cls != NULL)
- p->cb_cls = cb_cls;
- else
- p->cb_cls = p;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u configured with identity `%s'\n",
+ p->no,
+ GNUNET_i2s_full (&p->id));
- p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p,
+ p->th = GNUNET_TRANSPORT_connect (p->cfg,
+ NULL,
+ p,
&notify_receive,
&notify_connect,
&notify_disconnect);
@@ -367,7 +324,7 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth
"Failed to connect to transport service for peer `%s': `%s'\n",
cfgname,
emsg);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
return NULL;
}
p->ats = GNUNET_ATS_connectivity_init (p->cfg);
@@ -377,40 +334,30 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth
"Failed to connect to ATS service for peer `%s': `%s'\n",
cfgname,
emsg);
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
return NULL;
}
p->ghh = GNUNET_TRANSPORT_get_hello (p->cfg,
&get_hello,
p);
GNUNET_assert (p->ghh != NULL);
-
return p;
}
/**
- * Restart the given peer
+ * Stops and restarts the given peer, sleeping (!) for 5s in between.
*
* @param p the peer
- * @param cfgname the cfg file used to restart
* @param restart_cb callback to call when restarted
* @param cb_cls callback closure
* @return #GNUNET_OK in success otherwise #GNUNET_SYSERR
*/
int
-GNUNET_TRANSPORT_TESTING_restart_peer (struct PeerContext *p,
- const char *cfgname,
- GNUNET_TRANSPORT_TESTING_start_cb restart_cb,
+GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
+ GNUNET_TRANSPORT_TESTING_StartCallback restart_cb,
void *cb_cls)
{
- GNUNET_assert (NULL != p->peer);
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Restarting peer %u (`%s')\n",
- p->no,
- GNUNET_i2s (&p->id));
-
/* shutdown */
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Stopping peer %u (`%s')\n",
@@ -431,8 +378,8 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct PeerContext *p,
GNUNET_ATS_connectivity_done (p->ats);
p->ats = NULL;
}
-
- if (GNUNET_SYSERR == GNUNET_TESTING_peer_stop (p->peer))
+ if (GNUNET_SYSERR ==
+ GNUNET_TESTING_peer_stop (p->peer))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
"Failed to stop peer %u (`%s')\n",
@@ -443,6 +390,10 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct PeerContext *p,
sleep (5); // YUCK!
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Restarting peer %u (`%s')\n",
+ p->no,
+ GNUNET_i2s (&p->id));
/* restart */
if (GNUNET_SYSERR == GNUNET_TESTING_peer_start (p->peer))
{
@@ -476,13 +427,13 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct PeerContext *p,
/**
* Shutdown the given peer
*
- * @param tth testing handle
* @param p the peer
*/
void
-GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
- struct PeerContext *p)
+GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext *p)
{
+ struct GNUNET_TRANSPORT_TESTING_Handle *tth = p->tth;
+
if (NULL != p->ghh)
{
GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
@@ -495,10 +446,12 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
}
if (NULL != p->peer)
{
- if (GNUNET_OK != GNUNET_TESTING_peer_stop (p->peer))
+ if (GNUNET_OK !=
+ GNUNET_TESTING_peer_stop (p->peer))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Testing lib failed to stop peer %u (`%s') \n", p->no,
+ "Testing lib failed to stop peer %u (`%s')\n",
+ p->no,
GNUNET_i2s (&p->id));
}
GNUNET_TESTING_peer_destroy (p->peer);
@@ -523,7 +476,7 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
tth->p_tail,
p);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u (`%s') stopped \n",
+ "Peer %u (`%s') stopped\n",
p->no,
GNUNET_i2s (&p->id));
GNUNET_free (p);
@@ -531,6 +484,67 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
/**
+ * Offer the current HELLO of P2 to P1.
+ *
+ * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequest`
+ */
+static void
+offer_hello (void *cls);
+
+
+/**
+ * Function called after the HELLO was passed to the
+ * transport service.
+ */
+static void
+hello_offered (void *cls)
+{
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls;
+
+ cc->oh = NULL;
+ cc->tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &offer_hello,
+ cc);
+}
+
+
+/**
+ * Offer the current HELLO of P2 to P1.
+ *
+ * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequest`
+ */
+static void
+offer_hello (void *cls)
+{
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p1 = cc->p1;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p2 = cc->p2;
+
+ cc->tct = NULL;
+ {
+ char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id));
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %u bytes\n",
+ p1->no,
+ GNUNET_i2s (&p1->id),
+ p2->no,
+ p2_s,
+ GNUNET_HELLO_size (cc->p2->hello));
+ GNUNET_free (p2_s);
+ }
+
+ if (NULL != cc->oh)
+ GNUNET_TRANSPORT_offer_hello_cancel (cc->oh);
+ cc->oh =
+ GNUNET_TRANSPORT_offer_hello (cc->p1->cfg,
+ (const struct GNUNET_MessageHeader *) cc->p2->hello,
+ &hello_offered,
+ cc);
+}
+
+
+/**
* Initiate a connection from p1 to p2 by offering p1 p2's HELLO message
*
* 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,
* @return a connect request handle
*/
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *
-GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *tth,
- struct PeerContext *p1,
- struct PeerContext *p2,
- GNUNET_TRANSPORT_TESTING_connect_cb cb,
+GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_PeerContext *p1,
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p2,
+ GNUNET_SCHEDULER_TaskCallback cb,
void *cls)
{
+ struct GNUNET_TRANSPORT_TESTING_Handle *tth = p1->tth;
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
cc = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_ConnectRequest);
@@ -567,11 +581,9 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *
cc->ats_sh = GNUNET_ATS_connectivity_suggest (cc->p1->ats,
&p2->id,
1);
-
LOG (GNUNET_ERROR_TYPE_DEBUG,
"New connect request %p\n",
cc);
-
return cc;
}
@@ -584,12 +596,12 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *
* @param cc a connect request handle
*/
void
-GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_handle *tth,
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
+GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
{
+ struct GNUNET_TRANSPORT_TESTING_Handle *tth = cc->p1->tth;
+
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Canceling connect request %p!\n",
- cc);
+ "Canceling connect request!\n");
if (NULL != cc->tct)
{
GNUNET_SCHEDULER_cancel (cc->tct);
@@ -605,7 +617,6 @@ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_h
GNUNET_ATS_connectivity_suggest_cancel (cc->ats_sh);
cc->ats_sh = NULL;
}
-
GNUNET_CONTAINER_DLL_remove (tth->cc_head,
tth->cc_tail,
cc);
@@ -615,57 +626,53 @@ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_h
/**
* Clean up the transport testing
+ *
* @param tth transport testing handle
*/
void
-GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth)
+GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_Handle *tth)
{
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = tth->cc_head;
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ct = NULL;
- struct PeerContext *p = tth->p_head;
- struct PeerContext *t = NULL;
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ct;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *t;
- while (cc != tth->cc_tail)
+ cc = tth->cc_head;
+ while (NULL != cc)
{
ct = cc->next;
LOG (GNUNET_ERROR_TYPE_ERROR,
- "Developer forgot to cancel connect request %p!\n",
- cc);
- GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth,
- cc);
+ "Developer forgot to cancel connect request!\n");
+ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc);
cc = ct;
}
-
+ p = tth->p_head;
while (NULL != p)
{
t = p->next;
LOG (GNUNET_ERROR_TYPE_ERROR,
"Developer forgot to stop peer!\n");
- GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
+ GNUNET_TRANSPORT_TESTING_stop_peer (p);
p = t;
}
-
GNUNET_TESTING_system_destroy (tth->tl_system,
GNUNET_YES);
GNUNET_free (tth);
- tth = NULL;
}
/**
* Initialize the transport testing
+ *
* @return transport testing handle
*/
-struct GNUNET_TRANSPORT_TESTING_handle *
+struct GNUNET_TRANSPORT_TESTING_Handle *
GNUNET_TRANSPORT_TESTING_init ()
{
- struct GNUNET_TRANSPORT_TESTING_handle *tth;
-
- /* prepare hostkeys */
- tth = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_handle);
+ struct GNUNET_TRANSPORT_TESTING_Handle *tth;
- /* Init testing the testing lib */
+ tth = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_Handle);
tth->tl_system = GNUNET_TESTING_system_create ("transport-testing",
NULL,
NULL,
@@ -673,213 +680,11 @@ GNUNET_TRANSPORT_TESTING_init ()
if (NULL == tth->tl_system)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Failed to initialize testing library!\n"));
+ "Failed to initialize testing library!\n");
GNUNET_free (tth);
return NULL;
}
-
return tth;
}
-
-/*
- * Some utility functions
- */
-
-/**
- * Removes all directory separators from absolute filename
- *
- * @param file the absolute file name, e.g. as found in argv[0]
- * @return extracted file name, has to be freed by caller
- */
-static char *
-extract_filename (const char *file)
-{
- char *pch = GNUNET_strdup (file);
- char *backup = pch;
- char *filename = NULL;
- char *res;
-#if WINDOWS
- if ((strlen (pch) >= 3) && pch[1] == ':')
- {
- if (NULL != strstr (pch, "\\"))
- {
- pch = strtok (pch, "\\");
- while (pch != NULL)
- {
- pch = strtok (NULL, "\\");
- if (pch != NULL)
- filename = pch;
- }
- }
- }
- if (filename != NULL)
- pch = filename; /* If we miss the next condition, filename = pch will
- * not harm us.
- */
-#endif
- if (NULL != strstr (pch, "/"))
- {
- pch = strtok (pch, "/");
- while (pch != NULL)
- {
- pch = strtok (NULL, "/");
- if (pch != NULL)
- {
- filename = pch;
- }
- }
- }
- else
- filename = pch;
-
- res = GNUNET_strdup (filename);
- GNUNET_free (backup);
- return res;
-}
-
-
-/**
- * Extracts the test filename from an absolute file name and removes
- * the extension
- *
- * @param file absolute file name
- * @param dest where to store result
- */
-void
-GNUNET_TRANSPORT_TESTING_get_test_name (const char *file,
- char **dest)
-{
- char *filename = extract_filename (file);
- char *backup = filename;
- char *dotexe;
-
- if (filename == NULL)
- goto fail;
-
- /* remove "lt-" */
- filename = strstr (filename, "tes");
- if (filename == NULL)
- goto fail;
-
- /* remove ".exe" */
- if (NULL != (dotexe = strstr (filename, ".exe")))
- dotexe[0] = '\0';
-
- goto suc;
-
-fail:
- (*dest) = NULL;
- return;
-
-suc:
- /* create filename */
- GNUNET_asprintf (dest, "%s", filename);
- GNUNET_free (backup);
-}
-
-
-/**
- * Extracts the filename from an absolute file name and removes the extension
- *
- * @param file absolute file name
- * @param dest where to store result
- */
-void
-GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file,
- char **dest)
-{
- char *src = extract_filename (file);
- char *split;
-
- split = strstr (src, ".");
- if (split != NULL)
- {
- split[0] = '\0';
- }
- GNUNET_asprintf (dest, "%s", src);
- GNUNET_free (src);
-}
-
-
-/**
- * Extracts the plugin name from an absolute file name and the test name
- *
- * @param file absolute file name
- * @param test test name
- * @param dest where to store result
- */
-void
-GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *file,
- const char *test,
- char **dest)
-{
- char *filename;
- char *dotexe;
- char *e = extract_filename (file);
- char *t = extract_filename (test);
-
- if (NULL == e)
- goto fail;
- /* remove "lt-" */
- filename = strstr (e, "tes");
- if (NULL == filename)
- goto fail;
- /* remove ".exe" */
- if (NULL != (dotexe = strstr (filename, ".exe")))
- dotexe[0] = '\0';
-
- /* find last _ */
- filename = strstr (filename, t);
- if (NULL == filename)
- goto fail;
- /* copy plugin */
- filename += strlen (t);
- if ('\0' != *filename)
- filename++;
- GNUNET_asprintf (dest, "%s", filename);
- goto suc;
-fail:
- (*dest) = NULL;
-suc:
- GNUNET_free (t);
- GNUNET_free (e);
-}
-
-
-/**
- * This function takes the filename (e.g. argv[0), removes a "lt-"-prefix and
- * if existing ".exe"-prefix and adds the peer-number
- *
- * @param file filename of the test, e.g. argv[0]
- * @param dest where to write the filename
- * @param count peer number
- */
-void
-GNUNET_TRANSPORT_TESTING_get_config_name (const char *file,
- char **dest,
- int count)
-{
- char *filename = extract_filename (file);
- char *backup = filename;
- char *dotexe;
-
- if (NULL == filename)
- goto fail;
- /* remove "lt-" */
- filename = strstr (filename, "tes");
- if (NULL == filename)
- goto fail;
- /* remove ".exe" */
- if (NULL != (dotexe = strstr (filename, ".exe")))
- dotexe[0] = '\0';
- GNUNET_asprintf (dest, "%s_peer%u.conf", filename, count);
- GNUNET_free (backup);
- return;
-fail:
- (*dest) = NULL;
- GNUNET_free (backup);
-}
-
-
/* 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 @@
/*
This file is part of GNUnet.
- Copyright (C) 2006, 2009, 2015 GNUnet e.V.
+ Copyright (C) 2006, 2009, 2015, 2016 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -21,9 +21,11 @@
/**
* @file transport-testing.h
* @brief testing lib for transport service
- *
* @author Matthias Wachs
+ * @author Christian Grothoff
*/
+#ifndef TRANSPORT_TESTING_H
+#define TRANSPORT_TESTING_H
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_lib.h"
@@ -31,56 +33,45 @@
#include "gnunet_testing_lib.h"
-struct GNUNET_TRANSPORT_TESTING_ConnectRequest;
-
-
/**
* Context for a single peer
*/
-struct PeerContext;
+struct GNUNET_TRANSPORT_TESTING_PeerContext;
/**
- * Callback when two peers are connected and both have called the connect callback
- * to notify clients about a new peer
+ * Definition for a transport testing handle
*/
-typedef void
-(*GNUNET_TRANSPORT_TESTING_start_cb) (struct PeerContext *p,
- void *cls);
+struct GNUNET_TRANSPORT_TESTING_Handle;
+
/**
* Callback when two peers are connected and both have called the connect callback
* to notify clients about a new peer
*/
typedef void
-(*GNUNET_TRANSPORT_TESTING_connect_cb) (struct PeerContext *p1,
- struct PeerContext *p2,
- void *cls);
-
+(*GNUNET_TRANSPORT_TESTING_StartCallback) (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
+ void *cls);
-/**
- * Definition for a transport testing handle
- */
-struct GNUNET_TRANSPORT_TESTING_handle;
/**
* Context for a single peer
*/
-struct PeerContext
+struct GNUNET_TRANSPORT_TESTING_PeerContext
{
/**
* Next element in the DLL
*/
- struct PeerContext *next;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *next;
/**
* Previous element in the DLL
*/
- struct PeerContext *prev;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *prev;
/**
* Transport testing handle this peer belongs to
*/
- struct GNUNET_TRANSPORT_TESTING_handle *tth;
+ struct GNUNET_TRANSPORT_TESTING_Handle *tth;
/**
* Peer's configuration
@@ -135,7 +126,7 @@ struct PeerContext
/**
* Startup completed callback
*/
- GNUNET_TRANSPORT_TESTING_start_cb start_cb;
+ GNUNET_TRANSPORT_TESTING_StartCallback start_cb;
/**
* Peers HELLO Message
@@ -154,23 +145,29 @@ struct PeerContext
};
+/**
+ * Handle for a request to connect two peers.
+ */
struct GNUNET_TRANSPORT_TESTING_ConnectRequest
{
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *next;
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *prev;
- struct PeerContext *p1;
- struct PeerContext *p2;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p1;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p2;
struct GNUNET_SCHEDULER_Task *tct;
struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh;
struct GNUNET_TRANSPORT_OfferHelloHandle *oh;
- GNUNET_TRANSPORT_TESTING_connect_cb cb;
+ GNUNET_SCHEDULER_TaskCallback cb;
void *cb_cls;
int p1_c;
int p2_c;
};
-struct GNUNET_TRANSPORT_TESTING_handle
+/**
+ * Handle for a test run.
+ */
+struct GNUNET_TRANSPORT_TESTING_Handle
{
/**
* Testing library system handle
@@ -190,16 +187,34 @@ struct GNUNET_TRANSPORT_TESTING_handle
/**
* head DLL of peers
*/
- struct PeerContext *p_head;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p_head;
/**
* tail DLL of peers
*/
- struct PeerContext *p_tail;
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p_tail;
};
/**
+ * Initialize the transport testing
+ *
+ * @return transport testing handle
+ */
+struct GNUNET_TRANSPORT_TESTING_Handle *
+GNUNET_TRANSPORT_TESTING_init (void);
+
+
+/**
+ * Clean up the transport testing
+ *
+ * @param tth transport testing handle
+ */
+void
+GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_Handle *tth);
+
+
+/**
* Start a peer with the given configuration
*
* @param tth the testing handle
@@ -212,50 +227,46 @@ struct GNUNET_TRANSPORT_TESTING_handle
* @param cb_cls closure for callback
* @return the peer context
*/
-struct PeerContext *
-GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
+struct GNUNET_TRANSPORT_TESTING_PeerContext *
+GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_Handle *tth,
const char *cfgname,
int peer_id,
GNUNET_TRANSPORT_ReceiveCallback rec,
GNUNET_TRANSPORT_NotifyConnect nc,
GNUNET_TRANSPORT_NotifyDisconnect nd,
- GNUNET_TRANSPORT_TESTING_start_cb start_cb,
+ GNUNET_TRANSPORT_TESTING_StartCallback start_cb,
void *cb_cls);
/**
- * shutdown the given peer
+ * Shutdown the given peer
*
- * @param tth the testing handle
* @param p the peer
*/
void
-GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
- struct PeerContext *pc);
+GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext *pc);
/**
- * Restart the given peer
+ * Stops and restarts the given peer, sleeping (!) for 5s in between.
*
* @param p the peer
- * @param cfgname the cfg file used to restart
* @param restart_cb restart callback
* @param cb_cls callback closure
* @return #GNUNET_OK in success otherwise #GNUNET_SYSERR
*/
int
-GNUNET_TRANSPORT_TESTING_restart_peer (struct PeerContext *p,
- const char *cfgname,
- GNUNET_TRANSPORT_TESTING_start_cb restart_cb,
+GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_PeerContext *p,
+ GNUNET_TRANSPORT_TESTING_StartCallback restart_cb,
void *cb_cls);
+
/**
- * Connect the given peers and call the callback when both peers report the
- * inbound connection. Remarks: start_peer's notify_connect callback can be called
- * before.
+ * Connect the given peers and call the callback when both peers
+ * report the inbound connection. Remarks: start_peer's notify_connect
+ * callback can be called before.
*
- * @param tth transport testing handle
* @param p1 peer 1
* @param p2 peer 2
* @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,
* @return a connect request handle
*/
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *
-GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *tth,
- struct PeerContext *p1,
- struct PeerContext *p2,
- GNUNET_TRANSPORT_TESTING_connect_cb cb,
+GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_PeerContext *p1,
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *p2,
+ GNUNET_SCHEDULER_TaskCallback cb,
void *cls);
/**
- * Cancel the request to connect two peers
- * Tou MUST cancel the request if you stop the peers before the peers connected succesfully
- * @param tth testing
+ * Cancel the request to connect two peers. You MUST cancel the
+ * request if you stop the peers before the peers connected
+ * succesfully.
+ *
* @param cc a connect request handle
*/
void
-GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_handle *tth,
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc);
+GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc);
+
+/* ********************** high-level process functions *************** */
/**
- * Clean up the transport testing
- * @param tth transport testing handle
+ * Main function of a testcase. Called with the initial setup data
+ * for the test as derived from the source name and the binary name.
+ *
+ * @param cls closure
+ * @param tth initialized testing handle
+ * @param test_plugin name of the plugin (if available)
+ * @param num_peers number of entries in the @a cfg_file array
+ * @param cfg_files array of names of configuration files for the peers
*/
-void
-GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth);
+typedef void
+(*GNUNET_TRANSPORT_TESTING_CheckCallback)(void *cls,
+ struct GNUNET_TRANSPORT_TESTING_Handle *tth,
+ const char *test_plugin,
+ unsigned int num_peers,
+ const char *cfg_files[]);
/**
- * Initialize the transport testing
- * @return transport testing handle
+ * Setup testcase. Calls @a check with the data the test needs.
+ *
+ * @param argv0 binary name (argv[0])
+ * @param filename source file name (__FILE__)
+ * @param num_peers number of peers to start
+ * @param check main function to run
+ * @param check_cls closure for @a check
+ * @return #GNUNET_OK on success
*/
-struct GNUNET_TRANSPORT_TESTING_handle *
-GNUNET_TRANSPORT_TESTING_init (void);
+int
+GNUNET_TRANSPORT_TESTING_main_ (const char *argv0,
+ const char *filename,
+ unsigned int num_peers,
+ GNUNET_TRANSPORT_TESTING_CheckCallback check,
+ void *check_cls);
/**
- * Extracts the test filename from an absolute file name and removes the extension
+ * Setup testcase. Calls @a check with the data the test needs.
+ *
+ * @param num_peers number of peers to start
+ * @param check main function to run
+ * @param check_cls closure for @a check
+ * @return #GNUNET_OK on success
+ */
+#define GNUNET_TRANSPORT_TESTING_main(num_peers,check,check_cls) \
+ GNUNET_TRANSPORT_TESTING_main_ (argv[0], __FILE__, num_peers, check, check_cls)
+
+
+/* ********************** low-level filename functions *************** */
+
+
+/**
+ * Extracts the test filename from an absolute file name and removes
+ * the extension.
+ *
* @param file absolute file name
- * @param dest where to store result
+ * @return resulting test name
*/
-void
-GNUNET_TRANSPORT_TESTING_get_test_name (const char *file,
- char **dest);
+char *
+GNUNET_TRANSPORT_TESTING_get_test_name (const char *file);
/**
@@ -312,12 +360,11 @@ GNUNET_TRANSPORT_TESTING_get_test_name (const char *file,
* if existing ".exe"-prefix and adds the peer-number
*
* @param file filename of the test, e.g. argv[0]
- * @param dest where to write the filename
* @param count peer number
+ * @return configuration name to use
*/
-void
+char *
GNUNET_TRANSPORT_TESTING_get_config_name (const char *file,
- char **dest,
int count);
@@ -325,21 +372,22 @@ GNUNET_TRANSPORT_TESTING_get_config_name (const char *file,
* Extracts the plugin anme from an absolute file name and the test name
* @param file absolute file name
* @param test test name
- * @param dest where to store result
+ * @return the plugin name
*/
-void
+char *
GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *executable,
- const char *testname,
- char **pluginname);
+ const char *testname);
/**
- * Extracts the filename from an absolute file name and removes the extenstion
+ * Extracts the filename from an absolute file name and removes the
+ * extenstion
+ *
* @param file absolute file name
- * @param dest where to store result
+ * @return the source name
*/
-void
-GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file,
- char **testname);
+char *
+GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file);
+#endif
/* end of transport_testing.h */