gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: - refactored barrier header, fixed messa


From: gnunet
Subject: [gnunet] branch master updated: - refactored barrier header, fixed messages for barrier signaling
Date: Tue, 13 Dec 2022 13:08:28 +0100

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 ba4d141be - refactored barrier header, fixed messages for barrier 
signaling
ba4d141be is described below

commit ba4d141be09651b452270fc21f062d50bd3f738a
Author: t3sserakt <t3ss@posteo.de>
AuthorDate: Tue Dec 13 13:08:17 2022 +0100

    - refactored barrier header, fixed messages for barrier signaling
---
 src/include/gnunet_testing_barrier.h               | 185 +--------------------
 src/include/gnunet_testing_netjail_lib.h           |  10 --
 src/include/gnunet_testing_ng_lib.h                |  32 ----
 src/include/gnunet_testing_plugin.h                |   2 +-
 src/testing/gnunet-cmds-helper.c                   |   8 +-
 src/testing/testing.h                              | 185 +++++++++++++++++++++
 src/testing/testing_api_cmd_barrier.c              |  20 +--
 src/testing/testing_api_cmd_barrier_reached.c      |   6 +-
 .../testing_api_cmd_netjail_start_testsystem.c     |  25 +--
 src/testing/testing_api_loop.c                     |  52 +++---
 src/transport/test_transport_plugin_cmd_nat_upnp.c |  22 +--
 .../test_transport_plugin_cmd_simple_send.c        |  16 +-
 ...st_transport_plugin_cmd_simple_send_broadcast.c |  16 +-
 .../test_transport_plugin_cmd_simple_send_dv.c     |  16 +-
 .../test_transport_plugin_cmd_udp_backchannel.c    |  17 +-
 15 files changed, 271 insertions(+), 341 deletions(-)

diff --git a/src/include/gnunet_testing_barrier.h 
b/src/include/gnunet_testing_barrier.h
index b02499d14..3eb61c7ec 100644
--- a/src/include/gnunet_testing_barrier.h
+++ b/src/include/gnunet_testing_barrier.h
@@ -29,14 +29,6 @@
 
 #define GNUNET_TESTING_BARRIER_MAX 32
 
-#include "gnunet_testing_plugin.h"
-
-/**
- * A testing barrier
- * FIXME better description
- */
-struct GNUNET_TESTING_Barrier;
-
 /**
  * An entry for a barrier list
  */
@@ -48,8 +40,13 @@ struct GNUNET_TESTING_BarrierListEntry
   /* DLL */
   struct GNUNET_TESTING_BarrierListEntry *prev;
 
-  /* The barrier */
-  struct GNUNET_TESTING_Barrier *barrier;
+  /* The barrier name*/
+  char *barrier_name;
+
+  /**
+   * Number of commands attached to the barrier.
+   */
+  unsigned int expected_reaches;
 };
 
 /**
@@ -65,82 +62,6 @@ struct GNUNET_TESTING_BarrierList
 };
 
 
-/**
- * Message send to a child loop to inform the child loop about a barrier being 
advanced.
- * FIXME: This is not packed and contains a char*... no payload documentation.
- */
-struct GNUNET_TESTING_CommandBarrierAdvanced
-{
-  /**
-   * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED
-   */
-  struct GNUNET_MessageHeader header;
-
-  /**
-   * The name of the barrier.
-   */
-  const char *barrier_name;
-};
-
-/**
- * Message send by a child loop to inform the master loop how much
- * GNUNET_CMDS_BARRIER_REACHED messages the child will send.
- * FIXME: Not packed and contains char*; int in NBO? bitlength undefined.
- */
-struct GNUNET_TESTING_CommandBarrierAttached
-{
-  /**
-   * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED
-   */
-  struct GNUNET_MessageHeader header;
-
-  /**
-   * The name of the barrier.
-   */
-  const char *barrier_name;
-
-  /**
-   * How often the child loop will reach the barrier.
-   */
-  unsigned int expected_reaches;
-
-  /**
-   * The number of the node the barrier is running on.
-   */
-  unsigned int node_number;
-};
-
-
-// FIXME: See above
-struct GNUNET_TESTING_CommandBarrierReached
-{
-  /**
-   * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED
-   */
-  struct GNUNET_MessageHeader header;
-
-  /**
-   * The name of the barrier.
-   */
-  const char *barrier_name;
-
-  /**
-   * The number of the node the barrier is reached.
-   */
-  unsigned int node_number;
-
-  /**
-   * The number of reach messages which most likely will send.
-   */
-  unsigned int expected_number_of_reached_messages;
-};
-
-/**
- * Create a new #GNUNET_TESTING_Barrier
- */
-struct GNUNET_TESTING_Barrier*
-GNUNET_TESTING_barrier_new (const char *testcase_name);
-
 /**
  * FIXME: documentation
  * FIXME: high-level it is baffling how we need both the GNUNET_TESTING_Barrier
@@ -153,97 +74,5 @@ GNUNET_TESTING_cmd_barrier_create (
  double percentage_to_be_reached,
  unsigned int number_to_be_reached);
 
-
-// Wait for barrier to be reached by all;
-// async version implies reached but does not
-// wait on other peers to reach it.
-/**
- * FIXME: Documentation
- * Create command.
- *
- * @param label name for command.
- * @param barrier_label The name of the barrier we wait for and which will be 
reached.
- * @param asynchronous_finish If GNUNET_YES this command will not block. Can 
be NULL.
- * @param asynchronous_finish If GNUNET_YES this command will not block. Can 
be NULL.
- * @param node_number The global numer of the node the cmd runs on.
- * @param running_on_master Is this cmd running on the master loop.
- * @param write_message Callback to write messages to the master loop.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_barrier_reached (
-  const char *label,
-  const char *barrier_label,
-  unsigned int asynchronous_finish,
-  unsigned int node_number,
-  unsigned int running_on_master,
-  GNUNET_TESTING_cmd_helper_write_cb write_message);
-
-
-/**
- * FIXME: Return type
- * FIXME: Documentation
- * Can we advance the barrier?
- *
- * @param barrier The barrier in question.
- * @return GNUNET_YES if we can advance the barrier, GNUNET_NO if not.
- */
-unsigned int
-GNUNET_TESTING_can_barrier_advance (struct GNUNET_TESTING_Barrier *barrier);
-
-
-/**
- * FIXME: Naming
- * Send Message to netjail nodes that a barrier can be advanced.
- *
- * @param is The interpreter loop.
- * @param barrier_name The name of the barrier to advance.
- * @param global_node_number The global number of the node to inform.
- */
-void
-GNUNET_TESTING_send_barrier_advance (struct GNUNET_TESTING_Interpreter *is,
-                                     const char *barrier_name,
-                                     unsigned int global_node_number);
-
-
-/**
- * Finish all "barrier reached" comands attached to this barrier.
- *
- * @param barrier The barrier in question.
- */
-void
-GNUNET_TESTING_finish_attached_cmds (struct GNUNET_TESTING_Interpreter *is,
-                                     struct GNUNET_TESTING_Barrier *barrier);
-
-
-/**
- * Send Message to master loop that cmds being attached to a barrier.
- *
- * @param is The interpreter loop.
- * @param barrier_name The name of the barrier to advance.
- * @param subnet_number The number of the subnet.
- * @param node_number The node to inform.
- * @param write_message Callback to write messages to the master loop.
- */
-void
-GNUNET_TESTING_send_barrier_attach (struct GNUNET_TESTING_Interpreter *is,
-                                     char *barrier_name,
-                                    unsigned int global_node_number,
-                                    unsigned int expected_reaches,
-                                    GNUNET_TESTING_cmd_helper_write_cb 
write_message);
-
-
-/**
- * Getting a node from a map by global node number.
- *
- * @param nodes The map.
- * @param node_number The global node number.
- * @return The node.
- */
-struct GNUNET_TESTING_NetjailNode *
-GNUNET_TESTING_barrier_get_node (struct GNUNET_CONTAINER_MultiShortmap *nodes,
-                                 unsigned int node_number);
-
-
 #endif
 /* end of testing_barrier.h */
diff --git a/src/include/gnunet_testing_netjail_lib.h 
b/src/include/gnunet_testing_netjail_lib.h
index 6f1adde41..ada8b4754 100644
--- a/src/include/gnunet_testing_netjail_lib.h
+++ b/src/include/gnunet_testing_netjail_lib.h
@@ -348,16 +348,6 @@ GNUNET_TESTING_calculate_num (struct
 // defined in _plugin??
 struct GNUNET_TESTING_TestState
 {
-  /**
-   * The head of the DLL with barriers of the test case.
-   */
-  struct GNUNET_TESTING_Barrier *barriers_head;
-
-  /**
-   * The tail of the DLL with barriers of the test case.
-   */
-  struct GNUNET_TESTING_Barrier *barriers_tail;
-
   /**
    * Callback to write messages to the master loop.
    *
diff --git a/src/include/gnunet_testing_ng_lib.h 
b/src/include/gnunet_testing_ng_lib.h
index 270fdab26..f0e2e3250 100644
--- a/src/include/gnunet_testing_ng_lib.h
+++ b/src/include/gnunet_testing_ng_lib.h
@@ -418,38 +418,6 @@ GNUNET_TESTING_main (struct GNUNET_TESTING_Command 
*commands,
                      struct GNUNET_TIME_Relative timeout);
 
 
-/**
-  * Deleting all barriers create in the context of this interpreter.
-  *
-  * @param is The interpreter.
-  */
-void
-GNUNET_TESTING_delete_barriers (struct GNUNET_TESTING_Interpreter *is);
-
-
-/**
- * Getting a barrier from the interpreter.
- *
- * @param is The interpreter.
- * @param barrier_name The name of the barrier.
- * @return The barrier.
- */
-struct GNUNET_TESTING_Barrier *
-GNUNET_TESTING_get_barrier (struct GNUNET_TESTING_Interpreter *is,
-                            const char *barrier_name);
-
-
-/**
- * Add a barrier to the loop.
- *
- * @param is The interpreter.
- * @param barrier The barrier to add.
- */
-void
-GNUNET_TESTING_interpreter_add_barrier (struct GNUNET_TESTING_Interpreter *is,
-                            struct GNUNET_TESTING_Barrier *barrier);
-
-
 /* ************** Specific interpreter commands ************ */
 
 
diff --git a/src/include/gnunet_testing_plugin.h 
b/src/include/gnunet_testing_plugin.h
index d986fabcd..5f7570680 100644
--- a/src/include/gnunet_testing_plugin.h
+++ b/src/include/gnunet_testing_plugin.h
@@ -51,7 +51,7 @@ typedef void
 // FIXME documentation
 // FIXME: Why are n, m, local_m strings?
 // FIXME: Why is topology_data a string and not a 
GNUNET_TESTING_NetworkTopology??
-typedef void
+typedef struct GNUNET_TESTING_Interpreter *
 (*GNUNET_TESTING_PLUGIN_StartTestCase) (GNUNET_TESTING_cmd_helper_write_cb
                                         write_message,
                                         const char *router_ip,
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c
index 9c16038f0..22cf5a428 100644
--- a/src/testing/gnunet-cmds-helper.c
+++ b/src/testing/gnunet-cmds-helper.c
@@ -67,6 +67,8 @@
 
 struct GNUNET_SCHEDULER_Task *finished_task;
 
+struct GNUNET_TESTING_Interpreter *is;
+
 /**
  * Struct with information about a specific node and the whole network 
namespace setup.
  *
@@ -392,7 +394,7 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader 
*message)
     }
     strcat (node_ip, plugin->m);
 
-    plugin->api->start_testcase (&write_message, router_ip, node_ip, plugin->m,
+    is = plugin->api->start_testcase (&write_message, router_ip, node_ip, 
plugin->m,
 
                                  plugin->n, plugin->local_m, ni->topology_data,
                                  ni->read_file, &finished_cb);
@@ -413,9 +415,11 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader 
*message)
   else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED == ntohs (
              message->type))
   {
+    const char *barrier_name;
     struct GNUNET_TESTING_CommandBarrierAdvanced *adm = (struct 
GNUNET_TESTING_CommandBarrierAdvanced *) message;
 
-    plugin->api->barrier_advanced (adm->barrier_name);
+    barrier_name = (const char *) &adm[1];
+    GNUNET_TESTING_finish_attached_cmds (is, barrier_name);
     return GNUNET_OK;
   }
   else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED == ntohs (
diff --git a/src/testing/testing.h b/src/testing/testing.h
index 848533251..382879706 100644
--- a/src/testing/testing.h
+++ b/src/testing/testing.h
@@ -24,7 +24,70 @@
 #ifndef TESTING_H
 #define TESTING_H
 #include "gnunet_util_lib.h"
+#include "gnunet_testing_plugin.h"
 
+GNUNET_NETWORK_STRUCT_BEGIN
+
+/**
+ * Message send to a child loop to inform the child loop about a barrier being 
advanced.
+ * FIXME: This is not packed and contains a char*... no payload documentation.
+ */
+struct GNUNET_TESTING_CommandBarrierAdvanced
+{
+  /**
+   * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED
+   */
+  struct GNUNET_MessageHeader header;
+
+  /* followed by 0-terminated barrier name */
+};
+
+/**
+ * Message send by a child loop to inform the master loop how much
+ * GNUNET_CMDS_BARRIER_REACHED messages the child will send.
+ * FIXME: Not packed and contains char*; int in NBO? bitlength undefined.
+ */
+struct GNUNET_TESTING_CommandBarrierAttached
+{
+  /**
+   * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * How often the child loop will reach the barrier.
+   */
+  uint32_t expected_reaches GNUNET_PACKED;
+
+  /**
+   * The number of the node the barrier is running on.
+   */
+  uint32_t node_number GNUNET_PACKED;
+
+  /* followed by 0-terminated barrier name */
+};
+
+struct GNUNET_TESTING_CommandBarrierReached
+{
+  /**
+   * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * The number of the node the barrier is reached.
+   */
+  uint32_t node_number GNUNET_PACKED;
+
+  /**
+   * The number of reach messages which most likely will send.
+   */
+  uint32_t expected_number_of_reached_messages GNUNET_PACKED;
+
+  /* followed by 0-terminated barrier name */
+};
+
+GNUNET_NETWORK_STRUCT_END
 
 /**
  * Handle for a plugin.
@@ -153,6 +216,7 @@ struct GNUNET_TESTING_Barrier
   unsigned int shadow;
 };
 
+
 /**
  * Advance internal pointer to next command.
  *
@@ -196,6 +260,127 @@ GNUNET_TESTING_cmd_batch_set_current_ (const struct 
GNUNET_TESTING_Command *cmd,
                                        unsigned int new_ip);
 
 
+// Wait for barrier to be reached by all;
+// async version implies reached but does not
+// wait on other peers to reach it.
+/**
+ * FIXME: Documentation
+ * Create command.
+ *
+ * @param label name for command.
+ * @param barrier_label The name of the barrier we wait for and which will be 
reached.
+ * @param asynchronous_finish If GNUNET_YES this command will not block. Can 
be NULL.
+ * @param asynchronous_finish If GNUNET_YES this command will not block. Can 
be NULL.
+ * @param node_number The global numer of the node the cmd runs on.
+ * @param running_on_master Is this cmd running on the master loop.
+ * @param write_message Callback to write messages to the master loop.
+ * @return command.
+ */
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_barrier_reached (
+  const char *label,
+  const char *barrier_label,
+  unsigned int asynchronous_finish,
+  unsigned int node_number,
+  unsigned int running_on_master,
+  GNUNET_TESTING_cmd_helper_write_cb write_message);
+
+
+/**
+ * FIXME: Return type
+ * FIXME: Documentation
+ * Can we advance the barrier?
+ *
+ * @param barrier The barrier in question.
+ * @return GNUNET_YES if we can advance the barrier, GNUNET_NO if not.
+ */
+unsigned int
+GNUNET_TESTING_can_barrier_advance (struct GNUNET_TESTING_Barrier *barrier);
+
+
+/**
+ * FIXME: Naming
+ * Send Message to netjail nodes that a barrier can be advanced.
+ *
+ * @param is The interpreter loop.
+ * @param barrier_name The name of the barrier to advance.
+ * @param global_node_number The global number of the node to inform.
+ */
+void
+GNUNET_TESTING_send_barrier_advance (struct GNUNET_TESTING_Interpreter *is,
+                                     const char *barrier_name,
+                                     unsigned int global_node_number);
+
+
+/**
+ * Finish all "barrier reached" comands attached to this barrier.
+ *
+ * @param barrier The barrier in question.
+ */
+void
+GNUNET_TESTING_finish_attached_cmds (struct GNUNET_TESTING_Interpreter *is,
+                                     const char *barrier_name);
+
+
+/**
+ * Send Message to master loop that cmds being attached to a barrier.
+ *
+ * @param is The interpreter loop.
+ * @param barrier_name The name of the barrier to advance.
+ * @param subnet_number The number of the subnet.
+ * @param node_number The node to inform.
+ * @param write_message Callback to write messages to the master loop.
+ */
+void
+GNUNET_TESTING_send_barrier_attach (struct GNUNET_TESTING_Interpreter *is,
+                                     char *barrier_name,
+                                    unsigned int global_node_number,
+                                    unsigned int expected_reaches,
+                                    GNUNET_TESTING_cmd_helper_write_cb 
write_message);
+
+
+/**
+ * Getting a node from a map by global node number.
+ *
+ * @param nodes The map.
+ * @param node_number The global node number.
+ * @return The node.
+ */
+struct GNUNET_TESTING_NetjailNode *
+GNUNET_TESTING_barrier_get_node (struct GNUNET_CONTAINER_MultiShortmap *nodes,
+                                 unsigned int node_number);
+
+
+/**
+  * Deleting all barriers create in the context of this interpreter.
+  *
+  * @param is The interpreter.
+  */
+void
+GNUNET_TESTING_delete_barriers (struct GNUNET_TESTING_Interpreter *is);
+
+
+/**
+ * Getting a barrier from the interpreter.
+ *
+ * @param is The interpreter.
+ * @param barrier_name The name of the barrier.
+ * @return The barrier.
+ */
+struct GNUNET_TESTING_Barrier *
+GNUNET_TESTING_get_barrier (struct GNUNET_TESTING_Interpreter *is,
+                            const char *barrier_name);
+
+
+/**
+ * Add a barrier to the loop.
+ *
+ * @param is The interpreter.
+ * @param barrier The barrier to add.
+ */
+void
+GNUNET_TESTING_interpreter_add_barrier (struct GNUNET_TESTING_Interpreter *is,
+                                        struct GNUNET_TESTING_Barrier 
*barrier);
 
 
 #endif
diff --git a/src/testing/testing_api_cmd_barrier.c 
b/src/testing/testing_api_cmd_barrier.c
index 64cefd235..d27ce9d94 100644
--- a/src/testing/testing_api_cmd_barrier.c
+++ b/src/testing/testing_api_cmd_barrier.c
@@ -62,12 +62,14 @@ GNUNET_TESTING_send_barrier_attach (struct 
GNUNET_TESTING_Interpreter *is,
 {
   struct GNUNET_TESTING_CommandBarrierAttached *atm = GNUNET_new (struct 
GNUNET_TESTING_CommandBarrierAttached);
   size_t msg_length = sizeof(struct GNUNET_TESTING_CommandBarrierAttached);
+  size_t name_len;
 
+  name_len = strlen (barrier_name) + 1;
   atm->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED);
   atm->header.size = htons ((uint16_t) msg_length);
-  atm->barrier_name = barrier_name;
   atm->expected_reaches = expected_reaches;
   atm->node_number = global_node_number;
+  memcpy (&atm[1], barrier_name, name_len);
   write_message ((struct GNUNET_MessageHeader *) atm, msg_length);
 
   GNUNET_free (atm);
@@ -88,10 +90,12 @@ GNUNET_TESTING_send_barrier_advance (struct 
GNUNET_TESTING_Interpreter *is,
 {
   struct GNUNET_TESTING_CommandBarrierAdvanced *adm = GNUNET_new (struct 
GNUNET_TESTING_CommandBarrierAdvanced);
   size_t msg_length = sizeof(struct GNUNET_TESTING_CommandBarrierAdvanced);
+  size_t name_len;
 
+  name_len = strlen (barrier_name) + 1;
   adm->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED);
   adm->header.size = htons ((uint16_t) msg_length);
-  adm->barrier_name = barrier_name;
+  memcpy (&adm[1], barrier_name, name_len);
   GNUNET_TESTING_send_message_to_netjail (is,
                                          global_node_number,
                                          &adm->header);
@@ -225,15 +229,3 @@ GNUNET_TESTING_cmd_barrier_create (const char *label,
                                      &barrier_traits,
                                      NULL);
 }
-
-/**
- * FIXME: Not sure if this is correct here
- */
-struct GNUNET_TESTING_Barrier*
-GNUNET_TESTING_barrier_new (const char* testcase_name)
-{
-  struct GNUNET_TESTING_Barrier *barr;
-  barr = GNUNET_new (struct GNUNET_TESTING_Barrier);
-  barr->name = GNUNET_strdup (testcase_name);
-  return barr;
-}
diff --git a/src/testing/testing_api_cmd_barrier_reached.c 
b/src/testing/testing_api_cmd_barrier_reached.c
index 58f420214..eca422b1d 100644
--- a/src/testing/testing_api_cmd_barrier_reached.c
+++ b/src/testing/testing_api_cmd_barrier_reached.c
@@ -91,6 +91,7 @@ barrier_reached_run (void *cls,
   struct CommandListEntry *cle;
   size_t msg_length;
   struct GNUNET_TESTING_CommandBarrierReached *msg;
+  size_t name_len;
 
   barrier = GNUNET_TESTING_get_barrier (is, brs->barrier_name);
   if (NULL == barrier)
@@ -106,7 +107,7 @@ barrier_reached_run (void *cls,
     //FIXME cmd uninitialized
     GNUNET_assert (NULL != cmd);
     cmd->asynchronous_finish = GNUNET_YES;
-    GNUNET_TESTING_finish_attached_cmds (is, barrier);
+    GNUNET_TESTING_finish_attached_cmds (is, barrier->name);
   }
   else if (GNUNET_NO == brs->asynchronous_finish)
   {
@@ -126,11 +127,12 @@ barrier_reached_run (void *cls,
   }
   if (GNUNET_NO == brs->running_on_master)
   {
+    name_len = strlen (barrier->name) + 1;
     msg_length = sizeof(struct GNUNET_TESTING_CommandBarrierReached);
     msg = GNUNET_new (struct GNUNET_TESTING_CommandBarrierReached);
     msg->header.size = htons ((uint16_t) msg_length);
     msg->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED);
-    msg->barrier_name = barrier->name;
+    memcpy (&msg[1], barrier->name, name_len);
     msg->node_number = brs->node_number;
     brs->write_message ((struct GNUNET_MessageHeader *) msg, msg_length);
   }
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem.c 
b/src/testing/testing_api_cmd_netjail_start_testsystem.c
index a1712c7b5..09f767b7a 100644
--- a/src/testing/testing_api_cmd_netjail_start_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_start_testsystem.c
@@ -350,9 +350,11 @@ barrier_attached (struct NetJailState *ns, const struct
   struct GNUNET_TESTING_Barrier *barrier;
   struct GNUNET_ShortHashCode key;
   struct GNUNET_HashCode hc;
+  const char *barrier_name;
 
   am = (struct GNUNET_TESTING_CommandBarrierAttached *) message;
-  barrier = GNUNET_TESTING_get_barrier (ns->is, am->barrier_name);
+  barrier_name = (const char *) &am[1];
+  barrier = GNUNET_TESTING_get_barrier (ns->is, barrier_name);
   GNUNET_assert (NULL != barrier && GNUNET_NO == barrier->shadow);
   node = GNUNET_TESTING_barrier_get_node (barrier->nodes, am->node_number);
   if (NULL == node)
@@ -376,18 +378,19 @@ void
 barrier_reached (struct NetJailState *ns, const struct
                  GNUNET_MessageHeader *message)
 {
+  struct GNUNET_TESTING_Barrier *barrier;
+  const char *barrier_name;
   struct GNUNET_TESTING_CommandBarrierReached *rm = (struct
                                                      
GNUNET_TESTING_CommandBarrierReached
                                                      *) message;
-  struct GNUNET_TESTING_Barrier *barrier = GNUNET_TESTING_get_barrier (ns->is,
-                                                                       rm->
-                                                                       
barrier_name);
 
+  barrier_name = (const char *) &rm[1];
+  barrier = GNUNET_TESTING_get_barrier (ns->is, barrier_name);
   GNUNET_assert (NULL != barrier && GNUNET_NO == barrier->shadow);
   barrier->reached++;
   if (GNUNET_TESTING_can_barrier_advance (barrier))
   {
-    GNUNET_TESTING_finish_attached_cmds (ns->is, barrier);
+    GNUNET_TESTING_finish_attached_cmds (ns->is, barrier->name);
   }
 }
 
@@ -699,19 +702,21 @@ start_helper (struct NetJailState *ns,
 
   for (pos = barriers->head; NULL != pos; pos = pos->next)
   {
-    barrier = GNUNET_TESTING_get_barrier (ns->is, pos->barrier->name);
+    barrier = GNUNET_TESTING_get_barrier (ns->is, pos->barrier_name);
     if (NULL == barrier || GNUNET_YES == barrier->shadow)
     {
-      GNUNET_TESTING_interpreter_add_barrier (ns->is, pos->barrier);
-      barrier = pos->barrier;
+      barrier = GNUNET_new (struct GNUNET_TESTING_Barrier);
+      barrier->name = pos->barrier_name;
+      GNUNET_TESTING_interpreter_add_barrier (ns->is, barrier);
+
       barrier->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
     }
     GNUNET_assert (NULL != node);
     barrier_node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
     barrier_node->node_number = node->node_number;
-    barrier_node->expected_reaches = pos->barrier->expected_reaches;
+    barrier_node->expected_reaches = pos->expected_reaches;
     barrier->expected_reaches = barrier->expected_reaches
-                                + pos->barrier->expected_reaches;
+                                + pos->expected_reaches;
     GNUNET_CRYPTO_hash (&(node->node_number), sizeof(node->node_number), &hc);
     memcpy (&key, &hc, sizeof (key));
     GNUNET_CONTAINER_multishortmap_put (barrier->nodes,
diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c
index e8680fc13..d7456b91f 100644
--- a/src/testing/testing_api_loop.c
+++ b/src/testing/testing_api_loop.c
@@ -687,6 +687,31 @@ free_barrier_node_cb (void *cls,
 }
 
 
+/**
+  * Getting a barrier from the interpreter.
+  *
+  * @param is The interpreter.
+  * @param barrier_name The name of the barrier.
+  * @return The barrier.
+  */
+struct GNUNET_TESTING_Barrier *
+GNUNET_TESTING_get_barrier (struct GNUNET_TESTING_Interpreter *is,
+                            const char *barrier_name)
+{
+  struct GNUNET_HashCode hc;
+  struct GNUNET_ShortHashCode create_key;
+  struct GNUNET_TESTING_Barrier *barrier;
+
+  GNUNET_CRYPTO_hash (barrier_name, strlen (barrier_name), &hc);
+  memcpy (&create_key,
+          &hc,
+          sizeof (create_key));
+  barrier = GNUNET_CONTAINER_multishortmap_get (is->barriers, &create_key);
+  // GNUNET_free (create_key);
+  return barrier;
+}
+
+
 /**
  * Finish all "barrier reached" comands attached to this barrier.
  *
@@ -694,10 +719,12 @@ free_barrier_node_cb (void *cls,
  */
 void
 GNUNET_TESTING_finish_attached_cmds (struct GNUNET_TESTING_Interpreter *is,
-                                     struct GNUNET_TESTING_Barrier *barrier)
+                                     const char *barrier_name)
 {
   struct CommandListEntry *pos;
   struct FreeBarrierNodeCbCls *free_barrier_node_cb_cls;
+  struct GNUNET_TESTING_Barrier *barrier = GNUNET_TESTING_get_barrier (is,
+                                                                       
barrier_name);
 
   while (NULL != (pos = barrier->cmds_head))
   {
@@ -771,29 +798,6 @@ GNUNET_TESTING_delete_barriers (struct 
GNUNET_TESTING_Interpreter *is)
   GNUNET_CONTAINER_multishortmap_destroy (is->barriers);
 }
 
-/**
-  * Getting a barrier from the interpreter.
-  *
-  * @param is The interpreter.
-  * @param barrier_name The name of the barrier.
-  * @return The barrier.
-  */
-struct GNUNET_TESTING_Barrier *
-GNUNET_TESTING_get_barrier (struct GNUNET_TESTING_Interpreter *is,
-                            const char *barrier_name)
-{
-  struct GNUNET_HashCode hc;
-  struct GNUNET_ShortHashCode create_key;
-  struct GNUNET_TESTING_Barrier *barrier;
-
-  GNUNET_CRYPTO_hash (barrier_name, strlen (barrier_name), &hc);
-  memcpy (&create_key,
-          &hc,
-          sizeof (create_key));
-  barrier = GNUNET_CONTAINER_multishortmap_get (is->barriers, &create_key);
-  // GNUNET_free (create_key);
-  return barrier;
-}
 
 /**
  * Add a barrier to the loop.
diff --git a/src/transport/test_transport_plugin_cmd_nat_upnp.c 
b/src/transport/test_transport_plugin_cmd_nat_upnp.c
index 3fef41d87..b02673d04 100644
--- a/src/transport/test_transport_plugin_cmd_nat_upnp.c
+++ b/src/transport/test_transport_plugin_cmd_nat_upnp.c
@@ -24,7 +24,7 @@
  * @author t3sserakt
  */
 #include "platform.h"
-#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_barrier.h"
 #include "gnunet_testing_netjail_lib.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_transport_application_service.h"
@@ -95,13 +95,15 @@ get_waiting_for_barriers ()
 
   barriers = GNUNET_new (struct GNUNET_TESTING_BarrierList);
   ble = GNUNET_new (struct GNUNET_TESTING_BarrierListEntry);
-  ble->barrier = GNUNET_TESTING_barrier_new ("ready-to-connect");
+  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 = GNUNET_TESTING_barrier_new ("test-case-finished");
+  ble->barrier_name = "test-case-finished";
+  ble->expected_reaches = 1;
   GNUNET_CONTAINER_DLL_insert (barriers->head,
                                barriers->tail,
                                ble);
@@ -109,15 +111,6 @@ get_waiting_for_barriers ()
 }
 
 
-static void
-barrier_advanced (const char *barrier_name)
-{
-  struct GNUNET_TESTING_Barrier *barrier = GNUNET_TESTING_get_barrier (is, 
barrier_name);
-
-  GNUNET_TESTING_finish_attached_cmds (is, barrier);
-}
-
-
 /**
  * Callback to set the flag indicating all peers started. Will be called via 
the plugin api.
  *
@@ -213,7 +206,7 @@ all_local_tests_prepared ()
  * @param n The number of the network namespace.
  * @param local_m The number of nodes in a network namespace.
  */
-static void
+static struct GNUNET_TESTING_Interpreter *
 start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message,
                 const char *router_ip,
                 const char *node_ip,
@@ -354,7 +347,7 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb 
write_message,
                       TIMEOUT,
                       &handle_result,
                       ts);
-
+  return is;
 }
 
 
@@ -377,7 +370,6 @@ libgnunet_test_transport_plugin_cmd_nat_upnp_init (void 
*cls)
   api->start_testcase = &start_testcase;
   api->all_peers_started = &all_peers_started;
   api->all_local_tests_prepared = all_local_tests_prepared;
-  api->barrier_advanced = barrier_advanced;
   api->get_waiting_for_barriers = get_waiting_for_barriers;
   return api;
 }
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c 
b/src/transport/test_transport_plugin_cmd_simple_send.c
index e94667593..83f9d62b8 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send.c
@@ -24,7 +24,7 @@
  * @author t3sserakt
  */
 #include "platform.h"
-#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_barrier.h"
 #include "gnunet_testing_netjail_lib.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_transport_application_service.h"
@@ -95,15 +95,6 @@ get_waiting_for_barriers ()
 }
 
 
-static void
-barrier_advanced (const char *barrier_name)
-{
-  struct GNUNET_TESTING_Barrier *barrier = GNUNET_TESTING_get_barrier (is, 
barrier_name);
-
-  GNUNET_TESTING_finish_attached_cmds (is, barrier);
-}
-
-
 /**
  * Callback to set the flag indicating all peers started. Will be called via 
the plugin api.
  *
@@ -199,7 +190,7 @@ all_local_tests_prepared ()
  * @param n The number of the network namespace.
  * @param local_m The number of nodes in a network namespace.
  */
-static void
+static struct GNUNET_TESTING_Interpreter *
 start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message,
                 const char *router_ip,
                 const char *node_ip,
@@ -338,7 +329,7 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb 
write_message,
                       TIMEOUT,
                       &handle_result,
                       ts);
-
+  return is;
 }
 
 
@@ -361,7 +352,6 @@ libgnunet_test_transport_plugin_cmd_simple_send_init (void 
*cls)
   api->start_testcase = &start_testcase;
   api->all_peers_started = &all_peers_started;
   api->all_local_tests_prepared = all_local_tests_prepared;
-  api->barrier_advanced = barrier_advanced;
   api->get_waiting_for_barriers = get_waiting_for_barriers;
   return api;
 }
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 4eeb25ec8..9f028e260 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
@@ -24,7 +24,7 @@
  * @author t3sserakt
  */
 #include "platform.h"
-#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_barrier.h"
 #include "gnunet_testing_netjail_lib.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_transport_application_service.h"
@@ -95,15 +95,6 @@ get_waiting_for_barriers ()
 }
 
 
-static void
-barrier_advanced (const char *barrier_name)
-{
-  struct GNUNET_TESTING_Barrier *barrier = GNUNET_TESTING_get_barrier (is, 
barrier_name);
-
-  GNUNET_TESTING_finish_attached_cmds (is, barrier);
-}
-
-
 /**
  * Callback to set the flag indicating all peers started. Will be called via 
the plugin api.
  *
@@ -232,7 +223,7 @@ all_local_tests_prepared ()
  * @param n The number of the network namespace.
  * @param local_m The number of nodes in a network namespace.
  */
-static void
+static struct GNUNET_TESTING_Interpreter *
 start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message,
                 const char *router_ip,
                 const char *node_ip,
@@ -365,7 +356,7 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb 
write_message,
                       TIMEOUT,
                       &handle_result,
                       ts);
-
+  return is;
 }
 
 
@@ -388,7 +379,6 @@ 
libgnunet_test_transport_plugin_cmd_simple_send_broadcast_init (void *cls)
   api->start_testcase = &start_testcase;
   api->all_peers_started = &all_peers_started;
   api->all_local_tests_prepared = all_local_tests_prepared;
-  api->barrier_advanced = barrier_advanced;
   api->get_waiting_for_barriers = get_waiting_for_barriers;
   return api;
 }
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 fe2c04401..3f4ae735c 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send_dv.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send_dv.c
@@ -24,7 +24,7 @@
  * @author t3sserakt
  */
 #include "platform.h"
-#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_barrier.h"
 #include "gnunet_testing_netjail_lib.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_transport_application_service.h"
@@ -147,15 +147,6 @@ get_waiting_for_barriers ()
 }
 
 
-static void
-barrier_advanced (const char *barrier_name)
-{
-  struct GNUNET_TESTING_Barrier *barrier = GNUNET_TESTING_get_barrier (is, 
barrier_name);
-
-  GNUNET_TESTING_finish_attached_cmds (is, barrier);
-}
-
-
 /**
  * Callback to set the flag indicating all peers started. Will be called via 
the plugin api.
  *
@@ -255,7 +246,7 @@ all_local_tests_prepared ()
  * @param n The number of the network namespace.
  * @param local_m The number of nodes in a network namespace.
  */
-static void
+static struct GNUNET_TESTING_Interpreter *
 start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message,
                 const char *router_ip,
                 const char *node_ip,
@@ -393,7 +384,7 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb 
write_message,
                       TIMEOUT,
                       &handle_result,
                       ts);
-
+  return is;
 }
 
 
@@ -416,7 +407,6 @@ libgnunet_test_transport_plugin_cmd_simple_send_dv_init 
(void *cls)
   api->start_testcase = &start_testcase;
   api->all_peers_started = &all_peers_started;
   api->all_local_tests_prepared = all_local_tests_prepared;
-  api->barrier_advanced = barrier_advanced;
   api->get_waiting_for_barriers = get_waiting_for_barriers;
   return api;
 }
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c 
b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
index f96a25e80..524250590 100644
--- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c
+++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
@@ -24,7 +24,7 @@
  * @author t3sserakt
  */
 #include "platform.h"
-#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_barrier.h"
 #include "gnunet_testing_netjail_lib.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_transport_application_service.h"
@@ -93,16 +93,6 @@ get_waiting_for_barriers ()
 }
 
 
-static void
-barrier_advanced (const char *barrier_name)
-{
-  struct GNUNET_TESTING_Barrier *barrier = GNUNET_TESTING_get_barrier (is,
-                                                                       
barrier_name);
-
-  GNUNET_TESTING_finish_attached_cmds (is, barrier);
-}
-
-
 /**
  * Callback to set the flag indicating all peers started. Will be called via 
the plugin api.
  *
@@ -193,7 +183,7 @@ all_local_tests_prepared ()
  * @param n The number of the network namespace.
  * @param local_m The number of nodes in a network namespace.
  */
-static void
+static struct GNUNET_TESTING_Interpreter *
 start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message,
                 const char *router_ip,
                 const char *node_ip,
@@ -331,7 +321,7 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb 
write_message,
                            TIMEOUT,
                            &handle_result,
                            ts);
-
+  return is;
 }
 
 
@@ -354,7 +344,6 @@ libgnunet_test_transport_plugin_cmd_udp_backchannel_init 
(void *cls)
   api->start_testcase = &start_testcase;
   api->all_peers_started = &all_peers_started;
   api->all_local_tests_prepared = all_local_tests_prepared;
-  api->barrier_advanced = barrier_advanced;
   api->get_waiting_for_barriers = get_waiting_for_barriers;
   return api;
 }

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