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. GNUnet must be installed on the target
47 * system and available in the PATH. The machine must furthermore be
48 * reachable via "ssh" (unless the hostname is "NULL") without the
49 * need to enter a password.
51 * @param sched scheduler to use
52 * @param cfg configuration to use
53 * @param hostname name of the machine where to run GNUnet
54 * (use NULL for localhost).
55 * @param cb function to call with the result
56 * @param cb_cls closure for cb
57 * @return handle to the daemon (actual start will be completed asynchronously)
59 struct GNUNET_TESTING_Daemon *
60 GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched,
61 struct GNUNET_CONFIGURATION_Handle *cfg,
63 GNUNET_TESTING_NotifyDaemonRunning cb,
71 * Stops a GNUnet daemon.
73 * @param d the daemon that should be stopped
74 * @param cb function called once the daemon was stopped
75 * @param cb_cls closure for cb
77 void GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
78 GNUNET_TESTING_NotifyCompletion cb,
85 * Changes the configuration of a GNUnet daemon.
87 * @param d the daemon that should be modified
88 * @param cfg the new configuration for the daemon
89 * @param cb function called once the configuration was changed
90 * @param cb_cls closure for cb
92 void GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d,
93 const struct GNUNET_CONFIGURATION_Handle *cfg,
94 GNUNET_TESTING_NotifyCompletion cb,
101 * Establish a connection between two GNUnet daemons.
103 * @param d1 handle for the first daemon
104 * @param d2 handle for the second daemon
105 * @param timeout how long is the connection attempt
107 * @param cb function to call at the end
108 * @param cb_cls closure for cb
110 void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
111 struct GNUNET_TESTING_Daemon *d2,
112 struct GNUNET_TIME_Relative timeout,
113 GNUNET_TESTING_NotifyCompletion cb,
122 /* end of testing.c */
127 va_start (va, hostname);
128 GNUNET_TESTING_daemons_start_va (sched, cfg,
129 total, service_home_prefix,
130 transports, applications,
131 cb, cb_cls, cbe, cbe_cls, hostname,