aboutsummaryrefslogtreecommitdiff
path: root/src/service/core/test_core_quota_compliance.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/core/test_core_quota_compliance.c')
-rw-r--r--src/service/core/test_core_quota_compliance.c788
1 files changed, 788 insertions, 0 deletions
diff --git a/src/service/core/test_core_quota_compliance.c b/src/service/core/test_core_quota_compliance.c
new file mode 100644
index 000000000..099c6fa3b
--- /dev/null
+++ b/src/service/core/test_core_quota_compliance.c
@@ -0,0 +1,788 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2009, 2010, 2015, 2016 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/**
21 * @file core/test_core_quota_compliance.c
22 * @brief testcase for core_api.c focusing quota compliance on core level
23 * @author Christian Grothoff
24 */
25#include "platform.h"
26#include "gnunet_arm_service.h"
27#include "gnunet_core_service.h"
28#include "gnunet_util_lib.h"
29#include "gnunet_ats_service.h"
30#include "gnunet_transport_service.h"
31#include "gnunet_transport_hello_service.h"
32#include "gnunet_statistics_service.h"
33
34
35#define SYMMETRIC 0
36#define ASYMMETRIC_SEND_LIMITED 1
37#define ASYMMETRIC_RECV_LIMITED 2
38
39/**
40 * Note that this value must not significantly exceed
41 * 'MAX_PENDING' in 'gnunet-service-transport.c', otherwise
42 * messages may be dropped even for a reliable transport.
43 */
44#define TOTAL_MSGS (60000 * 10)
45
46/**
47 * How long until we give up on transmitting the message?
48 */
49#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
50
51/**
52 * What delay do we request from the core service for transmission?
53 */
54#define FAST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \
55 150)
56
57#define MTYPE 12345
58#define MESSAGESIZE (1024 - 8)
59#define MEASUREMENT_LENGTH GNUNET_TIME_relative_multiply ( \
60 GNUNET_TIME_UNIT_SECONDS, 30)
61
62static unsigned long long total_bytes_sent;
63static unsigned long long total_bytes_recv;
64
65static struct GNUNET_TIME_Absolute start_time;
66
67static struct GNUNET_SCHEDULER_Task *err_task;
68
69static struct GNUNET_SCHEDULER_Task *measure_task;
70
71
72struct PeerContext
73{
74 struct GNUNET_CONFIGURATION_Handle *cfg;
75 struct GNUNET_CORE_Handle *ch;
76 struct GNUNET_MQ_Handle *mq;
77 struct GNUNET_TRANSPORT_OfferHelloHandle *oh;
78 struct GNUNET_PeerIdentity id;
79 struct GNUNET_MessageHeader *hello;
80 struct GNUNET_STATISTICS_Handle *stats;
81 struct GNUNET_TRANSPORT_HelloGetHandle *ghh;
82 struct GNUNET_ATS_ConnectivityHandle *ats;
83 struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh;
84 int connect_status;
85 struct GNUNET_OS_Process *arm_proc;
86};
87
88static struct PeerContext p1;
89static struct PeerContext p2;
90
91static unsigned long long current_quota_p1_in;
92static unsigned long long current_quota_p1_out;
93static unsigned long long current_quota_p2_in;
94static unsigned long long current_quota_p2_out;
95
96static int ok;
97static int test;
98static int32_t tr_n;
99
100static int running;
101
102
103#if VERBOSE
104#define OKPP do { ok++; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, \
105 "Now at stage %u at %s:%u\n", ok, __FILE__, \
106 __LINE__); } while (0)
107#else
108#define OKPP do { ok++; } while (0)
109#endif
110
111struct TestMessage
112{
113 struct GNUNET_MessageHeader header;
114 uint32_t num GNUNET_PACKED;
115 uint8_t pad[MESSAGESIZE];
116};
117
118
119static void
120terminate_peer (struct PeerContext *p)
121{
122 if (NULL != p->ch)
123 {
124 GNUNET_CORE_disconnect (p->ch);
125 p->ch = NULL;
126 }
127 if (NULL != p->ghh)
128 {
129 GNUNET_TRANSPORT_hello_get_cancel (p->ghh);
130 p->ghh = NULL;
131 }
132 if (NULL != p->oh)
133 {
134 GNUNET_TRANSPORT_offer_hello_cancel (p->oh);
135 p->oh = NULL;
136 }
137 if (NULL != p->ats_sh)
138 {
139 GNUNET_ATS_connectivity_suggest_cancel (p->ats_sh);
140 p->ats_sh = NULL;
141 }
142 if (NULL != p->ats)
143 {
144 GNUNET_ATS_connectivity_done (p->ats);
145 p->ats = NULL;
146 }
147 if (NULL != p->stats)
148 {
149 GNUNET_STATISTICS_destroy (p->stats, GNUNET_NO);
150 p->stats = NULL;
151 }
152 if (NULL != p->hello)
153 {
154 GNUNET_free (p->hello);
155 p->hello = NULL;
156 }
157}
158
159
160static void
161shutdown_task (void *cls)
162{
163 if (NULL != err_task)
164 {
165 GNUNET_SCHEDULER_cancel (err_task);
166 err_task = NULL;
167 }
168 if (NULL != measure_task)
169 {
170 GNUNET_SCHEDULER_cancel (measure_task);
171 measure_task = NULL;
172 }
173 terminate_peer (&p1);
174 terminate_peer (&p2);
175}
176
177
178static void
179terminate_task_error (void *cls)
180{
181 err_task = NULL;
182 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
183 "Testcase failed (timeout)!\n");
184 GNUNET_SCHEDULER_shutdown ();
185 ok = 42;
186}
187
188
189/**
190 * Callback function to process statistic values.
191 *
192 * @param cls closure
193 * @param subsystem name of subsystem that created the statistic
194 * @param name the name of the datum
195 * @param value the current value
196 * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
197 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
198 */
199static int
200print_stat (void *cls,
201 const char *subsystem,
202 const char *name,
203 uint64_t value,
204 int is_persistent)
205{
206 if (cls == &p1)
207 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
208 "Peer1 %50s = %12llu\n",
209 name,
210 (unsigned long long) value);
211 if (cls == &p2)
212 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
213 "Peer2 %50s = %12llu\n",
214 name,
215 (unsigned long long) value);
216 return GNUNET_OK;
217}
218
219
220static void
221measurement_stop (void *cls)
222{
223 unsigned long long delta;
224 unsigned long long throughput_out;
225 unsigned long long throughput_in;
226 unsigned long long max_quota_in;
227 unsigned long long max_quota_out;
228 unsigned long long quota_delta;
229 enum GNUNET_ErrorType kind = GNUNET_ERROR_TYPE_DEBUG;
230
231 measure_task = NULL;
232 fprintf (stdout, "%s", "\n");
233 running = GNUNET_NO;
234
235 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us;
236 if (0 == delta)
237 delta = 1;
238 throughput_out = total_bytes_sent * 1000000LL / delta; /* convert to bytes/s */
239 throughput_in = total_bytes_recv * 1000000LL / delta; /* convert to bytes/s */
240
241 max_quota_in = GNUNET_MIN (current_quota_p1_in, current_quota_p2_in);
242 max_quota_out = GNUNET_MIN (current_quota_p1_out, current_quota_p2_out);
243 if (max_quota_out < max_quota_in)
244 quota_delta = max_quota_in / 3;
245 else
246 quota_delta = max_quota_out / 3;
247
248 if ((throughput_out > (max_quota_out + quota_delta)) ||
249 (throughput_in > (max_quota_in + quota_delta)))
250 ok = 1; /* fail */
251 else
252 ok = 0; /* pass */
253 GNUNET_STATISTICS_get (p1.stats,
254 "core",
255 "# discarded CORE_SEND requests",
256 NULL,
257 &print_stat,
258 &p1);
259 GNUNET_STATISTICS_get (p1.stats,
260 "core",
261 "# discarded CORE_SEND request bytes",
262 NULL,
263 &print_stat,
264 &p1);
265 GNUNET_STATISTICS_get (p1.stats,
266 "core",
267 "# discarded lower priority CORE_SEND requests",
268 NULL,
269 &print_stat,
270 NULL);
271 GNUNET_STATISTICS_get (p1.stats,
272 "core",
273 "# discarded lower priority CORE_SEND request bytes",
274 NULL,
275 &print_stat,
276 &p1);
277 GNUNET_STATISTICS_get (p2.stats,
278 "core",
279 "# discarded CORE_SEND requests",
280 NULL,
281 &print_stat,
282 &p2);
283
284 GNUNET_STATISTICS_get (p2.stats,
285 "core",
286 "# discarded CORE_SEND request bytes",
287 NULL,
288 &print_stat,
289 &p2);
290 GNUNET_STATISTICS_get (p2.stats,
291 "core",
292 "# discarded lower priority CORE_SEND requests",
293 NULL,
294 &print_stat,
295 &p2);
296 GNUNET_STATISTICS_get (p2.stats,
297 "core",
298 "# discarded lower priority CORE_SEND request bytes",
299 NULL,
300 &print_stat,
301 &p2);
302
303 if (ok != 0)
304 kind = GNUNET_ERROR_TYPE_ERROR;
305 switch (test)
306 {
307 case SYMMETRIC:
308 GNUNET_log (kind,
309 "Core quota compliance test with symmetric quotas: %s\n",
310 (0 == ok) ? "PASSED" : "FAILED");
311 break;
312
313 case ASYMMETRIC_SEND_LIMITED:
314 GNUNET_log (kind,
315 "Core quota compliance test with limited sender quota: %s\n",
316 (0 == ok) ? "PASSED" : "FAILED");
317 break;
318
319 case ASYMMETRIC_RECV_LIMITED:
320 GNUNET_log (kind,
321 "Core quota compliance test with limited receiver quota: %s\n",
322 (0 == ok) ? "PASSED" : "FAILED");
323 break;
324 }
325 ;
326 GNUNET_log (kind,
327 "Peer 1 send rate: %llu b/s (%llu bytes in %llu ms)\n",
328 throughput_out,
329 total_bytes_sent,
330 delta);
331 GNUNET_log (kind,
332 "Peer 1 send quota: %llu b/s\n",
333 current_quota_p1_out);
334 GNUNET_log (kind,
335 "Peer 2 receive rate: %llu b/s (%llu bytes in %llu ms)\n",
336 throughput_in,
337 total_bytes_recv,
338 delta);
339 GNUNET_log (kind,
340 "Peer 2 receive quota: %llu b/s\n",
341 current_quota_p2_in);
342/*
343 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. inbound quota allowed: %llu b/s\n",max_quota_in );
344 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. outbound quota allowed: %llu b/s\n",max_quota_out);
345 */
346 GNUNET_SCHEDULER_shutdown ();
347}
348
349
350static void
351do_transmit (void *cls)
352{
353 struct TestMessage *hdr;
354 struct GNUNET_MQ_Envelope *env;
355
356 env = GNUNET_MQ_msg (hdr,
357 MTYPE);
358 hdr->num = htonl (tr_n);
359 memset (&hdr->pad,
360 tr_n,
361 MESSAGESIZE);
362 tr_n++;
363 GNUNET_SCHEDULER_cancel (err_task);
364 err_task =
365 GNUNET_SCHEDULER_add_delayed (TIMEOUT,
366 &terminate_task_error,
367 NULL);
368 total_bytes_sent += sizeof(struct TestMessage);
369 GNUNET_MQ_send (p1.mq,
370 env);
371}
372
373
374static void *
375connect_notify (void *cls,
376 const struct GNUNET_PeerIdentity *peer,
377 struct GNUNET_MQ_Handle *mq)
378{
379 struct PeerContext *pc = cls;
380
381 if (0 == memcmp (&pc->id,
382 peer,
383 sizeof(struct GNUNET_PeerIdentity)))
384 return NULL; /* loopback */
385 GNUNET_assert (0 == pc->connect_status);
386 pc->connect_status = 1;
387 pc->mq = mq;
388 if (pc == &p1)
389 {
390 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
391 "Encrypted connection established to peer `%s'\n",
392 GNUNET_i2s (peer));
393 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
394 "Asking core (1) for transmission to peer `%s'\n",
395 GNUNET_i2s (&p2.id));
396 GNUNET_SCHEDULER_cancel (err_task);
397 err_task =
398 GNUNET_SCHEDULER_add_delayed (TIMEOUT,
399 &terminate_task_error,
400 NULL);
401 start_time = GNUNET_TIME_absolute_get ();
402 running = GNUNET_YES;
403 measure_task =
404 GNUNET_SCHEDULER_add_delayed (MEASUREMENT_LENGTH,
405 &measurement_stop,
406 NULL);
407 do_transmit (NULL);
408 }
409 return pc;
410}
411
412
413static void
414disconnect_notify (void *cls,
415 const struct GNUNET_PeerIdentity *peer,
416 void *internal_cls)
417{
418 struct PeerContext *pc = cls;
419
420 if (NULL == internal_cls)
421 return; /* loopback */
422 pc->connect_status = 0;
423 pc->mq = NULL;
424 if (NULL != measure_task)
425 {
426 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
427 "Measurement aborted due to disconnect!\n");
428 GNUNET_SCHEDULER_cancel (measure_task);
429 measure_task = NULL;
430 }
431 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
432 "Encrypted connection to `%s' cut\n",
433 GNUNET_i2s (peer));
434}
435
436
437static void
438handle_test (void *cls,
439 const struct TestMessage *hdr)
440{
441 static int n;
442
443 total_bytes_recv += sizeof(struct TestMessage);
444 if (ntohl (hdr->num) != n)
445 {
446 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
447 "Expected message %u, got message %u\n",
448 n,
449 ntohl (hdr->num));
450 GNUNET_SCHEDULER_cancel (err_task);
451 err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error,
452 NULL);
453 return;
454 }
455 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
456 "Got message %u\n",
457 ntohl (hdr->num));
458 n++;
459 if (0 == (n % 10))
460 fprintf (stderr, "%s", ".");
461
462 if (GNUNET_YES == running)
463 do_transmit (NULL);
464}
465
466
467static void
468init_notify (void *cls,
469 const struct GNUNET_PeerIdentity *my_identity)
470{
471 struct PeerContext *p = cls;
472 struct GNUNET_MQ_MessageHandler handlers[] = {
473 GNUNET_MQ_hd_fixed_size (test,
474 MTYPE,
475 struct TestMessage,
476 NULL),
477 GNUNET_MQ_handler_end ()
478 };
479
480 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
481 "Connection to CORE service of `%s' established\n",
482 GNUNET_i2s (my_identity));
483 GNUNET_assert (NULL != my_identity);
484 p->id = *my_identity;
485 if (cls == &p1)
486 {
487 GNUNET_assert (ok == 2);
488 OKPP;
489 /* connect p2 */
490 p2.ch = GNUNET_CORE_connect (p2.cfg,
491 &p2,
492 &init_notify,
493 &connect_notify,
494 &disconnect_notify,
495 handlers);
496 }
497 else
498 {
499 GNUNET_assert (ok == 3);
500 OKPP;
501 GNUNET_assert (cls == &p2);
502 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
503 "Asking core (1) to connect to peer `%s' and vice-versa\n",
504 GNUNET_i2s (&p2.id));
505 p1.ats_sh = GNUNET_ATS_connectivity_suggest (p1.ats,
506 &p2.id,
507 1);
508 p2.ats_sh = GNUNET_ATS_connectivity_suggest (p2.ats,
509 &p1.id,
510 1);
511 }
512}
513
514
515static void
516offer_hello_done (void *cls)
517{
518 struct PeerContext *p = cls;
519
520 p->oh = NULL;
521}
522
523
524static void
525process_hello (void *cls,
526 const struct GNUNET_MessageHeader *message)
527{
528 struct PeerContext *p = cls;
529
530 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
531 "Received (my) HELLO from transport service\n");
532 GNUNET_assert (message != NULL);
533 if (NULL != p->hello) GNUNET_free (p->hello);
534 p->hello = GNUNET_malloc (ntohs (message->size));
535 GNUNET_memcpy (p->hello, message, ntohs (message->size));
536 if ((p == &p1) &&
537 (NULL == p2.oh))
538 p2.oh = GNUNET_TRANSPORT_offer_hello (p2.cfg,
539 message,
540 &offer_hello_done,
541 &p2);
542 if ((p == &p2) &&
543 (NULL == p1.oh))
544 p1.oh = GNUNET_TRANSPORT_offer_hello (p1.cfg, message,
545 &offer_hello_done,
546 &p1);
547
548 if ((p == &p1) &&
549 (NULL != p2.hello) &&
550 (NULL == p1.oh))
551 p1.oh = GNUNET_TRANSPORT_offer_hello (p1.cfg,
552 p2.hello,
553 &offer_hello_done,
554 &p1);
555 if ((p == &p2) &&
556 (NULL != p1.hello) &&
557 (NULL == p2.oh))
558 p2.oh = GNUNET_TRANSPORT_offer_hello (p2.cfg,
559 p1.hello,
560 &offer_hello_done,
561 &p2);
562}
563
564
565static void
566setup_peer (struct PeerContext *p,
567 const char *cfgname)
568{
569 char *binary;
570
571 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm");
572 p->cfg = GNUNET_CONFIGURATION_create ();
573 p->arm_proc =
574 GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_OUT_AND_ERR
575 | GNUNET_OS_USE_PIPE_CONTROL,
576 NULL, NULL, NULL,
577 binary,
578 "gnunet-service-arm",
579 "-c",
580 cfgname,
581 NULL);
582 GNUNET_assert (GNUNET_OK ==
583 GNUNET_CONFIGURATION_load (p->cfg,
584 cfgname));
585 p->stats = GNUNET_STATISTICS_create ("core",
586 p->cfg);
587 GNUNET_assert (NULL != p->stats);
588 p->ats = GNUNET_ATS_connectivity_init (p->cfg);
589 GNUNET_assert (NULL != p->ats);
590 p->ghh = GNUNET_TRANSPORT_hello_get (p->cfg,
591 GNUNET_TRANSPORT_AC_ANY,
592 &process_hello,
593 p);
594 GNUNET_free (binary);
595}
596
597
598static void
599run (void *cls,
600 char *const *args,
601 const char *cfgfile,
602 const struct GNUNET_CONFIGURATION_Handle *cfg)
603{
604 struct GNUNET_MQ_MessageHandler handlers[] = {
605 GNUNET_MQ_hd_fixed_size (test,
606 MTYPE,
607 struct TestMessage,
608 NULL),
609 GNUNET_MQ_handler_end ()
610 };
611
612 GNUNET_assert (ok == 1);
613 OKPP;
614 err_task =
615 GNUNET_SCHEDULER_add_delayed (TIMEOUT,
616 &terminate_task_error,
617 NULL);
618 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
619 NULL);
620 if (test == SYMMETRIC)
621 {
622 setup_peer (&p1,
623 "test_core_quota_peer1.conf");
624 setup_peer (&p2,
625 "test_core_quota_peer2.conf");
626 }
627 else if (test == ASYMMETRIC_SEND_LIMITED)
628 {
629 setup_peer (&p1,
630 "test_core_quota_asymmetric_send_limit_peer1.conf");
631 setup_peer (&p2,
632 "test_core_quota_asymmetric_send_limit_peer2.conf");
633 }
634 else if (test == ASYMMETRIC_RECV_LIMITED)
635 {
636 setup_peer (&p1,
637 "test_core_quota_asymmetric_recv_limited_peer1.conf");
638 setup_peer (&p2,
639 "test_core_quota_asymmetric_recv_limited_peer2.conf");
640 }
641
642 GNUNET_assert (test != -1);
643 GNUNET_assert (GNUNET_SYSERR !=
644 GNUNET_CONFIGURATION_get_value_size (p1.cfg,
645 "ATS",
646 "WAN_QUOTA_IN",
647 &current_quota_p1_in));
648 GNUNET_assert (GNUNET_SYSERR !=
649 GNUNET_CONFIGURATION_get_value_size (p2.cfg,
650 "ATS",
651 "WAN_QUOTA_IN",
652 &current_quota_p2_in));
653 GNUNET_assert (GNUNET_SYSERR !=
654 GNUNET_CONFIGURATION_get_value_size (p1.cfg,
655 "ATS",
656 "WAN_QUOTA_OUT",
657 &current_quota_p1_out));
658 GNUNET_assert (GNUNET_SYSERR !=
659 GNUNET_CONFIGURATION_get_value_size (p2.cfg,
660 "ATS",
661 "WAN_QUOTA_OUT",
662 &current_quota_p2_out));
663
664 p1.ch = GNUNET_CORE_connect (p1.cfg,
665 &p1,
666 &init_notify,
667 &connect_notify,
668 &disconnect_notify,
669 handlers);
670}
671
672
673static void
674stop_arm (struct PeerContext *p)
675{
676 if (0 != GNUNET_OS_process_kill (p->arm_proc,
677 GNUNET_TERM_SIG))
678 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
679 "kill");
680 if (GNUNET_OK !=
681 GNUNET_OS_process_wait (p->arm_proc))
682 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
683 "waitpid");
684 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
685 "ARM process %u stopped\n",
686 GNUNET_OS_process_get_pid (p->arm_proc));
687 GNUNET_OS_process_destroy (p->arm_proc);
688 p->arm_proc = NULL;
689 GNUNET_CONFIGURATION_destroy (p->cfg);
690}
691
692
693static int
694check ()
695{
696 char *const argv[] = {
697 "test-core-quota-compliance",
698 "-c",
699 "test_core_api_data.conf",
700 NULL
701 };
702 struct GNUNET_GETOPT_CommandLineOption options[] = {
703 GNUNET_GETOPT_OPTION_END
704 };
705
706 ok = 1;
707 GNUNET_PROGRAM_run ((sizeof(argv) / sizeof(char *)) - 1,
708 argv,
709 "test-core-quota-compliance",
710 "nohelp",
711 options,
712 &run,
713 &ok);
714 stop_arm (&p1);
715 stop_arm (&p2);
716 return ok;
717}
718
719
720static void
721cleanup_directory (int test)
722{
723 switch (test)
724 {
725 case SYMMETRIC:
726 GNUNET_DISK_purge_cfg_dir
727 ("test_core_quota_peer1.conf",
728 "GNUNET_TEST_HOME");
729 GNUNET_DISK_purge_cfg_dir
730 ("test_core_quota_peer2.conf",
731 "GNUNET_TEST_HOME");
732 break;
733
734 case ASYMMETRIC_SEND_LIMITED:
735 GNUNET_DISK_purge_cfg_dir
736 ("test_core_quota_asymmetric_send_limit_peer1.conf",
737 "GNUNET_TEST_HOME");
738 GNUNET_DISK_purge_cfg_dir
739 ("test_core_quota_asymmetric_send_limit_peer2.conf",
740 "GNUNET_TEST_HOME");
741 break;
742
743 case ASYMMETRIC_RECV_LIMITED:
744 GNUNET_DISK_purge_cfg_dir
745 ("test_core_quota_asymmetric_recv_limited_peer1.conf",
746 "GNUNET_TEST_HOME");
747 GNUNET_DISK_purge_cfg_dir
748 ("test_core_quota_asymmetric_recv_limited_peer2.conf",
749 "GNUNET_TEST_HOME");
750 break;
751 }
752}
753
754
755int
756main (int argc,
757 char *argv[])
758{
759 int ret;
760
761 test = -1;
762 if (NULL != strstr (argv[0],
763 "_symmetric"))
764 {
765 test = SYMMETRIC;
766 }
767 else if (NULL != strstr (argv[0],
768 "_asymmetric_send"))
769 {
770 test = ASYMMETRIC_SEND_LIMITED;
771 }
772 else if (NULL != strstr (argv[0],
773 "_asymmetric_recv"))
774 {
775 test = ASYMMETRIC_RECV_LIMITED;
776 }
777 GNUNET_assert (test != -1);
778 cleanup_directory (test);
779 GNUNET_log_setup ("test-core-quota-compliance",
780 "WARNING",
781 NULL);
782 ret = check ();
783 cleanup_directory (test);
784 return ret;
785}
786
787
788/* end of test_core_quota_compliance.c */