summaryrefslogtreecommitdiff
path: root/src/transport/test_quota_compliance.c
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-09-08 12:33:09 +0000
committerng0 <ng0@n0.is>2019-09-08 12:33:09 +0000
commitd41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch)
tree9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/transport/test_quota_compliance.c
parenta0fce305c565c0937d917a92712f15e9c5736260 (diff)
uncrustify as demanded.
Diffstat (limited to 'src/transport/test_quota_compliance.c')
-rw-r--r--src/transport/test_quota_compliance.c326
1 files changed, 163 insertions, 163 deletions
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c
index 2c6ce8e5f..092935944 100644
--- a/src/transport/test_quota_compliance.c
+++ b/src/transport/test_quota_compliance.c
@@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
SPDX-License-Identifier: AGPL3.0-or-later
-*/
+ */
/**
* @file transport/test_quota_compliance.c
* @brief base test case for transport implementations
@@ -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,118 +61,117 @@ 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;
ret = (iter * iter * iter) % 60000;
- ret += sizeof (struct GNUNET_TRANSPORT_TESTING_TestMessage);
+ ret += sizeof(struct GNUNET_TRANSPORT_TESTING_TestMessage);
return ret;
}
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,
@@ -180,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,
@@ -255,65 +254,66 @@ check (void *cls,
.shutdown_task = &custom_shutdown,
.timeout = TIMEOUT
};
+
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]);
- }
- 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]);
- }
+ {
+ 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]);
+ }
- 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;
- }
- for (unsigned int i=0;i<2;i++)
- {
- if ( (NULL != gen_cfgs[i]) &&
- (GNUNET_YES == GNUNET_DISK_file_test (gen_cfgs[i])) )
+ GNUNET_TRANSPORT_TESTING_main(2,
+ &check,
+ NULL))
{
- GNUNET_DISK_directory_remove (gen_cfgs[i]);
- GNUNET_free (gen_cfgs[i]);
+ 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])))
+ {
+ GNUNET_DISK_directory_remove(gen_cfgs[i]);
+ GNUNET_free(gen_cfgs[i]);
+ }
}
- }
return 0;
}