From c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 5 Oct 2019 15:09:28 +0200 Subject: global reindent, now with uncrustify hook enabled --- src/transport/test_quota_compliance.c | 316 +++++++++++++++++----------------- 1 file changed, 158 insertions(+), 158 deletions(-) (limited to 'src/transport/test_quota_compliance.c') diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index 092935944..c3c46db37 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c @@ -32,9 +32,9 @@ /** * Testcase timeout */ -#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 480) +#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 480) -#define DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 80) +#define DURATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 80) static struct GNUNET_SCHEDULER_Task *measure_task; @@ -61,61 +61,61 @@ static struct GNUNET_TIME_Absolute start_time; static void -report() +report () { unsigned long long delta; unsigned long long datarate; - delta = GNUNET_TIME_absolute_get_duration(start_time).rel_value_us; + delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; if (0 == delta) delta = 1; datarate = (total_bytes_recv * 1000 * 1000) / delta; - fprintf(stderr, - "Throughput was %llu b/s\n", - datarate); + fprintf (stderr, + "Throughput was %llu b/s\n", + datarate); ccc->global_ret = GNUNET_OK; if (datarate > 1.5 * quota_in[1]) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Datarate of %llu b/s significantly higher than allowed inbound quota of %llu b/s\n", - datarate, - quota_in[1]); - ccc->global_ret = GNUNET_SYSERR; - } + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Datarate of %llu b/s significantly higher than allowed inbound quota of %llu b/s\n", + datarate, + quota_in[1]); + ccc->global_ret = GNUNET_SYSERR; + } if (datarate > 1.5 * quota_out[0]) - { - GNUNET_log(GNUNET_ERROR_TYPE_ERROR, - "Datarate of %llu b/s significantly higher than allowed outbound quota of %llu b/s\n", - datarate, - quota_out[0]); - ccc->global_ret = GNUNET_SYSERR; - } + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Datarate of %llu b/s significantly higher than allowed outbound quota of %llu b/s\n", + datarate, + quota_out[0]); + ccc->global_ret = GNUNET_SYSERR; + } if (GNUNET_OK == ccc->global_ret) - { - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Datarate of %llu b/s complied to allowed outbound quota of %llu b/s and inbound quota of %llu b/s\n", - datarate, - quota_out[0], - quota_in[1]); - } + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Datarate of %llu b/s complied to allowed outbound quota of %llu b/s and inbound quota of %llu b/s\n", + datarate, + quota_out[0], + quota_in[1]); + } } static void -custom_shutdown(void *cls) +custom_shutdown (void *cls) { if (NULL != measure_task) - { - GNUNET_SCHEDULER_cancel(measure_task); - measure_task = NULL; - } - report(); + { + GNUNET_SCHEDULER_cancel (measure_task); + measure_task = NULL; + } + report (); } static size_t -get_size(unsigned int iter) +get_size (unsigned int iter) { size_t ret; @@ -126,52 +126,52 @@ get_size(unsigned int iter) static void -notify_receive(void *cls, - struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver, - const struct GNUNET_PeerIdentity *sender, - const struct GNUNET_TRANSPORT_TESTING_TestMessage *hdr) +notify_receive (void *cls, + struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver, + const struct GNUNET_PeerIdentity *sender, + const struct GNUNET_TRANSPORT_TESTING_TestMessage *hdr) { - if (GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE != ntohs(hdr->header.type)) + if (GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE != ntohs (hdr->header.type)) return; - total_bytes_recv += ntohs(hdr->header.size); + total_bytes_recv += ntohs (hdr->header.size); { - char *ps = GNUNET_strdup(GNUNET_i2s(&receiver->id)); - - GNUNET_log(GNUNET_ERROR_TYPE_INFO, - "Peer %u (`%s') got message %u of size %u from peer (`%s')\n", - receiver->no, - ps, - ntohl(hdr->num), - ntohs(hdr->header.size), - GNUNET_i2s(sender)); - GNUNET_free(ps); + char *ps = GNUNET_strdup (GNUNET_i2s (&receiver->id)); + + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Peer %u (`%s') got message %u of size %u from peer (`%s')\n", + receiver->no, + ps, + ntohl (hdr->num), + ntohs (hdr->header.size), + GNUNET_i2s (sender)); + GNUNET_free (ps); } } static void -measure(void *cls) +measure (void *cls) { static int counter; measure_task = NULL; counter++; if ((DURATION.rel_value_us / 1000 / 1000LL) < counter) - { - fprintf(stderr, "%s", ".\n"); - GNUNET_SCHEDULER_shutdown(); - return; - } - fprintf(stderr, "%s", "."); - measure_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, - &measure, - NULL); + { + fprintf (stderr, "%s", ".\n"); + GNUNET_SCHEDULER_shutdown (); + return; + } + fprintf (stderr, "%s", "."); + measure_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, + &measure, + NULL); } static void -start_task(void *cls) +start_task (void *cls) { static struct GNUNET_TRANSPORT_TESTING_SendClosure sc = { .num_messages = TOTAL_MSGS, @@ -179,71 +179,71 @@ start_task(void *cls) }; sc.ccc = ccc; - measure_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, - &measure, - NULL); - start_time = GNUNET_TIME_absolute_get(); - GNUNET_SCHEDULER_add_now(&GNUNET_TRANSPORT_TESTING_simple_send, - &sc); + measure_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, + &measure, + NULL); + start_time = GNUNET_TIME_absolute_get (); + GNUNET_SCHEDULER_add_now (&GNUNET_TRANSPORT_TESTING_simple_send, + &sc); } static char * -generate_config(const char *cfg_file, - unsigned long long quota_in, - unsigned long long quota_out) +generate_config (const char *cfg_file, + unsigned long long quota_in, + unsigned long long quota_out) { char *in_name; char *out_name; char *fname = NULL; - struct GNUNET_CONFIGURATION_Handle *cfg = GNUNET_CONFIGURATION_create(); - - GNUNET_assert(GNUNET_OK == - GNUNET_CONFIGURATION_load(cfg, - cfg_file)); - GNUNET_asprintf(&fname, - "q_in_%llu_q_out_%llu_%s", - quota_in, - quota_out, - cfg_file); - GNUNET_CONFIGURATION_set_value_string(cfg, - "PATHS", - "DEFAULTCONFIG", - fname); + struct GNUNET_CONFIGURATION_Handle *cfg = GNUNET_CONFIGURATION_create (); + + GNUNET_assert (GNUNET_OK == + GNUNET_CONFIGURATION_load (cfg, + cfg_file)); + GNUNET_asprintf (&fname, + "q_in_%llu_q_out_%llu_%s", + quota_in, + quota_out, + cfg_file); + GNUNET_CONFIGURATION_set_value_string (cfg, + "PATHS", + "DEFAULTCONFIG", + fname); for (int c = 0; c < GNUNET_NT_COUNT; c++) - { - GNUNET_asprintf(&in_name, - "%s_QUOTA_IN", - GNUNET_NT_to_string(c)); - GNUNET_asprintf(&out_name, - "%s_QUOTA_OUT", - GNUNET_NT_to_string(c)); - GNUNET_CONFIGURATION_set_value_number(cfg, - "ats", - in_name, - quota_in); - GNUNET_CONFIGURATION_set_value_number(cfg, - "ats", - out_name, - quota_out); - GNUNET_free(in_name); - GNUNET_free(out_name); - } - GNUNET_assert(GNUNET_OK == - GNUNET_CONFIGURATION_write(cfg, - fname)); - GNUNET_CONFIGURATION_destroy(cfg); + { + GNUNET_asprintf (&in_name, + "%s_QUOTA_IN", + GNUNET_NT_to_string (c)); + GNUNET_asprintf (&out_name, + "%s_QUOTA_OUT", + GNUNET_NT_to_string (c)); + GNUNET_CONFIGURATION_set_value_number (cfg, + "ats", + in_name, + quota_in); + GNUNET_CONFIGURATION_set_value_number (cfg, + "ats", + out_name, + quota_out); + GNUNET_free (in_name); + GNUNET_free (out_name); + } + GNUNET_assert (GNUNET_OK == + GNUNET_CONFIGURATION_write (cfg, + fname)); + GNUNET_CONFIGURATION_destroy (cfg); return fname; } static int -check(void *cls, - struct GNUNET_TRANSPORT_TESTING_Handle *tth_, - const char *test_plugin_, - const char *test_name_, - unsigned int num_peers, - char *cfg_files[]) +check (void *cls, + struct GNUNET_TRANSPORT_TESTING_Handle *tth_, + const char *test_plugin_, + const char *test_name_, + unsigned int num_peers, + char *cfg_files[]) { struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext my_ccc = { .connect_continuation = &start_task, @@ -257,63 +257,63 @@ check(void *cls, ccc = &my_ccc; - if (NULL != strstr(test_name_, - "asymmetric")) - { - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Running asymmetric test with sending peer unlimited, receiving peer (in/out): %llu/%llu b/s \n", - quota_in[1], - quota_out[1]); - quota_out[0] = 1024 * 1024 * 1024; - quota_in[0] = 1024 * 1024 * 1024; - } + if (NULL != strstr (test_name_, + "asymmetric")) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Running asymmetric test with sending peer unlimited, receiving peer (in/out): %llu/%llu b/s \n", + quota_in[1], + quota_out[1]); + quota_out[0] = 1024 * 1024 * 1024; + quota_in[0] = 1024 * 1024 * 1024; + } else - { - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Running symmetric test with (in/out) %llu/%llu b/s \n", - quota_in[1], - quota_out[1]); - } + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Running symmetric test with (in/out) %llu/%llu b/s \n", + quota_in[1], + quota_out[1]); + } for (unsigned int i = 0; i < 2; i++) - { - gen_cfgs[i] = generate_config(cfg_files[i], - quota_in[i], - quota_out[i]); - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Generated config file `%s'\n", - gen_cfgs[i]); - } + { + gen_cfgs[i] = generate_config (cfg_files[i], + quota_in[i], + quota_out[i]); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Generated config file `%s'\n", + gen_cfgs[i]); + } - return GNUNET_TRANSPORT_TESTING_connect_check(&my_ccc, - tth_, - test_plugin_, - test_name_, - num_peers, - gen_cfgs); + return GNUNET_TRANSPORT_TESTING_connect_check (&my_ccc, + tth_, + test_plugin_, + test_name_, + num_peers, + gen_cfgs); } int -main(int argc, - char *argv[]) +main (int argc, + char *argv[]) { if (GNUNET_OK != - GNUNET_TRANSPORT_TESTING_main(2, - &check, - NULL)) - { - GNUNET_break(0); - return 1; - } + GNUNET_TRANSPORT_TESTING_main (2, + &check, + NULL)) + { + GNUNET_break (0); + return 1; + } for (unsigned int i = 0; i < 2; i++) + { + if ((NULL != gen_cfgs[i]) && + (GNUNET_YES == GNUNET_DISK_file_test (gen_cfgs[i]))) { - if ((NULL != gen_cfgs[i]) && - (GNUNET_YES == GNUNET_DISK_file_test(gen_cfgs[i]))) - { - GNUNET_DISK_directory_remove(gen_cfgs[i]); - GNUNET_free(gen_cfgs[i]); - } + GNUNET_DISK_directory_remove (gen_cfgs[i]); + GNUNET_free (gen_cfgs[i]); } + } return 0; } -- cgit v1.2.3