2 This file is part of GNUnet
3 (C) 2008, 2009, 2012 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 3, 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 include/gnunet_testing_service.h
23 * @brief API for writing tests and creating large-scale
24 * emulation testbeds for GNUnet.
25 * @author Christian Grothoff
28 #ifndef GNUNET_TESTING_SERVICE_H
29 #define GNUNET_TESTING_SERVICE_H
31 #include "gnunet_util_lib.h"
36 #if 0 /* keep Emacsens' auto-indent happy */
43 * Opaque handle to a host running experiments managed by the testing framework.
44 * The master process must be able to SSH to this host without password (via
47 struct GNUNET_TESTING_Host;
50 * Opaque handle to a peer controlled by the testing framework. A peer runs
51 * at a particular host.
53 struct GNUNET_TESTING_Peer;
56 * Opaque handle to an abstract operation to be executed by the testing framework.
58 struct GNUNET_TESTING_Operation;
61 * Handle to interact with a GNUnet testing controller. Each controller has at
62 * least one master handle which is created when the controller is created; this
63 * master handle interacts with the controller via stdin/stdout of the controller
64 * process. Additionally, controllers can interact with each other (in a P2P
65 * fashion); those links are established via TCP/IP on the controller's service
68 struct GNUNET_TESTING_Controller;
71 * Handle to a large-scale testbed that is managed at a high level.
73 struct GNUNET_TESTING_Testbed;
77 * Create a host to run peers and controllers on.
79 * @param hostname name of the host, use "NULL" for localhost
80 * @param username username to use for the login; may be NULL
81 * @param port port number to use for ssh; use 0 to let ssh decide
82 * @return handle to the host, NULL on error
84 struct GNUNET_TESTING_Host *
85 GNUNET_TESTING_host_create (const char *hostname,
91 * Load a set of hosts from a configuration file.
93 * @param filename file with the host specification
94 * @param hosts set to the hosts found in the file
95 * @return number of hosts returned in 'hosts', 0 on error
98 GNUNET_TESTING_hosts_load_from_file (const char *filename,
99 struct GNUNET_TESTING_Host **hosts);
103 * Configure shared services at a peer. Using this function,
104 * you can specify that certain services (such as "resolver")
105 * should not be run for each peer but instead be shared
106 * across N peers on the specified host. This function
107 * must be called before any peers are created at the host.
109 * @param host host to configure
110 * @param service_name name of the service to share
111 * @param num_peers number of peers that should share one instance
112 * of the specified service (1 for no sharing is the default),
113 * use 0 to disable the service
116 GNUNET_TESTING_host_configure (struct GNUNET_TESTING_Host *host,
117 const char *service_name,
122 * Destroy a host handle. Must only be called once everything
123 * running on that host has been stopped.
125 * @param host handle to destroy
128 GNUNET_TESTING_host_destroy (struct GNUNET_TESTING_Host *host);
132 * Enumeration with (at most 64) possible event types that
133 * can be monitored using the testing framework.
135 enum GNUNET_TESTING_EventType
138 * A peer has been started.
140 GNUNET_TESTING_ET_PEER_START = 0,
143 * A peer has been stopped.
145 GNUNET_TESTING_ET_PEER_STOP = 1,
148 * A connection between two peers was established.
150 GNUNET_TESTING_ET_CONNECT = 2,
153 * A connection between two peers was torn down.
155 GNUNET_TESTING_ET_DISCONNECT = 3
158 * A requested testing operation has been completed.
160 GNUNET_TESTING_ET_OPERATION_FINISHED = 4,
163 * The 'GNUNET_TESTING_run' operation has been completed
165 GNUNET_TESTING_ET_TESTBED_ONLINE = 5
171 * Argument to GNUNET_TESTING_ControllerCallback with details about
174 struct GNUNET_TESTING_EventInformation
180 enum GNUNET_TESTING_EventType type;
183 * Details about the event.
189 * Details about peer start event.
194 * Handle for the peer that was started.
196 struct GNUNET_TESTING_Peer *peer;
201 * Details about peer stop event.
206 * Handle for the host where the peer
209 struct GNUNET_TESTING_Host *host;
212 * Handle for the peer that was started.
214 struct GNUNET_TESTING_Peer *peer;
219 * Details about connect event.
224 * Handle for one of the connected peers.
226 struct GNUNET_TESTING_Peer *peer1;
229 * Handle for one of the connected peers.
231 struct GNUNET_TESTING_Peer *peer2;
236 * Details about disconnect event.
241 * Handle for one of the disconnected peers.
243 struct GNUNET_TESTING_Peer *peer1;
246 * Handle for one of the disconnected peers.
248 struct GNUNET_TESTING_Peer *peer2;
253 * Details about an operation finished event.
259 * Handle for the operation that was finished.
261 struct GNUNET_TESTING_Operation *operation;
264 * Closure that was passed in when the event was
270 * Error message for the operation, NULL on success.
275 * Peer information type; captures which of the types
276 * in the 'op_result' is actually in use.
278 enum GNUNET_TESTING_PeerInformationType pit;
281 * Pointer to an operation-specific return value; NULL on error;
282 * can be NULL for certain operations. Valid until
283 * 'GNUNET_TESTING_operation_done' is called.
288 * No result (NULL pointer) or generic result
289 * (whatever the GNUNET_TESTING_ConnectAdapter returned).
294 * Identity of host running the peer.
296 struct GNUNET_TESTING_Host *host;
299 * Identity of the peer.
301 const struct GNUNET_PeerIdentity *pid;
304 * Configuration of the peer.
306 const struct GNUNET_CONFIGURATION_Handle *cfg;
310 } operation_finished;
314 * Details about an testbed run completed event.
320 * Error message for the operation, NULL on success.
325 * Array of peers now running (valid until
326 * 'GNUNET_TESTING_testbed_stop' is called). Note that it is
327 * not allowed to call 'GNUNET_TESTING_peer_destroy' on peers
330 struct GNUNET_TESTING_Peer **peers;
333 * Size of the 'peers' array.
335 unsigned int num_peers;
337 } testbed_run_finished;
345 * Signature of the event handler function called by the
346 * respective event controller.
349 * @param event information about the event
351 typedef void (*GNUNET_TESTING_ControllerCallback)(void *cls,
352 const struct GNUNET_TESTING_EventInformation *event);
356 * Start a controller process using the given configuration at the
359 * @param cfg configuration to use
360 * @param host host to run the controller on, NULL for 'localhost'
361 * @param event_mask bit mask with set of events to call 'cc' for;
362 * or-ed values of "1LL" shifted by the
363 * respective 'enum GNUNET_TESTING_EventType'
364 * (i.e. "(1LL << GNUNET_TESTING_ET_CONNECT) || ...")
365 * @param cc controller callback to invoke on events
366 * @param cc_cls closure for cc
367 * @return handle to the controller
369 struct GNUNET_TESTING_Controller *
370 GNUNET_TESTING_controller_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
371 struct GNUNET_TESTING_Host *host,
373 GNUNET_TESTING_ControllerCallback cc,
379 * Stop the given controller (also will terminate all peers and
380 * controllers dependent on this controller). This function
381 * blocks until the testbed has been fully terminated (!).
383 * @param controller handle to controller to stop
386 GNUNET_TESTING_controller_stop (struct GNUNET_TESTING_Controller *controller);
390 * Create a link from a 'master' controller to a slave controller.
391 * Whenever the master controller is asked to start a peer at the
392 * given 'delegated_host', it will delegate the request to the
393 * specified slave controller. Note that the slave controller runs at
394 * the 'slave_host', which may or may not be the same host as the
395 * 'delegated_host' (for hierarchical delegations). The configuration
396 * of the slave controller is given and to be used to either create
397 * the slave controller or to connect to an existing slave controller
398 * process. 'is_subordinate' specifies if the given slave controller
399 * should be started and managed by the master controller, or if the
400 * slave already has a master and this is just a secondary master that
401 * is also allowed to use the existing slave.
403 * @param master handle to the master controller who creates the association
404 * @param delegated_host requests to which host should be delegated
405 * @param slave_host which host is used to run the slave controller
406 * @param slave_cfg configuration to use for the slave controller
407 * @param is_subordinate GNUNET_YES if the slave should be started (and stopped)
408 * by the master controller; GNUNET_NO if we are just
409 * allowed to use the slave via TCP/IP
412 GNUNET_TESTING_controller_link (struct GNUNET_TESTING_Controller *master,
413 struct GNUNET_TESTING_Host *delegated_host,
414 struct GNUNET_TESTING_Host *slave_host,
415 const struct GNUNET_CONFIGURATION_Handle *slave_cfg,
420 * Create the given peer at the specified host using the given
421 * controller. If the given controller is not running on the target
422 * host, it should find or create a controller at the target host and
423 * delegate creating the peer. Explicit delegation paths can be setup
424 * using 'GNUNET_TESTING_controller_link'. If no explicit delegation
425 * path exists, a direct link with a subordinate controller is setup
426 * for the first delegated peer to a particular host; the subordinate
427 * controller is then destroyed once the last peer that was delegated
428 * to the remote host is stopped.
430 * Creating the peer only creates the handle to manipulate and further
431 * configure the peer; use "GNUNET_TESTING_peer_start" and
432 * "GNUNET_TESTING_peer_stop" to actually start/stop the peer's
435 * Note that the given configuration will be adjusted by the
436 * controller to avoid port/path conflicts with other peers.
437 * The "final" configuration can be obtained using
438 * 'GNUNET_TESTING_peer_get_information'.
440 * @param controller controller process to use
441 * @param host host to run the peer on
442 * @param cfg configuration to use for the peer
443 * @return handle to the peer (actual startup will happen asynchronously)
445 struct GNUNET_TESTING_Peer *
446 GNUNET_TESTING_peer_create (struct GNUNET_TESTING_Controller *controller,
447 struct GNUNET_TESTING_Host *host,
448 const struct GNUNET_CONFIGURATION_Handle *cfg);
452 * Start the given peer.
454 * @param peer peer to start
455 * @return handle to the operation
457 struct GNUNET_TESTING_Operation *
458 GNUNET_TESTING_peer_start (struct GNUNET_TESTING_Peer *peer);
462 * Stop the given peer. The handle remains valid (use
463 * "GNUNET_TESTING_peer_destroy" to fully clean up the
464 * state of the peer).
466 * @param peer peer to stop
467 * @return handle to the operation
469 struct GNUNET_TESTING_Operation *
470 GNUNET_TESTING_peer_stop (struct GNUNET_TESTING_Peer *peer);
474 * Types of information that can be requested about a peer.
476 enum GNUNET_TESTING_PeerInformationType
480 * Special value (not valid for requesting information)
481 * that is used in the event struct if a 'generic' pointer
482 * is returned (for other operations not related to this
485 GNUNET_TESTING_PIT_GENERIC = 0,
488 * What host is the peer running on? Returns a 'const struct
489 * GNUNET_TESTING_Host *'. Valid until
490 * 'GNUNET_TESTING_operation_done' is called.
492 GNUNET_TESTING_PIT_HOST,
495 * What configuration is the peer using? Returns a 'const struct
496 * GNUNET_CONFIGURATION_Handle *'. Valid until
497 * 'GNUNET_TESTNIG_operation_done' is called. However, the
498 * values may be inaccurate if the peer is reconfigured in
501 GNUNET_TESTING_PIT_CONFIGURATION,
504 * What is the identity of the peer? Returns a
505 * 'const struct GNUNET_PeerIdentity *'. Valid until
506 * 'GNUNET_TESTNIG_operation_done' is called.
508 GNUNET_TESTING_PIT_IDENTITY
514 * Request information about a peer.
516 * @param peer peer to request information about
517 * @param pit desired information
518 * @return handle to the operation
520 struct GNUNET_TESTING_Operation *
521 GNUNET_TESTING_peer_get_information (struct GNUNET_TESTING_Peer *peer,
522 enum GNUNET_TESTING_PeerInformationType pit);
526 * Change peer configuration. Must only be called while the
527 * peer is stopped. Ports and paths cannot be changed this
530 * @param peer peer to change configuration for
531 * @param cfg new configuration (differences to existing
532 * configuration only)
533 * @return handle to the operation
535 struct GNUNET_TESTING_Operation *
536 GNUNET_TESTING_peer_update_configuration (struct GNUNET_TESTING_Peer *peer,
537 const struct GNUNET_CONFIGURATION_Handle *handle);
541 * Destroy the given peer; the peer should have been
542 * stopped first (if it was started).
544 * @param peer peer to stop
545 * @return handle to the operation
547 struct GNUNET_TESTING_Operation *
548 GNUNET_TESTING_peer_destroy (struct GNUNET_TESTING_Peer *peer);
552 * Options for peer connections.
554 enum GNUNET_TESTING_ConnectOption
557 * No option (not valid as an argument).
559 GNUNET_TESTING_CO_NONE = 0,
562 * Allow or disallow a connection between the specified peers.
563 * Followed by GNUNET_NO (int) if a connection is disallowed
564 * or GNUNET_YES if a connection is allowed. Note that the
565 * default (all connections allowed or disallowed) is
566 * specified in the configuration of the controller.
568 GNUNET_TESTING_CO_ALLOW = 1,
571 * FIXME: add (and implement) options to limit connection to
572 * particular transports, force simulation of particular latencies
573 * or message loss rates, or set bandwidth limitations.
580 * Manipulate the P2P underlay topology by configuring a link
583 * @param op_cls closure argument to give with the operation event
584 * @param p1 first peer
585 * @param p2 second peer
586 * @param co option to change
587 * @param ... option-specific values
588 * @return handle to the operation, NULL if configuring the link at this
589 * time is not allowed
591 struct GNUNET_TESTING_Operation *
592 GNUNET_TESTING_underlay_configure_link (void *op_cls,
593 struct GNUNET_TESTING_Peer *p1,
594 struct GNUNET_TESTING_Peer *p2,
595 enum GNUNET_TESTING_ConnectOption co, ...);
600 * Topologies supported for testbeds.
602 enum GNUNET_TESTING_Topology
605 * A clique (everyone connected to everyone else). No options.
607 GNUNET_TESTING_TOPOLOGY_CLIQUE,
610 * Small-world network (2d torus plus random links). Followed
611 * by the number of random links to add (unsigned int).
613 GNUNET_TESTING_TOPOLOGY_SMALL_WORLD,
616 * Small-world network (ring plus random links). Followed
617 * by the number of random links to add (unsigned int).
619 GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING,
622 * Ring topology. No options.
624 GNUNET_TESTING_TOPOLOGY_RING,
627 * 2-d torus. No options.
629 GNUNET_TESTING_TOPOLOGY_2D_TORUS,
632 * Random graph. Followed by the link density, that is the
633 * percentage of links present in relation to a clique
636 GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI,
639 * Certain percentage of peers are unable to communicate directly
640 * replicating NAT conditions. Followed by the fraction of
641 * NAT'ed peers (float).
643 GNUNET_TESTING_TOPOLOGY_INTERNAT,
646 * Scale free topology. FIXME: options?
648 GNUNET_TESTING_TOPOLOGY_SCALE_FREE,
651 * Straight line topology. No options.
653 GNUNET_TESTING_TOPOLOGY_LINE,
656 * All peers are disconnected. No options.
658 GNUNET_TESTING_TOPOLOGY_NONE,
661 * Read a topology from a given file. Followed by the name of the file (const char *).
663 GNUNET_TESTING_TOPOLOGY_FROM_FILE
668 * Configure overall network topology to have a particular shape.
670 * @param op_cls closure argument to give with the operation event
671 * @param num_peers number of peers in 'peers'
672 * @param peers array of 'num_peers' with the peers to configure
673 * @param topo desired underlay topology to use
674 * @param ap topology-specific options
675 * @return handle to the operation, NULL if configuring the topology
676 * is not allowed at this time
678 struct GNUNET_TESTING_Operation *
679 GNUNET_TESTING_underlay_configure_topology_va (void *op_cls,
680 unsigned int num_peers,
681 struct GNUNET_TESTING_Peer **peers,
682 enum GNUNET_TESTING_TopologyOption topo,
687 * Configure overall network topology to have a particular shape.
689 * @param op_cls closure argument to give with the operation event
690 * @param num_peers number of peers in 'peers'
691 * @param peers array of 'num_peers' with the peers to configure
692 * @param topo desired underlay topology to use
693 * @param ... topology-specific options
694 * @return handle to the operation, NULL if configuring the topology
695 * is not allowed at this time
697 struct GNUNET_TESTING_Operation *
698 GNUNET_TESTING_underlay_configure_topology (void *op_cls,
699 unsigned int num_peers,
700 struct GNUNET_TESTING_Peer **peers,
701 enum GNUNET_TESTING_TopologyOption topo,
706 * Both peers must have been started before calling this function.
707 * This function then obtains a HELLO from 'p1', gives it to 'p2'
708 * and asks 'p2' to connect to 'p1'.
710 * @param op_cls closure argument to give with the operation event
711 * @param p1 first peer
712 * @param p2 second peer
713 * @return handle to the operation, NULL if connecting these two
714 * peers is fundamentally not possible at this time (peers
715 * not running or underlay disallows)
717 struct GNUNET_TESTING_Operation *
718 GNUNET_TESTING_overlay_connect (void *op_cls,
719 struct GNUNET_TESTING_Peer *p1,
720 struct GNUNET_TESTING_Peer *p2);
724 * All peers must have been started before calling this function.
725 * This function then connects the given peers in the P2P overlay
726 * using the given topology.
728 * @param op_cls closure argument to give with the operation event
729 * @param num_peers number of peers in 'peers'
730 * @param peers array of 'num_peers' with the peers to configure
731 * @param topo desired underlay topology to use
732 * @param va topology-specific options
733 * @return handle to the operation, NULL if connecting these
734 * peers is fundamentally not possible at this time (peers
735 * not running or underlay disallows)
737 struct GNUNET_TESTING_Operation *
738 GNUNET_TESTING_overlay_configure_topology_va (void *op_cls,
739 unsigned int num_peers,
740 struct GNUNET_TESTING_Peer *peers,
741 enum GNUNET_TESTING_TopologyOption topo,
746 * All peers must have been started before calling this function.
747 * This function then connects the given peers in the P2P overlay
748 * using the given topology.
750 * @param op_cls closure argument to give with the operation event
751 * @param num_peers number of peers in 'peers'
752 * @param peers array of 'num_peers' with the peers to configure
753 * @param topo desired underlay topology to use
754 * @param ... topology-specific options
755 * @return handle to the operation, NULL if connecting these
756 * peers is fundamentally not possible at this time (peers
757 * not running or underlay disallows)
759 struct GNUNET_TESTING_Operation *
760 GNUNET_TESTING_overlay_configure_topology (void *op_cls,
761 unsigned int num_peers,
762 struct GNUNET_TESTING_Peer *peers,
763 enum GNUNET_TESTING_TopologyOption topo,
769 * Ask the testbed controller to write the current overlay topology to
770 * a file. Naturally, the file will only contain a snapshot as the
771 * topology may evolve all the time.
773 * @param controller overlay controller to inspect
774 * @param filename name of the file the topology should
778 GNUNET_TESTING_overlay_write_topology_to_file (struct GNUNET_TESTING_Controller *controller,
779 const char *filename);
783 * Adapter function called to establish a connection to
787 * @param cfg configuration of the peer to connect to
788 * @return service handle to return in 'op_result', NULL on error
790 typedef void * (*GNUNET_TESTING_ConnectAdapter)(void *cls,
791 const struct GNUNET_CONFIGURATION_Handle *cfg);
795 * Adapter function called to destroy a connection to
799 * @param op_result service handle returned from the connect adapter
801 typedef void (*GNUNET_TESTING_DisconnectAdapter)(void *cls,
806 * Connect to a service offered by the given peer. Will ensure that
807 * the request is queued to not overwhelm our ability to create and
808 * maintain connections with other systems. The actual service
809 * handle is then returned via the 'op_result' member in the event
810 * callback. The 'ca' callback is used to create the connection
811 * when the time is right; the 'da' callback will be used to
812 * destroy the connection (upon 'GNUNET_TESTING_operation_done').
813 * 'GNUNET_TESTING_operation_cancel' can be used to abort this
814 * operation until the event callback has been called.
816 * @param peer peer that runs the service
817 * @param service_name name of the service to connect to
818 * @param ca helper function to establish the connection
819 * @param da helper function to close the connection
820 * @param cada_cls closure for ca and da
821 * @return handle for the operation
823 struct GNUNET_TESTING_Operation *
824 GNUNET_TESTING_service_connect (struct GNUNET_TESTING_Peer *peer,
825 const char *service_name,
826 GNUNET_TESTING_ConnectAdapter ca,
827 GNUNET_TESTING_DisconnectAdapter da,
832 * Cancel a pending operation. Releases all resources
833 * of the operation and will ensure that no event
834 * is generated for the operation. Does NOT guarantee
835 * that the operation will be fully undone (or that
836 * nothing ever happened).
838 * @param operation operation to cancel
841 GNUNET_TESTING_operation_cancel (struct GNUNET_TESTING_Operation *operation);
845 * Signal that the information from an operation has been fully
846 * processed. This function MUST be called for each event
847 * of type 'operation_finished' to fully remove the operation
848 * from the operation queue. After calling this function, the
849 * 'op_result' becomes invalid (!).
851 * @param operation operation to signal completion for
854 GNUNET_TESTING_operation_done (struct GNUNET_TESTING_Operation *operation);
858 * Configure and run a testbed using the given
859 * master controller on 'num_hosts' starting
860 * 'num_peers' using the given peer configuration.
862 * @param controller master controller for the testbed
863 * (must not be destroyed until after the
864 * testbed is destroyed).
865 * @param num_hosts number of hosts in 'hosts', 0 to only
867 * @param hosts list of hosts to use for the testbed
868 * @param num_peers number of peers to start
869 * @param peer_cfg peer configuration template to use
870 * @param underlay_topology underlay topology to create
871 * @param va topology-specific options
872 * @return handle to the testbed
874 struct GNUNET_TESTING_Testbed *
875 GNUNET_TESTING_testbed_create_va (struct GNUNET_TESTING_Controller *controller,
876 unsigned int num_hosts,
877 struct GNUNET_TESTING_Host **hosts,
878 unsigned int num_peers,
879 const struct GNUNET_CONFIGURATION_Handle *peer_cfg,
880 enum GNUNET_TESTING_Topology topo,
885 * Configure and run a testbed using the given
886 * master controller on 'num_hosts' starting
887 * 'num_peers' using the given peer configuration.
889 * @param controller master controller for the testbed
890 * (must not be destroyed until after the
891 * testbed is destroyed).
892 * @param num_hosts number of hosts in 'hosts', 0 to only
894 * @param hosts list of hosts to use for the testbed
895 * @param num_peers number of peers to start
896 * @param peer_cfg peer configuration template to use
897 * @param underlay_topology underlay topology to create
898 * @param ... topology-specific options
900 struct GNUNET_TESTING_Testbed *
901 GNUNET_TESTING_testbed_create (struct GNUNET_TESTING_Controller *controller,
902 unsigned int num_hosts,
903 struct GNUNET_TESTING_Host **hosts,
904 unsigned int num_peers,
905 const struct GNUNET_CONFIGURATION_Handle *peer_cfg,
906 enum GNUNET_TESTING_Topology topo,
911 * Destroy a testbed. Stops all running peers and then
912 * destroys all peers. Does NOT destroy the master controller.
914 * @param testbed testbed to destroy
917 GNUNET_TESTING_testbed_destroy (struct GNUNET_TESTING_Testbed *testbed);
921 * Convenience method for running a testbed with
922 * a single call. Underlay and overlay topology
923 * are configured using the "UNDERLAY" and "OVERLAY"
924 * options in the "[testbed]" section of the configuration\
925 * (with possible options given in "UNDERLAY_XXX" and/or
928 * The testbed is to be terminated using a call to
929 * "GNUNET_SCHEDULER_shutdown".
931 * @param host_filename name of the file with the 'hosts', NULL
932 * to run everything on 'localhost'
933 * @param cfg configuration to use (for testbed, controller and peers)
934 * @param num_peers number of peers to start
935 * @param event_mask bit mask with set of events to call 'cc' for;
936 * or-ed values of "1LL" shifted by the
937 * respective 'enum GNUNET_TESTING_EventType'
938 * (i.e. "(1LL << GNUNET_TESTING_ET_CONNECT) || ...")
939 * @param cc controller callback to invoke on events
940 * @param cc_cls closure for cc
941 * @param master task to run once the testbed is ready
942 * @param master_cls closure for 'task'.
945 GNUNET_TESTING_testbed_run (const char *host_filename,
946 const struct GNUNET_CONFIGURATION_Handle *cfg,
947 unsigned int num_peers,
949 GNUNET_TESTING_ControllerCallback cc,
951 GNUNET_SCHEDULER_Task master,
956 * Signature of a main function for a testcase.
959 * @param num_peers number of peers in 'peers'
960 * @param peers handle to peers run in the testbed
962 typedef void (*GNUNET_TESTING_TestMaster)(void *cls,
963 unsigned int num_peers,
964 struct GNUNET_TESTING_Peer **peers);
968 * Convenience method for running a "simple" test on the local system
969 * with a single call from 'main'. Underlay and overlay topology are
970 * configured using the "UNDERLAY" and "OVERLAY" options in the
971 * "[testbed]" section of the configuration (with possible options
972 * given in "UNDERLAY_XXX" and/or "OVERLAY_XXX").
974 * The test is to be terminated using a call to
975 * "GNUNET_SCHEDULER_shutdown". If starting the test fails,
976 * the program is stopped without 'master' ever being run.
978 * NOTE: this function should be called from 'main', NOT from
979 * within a GNUNET_SCHEDULER-loop. This function will initialze
980 * the scheduler loop, the testbed and then pass control to
983 * @param testname name of the testcase (to configure logging, etc.)
984 * @param cfg_filename configuration filename to use
985 * (for testbed, controller and peers)
986 * @param num_peers number of peers to start
987 * @param test_master task to run once the test is ready
988 * @param test_master_cls closure for 'task'.
991 GNUNET_TESTING_test_run (const char *testname,
992 const char *cfg_filename,
993 unsigned int num_peers,
994 GNUNET_TESTING_TestMaster master,
998 #if 0 /* keep Emacsens' auto-indent happy */