diff options
Diffstat (limited to 'src/transport/test_quota_compliance.c')
-rw-r--r-- | src/transport/test_quota_compliance.c | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index d8e5c3f44..3422ef2fd 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c | |||
@@ -21,7 +21,7 @@ | |||
21 | * @file transport/test_quota_compliance.c | 21 | * @file transport/test_quota_compliance.c |
22 | * @brief base test case for transport implementations | 22 | * @brief base test case for transport implementations |
23 | * | 23 | * |
24 | * This test case tests quota compliance both on core and transport level | 24 | * This test case tests quota compliance both on transport level |
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_common.h" | 27 | #include "gnunet_common.h" |
@@ -282,19 +282,6 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
282 | } | 282 | } |
283 | #endif | 283 | #endif |
284 | n++; | 284 | n++; |
285 | if (0 == (n % (TOTAL_MSGS / 100))) | ||
286 | { | ||
287 | fprintf (stderr, "."); | ||
288 | if (die_task != GNUNET_SCHEDULER_NO_TASK) | ||
289 | GNUNET_SCHEDULER_cancel (die_task); | ||
290 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | ||
291 | } | ||
292 | if (n == TOTAL_MSGS) | ||
293 | { | ||
294 | ok = 0; | ||
295 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\nAll messages received\n"); | ||
296 | end (); | ||
297 | } | ||
298 | } | 285 | } |
299 | 286 | ||
300 | 287 | ||
@@ -409,6 +396,27 @@ sendtask () | |||
409 | NULL); | 396 | NULL); |
410 | } | 397 | } |
411 | 398 | ||
399 | |||
400 | static void | ||
401 | measure (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
402 | { | ||
403 | static int counter; | ||
404 | measure_task = GNUNET_SCHEDULER_NO_TASK; | ||
405 | |||
406 | counter++; | ||
407 | if ((DURATION.rel_value / 1000) < counter ) | ||
408 | { | ||
409 | fprintf (stderr, ".\n"); | ||
410 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
411 | } | ||
412 | else | ||
413 | { | ||
414 | fprintf (stderr, "."); | ||
415 | measure_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &measure, NULL); | ||
416 | } | ||
417 | } | ||
418 | |||
419 | |||
412 | static void | 420 | static void |
413 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | 421 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) |
414 | { | 422 | { |
@@ -421,7 +429,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
421 | cc = NULL; | 429 | cc = NULL; |
422 | test_connected = GNUNET_YES; | 430 | test_connected = GNUNET_YES; |
423 | 431 | ||
424 | measure_task = GNUNET_SCHEDULER_add_delayed (DURATION, &end, NULL); | 432 | measure_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &measure, NULL); |
425 | GNUNET_SCHEDULER_add_now (&sendtask, NULL); | 433 | GNUNET_SCHEDULER_add_now (&sendtask, NULL); |
426 | 434 | ||
427 | } | 435 | } |
@@ -516,7 +524,26 @@ static void | |||
516 | run (void *cls, char *const *args, const char *cfgfile, | 524 | run (void *cls, char *const *args, const char *cfgfile, |
517 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 525 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
518 | { | 526 | { |
519 | run_measurement (10000, 10000, 10000, 10000); | 527 | unsigned long long p1_quota_in = 10000; |
528 | unsigned long long p1_quota_out = 10000; | ||
529 | unsigned long long p2_quota_in = 10000; | ||
530 | unsigned long long p2_quota_out = 10000; | ||
531 | |||
532 | if (NULL != strstr (test_name,"asymmetric")) | ||
533 | { | ||
534 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
535 | "Running asymmetric test with sending peer unlimited, receiving peer (in/out): %llu/%llu b/s \n", | ||
536 | p2_quota_in, p2_quota_out); | ||
537 | p1_quota_out = 1024 * 1024 * 1024; | ||
538 | p1_quota_in = 1024 * 1024 * 1024; | ||
539 | } | ||
540 | else | ||
541 | { | ||
542 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
543 | "Running symmetric test with (in/out) %llu/%llu b/s \n", | ||
544 | p2_quota_in, p2_quota_out); | ||
545 | } | ||
546 | run_measurement (p1_quota_in, p1_quota_out, p2_quota_in, p2_quota_out); | ||
520 | } | 547 | } |
521 | 548 | ||
522 | static int | 549 | static int |
@@ -596,7 +623,7 @@ main (int argc, char *argv[]) | |||
596 | 623 | ||
597 | if (GNUNET_YES == GNUNET_DISK_file_test (gen_cfg_p2)) | 624 | if (GNUNET_YES == GNUNET_DISK_file_test (gen_cfg_p2)) |
598 | { | 625 | { |
599 | //GNUNET_DISK_directory_remove (gen_cfg_p2); | 626 | GNUNET_DISK_directory_remove (gen_cfg_p2); |
600 | GNUNET_free (gen_cfg_p2); | 627 | GNUNET_free (gen_cfg_p2); |
601 | } | 628 | } |
602 | 629 | ||