2 This file is part of GNUnet
3 (C) 2008, 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.
22 * @file testing/testing.c
23 * @brief convenience API for writing testcases for GNUnet
24 * Many testcases need to start and stop gnunetd,
25 * and this library is supposed to make that easier
26 * for TESTCASES. Normal programs should always
27 * use functions from gnunet_{util,arm}_lib.h. This API is
28 * ONLY for writing testcases!
29 * @author Christian Grothoff
32 #include "gnunet_arm_service.h"
33 #include "gnunet_testing_lib.h"
36 * Handle for a GNUnet daemon (technically a set of
37 * daemons; the handle is really for the master ARM
38 * daemon) started by the testing library.
40 struct GNUNET_TESTING_Daemon
46 * Starts a GNUnet daemon.
48 * @param service_home directory to use as the service home directory
49 * @param transports transport services that should be loaded
50 * @param applications application services and daemons that should be started
51 * @param port_offset offset to add to all ports for all services
52 * @param hostname name of the machine where to run GNUnet
53 * (use NULL for localhost).
54 * @param cb function to call with the result
55 * @param cb_cls closure for cb
58 GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched,
59 struct GNUNET_CONFIGURATION_Handle *cfg,
60 const char *service_home,
61 const char *transports,
62 const char *applications,
65 GNUNET_TESTING_NotifyDaemonRunning cb,
72 * Stops a GNUnet daemon.
74 * @param d the daemon that should be stopped
75 * @param cb function called once the daemon was stopped
76 * @param cb_cls closure for cb
78 void GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
79 GNUNET_TESTING_NotifyCompletion cb,
86 * Establish a connection between two GNUnet daemons.
88 * @param d1 handle for the first daemon
89 * @param d2 handle for the second daemon
90 * @param cb function to call at the end
91 * @param cb_cls closure for cb
93 void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
94 struct GNUNET_TESTING_Daemon *d2,
95 GNUNET_TESTING_NotifyCompletion cb,
102 * Start count gnunetd processes with the same set of
103 * transports and applications. The port numbers will
104 * be computed by adding delta each time (zero
105 * times for the first peer).
107 * @param total number of daemons to start
108 * @param service_home_prefix path to use as the prefix for the home of the services
109 * @param transports which transports should all peers use
110 * @param applications which applications should be used?
111 * @param timeout how long is this allowed to take?
112 * @param cb function to call on each daemon that was started
113 * @param cb_cls closure for cb
114 * @param cbe function to call at the end
115 * @param cbe_cls closure for cbe
116 * @param hostname where to run the peers; can be NULL (to run
117 * everything on localhost).
118 * @param va Additional hosts can be specified using a NULL-terminated list of
119 * varargs, hosts will then be used round-robin from that
120 * list; va only contains anything if hostname != NULL.
123 GNUNET_TESTING_daemons_start_va (struct GNUNET_SCHEDULER_Handle *sched,
124 struct GNUNET_CONFIGURATION_Handle *cfg,
126 const char *service_home_prefix,
127 const char *transports,
128 const char *applications,
129 GNUNET_TESTING_NotifyDaemonRunning cb,
131 GNUNET_TESTING_NotifyCompletion cbe,
133 const char *hostname,
140 * Start count gnunetd processes with the same set of
141 * transports and applications. The port numbers will
142 * be computed by adding delta each time (zero
143 * times for the first peer).
145 * @param total number of daemons to start
146 * @param service_home_prefix path to use as the prefix for the home of the services
147 * @param transports which transports should all peers use
148 * @param applications which applications should be used?
149 * @param timeout how long is this allowed to take?
150 * @param cb function to call on each daemon that was started
151 * @param cb_cls closure for cb
152 * @param cbe function to call at the end
153 * @param cbe_cls closure for cbe
154 * @param hostname where to run the peers; can be NULL (to run
155 * everything on localhost). Additional
156 * hosts can be specified using a NULL-terminated list of
157 * varargs, hosts will then be used round-robin from that
161 GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
162 struct GNUNET_CONFIGURATION_Handle *cfg,
164 const char *service_home_prefix,
165 const char *transports,
166 const char *applications,
167 GNUNET_TESTING_NotifyDaemonRunning cb,
169 GNUNET_TESTING_NotifyCompletion cbe,
171 const char *hostname,
176 va_start (va, hostname);
177 GNUNET_TESTING_daemons_start_va (sched, cfg,
178 total, service_home_prefix,
179 transports, applications,
180 cb, cb_cls, cbe, cbe_cls, hostname,
185 /* end of testing.c */