testing-update
[oweals/gnunet.git] / src / testing / testing.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.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  * 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.
39  */
40 struct GNUNET_TESTING_Daemon
41 {
42 };
43
44
45 /**
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.
50  *
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)
58  */
59 struct GNUNET_TESTING_Daemon *
60 GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched,
61                              struct GNUNET_CONFIGURATION_Handle *cfg,
62                              const char *hostname,
63                              GNUNET_TESTING_NotifyDaemonRunning cb,
64                              void *cb_cls)
65 {
66   return NULL;
67 }
68
69
70 /**
71  * Stops a GNUnet daemon.
72  *
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
76  */
77 void GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
78                                  GNUNET_TESTING_NotifyCompletion cb,
79                                  void * cb_cls)
80 {
81 }
82
83
84 /**
85  * Changes the configuration of a GNUnet daemon.
86  *
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
91  */
92 void GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d,
93                                         const struct GNUNET_CONFIGURATION_Handle *cfg,
94                                         GNUNET_TESTING_NotifyCompletion cb,
95                                         void * cb_cls)
96 {
97 }
98
99
100 /**
101  * Establish a connection between two GNUnet daemons.
102  *
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
106  *        allowed to take?
107  * @param cb function to call at the end
108  * @param cb_cls closure for cb
109  */
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,
114                                      void *cb_cls)
115 {
116 }
117
118
119
120
121
122 /* end of testing.c */
123
124 {
125   va_list va;
126   
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,
132                                    va);
133   va_end (va);
134 }