[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: TESTING: Fix TESTING-NG API to follow na
From: |
gnunet |
Subject: |
[gnunet] branch master updated: TESTING: Fix TESTING-NG API to follow naming conventions |
Date: |
Fri, 09 Dec 2022 04:09:53 +0100 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 4f46e2f2e TESTING: Fix TESTING-NG API to follow naming conventions
4f46e2f2e is described below
commit 4f46e2f2e72a07871b14c0a9aed70438616c4dd5
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Fri Dec 9 12:07:26 2022 +0900
TESTING: Fix TESTING-NG API to follow naming conventions
Rename structs and functions to follow GNUnet naming conventions.
Some structs may actually also be private, a review is necessary.
The barrier API was modified in order to untangle Barriers and
lists of Barriers.
This is a rough draft, it needs fixes wrt memory leaks.
---
src/include/gnunet_testing_barrier.h | 106 +++++--------
src/include/gnunet_testing_netjail_lib.h | 32 ++--
src/include/gnunet_testing_ng_lib.h | 15 +-
src/include/gnunet_testing_plugin.h | 15 +-
src/testing/gnunet-cmds-helper.c | 6 +-
src/testing/testing.c | 5 +-
src/testing/testing.h | 127 +++++++++++++++
src/testing/testing_api_cmd_barrier.c | 45 ++----
src/testing/testing_api_cmd_barrier_reached.c | 16 +-
.../testing_api_cmd_block_until_external_trigger.c | 14 +-
src/testing/testing_api_cmd_finish.c | 2 +
src/testing/testing_api_cmd_local_test_finished.c | 6 +-
src/testing/testing_api_cmd_local_test_prepared.c | 10 +-
src/testing/testing_api_cmd_netjail_start.c | 2 +
.../testing_api_cmd_netjail_start_testsystem.c | 175 +++++++++++----------
src/testing/testing_api_cmd_netjail_stop.c | 2 +
.../testing_api_cmd_netjail_stop_testsystem.c | 2 +
src/testing/testing_api_cmd_send_peer_ready.c | 6 +-
src/testing/testing_api_cmd_system_create.c | 1 +
src/testing/testing_api_cmd_system_destroy.c | 1 +
src/testing/testing_api_loop.c | 65 ++++----
src/testing/testing_api_traits.c | 2 +
src/testing/testing_cmds.h | 53 +------
src/transport/test_transport_plugin_cmd_nat_upnp.c | 40 ++---
.../test_transport_plugin_cmd_simple_send.c | 16 +-
...st_transport_plugin_cmd_simple_send_broadcast.c | 20 ++-
.../test_transport_plugin_cmd_simple_send_dv.c | 20 ++-
.../test_transport_plugin_cmd_udp_backchannel.c | 16 +-
28 files changed, 440 insertions(+), 380 deletions(-)
diff --git a/src/include/gnunet_testing_barrier.h
b/src/include/gnunet_testing_barrier.h
index 4a3d87ec7..ed4624e1b 100644
--- a/src/include/gnunet_testing_barrier.h
+++ b/src/include/gnunet_testing_barrier.h
@@ -27,74 +27,44 @@
#ifndef GNUNET_TESTING_BARRIER_LIB_H
#define GNUNET_TESTING_BARRIER_LIB_H
-#include "gnunet_testing_lib.h"
-#include "gnunet_testing_netjail_lib.h"
+#define GNUNET_TESTING_BARRIER_MAX 32
-struct GNUNET_TESTING_Barrier
-{
- /**
- * Pointer to the previous prefix in the DLL.
- */
- struct GNUNET_TESTING_Barrier *prev;
-
- /**
- * Pointer to the next prefix in the DLL.
- */
- struct GNUNET_TESTING_Barrier *next;
-
- /**
- * Head of the DLL with local commands the barrier is attached too.
- */
- struct GNUNET_TESTING_Command *cmds_head;
-
- /**
- * Tail of the DLL with local commands the barrier is attached too.
- */
- struct GNUNET_TESTING_Command *cmds_tail;
-
- /**
- * Hash map containing the global known nodes which are not natted.
- */
- struct GNUNET_CONTAINER_MultiShortmap *nodes;
+#include "gnunet_testing_plugin.h"
- /**
- * Name of the barrier.
- */
- const char *name;
-
- /**
- * Is this barrier running on the master.
- */
- unsigned int running_on_master;
+/**
+ * A testing barrier
+ * FIXME better description
+ */
+struct GNUNET_TESTING_Barrier;
- /**
- * Number of commands attached to this barrier.
- */
- unsigned int expected_reaches;
+/**
+ * An entry for a barrier list
+ */
+struct GNUNET_TESTING_BarrierListEntry
+{
+ /* DLL */
+ struct GNUNET_TESTING_BarrierListEntry *next;
- /**
- * Number of commands which reached this barrier.
- */
- unsigned int reached;
+ /* DLL */
+ struct GNUNET_TESTING_BarrierListEntry *prev;
- /**
- * Percentage of of commands which need to reach the barrier to change state.
- * Can not be used together with to_be_reached;
- */
- double percentage_to_be_reached;
+ /* The barrier */
+ struct GNUNET_TESTING_Barrier *barrier;
+};
- /**
- * Number of commands which need to reach the barrier to change state.
- * Can not be used together with percentage_to_be_reached;
- */
- unsigned int number_to_be_reached;
+/**
+ * A list to hold barriers provided by plugins
+ */
+struct GNUNET_TESTING_BarrierList
+{
+ /** List head **/
+ struct GNUNET_TESTING_BarrierListEntry *head;
- /*
- * No barrier locally. Shadow created. Real barrier created elsewhere.
- */
- unsigned int shadow;
+ /** List tail **/
+ struct GNUNET_TESTING_BarrierListEntry *tail;
};
+
/**
* Message send to a child loop to inform the child loop about a barrier being
advanced.
*/
@@ -112,7 +82,7 @@ struct GNUNET_TESTING_CommandBarrierAdvanced
};
/**
- * Message send by a child loop to inform the master loop how much
+ * Message send by a child loop to inform the master loop how much
* GNUNET_CMDS_BARRIER_REACHED messages the child will send.
*/
struct GNUNET_TESTING_CommandBarrierAttached
@@ -162,17 +132,11 @@ struct GNUNET_TESTING_CommandBarrierReached
unsigned int expected_number_of_reached_messages;
};
-
/**
- * Adding a node to the map of nodes of a barrier.
- *
- * @param nodes Map of nodes.
- * @param node The node to add.
+ * Create a new #GNUNET_TESTING_Barrier
*/
-void
-GNUNET_TESTING_barrier_add_node (struct GNUNET_CONTAINER_MultiShortmap *nodes,
- struct GNUNET_TESTING_NetjailNode *node);
-
+struct GNUNET_TESTING_Barrier*
+GNUNET_TESTING_barrier_new (const char *testcase_name);
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_barrier_create (
@@ -203,7 +167,7 @@ GNUNET_TESTING_cmd_barrier_reached (
unsigned int asynchronous_finish,
unsigned int node_number,
unsigned int running_on_master,
- TESTING_CMD_HELPER_write_cb write_message);
+ GNUNET_TESTING_cmd_helper_write_cb write_message);
/**
@@ -253,7 +217,7 @@ GNUNET_TESTING_send_barrier_attach (struct
GNUNET_TESTING_Interpreter *is,
char *barrier_name,
unsigned int global_node_number,
unsigned int expected_reaches,
- TESTING_CMD_HELPER_write_cb write_message);
+ GNUNET_TESTING_cmd_helper_write_cb
write_message);
/**
diff --git a/src/include/gnunet_testing_netjail_lib.h
b/src/include/gnunet_testing_netjail_lib.h
index 8d1295c98..53cae38c6 100644
--- a/src/include/gnunet_testing_netjail_lib.h
+++ b/src/include/gnunet_testing_netjail_lib.h
@@ -27,11 +27,10 @@
#ifndef GNUNET_TESTING_NETJAIL_LIB_H
#define GNUNET_TESTING_NETJAIL_LIB_H
-
-#include "gnunet_util_lib.h"
-#include "gnunet_testing_plugin.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_plugin.h"
+struct GNUNET_TESTING_AsyncContext;
/**
* Router of a netjail subnet.
@@ -342,7 +341,10 @@ unsigned int
GNUNET_TESTING_calculate_num (struct
GNUNET_TESTING_NodeConnection *node_connection,
struct GNUNET_TESTING_NetjailTopology *topology);
-struct TestState
+
+// FIXME this was not namespaced. Is this correct here? Why are the cmd_helpers
+// defined in _plugin??
+struct GNUNET_TESTING_TestState
{
/**
* The head of the DLL with barriers of the test case.
@@ -358,12 +360,12 @@ struct TestState
* Callback to write messages to the master loop.
*
*/
- TESTING_CMD_HELPER_write_cb write_message;
+ GNUNET_TESTING_cmd_helper_write_cb write_message;
/**
* Callback to notify the helper test case has finished.
*/
- TESTING_CMD_HELPER_finish_cb finished_cb;
+ GNUNET_TESTING_cmd_helper_finish_cb finished_cb;
/**
* The name for a specific test environment directory.
@@ -387,12 +389,12 @@ struct TestState
* Struct with information for callbacks.
*
*/
-struct BlockState
+struct GNUNET_TESTING_BlockState
{
/**
* Context for our asynchronous completion.
*/
- struct GNUNET_TESTING_AsyncContext ac;
+ struct GNUNET_TESTING_AsyncContext *ac;
/**
* The label of this command.
@@ -409,7 +411,7 @@ struct BlockState
* Struct to hold information for callbacks.
*
*/
-struct LocalPreparedState
+struct GNUNET_TESTING_LocalPreparedState
{
/**
* Context for our asynchronous completion.
@@ -420,7 +422,7 @@ struct LocalPreparedState
* Callback to write messages to the master loop.
*
*/
- TESTING_CMD_HELPER_write_cb write_message;
+ GNUNET_TESTING_cmd_helper_write_cb write_message;
};
/**
@@ -538,7 +540,7 @@ GNUNET_TESTING_cmd_block_until_external_trigger (
*/
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_send_peer_ready (const char *label,
- TESTING_CMD_HELPER_write_cb write_message);
+ GNUNET_TESTING_cmd_helper_write_cb
write_message);
/**
@@ -551,7 +553,7 @@ GNUNET_TESTING_cmd_send_peer_ready (const char *label,
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_local_test_finished (
const char *label,
- TESTING_CMD_HELPER_write_cb write_message);
+ GNUNET_TESTING_cmd_helper_write_cb write_message);
/**
* Create command.
@@ -562,7 +564,7 @@ GNUNET_TESTING_cmd_local_test_finished (
*/
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_local_test_prepared (const char *label,
- TESTING_CMD_HELPER_write_cb
+ GNUNET_TESTING_cmd_helper_write_cb
write_message);
@@ -576,8 +578,8 @@ GNUNET_TESTING_cmd_local_test_prepared (const char *label,
op (test_system, const struct GNUNET_TESTING_System) \
op (async_context, const struct GNUNET_TESTING_AsyncContext) \
op (helper_handles, const struct GNUNET_HELPER_Handle *) \
- op (local_prepared_state, const struct LocalPreparedState) \
- op (block_state, const struct BlockState)
+ op (local_prepared_state, const struct GNUNET_TESTING_LocalPreparedState) \
+ op (block_state, const struct GNUNET_TESTING_BlockState)
GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT)
diff --git a/src/include/gnunet_testing_ng_lib.h
b/src/include/gnunet_testing_ng_lib.h
index 0b4c05a59..d218a65db 100644
--- a/src/include/gnunet_testing_ng_lib.h
+++ b/src/include/gnunet_testing_ng_lib.h
@@ -29,7 +29,6 @@
#include "gnunet_util_lib.h"
-#include "gnunet_testing_plugin.h"
#include "gnunet_testing_lib.h"
/**
@@ -134,18 +133,6 @@ GNUNET_TESTING_command_new (void *cls,
*/
struct GNUNET_TESTING_Command
{
- // FIXME: This should not be here. Looking at the code commands are used
- // in arrays. Not lists.
- /**
- * Pointer to the previous command in the DLL.
- */
- struct GNUNET_TESTING_Command *prev;
-
- /**
- * Pointer to the next command in the DLL.
- */
- struct GNUNET_TESTING_Command *next;
-
/**
* Closure for all commands with command-specific context information.
*/
@@ -466,7 +453,7 @@ GNUNET_TESTING_get_barrier (struct
GNUNET_TESTING_Interpreter *is,
* @param barrier The barrier to add.
*/
void
-GNUNET_TESTING_barrier_add (struct GNUNET_TESTING_Interpreter *is,
+GNUNET_TESTING_interpreter_add_barrier (struct GNUNET_TESTING_Interpreter *is,
struct GNUNET_TESTING_Barrier *barrier);
diff --git a/src/include/gnunet_testing_plugin.h
b/src/include/gnunet_testing_plugin.h
index 312a7bfe5..d986fabcd 100644
--- a/src/include/gnunet_testing_plugin.h
+++ b/src/include/gnunet_testing_plugin.h
@@ -38,18 +38,21 @@ extern "C"
#endif
#endif
+struct GNUNET_TESTING_Barrier;
+
+//FIXME documentation for both functions
typedef void
-(*TESTING_CMD_HELPER_write_cb) (struct GNUNET_MessageHeader *message,
+(*GNUNET_TESTING_cmd_helper_write_cb) (struct GNUNET_MessageHeader *message,
size_t msg_length);
typedef void
-(*TESTING_CMD_HELPER_finish_cb) ();
+(*GNUNET_TESTING_cmd_helper_finish_cb) ();
// 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
-(*GNUNET_TESTING_PLUGIN_StartTestCase) (TESTING_CMD_HELPER_write_cb
+(*GNUNET_TESTING_PLUGIN_StartTestCase) (GNUNET_TESTING_cmd_helper_write_cb
write_message,
const char *router_ip,
const char *node_ip,
@@ -58,7 +61,7 @@ typedef void
const char *local_m,
const char *topology_data,
unsigned int *read_file,
- TESTING_CMD_HELPER_finish_cb
finish_cb);
+ GNUNET_TESTING_cmd_helper_finish_cb
finish_cb);
typedef void
@@ -71,8 +74,8 @@ typedef void
typedef void
(*GNUNET_TESTING_PLUGIN_BARRIER_ADVANCED) (const char *barrier_name);
-typedef struct GNUNET_TESTING_Barrier *
-(*GNUNET_TESTING_PLUGIN_GET_WAITING_FOR_BARRIERS) ();
+typedef struct GNUNET_TESTING_BarrierList*
+(*GNUNET_TESTING_PLUGIN_GET_WAITING_FOR_BARRIERS) (void);
// FIXME documentation
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c
index f87a055c3..9c16038f0 100644
--- a/src/testing/gnunet-cmds-helper.c
+++ b/src/testing/gnunet-cmds-helper.c
@@ -40,7 +40,9 @@
#include "gnunet_util_lib.h"
#include "gnunet_testing_lib.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_plugin.h"
#include "gnunet_testing_netjail_lib.h"
+#include "testing.h"
#include "testing_cmds.h"
#include "gnunet_testing_plugin.h"
#include "gnunet_testing_barrier.h"
@@ -135,7 +137,7 @@ static struct GNUNET_OS_Process *cmd_binary_process;*/
/**
* Plugin to dynamically load a test case.
*/
-struct Plugin *plugin;
+struct TestcasePlugin *plugin;
/**
* Our message stream tokenizer
@@ -355,7 +357,7 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader
*message)
binary = GNUNET_OS_get_libexec_binary_path ("gnunet-cmd");
- plugin = GNUNET_new (struct Plugin);
+ plugin = GNUNET_new (struct TestcasePlugin);
plugin->api = GNUNET_PLUGIN_load (plugin_name,
NULL);
plugin->library_name = GNUNET_strdup (basename (plugin_name));
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 56dc4e92d..b45270d57 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -33,6 +33,9 @@
#include "gnunet_util_lib.h"
#include "gnunet_arm_service.h"
#include "gnunet_testing_lib.h"
+#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_plugin.h"
+#include "gnunet_testing_barrier.h"
#include "gnunet_testing_netjail_lib.h"
#include "testing_cmds.h"
@@ -2248,7 +2251,7 @@ free_nodes_cb (void *cls,
pos_connection);
GNUNET_free (pos_connection);
}
-
+
GNUNET_free (node->plugin);
GNUNET_free (node);
return GNUNET_OK;
diff --git a/src/testing/testing.h b/src/testing/testing.h
index 8aba09e4b..848533251 100644
--- a/src/testing/testing.h
+++ b/src/testing/testing.h
@@ -26,6 +26,133 @@
#include "gnunet_util_lib.h"
+/**
+ * Handle for a plugin.
+ */
+struct TestcasePlugin
+{
+ /**
+ * Name of the shared library.
+ */
+ char *library_name;
+
+ /**
+ * Plugin API.
+ */
+ struct GNUNET_TESTING_PluginFunctions *api;
+
+ /**
+ * IP address of the specific node the helper is running for.
+ *
+ */
+ char *node_ip;
+
+ /**
+ * Name of the test case plugin.
+ *
+ */
+ char *plugin_name;
+
+ /**
+ * The number of namespaces
+ *
+ */
+ char *global_n;
+
+ /**
+ * The number of local nodes per namespace.
+ *
+ */
+ char *local_m;
+
+ /**
+ * The number of the namespace this node is in.
+ *
+ */
+ char *n;
+
+ /**
+ * The number of the node in the namespace.
+ *
+ */
+ char *m;
+};
+
+struct CommandListEntry
+{
+ struct CommandListEntry *next;
+
+ struct CommandListEntry *prev;
+
+ struct GNUNET_TESTING_Command *command;
+};
+
+
+struct GNUNET_TESTING_Barrier
+{
+ /**
+ * Pointer to the previous prefix in the DLL.
+ */
+ struct GNUNET_TESTING_Barrier *prev;
+
+ /**
+ * Pointer to the next prefix in the DLL.
+ */
+ struct GNUNET_TESTING_Barrier *next;
+
+ /**
+ * Head of the DLL with local commands the barrier is attached too.
+ */
+ struct CommandListEntry *cmds_head;
+
+ /**
+ * Tail of the DLL with local commands the barrier is attached too.
+ */
+ struct CommandListEntry *cmds_tail;
+
+ /**
+ * Hash map containing the global known nodes which are not natted.
+ */
+ struct GNUNET_CONTAINER_MultiShortmap *nodes;
+
+ /**
+ * Name of the barrier.
+ */
+ const char *name;
+
+ /**
+ * Is this barrier running on the master.
+ */
+ unsigned int running_on_master;
+
+ /**
+ * Number of commands attached to this barrier.
+ */
+ unsigned int expected_reaches;
+
+ /**
+ * Number of commands which reached this barrier.
+ */
+ unsigned int reached;
+
+ /**
+ * Percentage of of commands which need to reach the barrier to change state.
+ * Can not be used together with to_be_reached;
+ */
+ double percentage_to_be_reached;
+
+ /**
+ * Number of commands which need to reach the barrier to change state.
+ * Can not be used together with percentage_to_be_reached;
+ */
+ unsigned int number_to_be_reached;
+
+ /*
+ * No barrier locally. Shadow created. Real barrier created elsewhere.
+ */
+ unsigned int shadow;
+};
+
/**
* Advance internal pointer to next command.
*
diff --git a/src/testing/testing_api_cmd_barrier.c
b/src/testing/testing_api_cmd_barrier.c
index be5dc6d2d..64cefd235 100644
--- a/src/testing/testing_api_cmd_barrier.c
+++ b/src/testing/testing_api_cmd_barrier.c
@@ -24,7 +24,10 @@
* @author t3sserakt
*/
#include "platform.h"
+#include "testing.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_plugin.h"
+#include "gnunet_testing_netjail_lib.h"
#include "gnunet_testing_barrier.h"
struct BarrierState
@@ -55,7 +58,7 @@ GNUNET_TESTING_send_barrier_attach (struct
GNUNET_TESTING_Interpreter *is,
char *barrier_name,
unsigned int global_node_number,
unsigned int expected_reaches,
- TESTING_CMD_HELPER_write_cb write_message)
+ GNUNET_TESTING_cmd_helper_write_cb
write_message)
{
struct GNUNET_TESTING_CommandBarrierAttached *atm = GNUNET_new (struct
GNUNET_TESTING_CommandBarrierAttached);
size_t msg_length = sizeof(struct GNUNET_TESTING_CommandBarrierAttached);
@@ -138,8 +141,6 @@ barrier_traits (void *cls,
const char *trait,
unsigned int index)
{
- struct BarrierState *bs = cls;
-
struct GNUNET_TESTING_Trait traits[] = {
GNUNET_TESTING_trait_end ()
};
@@ -178,31 +179,9 @@ barrier_run (void *cls,
{
struct BarrierState *brs = cls;
- GNUNET_TESTING_barrier_add (is, brs->barrier);
+ GNUNET_TESTING_interpreter_add_barrier (is, brs->barrier);
}
-/**
- * Adding a node to the map of nodes of a barrier.
- *
- * @param nodes Map of nodes.
- * @param node The node to add.
- */
-void
-GNUNET_TESTING_barrier_add_node (struct GNUNET_CONTAINER_MultiShortmap *nodes,
- struct GNUNET_TESTING_NetjailNode *node)
-{
- struct GNUNET_HashCode hc;
- struct GNUNET_ShortHashCode key;
-
- GNUNET_CRYPTO_hash (&(node->node_number), sizeof(node->node_number), &hc);
- memcpy (&key, &hc, sizeof (key));
- GNUNET_CONTAINER_multishortmap_put (nodes,
- &key,
- node,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
-}
-
-
/**
* Getting a node from a map by global node number.
*
@@ -239,8 +218,6 @@ GNUNET_TESTING_cmd_barrier_create (const char *label,
barrier->name = label;
GNUNET_assert ((0 < percentage_to_be_reached && 0 == number_to_be_reached) ||
(0 == percentage_to_be_reached && 0 < number_to_be_reached));
- barrier->percentage_to_be_reached;
- barrier->number_to_be_reached;
bs->barrier = barrier;
return GNUNET_TESTING_command_new (bs, label,
&barrier_run,
@@ -248,3 +225,15 @@ 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 1a3b25d32..58f420214 100644
--- a/src/testing/testing_api_cmd_barrier_reached.c
+++ b/src/testing/testing_api_cmd_barrier_reached.c
@@ -24,8 +24,12 @@
* @author t3sserakt
*/
#include "platform.h"
+#include "gnunet_testing_lib.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_plugin.h"
#include "gnunet_testing_barrier.h"
+#include "gnunet_testing_netjail_lib.h"
+#include "testing.h"
/**
* Struct with information for callbacks.
@@ -37,7 +41,7 @@ struct BarrierReachedState
* Callback to write messages to the master loop.
*
*/
- TESTING_CMD_HELPER_write_cb write_message;
+ GNUNET_TESTING_cmd_helper_write_cb write_message;
/**
* Context for our asynchronous completion.
@@ -84,6 +88,7 @@ barrier_reached_run (void *cls,
struct BarrierReachedState *brs = cls;
struct GNUNET_TESTING_Barrier *barrier;
struct GNUNET_TESTING_Command *cmd = NULL;
+ struct CommandListEntry *cle;
size_t msg_length;
struct GNUNET_TESTING_CommandBarrierReached *msg;
@@ -93,7 +98,7 @@ barrier_reached_run (void *cls,
barrier = GNUNET_new (struct GNUNET_TESTING_Barrier);
barrier->shadow = GNUNET_YES;
barrier->name = brs->label;
- GNUNET_TESTING_barrier_add (is, barrier);
+ GNUNET_TESTING_interpreter_add_barrier (is, barrier);
}
barrier->reached++;
if (GNUNET_TESTING_can_barrier_advance (barrier))
@@ -109,10 +114,11 @@ barrier_reached_run (void *cls,
* It is unclear how this does not end up with a DLL issue.
* We should create a dedicated struct to hold this list.
*/
- cmd = GNUNET_TESTING_interpreter_get_current_command (is);
+ cle = GNUNET_new (struct CommandListEntry);
+ cle->command = GNUNET_TESTING_interpreter_get_current_command (is);
GNUNET_CONTAINER_DLL_insert (barrier->cmds_head,
barrier->cmds_tail,
- cmd);
+ cle);
}
else
{
@@ -194,7 +200,7 @@ GNUNET_TESTING_cmd_barrier_reached (
unsigned int asynchronous_finish,
unsigned int node_number,
unsigned int running_on_master,
- TESTING_CMD_HELPER_write_cb write_message)
+ GNUNET_TESTING_cmd_helper_write_cb write_message)
{
struct BarrierReachedState *brs;
diff --git a/src/testing/testing_api_cmd_block_until_external_trigger.c
b/src/testing/testing_api_cmd_block_until_external_trigger.c
index 1e2c3be7c..be30ec86b 100644
--- a/src/testing/testing_api_cmd_block_until_external_trigger.c
+++ b/src/testing/testing_api_cmd_block_until_external_trigger.c
@@ -26,6 +26,8 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_plugin.h"
+#include "gnunet_testing_barrier.h"
#include "gnunet_testing_netjail_lib.h"
/**
@@ -52,8 +54,8 @@ block_until_external_trigger_traits (void *cls,
const char *trait,
unsigned int index)
{
- struct BlockState *bs = cls;
- struct GNUNET_TESTING_AsyncContext *ac = &bs->ac;
+ struct GNUNET_TESTING_BlockState *bs = cls;
+ struct GNUNET_TESTING_AsyncContext *ac = bs->ac;
struct GNUNET_TESTING_Trait traits[] = {
GNUNET_TESTING_make_trait_async_context ((const void *) ac),
GNUNET_TESTING_make_trait_block_state ((const void *) bs),
@@ -75,7 +77,7 @@ static void
block_until_all_peers_started_run (void *cls,
struct GNUNET_TESTING_Interpreter *is)
{
- struct BlockState *bs = cls;
+ struct GNUNET_TESTING_BlockState *bs = cls;
struct GNUNET_TESTING_Command *cmd =
GNUNET_TESTING_interpreter_get_current_command (is);
@@ -103,14 +105,14 @@ struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_block_until_external_trigger (
const char *label)
{
- struct BlockState *bs;
+ struct GNUNET_TESTING_BlockState *bs;
- bs = GNUNET_new (struct BlockState);
+ bs = GNUNET_new (struct GNUNET_TESTING_BlockState);
bs->label = label;
bs->asynchronous_finish = GNUNET_NO;
return GNUNET_TESTING_command_new (bs, label,
&block_until_all_peers_started_run,
&block_until_all_peers_started_cleanup,
&block_until_external_trigger_traits,
- &bs->ac);
+ bs->ac);
}
diff --git a/src/testing/testing_api_cmd_finish.c
b/src/testing/testing_api_cmd_finish.c
index b352e28dc..e1fc69a09 100644
--- a/src/testing/testing_api_cmd_finish.c
+++ b/src/testing/testing_api_cmd_finish.c
@@ -25,6 +25,8 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_plugin.h"
+#include "gnunet_testing_barrier.h"
#include "gnunet_testing_netjail_lib.h"
diff --git a/src/testing/testing_api_cmd_local_test_finished.c
b/src/testing/testing_api_cmd_local_test_finished.c
index fb6fef030..f54b67acf 100644
--- a/src/testing/testing_api_cmd_local_test_finished.c
+++ b/src/testing/testing_api_cmd_local_test_finished.c
@@ -26,6 +26,8 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_plugin.h"
+#include "gnunet_testing_barrier.h"
#include "gnunet_testing_netjail_lib.h"
#include "testing_cmds.h"
@@ -46,7 +48,7 @@ struct LocalFinishedState
* Callback to write messages to the master loop.
*
*/
- TESTING_CMD_HELPER_write_cb write_message;
+ GNUNET_TESTING_cmd_helper_write_cb write_message;
/**
* The message send back to the master loop.
@@ -101,7 +103,7 @@ local_test_finished_run (void *cls,
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_local_test_finished (
const char *label,
- TESTING_CMD_HELPER_write_cb write_message)
+ GNUNET_TESTING_cmd_helper_write_cb write_message)
{
struct LocalFinishedState *lfs;
diff --git a/src/testing/testing_api_cmd_local_test_prepared.c
b/src/testing/testing_api_cmd_local_test_prepared.c
index 3f976f554..2b1525077 100644
--- a/src/testing/testing_api_cmd_local_test_prepared.c
+++ b/src/testing/testing_api_cmd_local_test_prepared.c
@@ -26,6 +26,8 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_plugin.h"
+#include "gnunet_testing_barrier.h"
#include "gnunet_testing_netjail_lib.h"
#include "testing_cmds.h"
@@ -78,7 +80,7 @@ static void
local_test_prepared_run (void *cls,
struct GNUNET_TESTING_Interpreter *is)
{
- struct LocalPreparedState *lfs = cls;
+ struct GNUNET_TESTING_LocalPreparedState *lfs = cls;
struct GNUNET_TESTING_CommandLocalTestPrepared *reply;
size_t msg_length;
@@ -94,12 +96,12 @@ local_test_prepared_run (void *cls,
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_local_test_prepared (const char *label,
- TESTING_CMD_HELPER_write_cb
+ GNUNET_TESTING_cmd_helper_write_cb
write_message)
{
- struct LocalPreparedState *lfs;
+ struct GNUNET_TESTING_LocalPreparedState *lfs;
- lfs = GNUNET_new (struct LocalPreparedState);
+ lfs = GNUNET_new (struct GNUNET_TESTING_LocalPreparedState);
lfs->write_message = write_message;
return GNUNET_TESTING_command_new (lfs, label,
diff --git a/src/testing/testing_api_cmd_netjail_start.c
b/src/testing/testing_api_cmd_netjail_start.c
index 9c1949c88..f45ab939b 100644
--- a/src/testing/testing_api_cmd_netjail_start.c
+++ b/src/testing/testing_api_cmd_netjail_start.c
@@ -26,6 +26,8 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_plugin.h"
+#include "gnunet_testing_barrier.h"
#include "gnunet_testing_netjail_lib.h"
#define NETJAIL_START_SCRIPT "netjail_start.sh"
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem.c
b/src/testing/testing_api_cmd_netjail_start_testsystem.c
index 6663e9b82..a1712c7b5 100644
--- a/src/testing/testing_api_cmd_netjail_start_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_start_testsystem.c
@@ -25,9 +25,11 @@
*/
#include "platform.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_plugin.h"
+#include "gnunet_testing_barrier.h"
#include "gnunet_testing_netjail_lib.h"
+#include "testing.h"
#include "testing_cmds.h"
-#include "gnunet_testing_barrier.h"
#define NETJAIL_EXEC_SCRIPT "netjail_exec.sh"
@@ -176,7 +178,7 @@ struct TestingSystemCount
/**
* The plugin correlated to this netjail node.
*/
- struct Plugin *plugin;
+ struct TestcasePlugin *plugin;
/**
* Kept in a DLL.
@@ -259,7 +261,7 @@ clear_msg (void *cls, int result)
struct TestingSystemCount *tbc = cls;
GNUNET_assert (NULL != tbc->shandle);
- //GNUNET_free (tbc->shandle);
+ // GNUNET_free (tbc->shandle);
GNUNET_free (tbc->plugin);
tbc->shandle = NULL;
GNUNET_free (tbc);
@@ -303,23 +305,6 @@ send_message_to_locals (
}
-static void
-send_barrier_advanced (struct GNUNET_TESTING_CommandBarrierReached *rm,
- unsigned int i,
- unsigned int j,
- struct NetJailState *ns)
-{
- struct GNUNET_TESTING_CommandBarrierAdvanced *adm = GNUNET_new (struct
GNUNET_TESTING_CommandBarrierAdvanced);
- size_t msg_length = sizeof(struct
GNUNET_TESTING_CommandAllLocalTestsPrepared);
-
- adm->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED);
- adm->header.size = htons ((uint16_t) msg_length);
- adm->barrier_name = rm->barrier_name;
- send_message_to_locals (i, j, ns, &adm->header);
- GNUNET_free (adm);
-}
-
-
static void
send_all_local_tests_prepared (unsigned int i, unsigned int j, struct
NetJailState *ns)
@@ -357,11 +342,14 @@ send_all_peers_started (unsigned int i, unsigned int j,
struct NetJailState *ns)
void
-barrier_attached (struct NetJailState *ns, const struct GNUNET_MessageHeader
*message)
+barrier_attached (struct NetJailState *ns, const struct
+ GNUNET_MessageHeader *message)
{
struct GNUNET_TESTING_CommandBarrierAttached *am;
struct GNUNET_TESTING_NetjailNode *node;
struct GNUNET_TESTING_Barrier *barrier;
+ struct GNUNET_ShortHashCode key;
+ struct GNUNET_HashCode hc;
am = (struct GNUNET_TESTING_CommandBarrierAttached *) message;
barrier = GNUNET_TESTING_get_barrier (ns->is, am->barrier_name);
@@ -371,7 +359,13 @@ barrier_attached (struct NetJailState *ns, const struct
GNUNET_MessageHeader *me
{
node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
node->node_number = am->node_number;
- GNUNET_TESTING_barrier_add_node (barrier->nodes, node);
+
+ GNUNET_CRYPTO_hash (&(node->node_number), sizeof(node->node_number), &hc);
+ memcpy (&key, &hc, sizeof (key));
+ GNUNET_CONTAINER_multishortmap_put (barrier->nodes,
+ &key,
+ node,
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
}
node->expected_reaches = node->expected_reaches + am->expected_reaches;
barrier->expected_reaches = barrier->expected_reaches + am->expected_reaches;
@@ -379,10 +373,15 @@ barrier_attached (struct NetJailState *ns, const struct
GNUNET_MessageHeader *me
void
-barrier_reached (struct NetJailState *ns, const struct GNUNET_MessageHeader
*message)
+barrier_reached (struct NetJailState *ns, const struct
+ GNUNET_MessageHeader *message)
{
- struct GNUNET_TESTING_CommandBarrierReached *rm = (struct
GNUNET_TESTING_CommandBarrierReached *) message;
- struct GNUNET_TESTING_Barrier *barrier = GNUNET_TESTING_get_barrier (ns->is,
rm->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);
GNUNET_assert (NULL != barrier && GNUNET_NO == barrier->shadow);
barrier->reached++;
@@ -414,62 +413,62 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader
*message)
switch (message_type)
{
- case GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED:
- barrier_attached (ns, message);
- break;
- case GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED:
- barrier_reached (ns, message);
- break;
- case GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY:
- ns->number_of_testsystems_started++;
- break;
- case GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED:
- ns->number_of_peers_started++;
- if (ns->number_of_peers_started == total_number)
+ case GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED:
+ barrier_attached (ns, message);
+ break;
+ case GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED:
+ barrier_reached (ns, message);
+ break;
+ case GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY:
+ ns->number_of_testsystems_started++;
+ break;
+ case GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED:
+ ns->number_of_peers_started++;
+ if (ns->number_of_peers_started == total_number)
+ {
+ for (int i = 1; i <= ns->known; i++)
{
- 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;
+ send_all_peers_started (0,i, ns);
}
- break;
- case GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED:
- ns->number_of_local_tests_prepared++;
- if (ns->number_of_local_tests_prepared == total_number)
+ for (int i = 1; i <= ns->global_n; i++)
{
- for (int i = 1; i <= ns->known; i++)
+ for (int j = 1; j <= ns->local_m; j++)
{
- send_all_local_tests_prepared (0,i, ns);
+ send_all_peers_started (i,j, ns);
}
+ }
+ ns->number_of_peers_started = 0;
+ }
+ break;
+ case GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED:
+ 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 i = 1; i <= ns->global_n; i++)
+ {
+ for (int j = 1; j <= ns->local_m; j++)
{
- for (int j = 1; j <= ns->local_m; j++)
- {
- send_all_local_tests_prepared (i,j, ns);
- }
+ send_all_local_tests_prepared (i,j, ns);
}
}
- break;
- case GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED:
- ns->number_of_local_tests_finished++;
- if (ns->number_of_local_tests_finished == total_number)
- {
- GNUNET_SCHEDULER_cancel (ns->timeout_task);
- GNUNET_TESTING_async_finish (&ns->ac);
- }
- break;
- default:
- // We received a message we can not handle.
- GNUNET_assert (0);
+ }
+ break;
+ case GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED:
+ ns->number_of_local_tests_finished++;
+ if (ns->number_of_local_tests_finished == total_number)
+ {
+ GNUNET_SCHEDULER_cancel (ns->timeout_task);
+ GNUNET_TESTING_async_finish (&ns->ac);
+ }
+ break;
+ default:
+ // We received a message we can not handle.
+ GNUNET_assert (0);
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -541,7 +540,7 @@ start_helper (struct NetJailState *ns,
unsigned int m,
unsigned int n)
{
- struct Plugin *plugin;
+ struct TestcasePlugin *plugin;
struct GNUNET_HELPER_Handle *helper;
struct GNUNET_TESTING_CommandHelperInit *msg;
struct TestingSystemCount *tbc;
@@ -556,6 +555,7 @@ start_helper (struct NetJailState *ns,
pid_t pid;
unsigned int script_num;
struct GNUNET_ShortHashCode *hkey;
+ struct GNUNET_ShortHashCode key;
struct GNUNET_HashCode hc;
struct GNUNET_TESTING_NetjailTopology *topology = ns->topology;
struct GNUNET_TESTING_NetjailNode *node;
@@ -563,9 +563,9 @@ start_helper (struct NetJailState *ns,
struct GNUNET_TESTING_NetjailNamespace *namespace;
char *data_dir;
char *script_name;
- struct GNUNET_TESTING_Barrier *barriers;
- struct GNUNET_TESTING_Barrier *pos;
+ struct GNUNET_TESTING_BarrierListEntry *pos;
struct GNUNET_TESTING_Barrier *barrier;
+ struct GNUNET_TESTING_BarrierList *barriers;
if (0 == n)
script_num = m - 1;
@@ -691,28 +691,35 @@ start_helper (struct NetJailState *ns,
}
- plugin = GNUNET_new (struct Plugin);
+ plugin = GNUNET_new (struct TestcasePlugin);
plugin->api = GNUNET_PLUGIN_load (plugin_name,
- NULL);
+ NULL);
barriers = plugin->api->get_waiting_for_barriers ();
- for (pos = barriers; NULL != pos; pos = pos->next)
+ for (pos = barriers->head; NULL != pos; pos = pos->next)
{
- barrier = GNUNET_TESTING_get_barrier (ns->is, pos->name);
+ barrier = GNUNET_TESTING_get_barrier (ns->is, pos->barrier->name);
if (NULL == barrier || GNUNET_YES == barrier->shadow)
{
- GNUNET_TESTING_barrier_add (ns->is, pos);
- barrier = pos;
+ GNUNET_TESTING_interpreter_add_barrier (ns->is, pos->barrier);
+ barrier = pos->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->expected_reaches;
- barrier->expected_reaches = barrier->expected_reaches +
pos->expected_reaches;
- GNUNET_TESTING_barrier_add_node (barrier->nodes, node);
+ barrier_node->expected_reaches = pos->barrier->expected_reaches;
+ barrier->expected_reaches = barrier->expected_reaches
+ + pos->barrier->expected_reaches;
+ GNUNET_CRYPTO_hash (&(node->node_number), sizeof(node->node_number), &hc);
+ memcpy (&key, &hc, sizeof (key));
+ GNUNET_CONTAINER_multishortmap_put (barrier->nodes,
+ &key,
+ node,
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
}
+ // FIXME Free barriers??
tbc->plugin = plugin;
msg = create_helper_init_msg_ (plugin_name);
diff --git a/src/testing/testing_api_cmd_netjail_stop.c
b/src/testing/testing_api_cmd_netjail_stop.c
index 49151a168..c13d177fb 100644
--- a/src/testing/testing_api_cmd_netjail_stop.c
+++ b/src/testing/testing_api_cmd_netjail_stop.c
@@ -26,6 +26,8 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_plugin.h"
+#include "gnunet_testing_barrier.h"
#include "gnunet_testing_netjail_lib.h"
diff --git a/src/testing/testing_api_cmd_netjail_stop_testsystem.c
b/src/testing/testing_api_cmd_netjail_stop_testsystem.c
index 38b14ac5c..8f63216ef 100644
--- a/src/testing/testing_api_cmd_netjail_stop_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_stop_testsystem.c
@@ -25,6 +25,8 @@
*/
#include "platform.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_plugin.h"
+#include "gnunet_testing_barrier.h"
#include "gnunet_testing_netjail_lib.h"
#include "testing_cmds.h"
diff --git a/src/testing/testing_api_cmd_send_peer_ready.c
b/src/testing/testing_api_cmd_send_peer_ready.c
index d76a95ae8..dcd69e595 100644
--- a/src/testing/testing_api_cmd_send_peer_ready.c
+++ b/src/testing/testing_api_cmd_send_peer_ready.c
@@ -26,6 +26,8 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_plugin.h"
+#include "gnunet_testing_barrier.h"
#include "gnunet_testing_netjail_lib.h"
#include "testing_cmds.h"
@@ -40,7 +42,7 @@ struct SendPeerReadyState
* Callback to write messages to the master loop.
*
*/
- TESTING_CMD_HELPER_write_cb write_message;
+ GNUNET_TESTING_cmd_helper_write_cb write_message;
/**
* The message send back to the master loop.
@@ -107,7 +109,7 @@ send_peer_ready_run (void *cls,
*/
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_send_peer_ready (const char *label,
- TESTING_CMD_HELPER_write_cb write_message)
+ GNUNET_TESTING_cmd_helper_write_cb
write_message)
{
struct SendPeerReadyState *sprs;
diff --git a/src/testing/testing_api_cmd_system_create.c
b/src/testing/testing_api_cmd_system_create.c
index 66b0f57b9..46fbd706e 100644
--- a/src/testing/testing_api_cmd_system_create.c
+++ b/src/testing/testing_api_cmd_system_create.c
@@ -26,6 +26,7 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_plugin.h"
#include "gnunet_testing_netjail_lib.h"
#include "gnunet_testing_lib.h"
diff --git a/src/testing/testing_api_cmd_system_destroy.c
b/src/testing/testing_api_cmd_system_destroy.c
index 23d8b9162..45adfd0da 100644
--- a/src/testing/testing_api_cmd_system_destroy.c
+++ b/src/testing/testing_api_cmd_system_destroy.c
@@ -26,6 +26,7 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_plugin.h"
#include "gnunet_testing_netjail_lib.h"
#include "gnunet_testing_lib.h"
diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c
index da95500f7..f133956cf 100644
--- a/src/testing/testing_api_loop.c
+++ b/src/testing/testing_api_loop.c
@@ -28,7 +28,9 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_plugin.h"
#include "gnunet_testing_barrier.h"
+#include "gnunet_testing_netjail_lib.h"
#include "testing.h"
/**
@@ -71,7 +73,7 @@ struct GNUNET_TESTING_Interpreter
/**
* Map with barriers for this loop.
*/
- struct GNUNET_CONTAINER_MultiShortmap *barriers;
+ struct GNUNET_CONTAINER_MultiShortmap *barriers;
/**
* Number of GNUNET_TESTING_Command in commands.
@@ -528,17 +530,17 @@ GNUNET_TESTING_command_new (void *cls,
GNUNET_TESTING_CommandGetTraits traits,
struct GNUNET_TESTING_AsyncContext *ac)
{
- struct GNUNET_TESTING_Command cmd = {
- .cls = cls,
- .run = run,
- .ac = ac,
- .cleanup = cleanup,
- .traits = traits
- };
- memset (&cmd, 0, sizeof (cmd));
- strncpy (cmd.label, label, GNUNET_TESTING_CMD_MAX_LABEL_LENGTH);
+ struct GNUNET_TESTING_Command cmd = {
+ .cls = cls,
+ .run = run,
+ .ac = ac,
+ .cleanup = cleanup,
+ .traits = traits
+ };
+ memset (&cmd, 0, sizeof (cmd));
+ strncpy (cmd.label, label, GNUNET_TESTING_CMD_MAX_LABEL_LENGTH);
- return cmd;
+ return cmd;
}
@@ -649,8 +651,8 @@ GNUNET_TESTING_send_message_to_netjail (struct
GNUNET_TESTING_Interpreter *is,
const struct GNUNET_HELPER_Handle *helper;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "send message of type %u to locals\n",
- header->type);
+ "send message of type %u to locals\n",
+ header->type);
helper = is->helper[global_node_number - 1];
struct GNUNET_HELPER_SendHandle *sh = GNUNET_HELPER_send (
(struct GNUNET_HELPER_Handle *) helper,
@@ -691,18 +693,19 @@ void
GNUNET_TESTING_finish_attached_cmds (struct GNUNET_TESTING_Interpreter *is,
struct GNUNET_TESTING_Barrier *barrier)
{
- struct GNUNET_TESTING_Command *pos;
+ struct CommandListEntry *pos;
struct FreeBarrierNodeCbCls *free_barrier_node_cb_cls;
while (NULL != (pos = barrier->cmds_head))
{
- if (GNUNET_NO == pos->ac->finished && GNUNET_NO ==
pos->asynchronous_finish)
+ if (GNUNET_NO == pos->command->ac->finished &&
+ GNUNET_NO == pos->command->asynchronous_finish)
{
- GNUNET_TESTING_async_finish (pos->ac);
+ GNUNET_TESTING_async_finish (pos->command->ac);
}
- else if (GNUNET_NO == pos->ac->finished)
+ else if (GNUNET_NO == pos->command->ac->finished)
{
- pos->asynchronous_finish = GNUNET_YES;
+ pos->command->asynchronous_finish = GNUNET_YES;
}
GNUNET_CONTAINER_DLL_remove (barrier->cmds_head,
barrier->cmds_tail,
@@ -715,7 +718,8 @@ GNUNET_TESTING_finish_attached_cmds (struct
GNUNET_TESTING_Interpreter *is,
free_barrier_node_cb_cls = GNUNET_new (struct FreeBarrierNodeCbCls);
free_barrier_node_cb_cls->barrier = barrier;
free_barrier_node_cb_cls->is = is;
- GNUNET_CONTAINER_multishortmap_iterate (barrier->nodes,
free_barrier_node_cb, free_barrier_node_cb_cls);
+ GNUNET_CONTAINER_multishortmap_iterate (barrier->nodes, free_barrier_node_cb,
+ free_barrier_node_cb_cls);
GNUNET_CONTAINER_multishortmap_destroy (barrier->nodes);
GNUNET_free (free_barrier_node_cb_cls);
}
@@ -723,18 +727,19 @@ GNUNET_TESTING_finish_attached_cmds (struct
GNUNET_TESTING_Interpreter *is,
int
free_barriers_cb (void *cls,
- const struct GNUNET_ShortHashCode *key,
- void *value)
+ const struct GNUNET_ShortHashCode *key,
+ void *value)
{
struct GNUNET_TESTING_Interpreter *is = cls;
struct GNUNET_TESTING_Barrier *barrier = value;
- struct GNUNET_TESTING_Command *pos;
+ struct CommandListEntry *pos;
struct FreeBarrierNodeCbCls *free_barrier_node_cb_cls;
free_barrier_node_cb_cls = GNUNET_new (struct FreeBarrierNodeCbCls);
free_barrier_node_cb_cls->barrier = barrier;
free_barrier_node_cb_cls->is = is;
- GNUNET_CONTAINER_multishortmap_iterate (barrier->nodes,
free_barrier_node_cb, free_barrier_node_cb_cls);
+ GNUNET_CONTAINER_multishortmap_iterate (barrier->nodes, free_barrier_node_cb,
+ free_barrier_node_cb_cls);
GNUNET_CONTAINER_multishortmap_destroy (barrier->nodes);
while (NULL != (pos = barrier->cmds_head))
@@ -778,12 +783,12 @@ GNUNET_TESTING_get_barrier (struct
GNUNET_TESTING_Interpreter *is,
struct GNUNET_ShortHashCode create_key;
struct GNUNET_TESTING_Barrier *barrier;
- GNUNET_CRYPTO_hash (barrier_name, strlen(barrier_name), &hc);
+ 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);
+ // GNUNET_free (create_key);
return barrier;
}
@@ -794,16 +799,16 @@ GNUNET_TESTING_get_barrier (struct
GNUNET_TESTING_Interpreter *is,
* @param barrier The barrier to add.
*/
void
-GNUNET_TESTING_barrier_add (struct GNUNET_TESTING_Interpreter *is,
- struct GNUNET_TESTING_Barrier *barrier)
+GNUNET_TESTING_interpreter_add_barrier (struct GNUNET_TESTING_Interpreter *is,
+ struct GNUNET_TESTING_Barrier *barrier)
{
struct GNUNET_HashCode hc;
struct GNUNET_ShortHashCode create_key;
- GNUNET_CRYPTO_hash (barrier->name, strlen(barrier->name), &hc);
+ GNUNET_CRYPTO_hash (barrier->name, strlen (barrier->name), &hc);
memcpy (&create_key,
- &hc,
- sizeof (create_key));
+ &hc,
+ sizeof (create_key));
GNUNET_CONTAINER_multishortmap_put (is->barriers,
&create_key,
barrier,
diff --git a/src/testing/testing_api_traits.c b/src/testing/testing_api_traits.c
index 9b54443a1..ee3edbed0 100644
--- a/src/testing/testing_api_traits.c
+++ b/src/testing/testing_api_traits.c
@@ -27,6 +27,8 @@
*/
#include "platform.h"
#include "gnunet_testing_ng_lib.h"
+#include "gnunet_testing_plugin.h"
+#include "gnunet_testing_barrier.h"
#include "gnunet_testing_netjail_lib.h"
diff --git a/src/testing/testing_cmds.h b/src/testing/testing_cmds.h
index edc4dfe19..a5ea59a3a 100644
--- a/src/testing/testing_cmds.h
+++ b/src/testing/testing_cmds.h
@@ -28,61 +28,10 @@
#define TESTING_CMDS_H
#define HELPER_CMDS_BINARY "gnunet-cmds-helper"
+#include "gnunet_common.h"
GNUNET_NETWORK_STRUCT_BEGIN
-/**
- * Handle for a plugin.
- */
-struct Plugin
-{
- /**
- * Name of the shared library.
- */
- char *library_name;
-
- /**
- * Plugin API.
- */
- struct GNUNET_TESTING_PluginFunctions *api;
-
- /**
- * IP address of the specific node the helper is running for.
- *
- */
- char *node_ip;
-
- /**
- * Name of the test case plugin.
- *
- */
- char *plugin_name;
-
- /**
- * The number of namespaces
- *
- */
- char *global_n;
-
- /**
- * The number of local nodes per namespace.
- *
- */
- char *local_m;
-
- /**
- * The number of the namespace this node is in.
- *
- */
- char *n;
-
- /**
- * The number of the node in the namespace.
- *
- */
- char *m;
-};
-
/**
* Initialization message for gnunet-cmds-testbed to start cmd binary.
*/
diff --git a/src/transport/test_transport_plugin_cmd_nat_upnp.c
b/src/transport/test_transport_plugin_cmd_nat_upnp.c
index 73380e03c..3fef41d87 100644
--- a/src/transport/test_transport_plugin_cmd_nat_upnp.c
+++ b/src/transport/test_transport_plugin_cmd_nat_upnp.c
@@ -87,21 +87,25 @@ handle_test (void *cls,
}
-struct GNUNET_TESTING_Barrier *
+struct GNUNET_TESTING_BarrierList*
get_waiting_for_barriers ()
{
- struct GNUNET_TESTING_Barrier *barriers_head;
- struct GNUNET_TESTING_Barrier *barriers_tail;
- struct GNUNET_TESTING_Barrier *ready_to_connect;
- struct GNUNET_TESTING_Barrier *test_case_finished;
-
- ready_to_connect = GNUNET_new (struct GNUNET_TESTING_Barrier);
- ready_to_connect->name = "ready-to-connect";
- test_case_finished = GNUNET_new (struct GNUNET_TESTING_Barrier);
- test_case_finished->name = "test-case-finished";
- GNUNET_CONTAINER_DLL_insert (barriers_head, barriers_tail, ready_to_connect);
- GNUNET_CONTAINER_DLL_insert (barriers_head, barriers_tail,
test_case_finished);
- return barriers_head;
+ 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 = GNUNET_TESTING_barrier_new ("ready-to-connect");
+ 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");
+ GNUNET_CONTAINER_DLL_insert (barriers->head,
+ barriers->tail,
+ ble);
+ return barriers;
}
@@ -143,7 +147,7 @@ static void
handle_result (void *cls,
enum GNUNET_GenericReturnValue rv)
{
- struct TestState *ts = cls;
+ struct GNUNET_TESTING_TestState *ts = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Local test exits with status %d\n",
@@ -186,7 +190,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is,
static void
all_local_tests_prepared ()
{
- const struct LocalPreparedState *lfs;
+ const struct GNUNET_TESTING_LocalPreparedState *lfs;
GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared,
&lfs);
@@ -210,7 +214,7 @@ all_local_tests_prepared ()
* @param local_m The number of nodes in a network namespace.
*/
static void
-start_testcase (TESTING_CMD_HELPER_write_cb write_message,
+start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message,
const char *router_ip,
const char *node_ip,
const char *m,
@@ -218,14 +222,14 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message,
const char *local_m,
const char *topology_data,
unsigned int *read_file,
- TESTING_CMD_HELPER_finish_cb finished_cb)
+ 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_TestState *ts = GNUNET_new (struct
GNUNET_TESTING_TestState);
struct GNUNET_TESTING_NetjailTopology *topology;
unsigned int sscanf_ret = 0;
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c
b/src/transport/test_transport_plugin_cmd_simple_send.c
index de923cbdd..e94667593 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send.c
@@ -87,13 +87,11 @@ handle_test (void *cls,
}
-struct GNUNET_TESTING_Barrier *
+struct GNUNET_TESTING_BarrierList *
get_waiting_for_barriers ()
{
- struct GNUNET_TESTING_Barrier *barrier;
-
//No Barrier
- return NULL;
+ return GNUNET_new (struct GNUNET_TESTING_BarrierList);
}
@@ -135,7 +133,7 @@ static void
handle_result (void *cls,
enum GNUNET_GenericReturnValue rv)
{
- struct TestState *ts = cls;
+ struct GNUNET_TESTING_TestState *ts = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Local test exits with status %d\n",
@@ -178,7 +176,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is,
static void
all_local_tests_prepared ()
{
- const struct LocalPreparedState *lfs;
+ const struct GNUNET_TESTING_LocalPreparedState *lfs;
GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared,
&lfs);
@@ -202,7 +200,7 @@ all_local_tests_prepared ()
* @param local_m The number of nodes in a network namespace.
*/
static void
-start_testcase (TESTING_CMD_HELPER_write_cb write_message,
+start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message,
const char *router_ip,
const char *node_ip,
const char *m,
@@ -210,14 +208,14 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message,
const char *local_m,
const char *topology_data,
unsigned int *read_file,
- TESTING_CMD_HELPER_finish_cb finished_cb)
+ 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_TestState *ts = GNUNET_new (struct
GNUNET_TESTING_TestState);
struct GNUNET_TESTING_NetjailTopology *topology;
unsigned int sscanf_ret = 0;
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 ff6f0def9..4eeb25ec8 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
@@ -87,13 +87,11 @@ handle_test (void *cls,
}
-struct GNUNET_TESTING_Barrier *
+struct GNUNET_TESTING_BarrierList *
get_waiting_for_barriers ()
{
- struct GNUNET_TESTING_Barrier *barrier;
-
//No Barrier
- return NULL;
+ return GNUNET_new (struct GNUNET_TESTING_BarrierList);
}
@@ -137,7 +135,7 @@ static void
handle_result (void *cls,
enum GNUNET_GenericReturnValue rv)
{
- struct TestState *ts = cls;
+ struct GNUNET_TESTING_TestState *ts = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Local test exits with status %d\n",
@@ -161,7 +159,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is,
const struct GNUNET_TESTING_AsyncContext *ac;
void *ret = NULL;
const struct GNUNET_TESTING_Command *cmd;
- struct BlockState *bs;
+ struct GNUNET_TESTING_BlockState *bs;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -190,7 +188,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is,
cmd->label);
GNUNET_TESTING_get_trait_block_state (
cmd,
- (const struct BlockState **) &bs);
+ (const struct GNUNET_TESTING_BlockState **) &bs);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"block state %u\n",
@@ -211,7 +209,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is,
static void
all_local_tests_prepared ()
{
- const struct LocalPreparedState *lfs;
+ const struct GNUNET_TESTING_LocalPreparedState *lfs;
GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared,
&lfs);
@@ -235,7 +233,7 @@ all_local_tests_prepared ()
* @param local_m The number of nodes in a network namespace.
*/
static void
-start_testcase (TESTING_CMD_HELPER_write_cb write_message,
+start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message,
const char *router_ip,
const char *node_ip,
const char *m,
@@ -243,13 +241,13 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message,
const char *local_m,
const char *topology_data,
unsigned int *read_file,
- TESTING_CMD_HELPER_finish_cb finished_cb)
+ 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_TestState *ts = GNUNET_new (struct
GNUNET_TESTING_TestState);
struct GNUNET_TESTING_NetjailTopology *topology;
unsigned int sscanf_ret = 0;
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 adbb3cc0b..fe2c04401 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send_dv.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send_dv.c
@@ -87,7 +87,7 @@ handle_test (void *cls,
const struct GNUNET_TESTING_AsyncContext *ac_block;
const struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
unsigned int connected;
- struct BlockState *bs;
+ struct GNUNET_TESTING_BlockState *bs;
struct GNUNET_TRANSPORT_CoreHandle *ch;
const struct StartPeerState *sps;
@@ -129,7 +129,7 @@ handle_test (void *cls,
{
GNUNET_TESTING_get_trait_block_state (
&block_receive,
- (const struct BlockState **) &bs);
+ (const struct GNUNET_TESTING_BlockState **) &bs);
bs->asynchronous_finish = GNUNET_YES;
}
@@ -139,13 +139,11 @@ handle_test (void *cls,
}
-struct GNUNET_TESTING_Barrier *
+struct GNUNET_TESTING_BarrierList *
get_waiting_for_barriers ()
{
- struct GNUNET_TESTING_Barrier *barrier;
-
//No Barrier
- return NULL;
+ return GNUNET_new (struct GNUNET_TESTING_BarrierList);
}
@@ -189,7 +187,7 @@ static void
handle_result (void *cls,
enum GNUNET_GenericReturnValue rv)
{
- struct TestState *ts = cls;
+ struct GNUNET_TESTING_TestState *ts = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Local test exits with status %d\n",
@@ -234,7 +232,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is,
static void
all_local_tests_prepared ()
{
- const struct LocalPreparedState *lfs;
+ const struct GNUNET_TESTING_LocalPreparedState *lfs;
GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared,
&lfs);
@@ -258,7 +256,7 @@ all_local_tests_prepared ()
* @param local_m The number of nodes in a network namespace.
*/
static void
-start_testcase (TESTING_CMD_HELPER_write_cb write_message,
+start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message,
const char *router_ip,
const char *node_ip,
const char *m,
@@ -266,13 +264,13 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message,
const char *local_m,
const char *topology_data,
unsigned int *read_file,
- TESTING_CMD_HELPER_finish_cb finished_cb)
+ 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_TestState *ts = GNUNET_new (struct
GNUNET_TESTING_TestState);
struct GNUNET_TESTING_NetjailTopology *topology;
struct GNUNET_MQ_MessageHandler handlers[] = {
GNUNET_MQ_hd_var_size (test,
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c
b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
index 1bc965848..f96a25e80 100644
--- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c
+++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
@@ -85,13 +85,11 @@ handle_test (void *cls,
}
-struct GNUNET_TESTING_Barrier *
+struct GNUNET_TESTING_BarrierList *
get_waiting_for_barriers ()
{
- struct GNUNET_TESTING_Barrier *barrier;
-
// No Barrier
- return NULL;
+ return GNUNET_new (struct GNUNET_TESTING_BarrierList);
}
@@ -134,7 +132,7 @@ static void
handle_result (void *cls,
enum GNUNET_GenericReturnValue rv)
{
- struct TestState *ts = cls;
+ struct GNUNET_TESTING_TestState *ts = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Local test exits with status %d\n",
@@ -173,7 +171,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is,
static void
all_local_tests_prepared ()
{
- const struct LocalPreparedState *lfs;
+ const struct GNUNET_TESTING_LocalPreparedState *lfs;
GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared,
&lfs);
@@ -196,7 +194,7 @@ all_local_tests_prepared ()
* @param local_m The number of nodes in a network namespace.
*/
static void
-start_testcase (TESTING_CMD_HELPER_write_cb write_message,
+start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message,
const char *router_ip,
const char *node_ip,
const char *m,
@@ -204,14 +202,14 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message,
const char *local_m,
const char *topology_data,
unsigned int *read_file,
- TESTING_CMD_HELPER_finish_cb finished_cb)
+ 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_TestState *ts = GNUNET_new (struct
GNUNET_TESTING_TestState);
struct GNUNET_TESTING_NetjailTopology *topology;
unsigned int sscanf_ret = 0;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: TESTING: Fix TESTING-NG API to follow naming conventions,
gnunet <=