wip
[oweals/gnunet.git] / src / transport / test_transport_api.c
1 /*
2      This file is part of GNUnet.
3      (C) 2009, 2010 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      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      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20 /**
21  * @file transport/test_transport_api.c
22  * @brief base test case for transport implementations
23  *
24  * This test case serves as a base for tcp, udp, and udp-nat
25  * transport test cases.  Based on the executable being run
26  * the correct test case will be performed.  Conservation of
27  * C code apparently.
28  */
29 #include "platform.h"
30 #include "gnunet_common.h"
31 #include "gnunet_hello_lib.h"
32 #include "gnunet_getopt_lib.h"
33 #include "gnunet_os_lib.h"
34 #include "gnunet_program_lib.h"
35 #include "gnunet_scheduler_lib.h"
36 #include "gnunet_transport_service.h"
37 #include "transport.h"
38
39 #define VERBOSE GNUNET_NO
40
41 #define VERBOSE_ARM GNUNET_NO
42
43 #define START_ARM GNUNET_YES
44
45 /**
46  * How long until we give up on transmitting the message?
47  */
48 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
49
50 /**
51  * How long until we give up on transmitting the message?
52  */
53 #define TIMEOUT_TRANSMIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
54
55 #define MTYPE 12345
56
57 struct PeerContext
58 {
59   struct GNUNET_CONFIGURATION_Handle *cfg;
60   struct GNUNET_TRANSPORT_Handle *th;
61   struct GNUNET_PeerIdentity id;
62 #if START_ARM
63   struct GNUNET_OS_Process *arm_proc;
64 #endif
65 };
66
67 static struct PeerContext p1;
68
69 static struct PeerContext p2;
70
71 static int ok;
72
73 static int is_tcp;
74
75 static int is_tcp_nat;
76
77 static int is_udp;
78
79 static int is_unix;
80
81 static int is_udp_nat;
82
83 static int is_http;
84
85 static int is_https;
86
87 static int is_multi_protocol;
88
89 static int is_wlan;
90
91 static  GNUNET_SCHEDULER_TaskIdentifier die_task;
92
93 static char * key_file_p1;
94 static char * cert_file_p1;
95
96 static char * key_file_p2;
97 static char * cert_file_p2;
98
99 #if VERBOSE
100 #define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
101 #else
102 #define OKPP do { ok++; } while (0)
103 #endif
104
105
106 static void
107 end ()
108 {
109   /* do work here */
110   GNUNET_assert (ok == 6);
111   GNUNET_SCHEDULER_cancel (die_task);
112   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
113   GNUNET_TRANSPORT_disconnect (p1.th);
114   GNUNET_TRANSPORT_disconnect (p2.th);
115
116   die_task = GNUNET_SCHEDULER_NO_TASK;
117   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transports disconnected, returning success!\n");
118   ok = 0;
119 }
120
121 static void
122 stop_arm (struct PeerContext *p)
123 {
124 #if START_ARM
125   if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
126     GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
127   GNUNET_OS_process_wait (p->arm_proc);
128   GNUNET_OS_process_close (p->arm_proc);
129   p->arm_proc = NULL;
130 #endif
131   GNUNET_CONFIGURATION_destroy (p->cfg);
132 }
133
134
135 static void
136 end_badly ()
137 {
138   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
139   GNUNET_break (0);
140   GNUNET_TRANSPORT_disconnect (p1.th);
141   GNUNET_TRANSPORT_disconnect (p2.th);
142   ok = 1;
143 }
144
145 static void
146 notify_receive (void *cls,
147                 const struct GNUNET_PeerIdentity *peer,
148                 const struct GNUNET_MessageHeader *message,
149                 const struct GNUNET_TRANSPORT_ATS_Information *ats,
150                 uint32_t ats_count)
151 {
152   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ok is (%d)!\n",
153               ok);
154
155   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message of type %d from peer (%p)!\n",
156                 ntohs(message->type), cls);
157
158   GNUNET_assert (ok == 5);
159   OKPP;
160
161   GNUNET_assert (MTYPE == ntohs (message->type));
162   GNUNET_assert (sizeof (struct GNUNET_MessageHeader) ==
163                  ntohs (message->size));
164   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message from peer (%p)!\n",
165               cls);
166   end ();
167 }
168
169
170 static size_t
171 notify_ready (void *cls, size_t size, void *buf)
172 {
173   struct GNUNET_MessageHeader *hdr;
174
175   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
176               "Transmitting message to peer (%p) - %u!\n", cls, sizeof (struct GNUNET_MessageHeader));
177   GNUNET_assert (size >= 256);
178   GNUNET_assert (ok == 4);
179   OKPP;
180
181   if (buf != NULL)
182   {
183     hdr = buf;
184     hdr->size = htons (sizeof (struct GNUNET_MessageHeader));
185     hdr->type = htons (MTYPE);
186   }
187
188   return sizeof (struct GNUNET_MessageHeader);
189 }
190
191 static size_t
192 notify_ready_connect (void *cls, size_t size, void *buf)
193 {
194   return 0;
195 }
196
197
198 static void
199 notify_connect (void *cls,
200                 const struct GNUNET_PeerIdentity *peer,
201                 const struct GNUNET_TRANSPORT_ATS_Information *ats,
202                 uint32_t ats_count)
203 {
204   if (cls == &p1)
205     {
206       GNUNET_SCHEDULER_cancel (die_task);
207       die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT,
208                                                &end_badly, NULL);
209
210       GNUNET_TRANSPORT_notify_transmit_ready (p1.th,
211                                               &p2.id,
212                                               256, 0, TIMEOUT, &notify_ready,
213                                               &p1);
214     }
215   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
216               "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
217 }
218
219
220 static void
221 notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
222 {
223   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
224               "Peer `%4s' disconnected (%p)!\n",
225               GNUNET_i2s (peer), cls);
226 }
227
228
229 static void
230 setup_peer (struct PeerContext *p, const char *cfgname)
231 {
232   p->cfg = GNUNET_CONFIGURATION_create ();
233 #if START_ARM
234   p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
235                                         "gnunet-service-arm",
236 #if VERBOSE_ARM
237                                         "-L", "DEBUG",
238 #endif
239                                         "-c", cfgname, NULL);
240 #endif
241   GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
242
243   if (is_https)
244   {
245           struct stat sbuf;
246           if (p==&p1)
247           {
248                   if (GNUNET_CONFIGURATION_have_value (p->cfg,
249                                                                                            "transport-https", "KEY_FILE"))
250                                 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p1);
251                   if (key_file_p1==NULL)
252                           GNUNET_asprintf(&key_file_p1,"https.key");
253                   if (0 == stat (key_file_p1, &sbuf ))
254                   {
255                           if (0 == remove(key_file_p1))
256                               GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing private key file `%s'\n",key_file_p1);
257                           else
258                                   GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove private key file `%s'\n",key_file_p1);
259                   }
260                   if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE"))
261                           GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p1);
262                   if (cert_file_p1==NULL)
263                           GNUNET_asprintf(&cert_file_p1,"https.cert");
264                   if (0 == stat (cert_file_p1, &sbuf ))
265                   {
266                           if (0 == remove(cert_file_p1))
267                               GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing certificate file `%s'\n",cert_file_p1);
268                           else
269                                   GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove existing certificate file `%s'\n",cert_file_p1);
270                   }
271           }
272           else if (p==&p2)
273           {
274                   if (GNUNET_CONFIGURATION_have_value (p->cfg,
275                                                                                            "transport-https", "KEY_FILE"))
276                                 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p2);
277                   if (key_file_p2==NULL)
278                           GNUNET_asprintf(&key_file_p2,"https.key");
279                   if (0 == stat (key_file_p2, &sbuf ))
280                   {
281                           if (0 == remove(key_file_p2))
282                               GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing private key file `%s'\n",key_file_p2);
283                           else
284                                   GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove private key file `%s'\n",key_file_p2);
285                   }
286                   if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE"))
287                           GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p2);
288                   if (cert_file_p2==NULL)
289                           GNUNET_asprintf(&cert_file_p2,"https.cert");
290                   if (0 == stat (cert_file_p2, &sbuf ))
291                   {
292                           if (0 == remove(cert_file_p2))
293                               GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing certificate file `%s'\n",cert_file_p2);
294                           else
295                                   GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove existing certificate file `%s'\n",cert_file_p2);
296                   }
297           }
298   }
299
300   p->th = GNUNET_TRANSPORT_connect (p->cfg,
301                                     NULL, p,
302                                     &notify_receive,
303                                     &notify_connect, &notify_disconnect);
304   GNUNET_assert (p->th != NULL);
305 }
306
307
308 static void
309 exchange_hello_last (void *cls,
310                      const struct GNUNET_MessageHeader *message)
311 {
312   struct PeerContext *me = cls;
313
314   GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, me);
315   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
316               "Exchanging HELLO with peer (%p)!\n", cls);
317   GNUNET_assert (ok >= 3);
318   OKPP;
319   GNUNET_assert (message != NULL);
320   GNUNET_assert (GNUNET_OK ==
321                  GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
322                                       message, &me->id));
323
324   GNUNET_assert(NULL != GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
325                                           &p1.id,
326                                           sizeof (struct GNUNET_MessageHeader), 0,
327                                           TIMEOUT,
328                                           &notify_ready_connect,
329                                           NULL));
330
331   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
332               "Finished exchanging HELLOs, now waiting for transmission!\n");
333 }
334
335 static void
336 exchange_hello (void *cls,
337                 const struct GNUNET_MessageHeader *message)
338 {
339   struct PeerContext *me = cls;
340
341   GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me);
342   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
343               "Exchanging HELLO with peer (%p)!\n", cls);
344   GNUNET_assert (ok >= 2);
345   OKPP;
346   GNUNET_assert (message != NULL);
347   GNUNET_assert (GNUNET_OK ==
348                  GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
349                                       message, &me->id));
350
351   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
352               "Received HELLO size %d\n", GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message));
353
354   GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
355   GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
356 }
357
358
359 static void
360 run (void *cls,
361      char *const *args,
362      const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
363 {
364   GNUNET_assert (ok == 1);
365   OKPP;
366   die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
367                                            &end_badly, NULL);
368
369   if (is_udp)
370     {
371       setup_peer (&p1, "test_transport_api_udp_peer1.conf");
372       setup_peer (&p2, "test_transport_api_udp_peer2.conf");
373     }
374   if (is_unix)
375     {
376       GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Using unix domain socket transport\n");
377       setup_peer (&p1, "test_transport_api_unix_peer1.conf");
378       setup_peer (&p2, "test_transport_api_unix_peer2.conf");
379     }
380   if (is_multi_protocol)
381     {
382       setup_peer (&p1, "test_transport_api_multi_peer1.conf");
383       setup_peer (&p2, "test_transport_api_multi_peer2.conf");
384     }
385   else if (is_tcp)
386     {
387       setup_peer (&p1, "test_transport_api_tcp_peer1.conf");
388       setup_peer (&p2, "test_transport_api_tcp_peer2.conf");
389     }
390   else if (is_tcp_nat)
391     {
392       setup_peer (&p1, "test_transport_api_tcp_nat_peer1.conf");
393       setup_peer (&p2, "test_transport_api_tcp_nat_peer2.conf");
394     }
395   else if (is_udp_nat)
396     {
397       setup_peer (&p1, "test_transport_api_udp_nat_peer1.conf");
398       setup_peer (&p2, "test_transport_api_udp_nat_peer2.conf");
399     }
400   else if (is_http)
401     {
402       setup_peer (&p1, "test_transport_api_http_peer1.conf");
403       setup_peer (&p2, "test_transport_api_http_peer2.conf");
404     }
405   else if (is_https)
406     {
407       setup_peer (&p1, "test_transport_api_https_peer1.conf");
408       setup_peer (&p2, "test_transport_api_https_peer2.conf");
409     }
410   else if (is_wlan)
411     {
412       setup_peer (&p1, "test_transport_api_wlan_peer1.conf");
413       setup_peer (&p2, "test_transport_api_wlan_peer2.conf");
414     }
415   GNUNET_assert(p1.th != NULL);
416   GNUNET_assert(p2.th != NULL);
417
418   GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
419 }
420
421 static int
422 check ()
423 {
424   static char *const argv[] = { "test-transport-api",
425     "-c",
426     "test_transport_api_data.conf",
427 #if VERBOSE
428     "-L", "DEBUG",
429 #endif
430     NULL
431   };
432   static struct GNUNET_GETOPT_CommandLineOption options[] = {
433     GNUNET_GETOPT_OPTION_END
434   };
435
436 #if WRITECONFIG
437   setTransportOptions("test_transport_api_data.conf");
438 #endif
439   ok = 1;
440   GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
441                       argv, "test-transport-api", "nohelp",
442                       options, &run, &ok);
443   stop_arm (&p1);
444   stop_arm (&p2);
445
446   if (is_https)
447   {
448           struct stat sbuf;
449           if (0 == stat (cert_file_p1, &sbuf ))
450           {
451                   if (0 == remove(cert_file_p1))
452                           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed existing certificate file `%s'\n",cert_file_p1);
453                   else
454                           GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove certfile `%s'\n",cert_file_p1);
455           }
456
457           if (0 == stat (key_file_p1, &sbuf ))
458           {
459                   if (0 == remove(key_file_p1))
460                           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed private key file `%s'\n",key_file_p1);
461                   else
462                           GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to private key file `%s'\n",key_file_p1);
463           }
464
465           if (0 == stat (cert_file_p2, &sbuf ))
466           {
467                   if (0 == remove(cert_file_p2))
468                           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed existing certificate file `%s'\n",cert_file_p2);
469                   else
470                           GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove certfile `%s'\n",cert_file_p2);
471           }
472
473           if (0 == stat (key_file_p2, &sbuf ))
474           {
475                   if (0 == remove(key_file_p2))
476                           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed private key file `%s'\n",key_file_p2);
477                   else
478                           GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to private key file `%s'\n",key_file_p2);
479           }
480           GNUNET_free(key_file_p1);
481           GNUNET_free(key_file_p2);
482           GNUNET_free(cert_file_p1);
483           GNUNET_free(cert_file_p2);
484   }
485   return ok;
486 }
487
488 /**
489  * Return the actual path to a file found in the current
490  * PATH environment variable.
491  *
492  * @param binary the name of the file to find
493  */
494 static char *
495 get_path_from_PATH (char *binary)
496 {
497   char *path;
498   char *pos;
499   char *end;
500   char *buf;
501   const char *p;
502
503   p = getenv ("PATH");
504   if (p == NULL)
505     {
506       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
507                   _("PATH environment variable is unset.\n"));
508       return NULL;
509     }
510   path = GNUNET_strdup (p);     /* because we write on it */
511   buf = GNUNET_malloc (strlen (path) + 20);
512   pos = path;
513
514   while (NULL != (end = strchr (pos, PATH_SEPARATOR)))
515     {
516       *end = '\0';
517       sprintf (buf, "%s/%s", pos, binary);
518       if (GNUNET_DISK_file_test (buf) == GNUNET_YES)
519         {
520           GNUNET_free (path);
521           return buf;
522         }
523       pos = end + 1;
524     }
525   sprintf (buf, "%s/%s", pos, binary);
526   if (GNUNET_DISK_file_test (buf) == GNUNET_YES)
527     {
528       GNUNET_free (path);
529       return buf;
530     }
531   GNUNET_free (buf);
532   GNUNET_free (path);
533   return NULL;
534 }
535
536 /**
537  * Check whether the suid bit is set on a file.
538  * Attempts to find the file using the current
539  * PATH environment variable as a search path.
540  *
541  * @param binary the name of the file to check
542  *
543  * @return GNUNET_YES if the binary is found and
544  *         can be run properly, GNUNET_NO otherwise
545  */
546 static int
547 check_gnunet_nat_binary(char *binary)
548 {
549   struct stat statbuf;
550   char *p;
551 #ifdef MINGW
552   SOCKET rawsock;
553 #endif
554
555 #ifdef MINGW
556   char *binaryexe;
557   GNUNET_asprintf (&binaryexe, "%s.exe", binary);
558   p = get_path_from_PATH (binaryexe);
559   free (binaryexe);
560 #else
561   p = get_path_from_PATH (binary);
562 #endif
563   if (p == NULL)
564     {
565       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
566                   _("Could not find binary `%s' in PATH!\n"),
567                   binary);
568       return GNUNET_NO;
569     }
570   if (0 != STAT (p, &statbuf))
571     {
572       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
573                   _("stat (%s) failed: %s\n"),
574                   p,
575                   STRERROR (errno));
576       GNUNET_free (p);
577       return GNUNET_SYSERR;
578     }
579   GNUNET_free (p);
580 #ifndef MINGW
581   if ( (0 != (statbuf.st_mode & S_ISUID)) &&
582        (statbuf.st_uid == 0) )
583     return GNUNET_YES;
584   return GNUNET_NO;
585 #else
586   rawsock = socket (AF_INET, SOCK_RAW, IPPROTO_ICMP);
587   if (INVALID_SOCKET == rawsock)
588     {
589       DWORD err = GetLastError ();
590       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
591                   "socket (AF_INET, SOCK_RAW, IPPROTO_ICMP) have failed! GLE = %d\n", err);
592       return GNUNET_NO; /* not running as administrator */
593     }
594   closesocket (rawsock);
595   return GNUNET_YES;
596 #endif
597 }
598
599 int
600 main (int argc, char *argv[])
601 {
602   int ret;
603 #ifdef MINGW
604   return GNUNET_SYSERR;
605 #endif
606
607   GNUNET_log_setup ("test-transport-api",
608 #if VERBOSE
609                     "DEBUG",
610 #else
611                     "WARNING",
612 #endif
613                     NULL);
614
615   if (strstr(argv[0], "tcp_nat") != NULL)
616     {
617       is_tcp_nat = GNUNET_YES;
618       if (GNUNET_YES != check_gnunet_nat_binary("gnunet-nat-server"))
619         {
620           GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
621                       "`%s' not properly installed, cannot run NAT test!\n",
622                       "gnunet-nat-server");
623           return 0;
624         }
625     }
626   else if (strstr(argv[0], "tcp") != NULL)
627     {
628       is_tcp = GNUNET_YES;
629     }
630   else if (strstr(argv[0], "udp_nat") != NULL)
631     {
632       is_udp_nat = GNUNET_YES;
633       if (GNUNET_YES != check_gnunet_nat_binary("gnunet-nat-server"))
634         {
635           GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
636                       "`%s' not properly installed, cannot run NAT test!\n",
637                       "gnunet-nat-server");
638           return 0;
639         }
640     }
641   else if (strstr(argv[0], "udp") != NULL)
642     {
643       is_udp = GNUNET_YES;
644     }
645   else if (strstr(argv[0], "unix") != NULL)
646     {
647       is_unix = GNUNET_YES;
648     }
649   else if (strstr(argv[0], "https") != NULL)
650     {
651       is_https = GNUNET_YES;
652     }
653   else if (strstr(argv[0], "http") != NULL)
654     {
655       is_http = GNUNET_YES;
656     }
657   else if (strstr(argv[0], "wlan") != NULL)
658     {
659        is_wlan = GNUNET_YES;
660     }
661   else if (strstr(argv[0], "multi") != NULL)
662     {
663        is_multi_protocol = GNUNET_YES;
664     }
665
666   ret = check ();
667   if (is_multi_protocol)
668   {
669          GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-multi-peer-1/");
670          GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-multi-peer-2/");
671   }
672   else
673   {
674          GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-1");
675          GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-transport-peer-2");
676   }
677
678   return ret;
679 }
680
681 /* end of test_transport_api.c */