gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] 02/02: transport: reintroducing simple send test


From: gnunet
Subject: [gnunet] 02/02: transport: reintroducing simple send test
Date: Sat, 21 Dec 2024 22:32:16 +0100

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

commit 6ec2d3346b3c184c357ad1c24877f62af0cf8aa7
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Sat Dec 21 22:31:56 2024 +0100

    transport: reintroducing simple send test
---
 src/service/transport/Makefile.am                  |   7 +-
 .../test_transport_plugin_cmd_simple_send.c        |   3 -
 .../transport/test_transport_plugin_simple_send.c  |  22 +--
 .../transport/test_transport_simple_send_topo.conf |  10 +-
 .../transport/testing_transport_cmd_send_simple.c  | 156 +++++++++++++++++++++
 src/service/transport/transport-testing-cmds.h     |   4 +-
 6 files changed, 181 insertions(+), 21 deletions(-)

diff --git a/src/service/transport/Makefile.am 
b/src/service/transport/Makefile.am
index 7a7c00029..b0894f052 100644
--- a/src/service/transport/Makefile.am
+++ b/src/service/transport/Makefile.am
@@ -30,6 +30,7 @@ lib_LTLIBRARIES = \
 libgnunet_test_transport_plugin_simple_send_la_SOURCES = \
   test_transport_plugin_simple_send.c
 libgnunet_test_transport_plugin_simple_send_la_LIBADD = \
+  libgnunettestingtransport.la \
   $(top_builddir)/src/service/arm/libgnunettestingarm.la \
   $(top_builddir)/src/lib/testing/libgnunettesting.la \
   $(top_builddir)/src/service/testbed/libgnunettestbed.la \
@@ -40,10 +41,10 @@ libgnunet_test_transport_plugin_simple_send_la_LIBADD = \
 
 libgnunettestingtransport_la_SOURCES = \
   testing_transport_traits.c transport-testing-cmds.h \
-  transport-testing-communicator.c transport-testing-communicator.h 
+  transport-testing-communicator.c transport-testing-communicator.h \
+  testing_transport_cmd_send_simple.c
 #  transport_api_cmd_connecting_peers.c \
 #  transport_api_cmd_backchannel_check.c \
-#  transport_api_cmd_send_simple.c \
 #  transport_api_cmd_send_simple_performance.c \
 #  transport-testing2.c transport-testing2.h \
 #  transport-testing-cmds.h \
@@ -57,6 +58,8 @@ libgnunettestingtransport_la_LIBADD = \
   $(top_builddir)/src/service/testbed/libgnunettestbed.la \
   $(top_builddir)/src/service/arm/libgnunetarm.la \
   $(top_builddir)/src/lib/testing/libgnunettesting.la \
+  $(top_builddir)/src/service/testbed/libgnunettestbed.la \
+  $(top_builddir)/src/service/testbed/libgnunettestingtestbed.la \
   $(top_builddir)/src/lib/hello/libgnunethello.la \
   $(top_builddir)/src/service/peerstore/libgnunetpeerstore.la \
   $(top_builddir)/src/lib/util/libgnunetutil.la
diff --git a/src/service/transport/test_transport_plugin_cmd_simple_send.c 
b/src/service/transport/test_transport_plugin_cmd_simple_send.c
index efef49826..bda935503 100644
--- a/src/service/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/service/transport/test_transport_plugin_cmd_simple_send.c
@@ -24,13 +24,10 @@
  * @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 "transport-testing2.h"
 #include "transport-testing-cmds.h"
-#include "gnunet_testing_barrier.h"
 
 /**
  * Generic logging shortcut
diff --git a/src/service/transport/test_transport_plugin_simple_send.c 
b/src/service/transport/test_transport_plugin_simple_send.c
index 2aa032480..5530eabaf 100644
--- a/src/service/transport/test_transport_plugin_simple_send.c
+++ b/src/service/transport/test_transport_plugin_simple_send.c
@@ -27,6 +27,7 @@
 #include "gnunet_testing_lib.h"
 #include "gnunet_testing_arm_lib.h"
 #include "gnunet_testing_testbed_lib.h"
+#include "transport-testing-cmds.h"
 
 #define MY_CONF_PREFIX "test_transport_simple_send"
 
@@ -36,21 +37,24 @@ get_conf_name (const char *my_node_id)
   const char *conf_name;
   const char *dash;
 
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+              "Getting conf for id %s\n",
+              my_node_id);
   dash = strchr (my_node_id, '-');
   GNUNET_assert (NULL != dash);
   dash++;
 
   if (0 == strcmp ("000000", dash))
-    conf_name = MY_CONF_PREFIX"_host.conf";
+    conf_name = MY_CONF_PREFIX "_host.conf";
   else if (0 == strcmp ("000003", dash))
-    conf_name = MY_CONF_PREFIX"_peer1.conf";
-  else if (0 == strcmp ("000006", dash))
-    conf_name = MY_CONF_PREFIX"_peer1.conf";
+    conf_name = MY_CONF_PREFIX "_peer1.conf";
+  else if (0 == strcmp ("000004", dash))
+    conf_name = MY_CONF_PREFIX "_peer1.conf";
   else
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-              "Getting conf for id %s failed \n",
-              my_node_id);
+                "Getting conf for id %s failed \n",
+                my_node_id);
     GNUNET_assert (0);
   }
 
@@ -60,6 +64,7 @@ get_conf_name (const char *my_node_id)
   return conf_name;
 }
 
+
 GNUNET_TESTING_MAKE_PLUGIN (
   libgnunet_test_transport,
   simple_send,
@@ -72,10 +77,11 @@ GNUNET_TESTING_MAKE_PLUGIN (
                               GNUNET_OS_PROCESS_EXITED,
                               0,
                               "sleep",
-                              "3000",
+                              "3",
                               NULL),
+  GNUNET_TRANSPORT_cmd_send_simple ("send", "start", "system", 10),
   GNUNET_TESTING_cmd_stop_peer ("stop",
                                 "start")
   )
 
-/* end of test_plugin_transport_simple_send.c */
+  /* end of test_plugin_transport_simple_send.c */
diff --git a/src/service/transport/test_transport_simple_send_topo.conf 
b/src/service/transport/test_transport_simple_send_topo.conf
index 64a0efe81..be6e3afab 100644
--- a/src/service/transport/test_transport_simple_send_topo.conf
+++ b/src/service/transport/test_transport_simple_send_topo.conf
@@ -1,12 +1,12 @@
 [DEFAULTS]
 SUBNETS = 1
-CARRIER_SETUP_PROGRAMMS = iptables -A INPUT -p icmp -j DROP;tc qdisc add dev 
$UPLINK root netm delay 100ms 10ms;
-SUBNET_SETUP_PROGRAMMS = iptables -A INPUT -p icmp -j DROP;tc qdisc add dev 
$UPLINK root netm delay 100ms 10ms;
-PEER_SETUP_PROGRAMMS = iptables -A INPUT -p icmp -j DROP;tc qdisc add dev 
$UPLINK root netm delay 100ms 10ms;
+#CARRIER_SETUP_PROGRAMMS = iptables -A INPUT -p icmp -j DROP;tc qdisc add dev 
$UPLINK root netm delay 100ms 10ms;
+#SUBNET_SETUP_PROGRAMMS = iptables -A INPUT -p icmp -j DROP;tc qdisc add dev 
$UPLINK root netm delay 100ms 10ms;
+#PEER_SETUP_PROGRAMMS = iptables -A INPUT -p icmp -j DROP;tc qdisc add dev 
$UPLINK root netm delay 100ms 10ms;
 TESTBED_PLUGIN = libgnunet_test_transport_plugin_simple_send
 CARRIER_PEERS = 0
-SUBNET_PEERS = 1
+SUBNET_PEERS = 2
 
 [BACKBONE]
-CARRIERS = 2
+CARRIERS = 1
 BACKBONE_PEERS = 1
diff --git a/src/service/transport/testing_transport_cmd_send_simple.c 
b/src/service/transport/testing_transport_cmd_send_simple.c
new file mode 100644
index 000000000..aba998e9b
--- /dev/null
+++ b/src/service/transport/testing_transport_cmd_send_simple.c
@@ -0,0 +1,156 @@
+/*
+      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_lib.h"
+#include "gnunet_testbed_lib.h"
+#include "gnunet_testing_testbed_lib.h"
+#include "gnunet_testing_transport_lib.h"
+#include "transport-testing2.h"
+#include "transport-testing-cmds.h"
+
+/**
+ * Generic logging shortcut
+ */
+#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
+
+/**
+ * Struct to hold information for callbacks.
+ *
+ */
+struct SendSimpleState
+{
+  /**
+   * Number globally identifying the node.
+   *
+   */
+  uint32_t num;
+
+  /**
+   * Label of the cmd to start a peer.
+   *
+   */
+  const char *start_peer_label;
+
+  /**
+   * Label of the cmd which started the test system.
+   *
+   */
+  const char *create_label;
+
+};
+
+
+/**
+ * The cleanup function of this cmd frees resources the cmd allocated.
+ *
+ */
+static void
+send_simple_cleanup (void *cls)
+{
+  struct SendSimpleState *sss = cls;
+
+  GNUNET_free (sss);
+}
+
+
+static int
+send_simple_cb  (void *cls,
+                 const struct GNUNET_ShortHashCode *key,
+                 void *value)
+{
+  struct SendSimpleState *sss = cls;
+  struct GNUNET_MQ_Handle *mq = value;
+  struct GNUNET_MQ_Envelope *env;
+  struct GNUNET_TRANSPORT_TESTING_TestMessage *test;
+
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Sending simple test message with mq %p\n",
+       mq);
+
+  env = GNUNET_MQ_msg_extra (test,
+                             1000 - sizeof(*test),
+                             GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE);
+  test->num = htonl (sss->num);
+  memset (&test[1],
+          sss->num,
+          1000 - sizeof(*test));
+  GNUNET_MQ_send (mq,
+                  env);
+  return GNUNET_OK;
+}
+
+
+/**
+ * The run method of this cmd will send a simple message to the connected 
peers.
+ *
+ */
+static void
+send_simple_run (void *cls,
+                 struct GNUNET_TESTING_Interpreter *is)
+{
+  struct SendSimpleState *sss = cls;
+  const struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
+  const struct GNUNET_TESTING_Command *peer1_cmd;
+  const struct GNUNET_TESTING_Command *system_cmd;
+  struct GNUNET_TESTBED_System *tl_system;
+
+  peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
+                                                         
sss->start_peer_label);
+  GNUNET_TRANSPORT_TESTING_get_trait_connected_peers_map (peer1_cmd,
+                                                          
&connected_peers_map);
+
+  system_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
+                                                          sss->create_label);
+  GNUNET_TESTING_TESTBED_get_trait_test_system (system_cmd,
+                                        &tl_system);
+
+  GNUNET_CONTAINER_multishortmap_iterate (
+    (struct GNUNET_CONTAINER_MultiShortmap *)
+    connected_peers_map, send_simple_cb,
+    sss);
+}
+
+
+struct GNUNET_TESTING_Command
+GNUNET_TRANSPORT_cmd_send_simple (const char *label,
+                                  const char *start_peer_label,
+                                  const char *create_label,
+                                  uint32_t num)
+{
+  struct SendSimpleState *sss;
+
+  sss = GNUNET_new (struct SendSimpleState);
+  sss->num = num;
+  sss->start_peer_label = start_peer_label;
+  sss->create_label = create_label;
+
+  return GNUNET_TESTING_command_new (sss,
+                                     label,
+                                     &send_simple_run,
+                                     &send_simple_cleanup,
+                                     NULL);
+}
diff --git a/src/service/transport/transport-testing-cmds.h 
b/src/service/transport/transport-testing-cmds.h
index 478b3cba6..390f8d049 100644
--- a/src/service/transport/transport-testing-cmds.h
+++ b/src/service/transport/transport-testing-cmds.h
@@ -196,9 +196,7 @@ struct GNUNET_TESTING_Command
 GNUNET_TRANSPORT_cmd_send_simple (const char *label,
                                   const char *start_peer_label,
                                   const char *create_label,
-                                  uint32_t num,
-                                  struct GNUNET_TESTING_NetjailTopology *
-                                  topology);
+                                  uint32_t num);
 
 /**
  *

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]