From: Matthias Wachs Date: Thu, 31 Mar 2011 09:35:56 +0000 (+0000) Subject: (no commit message) X-Git-Tag: initial-import-from-subversion-38251~18851 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=664f658ddc0b302cc7b04d31319dba1e26f5f603;p=oweals%2Fgnunet.git --- diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c index ed4f280f6..9f4e8d05f 100644 --- a/src/transport/test_transport_ats.c +++ b/src/transport/test_transport_ats.c @@ -18,8 +18,8 @@ Boston, MA 02111-1307, USA. */ /** - * @file testing/test_testing_group.c - * @brief testcase for functions to connect peers in testing.c + * @file testing/test_transport_ats.c + * @brief testcase for ats functionality */ #include "platform.h" #include "gnunet_testing_lib.h" @@ -27,14 +27,11 @@ #define VERBOSE GNUNET_YES -#define NUM_PEERS 4 +#define NUM_PEERS 2 -#define DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) +#define DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) +#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) -/** - * How long until we give up on connecting the peers? - */ -#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300) static int ok; @@ -46,6 +43,8 @@ static struct GNUNET_TESTING_PeerGroup *pg; static GNUNET_SCHEDULER_TaskIdentifier task; +struct GNUNET_TESTING_Daemon * master_deamon; + /** * Check whether peers successfully shut down. @@ -91,18 +90,25 @@ delay_task (void *cls, static void connect_peers() { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peers!\n"); - task = GNUNET_SCHEDULER_add_delayed(DELAY, &delay_task, NULL); +} - //GNUNET_TESTING_daemons_connect(); - //shutdown_peers(); - +void daemon_connect_cb(void *cls, + const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, + uint32_t distance, + const struct GNUNET_CONFIGURATION_Handle *first_cfg, + const struct GNUNET_CONFIGURATION_Handle *second_cfg, + struct GNUNET_TESTING_Daemon *first_daemon, + struct GNUNET_TESTING_Daemon *second_daemon, + const char *emsg) +{ + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected peer `%s' \n", GNUNET_i2s(first), GNUNET_i2s(second)); } static void -my_cb (void *cls, +daemon_start_cb (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) @@ -122,8 +128,19 @@ my_cb (void *cls, } return; } - peers_left--; + + if (master_deamon == NULL) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Master peer `%s'\n", GNUNET_i2s(id)); + master_deamon = d; + } + else + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer `%s'\n", GNUNET_i2s(id)); + GNUNET_TESTING_daemons_connect(master_deamon, d, TIMEOUT, 10, GNUNET_YES,&daemon_connect_cb, NULL); + } + if (peers_left == 0) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -157,7 +174,7 @@ run (void *cls, peers_left, /* Number of parallel ssh connections, or peers being started at once */ TIMEOUT, NULL, NULL, - &my_cb, NULL, NULL, NULL, NULL); + &daemon_start_cb, NULL, NULL, NULL, NULL); GNUNET_assert (pg != NULL); } @@ -205,4 +222,4 @@ main (int argc, char *argv[]) return ret; } -/* end of test_testing_group.c */ +/* end of test_transport_ats.c*/