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 arm/test_gnunet_service_manager.c (A mockup testcase, not functionally complete)
22 * @brief testcase for gnunet-service-manager.c
26 #include "gnunet_arm_service.h"
27 #include "gnunet_resolver_service.h"
28 #include "gnunet_program_lib.h"
31 * Timeout for starting services, very short because of the strange way start works
32 * (by checking if running before starting, so really this time is always waited on
33 * startup (annoying)).
35 #define START_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 50)
37 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
39 #define START_ARM GNUNET_YES
41 #define VERBOSE GNUNET_YES
45 static struct GNUNET_SCHEDULER_Handle *sched;
47 static const struct GNUNET_CONFIGURATION_Handle *cfg;
50 static struct GNUNET_ARM_Handle *arm;
54 arm_stopped (void *cls, int success)
56 if (success != GNUNET_NO)
61 GNUNET_ARM_disconnect (arm);
66 hostNameResolveCB(void *cls,
67 const struct sockaddr *addr,
70 if ( (ret == 0) || (ret == 4) )
74 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
75 "Name not resolved!\n");
77 GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL);
84 GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL);
90 arm_notify (void *cls, int success)
92 if (success != GNUNET_YES)
98 /* connect to the resolver service */
99 if (NULL == GNUNET_RESOLVER_hostname_resolve (sched,
105 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
106 "Unable to resolve our own hostname!\n");
109 GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL);
117 struct GNUNET_SCHEDULER_Handle *s,
120 const struct GNUNET_CONFIGURATION_Handle *c)
125 arm = GNUNET_ARM_connect (cfg, sched, NULL);
126 GNUNET_ARM_start_service (arm, "arm", START_TIMEOUT, &arm_notify, NULL);
128 arm_notify (NULL, GNUNET_YES);
136 char *const argv[] = {
137 "test-gnunet-service-manager",
138 "-c", "test_arm_api_data.conf",
144 struct GNUNET_GETOPT_CommandLineOption options[] = {
145 GNUNET_GETOPT_OPTION_END
147 GNUNET_assert (GNUNET_OK ==
148 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
150 "test-gnunet-service-manager",
151 "nohelp", options, &run, NULL));
156 main (int argc, char *argv[])
158 GNUNET_log_setup("test-gnunet-service-manager",