[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: -fix FTBFS
From: |
gnunet |
Subject: |
[gnunet] branch master updated: -fix FTBFS |
Date: |
Mon, 20 May 2024 15:37:54 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new a20d0ba31 -fix FTBFS
a20d0ba31 is described below
commit a20d0ba31562818a2c219d983667214505d15ab9
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon May 20 15:37:45 2024 +0200
-fix FTBFS
---
src/include/gnunet_arm_service.h | 82 +--
src/include/gnunet_testbed_lib.h | 43 +-
src/include/gnunet_testing_arm_lib.h | 19 +-
src/include/gnunet_testing_testbed_lib.h | 2 +-
src/include/gnunet_testing_transport_lib.h | 5 -
src/service/arm/Makefile.am | 2 +
src/service/arm/testing_arm_cmd_start_peer.c | 758 ++++++---------------------
src/service/arm/testing_arm_cmd_stop_peer.c | 64 +--
src/service/testbed/testbed.c | 175 +------
9 files changed, 268 insertions(+), 882 deletions(-)
diff --git a/src/include/gnunet_arm_service.h b/src/include/gnunet_arm_service.h
index 639e723c5..ef860bff4 100644
--- a/src/include/gnunet_arm_service.h
+++ b/src/include/gnunet_arm_service.h
@@ -244,8 +244,9 @@ struct GNUNET_ARM_Operation;
* #GNUNET_SYSERR if there was an error.
*/
typedef void
-(*GNUNET_ARM_ConnectionStatusCallback) (void *cls,
- int connected);
+(*GNUNET_ARM_ConnectionStatusCallback) (
+ void *cls,
+ enum GNUNET_GenericReturnValue connected);
/**
@@ -259,9 +260,10 @@ typedef void
* @param result result of the operation
*/
typedef void
-(*GNUNET_ARM_ResultCallback) (void *cls,
- enum GNUNET_ARM_RequestStatus rs,
- enum GNUNET_ARM_Result result);
+(*GNUNET_ARM_ResultCallback) (
+ void *cls,
+ enum GNUNET_ARM_RequestStatus rs,
+ enum GNUNET_ARM_Result result);
/**
@@ -276,10 +278,11 @@ typedef void
* @param list list of services managed by arm
*/
typedef void
-(*GNUNET_ARM_ServiceListCallback) (void *cls,
- enum GNUNET_ARM_RequestStatus rs,
- unsigned int count,
- const struct GNUNET_ARM_ServiceInfo *list);
+(*GNUNET_ARM_ServiceListCallback) (
+ void *cls,
+ enum GNUNET_ARM_RequestStatus rs,
+ unsigned int count,
+ const struct GNUNET_ARM_ServiceInfo *list);
/**
@@ -294,18 +297,20 @@ typedef void
* @return context to use for further ARM operations, NULL on error.
*/
struct GNUNET_ARM_Handle *
-GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
- GNUNET_ARM_ConnectionStatusCallback conn_status,
- void *conn_status_cls);
+GNUNET_ARM_connect (
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ GNUNET_ARM_ConnectionStatusCallback conn_status,
+ void *conn_status_cls);
/**
* Disconnect from the ARM service and destroy the handle.
*
- * @param h the handle that was being used
+ * @param[in] h the handle that was being used
*/
void
-GNUNET_ARM_disconnect (struct GNUNET_ARM_Handle *h);
+GNUNET_ARM_disconnect (
+ struct GNUNET_ARM_Handle *h);
/**
@@ -315,7 +320,8 @@ GNUNET_ARM_disconnect (struct GNUNET_ARM_Handle *h);
* @param op operation to cancel
*/
void
-GNUNET_ARM_operation_cancel (struct GNUNET_ARM_Operation *op);
+GNUNET_ARM_operation_cancel (
+ struct GNUNET_ARM_Operation *op);
/**
@@ -327,9 +333,10 @@ GNUNET_ARM_operation_cancel (struct GNUNET_ARM_Operation
*op);
* @return handle for the operation, NULL on error
*/
struct GNUNET_ARM_Operation *
-GNUNET_ARM_request_service_list (struct GNUNET_ARM_Handle *h,
- GNUNET_ARM_ServiceListCallback cont,
- void *cont_cls);
+GNUNET_ARM_request_service_list (
+ struct GNUNET_ARM_Handle *h,
+ GNUNET_ARM_ServiceListCallback cont,
+ void *cont_cls);
/**
@@ -347,10 +354,11 @@ GNUNET_ARM_request_service_list (struct GNUNET_ARM_Handle
*h,
* @return handle for the operation, NULL on error
*/
struct GNUNET_ARM_Operation *
-GNUNET_ARM_request_service_stop (struct GNUNET_ARM_Handle *h,
- const char *service_name,
- GNUNET_ARM_ResultCallback cont,
- void *cont_cls);
+GNUNET_ARM_request_service_stop (
+ struct GNUNET_ARM_Handle *h,
+ const char *service_name,
+ GNUNET_ARM_ResultCallback cont,
+ void *cont_cls);
/**
@@ -364,12 +372,12 @@ GNUNET_ARM_request_service_stop (struct GNUNET_ARM_Handle
*h,
* @return handle for the operation, NULL on error
*/
struct GNUNET_ARM_Operation *
-GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h,
- const char *service_name,
- enum GNUNET_OS_InheritStdioFlags
- std_inheritance,
- GNUNET_ARM_ResultCallback cont,
- void *cont_cls);
+GNUNET_ARM_request_service_start (
+ struct GNUNET_ARM_Handle *h,
+ const char *service_name,
+ enum GNUNET_OS_InheritStdioFlags std_inheritance,
+ GNUNET_ARM_ResultCallback cont,
+ void *cont_cls);
/**
@@ -386,10 +394,10 @@ struct GNUNET_ARM_MonitorHandle;
* @param status status of the service
*/
typedef void
-(*GNUNET_ARM_ServiceMonitorCallback) (void *cls,
- const char *service,
- enum GNUNET_ARM_ServiceMonitorStatus
- status);
+(*GNUNET_ARM_ServiceMonitorCallback) (
+ void *cls,
+ const char *service,
+ enum GNUNET_ARM_ServiceMonitorStatus status);
/**
@@ -404,9 +412,10 @@ typedef void
* @return context to use for further ARM monitor operations, NULL on error.
*/
struct GNUNET_ARM_MonitorHandle *
-GNUNET_ARM_monitor_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
- GNUNET_ARM_ServiceMonitorCallback cont,
- void *cont_cls);
+GNUNET_ARM_monitor_start (
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ GNUNET_ARM_ServiceMonitorCallback cont,
+ void *cont_cls);
/**
@@ -415,7 +424,8 @@ GNUNET_ARM_monitor_start (const struct
GNUNET_CONFIGURATION_Handle *cfg,
* @param h the handle that was being used
*/
void
-GNUNET_ARM_monitor_stop (struct GNUNET_ARM_MonitorHandle *h);
+GNUNET_ARM_monitor_stop (
+ struct GNUNET_ARM_MonitorHandle *h);
#if 0 /* keep Emacsens' auto-indent happy */
{
diff --git a/src/include/gnunet_testbed_lib.h b/src/include/gnunet_testbed_lib.h
index 5dc27912b..e33f31ee1 100644
--- a/src/include/gnunet_testbed_lib.h
+++ b/src/include/gnunet_testbed_lib.h
@@ -71,8 +71,9 @@ GNUNET_TESTBED_system_create (
* be removed (clean up on shutdown)?
*/
void
-GNUNET_TESTBED_system_destroy (struct GNUNET_TESTBED_System *system,
- int remove_paths);
+GNUNET_TESTBED_system_destroy (
+ struct GNUNET_TESTBED_System *system,
+ bool remove_paths);
/**
@@ -82,7 +83,8 @@ GNUNET_TESTBED_system_destroy (struct GNUNET_TESTBED_System
*system,
* @return 0 if no free port was available
*/
uint16_t
-GNUNET_TESTBED_reserve_port (struct GNUNET_TESTBED_System *system);
+GNUNET_TESTBED_reserve_port (
+ struct GNUNET_TESTBED_System *system);
/**
@@ -93,8 +95,9 @@ GNUNET_TESTBED_reserve_port (struct GNUNET_TESTBED_System
*system);
* @param port reserved port to release
*/
void
-GNUNET_TESTBED_release_port (struct GNUNET_TESTBED_System *system,
- uint16_t port);
+GNUNET_TESTBED_release_port (
+ struct GNUNET_TESTBED_System *system,
+ uint16_t port);
/**
@@ -106,32 +109,22 @@ GNUNET_TESTBED_release_port (struct GNUNET_TESTBED_System
*system,
* out of "*port" numbers, return #GNUNET_SYSERR.
*
* This is primarily a helper function used internally
- * by #GNUNET_TESTBED_peer_configure().
+ * by 'GNUNET_TESTBED_peer_configure'.
*
* @param system system to use to coordinate resource usage
* @param cfg template configuration to update
+ * @param ports array with port numbers used in the created configuration.
+ * Will be updated upon successful return. Can be NULL
+ * @param nports the size of the `ports' array. Will be updated.
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error - the configuration
will
* be incomplete and should not be used there upon
*/
-int
-GNUNET_TESTBED_configuration_create (struct GNUNET_TESTBED_System *system,
- struct GNUNET_CONFIGURATION_Handle *cfg);
-
-/**
- * Configure a GNUnet peer. GNUnet must be installed on the local
- * system and available in the PATH.
- *
- * @param system system to use to coordinate resource usage
- * @param cfg configuration to use; will be UPDATED (to reflect needed
- * changes in port numbers and paths)
- * @param emsg set to freshly allocated error message (set to NULL on success),
- * can be NULL
- * @return handle to the peer, NULL on error
- */
-struct GNUNET_TESTBED_Peer *
-GNUNET_TESTBED_peer_configure (struct GNUNET_TESTBED_System *system,
- struct GNUNET_CONFIGURATION_Handle *cfg,
- char **emsg);
+enum GNUNET_GenericReturnValue
+GNUNET_TESTBED_configuration_create (
+ struct GNUNET_TESTBED_System *system,
+ struct GNUNET_CONFIGURATION_Handle *cfg,
+ uint16_t **ports,
+ unsigned int *nports);
#endif
diff --git a/src/include/gnunet_testing_arm_lib.h
b/src/include/gnunet_testing_arm_lib.h
index 25fc17af9..f4d77ca6a 100644
--- a/src/include/gnunet_testing_arm_lib.h
+++ b/src/include/gnunet_testing_arm_lib.h
@@ -8,25 +8,22 @@
*
* @param label name for command.
* @param system_label Label of the cmd to setup a test environment.
- * @param no Decimal number representing the last byte of the IP address of
this peer.
- * @param node_ip The IP address of this node.
* @param cfgname Configuration file name for this peer.
- * @param broadcast Flag indicating, if broadcast should be switched on.
* @return command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TESTBED_cmd_start_peer (const char *label,
- const char *system_label,
- uint32_t no,
- const char *node_ip,
- const char *cfgname,
- unsigned int broadcast);
+GNUNET_TESTING_ARM_cmd_start_peer (
+ const char *label,
+ const char *system_label,
+ const char *cfgname);
/**
* Call #op on all simple traits.
*/
-#define GNUNET_TESTING_ARM_SIMPLE_TRAITS(op, prefix)
\
- op (prefix, arm_handle, const struct GNUNET_ARM_Handle)
+#define GNUNET_TESTING_ARM_SIMPLE_TRAITS(op, prefix) \
+ op (prefix, \
+ arm_handle, \
+ const struct GNUNET_ARM_Handle)
GNUNET_TESTING_ARM_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT,
diff --git a/src/include/gnunet_testing_testbed_lib.h
b/src/include/gnunet_testing_testbed_lib.h
index a75b1dec3..872382706 100644
--- a/src/include/gnunet_testing_testbed_lib.h
+++ b/src/include/gnunet_testing_testbed_lib.h
@@ -32,7 +32,7 @@ GNUNET_TESTBED_cmd_system_create (const char *label,
* Call #op on all simple traits.
*/
#define GNUNET_TESTING_TESTBED_SIMPLE_TRAITS(op, prefix)
\
- op (prefix, test_system, const struct GNUNET_TESTBED_System)
+ op (prefix, test_system, struct GNUNET_TESTBED_System)
GNUNET_TESTING_TESTBED_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT,
diff --git a/src/include/gnunet_testing_transport_lib.h
b/src/include/gnunet_testing_transport_lib.h
index 6d595684f..db2749661 100644
--- a/src/include/gnunet_testing_transport_lib.h
+++ b/src/include/gnunet_testing_transport_lib.h
@@ -34,11 +34,6 @@
*/
struct GNUNET_TRANSPORT_ApplicationHandle;
-/**
- * FIXME: what is this?
- */
-struct GNUNET_TESTING_StartPeerState;
-
// FIXME: breaks naming conventions
typedef void *
diff --git a/src/service/arm/Makefile.am b/src/service/arm/Makefile.am
index a80c00f63..26c940688 100644
--- a/src/service/arm/Makefile.am
+++ b/src/service/arm/Makefile.am
@@ -34,6 +34,8 @@ libgnunettestingarm_la_SOURCES = \
testing_arm_traits.c
libgnunettestingarm_la_LIBADD = \
libgnunetarm.la \
+ $(top_builddir)/src/service/testbed/libgnunettestingtestbed.la \
+ $(top_builddir)/src/service/testbed/libgnunettestbed.la \
$(top_builddir)/src/lib/testing/libgnunettesting.la \
$(top_builddir)/src/lib/util/libgnunetutil.la \
$(GN_LIBINTL) $(XLIB)
diff --git a/src/service/arm/testing_arm_cmd_start_peer.c
b/src/service/arm/testing_arm_cmd_start_peer.c
index 2b86db01c..1f3c4c035 100644
--- a/src/service/arm/testing_arm_cmd_start_peer.c
+++ b/src/service/arm/testing_arm_cmd_start_peer.c
@@ -27,44 +27,34 @@
#include "gnunet_util_lib.h"
#include "gnunet_testing_lib.h"
#include "gnunet_testbed_lib.h"
-#include "gnunet_testing_transport_lib.h"
+#include "gnunet_testing_testbed_lib.h"
+#include "gnunet_testing_arm_lib.h"
/**
- * Generic logging shortcut
+ * Handle for a peer controlled via ARM.
*/
-#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
+struct GNUNET_TESTING_StartPeerState
+{
+ const char *system_label;
-/**
- * Handle for a GNUnet peer controlled by testing.
- */
-struct GNUNET_TESTBED_Peer
-{
- /**
- * The TESTBED system associated with this peer
- */
- struct GNUNET_TESTBED_System *system;
+ const char *cfgname;
/**
- * Path to the configuration file for this peer.
+ * Our interpreter.
*/
- char *cfgfile;
+ struct GNUNET_TESTING_Interpreter *is;
/**
- * Binary to be executed during 'GNUNET_TESTBED_peer_start'.
- * Typically 'gnunet-service-arm' (but can be set to a
- * specific service by 'GNUNET_TESTBED_service_run' if
- * necessary).
+ * Asynchronous start context.
*/
- char *main_binary;
- char *args;
+ struct GNUNET_TESTING_AsyncContext ac;
/**
- * Handle to the running binary of the service, NULL if the
- * peer/service is currently not running.
+ * The TESTBED system associated with this peer
*/
- struct GNUNET_OS_Process *main_process;
+ struct GNUNET_TESTBED_System *system;
/**
* The handle to the peer's ARM service
@@ -72,44 +62,15 @@ struct GNUNET_TESTBED_Peer
struct GNUNET_ARM_Handle *ah;
/**
- * The config of the peer
- */
- struct GNUNET_CONFIGURATION_Handle *cfg;
-
- /**
- * The callback to call asynchronously when a peer is stopped
- */
- GNUNET_TESTBED_PeerStopCallback cb;
-
- /**
- * The closure for the above callback
+ * Handle to the ARM process information.
*/
- void *cb_cls;
+ struct GNUNET_OS_Process *arm;
/**
- * The cached identity of this peer. Will be populated on call to
- * GNUNET_TESTBED_peer_get_identity()
- */
- struct GNUNET_PeerIdentity *id;
-
- struct SharedServiceInstance **ss_instances;
-
- /**
- * Array of ports currently allocated to this peer. These ports will be
- * released upon peer destroy and can be used by other peers which are
- * configured after.
- */
- uint16_t *ports;
-
- /**
- * The number of ports in the above array
+ * The config of the peer
*/
- unsigned int nports;
+ struct GNUNET_CONFIGURATION_Handle *cfg;
- /**
- * The keynumber of this peer's hostkey
- */
- uint32_t key_number;
};
@@ -118,370 +79,22 @@ struct GNUNET_TESTBED_Peer
*
* @param cls closure
* @param connected #GNUNET_YES if connected, #GNUNET_NO if disconnected,
- * #GNUNET_SYSERR on error.
- */
-static void
-disconn_status (void *cls, int connected)
-{
- struct GNUNET_TESTBED_Peer *peer = cls;
-
- if (GNUNET_SYSERR == connected)
- {
- peer->cb (peer->cb_cls, peer, connected);
- return;
- }
- if (GNUNET_YES == connected)
- {
- GNUNET_break (GNUNET_OK == GNUNET_TESTBED_peer_kill (peer));
- return;
- }
- GNUNET_break (GNUNET_OK == GNUNET_TESTBED_peer_wait (peer));
- GNUNET_ARM_disconnect (peer->ah);
- peer->ah = NULL;
- peer->cb (peer->cb_cls, peer, GNUNET_YES);
-}
-
-
-int
-GNUNET_TESTBED_peer_stop_async (struct GNUNET_TESTBED_Peer *peer,
- GNUNET_TESTBED_PeerStopCallback cb,
- void *cb_cls)
-{
- if (NULL == peer->main_process)
- return GNUNET_SYSERR;
- peer->ah = GNUNET_ARM_connect (peer->cfg, &disconn_status, peer);
- if (NULL == peer->ah)
- return GNUNET_SYSERR;
- peer->cb = cb;
- peer->cb_cls = cb_cls;
- return GNUNET_OK;
-}
-
-
-/**
- * Cancel a previous asynchronous peer stop request.
- * GNUNET_TESTBED_peer_stop_async() should have been called before on the given
- * peer. It is an error to call this function if the peer stop callback was
- * already called
- *
- * @param peer the peer on which GNUNET_TESTBED_peer_stop_async() was called
- * before.
- */
-void
-GNUNET_TESTBED_peer_stop_async_cancel (struct GNUNET_TESTBED_Peer *peer)
-{
- GNUNET_assert (NULL != peer->ah);
- GNUNET_ARM_disconnect (peer->ah);
- peer->ah = NULL;
-}
-
-
-/**
- * Destroy the peer. Releases resources locked during peer configuration.
- * If the peer is still running, it will be stopped AND a warning will be
- * printed (users of the API should stop the peer explicitly first).
- *
- * @param peer peer to destroy
- */
-void
-GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer)
-{
- unsigned int cnt;
-
- if (NULL != peer->main_process)
- GNUNET_TESTBED_peer_stop (peer);
- if (NULL != peer->ah)
- GNUNET_ARM_disconnect (peer->ah);
- GNUNET_free (peer->cfgfile);
- if (NULL != peer->cfg)
- GNUNET_CONFIGURATION_destroy (peer->cfg);
- GNUNET_free (peer->main_binary);
- GNUNET_free (peer->args);
- GNUNET_free (peer->id);
- GNUNET_free (peer->ss_instances);
- if (NULL != peer->ports)
- {
- for (cnt = 0; cnt < peer->nports; cnt++)
- GNUNET_TESTBED_release_port (peer->system, peer->ports[cnt]);
- GNUNET_free (peer->ports);
- }
- GNUNET_free (peer);
-}
-
-
-int
-GNUNET_TESTBED_peer_run (const char *testdir,
- const char *cfgfilename,
- GNUNET_TESTBED_TestMain tm,
- void *tm_cls)
-{
- return GNUNET_TESTBED_service_run (testdir, "arm", cfgfilename, tm, tm_cls);
-}
-
-
-/**
- * Structure for holding service data
- */
-struct ServiceContext
-{
- /**
- * The configuration of the peer in which the service is run
- */
- const struct GNUNET_CONFIGURATION_Handle *cfg;
-
- /**
- * Callback to signal service startup
- */
- GNUNET_TESTBED_TestMain tm;
-
- /**
- * The peer in which the service is run.
- */
- struct GNUNET_TESTBED_Peer *peer;
-
- /**
- * Closure for the above callback
- */
- void *tm_cls;
-};
-
-
-/**
- * Callback to be called when SCHEDULER has been started
- *
- * @param cls the ServiceContext
+ * #GNUNET_SYSERR if there was an error.
*/
static void
-service_run_main (void *cls)
+conn_status (
+ void *cls,
+ enum GNUNET_GenericReturnValue connected)
{
- struct ServiceContext *sc = cls;
-
- sc->tm (sc->tm_cls, sc->cfg, sc->peer);
-}
-
-
-int
-GNUNET_TESTBED_service_run (const char *testdir,
- const char *service_name,
- const char *cfgfilename,
- GNUNET_TESTBED_TestMain tm,
- void *tm_cls)
-{
- struct ServiceContext sc;
- struct GNUNET_TESTBED_System *system;
- struct GNUNET_TESTBED_Peer *peer;
- struct GNUNET_CONFIGURATION_Handle *cfg;
- char *binary;
- char *libexec_binary;
-
- GNUNET_log_setup (testdir, "WARNING", NULL);
- system = GNUNET_TESTBED_system_create (testdir, "127.0.0.1", NULL, NULL);
- if (NULL == system)
- return 1;
- cfg = GNUNET_CONFIGURATION_create ();
- if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cfgfilename))
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- _ ("Failed to load configuration from %s\n"),
- cfgfilename);
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_TESTBED_system_destroy (system, GNUNET_YES);
- return 1;
- }
- peer = GNUNET_TESTBED_peer_configure (system, cfg, 0, NULL, NULL);
- if (NULL == peer)
- {
- GNUNET_CONFIGURATION_destroy (cfg);
- hostkeys_unload (system);
- GNUNET_TESTBED_system_destroy (system, GNUNET_YES);
- return 1;
- }
- GNUNET_free (peer->main_binary);
- GNUNET_free (peer->args);
- GNUNET_asprintf (&binary, "gnunet-service-%s", service_name);
- libexec_binary = GNUNET_OS_get_libexec_binary_path (binary);
- if (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_get_value_string (cfg,
- service_name,
- "PREFIX",
- &peer->main_binary))
- {
- /* No prefix */
- GNUNET_asprintf (&peer->main_binary, "%s", libexec_binary);
- peer->args = GNUNET_strdup ("");
- }
- else
- peer->args = GNUNET_strdup (libexec_binary);
-
- GNUNET_free (libexec_binary);
- GNUNET_free (binary);
- if (GNUNET_OK != GNUNET_TESTBED_peer_start (peer))
- {
- GNUNET_TESTBED_peer_destroy (peer);
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_TESTBED_system_destroy (system, GNUNET_YES);
- return 1;
- }
- sc.cfg = cfg;
- sc.tm = tm;
- sc.tm_cls = tm_cls;
- sc.peer = peer;
- GNUNET_SCHEDULER_run (&service_run_main, &sc); /* Scheduler loop */
- if ((NULL != peer->main_process) &&
- (GNUNET_OK != GNUNET_TESTBED_peer_stop (peer)))
- {
- GNUNET_TESTBED_peer_destroy (peer);
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_TESTBED_system_destroy (system, GNUNET_YES);
- return 1;
- }
- GNUNET_TESTBED_peer_destroy (peer);
- GNUNET_CONFIGURATION_destroy (cfg);
- GNUNET_TESTBED_system_destroy (system, GNUNET_YES);
- return 0;
-}
-
-
-/**
- * Start the peer.
- *
- * @param peer peer to start
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error (i.e. peer already
running)
- */
-int
-GNUNET_TESTBED_peer_start (struct GNUNET_TESTBED_Peer *peer)
-{
- struct SharedServiceInstance *i;
- unsigned int cnt;
-
- if (NULL != peer->main_process)
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- GNUNET_assert (NULL != peer->cfgfile);
- for (cnt = 0; cnt < peer->system->n_shared_services; cnt++)
- {
- i = peer->ss_instances[cnt];
- if ((0 == i->n_refs) &&
- (GNUNET_SYSERR == start_shared_service_instance (i)))
- return GNUNET_SYSERR;
- i->n_refs++;
- }
- peer->main_binary =
- GNUNET_CONFIGURATION_expand_dollar (peer->cfg, peer->main_binary);
- peer->main_process =
- GNUNET_OS_start_process_s (GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- NULL,
- peer->main_binary,
- peer->args,
- "-c",
- peer->cfgfile,
- NULL);
- if (NULL == peer->main_process)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ ("Failed to start `%s': %s\n"),
- peer->main_binary,
- strerror (errno));
- return GNUNET_SYSERR;
- }
- return GNUNET_OK;
-}
-
-
-/**
- * Sends SIGTERM to the peer's main process
- *
- * @param peer the handle to the peer
- * @return #GNUNET_OK if successful; #GNUNET_SYSERR if the main process is NULL
- * or upon any error while sending SIGTERM
- */
-int
-GNUNET_TESTBED_peer_kill (struct GNUNET_TESTBED_Peer *peer)
-{
- struct SharedServiceInstance *i;
- unsigned int cnt;
-
- if (NULL == peer->main_process)
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- if (0 != GNUNET_OS_process_kill (peer->main_process, GNUNET_TERM_SIG))
- return GNUNET_SYSERR;
- for (cnt = 0; cnt < peer->system->n_shared_services; cnt++)
- {
- i = peer->ss_instances[cnt];
- GNUNET_assert (0 != i->n_refs);
- i->n_refs--;
- if (0 == i->n_refs)
- stop_shared_service_instance (i);
- }
- return GNUNET_OK;
-}
-
-
-/**
- * Waits for a peer to terminate. The peer's main process will also be
destroyed.
- *
- * @param peer the handle to the peer
- * @return #GNUNET_OK if successful; #GNUNET_SYSERR if the main process is NULL
- * or upon any error while waiting
- */
-int
-GNUNET_TESTBED_peer_wait (struct GNUNET_TESTBED_Peer *peer)
-{
- int ret;
+ struct GNUNET_TESTING_StartPeerState *sps = cls;
- if (NULL == peer->main_process)
+ if (GNUNET_OK != connected)
{
GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- ret = GNUNET_OS_process_wait (peer->main_process);
- GNUNET_OS_process_destroy (peer->main_process);
- peer->main_process = NULL;
- return ret;
-}
-
-
-/**
- * Stop the peer.
- *
- * @param peer peer to stop
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
- */
-int
-GNUNET_TESTBED_peer_stop (struct GNUNET_TESTBED_Peer *peer)
-{
- if (GNUNET_SYSERR == GNUNET_TESTBED_peer_kill (peer))
- return GNUNET_SYSERR;
- if (GNUNET_SYSERR == GNUNET_TESTBED_peer_wait (peer))
- return GNUNET_SYSERR;
- return GNUNET_OK;
-}
-
-
-/**
- * Obtain the peer identity from a peer handle.
- *
- * @param peer peer handle for which we want the peer's identity
- * @param id identifier for the daemon, will be set
- */
-void
-GNUNET_TESTBED_peer_get_identity (struct GNUNET_TESTBED_Peer *peer,
- struct GNUNET_PeerIdentity *id)
-{
- if (NULL != peer->id)
- {
- GNUNET_memcpy (id, peer->id, sizeof(struct GNUNET_PeerIdentity));
+ GNUNET_TESTING_async_fail (&sps->ac);
return;
}
- peer->id = GNUNET_new (struct GNUNET_PeerIdentity);
- GNUNET_free_nz (
- GNUNET_TESTBED_hostkey_get (peer->system, peer->key_number, peer->id));
- GNUNET_memcpy (id, peer->id, sizeof(struct GNUNET_PeerIdentity));
+ GNUNET_TESTING_async_finish (&sps->ac);
}
@@ -494,163 +107,108 @@ start_peer_run (void *cls,
struct GNUNET_TESTING_Interpreter *is)
{
struct GNUNET_TESTING_StartPeerState *sps = cls;
- char *emsg = NULL;
- struct GNUNET_PeerIdentity dummy;
const struct GNUNET_TESTING_Command *system_cmd;
- const struct GNUNET_TESTBED_System *tl_system;
- char *home;
- char *transport_unix_path;
- char *tcp_communicator_unix_path;
- char *udp_communicator_unix_path;
- char *bindto;
- char *bindto_udp;
-
- if (GNUNET_NO == GNUNET_DISK_file_test (sps->cfgname))
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "File not found: `%s'\n",
- sps->cfgname);
- GNUNET_TESTING_interpreter_fail (is);
- return;
- }
-
-
- sps->cfg = GNUNET_CONFIGURATION_create ();
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONFIGURATION_load (sps->cfg, sps->cfgname));
-
- GNUNET_asprintf (&home,
- "$GNUNET_TMP/test-transport/api-tcp-p%u",
- sps->no);
-
- GNUNET_asprintf (&transport_unix_path,
- "$GNUNET_RUNTIME_DIR/tng-p%u.sock",
- sps->no);
-
- GNUNET_asprintf (&tcp_communicator_unix_path,
- "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock",
- sps->no);
-
- GNUNET_asprintf (&udp_communicator_unix_path,
- "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock",
- sps->no);
-
- GNUNET_asprintf (&bindto,
- "%s:60002",
- sps->node_ip);
-
- GNUNET_asprintf (&bindto_udp,
- "2086");
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "node_ip %s\n",
- bindto);
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "bind_udp %s\n",
- GNUNET_YES == sps->broadcast ?
- bindto_udp : bindto);
-
- GNUNET_CONFIGURATION_set_value_string (sps->cfg, "PATHS", "GNUNET_TEST_HOME",
- home);
- GNUNET_CONFIGURATION_set_value_string (sps->cfg, "transport", "UNIXPATH",
- transport_unix_path);
- GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp",
- "BINDTO",
- bindto);
- GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp",
- "BINDTO",
- GNUNET_YES == sps->broadcast ?
- bindto_udp : bindto);
- GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp",
- "UNIXPATH",
- tcp_communicator_unix_path);
- GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp",
- "UNIXPATH",
- udp_communicator_unix_path);
-
-
- system_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
- sps->system_label);
- GNUNET_TESTBED_get_trait_test_system (system_cmd,
- &tl_system);
-
- sps->tl_system = tl_system;
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Creating testing library with key number %u\n",
- sps->no);
-
- if (GNUNET_SYSERR ==
- GNUNET_TESTBED_configuration_create (tl_system,
- sps->cfg))
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Testing library failed to create unique configuration based on
`%s'\n",
- sps->cfgname);
- GNUNET_CONFIGURATION_destroy (sps->cfg);
- GNUNET_TESTING_interpreter_fail (is);
- return;
- }
- sps->peer = GNUNET_TESTBED_peer_configure (
- (struct GNUNET_TESTBED_System *) sps->tl_system,
- sps->cfg,
- sps->no,
- NULL,
- &emsg);
- if (NULL == sps->peer)
+ sps->is = is;
+ if (GNUNET_NO ==
+ GNUNET_DISK_file_test (sps->cfgname))
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Testing library failed to create unique configuration based on `%s':
`%s' with key number %u\n",
- sps->cfgname,
- emsg,
- sps->no);
- GNUNET_free (emsg);
- GNUNET_TESTING_interpreter_fail (is);
- return;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "File not found: `%s'\n",
+ sps->cfgname);
+ GNUNET_TESTING_FAIL (is);
}
-
+ system_cmd
+ = GNUNET_TESTING_interpreter_lookup_command (is,
+ sps->system_label);
+ if (NULL == system_cmd)
+ GNUNET_TESTING_FAIL (is);
+ if (GNUNET_OK !=
+ GNUNET_TESTING_TESTBED_get_trait_test_system (
+ system_cmd,
+ &sps->system))
+ GNUNET_TESTING_FAIL (is);
+ sps->cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_OK !=
- GNUNET_TESTBED_peer_start (sps->peer))
+ GNUNET_CONFIGURATION_load (sps->cfg,
+ sps->cfgname))
+ GNUNET_TESTING_FAIL (is);
+ if (GNUNET_SYSERR ==
+ GNUNET_TESTBED_configuration_create (sps->system,
+ sps->cfg,
+ NULL,
+ NULL))
+ GNUNET_TESTING_FAIL (is);
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Testing library failed to create unique configuration based on
`%s'\n",
- sps->cfgname);
- GNUNET_free (emsg);
- GNUNET_TESTING_interpreter_fail (is);
- return;
+ char *config_filename;
+ char *libexec_binary;
+ char *main_binary;
+ char *args;
+ char *prefix;
+
+ GNUNET_assert (
+ GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_filename (
+ sps->cfg,
+ "PATHS",
+ "DEFAULTCONFIG",
+ &config_filename));
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_write (sps->cfg,
+ config_filename))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to write configuration file `%s': %s\n",
+ config_filename,
+ strerror (errno));
+ GNUNET_free (config_filename);
+ GNUNET_TESTING_FAIL (is);
+ }
+
+ libexec_binary
+ = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm");
+
+ if (GNUNET_SYSERR ==
+ GNUNET_CONFIGURATION_get_value_string (sps->cfg,
+ "arm",
+ "PREFIX",
+ &prefix))
+ {
+ /* No prefix */
+ main_binary = libexec_binary;
+ args = GNUNET_strdup ("");
+ }
+ else
+ {
+ main_binary = prefix;
+ args = libexec_binary;
+ }
+ sps->arm
+ = GNUNET_OS_start_process_s (GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+ NULL,
+ main_binary,
+ args,
+ "-c",
+ config_filename,
+ NULL);
+ if (NULL == sps->arm)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Failed to start `%s': %s\n"),
+ main_binary,
+ strerror (errno));
+ GNUNET_TESTING_FAIL (is);
+ }
+ GNUNET_free (config_filename);
+ GNUNET_free (main_binary);
+ GNUNET_free (args);
}
- memset (&dummy,
- '\0',
- sizeof(dummy));
-
- GNUNET_TESTBED_peer_get_identity (sps->peer,
- &sps->id);
-
- if (0 == memcmp (&dummy,
- &sps->id,
- sizeof(struct GNUNET_PeerIdentity)))
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Testing library failed to obtain peer identity for peer %u\n",
- sps->no);
- GNUNET_free (emsg);
- GNUNET_TESTING_interpreter_fail (is);
- return;
- }
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u configured with identity `%s'\n",
- sps->no,
- GNUNET_i2s_full (&sps->id));
-
- GNUNET_free (home);
- GNUNET_free (transport_unix_path);
- GNUNET_free (tcp_communicator_unix_path);
- GNUNET_free (udp_communicator_unix_path);
- GNUNET_free (bindto);
- GNUNET_free (bindto_udp);
+ sps->ah = GNUNET_ARM_connect (sps->cfg,
+ &conn_status,
+ sps);
+ if (NULL == sps->ah)
+ GNUNET_TESTING_FAIL (is);
}
@@ -663,17 +221,27 @@ start_peer_cleanup (void *cls)
{
struct GNUNET_TESTING_StartPeerState *sps = cls;
- // TODO Investigate why this caused problems during shutdown.
- /*if (NULL != sps->cfg)
+ if (NULL != sps->ah)
+ {
+ GNUNET_ARM_disconnect (sps->ah);
+ sps->ah = NULL;
+ }
+ if (NULL != sps->arm)
+ {
+ GNUNET_break (0 ==
+ GNUNET_OS_process_kill (sps->arm,
+ SIGTERM));
+ GNUNET_break (GNUNET_OK ==
+ GNUNET_OS_process_wait (sps->arm));
+ GNUNET_OS_process_destroy (sps->arm);
+ sps->ah = NULL;
+ }
+
+ if (NULL != sps->cfg)
{
GNUNET_CONFIGURATION_destroy (sps->cfg);
sps->cfg = NULL;
- }*/
- GNUNET_free (sps->cfgname);
- GNUNET_free (sps->node_ip);
- GNUNET_free (sps->system_label);
- GNUNET_free (sps->hello);
- GNUNET_free (sps->connected_peers_map);
+ }
GNUNET_free (sps);
}
@@ -682,30 +250,18 @@ start_peer_cleanup (void *cls)
* This function prepares an array with traits.
*
*/
-static int
+static enum GNUNET_GenericReturnValue
start_peer_traits (void *cls,
const void **ret,
const char *trait,
unsigned int index)
{
struct GNUNET_TESTING_StartPeerState *sps = cls;
- struct GNUNET_TRANSPORT_ApplicationHandle *ah = sps->ah;
- struct GNUNET_PeerIdentity *id = &sps->id;
- struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
- sps->connected_peers_map;
- char *hello = sps->hello;
- size_t hello_size = sps->hello_size;
struct GNUNET_TESTING_Trait traits[] = {
- GNUNET_TRANSPORT_TESTING_make_trait_application_handle ((const void *) ah),
- GNUNET_TRANSPORT_TESTING_make_trait_peer_id ((const void *) id),
- GNUNET_TRANSPORT_TESTING_make_trait_connected_peers_map ((const
- void *)
-
connected_peers_map),
- GNUNET_TRANSPORT_TESTING_make_trait_hello ((const void *) hello),
- GNUNET_TRANSPORT_TESTING_make_trait_hello_size ((const void *) hello_size),
- GNUNET_TRANSPORT_TESTING_make_trait_state ((const void *) sps),
- GNUNET_TRANSPORT_TESTING_make_trait_broadcast ((const void *) &sps->
- broadcast),
+ GNUNET_TESTING_make_trait_process (
+ &sps->arm),
+ GNUNET_TESTING_ARM_make_trait_arm_handle (
+ sps->ah),
GNUNET_TESTING_trait_end ()
};
@@ -717,28 +273,20 @@ start_peer_traits (void *cls,
struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_start_peer (const char *label,
- const char *system_label,
- uint32_t no,
- const char *node_ip,
- const char *cfgname,
- unsigned int broadcast)
+GNUNET_TESTING_ARM_cmd_start_peer (
+ const char *label,
+ const char *system_label,
+ const char *cfgname)
{
struct GNUNET_TESTING_StartPeerState *sps;
- struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
- GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
sps = GNUNET_new (struct GNUNET_TESTING_StartPeerState);
- sps->no = no;
sps->system_label = GNUNET_strdup (system_label);
- sps->connected_peers_map = connected_peers_map;
- sps->cfgname = GNUNET_strdup (cfgname);
- sps->node_ip = GNUNET_strdup (node_ip);
- sps->broadcast = broadcast;
-
- return GNUNET_TESTING_command_new (sps,
- label,
- &start_peer_run,
- &start_peer_cleanup,
- &start_peer_traits);
+ sps->cfgname = cfgname;
+ return GNUNET_TESTING_command_new_ac (sps,
+ label,
+ &start_peer_run,
+ &start_peer_cleanup,
+ &start_peer_traits,
+ &sps->ac);
}
diff --git a/src/service/arm/testing_arm_cmd_stop_peer.c
b/src/service/arm/testing_arm_cmd_stop_peer.c
index 38d53ffba..489eb05a2 100644
--- a/src/service/arm/testing_arm_cmd_stop_peer.c
+++ b/src/service/arm/testing_arm_cmd_stop_peer.c
@@ -27,13 +27,7 @@
#include "gnunet_util_lib.h"
#include "gnunet_testing_lib.h"
#include "gnunet_testbed_lib.h"
-#include "gnunet_transport_testing_ng_lib.h"
-
-/**
- * Generic logging shortcut
- */
-#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
-
+#include "gnunet_testing_transport_lib.h"
/**
* Struct to hold information for callbacks.
@@ -41,7 +35,9 @@
*/
struct StopPeerState
{
- // Label of the cmd to start the peer.
+ /**
+ * Label of the cmd to start the peer.
+ */
const char *start_label;
};
@@ -55,28 +51,28 @@ stop_peer_run (void *cls,
struct GNUNET_TESTING_Interpreter *is)
{
struct StopPeerState *stop_ps = cls;
- const struct GNUNET_TESTING_StartPeerState *sps;
const struct GNUNET_TESTING_Command *start_cmd;
-
- start_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
- stop_ps->start_label);
- GNUNET_TRANSPORT_TESTING_get_trait_state (start_cmd,
- &sps);
-
- if (NULL != sps->peer)
- {
- if (GNUNET_OK !=
- GNUNET_TESTBED_peer_stop (sps->peer))
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Testing lib failed to stop peer %u (`%s')\n",
- sps->no,
- GNUNET_i2s (&sps->id));
- }
- GNUNET_TESTBED_peer_destroy (sps->peer);
- }
- if (NULL != sps->rh_task)
- GNUNET_SCHEDULER_cancel (sps->rh_task);
+ struct GNUNET_OS_Process **proc;
+
+ start_cmd
+ = GNUNET_TESTING_interpreter_lookup_command (is,
+ stop_ps->start_label);
+ if (NULL == start_cmd)
+ GNUNET_TESTING_FAIL (is);
+ /* FIMXE: maybe use the *ARM* handle to stop the peer
+ and actually _wait_ for it to be down (making this
+ an asynchronous operation...) instead of just
+ killing it without waiting for it to be done?
+ Or use a child wait handle and wait for
+ completion, and then NULL *proc in start? */
+ if (GNUNET_OK !=
+ GNUNET_TESTING_get_trait_process (start_cmd,
+ &proc))
+ GNUNET_TESTING_FAIL (is);
+ if (0 !=
+ GNUNET_OS_process_kill (*proc,
+ SIGTERM))
+ GNUNET_TESTING_FAIL (is);
}
@@ -103,7 +99,15 @@ stop_peer_traits (void *cls,
const char *trait,
unsigned int index)
{
- return GNUNET_OK;
+ struct GNUNET_TESTING_Trait traits[] = {
+ GNUNET_TESTING_trait_end ()
+ };
+
+ (void) cls;
+ return GNUNET_TESTING_get_trait (traits,
+ ret,
+ trait,
+ index);
}
diff --git a/src/service/testbed/testbed.c b/src/service/testbed/testbed.c
index 889098f9b..7cf2d352a 100644
--- a/src/service/testbed/testbed.c
+++ b/src/service/testbed/testbed.c
@@ -45,49 +45,6 @@
*/
#define HIGH_PORT 56000
-/**
- * Handle for a GNUnet peer controlled by testing.
- */
-struct GNUNET_TESTBED_Peer
-{
- /**
- * The TESTBED system associated with this peer
- */
- struct GNUNET_TESTBED_System *system;
-
- /**
- * Path to the configuration file for this peer.
- */
- char *cfgfile;
-
- /**
- * Binary to be executed during 'GNUNET_TESTBED_peer_start'.
- * Typically 'gnunet-service-arm' (but can be set to a
- * specific service by 'GNUNET_TESTBED_service_run' if
- * necessary).
- */
- char *main_binary;
- char *args;
-
- /**
- * The config of the peer
- */
- struct GNUNET_CONFIGURATION_Handle *cfg;
-
- /**
- * Array of ports currently allocated to this peer. These ports will be
- * released upon peer destroy and can be used by other peers which are
- * configured after.
- */
- uint16_t *ports;
-
- /**
- * The number of ports in the above array
- */
- unsigned int nports;
-
-};
-
/**
* Handle for a system on which GNUnet peers are executed;
@@ -571,30 +528,12 @@ update_config_sections (void *cls,
}
-/**
- * Create a new configuration using the given configuration as a template;
- * ports and paths will be modified to select available ports on the local
- * system. The default configuration will be available in PATHS section under
- * the option DEFAULTCONFIG after the call. GNUNET_HOME is also set in PATHS
- * section to the temporary directory specific to this configuration. If we run
- * out of "*port" numbers, return #GNUNET_SYSERR.
- *
- * This is primarily a helper function used internally
- * by 'GNUNET_TESTBED_peer_configure'.
- *
- * @param system system to use to coordinate resource usage
- * @param cfg template configuration to update
- * @param ports array with port numbers used in the created configuration.
- * Will be updated upon successful return. Can be NULL
- * @param nports the size of the `ports' array. Will be updated.
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - the configuration
will
- * be incomplete and should not be used there upon
- */
-static int
-configuration_create_ (struct GNUNET_TESTBED_System *system,
- struct GNUNET_CONFIGURATION_Handle *cfg,
- uint16_t **ports,
- unsigned int *nports)
+enum GNUNET_GenericReturnValue
+GNUNET_TESTBED_configuration_create (
+ struct GNUNET_TESTBED_System *system,
+ struct GNUNET_CONFIGURATION_Handle *cfg,
+ uint16_t **ports,
+ unsigned int *nports)
{
struct UpdateContext uc;
char *default_config;
@@ -637,106 +576,4 @@ configuration_create_ (struct GNUNET_TESTBED_System
*system,
}
-int
-GNUNET_TESTBED_configuration_create (struct GNUNET_TESTBED_System *system,
- struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- return configuration_create_ (system,
- cfg,
- NULL,
- NULL);
-}
-
-
-struct GNUNET_TESTBED_Peer *
-GNUNET_TESTBED_peer_configure (struct GNUNET_TESTBED_System *system,
- struct GNUNET_CONFIGURATION_Handle *cfg,
- char **emsg)
-{
- struct GNUNET_TESTBED_Peer *peer;
- char *config_filename;
- char *libexec_binary;
- char *emsg_;
- uint16_t *ports;
- unsigned int nports;
-
- ports = NULL;
- nports = 0;
- if (NULL != emsg)
- *emsg = NULL;
- if (GNUNET_NO ==
- GNUNET_CONFIGURATION_have_value (cfg,
- "PEER",
- "PRIVATE_KEY"))
- {
- GNUNET_asprintf (
- &emsg_,
- _ ("PRIVATE_KEY option in PEER section missing in configuration\n"));
- goto err_ret;
- }
- if (GNUNET_OK !=
- configuration_create_ (system,
- cfg,
- &ports,
- &nports))
- {
- GNUNET_asprintf (&emsg_,
- _ ("Failed to create configuration for peer "
- "(not enough free ports?)\n"));
- goto err_ret;
- }
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_filename (cfg,
- "PATHS",
- "DEFAULTCONFIG",
- &config_filename));
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_write (cfg,
- config_filename))
- {
- GNUNET_asprintf (&emsg_,
- _ (
- "Failed to write configuration file `%s': %s\n"),
- config_filename,
- strerror (errno));
- GNUNET_free (config_filename);
- goto err_ret;
- }
- peer = GNUNET_new (struct GNUNET_TESTBED_Peer);
- peer->cfgfile = config_filename; /* Free in peer_destroy */
- peer->cfg = GNUNET_CONFIGURATION_dup (cfg);
- libexec_binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm");
- if (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_get_value_string (cfg,
- "arm",
- "PREFIX",
- &peer->main_binary))
- {
- /* No prefix */
- GNUNET_asprintf (&peer->main_binary,
- "%s",
- libexec_binary);
- peer->args = GNUNET_strdup ("");
- }
- else
- {
- peer->args = GNUNET_strdup (libexec_binary);
- }
- peer->system = system;
- GNUNET_free (libexec_binary);
- peer->ports = ports; /* Free in peer_destroy */
- peer->nports = nports;
- return peer;
-
-err_ret:
- GNUNET_free (ports);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s", emsg_);
- if (NULL != emsg)
- *emsg = emsg_;
- else
- GNUNET_free (emsg_);
- return NULL;
-}
-
-
/* end of testbed.c */
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.