diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-10 16:41:45 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-10 16:41:45 +0000 |
commit | c6444a089a860da694842942283079a25bc1e957 (patch) | |
tree | d35d30bc35acf05681f7f89057ffdc2e774b33ec /src/transport/test_transport_api.c | |
parent | 4f77ea5b2b3d53a21f70237f8b92a9a2273c21bf (diff) | |
download | gnunet-c6444a089a860da694842942283079a25bc1e957.tar.gz gnunet-c6444a089a860da694842942283079a25bc1e957.zip |
fold bidirectional test into main test_ats_api
Diffstat (limited to 'src/transport/test_transport_api.c')
-rw-r--r-- | src/transport/test_transport_api.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c index bb10116e2..ad078f582 100644 --- a/src/transport/test_transport_api.c +++ b/src/transport/test_transport_api.c | |||
@@ -20,6 +20,7 @@ | |||
20 | /** | 20 | /** |
21 | * @file transport/test_transport_api.c | 21 | * @file transport/test_transport_api.c |
22 | * @brief base test case for transport implementations | 22 | * @brief base test case for transport implementations |
23 | * @author Christian Grothoff | ||
23 | * | 24 | * |
24 | * This test case serves as a base for tcp, udp, and udp-nat | 25 | * This test case serves as a base for tcp, udp, and udp-nat |
25 | * transport test cases. Based on the executable being run | 26 | * transport test cases. Based on the executable being run |
@@ -33,12 +34,12 @@ | |||
33 | /** | 34 | /** |
34 | * How long until we give up on transmitting the message? | 35 | * How long until we give up on transmitting the message? |
35 | */ | 36 | */ |
36 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) | 37 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
37 | 38 | ||
38 | /** | 39 | /** |
39 | * How long until we give up on transmitting the message? | 40 | * How long until we give up on transmitting the message? |
40 | */ | 41 | */ |
41 | #define TIMEOUT_TRANSMIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 42 | #define TIMEOUT_TRANSMIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) |
42 | 43 | ||
43 | #define TEST_MESSAGE_SIZE 2600 | 44 | #define TEST_MESSAGE_SIZE 2600 |
44 | 45 | ||
@@ -58,9 +59,6 @@ custom_shutdown (void *cls) | |||
58 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 59 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
59 | th = NULL; | 60 | th = NULL; |
60 | } | 61 | } |
61 | else | ||
62 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
63 | "Peers were not ready to send data\n"); | ||
64 | } | 62 | } |
65 | 63 | ||
66 | 64 | ||
@@ -148,7 +146,7 @@ sendtask (void *cls) | |||
148 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&ccc->p[0]->id)); | 146 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&ccc->p[0]->id)); |
149 | 147 | ||
150 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 148 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
151 | "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n", | 149 | "Sending message from peer %u (`%s') -> peer %u (`%s') !\n", |
152 | ccc->p[1]->no, | 150 | ccc->p[1]->no, |
153 | GNUNET_i2s (&ccc->p[1]->id), | 151 | GNUNET_i2s (&ccc->p[1]->id), |
154 | ccc->p[0]->no, | 152 | ccc->p[0]->no, |
@@ -162,6 +160,7 @@ sendtask (void *cls) | |||
162 | TIMEOUT_TRANSMIT, | 160 | TIMEOUT_TRANSMIT, |
163 | ¬ify_ready, | 161 | ¬ify_ready, |
164 | ccc->p[0]); | 162 | ccc->p[0]); |
163 | GNUNET_assert (NULL != th); | ||
165 | } | 164 | } |
166 | 165 | ||
167 | 166 | ||
@@ -181,9 +180,16 @@ notify_disconnect (void *cls, | |||
181 | } | 180 | } |
182 | 181 | ||
183 | 182 | ||
184 | int | 183 | /** |
185 | main (int argc, | 184 | * Runs the test. |
186 | char *argv[]) | 185 | * |
186 | * @param argv the argv argument from main() | ||
187 | * @param bi_directional should we try to establish connections | ||
188 | * in both directions simultaneously? | ||
189 | */ | ||
190 | static int | ||
191 | test (char *argv[], | ||
192 | int bi_directional) | ||
187 | { | 193 | { |
188 | struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext my_ccc = { | 194 | struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext my_ccc = { |
189 | .connect_continuation = &sendtask, | 195 | .connect_continuation = &sendtask, |
@@ -192,7 +198,8 @@ main (int argc, | |||
192 | .nc = &GNUNET_TRANSPORT_TESTING_log_connect, | 198 | .nc = &GNUNET_TRANSPORT_TESTING_log_connect, |
193 | .nd = ¬ify_disconnect, | 199 | .nd = ¬ify_disconnect, |
194 | .shutdown_task = &custom_shutdown, | 200 | .shutdown_task = &custom_shutdown, |
195 | .timeout = TIMEOUT | 201 | .timeout = TIMEOUT, |
202 | .bi_directional = bi_directional | ||
196 | }; | 203 | }; |
197 | 204 | ||
198 | ccc = &my_ccc; | 205 | ccc = &my_ccc; |
@@ -204,4 +211,17 @@ main (int argc, | |||
204 | return 0; | 211 | return 0; |
205 | } | 212 | } |
206 | 213 | ||
214 | |||
215 | int | ||
216 | main (int argc, | ||
217 | char *argv[]) | ||
218 | { | ||
219 | if ( (0 != test (argv, | ||
220 | GNUNET_NO)) || | ||
221 | (0 != test (argv, | ||
222 | GNUNET_YES) ) ) | ||
223 | return 1; | ||
224 | return 0; | ||
225 | } | ||
226 | |||
207 | /* end of test_transport_api.c */ | 227 | /* end of test_transport_api.c */ |