[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 22/40: NEWS: Code moved to the core package to get rid of circu
From: |
gnunet |
Subject: |
[gnunet] 22/40: NEWS: Code moved to the core package to get rid of circular dependencies. |
Date: |
Thu, 05 Oct 2023 08:57:25 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
commit 1016d6d193b1af38f90999de25854593c77364a8
Author: t3sserakt <t3ss@posteo.de>
AuthorDate: Mon Oct 2 18:10:36 2023 +0200
NEWS: Code moved to the core package to get rid of circular dependencies.
---
src/core/Makefile.am | 90 ++--
src/core/core_api_cmd_connecting_peers.c | 275 ++++++++++++
src/core/test_core_plugin_cmd_just_run.c | 512 +++++++++++++++++++++++
src/core/test_core_start_testcase.sh | 15 +
src/include/gnunet_testing_ng_lib.h | 91 +++-
src/transport/Makefile.am | 20 +-
src/transport/test_transport_api2_tng_node.conf | 9 +
src/transport/test_transport_start_with_config.c | 1 -
8 files changed, 947 insertions(+), 66 deletions(-)
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index cad234abd..1343fe395 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -3,6 +3,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/include
pkgcfgdir= $(pkgdatadir)/config.d/
+plugindir = $(libdir)/gnunet
+
libexecdir= $(pkglibdir)/libexec/
pkgcfg_DATA = \
@@ -13,9 +15,15 @@ if USE_COVERAGE
XLIB = -lgcov
endif
+plugin_LTLIBRARIES = \
+ libgnunet_test_core_plugin_cmd_just_run.la
+
+TESTING_LIBS = \
+ libgnunetcoretesting.la
lib_LTLIBRARIES = \
- libgnunetcore.la
+ libgnunetcore.la \
+ $(TESTING_LIBS)
libgnunetcore_la_SOURCES = \
core_api.c core.h \
@@ -27,6 +35,35 @@ libgnunetcore_la_LDFLAGS = \
$(GN_LIB_LDFLAGS) \
-version-info 0:1:0
+libgnunet_test_core_plugin_cmd_just_run_la_SOURCES = \
+ test_core_plugin_cmd_just_run.c
+libgnunet_test_core_plugin_cmd_just_run_la_LIBADD = \
+ $(top_builddir)/src/transport/libgnunettransportapplication.la \
+ $(top_builddir)/src/transport/libgnunettransportcore.la \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/peerstore/libgnunetpeerstore.la \
+ $(top_builddir)/src/core/libgnunetcoretesting.la \
+ $(top_builddir)/src/statistics/libgnunetstatistics.la \
+ $(top_builddir)/src/hello/libgnunethello.la \
+ $(top_builddir)/src/ats/libgnunetats.la \
+ $(top_builddir)/src/arm/libgnunetarm.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(LTLIBINTL)
+libgnunet_test_core_plugin_cmd_just_run_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
+
+libgnunetcoretesting_la_SOURCES = \
+ core_api_cmd_connecting_peers.c
+libgnunetcoretesting_la_LIBADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/transport/libgnunettransportapplication.la \
+ $(top_builddir)/src/transport/libgnunettransportcore.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+libgnunetcoretesting_la_LDFLAGS = \
+ $(GN_LIBINTL) \
+ $(GN_LIB_LDFLAGS) \
+ -version-info 0:0:0
+
libexec_PROGRAMS = \
gnunet-service-core
@@ -60,32 +97,18 @@ TESTING_TESTS = \
check_PROGRAMS = \
test_core_api_start_only \
- test_core_api \
- test_core_api_reliability \
- test_core_quota_compliance_symmetric \
- test_core_quota_compliance_asymmetric_send_limited \
- test_core_quota_compliance_asymmetric_recv_limited \
$(TESTING_TESTS)
+# Only test TNG if we run experimental
+check_SCRIPTS= \
+ test_core_start_testcase.sh
+
if ENABLE_TEST_RUN
AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export
PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset
XDG_CONFIG_HOME;
-TESTS = $(check_PROGRAMS)
+TESTS = $(check_PROGRAMS) \
+ $(check_SCRIPTS)
endif
-test_core_api_SOURCES = \
- test_core_api.c
-test_core_api_LDADD = \
- libgnunetcore.la \
- $(top_builddir)/src/ats/libgnunetats.la \
- $(top_builddir)/src/util/libgnunetutil.la
-
-test_core_api_reliability_SOURCES = \
- test_core_api_reliability.c
-test_core_api_reliability_LDADD = \
- libgnunetcore.la \
- $(top_builddir)/src/ats/libgnunetats.la \
- $(top_builddir)/src/util/libgnunetutil.la
-
test_core_api_send_to_self_SOURCES = \
test_core_api_send_to_self.c
test_core_api_send_to_self_LDADD = \
@@ -100,31 +123,8 @@ test_core_api_start_only_LDADD = \
libgnunetcore.la \
$(top_builddir)/src/util/libgnunetutil.la
-test_core_quota_compliance_symmetric_SOURCES = \
- test_core_quota_compliance.c
-test_core_quota_compliance_symmetric_LDADD = \
- libgnunetcore.la \
- $(top_builddir)/src/ats/libgnunetats.la \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/statistics/libgnunetstatistics.la
-
-test_core_quota_compliance_asymmetric_send_limited_SOURCES = \
- test_core_quota_compliance.c
-test_core_quota_compliance_asymmetric_send_limited_LDADD = \
- libgnunetcore.la \
- $(top_builddir)/src/ats/libgnunetats.la \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/statistics/libgnunetstatistics.la
-
-test_core_quota_compliance_asymmetric_recv_limited_SOURCES = \
- test_core_quota_compliance.c
-test_core_quota_compliance_asymmetric_recv_limited_LDADD = \
- libgnunetcore.la \
- $(top_builddir)/src/ats/libgnunetats.la \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/statistics/libgnunetstatistics.la
-
EXTRA_DIST = \
+ test_core_start_testcase.sh \
test_core_defaults.conf \
test_core_api_data.conf \
test_core_api_peer1.conf \
diff --git a/src/core/core_api_cmd_connecting_peers.c
b/src/core/core_api_cmd_connecting_peers.c
new file mode 100644
index 000000000..ce2184a3c
--- /dev/null
+++ b/src/core/core_api_cmd_connecting_peers.c
@@ -0,0 +1,275 @@
+/*
+ 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 testing_api_cmd_start_peer.c
+ * @brief cmd to start a peer.
+ * @author t3sserakt
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_netjail_lib.h"
+#include "gnunet_transport_application_service.h"
+#include "gnunet_hello_lib.h"
+#include "gnunet_transport_core_service.h"
+
+/**
+ * Generic logging shortcut
+ */
+#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
+
+
+/**
+ * The run method of this cmd will connect to peers.
+ *
+ */
+static void
+connect_peers_run (void *cls,
+ struct GNUNET_TESTING_Interpreter *is)
+{
+ struct GNUNET_TESTING_ConnectPeersState *cps = cls;
+ const struct GNUNET_TESTING_StartPeerState *sps;
+ const struct GNUNET_TESTING_Command *system_cmd;
+ const struct GNUNET_TESTING_System *tl_system;
+ const struct GNUNET_TESTING_Command *peer1_cmd;
+ struct GNUNET_PeerIdentity *peer;
+ enum GNUNET_NetworkType nt = 0;
+ struct GNUNET_TESTING_NodeConnection *pos_connection;
+ struct GNUNET_TESTING_AddressPrefix *pos_prefix;
+ const enum GNUNET_GenericReturnValue *broadcast;
+ unsigned int con_num = 0;
+ uint32_t num;
+ char *addr;
+ char *addr_and_port;
+ char *emsg = NULL;
+
+ cps->is = is;
+ peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
+
cps->start_peer_label);
+ GNUNET_TESTING_get_trait_broadcast (peer1_cmd,
+ &broadcast);
+ GNUNET_TESTING_get_trait_state (peer1_cmd,
+ &sps);
+
+ system_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
+ cps->create_label);
+ GNUNET_TESTING_get_trait_test_system (system_cmd,
+ &tl_system);
+
+ cps->tl_system = tl_system;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "cps->num: %u \n",
+ cps->num);
+
+
+ cps->ah = GNUNET_TRANSPORT_application_init (sps->cfg);
+ if (NULL == cps->ah)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to initialize the TRANSPORT application suggestion client
handle for peer `%s': `%s'\n",
+ sps->cfgname,
+ emsg);
+ GNUNET_free (emsg);
+ GNUNET_TESTING_interpreter_fail (is);
+ return;
+ }
+
+ cps->node_connections_head = GNUNET_TESTING_get_connections (cps->num,
+ cps->topology);
+
+ for (pos_connection = cps->node_connections_head; NULL != pos_connection;
+ pos_connection = pos_connection->next)
+ {
+ con_num++;
+ num = GNUNET_TESTING_calculate_num (pos_connection, cps->topology);
+ for (pos_prefix = pos_connection->address_prefixes_head; NULL !=
pos_prefix;
+ pos_prefix =
+ pos_prefix->next)
+ {
+ addr = GNUNET_TESTING_get_address (pos_connection,
+ pos_prefix->address_prefix);
+ if (NULL != addr)
+ {
+ char *natted_p = strstr (pos_prefix->address_prefix, "_");
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "0 validating peer number %s %s %s\n",
+ natted_p,
+ pos_prefix->address_prefix,
+ addr);
+ if (0 == GNUNET_memcmp (pos_prefix->address_prefix, "udp"))
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "validating memcmp\n");
+ if (GNUNET_YES == *broadcast)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "validating broadcast\n");
+ if ((0 == GNUNET_memcmp (pos_prefix->address_prefix, "udp")) &&
+ (GNUNET_YES == *broadcast) )
+ GNUNET_asprintf (&addr_and_port,
+ "%s:2086",
+ addr);
+ else if (NULL == natted_p)
+ GNUNET_asprintf (&addr_and_port,
+ "%s:60002",
+ addr);
+ else if (NULL != natted_p)
+ {
+ char *prefix;
+ char *rest;
+ char *rest2;
+ char *address;
+
+ prefix = strtok (addr, "_");
+ rest = strtok (NULL, "_");
+ rest2 = strtok (rest, "-");
+ address = strtok (NULL, "-");
+
+ GNUNET_asprintf (&addr_and_port,
+ "%s-%s:0",
+ prefix,
+ address);
+
+ }
+ peer = GNUNET_TESTING_get_peer (num, tl_system);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "validating peer number %u with identity %s and address %s
%u %s and handle %p\n",
+ num,
+ GNUNET_i2s (peer),
+ addr_and_port,
+ *broadcast,
+ pos_prefix->address_prefix,
+ cps->ah);
+ GNUNET_TRANSPORT_application_validate ((struct
+
GNUNET_TRANSPORT_ApplicationHandle
+ *) cps->ah,
+ peer,
+ nt,
+ addr_and_port);
+ GNUNET_free (peer);
+ GNUNET_free (addr);
+ GNUNET_free (addr_and_port);
+ }
+ }
+ }
+ cps->con_num = con_num;
+}
+
+
+/**
+ * The cleanup function of this cmd frees resources the cmd allocated.
+ *
+ */
+static void
+connect_peers_cleanup (void *cls)
+{
+ struct GNUNET_TESTING_ConnectPeersState *cps = cls;
+
+ GNUNET_free (cps->connected_peers_map);
+ GNUNET_free (cps);
+}
+
+
+/**
+ * This function prepares an array with traits.
+ *
+ */
+enum GNUNET_GenericReturnValue
+connect_peers_traits (void *cls,
+ const void **ret,
+ const char *trait,
+ unsigned int index)
+{
+ struct GNUNET_TESTING_ConnectPeersState *cps = cls;
+ struct GNUNET_TESTING_Trait traits[] = {
+ GNUNET_TESTING_make_trait_connect_peer_state ((const void *) cps),
+ GNUNET_TESTING_trait_end ()
+ };
+ return GNUNET_TESTING_get_trait (traits,
+ ret,
+ trait,
+ index);
+}
+
+
+struct GNUNET_TESTING_Command
+GNUNET_CORE_cmd_connect_peers (const char *label,
+ const char *start_peer_label,
+ const char *create_label,
+ uint32_t num,
+ struct GNUNET_TESTING_NetjailTopology *
+ topology,
+ unsigned int additional_connects,
+ unsigned int wait_for_connect,
+ struct GNUNET_MQ_MessageHandler *handlers)
+{
+ struct GNUNET_TESTING_ConnectPeersState *cps;
+ unsigned int node_additional_connects;
+ struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
+ GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
+ unsigned int i;
+
+ node_additional_connects = GNUNET_TESTING_get_additional_connects (num,
+ topology);
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "global: %u and local: %u additional_connects\n",
+ additional_connects,
+ node_additional_connects);
+
+ if (0 != node_additional_connects)
+ additional_connects = node_additional_connects;
+
+ cps = GNUNET_new (struct GNUNET_TESTING_ConnectPeersState);
+ cps->start_peer_label = start_peer_label;
+ cps->num = num;
+ cps->create_label = create_label;
+ cps->topology = topology;
+ cps->additional_connects = additional_connects;
+ cps->wait_for_connect = wait_for_connect;
+ cps->connected_peers_map = connected_peers_map;
+
+ if (NULL != handlers)
+ {
+ for (i = 0; NULL != handlers[i].cb; i++)
+ ;
+ cps->handlers = GNUNET_new_array (i + 1,
+ struct GNUNET_MQ_MessageHandler);
+ GNUNET_memcpy (cps->handlers,
+ handlers,
+ i * sizeof(struct GNUNET_MQ_MessageHandler));
+ }
+
+ if (GNUNET_YES == wait_for_connect)
+ return GNUNET_TESTING_command_new (cps,
+ label,
+ &connect_peers_run,
+ &connect_peers_cleanup,
+ &connect_peers_traits,
+ &cps->ac);
+ else
+ return GNUNET_TESTING_command_new (cps,
+ label,
+ &connect_peers_run,
+ &connect_peers_cleanup,
+ &connect_peers_traits,
+ NULL);
+}
diff --git a/src/core/test_core_plugin_cmd_just_run.c
b/src/core/test_core_plugin_cmd_just_run.c
new file mode 100644
index 000000000..176d055c8
--- /dev/null
+++ b/src/core/test_core_plugin_cmd_just_run.c
@@ -0,0 +1,512 @@
+/*
+ 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/plugin_cmd_simple_send.c
+ * @brief a plugin to provide the API for running test cases.
+ * @author t3sserakt
+ */
+#include "platform.h"
+#include "gnunet_testing_barrier.h"
+#include "gnunet_testing_netjail_lib.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_transport_application_service.h"
+#include "gnunet_transport_core_service.h"
+#include "gnunet_testing_barrier.h"
+#include "gnunet_core_service.h"
+#include "gnunet_transport_testing_ng_lib.h"
+
+/**
+ * Generic logging shortcut
+ */
+#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
+
+#define BASE_DIR "testdir"
+
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600)
+
+#define MAX_RECEIVED 1000
+
+#define MESSAGE_SIZE 65000
+
+static struct GNUNET_TESTING_Command block_script;
+
+static struct GNUNET_TESTING_Command connect_peers;
+
+static struct GNUNET_TESTING_Command local_prepared;
+
+static struct GNUNET_TESTING_Command start_peer;
+
+static struct GNUNET_TESTING_Interpreter *is;
+
+static struct GNUNET_CONTAINER_MultiPeerMap *senders;
+
+struct TestState
+{
+ /**
+ * Callback to write messages to the master loop.
+ *
+ */
+ GNUNET_TESTING_cmd_helper_write_cb write_message;
+
+ /**
+ * Callback to notify the helper test case has finished.
+ */
+ GNUNET_TESTING_cmd_helper_finish_cb finished_cb;
+
+ /**
+ * The name for a specific test environment directory.
+ *
+ */
+ char *testdir;
+
+ /**
+ * The name for the configuration file of the specific node.
+ *
+ */
+ char *cfgname;
+
+ /**
+ * The complete topology information.
+ */
+ struct GNUNET_TESTING_NetjailTopology *topology;
+};
+
+struct Sender
+{
+ /**
+ * Number of received messages from sender.
+ */
+ unsigned long long num_received;
+
+ /**
+ * Sample mean time the message traveled.
+ */
+ struct GNUNET_TIME_Relative mean_time;
+
+ /**
+ * Time the first message was send.
+ */
+ struct GNUNET_TIME_Absolute time_first;
+};
+
+
+struct GNUNET_TESTING_BarrierList*
+get_waiting_for_barriers ()
+{
+ struct GNUNET_TESTING_BarrierList*barriers;
+ struct GNUNET_TESTING_BarrierListEntry *ble;
+
+ barriers = GNUNET_new (struct GNUNET_TESTING_BarrierList);
+ ble = GNUNET_new (struct GNUNET_TESTING_BarrierListEntry);
+ ble->barrier_name = "ready-to-connect";
+ ble->expected_reaches = 1;
+ GNUNET_CONTAINER_DLL_insert (barriers->head,
+ barriers->tail,
+ ble);
+
+ ble = GNUNET_new (struct GNUNET_TESTING_BarrierListEntry);
+ ble->barrier_name = "test-case-finished";
+ ble->expected_reaches = 1;
+ GNUNET_CONTAINER_DLL_insert (barriers->head,
+ barriers->tail,
+ ble);
+ return barriers;
+}
+
+
+/**
+ * Callback to set the flag indicating all peers started. Will be called via
the plugin api.
+ *
+ */
+static void
+all_peers_started ()
+{
+}
+
+
+/**
+ * Function called with the final result of the test.
+ *
+ * @param cls the `struct MainParams`
+ * @param rv #GNUNET_OK if the test passed
+ */
+static void
+handle_result (void *cls,
+ enum GNUNET_GenericReturnValue rv)
+{
+ struct TestState *ts = cls;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Local test exits with status %d\n",
+ rv);
+
+ ts->finished_cb (rv);
+ GNUNET_free (ts->testdir);
+ GNUNET_free (ts->cfgname);
+ GNUNET_TESTING_free_topology (ts->topology);
+ GNUNET_free (ts);
+}
+
+
+/**
+ * Callback from start peer cmd for signaling a peer got connected.
+ *
+ *
+static void *
+notify_connect (struct GNUNET_TESTING_Interpreter *is,
+ const struct GNUNET_PeerIdentity *peer)
+{
+ const struct ConnectPeersState *cps;
+ const struct GNUNET_TESTING_Command *cmd;
+
+ cmd = GNUNET_TESTING_interpreter_lookup_command (is,
+ "connect-peers");
+ GNUNET_TRANSPORT_get_trait_connect_peer_state (cmd,
+ &cps);
+ void *ret = NULL;
+
+ cps->notify_connect (is,
+ peer);
+ return ret;
+ }*/
+
+
+/**
+ * Callback to set the flag indicating all peers are prepared to finish. Will
be called via the plugin api.
+ */
+static void
+all_local_tests_prepared ()
+{
+ const struct GNUNET_TESTING_LocalPreparedState *lfs;
+
+ GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared,
+ &lfs);
+ GNUNET_assert (NULL != &lfs->ac);
+ if (NULL == lfs->ac.cont)
+ GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *)
&lfs->ac);
+ else
+ GNUNET_TESTING_async_finish ((struct
+ GNUNET_TESTING_AsyncContext *) &lfs->ac);
+}
+
+
+static void
+child_completed_callback (void *cls,
+ enum GNUNET_OS_ProcessStatusType type,
+ long unsigned int exit_code)
+{
+
+}
+
+
+/**
+ * Function called to check a message being
+ * received.
+ *
+ */
+static int
+check_encrypted (void *cls, struct GNUNET_MessageHeader *header)
+{
+ return GNUNET_OK;
+}
+
+
+static void
+core_receive_continue (struct GNUNET_PeerIdentity *peer)
+{
+ const struct GNUNET_TESTING_StartPeerState *sps;
+
+ GNUNET_TESTING_get_trait_state (&start_peer,
+ &sps);
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Executing core receive continue\n");
+
+ GNUNET_TRANSPORT_core_receive_continue (sps->th, peer);
+}
+
+
+/*static void
+handle_core (void *cls, struct GNUNET_MessageHeader *header)
+{
+ struct GNUNET_PeerIdentity *peer = cls;
+
+ core_receive_continue (peer);
+ }*/
+
+
+/**
+ * Function called to handle a message being received.
+ *
+ */
+static void
+handle_encrypted (void *cls, struct GNUNET_MessageHeader *header)
+{
+ struct GNUNET_PeerIdentity *peer = cls;
+
+ core_receive_continue (peer);
+}
+
+
+static void
+handle_ephemeral_key (void *cls, struct GNUNET_MessageHeader *header)
+{
+ struct GNUNET_PeerIdentity *peer = cls;
+
+ core_receive_continue (peer);
+}
+
+
+static void
+handle_ping (void *cls, struct GNUNET_MessageHeader *header)
+{
+ struct GNUNET_PeerIdentity *peer = cls;
+
+ core_receive_continue (peer);
+}
+
+
+static void
+handle_pong (void *cls, struct GNUNET_MessageHeader *header)
+{
+ struct GNUNET_PeerIdentity *peer = cls;
+
+ core_receive_continue (peer);
+}
+
+
+/**
+ * Function to start a local test case.
+ *
+ * @param write_message Callback to send a message to the master loop.
+ * @param router_ip Global address of the network namespace.
+ * @param node_ip The IP address of the node.
+ * @param m The number of the node in a network namespace.
+ * @param n The number of the network namespace.
+ * @param local_m The number of nodes in a network namespace.
+ * @param topology_data A file name for the file containing the topology
configuration, or a string containing
+ * the topology configuration.
+ * @param read_file If read_file is GNUNET_YES this string is the filename for
the topology configuration,
+ * if read_file is GNUNET_NO the string contains the topology
configuration.
+ * @param finish_cb Callback function which writes a message from the helper
process running on a netjail
+ * node to the master process * signaling that the test case
running on the netjail node finished.
+ * @return Returns the struct GNUNET_TESTING_Interpreter of the command loop
running on this netjail node.
+ */
+static struct GNUNET_TESTING_Interpreter *
+start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message,
+ const char *router_ip,
+ const char *node_ip,
+ const char *m,
+ const char *n,
+ const char *local_m,
+ const char *topology_data,
+ unsigned int *read_file,
+ GNUNET_TESTING_cmd_helper_finish_cb finished_cb)
+{
+
+ unsigned int n_int;
+ unsigned int m_int;
+ unsigned int local_m_int;
+ unsigned int num;
+ struct TestState *ts = GNUNET_new (struct TestState);
+ struct GNUNET_TESTING_NetjailTopology *topology;
+ unsigned int sscanf_ret = 0;
+ char **argv = NULL;
+ int argc = 0;
+
+ ts->finished_cb = finished_cb;
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "n %s m %s\n",
+ n,
+ m);
+
+ if (GNUNET_YES == *read_file)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "read from file\n");
+ topology = GNUNET_TESTING_get_topo_from_file (topology_data);
+ }
+ else
+ topology = GNUNET_TESTING_get_topo_from_string (topology_data);
+
+ ts->topology = topology;
+
+ errno = 0;
+ sscanf_ret = sscanf (m, "%u", &m_int);
+ if (errno != 0)
+ {
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf");
+ }
+ GNUNET_assert (0 < sscanf_ret);
+ errno = 0;
+ sscanf_ret = sscanf (n, "%u", &n_int);
+ if (errno != 0)
+ {
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf");
+ }
+ GNUNET_assert (0 < sscanf_ret);
+ errno = 0;
+ sscanf_ret = sscanf (local_m, "%u", &local_m_int);
+ if (errno != 0)
+ {
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf");
+ }
+ GNUNET_assert (0 < sscanf_ret);
+
+ if (0 == n_int)
+ num = m_int;
+ else
+ num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
+
+ block_script = GNUNET_TESTING_cmd_block_until_external_trigger (
+ "block-script");
+ connect_peers = GNUNET_CORE_cmd_connect_peers ("connect-peers",
+ "start-peer",
+ "system-create",
+ num,
+ topology,
+ 0,
+ GNUNET_NO,
+ NULL);
+ local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
+ "local-test-prepared",
+ write_message);
+
+
+ GNUNET_asprintf (&ts->cfgname,
+ "test_core_just_run.conf");
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "plugin cfgname: %s\n",
+ ts->cfgname);
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "node ip: %s\n",
+ node_ip);
+
+ GNUNET_asprintf (&ts->testdir,
+ "%s%s%s",
+ BASE_DIR,
+ m,
+ n);
+
+ /*struct GNUNET_MQ_MessageHandler handlers[] = {
+ GNUNET_MQ_hd_fixed_size (ephemeral_key,
+ GNUNET_MESSAGE_TYPE_CORE_EPHEMERAL_KEY,
+ struct EphemeralKeyMessage,
+ NULL),
+ GNUNET_MQ_hd_fixed_size (ping,
+ GNUNET_MESSAGE_TYPE_CORE_PING,
+ struct PingMessage,
+ NULL),
+ GNUNET_MQ_hd_fixed_size (pong,
+ GNUNET_MESSAGE_TYPE_CORE_PONG,
+ struct PongMessage,
+ NULL),
+ GNUNET_MQ_handler_end ()
+ };*/
+
+ start_peer = GNUNET_TESTING_cmd_start_peer ("start-peer",
+ "system-create",
+ num,
+ node_ip,
+ ts->cfgname,
+ GNUNET_NO);
+
+ struct GNUNET_TESTING_Command commands[] = {
+ GNUNET_TESTING_cmd_system_create ("system-create",
+ ts->testdir),
+ start_peer,
+ GNUNET_TESTING_cmd_barrier_reached ("ready-to-connect-reached",
+ "ready-to-connect",
+ GNUNET_NO,
+ num,
+ GNUNET_NO,
+ write_message),
+ connect_peers,
+ GNUNET_TESTING_cmd_exec_bash_script ("script",
+ "block.sh",
+ argv,
+ argc,
+ &child_completed_callback),
+ block_script,
+ GNUNET_TESTING_cmd_barrier_reached ("test-case-finished-reached",
+ "test-case-finished",
+ GNUNET_NO,
+ num,
+ GNUNET_NO,
+ write_message),
+ GNUNET_TESTING_cmd_stop_peer ("stop-peer",
+ "start-peer"),
+ GNUNET_TESTING_cmd_system_destroy ("system-destroy",
+ "system-create"),
+ GNUNET_TESTING_cmd_end ()
+ };
+
+ ts->write_message = write_message;
+
+ is = GNUNET_TESTING_run (commands,
+ TIMEOUT,
+ &handle_result,
+ ts);
+ return is;
+}
+
+
+/**
+ * Entry point for the plugin.
+ *
+ * @param cls NULL
+ * @return the exported block API
+ */
+void *
+libgnunet_test_core_plugin_cmd_just_run_init (void *cls)
+{
+ struct GNUNET_TESTING_PluginFunctions *api;
+
+ GNUNET_log_setup ("simple-send",
+ "DEBUG",
+ NULL);
+
+ api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
+ api->start_testcase = &start_testcase;
+ api->get_waiting_for_barriers = get_waiting_for_barriers;
+ return api;
+}
+
+
+/**
+ * Exit point from the plugin.
+ *
+ * @param cls the return value from
#libgnunet_test_transport_plugin_just_run_init
+ * @return NULL
+ */
+void *
+libgnunet_test_core_plugin_cmd_just_run_done (void *cls)
+{
+ struct GNUNET_TESTING_PluginFunctions *api = cls;
+
+ GNUNET_free (api);
+ return NULL;
+}
+
+
+/* end of plugin_cmd_simple_send.c */
diff --git a/src/core/test_core_start_testcase.sh
b/src/core/test_core_start_testcase.sh
new file mode 100755
index 000000000..78e67dbf5
--- /dev/null
+++ b/src/core/test_core_start_testcase.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+echo gaga1 > gaga.txt
+read -p "Test case configuration to use:" conf
+if ! [ -d "/run/netns" ]; then
+ echo You have to create the directory /run/netns.
+fi
+if [ -f /proc/sys/kernel/unprivileged_userns_clone ]; then
+ if [ "$(cat /proc/sys/kernel/unprivileged_userns_clone)" != 1 ]; then
+ echo -e "Error during test setup: The kernel parameter
kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n
sysctl kernel.unprivileged_userns_clone=1\n"
+ exit 78
+ fi
+fi
+echo gaga2 >> gaga.txt
+exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns;
/usr/local/lib/gnunet/libexec/test_testing_start_with_config $conf"
+echo gaga3 >> gaga.txt
diff --git a/src/include/gnunet_testing_ng_lib.h
b/src/include/gnunet_testing_ng_lib.h
index 98ba65b59..eff45498b 100644
--- a/src/include/gnunet_testing_ng_lib.h
+++ b/src/include/gnunet_testing_ng_lib.h
@@ -621,6 +621,95 @@ typedef void *
(*GNUNET_TESTING_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is,
const struct GNUNET_PeerIdentity *peer);
+/**
+ * Struct to store information needed in callbacks.
+ *
+ */
+struct GNUNET_TESTING_ConnectPeersState
+{
+ /**
+ * Receive callback
+ */
+ struct GNUNET_MQ_MessageHandler *handlers;
+
+ /**
+ * A map with struct GNUNET_MQ_Handle values for each peer this peer
+ * is connected to.
+ */
+ struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
+
+ /**
+ * Handle for transport.
+ */
+ struct GNUNET_TRANSPORT_ApplicationHandle *ah;
+
+ /**
+ * Core handle.
+ */
+ struct GNUNET_TRANSPORT_CoreHandle *th;
+
+ /**
+ * Context for our asynchronous completion.
+ */
+ struct GNUNET_TESTING_AsyncContext ac;
+
+ /**
+ * The testing system of this node.
+ */
+ const struct GNUNET_TESTING_System *tl_system;
+
+ // Label of the cmd which started the test system.
+ const char *create_label;
+
+ /**
+ * Number globally identifying the node.
+ *
+ */
+ uint32_t num;
+
+ /**
+ * Label of the cmd to start a peer.
+ *
+ */
+ const char *start_peer_label;
+
+ /**
+ * The topology of the test setup.
+ */
+ struct GNUNET_TESTING_NetjailTopology *topology;
+
+ /**
+ * Connections to other peers.
+ */
+ struct GNUNET_TESTING_NodeConnection *node_connections_head;
+
+ struct GNUNET_TESTING_Interpreter *is;
+
+ /**
+ * Number of connections.
+ */
+ unsigned int con_num;
+
+ /**
+ * Number of additional connects this cmd will wait for not triggered by
this cmd.
+ */
+ unsigned int additional_connects;
+
+ /**
+ * Number of connections we already have a notification for.
+ */
+ unsigned int con_num_notified;
+
+ /**
+ * Number of additional connects this cmd will wait for not triggered by
this cmd we already have a notification for.
+ */
+ unsigned int additional_connects_notified;
+
+ /**
+ * Flag indicating, whether the command is waiting for peers to connect that
are configured to connect.
+ */
+ unsigned int wait_for_connect;
+};
/**
* Struct to store information needed in callbacks.
@@ -899,7 +988,7 @@ struct GNUNET_TESTING_StartPeerState
op (hello_size, const size_t) \
op (hello, const char) \
op (application_handle, const struct GNUNET_TRANSPORT_ApplicationHandle) \
- op (connect_peer_state, const struct ConnectPeersState) \
+ op (connect_peer_state, const struct GNUNET_TESTING_ConnectPeersState) \
op (state, const struct GNUNET_TESTING_StartPeerState) \
op (broadcast, const enum GNUNET_GenericReturnValue)
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index 93d6aed13..5b51f3edd 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -363,25 +363,7 @@ plugin_LTLIBRARIES = \
libgnunet_test_transport_plugin_cmd_simple_send.la \
libgnunet_test_transport_plugin_cmd_simple_send_broadcast.la \
libgnunet_test_transport_plugin_cmd_simple_send_dv.la \
- libgnunet_test_transport_plugin_cmd_udp_backchannel.la \
- libgnunet_test_transport_plugin_cmd_just_run.la
-
-libgnunet_test_transport_plugin_cmd_just_run_la_SOURCES = \
- test_transport_plugin_cmd_just_run.c
-libgnunet_test_transport_plugin_cmd_just_run_la_LIBADD = \
- libgnunettransporttesting2.la \
- libgnunettransportapplication.la \
- libgnunettransportcore.la \
- $(top_builddir)/src/testing/libgnunettesting.la \
- $(top_builddir)/src/peerstore/libgnunetpeerstore.la \
- $(top_builddir)/src/statistics/libgnunetstatistics.la \
- $(top_builddir)/src/hello/libgnunethello.la \
- $(top_builddir)/src/ats/libgnunetats.la \
- $(top_builddir)/src/arm/libgnunetarm.la \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(LTLIBINTL)
-libgnunet_test_transport_plugin_cmd_just_run_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
+ libgnunet_test_transport_plugin_cmd_udp_backchannel.la
libgnunet_test_transport_plugin_cmd_nat_upnp_la_SOURCES = \
test_transport_plugin_cmd_nat_upnp.c
diff --git a/src/transport/test_transport_api2_tng_node.conf
b/src/transport/test_transport_api2_tng_node.conf
index 61ffbe92f..b2514b39f 100644
--- a/src/transport/test_transport_api2_tng_node.conf
+++ b/src/transport/test_transport_api2_tng_node.conf
@@ -29,3 +29,12 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/udp-comm-p1.sock
[peerstore]
IMMEDIATE_START = YES
+
+[topology]
+IMMEDIATE_START = YES
+
+[dht]
+IMMEDIATE_START = YES
+
+[fs]
+IMMEDIATE_START = YES
diff --git a/src/transport/test_transport_start_with_config.c
b/src/transport/test_transport_start_with_config.c
index 8a7a3dbb5..a2c692dbc 100644
--- a/src/transport/test_transport_start_with_config.c
+++ b/src/transport/test_transport_start_with_config.c
@@ -26,7 +26,6 @@
#include "platform.h"
#include "gnunet_testing_ng_lib.h"
#include "gnunet_testing_netjail_lib.h"
-#include "transport-testing-cmds.h"
#include "gnunet_util_lib.h"
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet] branch master updated (92c6b1ae0 -> 898b9a01a), gnunet, 2023/10/05
- [gnunet] 01/40: NEWS: Added __attribute__((deprecated)) to the old transport API, gnunet, 2023/10/05
- [gnunet] 06/40: TNG: Accidentally removed code., gnunet, 2023/10/05
- [gnunet] 02/40: NEWS: Added __attribute__((deprecated)) to the old transport API, gnunet, 2023/10/05
- [gnunet] 09/40: NEWS: Moved start peer command to testing subsystem., gnunet, 2023/10/05
- [gnunet] 05/40: TNG: Deactivated all tests which rely on the old transport api., gnunet, 2023/10/05
- [gnunet] 12/40: TNG: Fixed bug that QueueEntry of another queue still holds reference to PendingMessage., gnunet, 2023/10/05
- [gnunet] 13/40: NEWS: Changed new hello uri api to allow to change the expiration time, gnunet, 2023/10/05
- [gnunet] 22/40: NEWS: Code moved to the core package to get rid of circular dependencies.,
gnunet <=
- [gnunet] 16/40: TOPOLOGY: Exchanged peerinfo api to store hellos with new peerstore api., gnunet, 2023/10/05
- [gnunet] 19/40: HELLO: Cli tool for changing hello files in contrib can change file from old to new hello design., gnunet, 2023/10/05
- [gnunet] 07/40: NEWS: Added command to execute a script., gnunet, 2023/10/05
- [gnunet] 17/40: PEERSTORE: change watch to return actual values, before watching., gnunet, 2023/10/05
- [gnunet] 32/40: Merge branch 'master' into l20integration, gnunet, 2023/10/05
- [gnunet] 29/40: TNG: Fixed syntax., gnunet, 2023/10/05
- [gnunet] 03/40: News: Merge branch 'l20integration' of ssh://git.gnunet.org/gnunet into l20integration, gnunet, 2023/10/05
- [gnunet] 36/40: Fix warnings; CADET not FTBFS because old hello removed, gnunet, 2023/10/05
- [gnunet] 33/40: Merge branch 'master' into l20integration, gnunet, 2023/10/05
- [gnunet] 18/40: NEWS: The old hello design replaced by the new hello design., gnunet, 2023/10/05