aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_testing_lib.h
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-03-31 20:48:06 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-03-31 20:48:06 +0000
commit36291b73fab94a984ae4f7314f983e18492238be (patch)
treec5a2d753c04ebedcf236b0b31018789afbaf7e85 /src/include/gnunet_testing_lib.h
parent1517375e5b33fb42d6cd50fcbbc8d990ddd5b81a (diff)
downloadgnunet-36291b73fab94a984ae4f7314f983e18492238be.tar.gz
gnunet-36291b73fab94a984ae4f7314f983e18492238be.zip
support for asynchronous peer start/stop and service start/stop using ARM API
Diffstat (limited to 'src/include/gnunet_testing_lib.h')
-rw-r--r--src/include/gnunet_testing_lib.h117
1 files changed, 117 insertions, 0 deletions
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h
index 630152ddf..6b3333188 100644
--- a/src/include/gnunet_testing_lib.h
+++ b/src/include/gnunet_testing_lib.h
@@ -35,6 +35,7 @@
35 35
36#include "gnunet_util_lib.h" 36#include "gnunet_util_lib.h"
37#include "gnunet_statistics_service.h" 37#include "gnunet_statistics_service.h"
38#include "gnunet_arm_service.h"
38 39
39#ifdef __cplusplus 40#ifdef __cplusplus
40extern "C" 41extern "C"
@@ -284,6 +285,122 @@ GNUNET_TESTING_peer_wait (struct GNUNET_TESTING_Peer *peer);
284 285
285 286
286/** 287/**
288 * Callback to inform whether the peer is running or stopped.
289 *
290 * @param cls the closure from GNUNET_TESTING_peer_configure2()
291 * @param peer the respective peer whose status is being reported
292 * @param success GNUNET_YES if the peer is running; GNUNET_NO if the peer is
293 * not running; GNUNET_SYSERR upon error communicating with the peer's
294 * ARM service
295 */
296typedef void (*GNUNET_TESTING_PeerStatusCallback) (void *cls,
297 struct GNUNET_TESTING_Peer *
298 peer,
299 int success);
300
301
302/**
303 * Wrapper over GNUNET_TESTING_peer_configure() to set the
304 * GNUNET_TESTING_PeerStatusCallback() for using functions
305 * GNUNET_TESTING_peer_start2() and GNUNET_TESTING_peer_stop2()
306 *
307 * @param system system to use to coordinate resource usage
308 * @param cfg configuration to use; will be UPDATED (to reflect needed
309 * changes in port numbers and paths)
310 * @param key_number number of the hostkey to use for the peer
311 * @param id identifier for the daemon, will be set, can be NULL
312 * @param emsg set to freshly allocated error message (set to NULL on success),
313 * can be NULL
314 * @param status_cb the status callback to call upon peer start and stop
315 * @return handle to the peer, NULL on error
316 */
317struct GNUNET_TESTING_Peer *
318GNUNET_TESTING_peer_configure2 (struct GNUNET_TESTING_System *system,
319 struct GNUNET_CONFIGURATION_Handle *cfg,
320 uint32_t key_number,
321 struct GNUNET_PeerIdentity *id,
322 char **emsg,
323 GNUNET_TESTING_PeerStatusCallback status_cb,
324 void *cls);
325
326
327/**
328 * Start a peer asynchronously using ARM API. Peer's startup is signaled
329 * through the GNUNET_TESTING_PeerStatusCallback() given to
330 * GNUNET_TESTING_peer_configure2(). To use this function the peer must be
331 * configured earlier using GNUNET_TESTING_peer_configure2();
332 *
333 * @param peer the peer to start
334 * @param timeout how long to wait before giving up to start the peer
335 * @return GNUNET_OK upon successfully giving the request to the ARM API (this
336 * does not mean that the peer is successfully started); GNUNET_SYSERR
337 * upon any error.
338 */
339int
340GNUNET_TESTING_peer_start2 (struct GNUNET_TESTING_Peer *peer,
341 struct GNUNET_TIME_Relative timeout);
342
343
344/**
345 * Stop a peer asynchronously using ARM API. Peer's shutdown is signaled
346 * through the GNUNET_TESTING_PeerStatusCallback() given to
347 * GNUNET_TESTING_peer_configure2(). To use this function the peer must be
348 * configured earlier using GNUNET_TESTING_peer_configure2();
349 *
350 * @param peer the peer to stop
351 * @param timeout how long to wait before giving up to stop the peer
352 * @return GNUNET_OK upon successfully giving the request to the ARM API (this
353 * does not mean that the peer is successfully stopped); GNUNET_SYSERR
354 * upon any error.
355 */
356int
357GNUNET_TESTING_peer_stop2 (struct GNUNET_TESTING_Peer *peer,
358 struct GNUNET_TIME_Relative timeout);
359
360
361/**
362 * Start a service at a peer using its ARM service. To use this function the
363 * peer must be configured earlier using GNUNET_TESTING_peer_configure2();
364 *
365 * @param peer the peer whose service has to be started
366 * @param service_name name of the service to start
367 * @param timeout how long should the ARM API try to send the request to start
368 * the service
369 * @param cont the callback to call with result and status from ARM API
370 * @param cont_cls the closure for the above callback
371 * @return GNUNET_OK upon successfully queuing the service start request;
372 * GNUNET_SYSERR upon error
373 */
374int
375GNUNET_TESTING_peer_service_start (struct GNUNET_TESTING_Peer *peer,
376 const char *service_name,
377 struct GNUNET_TIME_Relative timeout,
378 GNUNET_ARM_ResultCallback cont,
379 void *cont_cls);
380
381
382/**
383 * Stop a service at a peer using its ARM service. To use this function the
384 * peer must be configured earlier using GNUNET_TESTING_peer_configure2();
385 *
386 * @param peer the peer whose service has to be stopped
387 * @param service_name name of the service to stop
388 * @param timeout how long should the ARM API try to send the request to stop
389 * the service
390 * @param cont the callback to call with result and status from ARM API
391 * @param cont_cls the closure for the above callback
392 * @return GNUNET_OK upon successfully queuing the service stop request;
393 * GNUNET_SYSERR upon error
394 */
395int
396GNUNET_TESTING_peer_service_stop (struct GNUNET_TESTING_Peer *peer,
397 const char *service_name,
398 struct GNUNET_TIME_Relative timeout,
399 GNUNET_ARM_ResultCallback cont,
400 void *cont_cls);
401
402
403/**
287 * Signature of the 'main' function for a (single-peer) testcase that 404 * Signature of the 'main' function for a (single-peer) testcase that
288 * is run using 'GNUNET_TESTING_peer_run'. 405 * is run using 'GNUNET_TESTING_peer_run'.
289 * 406 *