diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-04 01:11:45 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-04 01:11:45 +0000 |
commit | 16ef10dfae9a73c5bad581ea939820d14afb087a (patch) | |
tree | 56778abd5886692f620a01466f03710bba09a7ee /src/transport/test_transport_address_switch.c | |
parent | 61b57d2d74d4f3e910e8274c8c95b62eb1631df5 (diff) | |
download | gnunet-16ef10dfae9a73c5bad581ea939820d14afb087a.tar.gz gnunet-16ef10dfae9a73c5bad581ea939820d14afb087a.zip |
cleaning up test a bit
Diffstat (limited to 'src/transport/test_transport_address_switch.c')
-rw-r--r-- | src/transport/test_transport_address_switch.c | 224 |
1 files changed, 135 insertions, 89 deletions
diff --git a/src/transport/test_transport_address_switch.c b/src/transport/test_transport_address_switch.c index e72b2cdee..9ffb6c297 100644 --- a/src/transport/test_transport_address_switch.c +++ b/src/transport/test_transport_address_switch.c | |||
@@ -21,8 +21,8 @@ | |||
21 | * @file transport/test_transport_address_switch.c | 21 | * @file transport/test_transport_address_switch.c |
22 | * @brief base test case for transport implementations | 22 | * @brief base test case for transport implementations |
23 | * | 23 | * |
24 | * This test case tests if peers can successfully switch address when connected | 24 | * This test case tests if peers can successfully switch address when |
25 | * connected by monitoring statistic values | 25 | * connected by monitoring statistic values. |
26 | */ | 26 | */ |
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_transport_service.h" | 28 | #include "gnunet_transport_service.h" |
@@ -38,7 +38,7 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
38 | struct TestMessage | 38 | struct TestMessage |
39 | { | 39 | { |
40 | struct GNUNET_MessageHeader header; | 40 | struct GNUNET_MessageHeader header; |
41 | uint32_t num; | 41 | uint32_t num GNUNET_PACKED; |
42 | }; | 42 | }; |
43 | GNUNET_NETWORK_STRUCT_END | 43 | GNUNET_NETWORK_STRUCT_END |
44 | 44 | ||
@@ -79,21 +79,21 @@ static struct GNUNET_SCHEDULER_Task *delayed_end_task; | |||
79 | static struct GNUNET_SCHEDULER_Task *measure_task; | 79 | static struct GNUNET_SCHEDULER_Task *measure_task; |
80 | 80 | ||
81 | 81 | ||
82 | struct PeerContext *p1; | 82 | static struct PeerContext *p1; |
83 | char *cfg_file_p1; | 83 | static char *cfg_file_p1; |
84 | struct GNUNET_STATISTICS_Handle *p1_stat; | 84 | static struct GNUNET_STATISTICS_Handle *p1_stat; |
85 | 85 | ||
86 | struct PeerContext *p2; | 86 | static struct PeerContext *p2; |
87 | char *cfg_file_p2; | 87 | static char *cfg_file_p2; |
88 | struct GNUNET_STATISTICS_Handle *p2_stat; | 88 | static struct GNUNET_STATISTICS_Handle *p2_stat; |
89 | 89 | ||
90 | struct PeerContext *sender; | 90 | static struct PeerContext *sender; |
91 | 91 | ||
92 | struct PeerContext *receiver; | 92 | static struct PeerContext *receiver; |
93 | 93 | ||
94 | struct GNUNET_TRANSPORT_TransmitHandle *th; | 94 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
95 | 95 | ||
96 | struct GNUNET_TRANSPORT_TESTING_handle *tth; | 96 | static struct GNUNET_TRANSPORT_TESTING_handle *tth; |
97 | 97 | ||
98 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 98 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; |
99 | 99 | ||
@@ -139,19 +139,23 @@ static unsigned long long bytes_recv_after_switch; | |||
139 | 139 | ||
140 | static void end (); | 140 | static void end (); |
141 | 141 | ||
142 | |||
142 | static int | 143 | static int |
143 | stat_start_attempt_cb (void *cls, const char *subsystem, const char *name, | 144 | stat_start_attempt_cb (void *cls, |
144 | uint64_t value, int is_persistent) | 145 | const char *subsystem, |
146 | const char *name, | ||
147 | uint64_t value, | ||
148 | int is_persistent) | ||
145 | { | 149 | { |
146 | if (cls == p1) | 150 | if (cls == p1) |
147 | { | 151 | { |
148 | p1_switch_attempts++; | 152 | p1_switch_attempts++; |
149 | FPRINTF (stderr, "(1:s)"); | 153 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "(1:s)"); |
150 | } | 154 | } |
151 | else if (cls == p2) | 155 | else if (cls == p2) |
152 | { | 156 | { |
153 | p2_switch_attempts++; | 157 | p2_switch_attempts++; |
154 | FPRINTF (stderr, "(2:s)"); | 158 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "(2:s)"); |
155 | } | 159 | } |
156 | 160 | ||
157 | bytes_recv_after_switch = 0; | 161 | bytes_recv_after_switch = 0; |
@@ -162,18 +166,21 @@ stat_start_attempt_cb (void *cls, const char *subsystem, const char *name, | |||
162 | 166 | ||
163 | 167 | ||
164 | static int | 168 | static int |
165 | stat_success_attempt_cb (void *cls, const char *subsystem, const char *name, | 169 | stat_success_attempt_cb (void *cls, |
166 | uint64_t value, int is_persistent) | 170 | const char *subsystem, |
171 | const char *name, | ||
172 | uint64_t value, | ||
173 | int is_persistent) | ||
167 | { | 174 | { |
168 | if (cls == p1) | 175 | if (cls == p1) |
169 | { | 176 | { |
170 | p1_switch_success++; | 177 | p1_switch_success++; |
171 | FPRINTF (stderr, "(1:+)"); | 178 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "(1:+)"); |
172 | } | 179 | } |
173 | if (cls == p2) | 180 | if (cls == p2) |
174 | { | 181 | { |
175 | p2_switch_success++; | 182 | p2_switch_success++; |
176 | FPRINTF (stderr, "(2:+)"); | 183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "(2:+)"); |
177 | } | 184 | } |
178 | 185 | ||
179 | return GNUNET_OK; | 186 | return GNUNET_OK; |
@@ -181,8 +188,11 @@ stat_success_attempt_cb (void *cls, const char *subsystem, const char *name, | |||
181 | 188 | ||
182 | 189 | ||
183 | static int | 190 | static int |
184 | stat_fail_attempt_cb (void *cls, const char *subsystem, const char *name, | 191 | stat_fail_attempt_cb (void *cls, |
185 | uint64_t value, int is_persistent) | 192 | const char *subsystem, |
193 | const char *name, | ||
194 | uint64_t value, | ||
195 | int is_persistent) | ||
186 | { | 196 | { |
187 | if (value == 0) | 197 | if (value == 0) |
188 | return GNUNET_OK; | 198 | return GNUNET_OK; |
@@ -190,20 +200,24 @@ stat_fail_attempt_cb (void *cls, const char *subsystem, const char *name, | |||
190 | if (cls == p1) | 200 | if (cls == p1) |
191 | { | 201 | { |
192 | p1_switch_fail++; | 202 | p1_switch_fail++; |
193 | FPRINTF (stderr, "(1:-)"); | 203 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "(1:-)"); |
194 | } | 204 | } |
195 | if (cls == p2) | 205 | if (cls == p2) |
196 | { | 206 | { |
197 | p2_switch_fail++; | 207 | p2_switch_fail++; |
198 | FPRINTF (stderr, "(2:-)"); | 208 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "(2:-)"); |
199 | } | 209 | } |
200 | 210 | ||
201 | return GNUNET_OK; | 211 | return GNUNET_OK; |
202 | } | 212 | } |
203 | 213 | ||
214 | |||
204 | static int | 215 | static int |
205 | stat_addresses_available (void *cls, const char *subsystem, const char *name, | 216 | stat_addresses_available (void *cls, |
206 | uint64_t value, int is_persistent) | 217 | const char *subsystem, |
218 | const char *name, | ||
219 | uint64_t value, | ||
220 | int is_persistent) | ||
207 | { | 221 | { |
208 | if (cls == p1) | 222 | if (cls == p1) |
209 | { | 223 | { |
@@ -213,26 +227,26 @@ stat_addresses_available (void *cls, const char *subsystem, const char *name, | |||
213 | { | 227 | { |
214 | p2_addresses_avail++; | 228 | p2_addresses_avail++; |
215 | } | 229 | } |
216 | |||
217 | return GNUNET_OK; | 230 | return GNUNET_OK; |
218 | } | 231 | } |
219 | 232 | ||
233 | |||
220 | static void | 234 | static void |
221 | clean_up () | 235 | clean_up () |
222 | { | 236 | { |
223 | if (measure_task != NULL ) | 237 | if (measure_task != NULL) |
224 | { | 238 | { |
225 | GNUNET_SCHEDULER_cancel (measure_task); | 239 | GNUNET_SCHEDULER_cancel (measure_task); |
226 | measure_task = NULL; | 240 | measure_task = NULL; |
227 | } | 241 | } |
228 | 242 | ||
229 | if (delayed_end_task != NULL ) | 243 | if (delayed_end_task != NULL) |
230 | { | 244 | { |
231 | GNUNET_SCHEDULER_cancel (delayed_end_task); | 245 | GNUNET_SCHEDULER_cancel (delayed_end_task); |
232 | delayed_end_task = NULL; | 246 | delayed_end_task = NULL; |
233 | } | 247 | } |
234 | 248 | ||
235 | if (die_task != NULL ) | 249 | if (die_task != NULL) |
236 | { | 250 | { |
237 | GNUNET_SCHEDULER_cancel (die_task); | 251 | GNUNET_SCHEDULER_cancel (die_task); |
238 | die_task = NULL; | 252 | die_task = NULL; |
@@ -283,22 +297,22 @@ clean_up () | |||
283 | p2_stat = NULL; | 297 | p2_stat = NULL; |
284 | } | 298 | } |
285 | 299 | ||
286 | if (th != NULL ) | 300 | if (th != NULL) |
287 | { | 301 | { |
288 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 302 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
289 | th = NULL; | 303 | th = NULL; |
290 | } | 304 | } |
291 | if (cc != NULL ) | 305 | if (cc != NULL) |
292 | { | 306 | { |
293 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); | 307 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); |
294 | cc = NULL; | 308 | cc = NULL; |
295 | } | 309 | } |
296 | if (p1 != NULL ) | 310 | if (p1 != NULL) |
297 | { | 311 | { |
298 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | 312 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); |
299 | p1 = NULL; | 313 | p1 = NULL; |
300 | } | 314 | } |
301 | if (p2 != NULL ) | 315 | if (p2 != NULL) |
302 | { | 316 | { |
303 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | 317 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); |
304 | p2 = NULL; | 318 | p2 = NULL; |
@@ -311,7 +325,9 @@ static void | |||
311 | end () | 325 | end () |
312 | { | 326 | { |
313 | int result = 0; | 327 | int result = 0; |
314 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n"); | 328 | |
329 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
330 | "Stopping peers\n"); | ||
315 | 331 | ||
316 | delayed_end_task = NULL; | 332 | delayed_end_task = NULL; |
317 | FPRINTF (stderr, "\n"); | 333 | FPRINTF (stderr, "\n"); |
@@ -371,22 +387,24 @@ static void | |||
371 | end_badly () | 387 | end_badly () |
372 | { | 388 | { |
373 | die_task = NULL; | 389 | die_task = NULL; |
374 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n"); | 390 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
391 | "Fail! Stopping peers\n"); | ||
375 | 392 | ||
376 | if (test_connected == GNUNET_YES) | 393 | if (test_connected == GNUNET_YES) |
377 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Peers got connected\n"); | 394 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
395 | "Peers got connected\n"); | ||
378 | else | 396 | else |
379 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Peers got NOT connected\n"); | 397 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
380 | 398 | "Peers got NOT connected\n"); | |
381 | clean_up(); | 399 | clean_up(); |
382 | |||
383 | res = GNUNET_YES; | 400 | res = GNUNET_YES; |
384 | } | 401 | } |
385 | 402 | ||
386 | 403 | ||
387 | static void | 404 | static void |
388 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 405 | notify_receive (void *cls, |
389 | const struct GNUNET_MessageHeader *message) | 406 | const struct GNUNET_PeerIdentity *peer, |
407 | const struct GNUNET_MessageHeader *message) | ||
390 | { | 408 | { |
391 | const struct TestMessage *hdr; | 409 | const struct TestMessage *hdr; |
392 | 410 | ||
@@ -398,23 +416,23 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
398 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | 416 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); |
399 | 417 | ||
400 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 418 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
401 | "Peer %u (`%s') got message %u of size %u from peer (`%s')\n", p->no, ps, | 419 | "Peer %u (`%s') got message %u of size %u from peer (`%s')\n", p->no, ps, |
402 | ntohl (hdr->num), ntohs (message->size), GNUNET_i2s (peer)); | 420 | ntohl (hdr->num), |
403 | 421 | ntohs (message->size), | |
422 | GNUNET_i2s (peer)); | ||
404 | if ( ((p1_switch_attempts >= 1) || (p2_switch_attempts >= 1)) && | 423 | if ( ((p1_switch_attempts >= 1) || (p2_switch_attempts >= 1)) && |
405 | (p1_switch_attempts == p1_switch_fail + p1_switch_success) && | 424 | (p1_switch_attempts == p1_switch_fail + p1_switch_success) && |
406 | (p2_switch_attempts == p2_switch_fail + p2_switch_success) ) | 425 | (p2_switch_attempts == p2_switch_fail + p2_switch_success) ) |
407 | { | 426 | { |
408 | bytes_recv_after_switch += ntohs(hdr->header.size); | 427 | bytes_recv_after_switch += ntohs(hdr->header.size); |
409 | if ((bytes_sent_after_switch > 0) && (bytes_recv_after_switch > 0)) | 428 | if ((bytes_sent_after_switch > 0) && (bytes_recv_after_switch > 0)) |
410 | { | 429 | { |
411 | /* A peer switched addresses and sent and received data after the | 430 | /* A peer switched addresses and sent and received data after the |
412 | * switch operations */ | 431 | * switch operations */ |
413 | end (); | 432 | end (); |
414 | } | 433 | } |
415 | } | 434 | } |
416 | 435 | ||
417 | |||
418 | GNUNET_free(ps); | 436 | GNUNET_free(ps); |
419 | } | 437 | } |
420 | 438 | ||
@@ -422,14 +440,15 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
422 | static size_t | 440 | static size_t |
423 | notify_ready (void *cls, size_t size, void *buf) | 441 | notify_ready (void *cls, size_t size, void *buf) |
424 | { | 442 | { |
443 | static uint32_t counter; | ||
425 | char *cbuf = buf; | 444 | char *cbuf = buf; |
426 | struct TestMessage hdr; | 445 | struct TestMessage hdr; |
427 | 446 | ||
428 | th = NULL; | 447 | th = NULL; |
429 | if (buf == NULL) | 448 | if (buf == NULL) |
430 | { | 449 | { |
431 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 450 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
432 | "Timeout occurred while waiting for transmit_ready for message\n"); | 451 | "Timeout occurred while waiting for transmit_ready for message\n"); |
433 | if (NULL != die_task) | 452 | if (NULL != die_task) |
434 | GNUNET_SCHEDULER_cancel (die_task); | 453 | GNUNET_SCHEDULER_cancel (die_task); |
435 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL ); | 454 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL ); |
@@ -443,21 +462,29 @@ notify_ready (void *cls, size_t size, void *buf) | |||
443 | 462 | ||
444 | hdr.header.size = htons (MSIZE); | 463 | hdr.header.size = htons (MSIZE); |
445 | hdr.header.type = htons (MTYPE); | 464 | hdr.header.type = htons (MTYPE); |
446 | hdr.num = htonl (0); | 465 | hdr.num = htonl (counter++); |
447 | memcpy (&cbuf[0], &hdr, sizeof(struct TestMessage)); | 466 | memcpy (&cbuf[0], &hdr, sizeof(struct TestMessage)); |
448 | memset (&cbuf[sizeof(struct TestMessage)], '0', MSIZE - sizeof(struct TestMessage)); | 467 | memset (&cbuf[sizeof(struct TestMessage)], '0', MSIZE - sizeof(struct TestMessage)); |
449 | 468 | ||
450 | #if VERBOSE | 469 | #if VERBOSE |
451 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&receiver->id)); | 470 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&receiver->id)); |
452 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 471 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
453 | "Sending message %u of size %u from peer %u (`%4s') -> peer %u (`%s') !\n", | 472 | "Sending message %u of size %u from peer %u (`%4s') -> peer %u (`%s') !\n", |
454 | n, s, sender->no, GNUNET_i2s (&sender->id), receiver->no, receiver_s); | 473 | (unsigned int) (counter - 1), |
474 | s, | ||
475 | sender->no, | ||
476 | GNUNET_i2s (&sender->id), | ||
477 | receiver->no, | ||
478 | receiver_s); | ||
455 | GNUNET_free(receiver_s); | 479 | GNUNET_free(receiver_s); |
456 | #endif | 480 | #endif |
457 | 481 | ||
458 | if (th == NULL ) | 482 | if (th == NULL) |
459 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, MSIZE, | 483 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, |
460 | TIMEOUT_TRANSMIT, ¬ify_ready, NULL ); | 484 | &p1->id, |
485 | MSIZE, | ||
486 | TIMEOUT_TRANSMIT, | ||
487 | ¬ify_ready, NULL); | ||
461 | 488 | ||
462 | if ( ((p1_switch_attempts >= 1) || (p2_switch_attempts >= 1)) && | 489 | if ( ((p1_switch_attempts >= 1) || (p2_switch_attempts >= 1)) && |
463 | (p1_switch_attempts == p1_switch_fail + p1_switch_success) && | 490 | (p1_switch_attempts == p1_switch_fail + p1_switch_success) && |
@@ -465,7 +492,6 @@ notify_ready (void *cls, size_t size, void *buf) | |||
465 | { | 492 | { |
466 | bytes_sent_after_switch += MSIZE; | 493 | bytes_sent_after_switch += MSIZE; |
467 | } | 494 | } |
468 | |||
469 | return MSIZE; | 495 | return MSIZE; |
470 | } | 496 | } |
471 | 497 | ||
@@ -474,18 +500,24 @@ static void | |||
474 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | 500 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) |
475 | { | 501 | { |
476 | struct PeerContext *p = cls; | 502 | struct PeerContext *p = cls; |
477 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to us!\n", | 503 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
478 | p->no, GNUNET_i2s (peer)); | 504 | "Peer %u (`%4s') connected to us!\n", |
505 | p->no, | ||
506 | GNUNET_i2s (peer)); | ||
479 | } | 507 | } |
480 | 508 | ||
481 | 509 | ||
482 | static void | 510 | static void |
483 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 511 | notify_disconnect (void *cls, |
512 | const struct GNUNET_PeerIdentity *peer) | ||
484 | { | 513 | { |
485 | struct PeerContext *p = cls; | 514 | struct PeerContext *p = cls; |
486 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') disconnected!\n", p->no, | 515 | |
487 | GNUNET_i2s (peer)); | 516 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
488 | if (th != NULL ) | 517 | "Peer %u (`%4s') disconnected!\n", |
518 | p->no, | ||
519 | GNUNET_i2s (peer)); | ||
520 | if (th != NULL) | ||
489 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 521 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
490 | th = NULL; | 522 | th = NULL; |
491 | 523 | ||
@@ -495,15 +527,19 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
495 | static void | 527 | static void |
496 | sendtask () | 528 | sendtask () |
497 | { | 529 | { |
498 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, MSIZE, | 530 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, |
499 | TIMEOUT_TRANSMIT, ¬ify_ready, NULL ); | 531 | &p1->id, MSIZE, |
532 | TIMEOUT_TRANSMIT, | ||
533 | ¬ify_ready, NULL); | ||
500 | } | 534 | } |
501 | 535 | ||
502 | 536 | ||
503 | static void | 537 | static void |
504 | progress_indicator (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 538 | progress_indicator (void *cls, |
539 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
505 | { | 540 | { |
506 | static int counter; | 541 | static int counter; |
542 | |||
507 | measure_task = NULL; | 543 | measure_task = NULL; |
508 | counter++; | 544 | counter++; |
509 | if ((DURATION.rel_value_us / 1000 / 1000LL) < counter) | 545 | if ((DURATION.rel_value_us / 1000 / 1000LL) < counter) |
@@ -514,7 +550,7 @@ progress_indicator (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
514 | { | 550 | { |
515 | FPRINTF (stderr, "%s", "."); | 551 | FPRINTF (stderr, "%s", "."); |
516 | measure_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 552 | measure_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
517 | &progress_indicator, NULL ); | 553 | &progress_indicator, NULL); |
518 | } | 554 | } |
519 | } | 555 | } |
520 | 556 | ||
@@ -524,18 +560,22 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
524 | { | 560 | { |
525 | char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); | 561 | char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
526 | 562 | ||
527 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", | 563 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
528 | p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id)); | 564 | "Peers connected: %u (%s) <-> %u (%s)\n", |
529 | GNUNET_free(p1_c); | 565 | p1->no, p1_c, p2->no, |
566 | GNUNET_i2s (&p2->id)); | ||
567 | GNUNET_free (p1_c); | ||
530 | 568 | ||
531 | cc = NULL; | 569 | cc = NULL; |
532 | test_connected = GNUNET_YES; | 570 | test_connected = GNUNET_YES; |
533 | 571 | ||
534 | FPRINTF (stderr, "(i:s/+/-) \t i == peer 1/2, s/+/- : switch attempt/switch ok/switch fail\n"); | 572 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
573 | "(i:s/+/-) \t i == peer 1/2, s/+/- : switch attempt/switch ok/switch fail\n"); | ||
535 | 574 | ||
536 | measure_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 575 | measure_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
537 | &progress_indicator, NULL ); | 576 | &progress_indicator, |
538 | GNUNET_SCHEDULER_add_now (&sendtask, NULL ); | 577 | NULL); |
578 | GNUNET_SCHEDULER_add_now (&sendtask, NULL); | ||
539 | } | 579 | } |
540 | 580 | ||
541 | 581 | ||
@@ -545,8 +585,10 @@ start_cb (struct PeerContext *p, void *cls) | |||
545 | static int started; | 585 | static int started; |
546 | started++; | 586 | started++; |
547 | 587 | ||
548 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no, | 588 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
549 | GNUNET_i2s (&p->id)); | 589 | "Peer %u (`%s') started\n", |
590 | p->no, | ||
591 | GNUNET_i2s (&p->id)); | ||
550 | if (started != 2) | 592 | if (started != 2) |
551 | return; | 593 | return; |
552 | 594 | ||
@@ -556,17 +598,21 @@ start_cb (struct PeerContext *p, void *cls) | |||
556 | 598 | ||
557 | char *sender_c = GNUNET_strdup (GNUNET_i2s (&sender->id)); | 599 | char *sender_c = GNUNET_strdup (GNUNET_i2s (&sender->id)); |
558 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 600 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
559 | "Test tries to send from %u (%s) -> peer %u (%s)\n", sender->no, sender_c, | 601 | "Test tries to send from %u (%s) -> peer %u (%s)\n", |
560 | receiver->no, GNUNET_i2s (&receiver->id)); | 602 | sender->no, sender_c, |
561 | GNUNET_free(sender_c); | 603 | receiver->no, GNUNET_i2s (&receiver->id)); |
562 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, | 604 | GNUNET_free (sender_c); |
563 | NULL ); | 605 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, |
606 | &testing_connect_cb, | ||
607 | NULL); | ||
564 | } | 608 | } |
565 | 609 | ||
566 | 610 | ||
567 | static void | 611 | static void |
568 | run (void *cls, char * const *args, const char *cfgfile, | 612 | run (void *cls, |
569 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 613 | char * const *args, |
614 | const char *cfgfile, | ||
615 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
570 | { | 616 | { |
571 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL ); | 617 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL ); |
572 | 618 | ||