X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Finclude%2Fgnunet_testing_lib.h;h=b170670d1ffe92a3d8230dd73142c77783759f23;hb=211fd52268a5ae7856273dd8d8b3b3ed427beadb;hp=42ee990c9be44d80be29c7524a0968a6f44a4753;hpb=4fe5a61f8149aeaf7da9f32408b3c3195695e0c4;p=oweals%2Fgnunet.git diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h index 42ee990c9..b170670d1 100644 --- a/src/include/gnunet_testing_lib.h +++ b/src/include/gnunet_testing_lib.h @@ -304,9 +304,34 @@ struct GNUNET_TESTING_Daemon void *update_cb_cls; /** - * PID of the process that we started last. + * PID of the process we used to run gnunet-arm or SSH to start the peer. */ - struct GNUNET_OS_Process *proc; + struct GNUNET_OS_Process *proc_arm_start; + + /** + * PID of the process we used to run gnunet-arm or SSH to stop the peer. + */ + struct GNUNET_OS_Process *proc_arm_stop; + + /** + * PID of the process we used to run gnunet-arm or SSH to manage services at the peer. + */ + struct GNUNET_OS_Process *proc_arm_srv_start; + + /** + * PID of the process we used to run gnunet-arm or SSH to manage services at the peer. + */ + struct GNUNET_OS_Process *proc_arm_srv_stop; + + /** + * PID of the process we used to run copy files + */ + struct GNUNET_OS_Process *proc_arm_copying; + + /** + * PID of the process we used to run gnunet-peerinfo. + */ + struct GNUNET_OS_Process *proc_arm_peerinfo; /** * Handle to the server. @@ -318,6 +343,11 @@ struct GNUNET_TESTING_Daemon */ struct GNUNET_TRANSPORT_Handle *th; + /** + * Handle for getting HELLOs from transport + */ + struct GNUNET_TRANSPORT_GetHelloHandle *ghh; + /** * HELLO message for this peer */ @@ -427,6 +457,7 @@ typedef void (*GNUNET_TESTING_NotifyConnection) (void *cls, second_daemon, const char *emsg); + /** * Prototype of a callback function indicating that two peers * are currently connected. @@ -443,6 +474,7 @@ typedef void (*GNUNET_TESTING_NotifyTopology) (void *cls, const struct GNUNET_PeerIdentity * second, const char *emsg); + /** * Starts a GNUnet daemon. GNUnet must be installed on the target * system and available in the PATH. The machine must furthermore be @@ -486,16 +518,31 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, void GNUNET_TESTING_daemon_continue_startup (struct GNUNET_TESTING_Daemon *daemon); + /** * Check whether the given daemon is running. * * @param daemon the daemon to check - * * @return GNUNET_YES if the daemon is up, GNUNET_NO if the * daemon is down, GNUNET_SYSERR on error. */ int -GNUNET_TESTING_daemon_running (struct GNUNET_TESTING_Daemon *daemon); +GNUNET_TESTING_test_daemon_running (struct GNUNET_TESTING_Daemon *daemon); + + +/** + * Obtain the peer identity of the peer with the given configuration + * handle. This function reads the private key of the peer, obtains + * the public key and hashes it. + * + * @param cfg configuration of the peer + * @param pid where to store the peer identity + * @return GNUNET_OK on success, GNUNET_SYSERR on failure + */ +int +GNUNET_TESTING_get_peer_identity (const struct GNUNET_CONFIGURATION_Handle *cfg, + struct GNUNET_PeerIdentity *pid); + /** * Restart (stop and start) a GNUnet daemon. @@ -509,6 +556,7 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d, GNUNET_TESTING_NotifyDaemonRunning cb, void *cb_cls); + /** * Start a peer that has previously been stopped using the daemon_stop * call (and files weren't deleted and the allow restart flag) @@ -524,6 +572,7 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon, GNUNET_TESTING_NotifyDaemonRunning cb, void *cb_cls); + /** * Starts a GNUnet daemon's service. * @@ -535,11 +584,12 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon, */ void GNUNET_TESTING_daemon_start_service (struct GNUNET_TESTING_Daemon *d, - char *service, + const char *service, struct GNUNET_TIME_Relative timeout, GNUNET_TESTING_NotifyDaemonRunning cb, void *cb_cls); + /** * Starts a GNUnet daemon's service which has been previously turned off. * @@ -557,6 +607,7 @@ GNUNET_TESTING_daemon_start_stopped_service (struct GNUNET_TESTING_Daemon *d, GNUNET_TESTING_NotifyDaemonRunning cb, void *cb_cls); + /** * Get a certain testing daemon handle. * @@ -579,7 +630,7 @@ GNUNET_TESTING_daemon_get (struct GNUNET_TESTING_PeerGroup *pg, */ struct GNUNET_TESTING_Daemon * GNUNET_TESTING_daemon_get_by_id (struct GNUNET_TESTING_PeerGroup *pg, - struct GNUNET_PeerIdentity *peer_id); + const struct GNUNET_PeerIdentity *peer_id); /** @@ -602,6 +653,29 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, int delete_files, int allow_restart); + +/** + * Create a new configuration using the given configuration + * as a template; however, each PORT in the existing cfg + * must be renumbered by incrementing "*port". If we run + * out of "*port" numbers, return NULL. + * + * @param cfg template configuration + * @param off the current peer offset + * @param port port numbers to use, update to reflect + * port numbers that were used + * @param upnum number to make unix domain socket names unique + * @param hostname hostname of the controlling host, to allow control connections from + * @param fdnum number used to offset the unix domain socket for grouped processes + * (such as statistics or peerinfo, which can be shared among others) + * + * @return new configuration, NULL on error + */ +struct GNUNET_CONFIGURATION_Handle * +GNUNET_TESTING_create_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off, + uint16_t * port, uint32_t * upnum, const char *hostname, + uint32_t * fdnum); + /** * Changes the configuration of a GNUnet daemon. * @@ -631,7 +705,7 @@ GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d, */ void GNUNET_TESTING_daemon_stop_service (struct GNUNET_TESTING_Daemon *d, - char *service, + const char *service, struct GNUNET_TIME_Relative timeout, GNUNET_TESTING_NotifyCompletion cb, void *cb_cls); @@ -703,7 +777,16 @@ GNUNET_TESTING_daemons_continue_startup (struct GNUNET_TESTING_PeerGroup *pg); /** - * Establish a connection between two GNUnet daemons. + * Handle for an active request to connect two peers. + */ +struct GNUNET_TESTING_ConnectContext; + + +/** + * Establish a connection between two GNUnet daemons. The daemons + * must both be running and not be stopped until either the + * 'cb' callback is called OR the connection request has been + * explicitly cancelled. * * @param d1 handle for the first daemon * @param d2 handle for the second daemon @@ -715,6 +798,7 @@ GNUNET_TESTING_daemons_continue_startup (struct GNUNET_TESTING_PeerGroup *pg); * the HELLO has already been exchanged * @param cb function to call at the end * @param cb_cls closure for cb + * @return handle to cancel the request, NULL on error */ struct GNUNET_TESTING_ConnectContext * GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, @@ -726,13 +810,16 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, void *cb_cls); + /** * Cancel an attempt to connect two daemons. * * @param cc connect context */ void -GNUNET_TESTING_daemons_connect_cancel (struct GNUNET_TESTING_ConnectContext *cc); +GNUNET_TESTING_daemons_connect_cancel (struct GNUNET_TESTING_ConnectContext + *cc); + /**