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