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_group.c
23 * @brief convenience API for writing testcases for GNUnet
24 * @author Christian Grothoff
27 #include "gnunet_arm_service.h"
28 #include "gnunet_testing_lib.h"
32 * Handle to a group of GNUnet peers.
34 struct GNUNET_TESTING_PeerGroup
39 struct GNUNET_SCHEDULER_Handle *sched;
42 * Configuration template.
44 struct GNUNET_CONFIGURATION_Handle *cfg;
47 * Function to call on each started daemon.
49 GNUNET_TESTING_NotifyDaemonRunning cb;
57 * NULL-terminated array of hostnames.
62 * Array of "total" peers.
64 struct GNUNET_TESTING_Daemon **peers;
67 * Number of peers in this group.
75 * Start count gnunetd processes with the same set of transports and
76 * applications. The port numbers (any option called "PORT") will be
77 * adjusted to ensure that no two peers running on the same system
78 * have the same port(s) in their respective configurations.
80 * @param sched scheduler to use
81 * @param cfg configuration template to use
82 * @param total number of daemons to start
83 * @param cb function to call on each daemon that was started
84 * @param cb_cls closure for cb
85 * @param hostname where to run the peers; can be NULL (to run
86 * everything on localhost).
87 * @param va Additional hosts can be specified using a NULL-terminated list of
88 * varargs, hosts will then be used round-robin from that
89 * list; va only contains anything if hostname != NULL.
90 * @return NULL on error, otherwise handle to control peer group
92 struct GNUNET_TESTING_PeerGroup *
93 GNUNET_TESTING_daemons_start_va (struct GNUNET_SCHEDULER_Handle *sched,
94 const struct GNUNET_CONFIGURATION_Handle *cfg,
96 GNUNET_TESTING_NotifyDaemonRunning cb,
101 struct GNUNET_TESTING_PeerGroup *pg;
103 pg = GNUNET_malloc (sizeof(struct GNUNET_TESTING_PeerGroup));
109 * Start count gnunetd processes with the same set of
110 * transports and applications. The port numbers will
111 * be computed by adding delta each time (zero
112 * times for the first peer).
114 * @param sched scheduler to use
115 * @param cfg configuration template to use
116 * @param total number of daemons to start
117 * @param timeout how long is this allowed to take?
118 * @param cb function to call on each daemon that was started
119 * @param cb_cls closure for cb
120 * @param hostname where to run the peers; can be NULL (to run
121 * everything on localhost). Additional
122 * hosts can be specified using a NULL-terminated list of
123 * varargs, hosts will then be used round-robin from that
125 * @return NULL on error, otherwise handle to control peer group
127 struct GNUNET_TESTING_PeerGroup *
128 GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
129 struct GNUNET_CONFIGURATION_Handle *cfg,
131 GNUNET_TESTING_NotifyDaemonRunning cb,
133 const char *hostname,
136 struct GNUNET_TESTING_PeerGroup * ret;
139 va_start (va, hostname);
140 ret = GNUNET_TESTING_daemons_start_va (sched, cfg,
141 total, cb, cb_cls, hostname,
150 * Shutdown all peers started in the given group.
152 * @param pg handle to the peer group
155 GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg)
162 /* end of testing_group.c */