2 This file is part of GNUnet
3 (C) 2009 Christian Grothoff (and other contributing authors)
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 2, or (at your
8 option) any later version.
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.
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.
21 * @file hostlist/test_gnunet_daemon_hostlist.c
22 * @brief test for gnunet_daemon_hostslist.c
23 * @author Christian Grothoff
26 #include "gnunet_util_lib.h"
27 #include "gnunet_arm_lib.h"
29 #define VERBOSE GNUNET_YES
31 #define START_ARM GNUNET_YES
35 struct GNUNET_CONFIGURATION_Handle *cfg;
36 struct GNUNET_CORE_Handle *ch;
37 struct GNUNET_PeerIdentity id;
38 struct GNUNET_TRANSPORT_Handle *th;
39 struct GNUNET_MessageHeader *hello;
48 setup_peer (struct PeerContext *p, const char *cfgname)
50 p->cfg = GNUNET_CONFIGURATION_create ();
52 p->arm_pid = GNUNET_OS_start_process ("gnunet-service-arm",
58 sleep (1); /* allow ARM to start */
60 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
61 GNUNET_ARM_start_service ("core", p->cfg, sched, TIMEOUT, NULL, NULL);
62 p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, p, NULL, NULL, NULL);
63 GNUNET_assert (p->th != NULL);
64 GNUNET_TRANSPORT_get_hello (p->th, TIMEOUT, &process_hello, p);
70 struct GNUNET_SCHEDULER_Handle *s,
72 const char *cfgfile, struct GNUNET_CONFIGURATION_Handle *cfg)
74 GNUNET_assert (ok == 1);
77 setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf");
78 setup_peer (&p2, "test_gnunet_daemon_hostlist_peer2.conf");
83 stop_arm (struct PeerContext *p)
86 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
87 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
88 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
89 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
90 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
91 "ARM process %u stopped\n", p->arm_pid);
93 GNUNET_CONFIGURATION_destroy (p->cfg);
100 char *const argv[] = { "test-gnunet-daemon-hostlist",
101 "-c", "test_gnunet_daemon_hostlist.conf",
107 struct GNUNET_GETOPT_CommandLineOption options[] = {
108 GNUNET_GETOPT_OPTION_END
111 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
112 argv, "test-gnunet-daemon-hostlist",
113 "nohelp", options, &run, &ok);
121 main (int argc, char *argv[])
126 GNUNET_log_setup ("test-gnunet-daemon-hostlist",