[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: - relsoved an coverity issue, worked on
From: |
gnunet |
Subject: |
[gnunet] branch master updated: - relsoved an coverity issue, worked on fixmes, code documentation and cleaned up up the barrier API |
Date: |
Fri, 06 Jan 2023 21:03:12 +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 2c2b2911e - relsoved an coverity issue, worked on fixmes, code
documentation and cleaned up up the barrier API
2c2b2911e is described below
commit 2c2b2911e1585dc378dbb88d4dd6aaec37b00316
Author: t3sserakt <t3ss@posteo.de>
AuthorDate: Fri Jan 6 21:02:55 2023 +0100
- relsoved an coverity issue, worked on fixmes, code documentation and
cleaned up up the barrier API
---
src/include/gnunet_protocols.h | 2 +-
src/include/gnunet_testing_barrier.h | 41 +++++-
src/include/gnunet_testing_netjail_lib.h | 77 ++++--------
src/include/gnunet_testing_ng_lib.h | 54 ++------
src/include/gnunet_testing_plugin.h | 66 +++++++---
src/testing/Makefile.am | 5 +-
src/testing/gnunet-cmds-helper.c | 47 +++++--
src/testing/testing.c | 140 +++++++++++++++------
src/testing/testing.h | 56 ++-------
src/testing/testing_api_cmd_barrier.c | 20 ++-
src/testing/testing_api_cmd_barrier_reached.c | 46 ++++---
.../testing_api_cmd_block_until_external_trigger.c | 2 +-
src/testing/testing_api_cmd_local_test_finished.c | 116 -----------------
...=> testing_api_cmd_netjail_start_cmds_helper.c} | 108 +++++++++++++---
src/testing/testing_api_cmd_netjail_stop.c | 2 +
... => testing_api_cmd_netjail_stop_cmds_helper.c} | 3 +-
src/testing/testing_api_loop.c | 104 ++++++++-------
src/testing/testing_cmds.h | 36 +++++-
src/transport/test_transport_api2_tcp_node1.conf | 3 +
src/transport/test_transport_nat_upnp.sh | 1 +
src/transport/test_transport_plugin_cmd_nat_upnp.c | 35 ++++--
.../test_transport_plugin_cmd_simple_send.c | 4 +-
...st_transport_plugin_cmd_simple_send_broadcast.c | 4 +-
.../test_transport_plugin_cmd_simple_send_dv.c | 4 +-
.../test_transport_plugin_cmd_udp_backchannel.c | 4 +-
.../test_transport_simple_send_dv_circle.sh | 1 -
src/transport/test_transport_start_with_config.c | 4 +-
src/transport/transport-testing-cmds.h | 35 +++---
.../transport_api_cmd_backchannel_check.c | 4 +-
src/transport/transport_api_cmd_connecting_peers.c | 4 +-
src/transport/transport_api_cmd_start_peer.c | 3 +
src/transport/transport_api_cmd_stop_peer.c | 2 +
32 files changed, 572 insertions(+), 461 deletions(-)
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 8f857e86c..e78738d7b 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -3605,7 +3605,7 @@ extern "C" {
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACH 1708
-#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED 1709
+#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE 1709
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED 1710
diff --git a/src/include/gnunet_testing_barrier.h
b/src/include/gnunet_testing_barrier.h
index 3eb61c7ec..4384dd055 100644
--- a/src/include/gnunet_testing_barrier.h
+++ b/src/include/gnunet_testing_barrier.h
@@ -27,6 +27,8 @@
#ifndef GNUNET_TESTING_BARRIER_LIB_H
#define GNUNET_TESTING_BARRIER_LIB_H
+#include "gnunet_testing_plugin.h"
+
#define GNUNET_TESTING_BARRIER_MAX 32
/**
@@ -47,7 +49,7 @@ struct GNUNET_TESTING_BarrierListEntry
* Number of commands attached to the barrier.
*/
unsigned int expected_reaches;
-};
+ };
/**
* A list to hold barriers provided by plugins
@@ -63,10 +65,21 @@ struct GNUNET_TESTING_BarrierList
/**
- * FIXME: documentation
+ * Command to create a barrier.
+ *
* FIXME: high-level it is baffling how we need both the GNUNET_TESTING_Barrier
* and the Command that creates barriers. Conceptually this seems to be
* very much separate. Can we move _Barrier completely into testing as private?
+ *
+ * @param label The label of this command.
+ * @param percentage_to_be_reached If this percentage of processes reached
+ * this barrier, all processes waiting at
+ * this barrier can pass it. Must not be
+ * used together with number_to_be_reached.
+ * @param number_to_be_reached If this number of processes reached
+ * this barrier, all processes waiting at
+ * this barrier can pass it. Must not be
+ * used together with percentage_to_be_reached.
*/
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_barrier_create (
@@ -74,5 +87,29 @@ GNUNET_TESTING_cmd_barrier_create (
double percentage_to_be_reached,
unsigned int number_to_be_reached);
+/**
+ * If this command is executed the the process is signaling the master process
+ * that it reached a barrier. If this command is synchronous it will block.
+ *
+ * FIXME: Now this, as it returns a Command, seems to me like it should be
+ * part of the public API?
+ *
+ * @param label name for command.
+ * @param barrier_label The name of the barrier we waited for and which was
reached.
+ * @param asynchronous_finish If GNUNET_YES this command will not block.
+ * @param node_number The global number 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);
+
#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 a2f2e056a..106d7cdae 100644
--- a/src/include/gnunet_testing_netjail_lib.h
+++ b/src/include/gnunet_testing_netjail_lib.h
@@ -50,10 +50,9 @@ struct GNUNET_TESTING_NetjailRouter
/**
- * FIXME: Naming
* Enum for the different types of nodes.
*/
-enum GNUNET_TESTING_NODE_TYPE
+enum GNUNET_TESTING_NodeType
{
/**
* Node in a subnet.
@@ -122,7 +121,7 @@ struct GNUNET_TESTING_NodeConnection
/**
* The type of the node this connection points to.
*/
- enum GNUNET_TESTING_NODE_TYPE node_type;
+ enum GNUNET_TESTING_NodeType node_type;
/**
* The node which establish the connection
@@ -345,7 +344,6 @@ GNUNET_TESTING_calculate_num (struct
struct GNUNET_TESTING_NetjailTopology *topology);
/**
- * FIXME: This was also not namespaces.
* Struct with information for callbacks.
*
*/
@@ -368,7 +366,6 @@ struct GNUNET_TESTING_BlockState
};
/**
- * FIXME: This was also not namespaced
* Struct to hold information for callbacks.
*
*/
@@ -387,9 +384,9 @@ struct GNUNET_TESTING_LocalPreparedState
};
/**
- * Create command. FIXME: What?
+ * This command destroys the ressources allocated for the test system setup.
*
- * @param label name for command.
+ * @param label Name for command.
* @param create_label Label of the cmd which started the test system.
* @param write_message Callback to write messages to the master loop.
* @return command.
@@ -398,15 +395,20 @@ struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_system_destroy (const char *label,
const char *create_label);
-//FIXME
+/**
+ * This command is setting up a test environment for a peer to start.
+ *
+ * @param label Name for command.
+ * @param testdir Only the directory name without any path. Temporary
+ * directory used for all service homes.
+ */
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_system_create (const char *label,
const char *testdir);
/**
- * FIXME
- * Create command.
+ * This command executes a shell script to setup the netjail environment.
*
* @param label name for command.
* @param topology_config Configuration file for the test topology.
@@ -420,8 +422,7 @@ GNUNET_TESTING_cmd_netjail_start (const char *label,
/**
- * FIXME
- * Create command.
+ * This command executes a shell script to remove the netjail environment.
*
* @param label name for command.
* @param topology_config Configuration file for the test topology.
@@ -435,9 +436,8 @@ GNUNET_TESTING_cmd_netjail_stop (const char *label,
/**
- * FIXME
- * FIXME Naming?
- * Create command.
+ * This command executes a shell script which starts a helper process.
+ * This process is running on a netjail node, executing a defined test case.
*
* @param label Name for the command.
* @param topology The complete topology information.
@@ -447,7 +447,7 @@ GNUNET_TESTING_cmd_netjail_stop (const char *label,
* @return command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_netjail_start_testing_system (
+GNUNET_TESTING_cmd_netjail_start_cmds_helper (
const char *label,
struct GNUNET_TESTING_NetjailTopology *topology,
unsigned int *read_file,
@@ -464,36 +464,17 @@ GNUNET_TESTING_cmd_netjail_start_testing_system (
* @return command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_stop_testing_system (
+GNUNET_TESTING_cmd_stop_cmds_helper (
const char *label,
const char *helper_start_label,
struct GNUNET_TESTING_NetjailTopology *topology);
-/**
- * Create a GNUNET_CMDS_LOCAL_FINISHED message.
- * FIXME: This is strange as messages are not really used
- * like this. Consider removing.
- *
- * @return The GNUNET_CMDS_LOCAL_FINISHED message.
- */
-struct GNUNET_MessageHeader *
-GNUNET_TESTING_send_local_test_finished_msg ();
-
-
-//FIXME
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_block_until_all_peers_started (
- const char *label,
- unsigned int *all_peers_started);
-
/**
- * FIXME
- * Create command.
+ * This command is used to block the loop, until the command is finished by
other commands,
+ * using a trait to get this commands struct GNUNET_TESTING_AsyncContext.
*
* @param label name for command.
- * @param all_peers_started Flag which will be set from outside.
- * @param asynchronous_finish If GNUNET_YES this command will not block.
* @return command.
*/
struct GNUNET_TESTING_Command
@@ -501,8 +482,8 @@ GNUNET_TESTING_cmd_block_until_external_trigger (
const char *label);
/**
- * FIXME
- * Create command.
+ * DEPRECATED
+ * This command sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED message
to the master loop.
*
* @param label name for command.
* @param write_message Callback to write messages to the master loop.
@@ -514,21 +495,7 @@ GNUNET_TESTING_cmd_send_peer_ready (const char *label,
/**
- * FIXME
- * Create command.
- *
- * @param label name for command.
- * @param write_message Callback to write messages to the master loop.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_local_test_finished (
- const char *label,
- GNUNET_TESTING_cmd_helper_write_cb write_message);
-
-/**
- * FIXME
- * Create command.
+ * This command sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TESTS_PREPARED
message to the master loop.
*
* @param label name for command.
* @param write_message 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 f0e2e3250..aae918ff3 100644
--- a/src/include/gnunet_testing_ng_lib.h
+++ b/src/include/gnunet_testing_ng_lib.h
@@ -421,46 +421,6 @@ GNUNET_TESTING_main (struct GNUNET_TESTING_Command
*commands,
/* ************** Specific interpreter commands ************ */
-/**
- * Adding a helper handle to the interpreter.
- *
- * @param is The interpreter.
- * @param helper The helper handle.
- */
-void
-GNUNET_TESTING_add_netjail_helper (struct GNUNET_TESTING_Interpreter *is,
- const struct GNUNET_HELPER_Handle *helper);
-
-
-/**
- * Send Message to netjail nodes that a barrier can be advanced.
- * FIXME: Naming. No "netjail" in argument. Or is there a
- * GNUNET_TESTING_send_message without "to_netjail"??
- *
- * @param is The interpreter.
- * @param global_node_number The node to inform.
- * @param header The message to send.
- */
-void
-GNUNET_TESTING_send_message_to_netjail (struct GNUNET_TESTING_Interpreter *is,
- unsigned int global_node_number,
- struct GNUNET_MessageHeader *header);
-
-
-/**
- * Returns the actual running command.
- * FIXME: Is Command allocated? Is it constant? Should this be a private
- * function? => not used outside of testing
- *
- * @param is Global state of the interpreter, used by a command
- * to access information about other commands.
- * @return The actual running command.
- */
-struct GNUNET_TESTING_Command *
-GNUNET_TESTING_interpreter_get_current_command (
- struct GNUNET_TESTING_Interpreter *is);
-
-
/**
* Check if the command is running.
* FIXME: Unused function.
@@ -561,15 +521,14 @@ struct GNUNET_TESTING_Timer
/**
- * Retrieve the public key from the test system with the unique node id.
- * FIXME: Naming. => get_peer? This returns a PeerIdentity not a PublicKey
+ * Retrieve peer identity from the test system with the unique node id.
*
* @param num The unique node id.
* @param tl_system The test system.
* @return The peer identity wrapping the public key.
*/
struct GNUNET_PeerIdentity *
-GNUNET_TESTING_get_pub_key (unsigned int num,
+GNUNET_TESTING_get_peer (unsigned int num,
const struct GNUNET_TESTING_System *tl_system);
@@ -586,8 +545,13 @@ GNUNET_TESTING_cmd_stat (struct GNUNET_TESTING_Timer
*timers);
/* *** Generic trait logic for implementing traits ********* */
/**
- * FIXME: Documentation
- * A trait.
+ * A struct GNUNET_TESTING_Trait can be used to exchange data between cmds.
+ *
+ * Therefor the cmd which like to provide data to other cmds has to implement
+ * the trait function, where an array of traits is defined with the help of
the
+ * GNUNET_TESTING_make_trait_ macro. The data can be retrieved with the help
of the
+ * GNUNET_TESTING_get_trait_ macro. Traits name and type must be defined to
make
+ * use of the macros.
*/
struct GNUNET_TESTING_Trait
{
diff --git a/src/include/gnunet_testing_plugin.h
b/src/include/gnunet_testing_plugin.h
index 5f7570680..12fbd7b75 100644
--- a/src/include/gnunet_testing_plugin.h
+++ b/src/include/gnunet_testing_plugin.h
@@ -40,17 +40,40 @@ extern "C"
struct GNUNET_TESTING_Barrier;
-//FIXME documentation for both functions
+/**
+ * Callback function to write messages from the helper process running on a
netjail node to the master process.
+ *
+ * @param message The message to write.
+ * @param msg_length The length of the message.
+ */
typedef void
(*GNUNET_TESTING_cmd_helper_write_cb) (struct GNUNET_MessageHeader *message,
size_t msg_length);
+/**
+ * Callback function which writes a message from the helper process running on
a netjail node to the master process * signaling that the test case running on
the netjail node finished.
+ */
typedef void
(*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??
+/**
+ * Function to be implemented for each test case plugin which starts the test
case on a netjail node.
+ *
+ * @param write_message Callback function to write messages from the helper
process running on a
+ * netjail node to the master process.
+ * @param router_ip Global address of the network namespace, if the helper
process is for a node in a subnet.
+ * @param node_ip The IP address of the node.
+ * @param m The number of the node in a network namespace.
+ * @param n The number of the network namespace.
+ * @param local_m The number of nodes in a network namespace.
+ * @param topology_data A file name for the file containing the topology
configuration, or a string containing
+ * the topology configuration.
+ * @param read_file If read_file is GNUNET_YES this string is the filename for
the topology configuration,
+ * if read_file is GNUNET_NO the string contains the topology
configuration.
+ * @param finish_cb Callback function which writes a message from the helper
process running on a netjail
+ * node to the master process * signaling that the test case
running on the netjail node finished.
+ * @return Returns The struct GNUNET_TESTING_Interpreter of the command loop
running on this netjail node.
+ */
typedef struct GNUNET_TESTING_Interpreter *
(*GNUNET_TESTING_PLUGIN_StartTestCase) (GNUNET_TESTING_cmd_helper_write_cb
write_message,
@@ -63,30 +86,41 @@ typedef struct GNUNET_TESTING_Interpreter *
unsigned int *read_file,
GNUNET_TESTING_cmd_helper_finish_cb
finish_cb);
-
+/**
+ * DEPRECATED
+ * The helper process received a message of type
+ * GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED. This will finish the
blocking command
+ * GNUNET_TESTING_cmd_block_until_external_trigger which was execute right
after the command
+ * GNUNET_TESTING_cmd_send_peer_ready.
+ */
typedef void
(*GNUNET_TESTING_PLUGIN_ALL_PEERS_STARTED) ();
-
+/**
+ * DEPRECATED
+ * The helper process received a message of type
+ * GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED. This will finish
the blocking command
+ * GNUNET_TESTING_cmd_local_test_prepared which was execute right after the
command
+ * GNUNET_TRANSPORT_cmd_connect_peers.
+ */
typedef void
(*GNUNET_TESTING_PLUGIN_ALL_LOCAL_TESTS_PREPARED) ();
-typedef void
-(*GNUNET_TESTING_PLUGIN_BARRIER_ADVANCED) (const char *barrier_name);
-
+/**
+ * This function returns a struct GNUNET_TESTING_BarrierList, which is a list
of all barriers
+ * this test case will wait for.
+ *
+ * @return A struct GNUNET_TESTING_BarrierList.
+ */
typedef struct GNUNET_TESTING_BarrierList*
(*GNUNET_TESTING_PLUGIN_GET_WAITING_FOR_BARRIERS) (void);
-// FIXME documentation
+/**
+ * The plugin API every test case plugin has to implement.
+ */
struct GNUNET_TESTING_PluginFunctions
{
- /**
- * Closure for all of the callbacks.
- */
- void *cls;
-
- GNUNET_TESTING_PLUGIN_BARRIER_ADVANCED barrier_advanced;
GNUNET_TESTING_PLUGIN_StartTestCase start_testcase;
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 3a4990db4..1f6ccc15b 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -33,13 +33,12 @@ libgnunettesting_la_SOURCES = \
testing_api_cmd_barrier_reached.c \
testing_api_cmd_end.c \
testing_api_cmd_finish.c \
- testing_api_cmd_local_test_finished.c \
testing_api_cmd_local_test_prepared.c \
testing_api_cmd_send_peer_ready.c \
testing_api_cmd_block_until_external_trigger.c \
testing_api_cmd_netjail_start.c \
- testing_api_cmd_netjail_start_testsystem.c \
- testing_api_cmd_netjail_stop_testsystem.c \
+ testing_api_cmd_netjail_start_cmds_helper.c \
+ testing_api_cmd_netjail_stop_cmds_helper.c \
testing_api_cmd_netjail_stop.c \
testing.c testing.h \
testing_api_cmd_system_create.c \
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c
index 4d3da6260..90b686891 100644
--- a/src/testing/gnunet-cmds-helper.c
+++ b/src/testing/gnunet-cmds-helper.c
@@ -61,7 +61,7 @@
#define NODE_BASE_IP "192.168.15."
-#define KNOWN_BASE_IP "172.168.151."
+#define KNOWN_BASE_IP "172.16.151."
#define ROUTER_BASE_IP "172.16.150."
@@ -213,6 +213,9 @@ do_shutdown (void *cls)
(void) GNUNET_DISK_file_close (stdout_fd);
GNUNET_MST_destroy (tokenizer);
tokenizer = NULL;
+ GNUNET_PLUGIN_unload (plugin->library_name,
+ NULL);
+ GNUNET_free (plugin);
}
@@ -286,16 +289,36 @@ delay_shutdown_cb ()
}
+struct GNUNET_MessageHeader *
+GNUNET_TESTING_send_local_test_finished_msg ()
+{
+ struct GNUNET_TESTING_CommandLocalFinished *reply;
+ size_t msg_length;
+
+ msg_length = sizeof(struct GNUNET_TESTING_CommandLocalFinished);
+ reply = GNUNET_new (struct GNUNET_TESTING_CommandLocalFinished);
+ reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED);
+ reply->header.size = htons ((uint16_t) msg_length);
+
+ return (struct GNUNET_MessageHeader *) reply;
+}
+
+
static void
-finished_cb ()
+finished_cb (enum GNUNET_GenericReturnValue rv)
{
- struct GNUNET_MessageHeader *reply;
+ struct GNUNET_TESTING_CommandLocalFinished *reply;
+ size_t msg_length;
- reply = GNUNET_TESTING_send_local_test_finished_msg ();
+ msg_length = sizeof(struct GNUNET_TESTING_CommandLocalFinished);
+ reply = GNUNET_new (struct GNUNET_TESTING_CommandLocalFinished);
+ reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED);
+ reply->header.size = htons ((uint16_t) msg_length);
+ reply->rv = rv;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"message prepared\n");
- write_message (reply, ntohs (reply->size));
+ write_message ((struct GNUNET_MessageHeader *) reply, msg_length);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"message send\n");
@@ -337,10 +360,11 @@ tokenizer_cb (void *cls, const struct
GNUNET_MessageHeader *message)
unsigned int namespace_n;
type = ntohs (message->type);
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Received message type %u\n",
- type);
msize = ntohs (message->size);
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Received message type %u and size %u\n",
+ type,
+ msize);
if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT == ntohs (message->type))
{
msg = (const struct GNUNET_TESTING_CommandHelperInit *) message;
@@ -412,13 +436,16 @@ tokenizer_cb (void *cls, const struct
GNUNET_MessageHeader *message)
return GNUNET_OK;
}
- else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED == ntohs (
+ else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE == ntohs (
message->type))
{
const char *barrier_name;
- struct CommandBarrierAdvanced *adm = (struct CommandBarrierAdvanced *)
message;
+ struct CommandBarrierCrossable *adm = (struct CommandBarrierCrossable *)
message;
barrier_name = (const char *) &adm[1];
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "cross barrier %s\n",
+ barrier_name);
TST_interpreter_finish_attached_cmds (is, barrier_name);
return GNUNET_OK;
}
diff --git a/src/testing/testing.c b/src/testing/testing.c
index b45270d57..f2bf68c08 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -1739,8 +1739,13 @@ GNUNET_TESTING_get_testname_from_underscore (const char
*argv0)
/**
- * FIXME: I'm just janitoring around here. I have no idea what this function
- * is supposed todo. Needs documentation.
+ * Every line in the topology configuration starts with a string indicating
which
+ * kind of information will be configured with this line. Configuration values
following
+ * this string are seperated by special sequences of characters. An integer
value seperated
+ * by ':' is returned by this function.
+ *
+ * @param line The line of configuration.
+ * @return An integer value.
*/
static unsigned int
get_first_value (const char *line)
@@ -1763,8 +1768,11 @@ get_first_value (const char *line)
/**
- * FIXME: I'm just janitoring around here. I have no idea what this function
- * is supposed todo. Needs documentation.
+ * Every line in the topology configuration starts with a string indicating
which
+ * kind of information will be configured with this line. This string is
returned by this function.
+ *
+ * @param line The line of configuration.
+ * @return The leading string of this configuration line.
*/
static char *
get_key (const char *line)
@@ -1789,8 +1797,13 @@ get_key (const char *line)
/**
- * FIXME: I'm just janitoring around here. I have no idea what this function
- * is supposed todo. Needs documentation.
+ * Every line in the topology configuration starts with a string indicating
which
+ * kind of information will be configured with this line. Configuration values
following
+ * this string are seperated by special sequences of characters. A string
value seperated
+ * by ':' is returned by this function.
+ *
+ * @param line The line of configuration.
+ * @return A string value.
*/
static char *
get_first_string_value (const char *line)
@@ -1818,8 +1831,13 @@ get_first_string_value (const char *line)
/**
- * FIXME: I'm just janitoring around here. I have no idea what this function
- * is supposed todo. Needs documentation.
+ * Every line in the topology configuration starts with a string indicating
which
+ * kind of information will be configured with this line. Configuration values
following
+ * this string are seperated by special sequences of characters. A second
integer value
+ * seperated by ':' from a first value is returned by this function.
+ *
+ * @param line The line of configuration.
+ * @return An integer value.
*/
static unsigned int
get_second_value (const char *line)
@@ -1833,7 +1851,9 @@ get_second_value (const char *line)
token = strtok_r (copy, ":", &rest);
token = strtok_r (NULL, ":", &rest);
token = strtok_r (NULL, ":", &rest);
- /* FIXME: ASSERT??? Are we not parsing "user" input here? */
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Format error in configuration line: %s\n",
+ line);
GNUNET_assert (1 == sscanf (token, "%u", &ret));
GNUNET_free (copy);
return ret;
@@ -1841,8 +1861,14 @@ get_second_value (const char *line)
/**
- * FIXME: I'm just janitoring around here. I have no idea what this function
- * is supposed todo. Needs documentation.
+ * Every line in the topology configuration starts with a string indicating
which
+ * kind of information will be configured with this line. Configuration values
following
+ * this string are seperated by special sequences of characters. A value might
be
+ * a key value pair.
+ * This function returns the value for a specific key in a configuration line.
+ *
+ * @param key The key of the key value pair.
+ * @return The value of the key value pair.
*/
static char *
get_value (const char *key, const char *line)
@@ -1873,8 +1899,16 @@ get_value (const char *key, const char *line)
/**
- * FIXME: I'm just janitoring around here. I have no idea what this function
- * is supposed todo. Needs documentation.
+ * Every line in the topology configuration starts with a string indicating
which
+ * kind of information will be configured with this line. Configuration values
following
+ * this string are seperated by special sequences of characters. A value might
be
+ * a key value pair. A special key is the 'connect' which can appear more than
once.
+ * The value is the information about a connection via some protocol to some
other node.
+ * This function returns the struct GNUNET_TESTING_NodeConnection which holds
the information
+ * of the connect value.
+ *
+ * @param value The value of the connect key value pair.
+ * @return The struct GNUNET_TESTING_NodeConnection.
*/
static struct GNUNET_TESTING_NodeConnection *
get_connect_value (const char *line,
@@ -1970,8 +2004,20 @@ get_connect_value (const char *line,
/**
- * FIXME: I'm just janitoring around here. I have no idea what this function
- * is supposed todo. Needs documentation.
+ * Every line in the topology configuration starts with a string indicating
which
+ * kind of information will be configured with this line. Configuration values
following
+ * this string are seperated by special sequences of characters. A value might
be
+ * a key value pair. A special key is the 'connect' key.
+ * The value is the information about a connections via some protocol to other
nodes.
+ * Each connection itself is a key value pair separated by the character '|'
and
+ * surrounded by the characters '{' and '}'.
+ * The struct GNUNET_TESTING_NodeConnection holds the information of each
connection value.
+ * This function extracts the values of each connection into a DLL of
+ * struct GNUNET_TESTING_NodeConnection which will be added to a node.
+ *
+ * @param line The line of configuration.
+ * @param node The struct GNUNET_TESTING_NetjailNode to which the DLL of
+ * struct GNUNET_TESTING_NodeConnection will be added.
*/
static void
node_connections (const char *line, struct GNUNET_TESTING_NetjailNode *node)
@@ -1998,7 +2044,12 @@ node_connections (const char *line, struct
GNUNET_TESTING_NetjailNode *node)
value);
node_connection = get_connect_value (value, node);
if (NULL == node_connection)
- break; /* FIXME: continue? */
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "connect key was not expected in this configuration line: %s\n",
+ line);
+ break;
+ }
GNUNET_CONTAINER_DLL_insert (node->node_connections_head,
node->node_connections_tail,
node_connection);
@@ -2014,8 +2065,12 @@ node_connections (const char *line, struct
GNUNET_TESTING_NetjailNode *node)
/**
- * FIXME: I'm just janitoring around here. I have no idea what this function
- * is supposed todo. Needs documentation.
+ * A helper function to log information about individual nodes.
+ *
+ * @param cls This is not used actually.
+ * @param id The key of this value in the map.
+ * @param value A struct GNUNET_TESTING_NetjailNode which holds information
about a node.
+ * return GNUNET_YES to continue with iterating, GNUNET_NO otherwise.
*/
static int
log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value)
@@ -2054,6 +2109,14 @@ log_nodes (void *cls, const struct GNUNET_ShortHashCode
*id, void *value)
}
+/**
+ * Helper function to log information about namespaces.
+ *
+ * @param cls This is not used actually.
+ * @param id The key of this value in the map.
+ * @param value A struct GNUNET_TESTING_NetjailNamespace which holds
information about a subnet.
+ * return GNUNET_YES to continue with iterating, GNUNET_NO otherwise.
+ */
static int
log_namespaces (void *cls, const struct GNUNET_ShortHashCode *id, void *value)
{
@@ -2064,6 +2127,11 @@ log_namespaces (void *cls, const struct
GNUNET_ShortHashCode *id, void *value)
}
+/**
+ * Helper function to log the configuration in case of a problem with
configuration.
+ *
+ * @param topology The struct GNUNET_TESTING_NetjailTopology holding the
configuration information.
+ */
static int
log_topo (const struct GNUNET_TESTING_NetjailTopology *topology)
{
@@ -2082,9 +2150,15 @@ log_topo (const struct GNUNET_TESTING_NetjailTopology
*topology)
}
/**
- * FIXME: I'm just janitoring around here. I have no idea what this function
- * is supposed todo. Needs documentation.
- */
+ * This function extracts information about a specific node from the topology.
+ *
+ * @param num The global index number of the node.
+ * @param[out] node_ex A struct GNUNET_TESTING_NetjailNode with information
about the node.
+ * @param[out] namespace_ex A struct GNUNET_TESTING_NetjailNamespace with
information about the namespace
+ the node is in or NULL, if the node is a global node.
+ * @param[out] node_connections_ex A struct GNUNET_TESTING_NodeConnection with
information about the connection
+ of this node to other nodes.
+*/
static void
get_node_info (unsigned int num,
const struct GNUNET_TESTING_NetjailTopology *topology,
@@ -2206,10 +2280,14 @@ GNUNET_TESTING_get_connections (unsigned int num,
/**
- * FIXME: Function named incorrectly IMO
+ * Retrieve the peer identity from the test system with the unique node id.
+ *
+ * @param num The unique node id.
+ * @param tl_system The test system.
+ * @return The peer identity wrapping the public key.
*/
struct GNUNET_PeerIdentity *
-GNUNET_TESTING_get_pub_key (unsigned int num,
+GNUNET_TESTING_get_peer (unsigned int num,
const struct GNUNET_TESTING_System *tl_system)
{
struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity);
@@ -2412,22 +2490,6 @@ GNUNET_TESTING_get_additional_connects (unsigned int num,
return node->additional_connects;
}
-
-struct GNUNET_MessageHeader *
-GNUNET_TESTING_send_local_test_finished_msg ()
-{
- struct GNUNET_CMDS_LOCAL_FINISHED *reply;
- size_t msg_length;
-
- msg_length = sizeof(struct GNUNET_CMDS_LOCAL_FINISHED);
- reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_FINISHED);
- reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED);
- reply->header.size = htons ((uint16_t) msg_length);
-
- return (struct GNUNET_MessageHeader *) reply;
-}
-
-
static void
parse_ac (struct GNUNET_TESTING_NetjailNode *p_node, const char *token)
{
diff --git a/src/testing/testing.h b/src/testing/testing.h
index debcec39a..adcb50a13 100644
--- a/src/testing/testing.h
+++ b/src/testing/testing.h
@@ -30,12 +30,11 @@ 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 CommandBarrierAdvanced
+struct CommandBarrierCrossable
{
/**
- * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED
+ * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE
*/
struct GNUNET_MessageHeader header;
@@ -45,7 +44,6 @@ struct CommandBarrierAdvanced
/**
* 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 CommandBarrierAttached
{
@@ -260,60 +258,26 @@ 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
- * FIXME: Now this, as it returns a Command, seems to me like it should be
- * part of the public API?
- * 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);
-
-
-/**
- * Can we advance the barrier?
- * FIXME: As this is not in testing.h it should be in another namespace.
- * Possibly BARRIER_can_advance. However, as this is also used in a netjail
cmd,
- * I am not sure if this needs to be public? Maybe there should be a barrier
- * trait that returns a barrier where this helper function can be called on?
- * Barriers are usually also not "advanced" but "crossed" or "passed"
- * but it seems to me that the word here should correctly be "reached"?
+ * This function checks, if a barrier can be crossed, which actually means that
+ * the cmd representing the barrier is finished.
*
* @param barrier The barrier in question.
- * @return GNUNET_YES if we can advance the barrier, GNUNET_NO if not.
+ * @return GNUNET_YES if we can cross the barrier, GNUNET_NO if not.
*/
unsigned int
-GNUNET_TESTING_can_barrier_advance (struct GNUNET_TESTING_Barrier *barrier);
+GNUNET_TESTING_barrier_crossable (struct GNUNET_TESTING_Barrier *barrier);
/**
- * FIXME: Naming
- * Send Message to netjail nodes that a barrier can be advanced.
+ * Send Message to a netjail node that a barrier can be crossed.
*
* @param is The interpreter loop.
- * @param barrier_name The name of the barrier to advance.
+ * @param barrier_name The name of the barrier to cross.
* @param global_node_number The global number of the node to inform.
*/
void
-TST_interpreter_send_barrier_advance (struct GNUNET_TESTING_Interpreter *is,
+TST_interpreter_send_barrier_crossable (struct GNUNET_TESTING_Interpreter *is,
const char *barrier_name,
unsigned int global_node_number);
@@ -333,7 +297,7 @@ TST_interpreter_finish_attached_cmds (struct
GNUNET_TESTING_Interpreter *is,
* FIXME: Unused function
*
* @param is The interpreter loop.
- * @param barrier_name The name of the barrier to advance.
+ * @param barrier_name The name of the barrier to attach to.
* @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.
diff --git a/src/testing/testing_api_cmd_barrier.c
b/src/testing/testing_api_cmd_barrier.c
index bc4f79eb6..118918bc4 100644
--- a/src/testing/testing_api_cmd_barrier.c
+++ b/src/testing/testing_api_cmd_barrier.c
@@ -30,6 +30,11 @@
#include "gnunet_testing_netjail_lib.h"
#include "gnunet_testing_barrier.h"
+/**
+ * Generic logging shortcut
+ */
+#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
+
struct BarrierState
{
/*
@@ -70,13 +75,22 @@ GNUNET_TESTING_send_barrier_attach (struct
GNUNET_TESTING_Interpreter *is,
unsigned int
-GNUNET_TESTING_can_barrier_advance (struct GNUNET_TESTING_Barrier *barrier)
+GNUNET_TESTING_barrier_crossable (struct GNUNET_TESTING_Barrier *barrier)
{
unsigned int expected_reaches = barrier->expected_reaches;
unsigned int reached = barrier->reached;
double percentage_to_be_reached = barrier->percentage_to_be_reached;
unsigned int number_to_be_reached = barrier->number_to_be_reached;
- double percentage_reached = (double) expected_reaches / reached * 100;
+ double percentage_reached = (double) reached / expected_reaches * 100;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "%u %f %f %u %u\n",
+ expected_reaches,
+ percentage_to_be_reached,
+ percentage_reached,
+ number_to_be_reached,
+ reached);
+
if (((0 < percentage_to_be_reached) &&
(percentage_reached >= percentage_to_be_reached)) ||
((0 < number_to_be_reached) && (reached >= number_to_be_reached)))
@@ -173,6 +187,8 @@ GNUNET_TESTING_cmd_barrier_create (const char *label,
bs->label = label;
barrier = GNUNET_new (struct GNUNET_TESTING_Barrier);
barrier->name = label;
+ barrier->percentage_to_be_reached = percentage_to_be_reached;
+ barrier->number_to_be_reached = number_to_be_reached;
GNUNET_assert ((0 < percentage_to_be_reached && 0 == number_to_be_reached) ||
(0 == percentage_to_be_reached && 0 < number_to_be_reached));
bs->barrier = barrier;
diff --git a/src/testing/testing_api_cmd_barrier_reached.c
b/src/testing/testing_api_cmd_barrier_reached.c
index 8d52310c9..3c2ba3a1d 100644
--- a/src/testing/testing_api_cmd_barrier_reached.c
+++ b/src/testing/testing_api_cmd_barrier_reached.c
@@ -25,12 +25,17 @@
*/
#include "platform.h"
#include "gnunet_testing_lib.h"
-#include "gnunet_testing_ng_lib.h"
+#include "testing_cmds.h"
#include "gnunet_testing_plugin.h"
#include "gnunet_testing_barrier.h"
#include "gnunet_testing_netjail_lib.h"
#include "testing.h"
+/**
+ * Generic logging shortcut
+ */
+#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
+
/**
* Struct with information for callbacks.
*
@@ -87,7 +92,7 @@ barrier_reached_run (void *cls,
{
struct BarrierReachedState *brs = cls;
struct GNUNET_TESTING_Barrier *barrier;
- struct GNUNET_TESTING_Command *cmd = NULL;
+ struct GNUNET_TESTING_Command *cmd =
GNUNET_TESTING_interpreter_get_current_command (is);
struct CommandListEntry *cle;
size_t msg_length;
struct GNUNET_TESTING_CommandBarrierReached *msg;
@@ -97,43 +102,44 @@ barrier_reached_run (void *cls,
if (NULL == barrier)
{
barrier = GNUNET_new (struct GNUNET_TESTING_Barrier);
- barrier->shadow = GNUNET_YES;
- barrier->name = brs->label;
+ barrier->name = brs->barrier_name;
TST_interpreter_add_barrier (is, barrier);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "barrier %s added locally\n",
+ brs->barrier_name);
}
barrier->reached++;
- if (GNUNET_TESTING_can_barrier_advance (barrier))
+ if (GNUNET_TESTING_barrier_crossable (barrier))
{
- //FIXME cmd uninitialized
GNUNET_assert (NULL != cmd);
cmd->asynchronous_finish = GNUNET_YES;
TST_interpreter_finish_attached_cmds (is, barrier->name);
}
else if (GNUNET_NO == brs->asynchronous_finish)
{
- /** FIXME: This is already fishy as commands in is are an array
- * It is unclear how this does not end up with a DLL issue.
- * We should create a dedicated struct to hold this list.
- */
cle = GNUNET_new (struct CommandListEntry);
- cle->command = GNUNET_TESTING_interpreter_get_current_command (is);
+ cle->command = cmd;
GNUNET_CONTAINER_DLL_insert (barrier->cmds_head,
barrier->cmds_tail,
cle);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "added cle for %p %s\n",
+ barrier,
+ barrier->name);
}
- else
- {
- cmd->asynchronous_finish = GNUNET_YES;
- }
+
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);
+ char *terminator = "\0";
+
+ name_len = strlen (barrier->name);
+ msg_length = sizeof(struct GNUNET_TESTING_CommandBarrierReached) +
name_len + 1;
+ msg = GNUNET_malloc (msg_length);
msg->header.size = htons ((uint16_t) msg_length);
msg->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED);
- memcpy (&msg[1], barrier->name, name_len);
msg->node_number = brs->node_number;
+ memcpy (&msg[1], barrier->name, name_len + 1);
+ memcpy(&msg[name_len + 1],terminator,1);
brs->write_message ((struct GNUNET_MessageHeader *) msg, msg_length);
}
}
@@ -189,7 +195,7 @@ barrier_reached_traits (void *cls,
*
* @param label name for command.
* @param barrier_label The name of the barrier we wait for (if finishing
asynchronous) 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.
* @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.
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 2219ec246..81a43a3ac 100644
--- a/src/testing/testing_api_cmd_block_until_external_trigger.c
+++ b/src/testing/testing_api_cmd_block_until_external_trigger.c
@@ -25,7 +25,7 @@
*/
#include "platform.h"
#include "gnunet_util_lib.h"
-#include "gnunet_testing_ng_lib.h"
+#include "testing_cmds.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
deleted file mode 100644
index f54b67acf..000000000
--- a/src/testing/testing_api_cmd_local_test_finished.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- This file is part of GNUnet
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-
-/**
- * @file testing_api_cmd_local_test_finished.c
- * @brief cmd to block the interpreter loop until all peers started.
- * @author t3sserakt
- */
-#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"
-
-/**
- * Generic logging shortcut
- */
-#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
-
-
-/**
- * Struct to hold information for callbacks.
- *
- */
-struct LocalFinishedState
-{
-
- /**
- * Callback to write messages to the master loop.
- *
- */
- GNUNET_TESTING_cmd_helper_write_cb write_message;
-
- /**
- * The message send back to the master loop.
- *
- */
- struct GNUNET_CMDS_LOCAL_FINISHED *reply;
-};
-
-
-/**
- * The cleanup function of this cmd frees resources the cmd allocated.
- *
- */
-static void
-local_test_finished_cleanup (void *cls)
-{
- struct LocalFinishedState *lfs = cls;
-
- GNUNET_free (lfs);
-}
-
-
-/**
- * This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED
message to the master loop.
- *
- */
-static void
-local_test_finished_run (void *cls,
- struct GNUNET_TESTING_Interpreter *is)
-{
- struct LocalFinishedState *lfs = cls;
- struct GNUNET_CMDS_LOCAL_FINISHED *reply;
- size_t msg_length;
-
- msg_length = sizeof(struct GNUNET_CMDS_LOCAL_FINISHED);
- reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_FINISHED);
- reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED);
- reply->header.size = htons ((uint16_t) msg_length);
- lfs->reply = reply;
- lfs->write_message ((struct GNUNET_MessageHeader *) reply,
- msg_length);
-}
-
-
-/**
- * Create command.
- *
- * @param label name for command.
- * @param write_message Callback to write messages to the master loop.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_local_test_finished (
- const char *label,
- GNUNET_TESTING_cmd_helper_write_cb write_message)
-{
- struct LocalFinishedState *lfs;
-
- lfs = GNUNET_new (struct LocalFinishedState);
- lfs->write_message = write_message;
- return GNUNET_TESTING_command_new (lfs, label,
- &local_test_finished_run,
- &local_test_finished_cleanup,
- NULL, NULL);
-}
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem.c
b/src/testing/testing_api_cmd_netjail_start_cmds_helper.c
similarity index 89%
rename from src/testing/testing_api_cmd_netjail_start_testsystem.c
rename to src/testing/testing_api_cmd_netjail_start_cmds_helper.c
index 40a23c67c..c0f238530 100644
--- a/src/testing/testing_api_cmd_netjail_start_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_start_cmds_helper.c
@@ -356,7 +356,7 @@ barrier_attached (struct NetJailState *ns, const struct
am = (struct CommandBarrierAttached *) message;
barrier_name = (const char *) &am[1];
barrier = TST_interpreter_get_barrier (ns->is, barrier_name);
- GNUNET_assert (NULL != barrier && GNUNET_NO == barrier->shadow);
+ GNUNET_assert (NULL != barrier);
node = GNUNET_TESTING_barrier_get_node (barrier, am->node_number);
if (NULL == node)
{
@@ -386,13 +386,29 @@ barrier_reached (struct NetJailState *ns, const struct
*) message;
barrier_name = (const char *) &rm[1];
+
barrier = TST_interpreter_get_barrier (ns->is, barrier_name);
- GNUNET_assert (NULL != barrier && GNUNET_NO == barrier->shadow);
+ GNUNET_assert (NULL != barrier);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "barrier %s reached %p %u\n",
+ barrier_name,
+ barrier,
+ barrier->reached);
barrier->reached++;
- if (GNUNET_TESTING_can_barrier_advance (barrier))
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "%u %p\n",
+ barrier->reached,
+ barrier);
+ if (GNUNET_TESTING_barrier_crossable (barrier))
{
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "%s can be crossed\n",
+ barrier_name);
TST_interpreter_finish_attached_cmds (ns->is, barrier->name);
}
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "barrier %s reached finished\n",
+ barrier_name);
}
@@ -414,6 +430,7 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader
*message)
struct NetJailState *ns = cls;
unsigned int total_number = ns->local_m * ns->global_n + ns->known;
uint16_t message_type = ntohs (message->type);
+ struct GNUNET_TESTING_CommandLocalFinished *lf;
switch (message_type)
{
@@ -463,8 +480,13 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader
*message)
}
break;
case GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED:
+ lf = (struct GNUNET_TESTING_CommandLocalFinished *) message;
+
ns->number_of_local_tests_finished++;
- if (ns->number_of_local_tests_finished == total_number)
+ if (GNUNET_OK != lf->rv)
+ {
+ GNUNET_TESTING_async_fail (&(ns->ac));
+ } else if (ns->number_of_local_tests_finished == total_number)
{
GNUNET_SCHEDULER_cancel (ns->timeout_task);
GNUNET_TESTING_async_finish (&ns->ac);
@@ -570,11 +592,19 @@ start_helper (struct NetJailState *ns,
struct GNUNET_TESTING_BarrierListEntry *pos;
struct GNUNET_TESTING_Barrier *barrier;
struct GNUNET_TESTING_BarrierList *barriers;
+ unsigned int node_num;
+ char *binary_path;
if (0 == n)
+ {
+ node_num = m;
script_num = m - 1;
+ }
else
+ {
+ node_num = (n - 1) * ns->local_m + m + ns->known;
script_num = n - 1 + (n - 1) * ns->local_m + m + ns->known;
+ }
pid = getpid ();
GNUNET_asprintf (&m_char, "%u", m);
@@ -613,6 +643,8 @@ start_helper (struct NetJailState *ns,
GNUNET_TESTING_interpreter_fail (ns->is);
}
+ binary_path = GNUNET_OS_get_libexec_binary_path (HELPER_CMDS_BINARY);
+
LOG (GNUNET_ERROR_TYPE_DEBUG,
"sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n",
ns->number_of_testsystems_started,
@@ -626,8 +658,7 @@ start_helper (struct NetJailState *ns,
char *const script_argv[] = {script_name,
m_char,
n_char,
- GNUNET_OS_get_libexec_binary_path (
- HELPER_CMDS_BINARY),
+ binary_path,
global_n_char,
local_m_char,
node_id,
@@ -643,17 +674,14 @@ start_helper (struct NetJailState *ns,
ns);
GNUNET_array_append (ns->helper, ns->n_helper, helper);
}
-
GNUNET_TESTING_add_netjail_helper (ns->is,
helper);
-
plugin_name = topology->plugin;
hkey = GNUNET_new (struct GNUNET_ShortHashCode);
- if (0 == m)
+ if (0 == n)
{
-
- GNUNET_CRYPTO_hash (&n, sizeof(n), &hc);
+ GNUNET_CRYPTO_hash (&m, sizeof(m), &hc);
memcpy (hkey,
&hc,
sizeof (*hkey));
@@ -665,11 +693,10 @@ start_helper (struct NetJailState *ns,
if (NULL != node->plugin)
plugin_name = node->plugin;
}
-
}
else
{
- GNUNET_CRYPTO_hash (&m, sizeof(m), &hc);
+ GNUNET_CRYPTO_hash (&n, sizeof(n), &hc);
memcpy (hkey,
&hc,
sizeof (*hkey));
@@ -678,7 +705,7 @@ start_helper (struct NetJailState *ns,
{
namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces,
hkey);
- GNUNET_CRYPTO_hash (&n, sizeof(n), &hc);
+ GNUNET_CRYPTO_hash (&m, sizeof(m), &hc);
memcpy (hkey,
&hc,
sizeof (*hkey));
@@ -694,7 +721,8 @@ start_helper (struct NetJailState *ns,
}
-
+ GNUNET_assert (NULL != node);
+ node->node_number = node_num;
plugin = GNUNET_new (struct TestcasePlugin);
plugin->api = GNUNET_PLUGIN_load (plugin_name,
NULL);
@@ -704,28 +732,49 @@ start_helper (struct NetJailState *ns,
for (pos = barriers->head; NULL != pos; pos = pos->next)
{
barrier = TST_interpreter_get_barrier (ns->is, pos->barrier_name);
- if (NULL == barrier || GNUNET_YES == barrier->shadow)
+ if (NULL == barrier)
{
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "barrier %s added\n",
+ pos->barrier_name);
barrier = GNUNET_new (struct GNUNET_TESTING_Barrier);
barrier->name = pos->barrier_name;
+ barrier->shadow = GNUNET_YES;
TST_interpreter_add_barrier (ns->is, barrier);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "%u %p\n",
+ barrier->reached,
+ barrier);
+
barrier->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
}
- GNUNET_assert (NULL != node);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "barrier %p %s node %u added \n",
+ barrier,
+ pos->barrier_name,
+ node->node_number);
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;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "number_to_be_reached %u\n",
+ barrier->number_to_be_reached);
+ if (GNUNET_YES == barrier->shadow)
+ barrier->number_to_be_reached++;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "number_to_be_reached %u\n",
+ barrier->number_to_be_reached);
GNUNET_CRYPTO_hash (&(node->node_number), sizeof(node->node_number), &hc);
memcpy (&key, &hc, sizeof (key));
GNUNET_CONTAINER_multishortmap_put (barrier->nodes,
&key,
- node,
+ barrier_node,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
}
- // FIXME Free barriers??
+
tbc->plugin = plugin;
msg = create_helper_init_msg_ (plugin_name);
@@ -743,8 +792,20 @@ start_helper (struct NetJailState *ns,
"Send handle is NULL!\n");
GNUNET_TESTING_interpreter_fail (ns->is);
}
+ GNUNET_free (pos);
+ GNUNET_free (binary_path);
GNUNET_free (hkey);
GNUNET_free (msg);
+ GNUNET_free (m_char);
+ GNUNET_free (n_char);
+ GNUNET_free (local_m_char);
+ GNUNET_free (global_n_char);
+ GNUNET_free (known_char);
+ GNUNET_free (node_id);
+ GNUNET_free (read_file);
+ GNUNET_free (data_dir);
+ GNUNET_free (script_name);
+ GNUNET_free (barriers);
}
@@ -783,6 +844,9 @@ netjail_exec_run (void *cls,
ns->is = is;
for (int i = 1; i <= ns->known; i++)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "i %u\n",
+ i);
start_helper (ns,
i,
0);
@@ -792,6 +856,10 @@ netjail_exec_run (void *cls,
{
for (int j = 1; j <= ns->local_m; j++)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "i %u j %u\n",
+ i,
+ j);
start_helper (ns,
j,
i);
@@ -818,7 +886,7 @@ netjail_exec_run (void *cls,
* @return command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_netjail_start_testing_system (
+GNUNET_TESTING_cmd_netjail_start_cmds_helper (
const char *label,
struct GNUNET_TESTING_NetjailTopology *topology,
unsigned int *read_file,
diff --git a/src/testing/testing_api_cmd_netjail_stop.c
b/src/testing/testing_api_cmd_netjail_stop.c
index c13d177fb..cc05617f7 100644
--- a/src/testing/testing_api_cmd_netjail_stop.c
+++ b/src/testing/testing_api_cmd_netjail_stop.c
@@ -178,6 +178,8 @@ netjail_stop_run (void *cls,
&child_completed_callback,
ns);
GNUNET_break (NULL != ns->cwh);
+ GNUNET_free (read_file);
+ GNUNET_free (pid);
}
diff --git a/src/testing/testing_api_cmd_netjail_stop_testsystem.c
b/src/testing/testing_api_cmd_netjail_stop_cmds_helper.c
similarity index 98%
rename from src/testing/testing_api_cmd_netjail_stop_testsystem.c
rename to src/testing/testing_api_cmd_netjail_stop_cmds_helper.c
index 8f63216ef..c6bb0ab52 100644
--- a/src/testing/testing_api_cmd_netjail_stop_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_stop_cmds_helper.c
@@ -123,6 +123,7 @@ stop_testing_system_run (void *cls,
GNUNET_YES);
}
}
+ GNUNET_free (helper);
}
@@ -135,7 +136,7 @@ stop_testing_system_run (void *cls,
* @return command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_stop_testing_system (
+GNUNET_TESTING_cmd_stop_cmds_helper (
const char *label,
const char *helper_start_label,
struct GNUNET_TESTING_NetjailTopology *topology)
diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c
index 7d76979dc..5385a53d7 100644
--- a/src/testing/testing_api_loop.c
+++ b/src/testing/testing_api_loop.c
@@ -40,11 +40,6 @@
*/
struct GNUNET_TESTING_Interpreter
{
- /**
- * Send handle for sending messages to netjail nodes.
- */
- struct GNUNET_HELPER_SendHandle *sh;
-
/**
* Array with handles of helper processes for communication with netjails.
*/
@@ -291,6 +286,7 @@ finish_test (void *cls)
GNUNET_free (is->commands);
is->rc (is->rc_cls,
is->result);
+ GNUNET_free (is->helper);
GNUNET_free (is);
}
@@ -618,11 +614,7 @@ loop_run (void *cls)
static void
clear_msg (void *cls, int result)
{
- struct GNUNET_TESTING_Interpreter *is = cls;
-
- GNUNET_assert (NULL != is->sh);
- GNUNET_free (is->sh);
- is->sh = NULL;
+ GNUNET_assert (GNUNET_YES == result);
}
/**
@@ -640,14 +632,14 @@ GNUNET_TESTING_add_netjail_helper (struct
GNUNET_TESTING_Interpreter *is,
/**
- * Send Message to netjail nodes that a barrier can be advanced.
+ * Send Message to netjail nodes.
*
* @param is The interpreter.
- * @param global_node_number The node to inform.
+ * @param global_node_number The netjail node to inform.
* @param header The message to send.
*/
void
-GNUNET_TESTING_send_message_to_netjail (struct GNUNET_TESTING_Interpreter *is,
+send_message_to_netjail (struct GNUNET_TESTING_Interpreter *is,
unsigned int global_node_number,
struct GNUNET_MessageHeader *header)
{
@@ -655,31 +647,36 @@ GNUNET_TESTING_send_message_to_netjail (struct
GNUNET_TESTING_Interpreter *is,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"send message of type %u to locals\n",
- header->type);
+ ntohs (header->type));
helper = is->helper[global_node_number - 1];
struct GNUNET_HELPER_SendHandle *sh = GNUNET_HELPER_send (
(struct GNUNET_HELPER_Handle *) helper,
header,
GNUNET_NO,
&clear_msg,
- is);
+ NULL);
}
void
-TST_interpreter_send_barrier_advance (struct GNUNET_TESTING_Interpreter *is,
+TST_interpreter_send_barrier_crossable (struct GNUNET_TESTING_Interpreter *is,
const char *barrier_name,
unsigned int global_node_number)
{
- struct CommandBarrierAdvanced *adm = GNUNET_new (struct
- CommandBarrierAdvanced);
- size_t msg_length = sizeof(struct CommandBarrierAdvanced);
+ struct CommandBarrierCrossable *adm;
+ size_t msg_length;
size_t name_len;
+ char *terminator = "\0";
- name_len = strlen (barrier_name) + 1;
- adm->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "send barrier name %s barrier_name\n",
+ barrier_name);
+ name_len = strlen (barrier_name);
+ msg_length = sizeof(struct CommandBarrierCrossable) + name_len + 1;
+ adm = GNUNET_malloc (msg_length);
+ adm->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE);
adm->header.size = htons ((uint16_t) msg_length);
memcpy (&adm[1], barrier_name, name_len);
- GNUNET_TESTING_send_message_to_netjail (is,
+ send_message_to_netjail (is,
global_node_number,
&adm->header);
GNUNET_free (adm);
@@ -697,13 +694,17 @@ free_barrier_node_cb (void *cls,
struct GNUNET_TESTING_Barrier *barrier = free_barrier_node_cb_cls->barrier;
struct GNUNET_TESTING_Interpreter *is = free_barrier_node_cb_cls->is;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "free_barrier_node_cb\n");
if (GNUNET_NO == is->finishing)
{
- TST_interpreter_send_barrier_advance (is,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "TST_interpreter_send_barrier_crossable\n");
+ TST_interpreter_send_barrier_crossable (is,
barrier->name,
node->node_number);
}
- GNUNET_CONTAINER_multishortmap_remove (barrier->nodes, key, node);
+ GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multishortmap_remove
(barrier->nodes, key, node));
return GNUNET_YES;
}
@@ -728,7 +729,6 @@ TST_interpreter_get_barrier (struct
GNUNET_TESTING_Interpreter *is,
&hc,
sizeof (create_key));
barrier = GNUNET_CONTAINER_multishortmap_get (is->barriers, &create_key);
- // GNUNET_free (create_key);
return barrier;
}
@@ -747,11 +747,17 @@ TST_interpreter_finish_attached_cmds (struct
GNUNET_TESTING_Interpreter *is,
struct GNUNET_TESTING_Barrier *barrier = TST_interpreter_get_barrier (is,
barrier_name);
- while (NULL != (pos = barrier->cmds_head))
+ while (NULL != barrier && NULL != (pos = barrier->cmds_head))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "command label %s\n",
+ pos->command->label);
if (GNUNET_NO == pos->command->ac->finished &&
GNUNET_NO == pos->command->asynchronous_finish)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "command label %s finish\n",
+ pos->command->label);
GNUNET_TESTING_async_finish (pos->command->ac);
}
else if (GNUNET_NO == pos->command->ac->finished)
@@ -761,18 +767,28 @@ TST_interpreter_finish_attached_cmds (struct
GNUNET_TESTING_Interpreter *is,
GNUNET_CONTAINER_DLL_remove (barrier->cmds_head,
barrier->cmds_tail,
pos);
- // FIXME: DANGER DANGER! "pos" is a pointer to the array(!) element in an
- // IS. This WILL crash and burn
- GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "command entry label %s removed\n",
+ pos->command->label);
GNUNET_free (pos);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "command entry freed\n");
+ }
+ if (NULL != barrier->nodes)
+ {
+ free_barrier_node_cb_cls = GNUNET_new (struct FreeBarrierNodeCbCls);
+ free_barrier_node_cb_cls->barrier = barrier;
+ free_barrier_node_cb_cls->is = is;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "freeing nodes\n");
+ GNUNET_CONTAINER_multishortmap_iterate (barrier->nodes,
free_barrier_node_cb,
+ free_barrier_node_cb_cls);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "nodes freed\n");
+ GNUNET_free (free_barrier_node_cb_cls);
+ GNUNET_CONTAINER_multishortmap_destroy (barrier->nodes);
+ barrier->nodes = NULL;
}
- 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_destroy (barrier->nodes);
- GNUNET_free (free_barrier_node_cb_cls);
}
@@ -786,12 +802,16 @@ free_barriers_cb (void *cls,
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_destroy (barrier->nodes);
+ if (NULL != barrier->nodes)
+ {
+ 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_destroy (barrier->nodes);
+ barrier->nodes = NULL;
+ }
while (NULL != (pos = barrier->cmds_head))
{
diff --git a/src/testing/testing_cmds.h b/src/testing/testing_cmds.h
index a5ea59a3a..9c261aab5 100644
--- a/src/testing/testing_cmds.h
+++ b/src/testing/testing_cmds.h
@@ -78,12 +78,17 @@ struct GNUNET_TESTING_CommandAllPeersStarted
struct GNUNET_MessageHeader header;
};
-struct GNUNET_CMDS_LOCAL_FINISHED
+struct GNUNET_TESTING_CommandLocalFinished
{
/**
* Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED
*/
struct GNUNET_MessageHeader header;
+
+ /**
+ * The exit status local test return with.
+ */
+ enum GNUNET_GenericReturnValue rv;
};
@@ -105,5 +110,34 @@ struct GNUNET_TESTING_CommandAllLocalTestsPrepared
GNUNET_NETWORK_STRUCT_END
+/**
+ * Global state of the interpreter, used by a command
+ * to access information about other commands.
+ */
+struct GNUNET_TESTING_Interpreter;
+
+
+/**
+ * Returns the actual running command.
+ *
+ * @param is Global state of the interpreter, used by a command
+ * to access information about other commands.
+ * @return The actual running command.
+ */
+struct GNUNET_TESTING_Command *
+GNUNET_TESTING_interpreter_get_current_command (
+ struct GNUNET_TESTING_Interpreter *is);
+
+
+/**
+ * Adding a helper handle to the interpreter.
+ *
+ * @param is The interpreter.
+ * @param helper The helper handle.
+ */
+void
+GNUNET_TESTING_add_netjail_helper (struct GNUNET_TESTING_Interpreter *is,
+ const struct GNUNET_HELPER_Handle *helper);
+
#endif
/* end of testing_cmds.h */
diff --git a/src/transport/test_transport_api2_tcp_node1.conf
b/src/transport/test_transport_api2_tcp_node1.conf
index d396f43d7..37b6f08d1 100644
--- a/src/transport/test_transport_api2_tcp_node1.conf
+++ b/src/transport/test_transport_api2_tcp_node1.conf
@@ -8,6 +8,9 @@ PLUGINS = tcp
#PREFIX = valgrind --leak-check=full --track-origins=yes --trace-children=yes
--log-file=$GNUNET_TEST_HOME/vg_peer1-%p
UNIXPATH = $GNUNET_RUNTIME_DIR/tng-p1.sock
+[PEER]
+PRIVATE_KEY = $GNUNET_RUNTIME_DIR/private.key
+
[communicator-tcp]
BINARY = gnunet-communicator-tcp
BINDTO = 192.168.15.1:60002
diff --git a/src/transport/test_transport_nat_upnp.sh
b/src/transport/test_transport_nat_upnp.sh
index f9dfca71f..df43ef320 100755
--- a/src/transport/test_transport_nat_upnp.sh
+++ b/src/transport/test_transport_nat_upnp.sh
@@ -9,3 +9,4 @@ if [ -f /proc/sys/kernel/unprivileged_userns_clone ]; then
fi
fi
exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns;
./test_transport_start_with_config test_transport_nat_upnp_topo.conf"
+#sudo valgrind --vgdb=yes --leak-check=full --track-origins=yes
--trace-children=yes
--trace-children-skip=/usr/bin/awk,/usr/bin/cut,/usr/bin/seq,/sbin/ip/sed/bash
./test_transport_start_with_config test_transport_nat_upnp_topo.conf
diff --git a/src/transport/test_transport_plugin_cmd_nat_upnp.c
b/src/transport/test_transport_plugin_cmd_nat_upnp.c
index 91255a9fe..1b02fbfc2 100644
--- a/src/transport/test_transport_plugin_cmd_nat_upnp.c
+++ b/src/transport/test_transport_plugin_cmd_nat_upnp.c
@@ -146,7 +146,7 @@ handle_result (void *cls,
"Local test exits with status %d\n",
rv);
- ts->finished_cb ();
+ ts->finished_cb (rv);
GNUNET_free (ts->testdir);
GNUNET_free (ts->cfgname);
GNUNET_TESTING_free_topology (ts->topology);
@@ -201,10 +201,17 @@ all_local_tests_prepared ()
*
* @param write_message Callback to send a message to the master loop.
* @param router_ip Global address of the network namespace.
- * @param node_ip Local address of a node i a network namespace.
+ * @param node_ip The IP address of the node.
* @param m The number of the node in a network namespace.
* @param n The number of the network namespace.
* @param local_m The number of nodes in a network namespace.
+ * @param topology_data A file name for the file containing the topology
configuration, or a string containing
+ * the topology configuration.
+ * @param read_file If read_file is GNUNET_YES this string is the filename for
the topology configuration,
+ * if read_file is GNUNET_NO the string contains the topology
configuration.
+ * @param finish_cb Callback function which writes a message from the helper
process running on a netjail
+ * node to the master process * signaling that the test case
running on the netjail node finished.
+ * @return Returns the struct GNUNET_TESTING_Interpreter of the command loop
running on this netjail node.
*/
static struct GNUNET_TESTING_Interpreter *
start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message,
@@ -321,9 +328,12 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb
write_message,
ts->cfgname,
notify_connect,
GNUNET_NO),
- GNUNET_TESTING_cmd_barrier_create ("ready-to-connect",
- 0.0,
- 2),
+ GNUNET_TESTING_cmd_barrier_reached ("ready-to-connect-reached",
+ "ready-to-connect",
+ GNUNET_NO,
+ num,
+ GNUNET_NO,
+ write_message),
connect_peers,
GNUNET_TRANSPORT_cmd_send_simple ("send-simple",
"start-peer",
@@ -331,9 +341,12 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb
write_message,
num,
topology),
block_receive,
- GNUNET_TESTING_cmd_barrier_create ("test-case-finished",
- 0.0,
- 2),
+ GNUNET_TESTING_cmd_barrier_reached ("test-case-finished-reached",
+ "test-case-finished",
+ GNUNET_NO,
+ num,
+ GNUNET_NO,
+ write_message),
GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer",
"start-peer"),
GNUNET_TESTING_cmd_system_destroy ("system-destroy",
@@ -368,8 +381,6 @@ libgnunet_test_transport_plugin_cmd_nat_upnp_init (void
*cls)
api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
api->start_testcase = &start_testcase;
- api->all_peers_started = &all_peers_started;
- api->all_local_tests_prepared = all_local_tests_prepared;
api->get_waiting_for_barriers = get_waiting_for_barriers;
return api;
}
@@ -378,11 +389,11 @@ libgnunet_test_transport_plugin_cmd_nat_upnp_init (void
*cls)
/**
* Exit point from the plugin.
*
- * @param cls the return value from
#libgnunet_test_transport_plugin_block_test_init
+ * @param cls the return value from
#libgnunet_test_transport_plugin_nat_upnp_init
* @return NULL
*/
void *
-libgnunet_test_transport_plugin_cmd_simple_send_done (void *cls)
+libgnunet_test_transport_plugin_cmd_nat_upnp_done (void *cls)
{
struct GNUNET_TESTING_PluginFunctions *api = cls;
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c
b/src/transport/test_transport_plugin_cmd_simple_send.c
index 632c522c9..375796dff 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send.c
@@ -130,7 +130,7 @@ handle_result (void *cls,
"Local test exits with status %d\n",
rv);
- ts->finished_cb ();
+ ts->finished_cb (rv);
GNUNET_free (ts->testdir);
GNUNET_free (ts->cfgname);
GNUNET_TESTING_free_topology (ts->topology);
@@ -185,7 +185,7 @@ all_local_tests_prepared ()
*
* @param write_message Callback to send a message to the master loop.
* @param router_ip Global address of the network namespace.
- * @param node_ip Local address of a node i a network namespace.
+ * @param node_ip The IP address of the node.
* @param m The number of the node in a network namespace.
* @param n The number of the network namespace.
* @param local_m The number of nodes in a network namespace.
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 2f84b8213..7381b1d7e 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
@@ -131,7 +131,7 @@ handle_result (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Local test exits with status %d\n",
rv);
- ts->finished_cb ();
+ ts->finished_cb (rv);
GNUNET_free (ts->testdir);
GNUNET_free (ts->cfgname);
GNUNET_TESTING_free_topology (ts->topology);
@@ -218,7 +218,7 @@ all_local_tests_prepared ()
*
* @param write_message Callback to send a message to the master loop.
* @param router_ip Global address of the network namespace.
- * @param node_ip Local address of a node i a network namespace.
+ * @param node_ip The IP address of the node.
* @param m The number of the node in a network namespace.
* @param n The number of the network namespace.
* @param local_m The number of nodes in a network namespace.
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 4da03d155..55ab4a48f 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send_dv.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send_dv.c
@@ -183,7 +183,7 @@ handle_result (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Local test exits with status %d\n",
rv);
- ts->finished_cb ();
+ ts->finished_cb (rv);
GNUNET_free (ts->testdir);
GNUNET_free (ts->cfgname);
GNUNET_TESTING_free_topology (ts->topology);
@@ -241,7 +241,7 @@ all_local_tests_prepared ()
*
* @param write_message Callback to send a message to the master loop.
* @param router_ip Global address of the network namespace.
- * @param node_ip Local address of a node i a network namespace.
+ * @param node_ip The IP address of the node.
* @param m The number of the node in a network namespace.
* @param n The number of the network namespace.
* @param local_m The number of nodes in a network namespace.
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c
b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
index 7a26a89d8..5e931fbe3 100644
--- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c
+++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
@@ -128,7 +128,7 @@ handle_result (void *cls,
"Local test exits with status %d\n",
rv);
- ts->finished_cb ();
+ ts->finished_cb (rv);
GNUNET_free (ts->testdir);
GNUNET_free (ts->cfgname);
GNUNET_TESTING_free_topology (ts->topology);
@@ -178,7 +178,7 @@ all_local_tests_prepared ()
*
* @param write_message Callback to send a message to the master loop.
* @param router_ip Global address of the network namespace.
- * @param node_ip Local address of a node i a network namespace.
+ * @param node_ip The IP address of the node.
* @param m The number of the node in a network namespace.
* @param n The number of the network namespace.
* @param local_m The number of nodes in a network namespace.
diff --git a/src/transport/test_transport_simple_send_dv_circle.sh
b/src/transport/test_transport_simple_send_dv_circle.sh
index 353d14f65..bd5f00abe 100755
--- a/src/transport/test_transport_simple_send_dv_circle.sh
+++ b/src/transport/test_transport_simple_send_dv_circle.sh
@@ -9,4 +9,3 @@ if [ -f /proc/sys/kernel/unprivileged_userns_clone ]; then
fi
fi
exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns;
./test_transport_start_with_config
test_transport_distance_vector_circle_topo.conf"
-# sudo valgrind --leak-check=full --track-origins=yes --trace-children=yes
--trace-children-skip=/usr/bin/awk,/usr/bin/cut,/usr/bin/seq,/sbin/ip/sed/bash
./test_transport_start_with_config
test_transport_distance_vector_circle_topo.conf
diff --git a/src/transport/test_transport_start_with_config.c
b/src/transport/test_transport_start_with_config.c
index 0c3271436..c4b6c55ad 100644
--- a/src/transport/test_transport_start_with_config.c
+++ b/src/transport/test_transport_start_with_config.c
@@ -94,12 +94,12 @@ main (int argc,
GNUNET_TESTING_cmd_netjail_start ("netjail-start",
topology_data_script,
&read_file),
- GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed",
+ GNUNET_TESTING_cmd_netjail_start_cmds_helper ("netjail-start-testbed",
topology,
&read_file,
topology_data_script,
TIMEOUT),
- GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed",
+ GNUNET_TESTING_cmd_stop_cmds_helper ("stop-testbed",
"netjail-start-testbed",
topology),
GNUNET_TESTING_cmd_netjail_stop ("netjail-stop",
diff --git a/src/transport/transport-testing-cmds.h
b/src/transport/transport-testing-cmds.h
index 1088f2e5b..46f6045dc 100644
--- a/src/transport/transport-testing-cmds.h
+++ b/src/transport/transport-testing-cmds.h
@@ -116,7 +116,9 @@ struct StartPeerState
*/
struct GNUNET_MQ_MessageHandler *handlers;
- //FIXME documentation
+ /**
+ * GNUnet configuration file used to start a peer.
+ */
char *cfgname;
/**
@@ -124,7 +126,9 @@ struct StartPeerState
*/
struct GNUNET_CONFIGURATION_Handle *cfg;
- //FIXME documentation
+ /**
+ * struct GNUNET_TESTING_Peer returned by GNUNET_TESTING_peer_configure.
+ */
struct GNUNET_TESTING_Peer *peer;
/**
@@ -167,13 +171,9 @@ struct StartPeerState
*/
size_t hello_size;
- /** All of the below: FIXME documentation */
- char *m;
-
- char *n;
-
- char *local_m;
-
+ /**
+ * The label of the command which was started by calling
GNUNET_TESTING_cmd_system_create.
+ */
char *system_label;
/**
@@ -181,10 +181,20 @@ struct StartPeerState
*/
unsigned int no;
+ /**
+ * A map with struct GNUNET_MQ_Handle values for each peer this peer
+ * is connected to.
+ */
struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
+ /**
+ * Test setup for this peer.
+ */
const struct GNUNET_TESTING_System *tl_system;
+ /**
+ * Callback which is called on neighbour connect events.
+ */
GNUNET_TRANSPORT_notify_connect_cb notify_connect;
/**
@@ -227,14 +237,11 @@ struct TestState
/**
* Create command.
- * FIXME: Parameter list does not match documentation.
- * FIXME: m and n parameters need a rename.
*
* @param label name for command.
* @param system_label Label of the cmd to setup a test environment.
- * @param m The number of the local node of the actual network namespace.
- * @param n The number of the actual namespace.
- * @param local_m Number of local nodes in each namespace.
+ * @param no Decimal number representing the last byte of the IP address of
this peer.
+ * @param node_ip The IP address of this node.
* @param handlers Handler for messages received by this peer.
* @param cfgname Configuration file name for this peer.
* @param notify_connect Method which will be called, when a peer connects.
diff --git a/src/transport/transport_api_cmd_backchannel_check.c
b/src/transport/transport_api_cmd_backchannel_check.c
index 9f62281a4..d672e3ae8 100644
--- a/src/transport/transport_api_cmd_backchannel_check.c
+++ b/src/transport/transport_api_cmd_backchannel_check.c
@@ -351,12 +351,12 @@ add_search_string (struct CheckState *cs, const struct
+ cs->topology->nodes_x;
// num = GNUNET_TESTING_calculate_num (pos_connection, cs->topology);
- peer = GNUNET_TESTING_get_pub_key (num, cs->tl_system);
+ peer = GNUNET_TESTING_get_peer (num, cs->tl_system);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"peer: %s num %u\n",
GNUNET_i2s (peer),
num);
- us = GNUNET_TESTING_get_pub_key (cs->num, cs->tl_system);
+ us = GNUNET_TESTING_get_peer (cs->num, cs->tl_system);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"us: %s cs->num %d\n",
GNUNET_i2s (us),
diff --git a/src/transport/transport_api_cmd_connecting_peers.c
b/src/transport/transport_api_cmd_connecting_peers.c
index 528e05b5f..d399e9d0a 100644
--- a/src/transport/transport_api_cmd_connecting_peers.c
+++ b/src/transport/transport_api_cmd_connecting_peers.c
@@ -112,7 +112,7 @@ connect_peers_run (void *cls,
GNUNET_asprintf (&addr_and_port,
"%s:60002",
addr);
- peer = GNUNET_TESTING_get_pub_key (num, tl_system);
+ peer = GNUNET_TESTING_get_peer (num, tl_system);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"validating peer number %u with identity %s and address %s
%u %s\n",
num,
@@ -160,7 +160,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is,
pos_connection = pos_connection->next)
{
num = GNUNET_TESTING_calculate_num (pos_connection, cps->topology);
- peer_connection = GNUNET_TESTING_get_pub_key (num, cps->tl_system);
+ peer_connection = GNUNET_TESTING_get_peer (num, cps->tl_system);
if (0 == GNUNET_memcmp (peer,
peer_connection))
cps->con_num_notified++;
diff --git a/src/transport/transport_api_cmd_start_peer.c
b/src/transport/transport_api_cmd_start_peer.c
index 0677b6227..516f8d0aa 100644
--- a/src/transport/transport_api_cmd_start_peer.c
+++ b/src/transport/transport_api_cmd_start_peer.c
@@ -64,6 +64,9 @@ hello_iter_cb (void *cb_cls,
memcpy (sps->hello, record->value, sps->hello_size);
sps->hello[sps->hello_size - 1] = '\0';
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Our hello %s\n",
+ sps->hello);
GNUNET_PEERSTORE_iterate_cancel (sps->pic);
sps->pic = NULL;
GNUNET_TESTING_async_finish (&sps->ac);
diff --git a/src/transport/transport_api_cmd_stop_peer.c
b/src/transport/transport_api_cmd_stop_peer.c
index 1fdd48fa6..a80742b5f 100644
--- a/src/transport/transport_api_cmd_stop_peer.c
+++ b/src/transport/transport_api_cmd_stop_peer.c
@@ -72,6 +72,8 @@ stop_peer_run (void *cls,
}
if (NULL != sps->th)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Disconnecting from TRANSPORT service\n");
GNUNET_TRANSPORT_core_disconnect (sps->th);
}
if (NULL != sps->ah)
--
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: - relsoved an coverity issue, worked on fixmes, code documentation and cleaned up up the barrier API,
gnunet <=