diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-23 16:57:10 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-23 16:57:10 +0000 |
commit | d11a7abfaf81303da7e166268200873b17caa6bc (patch) | |
tree | 9dd5c2698b4b47c0dc3afd61f34820ecfdf4b1bb /src/transport/transport-testing.c | |
parent | 5b4ec2bfc041816666e0c4f21034454d150d16e7 (diff) | |
download | gnunet-d11a7abfaf81303da7e166268200873b17caa6bc.tar.gz gnunet-d11a7abfaf81303da7e166268200873b17caa6bc.zip |
-use LOG macro instead of GNUNET_log_from
Diffstat (limited to 'src/transport/transport-testing.c')
-rw-r--r-- | src/transport/transport-testing.c | 135 |
1 files changed, 77 insertions, 58 deletions
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c index f9182b57f..b2af478e1 100644 --- a/src/transport/transport-testing.c +++ b/src/transport/transport-testing.c | |||
@@ -27,6 +27,9 @@ | |||
27 | #include "transport-testing.h" | 27 | #include "transport-testing.h" |
28 | 28 | ||
29 | 29 | ||
30 | #define LOG(kind,...) GNUNET_log_from(kind, "transport-testing", __VA_ARGS__) | ||
31 | |||
32 | |||
30 | static struct PeerContext * | 33 | static struct PeerContext * |
31 | find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, | 34 | find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
32 | const struct GNUNET_PeerIdentity *peer) | 35 | const struct GNUNET_PeerIdentity *peer) |
@@ -82,9 +85,11 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
82 | GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id)); | 85 | GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id)); |
83 | else | 86 | else |
84 | GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer)); | 87 | GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer)); |
85 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 88 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
86 | "Peers %s connected to peer %u (`%s')\n", p2_s, p->no, | 89 | "Peers %s connected to peer %u (`%s')\n", |
87 | GNUNET_i2s (&p->id)); | 90 | p2_s, |
91 | p->no, | ||
92 | GNUNET_i2s (&p->id)); | ||
88 | GNUNET_free (p2_s); | 93 | GNUNET_free (p2_s); |
89 | 94 | ||
90 | /* Find ConnectingContext */ | 95 | /* Find ConnectingContext */ |
@@ -129,9 +134,11 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
129 | GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id)); | 134 | GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id)); |
130 | else | 135 | else |
131 | GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer)); | 136 | GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer)); |
132 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 137 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
133 | "Peers %s disconnected from peer %u (`%s')\n", p2_s, no, | 138 | "Peers %s disconnected from peer %u (`%s')\n", |
134 | GNUNET_i2s (&p->id)); | 139 | p2_s, |
140 | no, | ||
141 | GNUNET_i2s (&p->id)); | ||
135 | GNUNET_free (p2_s); | 142 | GNUNET_free (p2_s); |
136 | 143 | ||
137 | if (p == NULL) | 144 | if (p == NULL) |
@@ -170,9 +177,9 @@ get_hello (void *cb_cls, const struct GNUNET_MessageHeader *message) | |||
170 | 177 | ||
171 | if (NULL != p->start_cb) | 178 | if (NULL != p->start_cb) |
172 | { | 179 | { |
173 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 180 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
174 | "Peer %u (`%s') successfully started\n", p->no, | 181 | "Peer %u (`%s') successfully started\n", p->no, |
175 | GNUNET_i2s (&p->id)); | 182 | GNUNET_i2s (&p->id)); |
176 | p->start_cb (p, p->cb_cls); | 183 | p->start_cb (p, p->cb_cls); |
177 | p->start_cb = NULL; | 184 | p->start_cb = NULL; |
178 | } | 185 | } |
@@ -196,10 +203,10 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
196 | 203 | ||
197 | char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id)); | 204 | char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id)); |
198 | 205 | ||
199 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 206 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
200 | "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %u bytes\n", | 207 | "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %u bytes\n", |
201 | p1->no, GNUNET_i2s (&p1->id), p2->no, p2_s, | 208 | p1->no, GNUNET_i2s (&p1->id), p2->no, p2_s, |
202 | GNUNET_HELLO_size (cc->p2->hello)); | 209 | GNUNET_HELLO_size (cc->p2->hello)); |
203 | GNUNET_free (p2_s); | 210 | GNUNET_free (p2_s); |
204 | 211 | ||
205 | GNUNET_TRANSPORT_offer_hello (cc->th_p1, | 212 | GNUNET_TRANSPORT_offer_hello (cc->th_p1, |
@@ -241,8 +248,9 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth | |||
241 | 248 | ||
242 | if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO) | 249 | if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO) |
243 | { | 250 | { |
244 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", | 251 | LOG (GNUNET_ERROR_TYPE_ERROR, |
245 | "File not found: `%s' \n", cfgname); | 252 | "File not found: `%s'\n", |
253 | cfgname); | ||
246 | return NULL; | 254 | return NULL; |
247 | } | 255 | } |
248 | 256 | ||
@@ -255,9 +263,9 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth | |||
255 | 263 | ||
256 | if (GNUNET_SYSERR == GNUNET_TESTING_configuration_create (tth->tl_system, p->cfg)) | 264 | if (GNUNET_SYSERR == GNUNET_TESTING_configuration_create (tth->tl_system, p->cfg)) |
257 | { | 265 | { |
258 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", | 266 | LOG (GNUNET_ERROR_TYPE_ERROR, |
259 | "Testing library failed to create unique configuration based on `%s'\n", | 267 | "Testing library failed to create unique configuration based on `%s'\n", |
260 | cfgname); | 268 | cfgname); |
261 | GNUNET_free (p); | 269 | GNUNET_free (p); |
262 | return NULL; | 270 | return NULL; |
263 | } | 271 | } |
@@ -267,9 +275,10 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth | |||
267 | p->peer = GNUNET_TESTING_peer_configure (tth->tl_system, p->cfg, p->no, NULL, &emsg); | 275 | p->peer = GNUNET_TESTING_peer_configure (tth->tl_system, p->cfg, p->no, NULL, &emsg); |
268 | if (NULL == p->peer) | 276 | if (NULL == p->peer) |
269 | { | 277 | { |
270 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", | 278 | LOG (GNUNET_ERROR_TYPE_ERROR, |
271 | "Testing library failed to create unique configuration based on `%s': `%s'\n", | 279 | "Testing library failed to create unique configuration based on `%s': `%s'\n", |
272 | cfgname, emsg); | 280 | cfgname, |
281 | emsg); | ||
273 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); | 282 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); |
274 | GNUNET_free_non_null (emsg); | 283 | GNUNET_free_non_null (emsg); |
275 | return NULL; | 284 | return NULL; |
@@ -277,9 +286,9 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth | |||
277 | GNUNET_free_non_null (emsg); | 286 | GNUNET_free_non_null (emsg); |
278 | if (GNUNET_OK != GNUNET_TESTING_peer_start (p->peer)) | 287 | if (GNUNET_OK != GNUNET_TESTING_peer_start (p->peer)) |
279 | { | 288 | { |
280 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", | 289 | LOG (GNUNET_ERROR_TYPE_ERROR, |
281 | "Testing library failed to create unique configuration based on `%s'\n", | 290 | "Testing library failed to create unique configuration based on `%s'\n", |
282 | cfgname); | 291 | cfgname); |
283 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); | 292 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); |
284 | return NULL; | 293 | return NULL; |
285 | } | 294 | } |
@@ -288,18 +297,18 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth | |||
288 | GNUNET_TESTING_peer_get_identity (p->peer, &p->id); | 297 | GNUNET_TESTING_peer_get_identity (p->peer, &p->id); |
289 | if (0 == memcmp (&dummy, &p->id, sizeof (struct GNUNET_PeerIdentity))) | 298 | if (0 == memcmp (&dummy, &p->id, sizeof (struct GNUNET_PeerIdentity))) |
290 | { | 299 | { |
291 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", | 300 | LOG (GNUNET_ERROR_TYPE_ERROR, |
292 | "Testing library failed to obtain peer identity for peer %u\n", | 301 | "Testing library failed to obtain peer identity for peer %u\n", |
293 | p->no); | 302 | p->no); |
294 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); | 303 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); |
295 | return NULL; | 304 | return NULL; |
296 | } | 305 | } |
297 | else | 306 | else |
298 | { | 307 | { |
299 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 308 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
300 | "Peer %u configured with identity `%s'\n", | 309 | "Peer %u configured with identity `%s'\n", |
301 | p->no, | 310 | p->no, |
302 | GNUNET_i2s_full (&p->id)); | 311 | GNUNET_i2s_full (&p->id)); |
303 | } | 312 | } |
304 | 313 | ||
305 | p->tth = tth; | 314 | p->tth = tth; |
@@ -317,9 +326,10 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth | |||
317 | ¬ify_connect, ¬ify_disconnect); | 326 | ¬ify_connect, ¬ify_disconnect); |
318 | if (NULL == p->th) | 327 | if (NULL == p->th) |
319 | { | 328 | { |
320 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", | 329 | LOG (GNUNET_ERROR_TYPE_ERROR, |
321 | "Failed to connect to transport service for peer `%s': `%s'\n", | 330 | "Failed to connect to transport service for peer `%s': `%s'\n", |
322 | cfgname, emsg); | 331 | cfgname, |
332 | emsg); | ||
323 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); | 333 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); |
324 | return NULL; | 334 | return NULL; |
325 | } | 335 | } |
@@ -350,12 +360,16 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle | |||
350 | GNUNET_assert (p != NULL); | 360 | GNUNET_assert (p != NULL); |
351 | GNUNET_assert (NULL != p->peer); | 361 | GNUNET_assert (NULL != p->peer); |
352 | 362 | ||
353 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 363 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
354 | "Restarting peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id)); | 364 | "Restarting peer %u (`%s')\n", |
365 | p->no, | ||
366 | GNUNET_i2s (&p->id)); | ||
355 | 367 | ||
356 | /* shutdown */ | 368 | /* shutdown */ |
357 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 369 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
358 | "Stopping peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id)); | 370 | "Stopping peer %u (`%s')\n", |
371 | p->no, | ||
372 | GNUNET_i2s (&p->id)); | ||
359 | if (NULL != p->ghh) | 373 | if (NULL != p->ghh) |
360 | GNUNET_TRANSPORT_get_hello_cancel (p->ghh); | 374 | GNUNET_TRANSPORT_get_hello_cancel (p->ghh); |
361 | p->ghh = NULL; | 375 | p->ghh = NULL; |
@@ -365,19 +379,21 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle | |||
365 | 379 | ||
366 | if (GNUNET_SYSERR == GNUNET_TESTING_peer_stop(p->peer)) | 380 | if (GNUNET_SYSERR == GNUNET_TESTING_peer_stop(p->peer)) |
367 | { | 381 | { |
368 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", | 382 | LOG (GNUNET_ERROR_TYPE_ERROR, |
369 | "Failed to stop peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id)); | 383 | "Failed to stop peer %u (`%s')\n", |
384 | p->no, | ||
385 | GNUNET_i2s (&p->id)); | ||
370 | return GNUNET_SYSERR; | 386 | return GNUNET_SYSERR; |
371 | } | 387 | } |
372 | 388 | ||
373 | sleep (5); | 389 | sleep (5); // YUCK! |
374 | 390 | ||
375 | /* restart */ | 391 | /* restart */ |
376 | if (GNUNET_SYSERR == GNUNET_TESTING_peer_start(p->peer)) | 392 | if (GNUNET_SYSERR == GNUNET_TESTING_peer_start(p->peer)) |
377 | { | 393 | { |
378 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", | 394 | LOG (GNUNET_ERROR_TYPE_ERROR, |
379 | "Failed to restart peer %u (`%s')\n", | 395 | "Failed to restart peer %u (`%s')\n", |
380 | p->no, GNUNET_i2s (&p->id)); | 396 | p->no, GNUNET_i2s (&p->id)); |
381 | return GNUNET_SYSERR; | 397 | return GNUNET_SYSERR; |
382 | } | 398 | } |
383 | 399 | ||
@@ -423,9 +439,9 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, | |||
423 | { | 439 | { |
424 | if (GNUNET_OK != GNUNET_TESTING_peer_stop (p->peer)) | 440 | if (GNUNET_OK != GNUNET_TESTING_peer_stop (p->peer)) |
425 | { | 441 | { |
426 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 442 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
427 | "Testing lib failed to stop peer %u (`%s') \n", p->no, | 443 | "Testing lib failed to stop peer %u (`%s') \n", p->no, |
428 | GNUNET_i2s (&p->id)); | 444 | GNUNET_i2s (&p->id)); |
429 | } | 445 | } |
430 | GNUNET_TESTING_peer_destroy (p->peer); | 446 | GNUNET_TESTING_peer_destroy (p->peer); |
431 | p->peer = NULL; | 447 | p->peer = NULL; |
@@ -442,9 +458,9 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, | |||
442 | p->cfg = NULL; | 458 | p->cfg = NULL; |
443 | } | 459 | } |
444 | GNUNET_CONTAINER_DLL_remove (tth->p_head, tth->p_tail, p); | 460 | GNUNET_CONTAINER_DLL_remove (tth->p_head, tth->p_tail, p); |
445 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 461 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
446 | "Peer %u (`%s') stopped \n", p->no, | 462 | "Peer %u (`%s') stopped \n", p->no, |
447 | GNUNET_i2s (&p->id)); | 463 | GNUNET_i2s (&p->id)); |
448 | GNUNET_free (p); | 464 | GNUNET_free (p); |
449 | } | 465 | } |
450 | 466 | ||
@@ -488,8 +504,9 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle * | |||
488 | GNUNET_assert (cc->th_p2 != NULL); | 504 | GNUNET_assert (cc->th_p2 != NULL); |
489 | GNUNET_CONTAINER_DLL_insert (tth->cc_head, tth->cc_tail, cc); | 505 | GNUNET_CONTAINER_DLL_insert (tth->cc_head, tth->cc_tail, cc); |
490 | cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc); | 506 | cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc); |
491 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 507 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
492 | "New connect request %p\n", cc); | 508 | "New connect request %p\n", |
509 | cc); | ||
493 | 510 | ||
494 | return cc; | 511 | return cc; |
495 | } | 512 | } |
@@ -513,8 +530,9 @@ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct | |||
513 | 530 | ||
514 | GNUNET_assert (tth != NULL); | 531 | GNUNET_assert (tth != NULL); |
515 | 532 | ||
516 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | 533 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
517 | "Canceling connect request %p!\n", cc); | 534 | "Canceling connect request %p!\n", |
535 | cc); | ||
518 | 536 | ||
519 | if (cc->tct != GNUNET_SCHEDULER_NO_TASK) | 537 | if (cc->tct != GNUNET_SCHEDULER_NO_TASK) |
520 | GNUNET_SCHEDULER_cancel (cc->tct); | 538 | GNUNET_SCHEDULER_cancel (cc->tct); |
@@ -542,8 +560,9 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth) | |||
542 | while (cc != tth->cc_tail) | 560 | while (cc != tth->cc_tail) |
543 | { | 561 | { |
544 | ct = cc->next; | 562 | ct = cc->next; |
545 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", | 563 | LOG (GNUNET_ERROR_TYPE_ERROR, |
546 | "Developer forgot to cancel connect request %p!\n", cc); | 564 | "Developer forgot to cancel connect request %p!\n", |
565 | cc); | ||
547 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); | 566 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); |
548 | cc = ct; | 567 | cc = ct; |
549 | } | 568 | } |
@@ -551,8 +570,8 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth) | |||
551 | while (p != NULL) | 570 | while (p != NULL) |
552 | { | 571 | { |
553 | t = p->next; | 572 | t = p->next; |
554 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", | 573 | LOG (GNUNET_ERROR_TYPE_ERROR, |
555 | "Developer forgot to stop peer!\n"); | 574 | "Developer forgot to stop peer!\n"); |
556 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); | 575 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); |
557 | p = t; | 576 | p = t; |
558 | } | 577 | } |