- disable unix
[oweals/gnunet.git] / src / dht / test_dht_monitor.c
1 /*
2      This file is part of GNUnet.
3      (C) 2011 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 dht/test_dht_monitor.c
22  *
23  * @brief Test for the dht service: store, retrieve and monitor in a line.
24  * TODO: update this description
25  * Each peer stores it own ID in the DHT and then a different peer tries to
26  * retrieve that key from it. The GET starts after a first round of PUTS has
27  * been made. Periodically, each peer stores its ID into the DHT. If after
28  * a timeout no result has been returned, the test fails.
29  */
30 #include "platform.h"
31 #include "gnunet_testing_lib.h"
32 #include "gnunet_dht_service.h"
33
34 #define VERBOSE GNUNET_YES
35
36 #define REMOVE_DIR GNUNET_YES
37
38
39 /**
40  * How long until we give up on connecting the peers?
41  */
42 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1500)
43
44 #define GET_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
45
46 #define PUT_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
47
48 static int ok;
49
50 /**
51  * Be verbose
52  */
53 static int verbose;
54
55 /**
56  * Total number of peers in the test.
57  */
58 static unsigned long long num_peers;
59
60 /**
61  * Global configuration file
62  */
63 static struct GNUNET_CONFIGURATION_Handle *testing_cfg;
64
65 /**
66  * Total number of currently running peers.
67  */
68 static unsigned long long peers_running;
69
70 /**
71  * Total number of connections in the whole network.
72  */
73 static unsigned int total_connections;
74
75 /**
76  * The currently running peer group.
77  */
78 static struct GNUNET_TESTING_PeerGroup *pg;
79
80 /**
81  * File to report results to.
82  */
83 static struct GNUNET_DISK_FileHandle *output_file;
84
85 /**
86  * File to log connection info, statistics to.
87  */
88 static struct GNUNET_DISK_FileHandle *data_file;
89
90 /**
91  * Task called to disconnect peers.
92  */
93 static GNUNET_SCHEDULER_TaskIdentifier disconnect_task;
94
95 /**
96  * Task To perform tests
97  */
98 static GNUNET_SCHEDULER_TaskIdentifier test_task;
99
100 /**
101  * Task to do DHT_puts
102  */
103 static GNUNET_SCHEDULER_TaskIdentifier put_task;
104
105 /**
106  * Task called to shutdown test.
107  */
108 static GNUNET_SCHEDULER_TaskIdentifier shutdown_handle;
109
110 static char *topology_file;
111
112 struct GNUNET_TESTING_Daemon *d1;
113
114 struct GNUNET_TESTING_Daemon *d2;
115
116 struct GNUNET_DHT_Handle **hs;
117
118 struct GNUNET_DHT_MonitorHandle **mhs;
119
120 struct GNUNET_DHT_GetHandle *get_h_far;
121
122 const char *id_origin = "FC74";
123 const char *id_far = "2UVH";
124
125 struct GNUNET_TESTING_Daemon *d_far;
126 struct GNUNET_TESTING_Daemon *o;
127
128 unsigned int monitor_counter;
129
130 int in_test;
131
132 /**
133  * Check whether peers successfully shut down.
134  */
135 static void
136 shutdown_callback (void *cls, const char *emsg)
137 {
138   if (emsg != NULL)
139   {
140 #if VERBOSE
141     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Shutdown of peers failed!\n");
142 #endif
143     ok++;
144   }
145   else
146   {
147 #if VERBOSE
148     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
149                 "test: All peers successfully shut down!\n");
150 #endif
151   }
152   GNUNET_CONFIGURATION_destroy (testing_cfg);
153 }
154
155
156 static void
157 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
158 {
159 #if VERBOSE
160   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Ending test.\n");
161 #endif
162
163   if (disconnect_task != GNUNET_SCHEDULER_NO_TASK)
164   {
165     GNUNET_SCHEDULER_cancel (disconnect_task);
166     disconnect_task = GNUNET_SCHEDULER_NO_TASK;
167   }
168
169   if (data_file != NULL)
170     GNUNET_DISK_file_close (data_file);
171   GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
172 }
173
174
175 static void
176 disconnect_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
177 {
178   unsigned int i;
179
180   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: disconnecting peers\n");
181   disconnect_task = GNUNET_SCHEDULER_NO_TASK;
182   GNUNET_SCHEDULER_cancel (put_task);
183   if (NULL != get_h_far)
184     GNUNET_DHT_get_stop (get_h_far);
185   for (i = 0; i < num_peers; i++)
186   {
187     GNUNET_DHT_monitor_stop(mhs[i]);
188     GNUNET_DHT_disconnect (hs[i]);
189   }
190   GNUNET_SCHEDULER_cancel (shutdown_handle);
191   shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
192 }
193
194 static void
195 dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
196                     const GNUNET_HashCode * key,
197                     const struct GNUNET_PeerIdentity *get_path,
198                     unsigned int get_path_length,
199                     const struct GNUNET_PeerIdentity *put_path,
200                     unsigned int put_path_length, enum GNUNET_BLOCK_Type type,
201                     size_t size, const void *data)
202 {
203   int i;
204
205   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
206               "test: ************* FOUND!!! ***********\n");
207   if (sizeof (GNUNET_HashCode) == size)
208   {
209     const GNUNET_HashCode *h = data;
210
211     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test:   Contents: %s\n",
212                 GNUNET_h2s_full (h));
213
214   }
215   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: PATH: (get %u, put %u)\n",
216               get_path_length, put_path_length);
217   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test:   LOCAL\n");
218   for (i = get_path_length - 1; i >= 0; i--)
219   {
220     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test:   %s\n",
221                 GNUNET_i2s (&get_path[i]));
222   }
223   for (i = put_path_length - 1; i >= 0; i--)
224   {
225     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test:   %s\n",
226                 GNUNET_i2s (&put_path[i]));
227   }
228   if (monitor_counter >= get_path_length + put_path_length)
229   {
230     ok = 0;
231     GNUNET_log (GNUNET_ERROR_TYPE_INFO, "expected at least %u hops, got %u\n",
232                 get_path_length + put_path_length, monitor_counter);
233   }
234   else
235     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "expected at least %u hops, got %u\n",
236                 get_path_length + put_path_length, monitor_counter);
237   GNUNET_SCHEDULER_cancel (disconnect_task);
238   disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL);
239 }
240
241 /**
242  * Start test: start GET request from the first node in the line looking for
243  * the ID of the last node in the line.
244  * 
245  * @param cls Closure (not used).
246  * @param tc Task context.
247  */
248 static void
249 do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
250 {
251   if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
252   {
253     return;
254   }
255   
256   in_test = GNUNET_YES;
257   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: test_task\n");
258   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: looking for %s\n",
259               GNUNET_h2s_full (&d_far->id.hashPubKey));
260   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test:        from %s\n",
261               GNUNET_h2s_full (&o->id.hashPubKey));
262   get_h_far = GNUNET_DHT_get_start (hs[0], GNUNET_TIME_UNIT_FOREVER_REL,        /* timeout */
263                                     GNUNET_BLOCK_TYPE_TEST,     /* type */
264                                     &d_far->id.hashPubKey,      /*key to search */
265                                     4U, /* replication level */
266                                     GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, NULL,    /* xquery */
267                                     0,  /* xquery bits */
268                                     &dht_get_id_handler, NULL);
269   GNUNET_SCHEDULER_cancel (disconnect_task);
270   disconnect_task =
271       GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, &disconnect_peers, NULL);
272 }
273
274
275 /**
276  * Periodic function used to put the ID of the far peer in the DHT.
277  * 
278  * @param cls Closure (not used).
279  * @param tc Task context.
280  */
281 static void
282 put_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
283 {
284   struct GNUNET_TESTING_Daemon *d;
285
286   if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
287   {
288     put_task = GNUNET_SCHEDULER_NO_TASK;
289     return;
290   }
291
292   d = GNUNET_TESTING_daemon_get (pg, 4);
293   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: putting into DHT: %s\n",
294               GNUNET_h2s_full (&d->id.hashPubKey));
295   GNUNET_DHT_put (hs[4], &d->id.hashPubKey, 10U,
296                   GNUNET_DHT_RO_RECORD_ROUTE |
297                   GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
298                   GNUNET_BLOCK_TYPE_TEST, sizeof (struct GNUNET_PeerIdentity),
299                   (const char *) &d->id, GNUNET_TIME_UNIT_FOREVER_ABS,
300                   GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL);
301
302   put_task = GNUNET_SCHEDULER_add_delayed (PUT_FREQUENCY, &put_id, NULL);
303 }
304
305 /**
306  * Callback called on each GET request going through the DHT.
307  * Prints the info about the intercepted packet and increments a counter.
308  *
309  * @param cls Closure.
310  * @param options Options, for instance RecordRoute, DemultiplexEverywhere.
311  * @param type The type of data in the request.
312  * @param hop_count Hop count so far.
313  * @param path_length number of entries in path (or 0 if not recorded).
314  * @param path peers on the GET path (or NULL if not recorded).
315  * @param desired_replication_level Desired replication level.
316  * @param key Key of the requested data.
317  */
318 void
319 monitor_get_cb (void *cls,
320                 enum GNUNET_DHT_RouteOption options,
321                 enum GNUNET_BLOCK_Type type,
322                 uint32_t hop_count,
323                 uint32_t desired_replication_level,
324                 unsigned int path_length,
325                 const struct GNUNET_PeerIdentity *path,
326                 const GNUNET_HashCode * key)
327 {
328   const char *s_key;
329   unsigned int i;
330
331   i = (unsigned int) (long) cls;
332   s_key = GNUNET_h2s(key);
333   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
334               "%u got a GET message for key %s\n",
335               i, s_key);
336
337   if (strncmp (s_key, id_far, 4) == 0 && in_test == GNUNET_YES)
338     monitor_counter++;
339 }
340
341
342 /**
343  * Callback called on each PUT request going through the DHT.
344  * Prints the info about the intercepted packet and increments a counter.
345  *
346  * @param cls Closure.
347  * @param options Options, for instance RecordRoute, DemultiplexEverywhere.
348  * @param type The type of data in the request.
349  * @param hop_count Hop count so far.
350  * @param path_length number of entries in path (or 0 if not recorded).
351  * @param path peers on the PUT path (or NULL if not recorded).
352  * @param desired_replication_level Desired replication level.
353  * @param exp Expiration time of the data.
354  * @param key Key under which data is to be stored.
355  * @param data Pointer to the data carried.
356  * @param size Number of bytes in data.
357  */
358 void
359 monitor_put_cb (void *cls,
360                 enum GNUNET_DHT_RouteOption options,
361                 enum GNUNET_BLOCK_Type type,
362                 uint32_t hop_count,
363                 uint32_t desired_replication_level,
364                 unsigned int path_length,
365                 const struct GNUNET_PeerIdentity *path,
366                 struct GNUNET_TIME_Absolute exp,
367                 const GNUNET_HashCode * key,
368                 const void *data,
369                 size_t size)
370 {
371   const char *s_key;
372   unsigned int i;
373
374   i = (unsigned int) (long) cls;
375   s_key = GNUNET_h2s(key);
376
377   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
378               "%u got a PUT message for key %s with %u bytes\n",
379               i, s_key, size);
380
381   if (strncmp (s_key, id_far, 4) == 0 && in_test == GNUNET_YES)
382     monitor_counter++;
383 }
384
385
386 /**
387  * Callback called on each GET reply going through the DHT.
388  * Prints the info about the intercepted packet and increments a counter.
389  *
390  * @param cls Closure.
391  * @param type The type of data in the result.
392  * @param get_path Peers on GET path (or NULL if not recorded).
393  * @param get_path_length number of entries in get_path.
394  * @param put_path peers on the PUT path (or NULL if not recorded).
395  * @param put_path_length number of entries in get_path.
396  * @param exp Expiration time of the data.
397  * @param key Key of the data.
398  * @param data Pointer to the result data.
399  * @param size Number of bytes in data.
400  */
401 void
402 monitor_res_cb (void *cls,
403                 enum GNUNET_BLOCK_Type type,
404                 const struct GNUNET_PeerIdentity *get_path,
405                 unsigned int get_path_length,
406                 const struct GNUNET_PeerIdentity *put_path,
407                 unsigned int put_path_length,
408                 struct GNUNET_TIME_Absolute exp,
409                 const GNUNET_HashCode * key,
410                 const void *data,
411                 size_t size)
412 {
413   const char *s_key;
414   unsigned int i;
415
416   i = (unsigned int) (long) cls;
417   s_key = GNUNET_h2s(key);
418   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
419               "%u got a REPLY message for key %s with %u bytes\n",
420               i, s_key, size);
421
422   if (strncmp (s_key, id_far, 4) == 0 && in_test == GNUNET_YES)
423     monitor_counter++;
424 }
425
426
427 /**
428  * peergroup_ready: start test when all peers are connected
429  *
430  * @param cls closure
431  * @param emsg error message
432  */
433 static void
434 peergroup_ready (void *cls, const char *emsg)
435 {
436   struct GNUNET_TESTING_Daemon *d;
437   char *buf;
438   int buf_len;
439   unsigned int i;
440
441   if (emsg != NULL)
442   {
443     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
444                 "test: Peergroup callback called with error, aborting test!\n");
445     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Error from testing: `%s'\n",
446                 emsg);
447     ok++;
448     GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
449     return;
450   }
451 #if VERBOSE
452   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
453               "************************************************************\n");
454   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
455               "test: Peer Group started successfully!\n");
456   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Have %u connections\n",
457               total_connections);
458 #endif
459
460   if (data_file != NULL)
461   {
462     buf = NULL;
463     buf_len = GNUNET_asprintf (&buf, "CONNECTIONS_0: %u\n", total_connections);
464     if (buf_len > 0)
465       GNUNET_DISK_file_write (data_file, buf, buf_len);
466     GNUNET_free (buf);
467   }
468   peers_running = GNUNET_TESTING_daemons_running (pg);
469
470   GNUNET_assert (peers_running == num_peers);
471   hs = GNUNET_malloc (num_peers * sizeof (struct GNUNET_DHT_Handle *));
472   mhs = GNUNET_malloc (num_peers * sizeof (struct GNUNET_DHT_MonitorHandle *));
473   d_far = o = NULL;
474   o = GNUNET_TESTING_daemon_get (pg, 0);
475   d_far = GNUNET_TESTING_daemon_get (pg, 4);
476
477   for (i = 0; i < num_peers; i++)
478   {
479     d = GNUNET_TESTING_daemon_get (pg, i);
480     hs[i] = GNUNET_DHT_connect (d->cfg, 32);
481     mhs[i] = GNUNET_DHT_monitor_start(hs[i],
482                                       GNUNET_BLOCK_TYPE_ANY,
483                                       NULL,
484                                       &monitor_get_cb,
485                                       &monitor_res_cb,
486                                       &monitor_put_cb,
487                                       (void *)(long)i);
488   }
489
490   if ((NULL == o) || (NULL == d_far))
491   {
492     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
493                 "test: Error getting daemons from pg\n");
494     GNUNET_SCHEDULER_cancel (disconnect_task);
495     disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL);
496     return;
497   }
498   monitor_counter = 0;
499   put_task = GNUNET_SCHEDULER_add_now (&put_id, NULL);
500   test_task =
501       GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
502                                     (GNUNET_TIME_UNIT_SECONDS, 2), &do_test,
503                                     NULL);
504   disconnect_task =
505       GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, &disconnect_peers, NULL);
506
507 }
508
509
510 /**
511  * Function that will be called whenever two daemons are connected by
512  * the testing library.
513  *
514  * @param cls closure
515  * @param first peer id for first daemon
516  * @param second peer id for the second daemon
517  * @param distance distance between the connected peers
518  * @param first_cfg config for the first daemon
519  * @param second_cfg config for the second daemon
520  * @param first_daemon handle for the first daemon
521  * @param second_daemon handle for the second daemon
522  * @param emsg error message (NULL on success)
523  */
524 static void
525 connect_cb (void *cls, const struct GNUNET_PeerIdentity *first,
526             const struct GNUNET_PeerIdentity *second, uint32_t distance,
527             const struct GNUNET_CONFIGURATION_Handle *first_cfg,
528             const struct GNUNET_CONFIGURATION_Handle *second_cfg,
529             struct GNUNET_TESTING_Daemon *first_daemon,
530             struct GNUNET_TESTING_Daemon *second_daemon, const char *emsg)
531 {
532
533   if (emsg == NULL)
534   {
535     total_connections++;
536     GNUNET_PEER_intern (first);
537     GNUNET_PEER_intern (second);
538   }
539   else
540   {
541     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
542                 "test: Problem with new connection (%s)\n", emsg);
543   }
544
545 }
546
547
548 /**
549  * run: load configuration options and schedule test to run (start peergroup)
550  * @param cls closure
551  * @param args argv
552  * @param cfgfile configuration file name (can be NULL)
553  * @param cfg configuration handle
554  */
555 static void
556 run (void *cls, char *const *args, const char *cfgfile,
557      const struct GNUNET_CONFIGURATION_Handle *cfg)
558 {
559   char *temp_str;
560   struct GNUNET_TESTING_Host *hosts;
561   char *data_filename;
562
563   ok = 1;
564   testing_cfg = GNUNET_CONFIGURATION_dup (cfg);
565
566   GNUNET_log_setup ("test_dht_monitor",
567 #if VERBOSE
568                     "DEBUG",
569 #else
570                     "WARNING",
571 #endif
572                     NULL);
573
574 #if VERBOSE
575   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Starting daemons.\n");
576   GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing",
577                                          "use_progressbars", "YES");
578 #endif
579
580   if (GNUNET_OK !=
581       GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing",
582                                              "num_peers", &num_peers))
583   {
584     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
585                 "Option TESTING:NUM_PEERS is required!\n");
586     return;
587   }
588
589   if (GNUNET_OK !=
590       GNUNET_CONFIGURATION_get_value_string (testing_cfg, "testing",
591                                              "topology_output_file",
592                                              &topology_file))
593   {
594     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
595                 "Option test_dht_monitor:topology_output_file is required!\n");
596     return;
597   }
598
599   if (GNUNET_OK ==
600       GNUNET_CONFIGURATION_get_value_string (testing_cfg, "test_dht_topo",
601                                              "data_output_file",
602                                              &data_filename))
603   {
604     data_file =
605         GNUNET_DISK_file_open (data_filename,
606                                GNUNET_DISK_OPEN_READWRITE |
607                                GNUNET_DISK_OPEN_CREATE,
608                                GNUNET_DISK_PERM_USER_READ |
609                                GNUNET_DISK_PERM_USER_WRITE);
610     if (data_file == NULL)
611     {
612       GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n",
613                   data_filename);
614       GNUNET_free (data_filename);
615     }
616   }
617
618   if (GNUNET_YES ==
619       GNUNET_CONFIGURATION_get_value_string (cfg, "test_dht_topo",
620                                              "output_file", &temp_str))
621   {
622     output_file =
623         GNUNET_DISK_file_open (temp_str,
624                                GNUNET_DISK_OPEN_READWRITE |
625                                GNUNET_DISK_OPEN_CREATE,
626                                GNUNET_DISK_PERM_USER_READ |
627                                GNUNET_DISK_PERM_USER_WRITE);
628     if (output_file == NULL)
629       GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n",
630                   temp_str);
631   }
632   GNUNET_free_non_null (temp_str);
633
634   hosts = GNUNET_TESTING_hosts_load (testing_cfg);
635
636   pg = GNUNET_TESTING_peergroup_start (testing_cfg, num_peers, TIMEOUT,
637                                        &connect_cb, &peergroup_ready, NULL,
638                                        hosts);
639   GNUNET_assert (pg != NULL);
640   shutdown_handle =
641       GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
642                                     &shutdown_task, NULL);
643 }
644
645
646
647 /**
648  * test_dht_monitor command line options
649  */
650 static struct GNUNET_GETOPT_CommandLineOption options[] = {
651   {'V', "verbose", NULL,
652    gettext_noop ("be verbose (print progress information)"),
653    0, &GNUNET_GETOPT_set_one, &verbose},
654   GNUNET_GETOPT_OPTION_END
655 };
656
657
658 /**
659  * Main: start test
660  */
661 int
662 main (int xargc, char *xargv[])
663 {
664   char *const argv[] = { "test-dht-monitor",
665     "-c",
666     "test_dht_line.conf",
667 #if VERBOSE
668     "-L", "DEBUG",
669 #endif
670     NULL
671   };
672
673   in_test = GNUNET_NO;
674   GNUNET_PROGRAM_run (sizeof (argv) / sizeof (char *) - 1, argv,
675                       "test_dht_monitor",
676                       gettext_noop ("Test dht monitoring in a line."),
677                       options, &run, NULL);
678 #if REMOVE_DIR
679   GNUNET_DISK_directory_remove ("/tmp/test_dht_monitor");
680 #endif
681   if (0 != ok)
682   {
683     GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "test: FAILED!\n");
684   }
685   return ok;
686 }
687
688 /* end of test_dht_monitor.c */