diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-04-26 13:45:27 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-04-26 13:45:27 +0000 |
commit | c589835426fadcab0fff0a3cfca73f09279343d7 (patch) | |
tree | 4aab028421e85d278637ae4e896cf19e8ba613c9 /src/include/gnunet_testing_lib.h | |
parent | 4b3aa82c084d5ef81614f18d9e9c7d7ceddf1c4a (diff) | |
download | gnunet-c589835426fadcab0fff0a3cfca73f09279343d7.tar.gz gnunet-c589835426fadcab0fff0a3cfca73f09279343d7.zip |
stuff
Diffstat (limited to 'src/include/gnunet_testing_lib.h')
-rw-r--r-- | src/include/gnunet_testing_lib.h | 360 |
1 files changed, 155 insertions, 205 deletions
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h index 3047319e4..b9306dae7 100644 --- a/src/include/gnunet_testing_lib.h +++ b/src/include/gnunet_testing_lib.h | |||
@@ -42,10 +42,13 @@ extern "C" | |||
42 | #endif | 42 | #endif |
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | /* Forward declaration */ | 45 | /** |
46 | * Handle for a GNUnet daemon (technically a set of | ||
47 | * daemons; the handle is really for the master ARM | ||
48 | * daemon) started by the testing library. | ||
49 | */ | ||
46 | struct GNUNET_TESTING_Daemon; | 50 | struct GNUNET_TESTING_Daemon; |
47 | /* Forward declaration */ | 51 | |
48 | struct GNUNET_TESTING_PeerGroup; | ||
49 | 52 | ||
50 | /** | 53 | /** |
51 | * Prototype of a function that will be called whenever | 54 | * Prototype of a function that will be called whenever |
@@ -65,6 +68,142 @@ typedef void (*GNUNET_TESTING_NotifyDaemonRunning)(void *cls, | |||
65 | 68 | ||
66 | 69 | ||
67 | /** | 70 | /** |
71 | * Handle to an entire testbed of GNUnet peers. | ||
72 | */ | ||
73 | struct GNUNET_TESTING_Testbed; | ||
74 | |||
75 | /** | ||
76 | * Phases of starting GNUnet on a system. | ||
77 | */ | ||
78 | enum GNUNET_TESTING_StartPhase; | ||
79 | |||
80 | |||
81 | /** | ||
82 | * Handle for a GNUnet daemon (technically a set of | ||
83 | * daemons; the handle is really for the master ARM | ||
84 | * daemon) started by the testing library. | ||
85 | */ | ||
86 | struct GNUNET_TESTING_Daemon | ||
87 | { | ||
88 | /** | ||
89 | * Our scheduler. | ||
90 | */ | ||
91 | struct GNUNET_SCHEDULER_Handle *sched; | ||
92 | |||
93 | /** | ||
94 | * Our configuration. | ||
95 | */ | ||
96 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
97 | |||
98 | /** | ||
99 | * Host to run GNUnet on. | ||
100 | */ | ||
101 | char *hostname; | ||
102 | |||
103 | /** | ||
104 | * Result of GNUNET_i2s of this peer, | ||
105 | * for printing | ||
106 | */ | ||
107 | char *shortname; | ||
108 | |||
109 | /** | ||
110 | * Username we are using. | ||
111 | */ | ||
112 | char *username; | ||
113 | |||
114 | /** | ||
115 | * Name of the configuration file | ||
116 | */ | ||
117 | char *cfgfile; | ||
118 | |||
119 | /** | ||
120 | * Function to call when the peer is running. | ||
121 | */ | ||
122 | GNUNET_TESTING_NotifyDaemonRunning cb; | ||
123 | |||
124 | /** | ||
125 | * Closure for cb. | ||
126 | */ | ||
127 | void *cb_cls; | ||
128 | |||
129 | /** | ||
130 | * Arguments from "daemon_stop" call. | ||
131 | */ | ||
132 | GNUNET_TESTING_NotifyCompletion dead_cb; | ||
133 | |||
134 | /** | ||
135 | * Closure for 'dead_cb'. | ||
136 | */ | ||
137 | void *dead_cb_cls; | ||
138 | |||
139 | /** | ||
140 | * Arguments from "daemon_stop" call. | ||
141 | */ | ||
142 | GNUNET_TESTING_NotifyCompletion update_cb; | ||
143 | |||
144 | /** | ||
145 | * Closure for 'update_cb'. | ||
146 | */ | ||
147 | void *update_cb_cls; | ||
148 | |||
149 | /** | ||
150 | * Identity of this peer (once started). | ||
151 | */ | ||
152 | struct GNUNET_PeerIdentity id; | ||
153 | |||
154 | /** | ||
155 | * Flag to indicate that we've already been asked | ||
156 | * to terminate (but could not because some action | ||
157 | * was still pending). | ||
158 | */ | ||
159 | int dead; | ||
160 | |||
161 | /** | ||
162 | * PID of the process that we started last. | ||
163 | */ | ||
164 | pid_t pid; | ||
165 | |||
166 | /** | ||
167 | * How many iterations have we been waiting for | ||
168 | * the started process to complete? | ||
169 | */ | ||
170 | unsigned int wait_runs; | ||
171 | |||
172 | /** | ||
173 | * In which phase are we during the start of | ||
174 | * this process? | ||
175 | */ | ||
176 | enum GNUNET_TESTING_StartPhase phase; | ||
177 | |||
178 | /** | ||
179 | * ID of the current task. | ||
180 | */ | ||
181 | GNUNET_SCHEDULER_TaskIdentifier task; | ||
182 | |||
183 | /** | ||
184 | * Handle to the server. | ||
185 | */ | ||
186 | struct GNUNET_CORE_Handle *server; | ||
187 | |||
188 | /** | ||
189 | * Handle to the transport service of this peer | ||
190 | */ | ||
191 | struct GNUNET_TRANSPORT_Handle *th; | ||
192 | |||
193 | /** | ||
194 | * HELLO message for this peer | ||
195 | */ | ||
196 | struct GNUNET_HELLO_Message *hello; | ||
197 | }; | ||
198 | |||
199 | |||
200 | /** | ||
201 | * Handle to a group of GNUnet peers. | ||
202 | */ | ||
203 | struct GNUNET_TESTING_PeerGroup; | ||
204 | |||
205 | |||
206 | /** | ||
68 | * Prototype of a function that will be called whenever | 207 | * Prototype of a function that will be called whenever |
69 | * two daemons are connected by the testing library. | 208 | * two daemons are connected by the testing library. |
70 | * | 209 | * |
@@ -146,27 +285,6 @@ void GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d, | |||
146 | GNUNET_TESTING_NotifyCompletion cb, | 285 | GNUNET_TESTING_NotifyCompletion cb, |
147 | void * cb_cls); | 286 | void * cb_cls); |
148 | 287 | ||
149 | #if HIDDEN | ||
150 | /* | ||
151 | * Get the short name of a running peer | ||
152 | * | ||
153 | * @param d the daemon handle | ||
154 | */ | ||
155 | char * | ||
156 | GNUNET_TESTING_daemon_get_shortname(struct GNUNET_TESTING_Daemon *d); | ||
157 | |||
158 | char * | ||
159 | GNUNET_TESTING_daemon_get_hostname (struct GNUNET_TESTING_Daemon *d); | ||
160 | |||
161 | char * | ||
162 | GNUNET_TESTING_daemon_get_username (struct GNUNET_TESTING_Daemon *d); | ||
163 | |||
164 | struct GNUNET_PeerIdentity * | ||
165 | GNUNET_TESTING_daemon_get_peer (struct GNUNET_TESTING_Daemon *d); | ||
166 | |||
167 | struct GNUNET_CONFIGURATION_Handle * | ||
168 | GNUNET_TESTING_daemon_get_config (struct GNUNET_TESTING_Daemon *d); | ||
169 | #endif | ||
170 | 288 | ||
171 | /** | 289 | /** |
172 | * Establish a connection between two GNUnet daemons. | 290 | * Establish a connection between two GNUnet daemons. |
@@ -189,11 +307,6 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, | |||
189 | 307 | ||
190 | 308 | ||
191 | 309 | ||
192 | /** | ||
193 | * Handle to a group of GNUnet peers. | ||
194 | */ | ||
195 | struct GNUNET_TESTING_PeerGroup; | ||
196 | |||
197 | 310 | ||
198 | /** | 311 | /** |
199 | * Start count gnunetd processes with the same set of transports and | 312 | * Start count gnunetd processes with the same set of transports and |
@@ -231,182 +344,6 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, | |||
231 | void | 344 | void |
232 | GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg); | 345 | GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg); |
233 | 346 | ||
234 | int | ||
235 | GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg); | ||
236 | |||
237 | |||
238 | /** | ||
239 | * Handle to an entire testbed of GNUnet peers. | ||
240 | */ | ||
241 | struct GNUNET_TESTING_Testbed; | ||
242 | |||
243 | /** | ||
244 | * Phases of starting GNUnet on a system. | ||
245 | */ | ||
246 | enum StartPhase | ||
247 | { | ||
248 | /** | ||
249 | * Copy the configuration file to the target system. | ||
250 | */ | ||
251 | SP_COPYING, | ||
252 | |||
253 | /** | ||
254 | * Configuration file has been copied, start ARM on target system. | ||
255 | */ | ||
256 | SP_COPIED, | ||
257 | |||
258 | /** | ||
259 | * ARM has been started, check that it has properly daemonized and | ||
260 | * then try to connect to the CORE service (which should be | ||
261 | * auto-started by ARM). | ||
262 | */ | ||
263 | SP_START_ARMING, | ||
264 | |||
265 | /** | ||
266 | * We're waiting for CORE to start. | ||
267 | */ | ||
268 | SP_START_CORE, | ||
269 | |||
270 | /** | ||
271 | * Core has notified us that we've established a connection to the service. | ||
272 | * The main FSM halts here and waits to be moved to UPDATE or CLEANUP. | ||
273 | */ | ||
274 | SP_START_DONE, | ||
275 | |||
276 | /** | ||
277 | * We've been asked to terminate the instance and are now waiting for | ||
278 | * the remote command to stop the gnunet-arm process and delete temporary | ||
279 | * files. | ||
280 | */ | ||
281 | SP_SHUTDOWN_START, | ||
282 | |||
283 | /** | ||
284 | * We've received a configuration update and are currently waiting for | ||
285 | * the copy process for the update to complete. Once it is, we will | ||
286 | * return to "SP_START_DONE" (and rely on ARM to restart all affected | ||
287 | * services). | ||
288 | */ | ||
289 | SP_CONFIG_UPDATE | ||
290 | }; | ||
291 | |||
292 | |||
293 | /** | ||
294 | * Handle for a GNUnet daemon (technically a set of | ||
295 | * daemons; the handle is really for the master ARM | ||
296 | * daemon) started by the testing library. | ||
297 | */ | ||
298 | struct GNUNET_TESTING_Daemon | ||
299 | { | ||
300 | /** | ||
301 | * Our scheduler. | ||
302 | */ | ||
303 | struct GNUNET_SCHEDULER_Handle *sched; | ||
304 | |||
305 | /** | ||
306 | * Our configuration. | ||
307 | */ | ||
308 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
309 | |||
310 | /** | ||
311 | * Host to run GNUnet on. | ||
312 | */ | ||
313 | char *hostname; | ||
314 | |||
315 | /* | ||
316 | * Result of GNUNET_i2s of this peer, | ||
317 | * for printing | ||
318 | */ | ||
319 | char *shortname; | ||
320 | |||
321 | /** | ||
322 | * Username we are using. | ||
323 | */ | ||
324 | char *username; | ||
325 | |||
326 | /** | ||
327 | * Name of the configuration file | ||
328 | */ | ||
329 | char *cfgfile; | ||
330 | |||
331 | /** | ||
332 | * Function to call when the peer is running. | ||
333 | */ | ||
334 | GNUNET_TESTING_NotifyDaemonRunning cb; | ||
335 | |||
336 | /** | ||
337 | * Closure for cb. | ||
338 | */ | ||
339 | void *cb_cls; | ||
340 | |||
341 | /** | ||
342 | * Arguments from "daemon_stop" call. | ||
343 | */ | ||
344 | GNUNET_TESTING_NotifyCompletion dead_cb; | ||
345 | |||
346 | /** | ||
347 | * Closure for 'dead_cb'. | ||
348 | */ | ||
349 | void *dead_cb_cls; | ||
350 | |||
351 | /** | ||
352 | * Arguments from "daemon_stop" call. | ||
353 | */ | ||
354 | GNUNET_TESTING_NotifyCompletion update_cb; | ||
355 | |||
356 | /** | ||
357 | * Closure for 'update_cb'. | ||
358 | */ | ||
359 | void *update_cb_cls; | ||
360 | |||
361 | /** | ||
362 | * Identity of this peer (once started). | ||
363 | */ | ||
364 | struct GNUNET_PeerIdentity id; | ||
365 | |||
366 | /** | ||
367 | * Flag to indicate that we've already been asked | ||
368 | * to terminate (but could not because some action | ||
369 | * was still pending). | ||
370 | */ | ||
371 | int dead; | ||
372 | |||
373 | /** | ||
374 | * PID of the process that we started last. | ||
375 | */ | ||
376 | pid_t pid; | ||
377 | |||
378 | /** | ||
379 | * How many iterations have we been waiting for | ||
380 | * the started process to complete? | ||
381 | */ | ||
382 | unsigned int wait_runs; | ||
383 | |||
384 | /** | ||
385 | * In which phase are we during the start of | ||
386 | * this process? | ||
387 | */ | ||
388 | enum StartPhase phase; | ||
389 | |||
390 | /** | ||
391 | * ID of the current task. | ||
392 | */ | ||
393 | GNUNET_SCHEDULER_TaskIdentifier task; | ||
394 | |||
395 | /** | ||
396 | * Handle to the server. | ||
397 | */ | ||
398 | struct GNUNET_CORE_Handle *server; | ||
399 | |||
400 | /** | ||
401 | * Handle to the transport service of this peer | ||
402 | */ | ||
403 | struct GNUNET_TRANSPORT_Handle *th; | ||
404 | |||
405 | /** | ||
406 | * HELLO message for this peer | ||
407 | */ | ||
408 | struct GNUNET_HELLO_Message *hello; | ||
409 | }; | ||
410 | 347 | ||
411 | /** | 348 | /** |
412 | * Topologies supported for testbeds. | 349 | * Topologies supported for testbeds. |
@@ -450,6 +387,11 @@ enum GNUNET_TESTING_Topology | |||
450 | GNUNET_TESTING_TOPOLOGY_INTERNAT, | 387 | GNUNET_TESTING_TOPOLOGY_INTERNAT, |
451 | 388 | ||
452 | /** | 389 | /** |
390 | * FIXME: implement | ||
391 | */ | ||
392 | GNUNET_TESTING_TOPOLOGY_SCALE_FREE, | ||
393 | |||
394 | /** | ||
453 | * All peers are disconnected. | 395 | * All peers are disconnected. |
454 | */ | 396 | */ |
455 | GNUNET_TESTING_TOPOLOGY_NONE | 397 | GNUNET_TESTING_TOPOLOGY_NONE |
@@ -457,6 +399,14 @@ enum GNUNET_TESTING_Topology | |||
457 | 399 | ||
458 | 400 | ||
459 | /** | 401 | /** |
402 | * FIXME: document | ||
403 | */ | ||
404 | int | ||
405 | GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg | ||
406 | /* enum GNUNET_TESTING_Topology topo */); | ||
407 | |||
408 | |||
409 | /** | ||
460 | * Start "count" GNUnet daemons with a particular topology. | 410 | * Start "count" GNUnet daemons with a particular topology. |
461 | * | 411 | * |
462 | * @param sched scheduler to use | 412 | * @param sched scheduler to use |