gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: - some bug fixes and enhancements to tes


From: gnunet
Subject: [gnunet] branch master updated: - some bug fixes and enhancements to test NG tear done
Date: Mon, 10 Oct 2022 15:01:27 +0200

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

t3sserakt pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 9b39fb6ea - some bug fixes and enhancements to test NG tear done
     new 1d5786304 Merge branch 'master' of ssh://git.gnunet.org/gnunet
9b39fb6ea is described below

commit 9b39fb6ea253b89ec6588e0814fc473c12e7317b
Author: t3sserakt <t3ss@posteo.de>
AuthorDate: Mon Oct 10 14:59:55 2022 +0200

    - some bug fixes and enhancements to test NG tear done
---
 src/include/gnunet_testing_netjail_lib.h           | 49 ++++++++++++--
 src/include/gnunet_testing_plugin.h                |  6 +-
 src/testing/gnunet-cmds-helper.c                   | 49 +++++++++++++-
 src/testing/testing.c                              | 78 +++++++++++++++-------
 .../testing_api_cmd_netjail_start_testsystem.c     | 60 -----------------
 src/testing/testing_cmds.h                         |  3 +-
 .../test_transport_plugin_cmd_simple_send.c        | 51 ++++----------
 ...st_transport_plugin_cmd_simple_send_broadcast.c | 41 ++----------
 .../test_transport_plugin_cmd_simple_send_dv.c     | 41 ++----------
 .../test_transport_plugin_cmd_udp_backchannel.c    | 39 ++---------
 10 files changed, 176 insertions(+), 241 deletions(-)

diff --git a/src/include/gnunet_testing_netjail_lib.h 
b/src/include/gnunet_testing_netjail_lib.h
index 3fbb88dd0..ea44e030d 100644
--- a/src/include/gnunet_testing_netjail_lib.h
+++ b/src/include/gnunet_testing_netjail_lib.h
@@ -320,7 +320,36 @@ unsigned int
 GNUNET_TESTING_calculate_num (struct
                               GNUNET_TESTING_NodeConnection *node_connection,
                               struct GNUNET_TESTING_NetjailTopology *topology);
+struct TestState
+{
+  /**
+   * Callback to write messages to the master loop.
+   *
+   */
+  TESTING_CMD_HELPER_write_cb write_message;
+
+  /**
+   * Callback to notify the helper test case has finished.
+   */
+  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 with information for callbacks.
@@ -362,7 +391,14 @@ struct LocalPreparedState
   TESTING_CMD_HELPER_write_cb write_message;
 };
 
-
+/**
+ * Create command.
+ *
+ * @param label name for command.
+ * @param create_label Label of the cmd which started the test system.
+ * @param write_message Callback to write messages to the master loop.
+ * @return command.
+ */
 struct GNUNET_TESTING_Command
 GNUNET_TESTING_cmd_system_destroy (const char *label,
                                    const char *create_label);
@@ -438,11 +474,10 @@ GNUNET_TESTING_cmd_stop_testing_system (
 /**
  * Create a GNUNET_CMDS_LOCAL_FINISHED message.
  *
- * @param rv The result of the local test as GNUNET_GenericReturnValue.
  * @return The GNUNET_CMDS_LOCAL_FINISHED message.
 */
 struct GNUNET_MessageHeader *
-GNUNET_TESTING_send_local_test_finished_msg (enum GNUNET_GenericReturnValue 
rv);
+GNUNET_TESTING_send_local_test_finished_msg ();
 
 
 struct GNUNET_TESTING_Command
@@ -482,7 +517,13 @@ struct GNUNET_TESTING_Command
 GNUNET_TESTING_cmd_block_until_external_trigger (
   const char *label);
 
-
+/**
+ * Create command.
+ *
+ * @param label name for command.
+ * @param write_message Callback to write messages to the master loop.
+ * @return command.
+ */
 struct GNUNET_TESTING_Command
 GNUNET_TESTING_cmd_send_peer_ready (const char *label,
                                     TESTING_CMD_HELPER_write_cb write_message);
diff --git a/src/include/gnunet_testing_plugin.h 
b/src/include/gnunet_testing_plugin.h
index b59d2cea1..9d0ef269d 100644
--- a/src/include/gnunet_testing_plugin.h
+++ b/src/include/gnunet_testing_plugin.h
@@ -40,6 +40,9 @@ typedef void
 (*TESTING_CMD_HELPER_write_cb) (struct GNUNET_MessageHeader *message, size_t
                                 msg_length);
 
+typedef void
+(*TESTING_CMD_HELPER_finish_cb) ();
+
 typedef void
 (*GNUNET_TESTING_PLUGIN_StartTestCase) (TESTING_CMD_HELPER_write_cb
                                         write_message, char *router_ip,
@@ -48,7 +51,8 @@ typedef void
                                         char *m,
                                         char *local_m,
                                         char *topology_data,
-                                        unsigned int *read_file);
+                                        unsigned int *read_file,
+                                        TESTING_CMD_HELPER_finish_cb 
finish_cb);
 
 
 typedef void
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c
index 178b1b133..be58f6f6a 100644
--- a/src/testing/gnunet-cmds-helper.c
+++ b/src/testing/gnunet-cmds-helper.c
@@ -40,6 +40,7 @@
 #include "gnunet_util_lib.h"
 #include "gnunet_testing_lib.h"
 #include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_netjail_lib.h"
 #include "testing_cmds.h"
 #include "gnunet_testing_plugin.h"
 #include <zlib.h>
@@ -61,6 +62,8 @@ testing_api_cmd_block_until_all_peers_started.c */
 
 #define ROUTER_BASE_IP "92.68.150."
 
+struct GNUNET_SCHEDULER_Task *finished_task;
+
 /**
  * Handle for a plugin.
  */
@@ -232,7 +235,7 @@ static int status;
  * @param cls NULL
  */
 static void
-shutdown_task (void *cls)
+do_shutdown (void *cls)
 {
 
   LOG_DEBUG ("Shutting down.\n");
@@ -276,6 +279,8 @@ write_task (void *cls)
   bytes_wrote = GNUNET_DISK_file_write (stdout_fd,
                                         wc->data + wc->pos,
                                         wc->length - wc->pos);
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+              "message send to master loop\n");
   if (GNUNET_SYSERR == bytes_wrote)
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -307,6 +312,8 @@ write_message (struct GNUNET_MessageHeader *message, size_t 
msg_length)
 {
   struct WriteContext *wc;
 
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+              "write message to master loop\n");
   wc = GNUNET_new (struct WriteContext);
   wc->length = msg_length;
   wc->data = message;
@@ -317,6 +324,35 @@ write_message (struct GNUNET_MessageHeader *message, 
size_t msg_length)
     wc);
 }
 
+static void
+delay_shutdown_cb ()
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "doing shutdown after delay\n");
+  GNUNET_SCHEDULER_shutdown ();
+}
+
+
+static void
+finished_cb ()
+{
+  struct GNUNET_MessageHeader *reply;
+
+  reply = GNUNET_TESTING_send_local_test_finished_msg ();
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "message prepared\n");
+  write_message (reply, ntohs (reply->size));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "message send\n");
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "delaying shutdown\n");
+  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                delay_shutdown_cb,
+                                NULL);
+}
+
 
 /**
  * Functions with this signature are called whenever a
@@ -341,11 +377,16 @@ tokenizer_cb (void *cls, const struct 
GNUNET_MessageHeader *message)
   char *plugin_name;
   size_t plugin_name_size;
   uint16_t msize;
+  uint16_t type;
   size_t msg_length;
   char *router_ip;
   char *node_ip;
   unsigned int namespace_n;
 
+  type = ntohs (message->type);
+  LOG (GNUNET_ERROR_TYPE_ERROR,
+       "Received message type %u\n",
+       type);
   msize = ntohs (message->size);
   if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT == ntohs (message->type))
   {
@@ -402,7 +443,7 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader 
*message)
 
     plugin->api->start_testcase (&write_message, router_ip, node_ip, plugin->m,
                                  plugin->n, plugin->local_m, ni->topology_data,
-                                 ni->read_file);
+                                 ni->read_file, &finished_cb);
 
     msg_length = sizeof(struct GNUNET_CMDS_HelperReply);
     reply = GNUNET_new (struct GNUNET_CMDS_HelperReply);
@@ -522,7 +563,7 @@ run (void *cls,
                                                  stdin_fd,
                                                  &read_task,
                                                  NULL);
-  GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
+  GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
 }
 
 
@@ -629,6 +670,8 @@ main (int argc, char **argv)
                             &run,
                             ni);
 
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Finishing helper\n");
   GNUNET_SIGNAL_handler_uninstall (shc_chld);
   shc_chld = NULL;
   GNUNET_DISK_pipe_close (sigpipe);
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 4f0b8eaa9..95651830f 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -1319,7 +1319,7 @@ GNUNET_TESTING_peer_configure (struct 
GNUNET_TESTING_System *system,
   peer->nports = nports;
   return peer;
 
-err_ret:
+  err_ret:
   GNUNET_free (ss_instances);
   GNUNET_free (ports);
   GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s", emsg_);
@@ -2118,7 +2118,7 @@ get_node_info (unsigned int num,
   unsigned int node_m;
   struct GNUNET_TESTING_NetjailNode *node;
   struct GNUNET_TESTING_NetjailNamespace *namespace;
-  struct GNUNET_TESTING_NodeConnection *node_connections;
+  struct GNUNET_TESTING_NodeConnection *node_connections = NULL;
 
   log_topo (topology);
   hkey = GNUNET_new (struct GNUNET_ShortHashCode);
@@ -2135,7 +2135,10 @@ get_node_info (unsigned int num,
     node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals,
                                                hkey);
     if (NULL != node)
-      node_connections = node->node_connections_head;
+    {
+      *node_ex = node;
+      *node_connections_ex = node->node_connections_head;
+    }
   }
   else
   {
@@ -2248,8 +2251,15 @@ free_nodes_cb (void *cls,
   {
     while (NULL != (pos_prefix = pos_connection->address_prefixes_head))
     {
+      GNUNET_CONTAINER_DLL_remove (pos_connection->address_prefixes_head,
+                                   pos_connection->address_prefixes_tail,
+                                   pos_prefix);
       GNUNET_free (pos_prefix->address_prefix);
+      GNUNET_free (pos_prefix);
     }
+    GNUNET_CONTAINER_DLL_remove (node->node_connections_head,
+                                 node->node_connections_tail,
+                                 pos_connection);
     GNUNET_free (pos_connection);
   }
 
@@ -2398,9 +2408,11 @@ GNUNET_TESTING_get_additional_connects (unsigned int num,
   get_node_info (num, topology, &node, &namespace, &node_connections);
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "node additional_connects: %u %p\n",
-       node->additional_connects,
+       "node additional_connects for node %p\n",
        node);
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "node additional_connects: %u\n",
+       node->additional_connects);
 
   return node->additional_connects;
 }
@@ -2409,28 +2421,47 @@ GNUNET_TESTING_get_additional_connects (unsigned int 
num,
 /**
  * Create a GNUNET_CMDS_LOCAL_FINISHED message.
  *
- * @param rv The result of the local test as GNUNET_GenericReturnValue.
  * @return The GNUNET_CMDS_LOCAL_FINISHED message.
 */
 struct GNUNET_MessageHeader *
-GNUNET_TESTING_send_local_test_finished_msg (enum GNUNET_GenericReturnValue rv)
+GNUNET_TESTING_send_local_test_finished_msg ()
 {
   struct GNUNET_CMDS_LOCAL_FINISHED *reply;
   size_t msg_length;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Local test exits with status %d\n",
-              rv);
   msg_length = sizeof(struct GNUNET_CMDS_LOCAL_FINISHED);
   reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_FINISHED);
   reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED);
   reply->header.size = htons ((uint16_t) msg_length);
-  reply->result = htons (rv);
 
   return (struct GNUNET_MessageHeader *) reply;
 }
 
 
+static void
+parse_ac (struct GNUNET_TESTING_NetjailNode *p_node, char *token)
+{
+  char *ac_value;
+
+  ac_value = get_value ("AC", token);
+  if (NULL != ac_value)
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "ac value: %s\n",
+         ac_value);
+    sscanf (ac_value, "%u", &p_node->additional_connects);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "AC %u\n",
+         p_node->additional_connects);
+  }
+  else
+  {
+    p_node->additional_connects = 0;
+  }
+  GNUNET_free (ac_value);
+}
+
+
 /**
  * Parse the topology data.
  *
@@ -2446,7 +2477,6 @@ GNUNET_TESTING_get_topo_from_string (char *data)
   char *rest = NULL;
   char *value = NULL;
   char *value2;
-  char *ac_value;
   int ret;
   struct GNUNET_TESTING_NetjailTopology *topo;
   struct GNUNET_TESTING_NetjailRouter *router;
@@ -2555,6 +2585,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
            "value: %s\n",
            value);
       k_node->plugin = value;
+      parse_ac (k_node, token);
       node_connections (token, k_node);
       GNUNET_free (value);
     }
@@ -2617,6 +2648,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
     {
       struct GNUNET_TESTING_NetjailNode *p_node = GNUNET_new (struct
                                                               
GNUNET_TESTING_NetjailNode);
+      hkey = GNUNET_new (struct GNUNET_ShortHashCode);
 
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Get first Value for P.\n");
@@ -2672,26 +2704,22 @@ GNUNET_TESTING_get_topo_from_string (char *data)
         LOG (GNUNET_ERROR_TYPE_DEBUG,
              "Get value for key plugin on P.\n");
         value = get_value ("plugin", token);
-        LOG (GNUNET_ERROR_TYPE_DEBUG,
-             "plugin: %s\n",
-             value);
-        memcpy (p_node->plugin, value, sizeof (*value));
+        if (NULL != value)
+        {
+          LOG (GNUNET_ERROR_TYPE_DEBUG,
+               "plugin: %s\n",
+               value);
+          p_node->plugin = GNUNET_malloc (sizeof(*value));
+          memcpy (p_node->plugin, value, sizeof (*value));
+        }
         GNUNET_free (value);
         p_node->node_n = out;
         p_node->namespace_n = namespace->namespace_n;
       }
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Get AC Value for P.\n");
-      ac_value = get_value ("AC", token);
-      LOG (GNUNET_ERROR_TYPE_DEBUG,
-           "ac value: %s\n",
-           ac_value);
-      sscanf (ac_value, "%u", &p_node->additional_connects);
-      LOG (GNUNET_ERROR_TYPE_DEBUG,
-           "P:AC %u\n",
-           p_node->additional_connects);
+      parse_ac (p_node, token);
       node_connections (token, p_node);
-      GNUNET_free (ac_value);
     }
     token = strtok_r (NULL, "\n", &rest);
     if (NULL != token)
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem.c 
b/src/testing/testing_api_cmd_netjail_start_testsystem.c
index 972c566d6..98de0698a 100644
--- a/src/testing/testing_api_cmd_netjail_start_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_start_testsystem.c
@@ -414,66 +414,6 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader 
*message)
     // We received a message we can not handle.
     GNUNET_assert (0);
   }
-  /*if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY == ntohs (message->type))
-  {
-    ns->number_of_testsystems_started++;
-  }
-  else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED == ntohs (
-             message->type))
-  {
-    ns->number_of_peers_started++;
-    if (ns->number_of_peers_started == total_number)
-    {
-      for (int i = 1; i <= ns->known; i++)
-      {
-        send_all_peers_started (0,i, ns);
-      }
-
-      for (int i = 1; i <= ns->global_n; i++)
-      {
-        for (int j = 1; j <= ns->local_m; j++)
-        {
-          send_all_peers_started (i,j, ns);
-        }
-      }
-      ns->number_of_peers_started = 0;
-    }
-  }
-  else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED == ntohs (
-             message->type))
-  {
-    ns->number_of_local_tests_prepared++;
-    if (ns->number_of_local_tests_prepared == total_number)
-    {
-      for (int i = 1; i <= ns->known; i++)
-      {
-        send_all_local_tests_prepared (0,i, ns);
-      }
-
-      for (int i = 1; i <= ns->global_n; i++)
-      {
-        for (int j = 1; j <= ns->local_m; j++)
-        {
-          send_all_local_tests_prepared (i,j, ns);
-        }
-      }
-    }
-  }
-  else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED == ntohs (
-             message->type))
-  {
-    ns->number_of_local_tests_finished++;
-    if (ns->number_of_local_tests_finished == total_number)
-    {
-      GNUNET_TESTING_async_finish (&ns->ac);
-    }
-  }
-  else
-  {
-    // We received a message we can not handle.
-    GNUNET_assert (0);
-    }*/
-
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "total %u sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n",
diff --git a/src/testing/testing_cmds.h b/src/testing/testing_cmds.h
index 12db87d19..c4246d51e 100644
--- a/src/testing/testing_cmds.h
+++ b/src/testing/testing_cmds.h
@@ -83,10 +83,9 @@ struct GNUNET_CMDS_LOCAL_FINISHED
    * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED
    */
   struct GNUNET_MessageHeader header;
-
-  enum GNUNET_GenericReturnValue result;
 };
 
+
 struct GNUNET_CMDS_LOCAL_TEST_PREPARED
 {
   /**
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c 
b/src/transport/test_transport_plugin_cmd_simple_send.c
index a59452449..ee6b9669b 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send.c
@@ -40,32 +40,6 @@
 
 #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf"
 
-struct TestState
-{
-  /**
-   * Callback to write messages to the master loop.
-   *
-   */
-  TESTING_CMD_HELPER_write_cb write_message;
-
-  /**
-   * 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;
-};
-
 static struct GNUNET_TESTING_Command block_send;
 
 static struct GNUNET_TESTING_Command block_receive;
@@ -144,14 +118,10 @@ handle_result (void *cls,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Local test exits with status %d\n",
               rv);
-  reply = GNUNET_TESTING_send_local_test_finished_msg (rv);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "message prepared\n");
-  ts->write_message (reply,
-                     ntohs (reply->size));
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "message send\n");
+  reply = GNUNET_TESTING_send_local_test_finished_msg ();
+
+  ts->finished_cb ();
   GNUNET_free (ts->testdir);
   GNUNET_free (ts->cfgname);
   GNUNET_TESTING_free_topology (ts->topology);
@@ -218,7 +188,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, 
char *router_ip,
                 char *n,
                 char *local_m,
                 char *topology_data,
-                unsigned int *read_file)
+                unsigned int *read_file,
+                TESTING_CMD_HELPER_finish_cb finished_cb)
 {
 
   unsigned int n_int;
@@ -229,6 +200,12 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, 
char *router_ip,
   struct GNUNET_TESTING_NetjailTopology *topology;
   unsigned int sscanf_ret = 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,
@@ -241,21 +218,21 @@ start_testcase (TESTING_CMD_HELPER_write_cb 
write_message, char *router_ip,
   ts->topology = topology;
 
   errno = 0;
-  sscanf (m, "%u", &m_int);
+  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 (n, "%u", &n_int);
+  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 (local_m, "%u", &local_m_int);
+  sscanf_ret = sscanf (local_m, "%u", &local_m_int);
   if (errno != 0)
   {
     GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf");
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c 
b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
index 9d6844be1..6254dba36 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
@@ -40,32 +40,6 @@
 
 #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf"
 
-struct TestState
-{
-  /**
-   * Callback to write messages to the master loop.
-   *
-   */
-  TESTING_CMD_HELPER_write_cb write_message;
-
-  /**
-   * 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;
-};
-
 static struct GNUNET_TESTING_Command block_send;
 
 static struct GNUNET_TESTING_Command block_receive;
@@ -140,19 +114,11 @@ handle_result (void *cls,
                enum GNUNET_GenericReturnValue rv)
 {
   struct TestState *ts = cls;
-  struct GNUNET_MessageHeader *reply;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Local test exits with status %d\n",
               rv);
-  reply = GNUNET_TESTING_send_local_test_finished_msg (rv);
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "message prepared\n");
-  ts->write_message (reply,
-                     ntohs (reply->size));
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "message send\n");
+  ts->finished_cb ();
   GNUNET_free (ts->testdir);
   GNUNET_free (ts->cfgname);
   GNUNET_TESTING_free_topology (ts->topology);
@@ -251,7 +217,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, 
char *router_ip,
                 char *n,
                 char *local_m,
                 char *topology_data,
-                unsigned int *read_file)
+                unsigned int *read_file,
+                TESTING_CMD_HELPER_finish_cb finished_cb)
 {
   unsigned int n_int;
   unsigned int m_int;
@@ -261,7 +228,7 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, 
char *router_ip,
   struct GNUNET_TESTING_NetjailTopology *topology;
 
 
-
+  ts->finished_cb = finished_cb;
   if (GNUNET_YES == *read_file)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_dv.c 
b/src/transport/test_transport_plugin_cmd_simple_send_dv.c
index 3ef2f64cd..ea0c9aea8 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send_dv.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send_dv.c
@@ -40,33 +40,6 @@
 
 #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf"
 
-struct TestState
-{
-  /**
-   * Callback to write messages to the master loop.
-   *
-   */
-  TESTING_CMD_HELPER_write_cb write_message;
-
-  /**
-   * 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;
-
-};
-
 /**
    * The number of messages received.
    */
@@ -193,19 +166,11 @@ handle_result (void *cls,
                enum GNUNET_GenericReturnValue rv)
 {
   struct TestState *ts = cls;
-  struct GNUNET_MessageHeader *reply;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Local test exits with status %d\n",
               rv);
-  reply = GNUNET_TESTING_send_local_test_finished_msg (rv);
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "message prepared\n");
-  ts->write_message (reply,
-                     ntohs (reply->size));
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "message send\n");
+  ts->finished_cb ();
   GNUNET_free (ts->testdir);
   GNUNET_free (ts->cfgname);
   GNUNET_TESTING_free_topology (ts->topology);
@@ -275,7 +240,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, 
char *router_ip,
                 char *n,
                 char *local_m,
                 char *topology_data,
-                unsigned int *read_file)
+                unsigned int *read_file,
+                TESTING_CMD_HELPER_finish_cb finished_cb)
 {
   unsigned int n_int;
   unsigned int m_int;
@@ -291,6 +257,7 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, 
char *router_ip,
     GNUNET_MQ_handler_end ()
   };
 
+  ts->finished_cb = finished_cb;
   if (GNUNET_YES == *read_file)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c 
b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
index 537832e61..87065e340 100644
--- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c
+++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
@@ -40,32 +40,6 @@
 
 #define TOPOLOGY_CONFIG "test_transport_udp_backchannel_topo.conf"
 
-struct TestState
-{
-  /**
-   * Callback to write messages to the master loop.
-   *
-   */
-  TESTING_CMD_HELPER_write_cb write_message;
-
-  /**
-   * 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;
-};
-
 static struct GNUNET_TESTING_Command block_send;
 
 static struct GNUNET_TESTING_Command connect_peers;
@@ -136,18 +110,12 @@ handle_result (void *cls,
                enum GNUNET_GenericReturnValue rv)
 {
   struct TestState *ts = cls;
-  struct GNUNET_MessageHeader *reply;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Local test exits with status %d\n",
               rv);
-  reply = GNUNET_TESTING_send_local_test_finished_msg (rv);
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "message prepared\n");
-  ts->write_message (reply,
-                     ntohs (reply->size));
 
+  ts->finished_cb ();
   GNUNET_free (ts->testdir);
   GNUNET_free (ts->cfgname);
   GNUNET_TESTING_free_topology (ts->topology);
@@ -209,7 +177,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, 
char *router_ip,
                 char *n,
                 char *local_m,
                 char *topology_data,
-                unsigned int *read_file)
+                unsigned int *read_file,
+                TESTING_CMD_HELPER_finish_cb finished_cb)
 {
 
   unsigned int n_int;
@@ -217,9 +186,9 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, 
char *router_ip,
   unsigned int local_m_int;
   unsigned int num;
   struct TestState *ts = GNUNET_new (struct TestState);
-
   struct GNUNET_TESTING_NetjailTopology *topology;
 
+  ts->finished_cb = finished_cb;
   if (GNUNET_YES == *read_file)
     topology = GNUNET_TESTING_get_topo_from_file (topology_data);
   else

-- 
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]