diff options
author | t3sserakt <t3ss@posteo.de> | 2020-07-21 12:26:55 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2020-07-21 12:26:55 +0200 |
commit | 17d84245fdfeeb1a6da4ffb97898903cb55f702c (patch) | |
tree | 6e448372a1fb87e21a25e8ea0542fa7f2f327967 /src/transport/test_communicator_basic.c | |
parent | d63986fa2002fcee65dff17746b2b8154289a543 (diff) | |
download | gnunet-17d84245fdfeeb1a6da4ffb97898903cb55f702c.tar.gz gnunet-17d84245fdfeeb1a6da4ffb97898903cb55f702c.zip |
- fixed mem leaks.
Diffstat (limited to 'src/transport/test_communicator_basic.c')
-rw-r--r-- | src/transport/test_communicator_basic.c | 70 |
1 files changed, 43 insertions, 27 deletions
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c index 290167960..e2d2eb73c 100644 --- a/src/transport/test_communicator_basic.c +++ b/src/transport/test_communicator_basic.c | |||
@@ -224,8 +224,8 @@ latency_timeout (void *cls) | |||
224 | } | 224 | } |
225 | 225 | ||
226 | LOG (GNUNET_ERROR_TYPE_ERROR, | 226 | LOG (GNUNET_ERROR_TYPE_ERROR, |
227 | "Latency too high. Test failed. (Phase: %d. Sent: %lu, Received: %lu)\n", | 227 | "Latency too high. Test failed. (Phase: %d. Sent: %lu, Received: %lu)\n", |
228 | phase, num_sent, num_received); | 228 | phase, num_sent, num_received); |
229 | ret = 2; | 229 | ret = 2; |
230 | GNUNET_SCHEDULER_shutdown (); | 230 | GNUNET_SCHEDULER_shutdown (); |
231 | } | 231 | } |
@@ -403,7 +403,7 @@ incoming_message_cb (void *cls, | |||
403 | if (0 != strcmp ((char*) cls, cfg_peers_name[NUM_PEERS - 1])) | 403 | if (0 != strcmp ((char*) cls, cfg_peers_name[NUM_PEERS - 1])) |
404 | { | 404 | { |
405 | LOG (GNUNET_ERROR_TYPE_WARNING, | 405 | LOG (GNUNET_ERROR_TYPE_WARNING, |
406 | "unexpected receiver...\n"); | 406 | "unexpected receiver...\n"); |
407 | return; | 407 | return; |
408 | } | 408 | } |
409 | /* Reset timeout */ | 409 | /* Reset timeout */ |
@@ -422,18 +422,18 @@ incoming_message_cb (void *cls, | |||
422 | if (num_received == BURST_PACKETS) | 422 | if (num_received == BURST_PACKETS) |
423 | { | 423 | { |
424 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 424 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
425 | "Short size packet test done.\n"); | 425 | "Short size packet test done.\n"); |
426 | char *goodput = GNUNET_STRINGS_byte_size_fancy ((SHORT_MESSAGE_SIZE | 426 | char *goodput = GNUNET_STRINGS_byte_size_fancy ((SHORT_MESSAGE_SIZE |
427 | * num_received * 1000 | 427 | * num_received * 1000 |
428 | * 1000) | 428 | * 1000) |
429 | / duration.rel_value_us); | 429 | / duration.rel_value_us); |
430 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 430 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
431 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", | 431 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", |
432 | (unsigned long) num_received, | 432 | (unsigned long) num_received, |
433 | (unsigned long) num_sent, | 433 | (unsigned long) num_sent, |
434 | (unsigned long long) duration.rel_value_us, | 434 | (unsigned long long) duration.rel_value_us, |
435 | goodput, | 435 | goodput, |
436 | (unsigned long long) avg_latency); | 436 | (unsigned long long) avg_latency); |
437 | GNUNET_free (goodput); | 437 | GNUNET_free (goodput); |
438 | start_long = GNUNET_TIME_absolute_get (); | 438 | start_long = GNUNET_TIME_absolute_get (); |
439 | phase = TP_BURST_LONG; | 439 | phase = TP_BURST_LONG; |
@@ -449,7 +449,7 @@ incoming_message_cb (void *cls, | |||
449 | if (long_message_size != payload_len) | 449 | if (long_message_size != payload_len) |
450 | { | 450 | { |
451 | LOG (GNUNET_ERROR_TYPE_WARNING, | 451 | LOG (GNUNET_ERROR_TYPE_WARNING, |
452 | "Ignoring packet with wrong length\n"); | 452 | "Ignoring packet with wrong length\n"); |
453 | return; // Ignore | 453 | return; // Ignore |
454 | } | 454 | } |
455 | num_received++; | 455 | num_received++; |
@@ -458,19 +458,19 @@ incoming_message_cb (void *cls, | |||
458 | if (num_received == BURST_PACKETS) | 458 | if (num_received == BURST_PACKETS) |
459 | { | 459 | { |
460 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 460 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
461 | "Long size packet test done.\n"); | 461 | "Long size packet test done.\n"); |
462 | char *goodput = GNUNET_STRINGS_byte_size_fancy ((long_message_size | 462 | char *goodput = GNUNET_STRINGS_byte_size_fancy ((long_message_size |
463 | * num_received * 1000 | 463 | * num_received * 1000 |
464 | * 1000) | 464 | * 1000) |
465 | / duration.rel_value_us); | 465 | / duration.rel_value_us); |
466 | 466 | ||
467 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 467 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
468 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", | 468 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", |
469 | (unsigned long) num_received, | 469 | (unsigned long) num_received, |
470 | (unsigned long) num_sent, | 470 | (unsigned long) num_sent, |
471 | (unsigned long long) duration.rel_value_us, | 471 | (unsigned long long) duration.rel_value_us, |
472 | goodput, | 472 | goodput, |
473 | (unsigned long long) avg_latency); | 473 | (unsigned long long) avg_latency); |
474 | GNUNET_free (goodput); | 474 | GNUNET_free (goodput); |
475 | ack = 0; | 475 | ack = 0; |
476 | phase = TP_SIZE_CHECK; | 476 | phase = TP_SIZE_CHECK; |
@@ -493,12 +493,12 @@ incoming_message_cb (void *cls, | |||
493 | if (num_received >= (max_size) / 10) | 493 | if (num_received >= (max_size) / 10) |
494 | { | 494 | { |
495 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 495 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
496 | "Size packet test done.\n"); | 496 | "Size packet test done.\n"); |
497 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 497 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
498 | "%lu/%lu packets -- avg latency: %llu us\n", | 498 | "%lu/%lu packets -- avg latency: %llu us\n", |
499 | (unsigned long) num_received, | 499 | (unsigned long) num_received, |
500 | (unsigned long) num_sent, | 500 | (unsigned long) num_sent, |
501 | (unsigned long long) avg_latency); | 501 | (unsigned long long) avg_latency); |
502 | num_received = 0; | 502 | num_received = 0; |
503 | num_sent = 0; | 503 | num_sent = 0; |
504 | avg_latency = 0; | 504 | avg_latency = 0; |
@@ -511,7 +511,7 @@ incoming_message_cb (void *cls, | |||
511 | break; | 511 | break; |
512 | } | 512 | } |
513 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 513 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
514 | "Finished\n"); | 514 | "Finished\n"); |
515 | GNUNET_SCHEDULER_shutdown (); | 515 | GNUNET_SCHEDULER_shutdown (); |
516 | } | 516 | } |
517 | break; | 517 | break; |
@@ -587,6 +587,7 @@ main (int argc, | |||
587 | GNUNET_asprintf (&communicator_binary, | 587 | GNUNET_asprintf (&communicator_binary, |
588 | "gnunet-communicator-%s", | 588 | "gnunet-communicator-%s", |
589 | communicator_name); | 589 | communicator_name); |
590 | |||
590 | if (GNUNET_OK != | 591 | if (GNUNET_OK != |
591 | GNUNET_log_setup ("test_communicator_basic", | 592 | GNUNET_log_setup ("test_communicator_basic", |
592 | "DEBUG", | 593 | "DEBUG", |
@@ -640,11 +641,26 @@ main (int argc, | |||
640 | &peer_id[i].public_key); | 641 | &peer_id[i].public_key); |
641 | GNUNET_free (private_key); | 642 | GNUNET_free (private_key); |
642 | LOG (GNUNET_ERROR_TYPE_INFO, | 643 | LOG (GNUNET_ERROR_TYPE_INFO, |
643 | "Identity of peer %u is %s\n", | 644 | "Identity of peer %u is %s\n", |
644 | i, | 645 | i, |
645 | GNUNET_i2s_full (&peer_id[i])); | 646 | GNUNET_i2s_full (&peer_id[i])); |
646 | } | 647 | } |
647 | LOG (GNUNET_ERROR_TYPE_MESSAGE, "Starting test...\n"); | 648 | LOG (GNUNET_ERROR_TYPE_MESSAGE, "Starting test...\n"); |
649 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
650 | "argv[0]: %s\n", | ||
651 | argv[0]); | ||
652 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
653 | "test_name: %s\n", | ||
654 | test_name); | ||
655 | |||
656 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
657 | "communicator_name: %s\n", | ||
658 | communicator_name); | ||
659 | |||
660 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
661 | "communicator_binary: %s\n", | ||
662 | communicator_binary); | ||
663 | |||
648 | GNUNET_SCHEDULER_run (&run, | 664 | GNUNET_SCHEDULER_run (&run, |
649 | NULL); | 665 | NULL); |
650 | return ret; | 666 | return ret; |