summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2021-08-17 14:21:53 +0200
committert3sserakt <t3ss@posteo.de>2021-08-17 14:21:53 +0200
commit1e063cd73452396778cf00127346b9b08a922317 (patch)
treedc0c119ecf8511c5c56a469e580fee09800fc45a /src
parent0f00c002810907f4edf740203bdf24d81124fd32 (diff)
- renamed methods and variables to prepare moving files from testbed to testing, to fix circular dependency problem
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_testbed_ng_service.h203
-rw-r--r--src/include/gnunet_testing_plugin.h4
-rw-r--r--src/testbed/Makefile.am11
-rw-r--r--src/testbed/gnunet-cmd.c123
-rw-r--r--src/testbed/plugin_testcmd.c2
-rw-r--r--src/testbed/test_testbed_api_cmd_netjail.c20
-rw-r--r--src/testbed/testbed_api_cmd_controller.c203
-rw-r--r--src/testbed/testbed_api_cmd_local_test_finished.c4
-rw-r--r--src/testbed/testbed_api_cmd_netjail_start.c11
-rw-r--r--src/testbed/testbed_api_cmd_netjail_start_testbed.c99
-rw-r--r--src/testbed/testbed_api_cmd_netjail_stop.c11
-rw-r--r--src/testbed/testbed_api_cmd_netjail_stop_testbed.c36
-rw-r--r--src/testbed/testbed_api_cmd_peer.c281
-rw-r--r--src/testbed/testbed_api_cmd_peer_store.c60
-rw-r--r--src/testbed/testbed_api_cmd_send_peer_ready.c4
-rw-r--r--src/testbed/testbed_api_cmd_tng_connect.c55
-rw-r--r--src/testbed/testbed_api_cmd_tng_service.c276
-rwxr-xr-xsrc/testing/netjail_exec.sh16
-rwxr-xr-xsrc/testing/netjail_start.sh52
-rwxr-xr-xsrc/testing/netjail_stop.sh26
-rw-r--r--src/testing/testing_api_cmd_send_peer_ready.c4
-rw-r--r--src/transport/plugin_cmd_simple_send.c2
-rw-r--r--src/transport/test_transport_api_cmd_simple_send.c22
23 files changed, 205 insertions, 1320 deletions
diff --git a/src/include/gnunet_testbed_ng_service.h b/src/include/gnunet_testbed_ng_service.h
index 2ff5228cf..5979cd85a 100644
--- a/src/include/gnunet_testbed_ng_service.h
+++ b/src/include/gnunet_testbed_ng_service.h
@@ -38,176 +38,6 @@
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
-struct TngState;
-
-struct PeerCmdState
-{
- /**
- * The label of a controller command.
- */
- const char *controller_label;
-
- /**
- * Handle to operation
- */
- struct GNUNET_TESTBED_Operation *operation;
-
- /**
- * Name of the host, use "NULL" for localhost.
- */
- const char *hostname;
-
- /**
- * Username to use for the login; may be NULL.
- */
- const char *username;
-
- /**
- * Port number to use for ssh; use 0 to let ssh decide.
- */
- uint16_t port;
-
- /**
- * The configuration to use as a template while starting a controller
- * on this host. Operation queue sizes specific to a host are also
- * read from this configuration handle.
- */
- struct GNUNET_CONFIGURATION_Handle *cfg;
-
- /**
- * The host to run peers and controllers on
- */
- struct GNUNET_TESTBED_Host *host;
-
- /**
- * Abort task identifier
- */
- struct GNUNET_SCHEDULER_Task *abort_task;
-
- /**
- * Flag indicating if peer is ready.
- */
- int peer_ready;
-
- /**
- * Flag indicating controller is going down.
- */
- int peer_going_down;
-
- /**
- * Interpreter state.
- */
- struct GNUNET_TESTING_Interpreter *is;
-
- /**
- * Peer to start
- */
- struct GNUNET_TESTBED_Peer *peer;
-};
-
-struct ControllerState
-{
- /**
- * The ip address of the controller which will be set as TRUSTED
- * HOST(all connections form this ip are permitted by the testbed) when
- * starting testbed controller at host. This can either be a single ip
- * address or a network address in CIDR notation.
- */
- const char *trusted_ip;
-
- /**
- * Name of the host, use "NULL" for localhost.
- */
- const char *hostname;
-
- /**
- * Username to use for the login; may be NULL.
- */
- const char *username;
-
- /**
- * Port number to use for ssh; use 0 to let ssh decide.
- */
- uint16_t port;
-
- /**
- * The configuration to use as a template while starting a controller
- * on this host. Operation queue sizes specific to a host are also
- * read from this configuration handle.
- */
- struct GNUNET_CONFIGURATION_Handle *cfg;
-
- /**
- * The host to run peers and controllers on
- */
- struct GNUNET_TESTBED_Host *host;
-
- /**
- * The controller process
- */
- struct GNUNET_TESTBED_ControllerProc *cp;
-
- /**
- * The controller handle
- */
- struct GNUNET_TESTBED_Controller *controller;
-
- /**
- * A bit mask with set of events to call the controller for.
- */
- uint64_t event_mask;
-
- /**
- * Abort task identifier
- */
- struct GNUNET_SCHEDULER_Task *abort_task;
-
- /**
- * Handle for host registration
- */
- struct GNUNET_TESTBED_HostRegistrationHandle *reg_handle;
-
- /**
- * Flag indicating if host create with controller is ready.
- */
- int host_ready;
-
- /**
- * Flag indicating controller is going down.
- */
- int controller_going_down;
-
- /**
- * Interpreter state.
- */
- struct GNUNET_TESTING_Interpreter *is;
-};
-
-/**
- * Offer data from trait
- *
- * @param cmd command to extract the controller from.
- * @param pt pointer to controller.
- * @return #GNUNET_OK on success.
- */
-int
-GNUNET_TESTBED_get_trait_controller (const struct GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTBED_Controller **
- controller);
-
-struct GNUNET_TESTING_Command
-GNUNET_TESTBED_cmd_controller (const char *label,
- const char *host,
- uint64_t event_mask);
-
-void
-GNUNET_TESTBED_shutdown_controller (struct ControllerState *cs);
-
-void
-GNUNET_TESTBED_shutdown_peer (struct PeerCmdState *ps);
-
-void
-GNUNET_TESTBED_shutdown_service (struct TngState *ss);
/**
* Create command.
@@ -217,7 +47,7 @@ GNUNET_TESTBED_shutdown_service (struct TngState *ss);
* @return command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TESTBED_cmd_netjail_start (const char *label,
+GNUNET_TESTING_cmd_netjail_start (const char *label,
char *local_m,
char *global_n);
@@ -230,11 +60,11 @@ GNUNET_TESTBED_cmd_netjail_start (const char *label,
* @return command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TESTBED_cmd_netjail_start_testbed (const char *label,
- char *local_m,
- char *global_n,
- char *plugin_name,
- unsigned int *rv);
+GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label,
+ char *local_m,
+ char *global_n,
+ char *plugin_name,
+ unsigned int *rv);
/**
@@ -245,29 +75,24 @@ GNUNET_TESTBED_cmd_netjail_start_testbed (const char *label,
* @return command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TESTBED_cmd_netjail_stop (const char *label,
+GNUNET_TESTING_cmd_netjail_stop (const char *label,
char *local_m,
char *global_n);
struct GNUNET_TESTING_Command
-GNUNET_TESTBED_cmd_stop_testbed (const char *label,
- const char *helper_start_label,
- char *local_m,
- char *global_n);
+GNUNET_TESTING_cmd_stop_testing_system (const char *label,
+ const char *helper_start_label,
+ char *local_m,
+ char *global_n);
int
-GNUNET_TESTBED_get_trait_helper_handles (const struct
+GNUNET_TESTING_get_trait_helper_handles (const struct
GNUNET_TESTING_Command *cmd,
struct GNUNET_HELPER_Handle ***helper);
-int
-GNUNET_TESTBED_get_trait_hosts (const struct
- GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTBED_Host ***hosts);
-
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_block_until_all_peers_started (const char *label,
unsigned int *
@@ -275,11 +100,11 @@ GNUNET_TESTING_cmd_block_until_all_peers_started (const char *label,
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_send_peer_ready (const char *label,
- TESTBED_CMD_HELPER_write_cb write_message);
+ TESTING_CMD_HELPER_write_cb write_message);
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_local_test_finished (const char *label,
- TESTBED_CMD_HELPER_write_cb
+ TESTING_CMD_HELPER_write_cb
write_message);
#endif
diff --git a/src/include/gnunet_testing_plugin.h b/src/include/gnunet_testing_plugin.h
index 103eb23be..151827d4b 100644
--- a/src/include/gnunet_testing_plugin.h
+++ b/src/include/gnunet_testing_plugin.h
@@ -37,11 +37,11 @@ extern "C"
#endif
typedef void
-(*TESTBED_CMD_HELPER_write_cb) (struct GNUNET_MessageHeader *message, size_t
+(*TESTING_CMD_HELPER_write_cb) (struct GNUNET_MessageHeader *message, size_t
msg_length);
typedef void
-(*GNUNET_TESTING_PLUGIN_StartTestCase) (TESTBED_CMD_HELPER_write_cb
+(*GNUNET_TESTING_PLUGIN_StartTestCase) (TESTING_CMD_HELPER_write_cb
write_message, char *router_ip,
char *node_ip,
char *n,
diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am
index b4b2cff97..5a221cd69 100644
--- a/src/testbed/Makefile.am
+++ b/src/testbed/Makefile.am
@@ -23,7 +23,6 @@ if HAVE_SQLITE
endif
libexec_PROGRAMS = \
- gnunet-cmd \
gnunet-cmds-helper \
gnunet-service-testbed \
gnunet-helper-testbed \
@@ -90,14 +89,6 @@ gnunet_helper_testbed_LDADD = $(XLIB) \
libgnunettestbed.la \
$(LTLIBINTL) $(Z_LIBS)
-gnunet_cmd_SOURCES = \
- gnunet-cmd.c
-gnunet_cmd_LDADD = $(XLIB) \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/testing/libgnunettesting.la \
- libgnunettestbed.la \
- $(LTLIBINTL) $(Z_LIBS)
-
gnunet_cmds_helper_SOURCES = \
gnunet-cmds-helper.c
gnunet_cmds_helper_LDADD = $(XLIB) \
@@ -138,8 +129,6 @@ libgnunettestbed_la_SOURCES = \
testbed_api_cmd_netjail_stop.c \
testbed_api.c testbed_api.h testbed.h \
testbed_api_hosts.c testbed_api_hosts.h testbed_helper.h \
- testbed_api_cmd_controller.c \
- testbed_api_cmd_peer.c \
testbed_api_operations.c testbed_api_operations.h \
testbed_api_peers.c testbed_api_peers.h \
testbed_api_services.c \
diff --git a/src/testbed/gnunet-cmd.c b/src/testbed/gnunet-cmd.c
deleted file mode 100644
index 0ba94fdd9..000000000
--- a/src/testbed/gnunet-cmd.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2008--2013, 2016 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file testbed/gnunet-cmd.c
- *
- * @brief Binary to start testcase plugins
- *
- * @author t3sserakt
- */
-
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_testing_lib.h"
-#include "gnunet_testing_plugin.h"
-
-/**
- * Generic logging shortcut
- */
-#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
-
-#define NODE_BASE_IP "192.168.15."
-
-#define ROUTER_BASE_IP "92.68.150."
-
-/**
- * Handle for a plugin.
- */
-struct Plugin
-{
- /**
- * Name of the shared library.
- */
- char *library_name;
-
- /**
- * Plugin API.
- */
- struct GNUNET_TESTING_PluginFunctions *api;
-
- char *node_ip;
-
- char *plugin_name;
-
- char *global_n;
-
- char *local_m;
-
- char *n;
-
- char *m;
-};
-
-
-/**
- * Main function to run the test cases.
- *
- * @param cls plugin to use.
- *
- */
-static void
-run (void *cls)
-{
- struct Plugin *plugin = cls;
- char *router_ip;
- char *node_ip;
-
- router_ip = GNUNET_malloc (strlen (ROUTER_BASE_IP) + strlen (plugin->m) + 1);
- strcpy (router_ip, ROUTER_BASE_IP);
- strcat (router_ip, plugin->m);
-
- node_ip = GNUNET_malloc (strlen (NODE_BASE_IP) + strlen (plugin->n) + 1);
- strcat (node_ip, NODE_BASE_IP);
- strcat (node_ip, plugin->n);
-
- plugin->api->start_testcase (NULL, router_ip, node_ip, NULL, NULL, NULL);
-
-}
-
-
-int
-main (int argc, char *const *argv)
-{
- int rv = 0;
- struct Plugin *plugin;
-
- GNUNET_log_setup ("gnunet-cmd",
- "DEBUG",
- NULL);
-
- plugin = GNUNET_new (struct Plugin);
- plugin->api = GNUNET_PLUGIN_load (argv[0],
- NULL);
- plugin->library_name = GNUNET_strdup (argv[0]);
-
- plugin->global_n = argv[1];
- plugin->local_m = argv[2];
- plugin->n = argv[3];
- plugin->m = argv[4];
-
- GNUNET_SCHEDULER_run (&run,
- plugin);
-
- GNUNET_free (plugin);
- return rv;
-}
diff --git a/src/testbed/plugin_testcmd.c b/src/testbed/plugin_testcmd.c
index e08ec067d..b74b67240 100644
--- a/src/testbed/plugin_testcmd.c
+++ b/src/testbed/plugin_testcmd.c
@@ -45,7 +45,7 @@ all_peers_started ()
}
static void
-start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip,
+start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
char *node_ip,
char *n,
char *m,
diff --git a/src/testbed/test_testbed_api_cmd_netjail.c b/src/testbed/test_testbed_api_cmd_netjail.c
index 8bb9e40e8..85da39f0e 100644
--- a/src/testbed/test_testbed_api_cmd_netjail.c
+++ b/src/testbed/test_testbed_api_cmd_netjail.c
@@ -39,18 +39,18 @@ static void
run (void *cls)
{
struct GNUNET_TESTING_Command commands[] = {
- GNUNET_TESTBED_cmd_netjail_start ("netjail-start-1",
+ GNUNET_TESTING_cmd_netjail_start ("netjail-start-1",
"2",
"2"),
- GNUNET_TESTBED_cmd_netjail_start_testbed ("netjail-start-testbed-1",
- "2",
- "2",
- "libgnunet_plugin_testcmd"),
- GNUNET_TESTBED_cmd_stop_testbed ("stop-testbed",
- "netjail-start-testbed-1",
- "2",
- "2"),
- GNUNET_TESTBED_cmd_netjail_stop ("netjail-stop-1",
+ GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed-1",
+ "2",
+ "2",
+ "libgnunet_plugin_testcmd"),
+ GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed",
+ "netjail-start-testbed-1",
+ "2",
+ "2"),
+ GNUNET_TESTING_cmd_netjail_stop ("netjail-stop-1",
"2",
"2"),
GNUNET_TESTING_cmd_end ()
diff --git a/src/testbed/testbed_api_cmd_controller.c b/src/testbed/testbed_api_cmd_controller.c
deleted file mode 100644
index 794b1ccf3..000000000
--- a/src/testbed/testbed_api_cmd_controller.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file testbed/testbed_api_cmd_controller.c
- * @brief Command to create a controller.
- * @author t3sserakt
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_testing_ng_lib.h"
-#include "gnunet-service-testbed.h"
-#include "testbed_api_hosts.h"
-#include "gnunet_testbed_ng_service.h"
-
-
-/**
- * Generic logging shortcut
- */
-#define LOG(kind, ...) \
- GNUNET_log (kind, __VA_ARGS__)
-
-
-/**
-*
-*
-* @param cls closure
-* @param cmd current CMD being cleaned up.
-*/
-static void
-controller_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
-{
- (void) cls;
-}
-
-
-/**
- * Signature of the event handler function called by the
- * respective event controller.
- *
- * @param cls closure
- * @param event information about the event
- */
-static void
-controller_cb (void *cls,
- const struct GNUNET_TESTBED_EventInformation *event)
-{
- struct ControllerState *cs = cls;
-
- if (NULL != event->details.operation_finished.emsg)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "There was an operation error: %s\n",
- event->details.operation_finished.emsg);
- GNUNET_TESTBED_shutdown_controller (cs);
- }
- else if (NULL == event->details.operation_finished.generic)
- {
- GNUNET_TESTBED_operation_done (event->op);
- }
-}
-
-
-static void
-controller_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTING_Interpreter *is)
-{
- struct ControllerState *cs = cls;
-
- cs->is = is;
-
- cs->controller =
- GNUNET_TESTBED_controller_connect (cs->host, cs->event_mask, &controller_cb,
- cs);
-
-
-}
-
-/**
-*
-*
-* @param cls closure.
-* @param[out] ret result
-* @param trait name of the trait.
-* @param index index number of the object to offer.
-* @return #GNUNET_OK on success.
-*/
-static int
-controller_traits (void *cls,
- const void **ret,
- const char *trait,
- unsigned int index)
-{
- (void) cls;
-
- struct ControllerState *cs = cls;
-
-
- struct GNUNET_TESTING_Trait traits[] = {
- {
- .index = 0,
- .trait_name = "controller",
- .ptr = (const void *) cs->controller,
- },
- GNUNET_TESTING_trait_end ()
- };
-
- return GNUNET_TESTING_get_trait (traits,
- ret,
- trait,
- index);
- return GNUNET_OK;
-}
-
-
-/**
- * Offer data from trait
- *
- * @param cmd command to extract the controller from.
- * @param pt pointer to controller.
- * @return #GNUNET_OK on success.
- */
-int
-GNUNET_TESTBED_get_trait_controller (const struct GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTBED_Controller **
- controller)
-{
- return cmd->traits (cmd->cls,
- (const void **) controller,
- "controller",
- (unsigned int) 0);
-}
-
-
-/**
- * Shutdown nicely
- *
- * @param cs controller state.
- */
-void
-GNUNET_TESTBED_shutdown_controller (struct ControllerState *cs)
-{
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Shutting down...\n");
-
- cs->controller_going_down = GNUNET_YES;
-
- if (NULL != cs->abort_task)
- GNUNET_SCHEDULER_cancel (cs->abort_task);
- if (NULL != cs->reg_handle)
- GNUNET_TESTBED_cancel_registration (cs->reg_handle);
- if (NULL != cs->controller)
- GNUNET_TESTBED_controller_disconnect (cs->controller);
- if (NULL != cs->cfg)
- GNUNET_CONFIGURATION_destroy (cs->cfg);
- if (NULL != cs->cp)
- GNUNET_TESTBED_controller_stop (cs->cp);
- if (NULL != cs->host)
- GNUNET_TESTBED_host_destroy (cs->host);
-}
-
-
-
-struct GNUNET_TESTING_Command
-GNUNET_TESTBED_cmd_controller (const char *label,
- const char *host,
- uint64_t event_mask)
-{
- struct ControllerState *cs;
-
- cs = GNUNET_new (struct ControllerState);
- cs->event_mask = event_mask;
- cs->hostname = host;
-
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = cs,
- .label = label,
- .run = &controller_run,
- .cleanup = &controller_cleanup,
- .traits = &controller_traits
- };
-
- return cmd;
-}
diff --git a/src/testbed/testbed_api_cmd_local_test_finished.c b/src/testbed/testbed_api_cmd_local_test_finished.c
index b5f4b8b31..c02546945 100644
--- a/src/testbed/testbed_api_cmd_local_test_finished.c
+++ b/src/testbed/testbed_api_cmd_local_test_finished.c
@@ -35,7 +35,7 @@
struct LocalFinishedState
{
- TESTBED_CMD_HELPER_write_cb write_message;
+ TESTING_CMD_HELPER_write_cb write_message;
struct GNUNET_CMDS_LOCAL_FINISHED *reply;
};
@@ -107,7 +107,7 @@ local_test_finished_finish (void *cls,
*/
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_local_test_finished (const char *label,
- TESTBED_CMD_HELPER_write_cb
+ TESTING_CMD_HELPER_write_cb
write_message)
{
struct LocalFinishedState *lfs;
diff --git a/src/testbed/testbed_api_cmd_netjail_start.c b/src/testbed/testbed_api_cmd_netjail_start.c
index 8edfb8b62..0cc020275 100644
--- a/src/testbed/testbed_api_cmd_netjail_start.c
+++ b/src/testbed/testbed_api_cmd_netjail_start.c
@@ -28,7 +28,7 @@
#include "gnunet_testing_ng_lib.h"
#include "gnunet_testbed_ng_service.h"
-#define NETJAIL_START_SCRIPT "./../testbed/netjail_start.sh"
+#define NETJAIL_START_SCRIPT "./../testing/netjail_start.sh"
struct NetJailState
{
@@ -139,9 +139,10 @@ netjail_start_run (void *cls,
ns->local_m,
ns->global_n,
NULL};
- unsigned int helper_check = GNUNET_OS_check_helper_binary (NETJAIL_START_SCRIPT,
- GNUNET_YES,
- NULL);
+ unsigned int helper_check = GNUNET_OS_check_helper_binary (
+ NETJAIL_START_SCRIPT,
+ GNUNET_YES,
+ NULL);
if (GNUNET_NO == helper_check)
{
@@ -193,7 +194,7 @@ netjail_start_finish (void *cls,
* @return command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TESTBED_cmd_netjail_start (const char *label,
+GNUNET_TESTING_cmd_netjail_start (const char *label,
char *local_m,
char *global_n)
{
diff --git a/src/testbed/testbed_api_cmd_netjail_start_testbed.c b/src/testbed/testbed_api_cmd_netjail_start_testbed.c
index db9cf7508..3d1a1d893 100644
--- a/src/testbed/testbed_api_cmd_netjail_start_testbed.c
+++ b/src/testbed/testbed_api_cmd_netjail_start_testbed.c
@@ -30,7 +30,7 @@
#include "testbed_api_hosts.h"
#include "testbed_helper.h"
-#define NETJAIL_EXEC_SCRIPT "./../testbed/netjail_exec.sh"
+#define NETJAIL_EXEC_SCRIPT "./../testing/netjail_exec.sh"
struct HelperMessage;
@@ -87,23 +87,16 @@ struct NetJailState
unsigned int n_msg;
- unsigned int number_of_testbeds_started;
+ unsigned int number_of_testsystems_started;
unsigned int number_of_peers_started;
unsigned int number_of_local_test_finished;
- /**
- * The host where the controller is running
- */
- struct GNUNET_TESTBED_Host **host;
-
- unsigned int n_host;
-
char *plugin_name;
};
-struct TestbedCount
+struct TestingSystemCount
{
unsigned int count;
@@ -168,14 +161,14 @@ netjail_exec_traits (void *cls,
/**
- * Offer handles to testbed helper from trait
+ * Offer handles to testing cmd helper from trait
*
* @param cmd command to extract the message from.
* @param pt pointer to message.
* @return #GNUNET_OK on success.
*/
int
-GNUNET_TESTBED_get_trait_helper_handles (const struct
+GNUNET_TESTING_get_trait_helper_handles (const struct
GNUNET_TESTING_Command *cmd,
struct GNUNET_HELPER_Handle ***helper)
{
@@ -186,14 +179,14 @@ GNUNET_TESTBED_get_trait_helper_handles (const struct
}
/**
- * Offer handles to testbed helper from trait
+ * Offer messages received via testing cmd helper from trait
*
* @param cmd command to extract the message from.
* @param pt pointer to message.
* @return #GNUNET_OK on success.
*/
int
-GNUNET_TESTBED_get_trait_helper_messages (const struct
+GNUNET_TESTING_get_trait_helper_messages (const struct
GNUNET_TESTING_Command *cmd,
struct HelperMessage ***
hp_messages_head)
@@ -216,7 +209,7 @@ GNUNET_TESTBED_get_trait_helper_messages (const struct
static void
clear_msg (void *cls, int result)
{
- struct TestbedCount *tbc = cls;
+ struct TestingSystemCount *tbc = cls;
struct NetJailState *ns = tbc->ns;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -244,7 +237,7 @@ clear_msg (void *cls, int result)
static int
helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
{
- struct TestbedCount *tbc = cls;
+ struct TestingSystemCount *tbc = cls;
struct NetJailState *ns = tbc->ns;
struct HelperMessage *hp_msg;
@@ -253,10 +246,9 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"helper_mst tbc->count: %d\n",
tbc->count);
- // GNUNET_TESTBED_extract_cfg (host, message);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received message from helper.\n");
- ns->number_of_testbeds_started++;
+ ns->number_of_testsystems_started++;
}
else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED == ntohs (
message->type))
@@ -320,57 +312,38 @@ create_helper_init_msg_ (char *m_char,
static void
-start_testbed (struct NetJailState *ns, struct
- GNUNET_CONFIGURATION_Handle *config,
- char *m_char,
- char *n_char)
+start_helper (struct NetJailState *ns, struct
+ GNUNET_CONFIGURATION_Handle *config,
+ char *m_char,
+ char *n_char)
{
// struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_CMDS_HelperInit *msg;
- struct TestbedCount *tbc;
+ struct TestingSystemCount *tbc;
char *const script_argv[] = {NETJAIL_EXEC_SCRIPT,
m_char,
n_char,
- GNUNET_OS_get_libexec_binary_path(HELPER_CMDS_BINARY),
+ GNUNET_OS_get_libexec_binary_path (
+ HELPER_CMDS_BINARY),
ns->global_n,
ns->local_m,
NULL};
unsigned int m = atoi (m_char);
unsigned int n = atoi (n_char);
- unsigned int helper_check = GNUNET_OS_check_helper_binary (NETJAIL_EXEC_SCRIPT,
- GNUNET_YES,
- NULL);
+ unsigned int helper_check = GNUNET_OS_check_helper_binary (
+ NETJAIL_EXEC_SCRIPT,
+ GNUNET_YES,
+ NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"m: %d n: %d\n",
m,
n);
- tbc = GNUNET_new (struct TestbedCount);
+ tbc = GNUNET_new (struct TestingSystemCount);
tbc->ns = ns;
tbc->count = (n - 1) * atoi (ns->local_m) + m;
- // cfg = GNUNET_CONFIGURATION_dup (config);
-
- // TODO We do not need this?
- /*GNUNET_array_append (ns->host, ns->n_host,
- GNUNET_TESTBED_host_create_with_id (tbc->count - 1,
- NULL,
- NULL,
- cfg,
- 0));*/
-
- /*if ((GNUNET_YES != GNUNET_DISK_file_test ("test_testbed_api.conf")) ||
- (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (config,
- "test_testbed_api.conf")))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ (
- "Unreadable or malformed configuration file `%s', exit ...\n"),
- "test_testbed_api.conf");
- }*/
-
-
if (GNUNET_NO == helper_check)
{
@@ -396,13 +369,13 @@ start_testbed (struct NetJailState *ns, struct
tbc));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "First using helper %d %d\n",
+ "First using helper %d %d\n",
tbc->count - 1,
ns->n_helper);
struct GNUNET_HELPER_Handle *helper = ns->helper[tbc->count - 1];
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "First using helper %d %d %p\n",
+ "First using helper %d %d %p\n",
tbc->count - 1,
ns->n_helper,
helper);
@@ -456,9 +429,9 @@ netjail_exec_run (void *cls,
{
sprintf (str_n, "%d", i);
sprintf (str_m, "%d", j);
- start_testbed (ns, config,
- str_m,
- str_n);
+ start_helper (ns, config,
+ str_m,
+ str_n);
}
}
}
@@ -475,7 +448,7 @@ netjail_start_finish (void *cls,
struct GNUNET_CMDS_ALL_PEERS_STARTED *reply;
size_t msg_length;
struct GNUNET_HELPER_Handle *helper;
- struct TestbedCount *tbc;
+ struct TestingSystemCount *tbc;
if (ns->number_of_local_test_finished == total_number)
{
@@ -483,11 +456,11 @@ netjail_start_finish (void *cls,
cont (cont_cls);
}
- if (ns->number_of_testbeds_started == total_number)
+ if (ns->number_of_testsystems_started == total_number)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"All helpers started!\n");
- ns->number_of_testbeds_started = 0;
+ ns->number_of_testsystems_started = 0;
}
if (ns->number_of_peers_started == total_number)
@@ -498,7 +471,7 @@ netjail_start_finish (void *cls,
for (int i = 1; i <= atoi (ns->global_n); i++) {
for (int j = 1; j <= atoi (ns->local_m); j++)
{
- tbc = GNUNET_new (struct TestbedCount);
+ tbc = GNUNET_new (struct TestingSystemCount);
tbc->ns = ns;
// TODO This needs to be more generic. As we send more messages back and forth, we can not grow the arrays again and again, because this is to error prone.
tbc->count = (i - 1) * atoi (ns->local_m) + j + total_number;
@@ -544,11 +517,11 @@ netjail_start_finish (void *cls,
* @return command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TESTBED_cmd_netjail_start_testbed (const char *label,
- char *local_m,
- char *global_n,
- char *plugin_name,
- unsigned int *rv)
+GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label,
+ char *local_m,
+ char *global_n,
+ char *plugin_name,
+ unsigned int *rv)
{
struct NetJailState *ns;
diff --git a/src/testbed/testbed_api_cmd_netjail_stop.c b/src/testbed/testbed_api_cmd_netjail_stop.c
index 947384fed..f837ec08c 100644
--- a/src/testbed/testbed_api_cmd_netjail_stop.c
+++ b/src/testbed/testbed_api_cmd_netjail_stop.c
@@ -29,7 +29,7 @@
#include "gnunet_testbed_ng_service.h"
-#define NETJAIL_STOP_SCRIPT "./../testbed/netjail_stop.sh"
+#define NETJAIL_STOP_SCRIPT "./../testing/netjail_stop.sh"
struct GNUNET_ChildWaitHandle *cwh;
@@ -135,9 +135,10 @@ netjail_stop_run (void *cls,
ns->local_m,
ns->global_n,
NULL};
- unsigned int helper_check = GNUNET_OS_check_helper_binary (NETJAIL_STOP_SCRIPT,
- GNUNET_YES,
- NULL);
+ unsigned int helper_check = GNUNET_OS_check_helper_binary (
+ NETJAIL_STOP_SCRIPT,
+ GNUNET_YES,
+ NULL);
if (GNUNET_NO == helper_check)
{
@@ -192,7 +193,7 @@ netjail_stop_finish (void *cls,
* @return command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TESTBED_cmd_netjail_stop (const char *label,
+GNUNET_TESTING_cmd_netjail_stop (const char *label,
char *local_m,
char *global_n)
{
diff --git a/src/testbed/testbed_api_cmd_netjail_stop_testbed.c b/src/testbed/testbed_api_cmd_netjail_stop_testbed.c
index 9a9d489a7..c74c1e94f 100644
--- a/src/testbed/testbed_api_cmd_netjail_stop_testbed.c
+++ b/src/testbed/testbed_api_cmd_netjail_stop_testbed.c
@@ -53,8 +53,8 @@ struct StopHelperState
* @param cmd current CMD being cleaned up.
*/
static void
-stop_testbed_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+stop_testing_system_cleanup (void *cls,
+ const struct GNUNET_TESTING_Command *cmd)
{
}
@@ -70,10 +70,10 @@ stop_testbed_cleanup (void *cls,
* @return #GNUNET_OK on success.
*/
static int
-stop_testbed_traits (void *cls,
- const void **ret,
- const char *trait,
- unsigned int index)
+stop_testing_system_traits (void *cls,
+ const void **ret,
+ const char *trait,
+ unsigned int index)
{
return GNUNET_OK;
}
@@ -87,9 +87,9 @@ stop_testbed_traits (void *cls,
* @param is interpreter state.
*/
static void
-stop_testbed_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTING_Interpreter *is)
+stop_testing_system_run (void *cls,
+ const struct GNUNET_TESTING_Command *cmd,
+ struct GNUNET_TESTING_Interpreter *is)
{
struct StopHelperState *shs = cls;
struct GNUNET_HELPER_Handle **helper;
@@ -97,7 +97,7 @@ stop_testbed_run (void *cls,
start_helper_cmd = GNUNET_TESTING_interpreter_lookup_command (
shs->helper_start_label);
- GNUNET_TESTBED_get_trait_helper_handles (start_helper_cmd,
+ GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd,
&helper);
for (int i = 1; i <= atoi (shs->global_n); i++) {
@@ -118,11 +118,11 @@ stop_testbed_run (void *cls,
* @return command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TESTBED_cmd_stop_testbed (const char *label,
- const char *helper_start_label,
- char *local_m,
- char *global_n
- )
+GNUNET_TESTING_cmd_stop_testing_system (const char *label,
+ const char *helper_start_label,
+ char *local_m,
+ char *global_n
+ )
{
struct StopHelperState *shs;
@@ -134,9 +134,9 @@ GNUNET_TESTBED_cmd_stop_testbed (const char *label,
struct GNUNET_TESTING_Command cmd = {
.cls = shs,
.label = label,
- .run = &stop_testbed_run,
- .cleanup = &stop_testbed_cleanup,
- .traits = &stop_testbed_traits
+ .run = &stop_testing_system_run,
+ .cleanup = &stop_testing_system_cleanup,
+ .traits = &stop_testing_system_traits
};
return cmd;
diff --git a/src/testbed/testbed_api_cmd_peer.c b/src/testbed/testbed_api_cmd_peer.c
deleted file mode 100644
index 2e253e408..000000000
--- a/src/testbed/testbed_api_cmd_peer.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-
-/**
- * @file testbed/testbed_api_cmd_peer.c
- * @brief Command to create a peer.
- * @author t3sserakt
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_testing_ng_lib.h"
-#include "gnunet_testbed_ng_service.h"
-#include "gnunet-service-testbed.h"
-#include "testbed_api_peers.h"
-
-
-/**
- * Generic logging shortcut
- */
-#define LOG(kind, ...) \
- GNUNET_log (kind, __VA_ARGS__)
-
-
-/**
-*
-*
-* @param cls closure.
-* @param[out] ret result
-* @param trait name of the trait.
-* @param index index number of the object to offer.
-* @return #GNUNET_OK on success.
-*/
-static int
-peer_traits (void *cls,
- const void **ret,
- const char *trait,
- unsigned int index)
-{
- struct PeerCmdState *ps = cls;
-
- struct GNUNET_TESTING_Trait traits[] = {
- {
- .index = 0,
- .trait_name = "peer",
- .ptr = (const void *) ps->peer,
- },
- GNUNET_TESTING_trait_end ()
- };
-
- return GNUNET_TESTING_get_trait (traits,
- ret,
- trait,
- index);
-
- return GNUNET_OK;
-}
-
-/**
- * Offer data from trait
- *
- * @param cmd command to extract the controller from.
- * @param peer pointer GNUNET_TESTBED_PEER
- * @return #GNUNET_OK on success.
- */
-int
-GNUNET_TESTBED_get_trait_peer (const struct GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTBED_Peer **
- peer)
-{
- return cmd->traits (cmd->cls,
- (const void **) peer,
- "peer",
- (unsigned int) 0);
-}
-
-
-/**
-*
-*
-* @param cls closure
-* @param cmd current CMD being cleaned up.
-*/
-static void
-peer_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
-{
- (void) cls;
-}
-
-
-/**
- * abort task to run on test timed out
- *
- * @param cls NULL
- * @param tc the task context
- */
-static void
-do_abort (void *cls)
-{
- struct PeerCmdState *ps = cls;
-
- if (GNUNET_NO == ps->peer_ready)
- {
- LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n");
- ps->abort_task = NULL;
- GNUNET_TESTBED_shutdown_peer (ps);
- }
-}
-
-
-/**
- * Functions of this signature are called when a peer has been successfully
- * created
- *
- * @param cls the closure from GNUNET_TESTBED_peer_create()
- * @param emsg MAY contain an error description, if starting peer failed.
- */
-static void
-peer_started_cb (void *cls,
- const char *emsg)
-{
- struct PeerCmdState *ps = cls;
-
- GNUNET_TESTBED_operation_done (ps->operation);
- if (NULL == emsg)
- {
- ps->peer_ready = GNUNET_YES;
- }
- else
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "There was an error starting a peer: %s\n",
- emsg);
- }
-
-}
-
-
-/**
- * Functions of this signature are called when a peer has been successfully
- * created
- *
- * @param cls the closure from GNUNET_TESTBED_peer_create()
- * @param peer the handle for the created peer; NULL on any error during
- * creation
- * @param emsg NULL if peer is not NULL; else MAY contain the error description
- */
-static void
-peer_create_cb (void *cls,
- struct GNUNET_TESTBED_Peer *peer,
- const char *emsg)
-{
- struct PeerCmdState *ps = cls;
-
- ps->peer = peer;
- GNUNET_TESTBED_operation_done (ps->operation);
- ps->operation = GNUNET_TESTBED_peer_start (NULL,
- peer,
- &peer_started_cb,
- ps);
-}
-
-
-static void
-peer_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTING_Interpreter *is)
-{
- struct PeerCmdState *ps = cls;
- const struct GNUNET_TESTING_Command *controller_cmd;
- struct GNUNET_TESTBED_Controller *controller;
-
- ps->is = is;
- controller_cmd = GNUNET_TESTING_interpreter_lookup_command (
- ps->controller_label);
- GNUNET_TESTBED_get_trait_controller (controller_cmd,
- &controller);
- ps->host = GNUNET_TESTBED_host_create (ps->hostname, ps->username, ps->cfg,
- ps->port);
- ps->operation =
- GNUNET_TESTBED_peer_create (controller,
- ps->host,
- ps->cfg,
- &peer_create_cb,
- ps);
-
- ps->abort_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_MINUTES, 5),
- &do_abort,
- ps);
-}
-
-
-void
-peer_stopped_cb (void *cls,
- const char *emsg)
-{
- struct PeerCmdState *ps = cls;
-
- if (NULL != emsg)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "There was an error stopping a peer: %s\n",
- emsg);
- }
- GNUNET_TESTBED_operation_done (ps->operation);
- GNUNET_TESTBED_peer_destroy (ps->peer);
-}
-
-
-/**
- * Shutdown nicely
- *
- * @param cs controller state.
- */
-void
-GNUNET_TESTBED_shutdown_peer (struct PeerCmdState *ps)
-{
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Shutting down...\n");
-
- ps->peer_going_down = GNUNET_YES;
-
- if (NULL != ps->abort_task)
- GNUNET_SCHEDULER_cancel (ps->abort_task);
- if (NULL != ps->cfg)
- GNUNET_CONFIGURATION_destroy (ps->cfg);
- if (NULL != ps->host)
- GNUNET_TESTBED_host_destroy (ps->host);
-
- GNUNET_TESTBED_operation_done (ps->operation);
- ps->operation = GNUNET_TESTBED_peer_stop (NULL, ps->peer, peer_stopped_cb,
- ps);
-
-}
-
-
-struct GNUNET_TESTING_Command
-GNUNET_TESTBED_cmd_peer (const char *label,
- const char *controller_label,
- const char *hostname,
- const char *username,
- uint16_t port,
- struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct PeerCmdState *ps;
-
- ps = GNUNET_new (struct PeerCmdState);
- ps->hostname = hostname;
- ps->username = username;
- ps->port = port;
- ps->cfg = cfg;
- ps->controller_label = controller_label;
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = ps,
- .label = label,
- .run = &peer_run,
- .cleanup = &peer_cleanup,
- .traits = &peer_traits
- };
-
- return cmd;
-}
diff --git a/src/testbed/testbed_api_cmd_peer_store.c b/src/testbed/testbed_api_cmd_peer_store.c
deleted file mode 100644
index fc96f589c..000000000
--- a/src/testbed/testbed_api_cmd_peer_store.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file testbed/testbed_api_cmd_peer_store.c
- * @brief Command to start the peer store service of a peer.
- * @author t3sserakt
- */
-
-
-static void
-service_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTING_Interpreter *is)
-{
- struct PeerStoreState *pss = cls;
-
- pss->psh = GNUNET_PEERSTORE_connect (pss->cfg);
- GNUNET_TESTING_interpreter_next (ps->is);
-}
-
-
-struct GNUNET_TESTING_Command
-GNUNET_TESTBED_cmd_peer_store (const char *label,
- struct GNUNET_CONFIGURATION_Handle *cfg)
-{
-
- struct PeerStoreState *pss;
-
- pss = GNUNET_new (struct PeerStoreState);
- pss->cfg = cfg;
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = pss,
- .label = label,
- .run = &peer_store_run,
- .cleanup = &peer_store_cleanup,
- .traits = &peer_store_traits
- };
-
- return cmd;
-
-}
diff --git a/src/testbed/testbed_api_cmd_send_peer_ready.c b/src/testbed/testbed_api_cmd_send_peer_ready.c
index f175a3e18..987f0853e 100644
--- a/src/testbed/testbed_api_cmd_send_peer_ready.c
+++ b/src/testbed/testbed_api_cmd_send_peer_ready.c
@@ -31,7 +31,7 @@
struct SendPeerReadyState
{
- TESTBED_CMD_HELPER_write_cb write_message;
+ TESTING_CMD_HELPER_write_cb write_message;
struct GNUNET_CMDS_PEER_STARTED *reply;
};
@@ -84,7 +84,7 @@ send_peer_ready_run (void *cls,
*/
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_send_peer_ready (const char *label,
- TESTBED_CMD_HELPER_write_cb write_message)
+ TESTING_CMD_HELPER_write_cb write_message)
{
struct SendPeerReadyState *sprs;
diff --git a/src/testbed/testbed_api_cmd_tng_connect.c b/src/testbed/testbed_api_cmd_tng_connect.c
deleted file mode 100644
index e52cd3c76..000000000
--- a/src/testbed/testbed_api_cmd_tng_connect.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-
-/**
- * @file testbed/testbed_api_cmd_peer.c
- * @brief Command to create a peer.
- * @author t3sserakt
- */
-
-
-static void
-tng_connect_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTING_Interpreter *is)
-{
- struct TngConnectState *tcs = cls;
-
- tcs->ah = GNUNET_TRANSPORT_application_init (tcs->cfg);
-}
-
-struct GNUNET_TESTING_Command
-GNUNET_TESTBED_cmd_tng_connect (const char *label)
-{
- struct TngConnectState *tcs;
-
- ts = GNUNET_new (struct TngConnectState);
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = tcs,
- .label = label,
- .run = &tng_connect_run,
- .cleanup = &tmg_connect_cleanup,
- .traits = &tng_connect_traits
- };
-
- return cmd;
-}
diff --git a/src/testbed/testbed_api_cmd_tng_service.c b/src/testbed/testbed_api_cmd_tng_service.c
deleted file mode 100644
index cce2e14e3..000000000
--- a/src/testbed/testbed_api_cmd_tng_service.c
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file testbed/testbed_api_cmd_tng.c
- * @brief Command to start the transport service of a peer.
- * @author t3sserakt
- */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_testing_ng_lib.h"
-#include "gnunet-service-testbed.h"
-#include "testbed_api_hosts.h"
-#include "gnunet_testbed_ng_service.h"
-
-/**
- * Generic logging shortcut
- */
-#define LOG(kind, ...) \
- GNUNET_log (kind, __VA_ARGS__)
-
-
-/**
- * abort task to run on test timed out
- *
- * @param cls NULL
- * @param tc the task context
- */
-static void
-do_abort (void *cls)
-{
- struct TngState *ts = cls;
-
- if (GNUNET_NO == ts->service_ready)
- {
- LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n");
- ts->abort_task = NULL;
- GNUNET_TESTBED_shutdown_service (ts);
- }
-}
-
-/**
-*
-*
-* @param cls closure
-* @param cmd current CMD being cleaned up.
-*/
-static void
-tng_service_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
-{
- (void) cls;
-}
-
-/**
-*
-*
-* @param cls closure.
-* @param[out] ret result
-* @param trait name of the trait.
-* @param index index number of the object to offer.
-* @return #GNUNET_OK on success.
-*/
-static int
-tng_service_traits (void *cls,
- const void **ret,
- const char *trait,
- unsigned int index)
-{
- (void) cls;
- return GNUNET_OK;
-}
-
-
-static void *
-notify_connect (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- struct GNUNET_MQ_Handle *mq)
-{
- struct TngState *ts = cls;
-
- if (NULL != emsg)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "There was an error starting the transport subsystem: %s\n",
- emsg);
- }
- GNUNET_TESTING_interpreter_next (ps->is);
- return ts->nc (ts->cb_cls);
-
-}
-
-
-static void
-notify_disconnect (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- void *handler_cls)
-{
-}
-
-
-
-
-/**
- * Adapter function called to establish a connection to
- * a service.
- *
- * @param cls closure
- * @param cfg configuration of the peer to connect to; will be available until
- * GNUNET_TESTBED_operation_done() is called on the operation returned
- * from GNUNET_TESTBED_service_connect()
- * @return service handle to return in 'op_result', NULL on error
- */
-static void *
-connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- struct TngState *ts = cls;
-
- service_handle = GNUNET_TRANSPORT_core_connect (cfg,
- ts->peer_identity,
- ts->handlers,
- ts,
- &notify_connect,
- &notify_disconnect);
- return service_handle;
-}
-
-
-/**
- * Adapter function called to destroy a connection to
- * a service.
- *
- * @param cls closure
- * @param op_result service handle returned from the connect adapter
- */
-static void
-disconnect_adapter (void *cls,
- void *op_result)
-{
-}
-
-/**
- * Callback to be called when a service connect operation is completed
- *
- * @param cls the callback closure from functions generating an operation
- * @param op the operation that has been finished
- * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter()
- * @param emsg error message in case the operation has failed; will be NULL if
- * operation has executed successfully.
- */
-static void
-service_connect_comp_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- void *ca_result,
- const char *emsg)
-{
- struct TngState *ts = cls;
-
- if (NULL != emsg)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "An error occurred connecting to service %s\n",
- emsg);
- GNUNET_TESTBED_operation_done (ts->operation);
- }
-}
-
-
-/**
- * Callback to be called when the requested peer information is available
- *
- * @param cls the closure from GNUNET_TESTBED_peer_getinformation()
- * @param op the operation this callback corresponds to
- * @param pinfo the result; will be NULL if the operation has failed
- * @param emsg error message if the operation has failed;
- * NULL if the operation is successful
- */
-static void
-pi_cb (void *cls,
- struct GNUNET_TESTBED_Operation *op,
- const struct GNUNET_TESTBED_PeerInformation *pinfo,
- const char *emsg)
-{
- struct TngState *ts = cls;
-
- ts->peer_identity = pinfo->id;
- ts->operation =
- GNUNET_TESTBED_service_connect (NULL, peer, NULL,
- &service_connect_comp_cb, ts,
- &connect_adapter,
- &disconnect_adapter,
- ts);
-}
-
-
-static void
-tng_service_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTING_Interpreter *is)
-{
- struct TngState *ts = cls;
- struct GNUNET_TESTBED_Peer *peer;
- const struct GNUNET_TESTING_Command *peer_cmd;
-
- ts->is = is;
- peer_cmd = GNUNET_TESTING_interpreter_lookup_command (
- ts->peer_label);
- GNUNET_TESTBED_get_trait_peer (peer_cmd,
- &peer);
-
- ts->operation = GNUNET_TESTBED_peer_get_information (peer,
- GNUNET_TESTBED_PIT_IDENTITY,
- &pi_cb,
- ts);
-}
-
-/**
- * Shutdown nicely
- *
- * @param cs service state.
- */
-void
-GNUNET_TESTBED_shutdown_service (struct TngState *cs)
-{
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Shutting down...\n");
-}
-
-
-struct GNUNET_TESTING_Command
-GNUNET_TESTBED_cmd_tng_service (const char *label,
- const char *peer_label,
- const struct GNUNET_MQ_MessageHandler *handlers,
- GNUNET_TRANSPORT_NotifyConnect nc,
- void *cb_cls)
-
-{
- struct TngState *ts;
-
- ts = GNUNET_new (struct TngState);
- ts->servicename = servicename;
- ts->peer_label = peer_label;
- ts->handlers = handlers;
- ts->nc = nc;
- ts->nd = nd;
- ts->cb_cls;
-
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = ts,
- .label = label,
- .run = &tng_service_run,
- .cleanup = &tmg_service_cleanup,
- .traits = &tng_service_traits
- };
-
- return cmd;
-}
diff --git a/src/testing/netjail_exec.sh b/src/testing/netjail_exec.sh
new file mode 100755
index 000000000..b76d2e444
--- /dev/null
+++ b/src/testing/netjail_exec.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+. "./../testbed/netjail_core.sh"
+
+set -eu
+set -x
+
+export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+
+M=$1
+N=$2
+
+NODE=$(netjail_print_name "N" $N $M)
+
+
+
+netjail_node_exec_without_fds $NODE $3 $4 $5 $1 $2
diff --git a/src/testing/netjail_start.sh b/src/testing/netjail_start.sh
new file mode 100755
index 000000000..4c1c33c83
--- /dev/null
+++ b/src/testing/netjail_start.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+. "./../testbed/netjail_core.sh"
+
+set -eu
+set -x
+
+export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+
+LOCAL_M=$1
+GLOBAL_N=$2
+
+# TODO: stunserver? ..and globally known peer?
+
+shift 2
+
+LOCAL_GROUP="192.168.15"
+GLOBAL_GROUP="92.68.150"
+
+NETWORK_NET=$(netjail_print_name "n" $GLOBAL_N $LOCAL_M)
+
+netjail_bridge $NETWORK_NET
+
+for N in $(seq $GLOBAL_N); do
+ ROUTER=$(netjail_print_name "R" $N)
+
+ netjail_node $ROUTER
+ netjail_node_link_bridge $ROUTER $NETWORK_NET "$GLOBAL_GROUP.$N" 24
+
+ ROUTER_NET=$(netjail_print_name "r" $N)
+
+ netjail_bridge $ROUTER_NET
+
+ for M in $(seq $LOCAL_M); do
+ NODE=$(netjail_print_name "N" $N $M)
+
+ netjail_node $NODE
+ netjail_node_link_bridge $NODE $ROUTER_NET "$LOCAL_GROUP.$M" 24
+ done
+
+ ROUTER_ADDR="$LOCAL_GROUP.$(($LOCAL_M+1))"
+
+ netjail_node_link_bridge $ROUTER $ROUTER_NET $ROUTER_ADDR 24
+ netjail_node_add_nat $ROUTER $ROUTER_ADDR 24
+
+ for M in $(seq $LOCAL_M); do
+ NODE=$(netjail_print_name "N" $N $M)
+
+ netjail_node_add_default $NODE $ROUTER_ADDR
+ done
+done
+
+
diff --git a/src/testing/netjail_stop.sh b/src/testing/netjail_stop.sh
new file mode 100755
index 000000000..689bf7ae9
--- /dev/null
+++ b/src/testing/netjail_stop.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+. "./../testbed/netjail_core.sh"
+
+set -eu
+set -x
+
+export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+
+LOCAL_M=$1
+GLOBAL_N=$2
+NETWORK_NET=$(netjail_print_name "n" $GLOBAL_N $LOCAL_M)
+
+shift 2
+
+for N in $(seq $GLOBAL_N); do
+ for M in $(seq $LOCAL_M); do
+ netjail_node_clear $(netjail_print_name "N" $N $M)
+ done
+
+ netjail_bridge_clear $(netjail_print_name "r" $N)
+ netjail_node_clear $(netjail_print_name "R" $N)
+done
+
+netjail_bridge_clear $NETWORK_NET
+
+echo "Done"
diff --git a/src/testing/testing_api_cmd_send_peer_ready.c b/src/testing/testing_api_cmd_send_peer_ready.c
index 27761c4d5..e5e004924 100644
--- a/src/testing/testing_api_cmd_send_peer_ready.c
+++ b/src/testing/testing_api_cmd_send_peer_ready.c
@@ -32,7 +32,7 @@
struct SendPeerReadyState
{
- TESTBED_CMD_HELPER_write_cb write_message;
+ TESTING_CMD_HELPER_write_cb write_message;
struct GNUNET_CMDS_PEER_STARTED *reply;
};
@@ -85,7 +85,7 @@ send_peer_ready_run (void *cls,
*/
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_send_peer_ready (const char *label,
- TESTBED_CMD_HELPER_write_cb write_message)
+ TESTING_CMD_HELPER_write_cb write_message)
{
struct SendPeerReadyState *sprs;
diff --git a/src/transport/plugin_cmd_simple_send.c b/src/transport/plugin_cmd_simple_send.c
index 2a4a8c137..468f4e48a 100644
--- a/src/transport/plugin_cmd_simple_send.c
+++ b/src/transport/plugin_cmd_simple_send.c
@@ -83,7 +83,7 @@ all_peers_started ()
}
static void
-start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip,
+start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
char *node_ip,
char *m,
char *n,
diff --git a/src/transport/test_transport_api_cmd_simple_send.c b/src/transport/test_transport_api_cmd_simple_send.c
index 26da53c47..1cc16f307 100644
--- a/src/transport/test_transport_api_cmd_simple_send.c
+++ b/src/transport/test_transport_api_cmd_simple_send.c
@@ -43,19 +43,19 @@ static void
run (void *cls)
{
struct GNUNET_TESTING_Command commands[] = {
- GNUNET_TESTBED_cmd_netjail_start ("netjail-start-1",
+ GNUNET_TESTING_cmd_netjail_start ("netjail-start-1",
"2",
"1"),
- GNUNET_TESTBED_cmd_netjail_start_testbed ("netjail-start-testbed-1",
- "2",
- "1",
- "libgnunet_plugin_cmd_simple_send",
- &rv),
- GNUNET_TESTBED_cmd_stop_testbed ("stop-testbed",
- "netjail-start-testbed-1",
- "2",
- "1"),
- GNUNET_TESTBED_cmd_netjail_stop ("netjail-stop-1",
+ GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed-1",
+ "2",
+ "1",
+ "libgnunet_plugin_cmd_simple_send",
+ &rv),
+ GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed",
+ "netjail-start-testbed-1",
+ "2",
+ "1"),
+ GNUNET_TESTING_cmd_netjail_stop ("netjail-stop-1",
"2",
"1"),
GNUNET_TESTING_cmd_end ()