diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-03-31 09:35:56 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-03-31 09:35:56 +0000 |
commit | 664f658ddc0b302cc7b04d31319dba1e26f5f603 (patch) | |
tree | 59ec462d24f8a2ec29d9d14c6638e0deed4119b6 /src/transport/test_transport_ats.c | |
parent | e25aa5c0890e25e2433372698fa5b09a11920559 (diff) | |
download | gnunet-664f658ddc0b302cc7b04d31319dba1e26f5f603.tar.gz gnunet-664f658ddc0b302cc7b04d31319dba1e26f5f603.zip |
Diffstat (limited to 'src/transport/test_transport_ats.c')
-rw-r--r-- | src/transport/test_transport_ats.c | 51 |
1 files changed, 34 insertions, 17 deletions
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 @@ | |||
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file testing/test_testing_group.c | 21 | * @file testing/test_transport_ats.c |
22 | * @brief testcase for functions to connect peers in testing.c | 22 | * @brief testcase for ats functionality |
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_testing_lib.h" | 25 | #include "gnunet_testing_lib.h" |
@@ -27,14 +27,11 @@ | |||
27 | 27 | ||
28 | #define VERBOSE GNUNET_YES | 28 | #define VERBOSE GNUNET_YES |
29 | 29 | ||
30 | #define NUM_PEERS 4 | 30 | #define NUM_PEERS 2 |
31 | 31 | ||
32 | #define DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | 32 | #define DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
33 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | ||
33 | 34 | ||
34 | /** | ||
35 | * How long until we give up on connecting the peers? | ||
36 | */ | ||
37 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300) | ||
38 | 35 | ||
39 | static int ok; | 36 | static int ok; |
40 | 37 | ||
@@ -46,6 +43,8 @@ static struct GNUNET_TESTING_PeerGroup *pg; | |||
46 | 43 | ||
47 | static GNUNET_SCHEDULER_TaskIdentifier task; | 44 | static GNUNET_SCHEDULER_TaskIdentifier task; |
48 | 45 | ||
46 | struct GNUNET_TESTING_Daemon * master_deamon; | ||
47 | |||
49 | 48 | ||
50 | /** | 49 | /** |
51 | * Check whether peers successfully shut down. | 50 | * Check whether peers successfully shut down. |
@@ -91,18 +90,25 @@ delay_task (void *cls, | |||
91 | 90 | ||
92 | static void connect_peers() | 91 | static void connect_peers() |
93 | { | 92 | { |
94 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peers!\n"); | ||
95 | |||
96 | task = GNUNET_SCHEDULER_add_delayed(DELAY, &delay_task, NULL); | 93 | task = GNUNET_SCHEDULER_add_delayed(DELAY, &delay_task, NULL); |
97 | 94 | ||
95 | } | ||
98 | 96 | ||
99 | //GNUNET_TESTING_daemons_connect(); | 97 | void daemon_connect_cb(void *cls, |
100 | //shutdown_peers(); | 98 | const struct GNUNET_PeerIdentity *first, |
101 | 99 | const struct GNUNET_PeerIdentity *second, | |
100 | uint32_t distance, | ||
101 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | ||
102 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | ||
103 | struct GNUNET_TESTING_Daemon *first_daemon, | ||
104 | struct GNUNET_TESTING_Daemon *second_daemon, | ||
105 | const char *emsg) | ||
106 | { | ||
107 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected peer `%s' \n", GNUNET_i2s(first), GNUNET_i2s(second)); | ||
102 | } | 108 | } |
103 | 109 | ||
104 | static void | 110 | static void |
105 | my_cb (void *cls, | 111 | daemon_start_cb (void *cls, |
106 | const struct GNUNET_PeerIdentity *id, | 112 | const struct GNUNET_PeerIdentity *id, |
107 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 113 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
108 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 114 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
@@ -122,8 +128,19 @@ my_cb (void *cls, | |||
122 | } | 128 | } |
123 | return; | 129 | return; |
124 | } | 130 | } |
125 | |||
126 | peers_left--; | 131 | peers_left--; |
132 | |||
133 | if (master_deamon == NULL) | ||
134 | { | ||
135 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Master peer `%s'\n", GNUNET_i2s(id)); | ||
136 | master_deamon = d; | ||
137 | } | ||
138 | else | ||
139 | { | ||
140 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer `%s'\n", GNUNET_i2s(id)); | ||
141 | GNUNET_TESTING_daemons_connect(master_deamon, d, TIMEOUT, 10, GNUNET_YES,&daemon_connect_cb, NULL); | ||
142 | } | ||
143 | |||
127 | if (peers_left == 0) | 144 | if (peers_left == 0) |
128 | { | 145 | { |
129 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 146 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -157,7 +174,7 @@ run (void *cls, | |||
157 | peers_left, /* Number of parallel ssh connections, or peers being started at once */ | 174 | peers_left, /* Number of parallel ssh connections, or peers being started at once */ |
158 | TIMEOUT, | 175 | TIMEOUT, |
159 | NULL, NULL, | 176 | NULL, NULL, |
160 | &my_cb, NULL, NULL, NULL, NULL); | 177 | &daemon_start_cb, NULL, NULL, NULL, NULL); |
161 | GNUNET_assert (pg != NULL); | 178 | GNUNET_assert (pg != NULL); |
162 | } | 179 | } |
163 | 180 | ||
@@ -205,4 +222,4 @@ main (int argc, char *argv[]) | |||
205 | return ret; | 222 | return ret; |
206 | } | 223 | } |
207 | 224 | ||
208 | /* end of test_testing_group.c */ | 225 | /* end of test_transport_ats.c*/ |