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