longer timeout to make test work on slower machines, but the problem is still that...
[oweals/gnunet.git] / src / testing / testing_testbed.c
1 /*
2       This file is part of GNUnet
3       (C) 2008, 2009 Christian Grothoff (and other contributing authors)
4
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.
9
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.
14
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.
19  */
20
21 /**
22  * @file testing/testing_testbed.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
30  */
31 #include "platform.h"
32 #include "gnunet_arm_service.h"
33 #include "gnunet_testing_lib.h"
34
35
36 /**
37  * Handle to an entire testbed of GNUnet peers.
38  */
39 struct GNUNET_TESTING_Testbed
40 {
41 };
42
43
44 /**
45  * Start "count" GNUnet daemons with a particular topology.
46  *
47  * @param sched scheduler to use 
48  * @param cfg configuration template to use
49  * @param count number of peers the testbed should have
50  * @param topology desired topology (enforced via F2F)
51  * @param cb function to call on each daemon that was started
52  * @param cb_cls closure for cb
53  * @param hostname where to run the peers; can be NULL (to run
54  *        everything on localhost). Additional
55  *        hosts can be specified using a NULL-terminated list of
56  *        varargs, hosts will then be used round-robin from that
57  *        list.
58  * @return handle to control the testbed
59  */
60 struct GNUNET_TESTING_Testbed *
61 GNUNET_TESTING_testbed_start (struct GNUNET_SCHEDULER_Handle *sched,
62                               const struct GNUNET_CONFIGURATION_Handle *cfg,
63                               unsigned int count,
64                               enum GNUNET_TESTING_Topology topology,
65                               GNUNET_TESTING_NotifyDaemonRunning cb,
66                               void *cb_cls,
67                               const char *hostname,
68                               ...)
69 {
70   GNUNET_break (0);
71   return NULL;
72 }
73
74
75 /**
76  * Stop all of the daemons started with the start function.
77  *
78  * @param tb handle for the testbed
79  * @param cb function to call when done
80  * @param cb_cls closure for cb
81  */
82 void
83 GNUNET_TESTING_testbed_stop (struct GNUNET_TESTING_Testbed *tb,
84                              GNUNET_TESTING_NotifyCompletion cb,
85                              void *cb_cls)
86 {
87   GNUNET_break (0);
88 }
89
90
91 /**
92  * Simulate churn in the testbed by stopping some peers (and possibly
93  * re-starting others if churn is called multiple times).  This
94  * function can only be used to create leave-join churn (peers "never"
95  * leave for good).  First "voff" random peers that are currently
96  * online will be taken offline; then "von" random peers that are then
97  * offline will be put back online.  No notifications will be
98  * generated for any of these operations except for the callback upon
99  * completion.  Note that the implementation is at liberty to keep
100  * the ARM service itself (but none of the other services or daemons)
101  * running even though the "peer" is being varied offline.
102  *
103  * @param tb handle for the testbed
104  * @param voff number of peers that should go offline
105  * @param von number of peers that should come back online;
106  *            must be zero on first call (since "testbed_start"
107  *            always starts all of the peers)
108  * @param cb function to call at the end
109  * @param cb_cls closure for cb
110  */
111 void
112 GNUNET_TESTING_testbed_churn (struct GNUNET_TESTING_Testbed *tb,
113                               unsigned int voff,
114                               unsigned int von,
115                               GNUNET_TESTING_NotifyCompletion cb,
116                               void *cb_cls)
117 {
118   GNUNET_break (0);
119 }
120
121
122 /* end of testing_testbed.c */