adapting testcases to use new API
[oweals/gnunet.git] / src / transport / test_plugin_transport_http.c
1 /*
2      This file is part of GNUnet.
3      (C) 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_plugin_transport_http.c
22  * @brief testcase for plugin_transport_http.c
23  * @author Matthias Wachs
24  */
25
26 #include "platform.h"
27 #include "gnunet_constants.h"
28 #include "gnunet_common.h"
29 #include "gnunet_getopt_lib.h"
30 #include "gnunet_hello_lib.h"
31 #include "gnunet_os_lib.h"
32 #include "gnunet_peerinfo_service.h"
33 #include "gnunet_plugin_lib.h"
34 #include "gnunet_protocols.h"
35 #include "gnunet_program_lib.h"
36 #include "gnunet_signatures.h"
37 #include "gnunet_service_lib.h"
38 #include "gnunet_crypto_lib.h"
39
40 #include "gnunet_transport_plugin.h"
41 #include "gnunet_statistics_service.h"
42 #include "transport.h"
43 #include <curl/curl.h>
44
45 #define VERBOSE GNUNET_NO
46 #define DEBUG_CURL GNUNET_NO
47 #define HTTP_BUFFER_SIZE 2048
48
49 #define PROTOCOL_PREFIX "http"
50
51 #define PLUGIN libgnunet_plugin_transport_template
52
53 /**
54  * How long until we give up on transmitting the message?
55  */
56 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
57
58 /**
59  * Testcase timeout
60  */
61 #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20)
62
63 /**
64  * How long between recieve and send?
65  */
66 #define WAIT_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
67
68
69
70 /**
71  *  Struct for plugin addresses
72  */
73 struct Plugin_Address
74 {
75   /**
76    * Next field for linked list
77    */
78   struct Plugin_Address * next;
79
80   /**
81    * buffer containing data to send
82    */
83   void * addr;
84
85   /**
86    * amount of data to sent
87    */
88   size_t addrlen;
89 };
90
91 /**
92  *  Message to send using http
93  */
94 struct HTTP_Message
95 {
96   /**
97    * buffer
98    */
99   unsigned char buf[HTTP_BUFFER_SIZE];
100
101   /**
102    * current position in buffer
103    */
104   size_t pos;
105
106   /**
107    * buffer size
108    */
109   size_t size;
110
111   /**
112    * data size
113    */
114   size_t len;
115 };
116
117
118 /**
119  *  Struct for plugin addresses
120  */
121 struct HTTP_Transfer
122 {
123   /**
124    * amount of bytes we recieved
125    */
126   size_t data_size;
127
128   /**
129    * buffer for http transfers
130    */
131   unsigned char buf[HTTP_BUFFER_SIZE];
132
133   /**
134    * buffer size this transfer
135    */
136   size_t size;
137
138   /**
139    * amount of bytes we recieved
140    */
141   size_t pos;
142
143   /**
144    * HTTP Header result for transfer
145    */
146   unsigned int http_result_code;
147
148   /**
149    * did the test fail?
150    */
151   unsigned int test_failed;
152
153   /**
154    * was this test already executed?
155    */
156   unsigned int test_executed;
157 };
158
159
160 /**
161  * Network format for IPv4 addresses.
162  */
163 struct IPv4HttpAddress
164 {
165   struct IPv4HttpAddress * next;
166
167   struct IPv4HttpAddress * prev;
168
169   /**
170    * IPv4 address, in network byte order.
171    */
172   uint32_t ipv4_addr GNUNET_PACKED;
173
174   /**
175    * Port number, in network byte order.
176    */
177   uint16_t u_port GNUNET_PACKED;
178
179 };
180
181
182 /**
183  * Network format for IPv6 addresses.
184  */
185 struct IPv6HttpAddress
186 {
187   struct IPv6HttpAddress * next;
188
189   struct IPv6HttpAddress * prev;
190
191   /**
192    * IPv6 address.
193    */
194   struct in6_addr ipv6_addr GNUNET_PACKED;
195
196   /**
197    * Port number, in network byte order.
198    */
199   uint16_t u6_port GNUNET_PACKED;
200
201 };
202
203
204 /**
205  * Our public key.
206  */
207 /* static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded my_public_key; */
208
209 /**
210  * Our public key.
211  */
212 static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded my_public_key;
213
214 /**
215  * Our identity.
216  */
217 static struct GNUNET_PeerIdentity my_identity;
218
219 /**
220  * Our private key.
221  */
222 static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key;
223
224 /**
225  * Peer's port
226  */
227 static long long unsigned int port;
228
229 /**
230  * Peer's addr
231  */
232 static char * test_addr;
233
234 /**
235  * Our statistics handle.
236  */
237 struct GNUNET_STATISTICS_Handle *stats;
238
239
240 /**
241  * Our configuration.
242  */
243 const struct GNUNET_CONFIGURATION_Handle *cfg;
244
245 /**
246  * Number of neighbours we'd like to have.
247  */
248 static uint32_t max_connect_per_transport;
249
250 /**
251  * Environment for this plugin.
252  */
253 static struct GNUNET_TRANSPORT_PluginEnvironment env;
254
255 /**
256  *handle for the api provided by this plugin
257  */
258 static struct GNUNET_TRANSPORT_PluginFunctions *api;
259
260 /**
261  * ID of the task controlling the testcase timeout
262  */
263 static GNUNET_SCHEDULER_TaskIdentifier ti_timeout;
264
265 static GNUNET_SCHEDULER_TaskIdentifier ti_send;
266
267 //const struct GNUNET_PeerIdentity * p;
268
269 /**
270  * buffer for data to send
271  */
272 static struct HTTP_Message buffer_out;
273
274 /**
275  * buffer for data to recieve
276  */
277 static struct HTTP_Message buffer_in;
278
279
280 struct Plugin_Address * addr_head;
281
282 /**
283  * Did the test pass or fail?
284  */
285 static int fail_notify_address;
286 /**
287  * Did the test pass or fail?
288  */
289 static int fail_notify_address_count;
290
291 /**
292  * Did the test pass or fail?
293  */
294 static int fail_pretty_printer;
295
296 /**
297  * Did the test pass or fail?
298  */
299 static int fail_pretty_printer_count;
300
301 /**
302  * Did the test pass or fail?
303  */
304 static int fail_addr_to_str;
305
306 /**
307  * No. of msgs transmitted successfully to local addresses
308  */
309 static int fail_msgs_transmited_to_local_addrs;
310
311 /**
312  * Test: transmit msg of max. size
313  */
314 static int fail_msg_transmited_bigger_max_size;
315
316 /**
317  * Test: transmit msg of max. size
318  */
319 static int fail_msg_transmited_max_size;
320
321 /**
322  * Test: transmit 2 msgs. in in send operation
323  */
324 static int fail_multiple_msgs_in_transmission;
325
326 /**
327  * Test: connect to peer without peer identification
328  */
329 static struct HTTP_Transfer test_no_ident;
330
331 /**
332  * Test: connect to peer without peer identification
333  */
334 static struct HTTP_Transfer test_too_short_ident;
335
336 /**
337  * Test: connect to peer without peer identification
338  */
339 static struct HTTP_Transfer test_too_long_ident;
340
341 /**
342  * Test: connect to peer with valid peer identification
343  */
344 static struct HTTP_Transfer test_valid_ident;
345
346 /**
347  * Test: session selection, use any existing
348  */
349 static int fail_session_selection_any;
350
351 /**
352  * Test: session selection, use existing inbound session
353  */
354 static int fail_session_selection_session;
355
356 /**
357  * Test: session selection, use existing inbound session
358  * max message, not fitting in send & recv buffers at one time
359  */
360 static int fail_session_selection_session_big;
361
362 /**
363 * Test: session selection, use reliable existing
364  */
365 static int fail_session_selection_reliable;
366
367 /**
368  * Did the test pass or fail?
369  */
370 static int fail;
371
372 /**
373  * Number of local addresses
374  */
375 static unsigned int count_str_addr;
376
377 CURL *curl_handle;
378
379 /**
380  * cURL Multihandle
381  */
382 static CURLM *multi_handle;
383
384 /**
385  * The task sending data
386  */
387 static GNUNET_SCHEDULER_TaskIdentifier http_task_send;
388
389 /**
390  * Shutdown testcase
391  */
392 static void
393 shutdown_clean ()
394 {
395   struct Plugin_Address * tmp;
396
397   /* Evaluate results  */
398   fail = 0;
399   if ( (fail_notify_address == GNUNET_YES) || 
400        (fail_pretty_printer == GNUNET_YES) || 
401        (fail_addr_to_str == GNUNET_YES))
402     {
403       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
404                   "Phase 0: Test plugin functions failed\n");
405       fail = 1;
406     }
407   if ( (test_no_ident.test_failed == GNUNET_YES) || 
408        (test_too_short_ident.test_failed == GNUNET_YES) || 
409        (test_too_long_ident.test_failed == GNUNET_YES) || 
410        (test_valid_ident.test_failed == GNUNET_YES) )
411   {
412     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
413                 "Phase 1: Test connect with wrong data failed\n");
414     fail = 1;
415   }
416   if ( (fail_session_selection_any != GNUNET_NO) || 
417        (fail_session_selection_reliable != GNUNET_NO) ||
418        (fail_session_selection_session != GNUNET_NO) || 
419        (fail_session_selection_session_big != GNUNET_NO) )
420     {
421       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
422                   "Phase 2: Test session selection failed\n");
423       fail = 1;
424     }
425   if ( (fail_msgs_transmited_to_local_addrs != count_str_addr) ||
426        (fail_multiple_msgs_in_transmission != 2) || 
427        (fail_msg_transmited_max_size == GNUNET_YES) )
428     {
429       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
430                   "Phase 3: Test sending with plugin failed\n");
431       fail = 1;
432     }
433   if (fail != 1)
434     {
435       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
436                   "All tests successful\n");
437     }
438   
439   api->disconnect(api->cls,&my_identity);
440
441   curl_multi_cleanup(multi_handle);
442
443   if (NULL != curl_handle)
444     curl_easy_cleanup (curl_handle);
445
446   /* cleaning addresses */
447   while (addr_head != NULL)
448   {
449     tmp = addr_head->next;
450     GNUNET_free (addr_head->addr);
451     GNUNET_free (addr_head);
452     addr_head=tmp;
453   }
454
455   if (ti_send != GNUNET_SCHEDULER_NO_TASK)
456   {
457     GNUNET_SCHEDULER_cancel(ti_send);
458     ti_send = GNUNET_SCHEDULER_NO_TASK;
459   }
460
461   if (http_task_send != GNUNET_SCHEDULER_NO_TASK)
462   {
463     GNUNET_SCHEDULER_cancel(http_task_send);
464     http_task_send = GNUNET_SCHEDULER_NO_TASK;
465   }
466
467   if (ti_timeout != GNUNET_SCHEDULER_NO_TASK)
468   {
469     GNUNET_SCHEDULER_cancel(ti_timeout);
470     ti_timeout = GNUNET_SCHEDULER_NO_TASK;
471   }
472
473   GNUNET_free(test_addr);
474   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
475               "Unloading http plugin\n");
476   GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_gnunet_transport_plugin_http", api));
477
478   GNUNET_SCHEDULER_shutdown();
479   GNUNET_DISK_directory_remove ("/tmp/test_gnunet_transport_plugin_http");
480
481   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
482               "Exiting testcase\n");
483   exit(fail);
484   return;
485 }
486
487
488 /**
489  * Continuation called after plugin send message
490  * @cls closure
491  * @target target
492  * @result GNUNET_OK or GNUNET_SYSERR
493  */
494
495 static void
496 task_send_cont (void *cls,
497                 const struct GNUNET_PeerIdentity * target,
498                 int result)
499 {
500   if ((cls == &fail_msg_transmited_bigger_max_size) && (result == GNUNET_SYSERR))
501     {
502       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
503                   "Message bigger max msg size was not sent!\n");
504       fail_msg_transmited_bigger_max_size = GNUNET_NO;
505       return;
506     }
507
508   if ((cls == &fail_msg_transmited_max_size) && (result == GNUNET_OK))
509     {
510       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
511                   "Message with max msg size succesfully sent!\n",
512                   fail_msgs_transmited_to_local_addrs);
513       fail_msg_transmited_max_size = GNUNET_NO;
514     }
515 }
516
517
518 static void run_connection_tests( int phase , void * cls);
519
520 /**
521  * Recieves messages from plugin, in real world transport
522  */
523 static struct GNUNET_TIME_Relative
524 receive (void *cls, const struct GNUNET_PeerIdentity *peer,
525         const struct GNUNET_MessageHeader *message,
526         const struct GNUNET_TRANSPORT_ATS_Information *ats,
527         uint32_t ats_count,
528         struct Session *session,
529         const char *sender_address,
530         uint16_t sender_address_len)
531 {
532   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
533               "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n",
534               GNUNET_i2s(peer), 
535               ntohs(message->type), 
536               ntohs(message->size),
537               session);
538
539   if ( (ntohs(message->type)>=10) && 
540        (ntohs(message->type)<20) )
541     {
542       fail_msgs_transmited_to_local_addrs++;
543       if (fail_msgs_transmited_to_local_addrs == count_str_addr)
544         run_connection_tests(2, session);
545     }
546   if ((ntohs(message->type)==20))
547     {
548       fail_session_selection_reliable = GNUNET_NO;
549     }  
550   if ((ntohs(message->type)==21))
551     {
552       fail_session_selection_any = GNUNET_NO;
553     }
554   if ((ntohs(message->type)==22))
555     {
556       fail_session_selection_session = GNUNET_NO;
557     }  
558   if ((ntohs(message->type)==23))
559     {
560       fail_session_selection_session_big = GNUNET_NO;
561       run_connection_tests(3, NULL);
562     }  
563   if ((ntohs(message->type)==30) || (ntohs(message->type)==31))
564     {
565       fail_multiple_msgs_in_transmission ++;
566     }  
567   if ((ntohs(message->type)==32) && (ntohs(message->size) == GNUNET_SERVER_MAX_MESSAGE_SIZE-1))
568     {
569       fail_msg_transmited_max_size = GNUNET_NO;
570       shutdown_clean();
571     }  
572   return GNUNET_TIME_UNIT_ZERO;
573 }
574
575
576 static size_t 
577 send_function (void *stream, size_t size, size_t nmemb, void *ptr)
578 {
579   unsigned int len;
580
581   len = buffer_out.len;
582
583   if (( buffer_out.pos == len) || (len > (size * nmemb)))
584     return 0;
585   memcpy(stream, buffer_out.buf, len);
586   buffer_out.pos = len;
587   return len;
588
589 }
590
591 static size_t 
592 recv_function (void *ptr, size_t size, size_t nmemb, void *ctx)
593 {
594
595   if (buffer_in.pos + size * nmemb > buffer_in.size)
596     return 0;                   /* overflow */
597
598   buffer_in.len = size * nmemb;
599   memcpy (&buffer_in.buf[buffer_in.pos], ptr, size * nmemb);
600   buffer_in.pos += size * nmemb;
601   buffer_in.len = buffer_in.pos;
602   buffer_in.buf[buffer_in.pos] = '\0';
603   return buffer_in.pos;
604 }
605
606 static size_t
607 header_function( void *ptr, size_t size, size_t nmemb, void *stream)
608 {
609   struct HTTP_Transfer * res = stream;
610   char * tmp;
611   unsigned int len = size * nmemb;
612
613   tmp = GNUNET_malloc (  len+1 );
614   memcpy(tmp,ptr,len);
615   if (tmp[len-2] == 13)
616     tmp[len-2]= '\0';
617 #if DEBUG_CURL
618   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
619               "Header: `%s'\n",
620               tmp);
621 #endif
622   if (0==strcmp (tmp,"HTTP/1.1 100 Continue"))
623     {
624       res->http_result_code=100;
625     }
626   if (0==strcmp (tmp,"HTTP/1.1 200 OK"))
627     {
628       res->http_result_code=200;
629     }
630   if (0==strcmp (tmp,"HTTP/1.1 400 Bad Request"))
631     {
632       res->http_result_code=400;
633     }
634   if (0==strcmp (tmp,"HTTP/1.1 404 Not Found"))
635     {
636       res->http_result_code=404;
637     }
638   if (0==strcmp (tmp,"HTTP/1.1 413 Request entity too large"))
639     {
640       res->http_result_code=413;
641     }
642   
643   GNUNET_free (tmp);
644   return size * nmemb;
645 }
646
647
648 static size_t 
649 send_prepare( struct HTTP_Transfer * result);
650
651
652 static void 
653 send_execute (void *cls,
654               const struct GNUNET_SCHEDULER_TaskContext *tc)
655 {
656   struct HTTP_Transfer *res;
657
658   int running;
659   struct CURLMsg *msg;
660   CURLMcode mret;
661
662   res = (struct HTTP_Transfer *) cls;
663   http_task_send = GNUNET_SCHEDULER_NO_TASK;
664   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
665     return;
666
667   do
668     {
669       running = 0;
670       mret = curl_multi_perform (multi_handle, &running);
671       if (running == 0)
672         {
673           do
674             {
675
676               msg = curl_multi_info_read (multi_handle, &running);
677               if (msg == NULL)
678                 break;
679               /* get session for affected curl handle */
680               //cs = find_session_by_curlhandle (msg->easy_handle);
681               //GNUNET_assert ( cs != NULL );
682               switch (msg->msg)
683                 {
684
685                 case CURLMSG_DONE:
686                   if ( (msg->data.result != CURLE_OK) &&
687                        (msg->data.result != CURLE_GOT_NOTHING) )
688                     {
689
690                     GNUNET_log(GNUNET_ERROR_TYPE_INFO,
691                                _("curl failed for `%s' at %s:%d: `%s'\n"),
692                                "curl_multi_perform",
693                                __FILE__,
694                                __LINE__,
695                                curl_easy_strerror (msg->data.result));
696                     /* sending msg failed*/
697                     curl_easy_cleanup(curl_handle);
698                     curl_handle=NULL;
699
700                     run_connection_tests(0, NULL);
701                     }
702                   if (res == &test_no_ident)
703                   {
704                     if  ((res->http_result_code==404) && (buffer_in.len==208))
705                       {
706                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
707                                   "Connecting to peer without any peer identification: test passed\n");
708                       res->test_failed = GNUNET_NO;
709                     }
710                     else
711                       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
712                                   _("Connecting to peer without any peer identification: test failed\n"));
713                   }
714                   if (res == &test_too_short_ident)
715                   {
716                     if  ((res->http_result_code==404) && (buffer_in.len==208))
717                     {
718                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
719                                   "Connecting to peer with too short peer identification: test passed\n");
720                       res->test_failed = GNUNET_NO;
721                     }
722                     else
723                       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
724                                   _("Connecting to peer with too short peer identification: test failed\n"));
725                   }
726                   if (res == &test_too_long_ident)
727                   {
728                     if  ((res->http_result_code==404) && (buffer_in.len==208))
729                       {
730                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
731                                   "Connecting to peer with too long peer identification: test passed\n");
732                       res->test_failed = GNUNET_NO;
733                       }
734                     else
735                       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
736                                   _("Connecting to peer with too long peer identification: test failed\n"));
737                   }
738                   if (res == &test_valid_ident)
739                   {
740                     if  ((res->http_result_code==200))
741                     {
742                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
743                                   "Connecting to peer with valid peer identification: test passed\n");
744                       res->test_failed = GNUNET_NO;
745                     }
746                     else
747                       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
748                                   "Connecting to peer with valid peer identification: test failed\n");
749                   }
750                   curl_easy_cleanup(curl_handle);
751                   curl_handle=NULL;
752                   if ((res == &test_valid_ident) && (res->test_failed == GNUNET_NO))
753                     run_connection_tests(1, NULL);
754                   run_connection_tests(0, NULL);
755                   return;
756                 default:
757                   break;
758                 }
759
760             }
761           while ( (running > 0) );
762         }
763     }
764   while (mret == CURLM_CALL_MULTI_PERFORM);
765   send_prepare(cls);
766 }
767
768
769 /**
770  * Function setting up file descriptors and scheduling task to run
771  * @param ses session to send data to
772  * @return bytes sent to peer
773  */
774 static size_t
775 send_prepare( struct HTTP_Transfer * result)
776 {
777   fd_set rs;
778   fd_set ws;
779   fd_set es;
780   int max;
781   struct GNUNET_NETWORK_FDSet *grs;
782   struct GNUNET_NETWORK_FDSet *gws;
783   long to;
784   CURLMcode mret;
785
786   max = -1;
787   FD_ZERO (&rs);
788   FD_ZERO (&ws);
789   FD_ZERO (&es);
790   mret = curl_multi_fdset (multi_handle, &rs, &ws, &es, &max);
791   if (mret != CURLM_OK)
792     {
793       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
794                   _("%s failed at %s:%d: `%s'\n"),
795                   "curl_multi_fdset", __FILE__, __LINE__,
796                   curl_multi_strerror (mret));
797       return -1;
798     }
799   mret = curl_multi_timeout (multi_handle, &to);
800   if (mret != CURLM_OK)
801     {
802       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
803                   _("%s failed at %s:%d: `%s'\n"),
804                   "curl_multi_timeout", __FILE__, __LINE__,
805                   curl_multi_strerror (mret));
806       return -1;
807     }
808
809   grs = GNUNET_NETWORK_fdset_create ();
810   gws = GNUNET_NETWORK_fdset_create ();
811   GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1);
812   GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1);
813   http_task_send = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
814                                                 GNUNET_SCHEDULER_NO_TASK,
815                                                 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0),
816                                                 grs,
817                                                 gws,
818                                                 &send_execute,
819                                                 result);
820   GNUNET_NETWORK_fdset_destroy (gws);
821   GNUNET_NETWORK_fdset_destroy (grs);
822
823   /* FIXME: return bytes REALLY sent */
824   return 0;
825 }
826
827 /**
828  * function to send data to server
829  */
830 static int 
831 send_data(struct HTTP_Transfer * result,
832           char * url)
833 {
834
835   curl_handle = curl_easy_init();
836   if( NULL == curl_handle)
837     {
838       printf("easy_init failed \n");
839       return GNUNET_SYSERR;
840     }
841 #if DEBUG_CURL
842   curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L);
843 #endif
844   curl_easy_setopt(curl_handle, CURLOPT_URL, url);
845   curl_easy_setopt(curl_handle, CURLOPT_PUT, 1L);
846   curl_easy_setopt (curl_handle, CURLOPT_HEADERFUNCTION, &header_function);
847   curl_easy_setopt (curl_handle, CURLOPT_WRITEHEADER, result);
848   curl_easy_setopt (curl_handle, CURLOPT_WRITEFUNCTION, &recv_function);
849   curl_easy_setopt (curl_handle, CURLOPT_WRITEDATA, result);
850   curl_easy_setopt (curl_handle, CURLOPT_READFUNCTION, &send_function);
851   curl_easy_setopt (curl_handle, CURLOPT_READDATA, result);
852   curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t) buffer_out.len);
853   curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, 30);
854   curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT, 20);
855
856   curl_multi_add_handle(multi_handle, curl_handle);
857
858   send_prepare(result);
859
860   return GNUNET_OK;
861 }
862
863 /**
864  * Plugin notifies transport (aka testcase) about its addresses
865  */
866 static void
867 notify_address (void *cls,
868                 const char *name,
869                 const void *addr,
870                 uint16_t addrlen,
871                 struct GNUNET_TIME_Relative expires)
872 {
873   char address[INET6_ADDRSTRLEN];
874   unsigned int port;
875   struct Plugin_Address * pl_addr;
876   struct Plugin_Address * cur;
877
878   if (addrlen == (sizeof (struct IPv4HttpAddress)))
879     {
880       inet_ntop(AF_INET, (struct in_addr *) addr,address,INET_ADDRSTRLEN);
881       port = ntohs(((struct IPv4HttpAddress *) addr)->u_port);
882     }
883   else if (addrlen == (sizeof (struct IPv6HttpAddress)))
884     {
885       inet_ntop(AF_INET6, (struct in6_addr *) addr,address,INET6_ADDRSTRLEN);
886       port = ntohs(((struct IPv6HttpAddress *) addr)->u6_port);
887     }
888   else
889     {
890     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
891                 _("Unknown address size: ipv6 has %u ipv4 has %u but this has %u\n"),
892                 sizeof (struct IPv6HttpAddress),
893                 sizeof (struct IPv4HttpAddress),
894                 addrlen);
895       return;
896     }
897   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
898               _("Transport plugin notification for address: `%s':%u\n"),
899               address,
900               port);
901   pl_addr = GNUNET_malloc (sizeof (struct Plugin_Address) );
902   pl_addr->addrlen = addrlen;
903   pl_addr->addr = GNUNET_malloc(addrlen);
904   memcpy(pl_addr->addr,addr,addrlen);
905   pl_addr->next = NULL;
906
907   if ( NULL == addr_head)
908     {
909       addr_head = pl_addr;
910     }
911   else
912     {
913       cur = addr_head;
914       while (NULL != cur->next)
915         {
916           cur = cur->next;
917         }
918       cur->next = pl_addr;
919     }
920   fail_notify_address_count++;
921   fail_notify_address = GNUNET_NO;
922 }
923
924 static void
925 plugin_env_session_end (void *cls,
926                         const struct GNUNET_PeerIdentity *peer,
927                         struct Session *session)
928 {
929   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
930               "Pluging tells me: session %X to peer `%s' ended\n", 
931               session, 
932               GNUNET_i2s(peer));
933 }
934
935
936 /**
937  * Setup plugin environment
938  */
939 static void
940 setup_plugin_environment ()
941 {
942   env.cfg = cfg;
943   env.stats = stats;
944   env.my_identity = &my_identity;
945   env.cls = &env;
946   env.receive = &receive;
947   env.notify_address = &notify_address;
948   env.max_connections = max_connect_per_transport;
949   env.session_end = &plugin_env_session_end;
950 }
951
952
953 /**
954  * Task shutting down testcase if it a timeout occurs
955  */
956 static void
957 task_timeout (void *cls,
958             const struct GNUNET_SCHEDULER_TaskContext *tc)
959 {
960   ti_timeout = GNUNET_SCHEDULER_NO_TASK;
961   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
962     return;
963
964   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase timeout\n");
965   fail = GNUNET_YES;
966   shutdown_clean();
967   return;
968 }
969
970
971 static void 
972 pretty_printer_cb (void *cls,
973                    const char *address)
974 {
975   if (NULL==address)
976     return;
977   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
978               "Plugin returned pretty address: `%s'\n",
979               address);
980   fail_pretty_printer_count++;
981 }
982
983 /**
984  * Runs every single test to test the plugin
985  */
986 static void 
987 run_connection_tests( int phase , void * cls)
988 {
989   struct GNUNET_MessageHeader * msg;
990   unsigned int size;
991
992   if (phase==0)
993   {
994     char * host_str = NULL;
995     /* resetting buffers */
996     buffer_in.size = HTTP_BUFFER_SIZE;
997     buffer_in.pos = 0;
998     buffer_in.len = 0;
999
1000     buffer_out.size = HTTP_BUFFER_SIZE;
1001     buffer_out.pos = 0;
1002     buffer_out.len = 0;
1003
1004     if (test_no_ident.test_executed == GNUNET_NO)
1005       {
1006         /* Connecting to peer without identification */
1007         const char * ident = "";
1008         GNUNET_asprintf (&host_str,
1009                          "%s://%s/%s",
1010                          PROTOCOL_PREFIX, 
1011                          test_addr,ident);
1012         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
1013                     _("Connecting to peer without any peer identification.\n"));
1014         test_no_ident.test_executed = GNUNET_YES;
1015         send_data ( &test_no_ident, host_str);
1016         GNUNET_free (host_str);
1017         return;
1018       }
1019     if (test_too_short_ident.test_executed == GNUNET_NO)
1020       {
1021         const char * ident = "AAAAAAAAAA";
1022         /* Connecting to peer with too short identification */
1023         GNUNET_asprintf (&host_str, 
1024                          "%s://%s/%s",
1025                          PROTOCOL_PREFIX,
1026                          test_addr,
1027                          ident);
1028         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
1029                     _("Connecting to peer with too short peer identification.\n"));
1030         test_too_short_ident.test_executed = GNUNET_YES;
1031         send_data ( &test_too_short_ident, host_str);
1032         GNUNET_free (host_str);
1033         return;
1034       }
1035
1036     if (test_too_long_ident.test_executed == GNUNET_NO)
1037       {
1038         const char * ident = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
1039         
1040         /* Connecting to peer with too long identification */
1041         GNUNET_asprintf (&host_str, "%s://%s/%s",PROTOCOL_PREFIX, test_addr,ident);
1042         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
1043                     _("Connecting to peer with too long peer identification.\n"));
1044         test_too_long_ident.test_executed = GNUNET_YES;
1045         send_data ( &test_too_long_ident, host_str);
1046         GNUNET_free (host_str);
1047         return;
1048     }
1049     if (test_valid_ident.test_executed == GNUNET_NO)
1050       {
1051         struct GNUNET_CRYPTO_HashAsciiEncoded ident;
1052         GNUNET_CRYPTO_hash_to_enc(&my_identity.hashPubKey,&ident);
1053         GNUNET_asprintf (&host_str, 
1054                          "%s://%s/%s%s",
1055                          PROTOCOL_PREFIX, 
1056                          test_addr,
1057                          (char *) &ident,
1058                          ";0");
1059         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
1060                     _("Connecting to peer with valid peer identification.\n"));
1061         test_valid_ident.test_executed = GNUNET_YES;
1062         send_data ( &test_valid_ident, host_str);
1063         GNUNET_free (host_str);
1064         return;
1065       }
1066   }
1067   if (phase==1)
1068     {
1069       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1070                   "\nPhase 1: transmit data to all suggested addresses\n\n");
1071       /* Using one of the addresses the plugin proposed */
1072       GNUNET_assert (addr_head->addr != NULL);
1073       
1074       struct Plugin_Address * tmp_addr;
1075       struct GNUNET_MessageHeader msg;
1076       char * tmp = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader));
1077       char address[INET6_ADDRSTRLEN];
1078       unsigned int port;
1079       unsigned int type = 10;
1080       
1081       msg.size=htons(sizeof(struct GNUNET_MessageHeader));
1082       tmp_addr = addr_head;
1083       /* send a message to all addresses advertised by plugin */
1084       
1085       int count = 0;
1086       while (tmp_addr != NULL)
1087         {
1088           if (tmp_addr->addrlen == (sizeof (struct IPv4HttpAddress)))
1089             {
1090               inet_ntop(AF_INET, (struct in_addr *) tmp_addr->addr,address,INET_ADDRSTRLEN);
1091               port = ntohs(((struct IPv4HttpAddress *) tmp_addr->addr)->u_port);
1092               GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1093                           "Sending message to addres no. %u: `%s':%u\n", 
1094                           count,
1095                           address, 
1096                           port);
1097             }
1098           if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress)))
1099             {
1100               inet_ntop(AF_INET6, (struct in6_addr *) tmp_addr->addr,address,INET6_ADDRSTRLEN);
1101               port = ntohs(((struct IPv6HttpAddress *) tmp_addr->addr)->u6_port);
1102               GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1103                           "Sending message to addres no. %u: `%s':%u\n", 
1104                           count,
1105                           address,
1106                           port);
1107             }
1108           msg.type=htons(type);
1109           memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader));
1110           api->send(api->cls,
1111                     &my_identity, 
1112                     tmp, sizeof(struct GNUNET_MessageHeader), 
1113                     0, TIMEOUT, 
1114                     NULL, 
1115                     tmp_addr->addr, tmp_addr->addrlen, 
1116                     GNUNET_YES, 
1117                     &task_send_cont, &fail_msgs_transmited_to_local_addrs);
1118           tmp_addr = tmp_addr->next;      
1119           count++;
1120           type++;
1121         }
1122       GNUNET_free(tmp);
1123       return;
1124     }
1125
1126   if (phase==2)
1127     {
1128       struct Session * session = cls;
1129       msg = GNUNET_malloc (sizeof(struct GNUNET_MessageHeader));
1130       
1131       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
1132                   "Phase 2: session selection\n\n");
1133       size = sizeof(struct GNUNET_MessageHeader);
1134       msg->size=htons(size);
1135       msg->type = htons(20);
1136       api->send(api->cls, 
1137                 &my_identity,
1138                 (const char *) msg, size, 
1139                 0, TIMEOUT, NULL, NULL, 0, GNUNET_NO, 
1140                 &task_send_cont, NULL);
1141       
1142       msg->type = htons(21);
1143       api->send(api->cls, 
1144                 &my_identity,
1145                 (const char *) msg, size, 
1146                 0, TIMEOUT, NULL, NULL, 0, GNUNET_SYSERR,
1147                 &task_send_cont, NULL);
1148       
1149       /* answer on session*/
1150       size = sizeof( struct GNUNET_MessageHeader);
1151       msg->size = htons(size);
1152       msg->type = htons(22);
1153       api->send(api->cls, 
1154                 &my_identity,
1155                 (const char *) msg, size,
1156                 0, TIMEOUT, session, NULL, 0, GNUNET_SYSERR, 
1157                 &task_send_cont, NULL);      
1158       GNUNET_free(msg);
1159       
1160       /* answer on session with big message not fitting in mhd send buffer*/
1161       size = GNUNET_SERVER_MAX_MESSAGE_SIZE-1;
1162       msg = GNUNET_malloc (size);
1163       msg->size=htons(size);
1164       msg->type = htons(23);
1165       api->send(api->cls,
1166                 &my_identity,
1167                 (const char *) msg, size,
1168                 0, TIMEOUT, session, NULL, 0, GNUNET_NO, 
1169                 &task_send_cont, NULL);
1170       GNUNET_free(msg);
1171       return;
1172     }
1173   
1174   if (phase==3)
1175     {
1176       
1177     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
1178                 "Phase 3: send multiple or big messages after disconnect\n\n");
1179     /* disconnect from peer, so new connections are created */
1180     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Disconnect from peer: `%s'\n", GNUNET_i2s(&my_identity));
1181     api->disconnect(api->cls, &my_identity);
1182     
1183     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Phase 3: sending messages\n");
1184     /* send a multiple GNUNET_messages at a time*/
1185     size = 2 * sizeof(struct GNUNET_MessageHeader);
1186     msg = GNUNET_malloc( 2* size);
1187     msg->size = htons(size);
1188     msg->type = htons(30);
1189     struct GNUNET_MessageHeader * msg2 = &msg[2];
1190     msg2->size = htons(2 * sizeof(struct GNUNET_MessageHeader));
1191     msg2->type = htons(31);
1192     api->send(api->cls,
1193               &my_identity, 
1194               (const char *) msg, 4 * sizeof(struct GNUNET_MessageHeader), 
1195               0, TIMEOUT, NULL, 
1196               addr_head->addr, addr_head->addrlen, 
1197               GNUNET_NO,
1198               &task_send_cont, &fail_multiple_msgs_in_transmission);
1199     GNUNET_free(msg);
1200     /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1  */
1201
1202     size = GNUNET_SERVER_MAX_MESSAGE_SIZE-1;
1203     msg = GNUNET_malloc(size);
1204     msg->size = htons(size);
1205     msg->type = htons(32);
1206     api->send(api->cls,
1207               &my_identity, 
1208               (const char *) msg, size,
1209               0, TIMEOUT, NULL,
1210               addr_head->addr, addr_head->addrlen, 
1211               GNUNET_NO, 
1212               &task_send_cont, &fail_msg_transmited_max_size);
1213     GNUNET_free(msg);
1214     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1215                 "No more tests to run\n");
1216   }
1217 }
1218
1219
1220 /**
1221  * Runs the test.
1222  *
1223  * @param cls closure
1224  * @param c configuration to use
1225  */
1226 static void
1227 run (void *cls,
1228      char *const *args,
1229      const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
1230 {
1231   char * libname;
1232   cfg = c;
1233   char *keyfile;
1234   unsigned long long tneigh;
1235   struct Plugin_Address * cur;
1236   const char * addr_str;
1237
1238
1239   unsigned int suggest_res;
1240
1241   fail_pretty_printer = GNUNET_YES;
1242   fail_notify_address = GNUNET_YES;
1243   fail_addr_to_str = GNUNET_YES;
1244   fail_msgs_transmited_to_local_addrs = 0;
1245   fail_msg_transmited_max_size = GNUNET_YES;
1246   fail_multiple_msgs_in_transmission = 0;
1247   fail_session_selection_reliable = GNUNET_YES;
1248   fail_session_selection_reliable = GNUNET_YES;
1249   fail_session_selection_session = GNUNET_YES;
1250   fail_session_selection_session_big = GNUNET_YES;
1251
1252   addr_head = NULL;
1253   count_str_addr = 0;
1254   /* parse configuration */
1255   if ((GNUNET_OK !=
1256        GNUNET_CONFIGURATION_get_value_number (c,
1257                                               "TRANSPORT",
1258                                               "NEIGHBOUR_LIMIT",
1259                                               &tneigh)) ||
1260       (GNUNET_OK !=
1261        GNUNET_CONFIGURATION_get_value_filename (c,
1262                                                 "GNUNETD",
1263                                                 "HOSTKEY", &keyfile)))
1264     {
1265       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1266                   _("Transport service is lacking key configuration settings.  Exiting.\n"));
1267       GNUNET_SCHEDULER_shutdown ();
1268       fail = 1;
1269       return;
1270     }
1271
1272   if ((GNUNET_OK !=
1273       GNUNET_CONFIGURATION_get_value_number (cfg,
1274                                              "transport-http",
1275                                              "PORT",
1276                                              &port)) ||
1277      (port > 65535) || (port == 0))
1278   {
1279     GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
1280                      "http",
1281                      _
1282                      ("Require valid port number for transport plugin `%s' in configuration!\n"),
1283                      "transport-http");
1284   }
1285
1286   max_connect_per_transport = (uint32_t) tneigh;
1287   my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
1288   GNUNET_free (keyfile);
1289   if (my_private_key == NULL)
1290     {
1291       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1292                   _("Transport service could not access hostkey.  Exiting.\n"));
1293       GNUNET_SCHEDULER_shutdown ();
1294       fail = 1;
1295       return;
1296     }
1297
1298   GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key);
1299   GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), &my_identity.hashPubKey);
1300
1301   /* assertions before start */
1302   GNUNET_assert ((port > 0) && (port <= 65535));
1303
1304   /* load plugins... */
1305   setup_plugin_environment ();
1306   GNUNET_asprintf (&libname, "libgnunet_plugin_transport_http");
1307   GNUNET_log (GNUNET_ERROR_TYPE_INFO, 
1308               _("Loading HTTP transport plugin `%s'\n"),
1309               libname);
1310   api = GNUNET_PLUGIN_load (libname, &env);
1311   GNUNET_free (libname);
1312   if (api == NULL)
1313   {
1314     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1315                 _("Failed to load transport plugin for http\n"));
1316     fail = 1;
1317     return;
1318   }
1319
1320
1321   ti_timeout = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &task_timeout, NULL);
1322
1323   /* testing plugin functionality */
1324   GNUNET_assert (0!=fail_notify_address_count);
1325   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
1326               "Transport plugin returned %u addresses to connect to\n", 
1327               fail_notify_address_count);
1328
1329   /* testing pretty printer with all addresses obtained from the plugin*/
1330   cur = addr_head;
1331   while (cur != NULL)
1332   {
1333     api->address_pretty_printer (api->cls, "http",
1334                                  cur->addr,cur->addrlen, GNUNET_NO,TEST_TIMEOUT, 
1335                                  &pretty_printer_cb, NULL);
1336     addr_str = api->address_to_string (api->cls, cur->addr, cur->addrlen);
1337     suggest_res = api->check_address (api->cls, cur->addr, cur->addrlen);
1338
1339     GNUNET_assert (GNUNET_OK == suggest_res);
1340     GNUNET_assert (NULL != addr_str);
1341     count_str_addr++;
1342     GNUNET_free ( (char *) addr_str);
1343     cur = cur->next;
1344   }
1345   GNUNET_assert (fail_pretty_printer_count > 0);
1346   GNUNET_assert (fail_pretty_printer_count==fail_notify_address_count);
1347   GNUNET_assert (fail_pretty_printer_count==count_str_addr);
1348   fail_pretty_printer=GNUNET_NO;
1349   fail_addr_to_str=GNUNET_NO;
1350
1351   struct IPv4HttpAddress failing_addr;
1352
1353   /* Suggesting addresses with wrong size*/
1354   failing_addr.ipv4_addr = htonl(INADDR_LOOPBACK);
1355   failing_addr.u_port = htons(0);
1356   suggest_res = api->check_address (api->cls,&failing_addr,sizeof (struct IPv6HttpAddress));
1357   GNUNET_assert (GNUNET_SYSERR == suggest_res);
1358
1359   /* Suggesting addresses with wrong address*/
1360   failing_addr.ipv4_addr = htonl(0xffc00000);
1361   failing_addr.u_port = htons(12389);
1362   suggest_res = api->check_address (api->cls,&failing_addr,100);
1363   GNUNET_assert (GNUNET_SYSERR == suggest_res);
1364
1365   /* test sending to client */
1366   multi_handle = curl_multi_init();
1367
1368   /* Setting up buffers */
1369   buffer_in.size = HTTP_BUFFER_SIZE;
1370   buffer_in.pos = 0;
1371   buffer_in.len = 0;
1372
1373   buffer_out.size = HTTP_BUFFER_SIZE;
1374   buffer_out.pos = 0;
1375   buffer_out.len = 0;
1376
1377   /* Setting up connection tests */
1378
1379   /* Test: connecting without a peer identification */
1380   test_no_ident.test_executed = GNUNET_NO;
1381   test_no_ident.test_failed = GNUNET_YES;
1382
1383   /* Test: connecting with too short peer identification */
1384   test_too_short_ident.test_executed = GNUNET_NO;
1385   test_too_short_ident.test_failed = GNUNET_YES;
1386
1387   /* Test: connecting with too long peer identification */
1388   test_too_long_ident.test_executed = GNUNET_NO;
1389   test_too_long_ident.test_failed = GNUNET_YES;
1390
1391   /* Test: connecting with valid identification */
1392   test_valid_ident.test_executed = GNUNET_NO;
1393   test_valid_ident.test_failed = GNUNET_YES;
1394
1395   test_addr = (char *) api->address_to_string (api->cls,addr_head->addr,addr_head->addrlen);
1396
1397   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Phase 0\n\n"));
1398   run_connection_tests(0, NULL);
1399   /* testing finished */
1400 }
1401
1402
1403 /**
1404  * The main function for the transport service.
1405  *
1406  * @param argc number of arguments from the command line
1407  * @param argv command line arguments
1408  * @return 0 ok, 1 on error
1409  */
1410 int
1411 main (int argc, char *const *argv)
1412 {
1413   static struct GNUNET_GETOPT_CommandLineOption options[] = {
1414     GNUNET_GETOPT_OPTION_END
1415   };
1416   int ret;
1417   char *const argv_prog[] = {
1418     "test_gnunet_transport_plugin_http",
1419     "-c",
1420     "test_plugin_transport_data_http.conf",
1421     "-L",
1422 #if VERBOSE
1423     "DEBUG",
1424 #else
1425     "WARNING",
1426 #endif
1427     NULL
1428   };
1429   GNUNET_log_setup ("test_gnunet_transport_plugin_http",
1430 #if VERBOSE
1431                     "DEBUG",
1432 #else
1433                     "WARNING",
1434 #endif
1435                     NULL);
1436
1437   ret = (GNUNET_OK ==
1438          GNUNET_PROGRAM_run (5,
1439                              argv_prog,
1440                              "test_gnunet_transport_plugin_http",
1441                              "testcase", options, &run, NULL)) ? GNUNET_NO : GNUNET_YES;
1442
1443   GNUNET_DISK_directory_remove ("/tmp/test_plugin_transport_http");
1444   if (ret != GNUNET_OK)
1445     return 1;
1446   return fail;
1447 }
1448
1449 /* end of test_gnunet_transport_plugin_http.c */