[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: - Fixed header, fixed log level, changed
From: |
gnunet |
Subject: |
[gnunet] branch master updated: - Fixed header, fixed log level, changed block until connect logic, fixed memory issues. |
Date: |
Fri, 19 Nov 2021 15:29:58 +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 6a043a922 - Fixed header, fixed log level, changed block until connect
logic, fixed memory issues.
new 7e5fdf075 Merge branch 'master' of ssh://git.gnunet.org/gnunet
6a043a922 is described below
commit 6a043a9228022fcce97fd50739db74abdabde055
Author: t3sserakt <t3ss@posteo.de>
AuthorDate: Fri Nov 19 15:18:24 2021 +0100
- Fixed header, fixed log level, changed block until connect logic, fixed
memory issues.
---
contrib/netjail/netjail_exec.sh | 1 +
src/include/gnunet_testing_netjail_lib.h | 91 ++++-
src/include/gnunet_testing_ng_lib.h | 452 +++------------------
src/testing/gnunet-cmds-helper.c | 6 +-
src/testing/testing.c | 93 +++--
.../testing_api_cmd_block_until_external_trigger.c | 61 ++-
src/testing/testing_api_cmd_netjail_start.c | 4 +
src/testing/testing_api_cmd_netjail_stop.c | 1 +
src/testing/testing_api_loop.c | 116 +++++-
src/transport/Makefile.am | 3 +-
src/transport/gnunet-communicator-tcp.c | 17 +-
.../test_communicator_tcp_basic_peer1.conf | 2 +-
src/transport/test_transport_api2_tcp_node1.conf | 1 +
.../test_transport_plugin_cmd_simple_send.c | 22 +-
...st_transport_plugin_cmd_simple_send_broadcast.c | 56 ++-
.../test_transport_plugin_cmd_udp_backchannel.c | 17 +-
src/transport/test_transport_simple_send.sh | 5 +-
.../test_transport_simple_send_broadcast.sh | 6 +-
src/transport/test_transport_simple_send_string.sh | 7 +-
src/transport/test_transport_udp_backchannel.sh | 5 +-
src/transport/transport-testing-cmds.h | 11 +-
src/transport/transport_api_cmd_connecting_peers.c | 13 +-
src/transport/transport_api_cmd_start_peer.c | 17 +-
23 files changed, 455 insertions(+), 552 deletions(-)
diff --git a/contrib/netjail/netjail_exec.sh b/contrib/netjail/netjail_exec.sh
index ab4aad5b8..fa68d90d4 100755
--- a/contrib/netjail/netjail_exec.sh
+++ b/contrib/netjail/netjail_exec.sh
@@ -11,4 +11,5 @@ N=$2
NODE=$6
+#netjail_node_exec_without_fds_and_sudo $NODE valgrind --leak-check=full
--track-origins=yes --trace-children=yes $3 $4 $5 $1 $2 $7 $8
netjail_node_exec_without_fds_and_sudo $NODE $3 $4 $5 $1 $2 $7 $8
diff --git a/src/include/gnunet_testing_netjail_lib.h
b/src/include/gnunet_testing_netjail_lib.h
index 3a5e9f749..334f43c88 100644
--- a/src/include/gnunet_testing_netjail_lib.h
+++ b/src/include/gnunet_testing_netjail_lib.h
@@ -24,8 +24,8 @@
* @author Marcello Stanisci
* @author t3sserakt
*/
-#ifndef GNUNET_TESTING_NG_LIB_H
-#define GNUNET_TESTING_NG_LIB_H
+#ifndef GNUNET_TESTING_NETJAIL_LIB_H
+#define GNUNET_TESTING_NETJAIL_LIB_H
#include "gnunet_util_lib.h"
#include "gnunet_testing_plugin.h"
@@ -300,6 +300,28 @@ GNUNET_TESTING_calculate_num (struct
struct GNUNET_TESTING_NetjailTopology *topology);
+/**
+ * Struct with information for callbacks.
+ *
+ */
+struct BlockState
+{
+ /**
+ * Context for our asynchronous completion.
+ */
+ struct GNUNET_TESTING_AsyncContext ac;
+
+ /**
+ * The label of this command.
+ */
+ const char *label;
+
+ /**
+ * If this command will block.
+ */
+ unsigned int asynchronous_finish;
+};
+
/**
* Struct to hold information for callbacks.
*
@@ -309,7 +331,7 @@ struct LocalPreparedState
/**
* Context for our asynchronous completion.
*/
- struct GNUNET_TESTING_AsyncContext *ac;
+ struct GNUNET_TESTING_AsyncContext ac;
/**
* Callback to write messages to the master loop.
@@ -319,11 +341,28 @@ struct LocalPreparedState
};
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_system_destroy (const char *label,
+ const char *create_label);
+
+
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_system_create (const char *label,
+ const char *testdir);
+
+
+int
+GNUNET_TESTING_get_trait_test_system (const struct
+ GNUNET_TESTING_Command *cmd,
+ struct GNUNET_TESTING_System
**test_system);
+
+
/**
* Create command.
*
* @param label name for command.
* @param topology_config Configuration file for the test topology.
+ * @param read_file Flag indicating if the the name of the topology file is
send to the helper, or a string with the topology data.
* @return command.
*/
struct GNUNET_TESTING_Command
@@ -335,27 +374,32 @@ GNUNET_TESTING_cmd_netjail_start (const char *label,
/**
* Create command.
*
- * @param label Name for the command.
- * @param topology The complete topology information.
+ * @param label name for command.
+ * @param topology_config Configuration file for the test topology.
+ * @param read_file Flag indicating if the the name of the topology file is
send to the helper, or a string with the topology data.
* @return command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_netjail_start_testing_system (
- const char *label,
- struct GNUNET_TESTING_NetjailTopology *topology);
+GNUNET_TESTING_cmd_netjail_stop (const char *label,
+ char *topology_config,
+ unsigned int *read_file);
/**
* Create command.
*
- * @param label name for command.
- * @param topology_config Configuration file for the test topology.
+ * @param label Name for the command.
+ * @param topology The complete topology information.
+ * @param read_file Flag indicating if the the name of the topology file is
send to the helper, or a string with the topology data.
+ * @param topology_data If read_file is GNUNET_NO, topology_data holds the
string with the topology.
* @return command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_netjail_stop (const char *label,
- char *topology_config,
- unsigned int *read_file);
+GNUNET_TESTING_cmd_netjail_start_testing_system (
+ const char *label,
+ struct GNUNET_TESTING_NetjailTopology *topology,
+ unsigned int *read_file,
+ char *topology_data);
/**
@@ -414,10 +458,19 @@ GNUNET_TESTING_cmd_block_until_all_peers_started (
unsigned int *all_peers_started);
+/**
+ * Create command.
+ *
+ * @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
GNUNET_TESTING_cmd_block_until_external_trigger (
const char *label);
+
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_send_peer_ready (const char *label,
TESTING_CMD_HELPER_write_cb write_message);
@@ -460,4 +513,16 @@ GNUNET_TESTING_get_trait_local_prepared_state (
const struct GNUNET_TESTING_Command *cmd,
struct LocalPreparedState **lfs);
+
+/**
+ * Function to get the trait with the internal command state BlockState.
+ *
+ * * @param[out] ac struct BlockState.
+* @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
+ */
+int
+GNUNET_TESTING_get_trait_block_state (
+ const struct GNUNET_TESTING_Command *cmd,
+ struct BlockState **bs);
+
#endif
diff --git a/src/include/gnunet_testing_ng_lib.h
b/src/include/gnunet_testing_ng_lib.h
index 2d040ac21..5011aefd8 100644
--- a/src/include/gnunet_testing_ng_lib.h
+++ b/src/include/gnunet_testing_ng_lib.h
@@ -47,212 +47,6 @@
} while (0)
-/**
- * Router of a network namespace.
- * // FIXME: this does not belong here!
- */
-struct GNUNET_TESTING_NetjailRouter
-{
- /**
- * Will tcp be forwarded?
- */
- unsigned int tcp_port;
-
- /**
- * Will udp be forwarded?
- */
- unsigned int udp_port;
-};
-
-
-/**
- * Enum for the different types of nodes.
- * // FIXME: this does not belong here!
- */
-enum GNUNET_TESTING_NODE_TYPE
-{
- /**
- * Node in a subnet.
- */
- GNUNET_TESTING_SUBNET_NODE,
-
- /**
- * Global known node.
- */
- GNUNET_TESTING_GLOBAL_NODE
-};
-
-
-// FIXME: this does not belong here!
-struct GNUNET_TESTING_AddressPrefix
-{
- /**
- * Pointer to the previous prefix in the DLL.
- */
- struct GNUNET_TESTING_AddressPrefix *prev;
-
- /**
- * Pointer to the next prefix in the DLL.
- */
- struct GNUNET_TESTING_AddressPrefix *next;
-
- /**
- * The address prefix.
- */
- char *address_prefix;
-};
-
-
-// FIXME: this does not belong here!
-struct GNUNET_TESTING_NetjailNode;
-
-/**
- * Connection to another node.
- * // FIXME: this does not belong here!
- */
-struct GNUNET_TESTING_NodeConnection
-{
- /**
- * Pointer to the previous connection in the DLL.
- */
- struct GNUNET_TESTING_NodeConnection *prev;
-
- /**
- * Pointer to the next connection in the DLL.
- */
- struct GNUNET_TESTING_NodeConnection *next;
-
- /**
- * The number of the subnet of the node this connection points to. This is 0,
- * if the node is a global known node.
- */
- unsigned int namespace_n;
-
- /**
- * The number of the node this connection points to.
- */
- unsigned int node_n;
-
- /**
- * The type of the node this connection points to.
- */
- enum GNUNET_TESTING_NODE_TYPE node_type;
-
- /**
- * The node which establish the connection
- */
- struct GNUNET_TESTING_NetjailNode *node;
-
- /**
- * Head of the DLL with the address prefixes for the protocolls this node is
reachable.
- */
- struct GNUNET_TESTING_AddressPrefix *address_prefixes_head;
-
- /**
- * Tail of the DLL with the address prefixes for the protocolls this node is
reachable.
- */
- struct GNUNET_TESTING_AddressPrefix *address_prefixes_tail;
-};
-
-/**
- * Node in the netjail topology.
- * // FIXME: this does not belong here!
- */
-struct GNUNET_TESTING_NetjailNode
-{
- /**
- * Plugin for the test case to be run on this node.
- */
- char *plugin;
-
- /**
- * Flag indicating if this node is a global known node.
- */
- unsigned int is_global;
-
- /**
- * The number of the namespace this node is running in.
- */
- unsigned int namespace_n;
-
- /**
- * The number of this node in the namespace.
- */
- unsigned int node_n;
-
- /**
- * Head of the DLL with the connections which shall be established to other
nodes.
- */
- struct GNUNET_TESTING_NodeConnection *node_connections_head;
-
- /**
- * Tail of the DLL with the connections which shall be established to other
nodes.
- */
- struct GNUNET_TESTING_NodeConnection *node_connections_tail;
-};
-
-
-/**
- * Namespace in a topology.
- * // FIXME: this does not belong here!
- */
-struct GNUNET_TESTING_NetjailNamespace
-{
- /**
- * The number of the namespace.
- */
- unsigned int namespace_n;
-
- /**
- * Router of the namespace.
- */
- struct GNUNET_TESTING_NetjailRouter *router;
-
- /**
- * Hash map containing the nodes in this namespace.
- */
- struct GNUNET_CONTAINER_MultiShortmap *nodes;
-};
-
-/**
- * Toplogy of our netjail setup.
- * // FIXME: this does not belong here!
- */
-struct GNUNET_TESTING_NetjailTopology
-{
-
- /**
- * Default plugin for the test case to be run on nodes.
- */
- char *plugin;
-
- /**
- * Number of namespaces.
- */
- unsigned int namespaces_n;
-
- /**
- * Number of nodes per namespace.
- */
- unsigned int nodes_m;
-
- /**
- * Number of global known nodes per namespace.
- */
- unsigned int nodes_x;
-
- /**
- * Hash map containing the namespaces (for natted nodes) of the topology.
- */
- struct GNUNET_CONTAINER_MultiShortmap *map_namespaces;
-
- /**
- * Hash map containing the global known nodes which are not natted.
- */
- struct GNUNET_CONTAINER_MultiShortmap *map_globals;
-};
-
-
/* ******************* Generic interpreter logic ************ */
/**
@@ -284,7 +78,7 @@ struct GNUNET_TESTING_AsyncContext
/**
* Indication if the command finished (#GNUNET_OK).
- * #GNUNET_NO if it is still running,
+ * #GNUNET_NO if it did not finish,
* #GNUNET_SYSERR if it failed.
*/
enum GNUNET_GenericReturnValue finished;
@@ -409,6 +203,20 @@ struct GNUNET_TESTING_Command
};
+/**
+ * Lookup command by label.
+ * Only future commands are looked up.
+ *
+ * @param is interpreter to lookup command in
+ * @param label label of the command to lookup.
+ * @return the command, if it is found, or NULL.
+ */
+const struct GNUNET_TESTING_Command *
+GNUNET_TESTING_interpreter_lookup_future_command (
+ struct GNUNET_TESTING_Interpreter *is,
+ const char *label);
+
+
/**
* Lookup command by label.
*
@@ -569,6 +377,39 @@ GNUNET_TESTING_has_in_name (const char *prog,
/* ************** Specific interpreter commands ************ */
+
+/**
+ * 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);
+
+
+/**
+ * Check if the command is running.
+ *
+ * @param cmd The command to check.
+ * @return GNUNET_NO if the command is not running, GNUNET_YES if it is
running.
+ */
+enum GNUNET_GenericReturnValue
+GNUNET_TESTING_running (const struct GNUNET_TESTING_Command *command);
+
+
+/**
+ * Check if a command is finished.
+ *
+ * @param cmd The command to check.
+ * @return GNUNET_NO if the command is not finished, GNUNET_YES if it is
finished.
+ */
+enum GNUNET_GenericReturnValue
+GNUNET_TESTING_finished (struct GNUNET_TESTING_Command *command);
+
+
/**
* Create a "signal" CMD.
*
@@ -1062,201 +903,4 @@ GNUNET_TESTING_make_trait_relative_time (
unsigned int index,
const struct GNUNET_TIME_Relative *time);
-
-// FIXME: move these commands into a separate libgnunetestingnetjail lib or so!
-
-/**
- * Struct to hold information for callbacks.
- *
- */
-struct LocalPreparedState
-{
- /**
- * Context for our asynchronous completion.
- */
- struct GNUNET_TESTING_AsyncContext ac;
-
- /**
- * Callback to write messages to the master loop.
- *
- */
- TESTING_CMD_HELPER_write_cb write_message;
-};
-
-
-/**
- * Offer data from trait
- *
- * @param cmd command to extract the url from.
- * @param pt which url is to be picked, in case
- * multiple are offered.
- * @param[out] url where to write the url.
- * @return #GNUNET_OK on success.
- */
-int
-GNUNET_TESTING_get_trait_what_am_i (const struct GNUNET_TESTING_Command *cmd,
- char **what_am_i);
-
-
-int
-GNUNET_TESTING_get_trait_test_system (const struct
- GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTING_System
**test_system);
-
-
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_system_create (const char *label,
- const char *testdir);
-
-
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_system_destroy (const char *label,
- const char *create_label);
-
-
-/**
- * Create command.
- *
- * @param label name for command.
- * @param topology_config Configuration file for the test topology.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_netjail_start (const char *label,
- char *topology_config,
- unsigned int *read_file);
-
-
-/**
- * Create command.
- *
- * @param label Name for the command.
- * @param topology The complete topology information.
- * @param read_file Flag indicating if the the name of the topology file is
send to the helper, or a string with the topology data.
- * @param topology_data If read_file is GNUNET_NO, topology_data holds the
string with the topology.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_netjail_start_testing_system (
- const char *label,
- struct GNUNET_TESTING_NetjailTopology *topology,
- unsigned int *read_file,
- char *topology_data);
-
-
-/**
- * Create command.
- *
- * @param label name for command.
- * @param topology_config Configuration file for the test topology.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_netjail_stop (const char *label,
- char *topology_config,
- unsigned int *read_file);
-
-
-/**
- * Create command.
- *
- * @param label name for command.
- * @param helper_start_label label of the cmd to start the test system.
- * @param topology The complete topology information.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_stop_testing_system (
- const char *label,
- const char *helper_start_label,
- struct GNUNET_TESTING_NetjailTopology *topology);
-
-
-/**
- * Create a GNUNET_CMDS_LOCAL_FINISHED message.
- *
- * @param rv The result of the local test as GNUNET_GenericReturnValue.
- * @return The GNUNET_CMDS_LOCAL_FINISHED message.
-*/
-struct GNUNET_MessageHeader *
-GNUNET_TESTING_send_local_test_finished_msg (enum GNUNET_GenericReturnValue
rv);
-
-
-/**
- * Function to get the trait with the async context.
- *
- * @param[out] ac GNUNET_TESTING_AsyncContext.
- * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
- */
-int
-GNUNET_TESTING_get_trait_async_context (
- const struct GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTING_AsyncContext **ac);
-
-
-/**
- * Offer handles to testing cmd helper from trait
- *
- * @param cmd command to extract the message from.
- * @param pt pointer to message.
- * @return #GNUNET_OK on success.
- */
-enum GNUNET_GenericReturnValue
-GNUNET_TESTING_get_trait_helper_handles (
- const struct GNUNET_TESTING_Command *cmd,
- struct GNUNET_HELPER_Handle ***helper);
-
-
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_block_until_all_peers_started (
- const char *label,
- unsigned int *all_peers_started);
-
-
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_block_until_external_trigger (
- const char *label);
-
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_send_peer_ready (const char *label,
- TESTING_CMD_HELPER_write_cb write_message);
-
-
-/**
- * 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,
- TESTING_CMD_HELPER_write_cb write_message);
-
-/**
- * Create command.
- *
- * @param label name for command.
- * @param write_message Callback to write messages to the master loop.
- * @param all_local_tests_prepared Flag which will be set from outside.
- * @return command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_local_test_prepared (const char *label,
- TESTING_CMD_HELPER_write_cb
- write_message);
-
-/**
- * Function to get the trait with the struct LocalPreparedState.
- *
- * @param[out] lfs struct LocalPreparedState.
- * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
- *
- */
-enum GNUNET_GenericReturnValue
-GNUNET_TESTING_get_trait_local_prepared_state (
- const struct GNUNET_TESTING_Command *cmd,
- struct LocalPreparedState **lfs);
-
#endif
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c
index f90cc3cc4..5ff7c04ea 100644
--- a/src/testing/gnunet-cmds-helper.c
+++ b/src/testing/gnunet-cmds-helper.c
@@ -415,8 +415,6 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader
*message)
plugin->n, plugin->local_m, ni->topology_data,
ni->read_file);
- GNUNET_free (binary);
-
msg_length = sizeof(struct GNUNET_CMDS_HelperReply);
reply = GNUNET_new (struct GNUNET_CMDS_HelperReply);
reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY);
@@ -424,6 +422,10 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader
*message)
write_message ((struct GNUNET_MessageHeader *) reply, msg_length);
+ GNUNET_free (binary);
+ GNUNET_free (router_ip);
+ GNUNET_free (plugin_name);
+
return GNUNET_OK;
}
else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED == ntohs (
diff --git a/src/testing/testing.c b/src/testing/testing.c
index ced04e65d..9e664292b 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -1838,7 +1838,7 @@ get_first_string_value (char *line)
memcpy (copy, line, slen);
token = strtok_r (copy, ":", &rest);
token = strtok_r (NULL, ":", &rest);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"first token %s\n",
token);
slen_token = strlen (token);
@@ -1924,7 +1924,7 @@ get_connect_value (char *line, struct
GNUNET_TESTING_NetjailNode *node)
node_connection->node_type = GNUNET_TESTING_GLOBAL_NODE;
token = strtok_r (NULL, ":", &rest);
GNUNET_assert (1 == sscanf (token, "%u", &node_n));
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"node_n %u\n",
node_n);
node_connection->node_n = node_n;
@@ -1939,7 +1939,7 @@ get_connect_value (char *line, struct
GNUNET_TESTING_NetjailNode *node)
token = strtok_r (NULL, ":", &rest);
sscanf (token, "%u", &node_n);
node_connection->node_n = node_n;
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"node_n %u namespace_n %u node->node_n %u node->namespace_n %u\n",
node_n,
namespace_n,
@@ -1963,14 +1963,14 @@ get_connect_value (char *line, struct
GNUNET_TESTING_NetjailNode *node)
memcpy (prefix->address_prefix, token, slen);
}
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"address_prefix %s\n",
prefix->address_prefix);
GNUNET_CONTAINER_DLL_insert (node_connection->address_prefixes_head,
node_connection->address_prefixes_tail,
prefix);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"address_prefix %s\n",
prefix->address_prefix);
}
@@ -2028,7 +2028,7 @@ log_nodes (void *cls, const struct GNUNET_ShortHashCode
*id, void *value)
struct GNUNET_TESTING_NodeConnection *pos_connection;
struct GNUNET_TESTING_AddressPrefix *pos_prefix;
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"plugin: %s space: %u node: %u global: %u\n",
node->plugin,
node->namespace_n,
@@ -2039,7 +2039,7 @@ log_nodes (void *cls, const struct GNUNET_ShortHashCode
*id, void *value)
pos_connection = pos_connection->next)
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"namespace_n: %u node_n: %u node_type: %u\n",
pos_connection->namespace_n,
pos_connection->node_n,
@@ -2049,7 +2049,7 @@ log_nodes (void *cls, const struct GNUNET_ShortHashCode
*id, void *value)
pos_prefix =
pos_prefix->next)
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"prefix: %s\n",
pos_prefix->address_prefix);
}
@@ -2071,7 +2071,7 @@ log_namespaces (void *cls, const struct
GNUNET_ShortHashCode *id, void *value)
static int
log_topo (struct GNUNET_TESTING_NetjailTopology *topology)
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"plugin: %s spaces: %u nodes: %u known: %u\n",
topology->plugin,
topology->namespaces_n,
@@ -2218,6 +2218,8 @@ free_nodes_cb (void *cls,
GNUNET_free (pos_connection);
pos_connection = tmp_connection;
}
+ GNUNET_free (node->plugin);
+ GNUNET_free (node);
return GNUNET_OK;
}
@@ -2248,8 +2250,11 @@ GNUNET_TESTING_free_topology (struct
GNUNET_TESTING_NetjailTopology *topology)
{
GNUNET_CONTAINER_multishortmap_iterate (topology->map_namespaces,
free_namespaces_cb, NULL);
+ GNUNET_CONTAINER_multishortmap_destroy (topology->map_namespaces);
GNUNET_CONTAINER_multishortmap_iterate (topology->map_globals, free_nodes_cb,
NULL);
+ GNUNET_CONTAINER_multishortmap_destroy (topology->map_globals);
+ GNUNET_free (topology->plugin);
GNUNET_free (topology);
}
@@ -2294,7 +2299,7 @@ GNUNET_TESTING_get_address (struct
GNUNET_TESTING_NodeConnection *connection,
char *addr;
char *template;
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"node_n: %u\n",
connection->node_n);
@@ -2374,7 +2379,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
char *key = NULL;
unsigned int out;
char *rest = NULL;
- char *value;
+ char *value = NULL;
char *value2;
int ret;
struct GNUNET_TESTING_NetjailTopology *topo;
@@ -2384,9 +2389,6 @@ GNUNET_TESTING_get_topo_from_string (char *data)
struct GNUNET_ShortHashCode *hkey;
struct GNUNET_HashCode hc;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "data %s\n",
- data);
token = strtok_r (data, "\n", &rest);
topo = GNUNET_new (struct GNUNET_TESTING_NetjailTopology);
topo->map_namespaces =
@@ -2399,46 +2401,46 @@ GNUNET_TESTING_get_topo_from_string (char *data)
if (NULL != key)
free (key);
key = get_key (token);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"In the loop with token: %s beginning with %s\n",
token,
key);
if (0 == strcmp (key, "M"))
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Get first Value for M.\n");
out = get_first_value (token);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"M: %u\n",
out);
topo->nodes_m = out;
}
else if (0 == strcmp (key, "N"))
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Get first Value for N.\n");
out = get_first_value (token);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"N: %u\n",
out);
topo->namespaces_n = out;
}
else if (0 == strcmp (key, "X"))
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Get first Value for X.\n");
out = get_first_value (token);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"X: %u\n",
out);
topo->nodes_x = out;
}
else if (0 == strcmp (key, "T"))
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Get first string value for T.\n");
value = get_first_string_value (token);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"value: %s\n",
value);
topo->plugin = value;
@@ -2448,10 +2450,10 @@ GNUNET_TESTING_get_topo_from_string (char *data)
hkey = GNUNET_new (struct GNUNET_ShortHashCode);
node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Get first Value for K.\n");
out = get_first_value (token);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"K: %u\n",
out);
node->node_n = out;
@@ -2470,10 +2472,10 @@ GNUNET_TESTING_get_topo_from_string (char *data)
hkey,
node,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Get value for key value on K.\n");
value = get_value ("plugin", token);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"value: %s\n",
value);
node->plugin = value;
@@ -2485,10 +2487,10 @@ GNUNET_TESTING_get_topo_from_string (char *data)
router = GNUNET_new (struct GNUNET_TESTING_NetjailRouter);
node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Get first Value for R.\n");
out = get_first_value (token);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"R: %u\n",
out);
node->node_n = out;
@@ -2496,22 +2498,22 @@ GNUNET_TESTING_get_topo_from_string (char *data)
memcpy (hkey,
&hc,
sizeof (*hkey));
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Get value for key tcp_port on R.\n");
value = get_value ("tcp_port", token);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"tcp_port: %s\n",
value);
ret = sscanf (value, "%u", &(router->tcp_port));
GNUNET_break (0 != ret && 1 >= router->tcp_port);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Get value for key udp_port on R.\n");
value2 = get_value ("udp_port", token);
ret = sscanf (value2, "%u", &(router->udp_port));
GNUNET_break (0 != ret && 1 >= router->udp_port);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"udp_port: %s\n",
value2);
@@ -2540,10 +2542,10 @@ GNUNET_TESTING_get_topo_from_string (char *data)
hkey = GNUNET_new (struct GNUNET_ShortHashCode);
node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Get first Value for P.\n");
out = get_first_value (token);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"P: %u\n",
out);
GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
@@ -2568,10 +2570,10 @@ GNUNET_TESTING_get_topo_from_string (char *data)
namespace,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
}
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Get second Value for P.\n");
out = get_second_value (token);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"P: %u\n",
out);
GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
@@ -2591,10 +2593,10 @@ GNUNET_TESTING_get_topo_from_string (char *data)
hkey,
node,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Get value for key plugin on P.\n");
value = get_value ("plugin", token);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"plugin: %s\n",
value);
node->plugin = value;
@@ -2605,10 +2607,14 @@ GNUNET_TESTING_get_topo_from_string (char *data)
}
token = strtok_r (NULL, "\n", &rest);
if (NULL != token)
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Next token %s\n",
token);
}
+ if (NULL != key)
+ GNUNET_free (key);
+ /*if (NULL != value)
+ GNUNET_free (value);*/
return topo;
}
@@ -2642,7 +2648,7 @@ GNUNET_TESTING_get_topo_from_file (const char *filename)
filename);
return NULL;
}
- data = GNUNET_malloc (fs);
+ data = GNUNET_malloc (fs + 1);
if (fs != GNUNET_DISK_fn_read (filename, data, fs))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -2653,9 +2659,8 @@ GNUNET_TESTING_get_topo_from_file (const char *filename)
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "data: %s\n",
- data);
-
+ "file lenght %lu\n",
+ fs);
data[fs] = '\0';
topo = GNUNET_TESTING_get_topo_from_string (data);
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 7ff554280..9360dd02e 100644
--- a/src/testing/testing_api_cmd_block_until_external_trigger.c
+++ b/src/testing/testing_api_cmd_block_until_external_trigger.c
@@ -33,23 +33,6 @@
*/
#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
-/**
- * Struct with information for callbacks.
- *
- */
-struct BlockState
-{
- /**
- * Context for our asynchronous completion.
- */
- struct GNUNET_TESTING_AsyncContext ac;
-
- /**
- * The label of this command.
- */
- const char *label;
-};
-
/**
* The cleanup function of this cmd frees resources the cmd allocated.
@@ -77,6 +60,11 @@ block_until_external_trigger_traits (void *cls,
.trait_name = "async_context",
.ptr = (const void *) ac,
},
+ {
+ .index = 1,
+ .trait_name = "block_state",
+ .ptr = (const void *) bs,
+ },
GNUNET_TESTING_trait_end ()
};
@@ -87,10 +75,28 @@ block_until_external_trigger_traits (void *cls,
}
+/**
+ * Function to get the trait with the internal command state BlockState.
+ *
+ * * @param[out] ac struct BlockState.
+* @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
+ */
+int
+GNUNET_TESTING_get_trait_block_state (
+ const struct GNUNET_TESTING_Command *cmd,
+ struct BlockState **bs)
+{
+ return cmd->traits (cmd->cls,
+ (const void **) bs,
+ "block_state",
+ (unsigned int) 1);
+}
+
+
/**
* Function to get the trait with the async context.
*
- * @param[out] ac GNUNET_TESTING_AsyncContext.
+ * @param[out] ac struct GNUNET_TESTING_AsyncContext.
* @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
*/
int
@@ -114,10 +120,20 @@ block_until_all_peers_started_run (void *cls,
struct GNUNET_TESTING_Interpreter *is)
{
struct BlockState *bs = cls;
+ struct GNUNET_TESTING_Command *cmd =
+ GNUNET_TESTING_interpreter_get_current_command (is);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "block %s running!\n",
- bs->label);
+ "block %s running %u!\n",
+ bs->label,
+ bs->asynchronous_finish);
+ if (GNUNET_YES == bs->asynchronous_finish)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "block %s running asynchronous!\n",
+ bs->label);
+ cmd->asynchronous_finish = bs->asynchronous_finish;
+ }
}
@@ -126,15 +142,18 @@ block_until_all_peers_started_run (void *cls,
*
* @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. Can
be NULL.
* @return command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_block_until_external_trigger (const char *label)
+GNUNET_TESTING_cmd_block_until_external_trigger (
+ const char *label)
{
struct BlockState *bs;
bs = GNUNET_new (struct BlockState);
bs->label = label;
+ bs->asynchronous_finish = GNUNET_NO;
{
struct GNUNET_TESTING_Command cmd = {
.cls = bs,
diff --git a/src/testing/testing_api_cmd_netjail_start.c
b/src/testing/testing_api_cmd_netjail_start.c
index 2ff70c33e..6cd648c3a 100644
--- a/src/testing/testing_api_cmd_netjail_start.c
+++ b/src/testing/testing_api_cmd_netjail_start.c
@@ -193,11 +193,15 @@ netjail_start_run (void *cls,
NULL,
script_name,
script_argv);
+
}
ns->cwh = GNUNET_wait_child (ns->start_proc,
&child_completed_callback,
ns);
GNUNET_break (NULL != ns->cwh);
+ GNUNET_free (read_file);
+ GNUNET_free (script_name);
+ GNUNET_free (data_dir);
}
diff --git a/src/testing/testing_api_cmd_netjail_stop.c
b/src/testing/testing_api_cmd_netjail_stop.c
index e3bf7da62..f1b2260ab 100644
--- a/src/testing/testing_api_cmd_netjail_stop.c
+++ b/src/testing/testing_api_cmd_netjail_stop.c
@@ -87,6 +87,7 @@ netjail_stop_cleanup (void *cls)
GNUNET_OS_process_destroy (ns->stop_proc);
ns->stop_proc = NULL;
}
+ GNUNET_free (ns);
}
diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c
index 3727d2543..e82ec33ab 100644
--- a/src/testing/testing_api_loop.c
+++ b/src/testing/testing_api_loop.c
@@ -52,6 +52,11 @@ struct GNUNET_TESTING_Interpreter
*/
struct GNUNET_TESTING_Command *commands;
+ /**
+ * Number of GNUNET_TESTING_Command in commands.
+ */
+ unsigned int cmds_n;
+
/**
* Interpreter task (if one is scheduled).
*/
@@ -83,21 +88,32 @@ struct GNUNET_TESTING_Interpreter
const struct GNUNET_TESTING_Command *
-GNUNET_TESTING_interpreter_lookup_command (
- struct GNUNET_TESTING_Interpreter *is,
- const char *label)
+get_command (struct GNUNET_TESTING_Interpreter *is,
+ const char *label,
+ unsigned int future)
{
+ int start_i = GNUNET_NO == future ? is->ip : is->cmds_n - 1;
+ int end_i = GNUNET_NO == future ? 0 : is->ip + 1;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "start_i: %u end_i: %u\n",
+ start_i,
+ end_i);
if (NULL == label)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Attempt to lookup command for empty label\n");
return NULL;
}
- /* Search backwards as we most likely reference recent commands */
- for (int i = is->ip; i >= 0; i--)
+
+ for (int i = start_i; i >= end_i; i--)
{
const struct GNUNET_TESTING_Command *cmd = &is->commands[i];
+ if (NULL != cmd->label)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "label to compare %s\n",
+ cmd->label);
/* Give precedence to top-level commands. */
if ( (NULL != cmd->label) &&
(0 == strcmp (cmd->label,
@@ -141,6 +157,40 @@ GNUNET_TESTING_interpreter_lookup_command (
}
+/**
+ * Lookup command by label.
+ * Only future commands are looked up.
+ *
+ * @param is interpreter to lookup command in
+ * @param label label of the command to lookup.
+ * @return the command, if it is found, or NULL.
+ */
+const struct GNUNET_TESTING_Command *
+GNUNET_TESTING_interpreter_lookup_future_command (
+ struct GNUNET_TESTING_Interpreter *is,
+ const char *label)
+{
+ return get_command (is, label, GNUNET_YES);
+}
+
+
+/**
+ * Lookup command by label.
+ * Only commands from current command to commands in the past are looked up.
+ *
+ * @param is interpreter to lookup command in
+ * @param label label of the command to lookup.
+ * @return the command, if it is found, or NULL.
+ */
+const struct GNUNET_TESTING_Command *
+GNUNET_TESTING_interpreter_lookup_command (
+ struct GNUNET_TESTING_Interpreter *is,
+ const char *label)
+{
+ return get_command (is, label, GNUNET_NO);
+}
+
+
/**
* Finish the test run, return the final result.
*
@@ -267,6 +317,20 @@ GNUNET_TESTING_interpreter_fail (struct
GNUNET_TESTING_Interpreter *is)
}
+/**
+ * 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)
+{
+ return &is->commands[is->ip];
+}
+
const char *
GNUNET_TESTING_interpreter_get_current_label (
struct GNUNET_TESTING_Interpreter *is)
@@ -300,9 +364,17 @@ interpreter_run (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Running command `%s'\n",
cmd->label);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "start time of %p expected 0 is `%lu'\n",
+ cmd,
+ cmd->start_time.abs_value_us);
cmd->start_time
= cmd->last_req_time
= GNUNET_TIME_absolute_get ();
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "start time of %p expected something is `%lu'\n",
+ cmd,
+ cmd->start_time.abs_value_us);
cmd->num_tries = 1;
if (NULL != cmd->ac)
{
@@ -344,6 +416,37 @@ do_timeout (void *cls)
}
+/**
+ * Check if the command is running.
+ *
+ * @param cmd The command to check.
+ * @return GNUNET_NO if the command is not running, GNUNET_YES if it is
running.
+ */
+enum GNUNET_GenericReturnValue
+GNUNET_TESTING_running (const struct GNUNET_TESTING_Command *command)
+{
+ return 0 != command->start_time.abs_value_us && 0 ==
+ command->finish_time.abs_value_us;
+}
+
+
+/**
+ * Check if a command is finished.
+ *
+ * @param cmd The command to check.
+ * @return GNUNET_NO if the command is not finished, GNUNET_YES if it is
finished.
+ */
+enum GNUNET_GenericReturnValue
+GNUNET_TESTING_finished (struct GNUNET_TESTING_Command *command)
+{
+ struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
+ struct GNUNET_TIME_Relative diff = GNUNET_TIME_absolute_get_difference (
+ command->finish_time,
+ now);
+ return 0 < diff.rel_value_us;
+}
+
+
void
GNUNET_TESTING_run (struct GNUNET_TESTING_Command *commands,
struct GNUNET_TIME_Relative timeout,
@@ -359,7 +462,8 @@ GNUNET_TESTING_run (struct GNUNET_TESTING_Command *commands,
/* get the number of commands */
for (i = 0; NULL != commands[i].label; i++)
;
- is->commands = GNUNET_new_array (i + 1,
+ is->cmds_n = i + 1;
+ is->commands = GNUNET_new_array (is->cmds_n,
struct GNUNET_TESTING_Command);
memcpy (is->commands,
commands,
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index f17be359e..a53f17fe6 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -123,6 +123,7 @@ endif
noinst_PROGRAMS = \
+ test_transport_start_with_config \
gnunet-transport-profiler \
gnunet-communicator-udp \
$(WLAN_BIN_SENDER) \
@@ -589,7 +590,6 @@ libgnunet_plugin_transport_https_server_la_CFLAGS = \
$(MHD_CFLAGS) $(AM_CFLAGS) -DBUILD_HTTPS
check_PROGRAMS = \
- test_transport_start_with_config \
test_transport_address_switch_tcp \
test_transport_testing_startstop \
test_transport_testing_restart \
@@ -766,7 +766,6 @@ test_transport_start_with_config_SOURCES = \
test_transport_start_with_config_LDADD = \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/testbed/libgnunettestbed.la \
$(top_builddir)/src/hello/libgnunethello.la \
libgnunettransportcore.la \
libgnunettransporttesting2.la
diff --git a/src/transport/gnunet-communicator-tcp.c
b/src/transport/gnunet-communicator-tcp.c
index 0bf919787..07eb6db3a 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -3264,7 +3264,7 @@ init_socket (struct sockaddr *addr,
return GNUNET_SYSERR;
}
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"address %s\n",
GNUNET_a2s (addr, in_len));
@@ -3403,15 +3403,17 @@ nat_register ()
socklen_t *saddr_lens;
int i;
struct Addresses *pos;
+ size_t len;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"starting nat register!\n");
+ len = 0;
i = 0;
- saddrs = GNUNET_malloc ((addrs_lens + 1) * sizeof(struct sockaddr *));
+ saddrs = GNUNET_malloc ((addrs_lens) * sizeof(struct sockaddr *));
- saddr_lens = GNUNET_malloc ((addrs_lens + 1) * sizeof(socklen_t));
+ saddr_lens = GNUNET_malloc ((addrs_lens) * sizeof(socklen_t));
for (pos = addrs_head; NULL != pos; pos = pos->next)
{
@@ -3421,12 +3423,19 @@ nat_register ()
GNUNET_a2s (addrs_head->addr, addrs_head->addr_len));
saddr_lens[i] = addrs_head->addr_len;
+ len += saddr_lens[i];
saddrs[i] = GNUNET_memdup (addrs_head->addr, saddr_lens[i]);
i++;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "registering addresses %lu %lu %lu %lu\n",
+ (addrs_lens) * sizeof(struct sockaddr *),
+ (addrs_lens) * sizeof(socklen_t),
+ len,
+ sizeof(COMMUNICATOR_CONFIG_SECTION));
nat = GNUNET_NAT_register (cfg,
COMMUNICATOR_CONFIG_SECTION,
IPPROTO_TCP,
@@ -3437,7 +3446,7 @@ nat_register ()
NULL /* FIXME: support reversal: #5529 */,
NULL /* closure */);
- i = 0;
+ // i = 0;
for (i = addrs_lens - 1; i >= 0; i--)
GNUNET_free (saddrs[i]);
diff --git a/src/transport/test_communicator_tcp_basic_peer1.conf
b/src/transport/test_communicator_tcp_basic_peer1.conf
index dbc227ac6..d9fff8bbb 100644
--- a/src/transport/test_communicator_tcp_basic_peer1.conf
+++ b/src/transport/test_communicator_tcp_basic_peer1.conf
@@ -36,7 +36,7 @@ UNIXPATH =
$GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock
[communicator-tcp]
#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
-#PREFIX = valgrind --leak-check=full --track-origins=yes
+PREFIX = valgrind --leak-check=full --track-origins=yes
BINDTO = 60002
DISABLE_V6 = YES
diff --git a/src/transport/test_transport_api2_tcp_node1.conf
b/src/transport/test_transport_api2_tcp_node1.conf
index 807a9360a..d6932b1b9 100644
--- a/src/transport/test_transport_api2_tcp_node1.conf
+++ b/src/transport/test_transport_api2_tcp_node1.conf
@@ -15,6 +15,7 @@ DISABLE_V6 = YES
IMMEDIATE_START = YES
UNIXPATH = $GNUNET_RUNTIME_DIR/tcp-comm-p1.sock
#PREFIX = valgrind --log-file=/tmp/vg_cpeer1-%p
+PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
[communicator-udp]
BINARY = gnunet-communicator-udp
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c
b/src/transport/test_transport_plugin_cmd_simple_send.c
index 6829daf84..476fbdf4f 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send.c
@@ -164,19 +164,20 @@ handle_result (void *cls,
*
*/
static void *
-notify_connect (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- struct GNUNET_MQ_Handle *mq)
+notify_connect (struct GNUNET_TESTING_Interpreter *is,
+ const struct GNUNET_PeerIdentity *peer)
{
struct ConnectPeersState *cps;
+ const struct GNUNET_TESTING_Command *cmd;
- GNUNET_TRANSPORT_get_trait_connect_peer_state (&connect_peers,
+ cmd = GNUNET_TESTING_interpreter_lookup_command (is,
+ "connect-peers");
+ GNUNET_TRANSPORT_get_trait_connect_peer_state (cmd,
&cps);
void *ret = NULL;
- cps->notify_connect (cps,
- peer,
- mq);
+ cps->notify_connect (is,
+ peer);
return ret;
}
@@ -246,7 +247,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message,
char *router_ip,
else
num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
- block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block");
+ block_send = GNUNET_TESTING_cmd_block_until_external_trigger (
+ "block");
block_receive = GNUNET_TESTING_cmd_block_until_external_trigger (
"block-receive");
connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers",
@@ -262,11 +264,11 @@ start_testcase (TESTING_CMD_HELPER_write_cb
write_message, char *router_ip,
GNUNET_asprintf (&ts->cfgname,
"test_transport_api2_tcp_node1.conf");
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"plugin cfgname: %s\n",
ts->cfgname);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"node ip: %s\n",
node_ip);
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 986fe6014..e2757671b 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
@@ -74,7 +74,6 @@ static struct GNUNET_TESTING_Command connect_peers;
static struct GNUNET_TESTING_Command local_prepared;
-
/**
* Function called to check a message of type
GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being
* received.
@@ -164,25 +163,50 @@ handle_result (void *cls,
*
*/
static void *
-notify_connect (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- struct GNUNET_MQ_Handle *mq)
+notify_connect (struct GNUNET_TESTING_Interpreter *is,
+ const struct GNUNET_PeerIdentity *peer)
{
struct GNUNET_TESTING_AsyncContext *ac;
+ void *ret = NULL;
+ const struct GNUNET_TESTING_Command *cmd;
+ struct BlockState *bs;
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"notify_connect\n");
GNUNET_TESTING_get_trait_async_context (&connect_peers,
- &ac);
- void *ret = NULL;
+ &ac);
- GNUNET_assert (NULL != ac);
- if (NULL == ac->cont)
- GNUNET_TESTING_async_fail (ac);
+ if (NULL != ac->is)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "notify_connect running\n");
+ GNUNET_assert (NULL != ac);
+ if (NULL == ac->cont)
+ GNUNET_TESTING_async_fail (ac);
+ else
+ GNUNET_TESTING_async_finish (ac);
+ }
else
- GNUNET_TESTING_async_finish (ac);
-
+ {
+ cmd = GNUNET_TESTING_interpreter_lookup_future_command (is,
+ "connect-peers");
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "block state %s\n",
+ cmd->label);
+ GNUNET_TESTING_get_trait_block_state (cmd,&bs);
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "block state %u\n",
+ bs->asynchronous_finish);
+ bs->asynchronous_finish = GNUNET_YES;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "block state %u\n",
+ bs->asynchronous_finish);
+ }
+
return ret;
}
@@ -224,7 +248,6 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message,
char *router_ip,
char *topology_data,
unsigned int *read_file)
{
-
unsigned int n_int;
unsigned int m_int;
unsigned int local_m_int;
@@ -232,6 +255,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message,
char *router_ip,
struct TestState *ts = GNUNET_new (struct TestState);
struct GNUNET_TESTING_NetjailTopology *topology;
+
+
if (GNUNET_YES == *read_file)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -255,7 +280,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message,
char *router_ip,
block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block");
block_receive = GNUNET_TESTING_cmd_block_until_external_trigger (
"block-receive");
- connect_peers = GNUNET_TESTING_cmd_block_until_external_trigger
("connect-peers");
+ connect_peers = GNUNET_TESTING_cmd_block_until_external_trigger (
+ "connect-peers");
local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
"local-test-prepared",
write_message);
@@ -264,11 +290,11 @@ start_testcase (TESTING_CMD_HELPER_write_cb
write_message, char *router_ip,
GNUNET_asprintf (&ts->cfgname,
"test_transport_api2_tcp_node1.conf");
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"plugin cfgname: %s\n",
ts->cfgname);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"node ip: %s\n",
node_ip);
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c
b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
index 11cd177c4..c98a3075d 100644
--- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c
+++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
@@ -160,9 +160,8 @@ handle_result (void *cls,
*
*/
static void *
-notify_connect (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- struct GNUNET_MQ_Handle *mq)
+notify_connect (struct GNUNET_TESTING_Interpreter *is,
+ const struct GNUNET_PeerIdentity *peer)
{
struct ConnectPeersState *cps;
@@ -170,9 +169,8 @@ notify_connect (void *cls,
&cps);
void *ret = NULL;
- cps->notify_connect (cps,
- peer,
- mq);
+ cps->notify_connect (is,
+ peer);
return ret;
}
@@ -238,7 +236,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message,
char *router_ip,
else
num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
- block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block");
+ block_send = GNUNET_TESTING_cmd_block_until_external_trigger (
+ "block");
connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers",
"start-peer",
"system-create",
@@ -251,11 +250,11 @@ start_testcase (TESTING_CMD_HELPER_write_cb
write_message, char *router_ip,
GNUNET_asprintf (&ts->cfgname,
"test_transport_api2_tcp_node1.conf");
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"plugin cfgname: %s\n",
ts->cfgname);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"node ip: %s\n",
node_ip);
diff --git a/src/transport/test_transport_simple_send.sh
b/src/transport/test_transport_simple_send.sh
index 7e3ee032f..e7da65ff7 100755
--- a/src/transport/test_transport_simple_send.sh
+++ b/src/transport/test_transport_simple_send.sh
@@ -1,5 +1,8 @@
#!/bin/bash
-if [ "$(sysctl -n kernel.unprivileged_userns_clone)" == 1 ]; then
+if ! [ -d "/run/netns" ]; then
+ echo You have to create the directory /run/netns.
+fi
+if [ "$(cat /proc/sys/kernel/core_uses_pid)" == 1 ]; then
exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs
/run/netns; ./test_transport_start_with_config
test_transport_simple_send_topo.conf"
else
echo -e "Error during test setup: The kernel parameter
kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n
sysctl kernel.unprivileged_userns_clone=1\n"
diff --git a/src/transport/test_transport_simple_send_broadcast.sh
b/src/transport/test_transport_simple_send_broadcast.sh
index 6e455f0d5..93572327b 100755
--- a/src/transport/test_transport_simple_send_broadcast.sh
+++ b/src/transport/test_transport_simple_send_broadcast.sh
@@ -1,5 +1,9 @@
#!/bin/bash
-if [ "$(sysctl -n kernel.unprivileged_userns_clone)" == 1 ]; then
+if ! [ -d "/run/netns" ]; then
+ echo You have to create the directory /run/netns.
+fi
+if [ "$(cat /proc/sys/kernel/core_uses_pid)" == 1 ]; then
+ # exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs
/run/netns; 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_simple_send_broadcast_topo.conf"
exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs
/run/netns; ./test_transport_start_with_config
test_transport_simple_send_broadcast_topo.conf"
else
echo -e "Error during test setup: The kernel parameter
kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n
sysctl kernel.unprivileged_userns_clone=1\n"
diff --git a/src/transport/test_transport_simple_send_string.sh
b/src/transport/test_transport_simple_send_string.sh
index 018ea55e8..f9510e6b6 100755
--- a/src/transport/test_transport_simple_send_string.sh
+++ b/src/transport/test_transport_simple_send_string.sh
@@ -7,8 +7,11 @@ T:libgnunet_test_transport_plugin_cmd_simple_send
P:1:1|{connect:{P:1:2:tcp}}
P:1:2|{connect:{P:1:1:tcp}}
EOF
-)
-if [ "$(sysctl -n kernel.unprivileged_userns_clone)" == 1 ]; then
+ )
+if ! [ -d "/run/netns" ]; then
+ echo You have to create the directory /run/netns.
+fi
+if [ "$(cat /proc/sys/kernel/core_uses_pid)" == 1 ]; then
exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs
/run/netns; ./test_transport_start_with_config -s '$string'"
else
echo -e "Error during test setup: The kernel parameter
kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n
sysctl kernel.unprivileged_userns_clone=1\n"
diff --git a/src/transport/test_transport_udp_backchannel.sh
b/src/transport/test_transport_udp_backchannel.sh
index 9c0b11fad..f93aef7ff 100755
--- a/src/transport/test_transport_udp_backchannel.sh
+++ b/src/transport/test_transport_udp_backchannel.sh
@@ -1,5 +1,8 @@
#!/bin/bash
-if [ "$(sysctl -n kernel.unprivileged_userns_clone)" == 1 ]; then
+if ! [ -d "/run/netns" ]; then
+ echo You have to create the directory /run/netns.
+fi
+if [ "$(cat /proc/sys/kernel/core_uses_pid)" == 1 ]; then
#exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns;
valgrind --leak-check=full --track-origins=yes --trace-children=yes
--trace-children-skip=/usr/bin/awk,/usr/bin/cut,/usr/bin/seq,/sbin/ip
./test_transport_start_with_config test_transport_udp_backchannel_topo.conf"
exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns;
./test_transport_start_with_config test_transport_udp_backchannel_topo.conf"
# exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs
/run/netns; valgrind --leak-check=full --track-origins=yes
./test_transport_start_with_config test_transport_udp_backchannel_topo.conf"
diff --git a/src/transport/transport-testing-cmds.h
b/src/transport/transport-testing-cmds.h
index 5d0b902f6..d2e49c0d3 100644
--- a/src/transport/transport-testing-cmds.h
+++ b/src/transport/transport-testing-cmds.h
@@ -29,6 +29,10 @@
#include "gnunet_testing_lib.h"
+typedef void *
+(*GNUNET_TRANSPORT_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is,
+ const struct GNUNET_PeerIdentity *peer);
+
/**
* Struct to store information needed in callbacks.
*
@@ -40,7 +44,7 @@ struct ConnectPeersState
*/
struct GNUNET_TESTING_AsyncContext ac;
- GNUNET_TRANSPORT_NotifyConnect notify_connect;
+ GNUNET_TRANSPORT_notify_connect_cb notify_connect;
/**
* The testing system of this node.
@@ -163,7 +167,7 @@ struct StartPeerState
struct GNUNET_TESTING_System *tl_system;
- GNUNET_TRANSPORT_NotifyConnect notify_connect;
+ GNUNET_TRANSPORT_notify_connect_cb notify_connect;
/**
* Flag indicating, if udp broadcast should be switched on.
@@ -213,7 +217,8 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
char *node_ip,
struct GNUNET_MQ_MessageHandler *handlers,
const char *cfgname,
- GNUNET_TRANSPORT_NotifyConnect notify_connect,
+ GNUNET_TRANSPORT_notify_connect_cb
+ notify_connect,
unsigned int broadcast);
diff --git a/src/transport/transport_api_cmd_connecting_peers.c
b/src/transport/transport_api_cmd_connecting_peers.c
index b50b63c62..3fef7d687 100644
--- a/src/transport/transport_api_cmd_connecting_peers.c
+++ b/src/transport/transport_api_cmd_connecting_peers.c
@@ -113,17 +113,20 @@ connect_peers_run (void *cls,
*
*/
static void *
-notify_connect (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- struct GNUNET_MQ_Handle *mq)
+notify_connect (struct GNUNET_TESTING_Interpreter *is,
+ const struct GNUNET_PeerIdentity *peer)
{
- struct ConnectPeersState *cps = cls;
+ const struct GNUNET_TESTING_Command *cmd;
+ struct ConnectPeersState *cps;
struct GNUNET_PeerIdentity *peer_connection;
unsigned int con_num = 0;
struct GNUNET_TESTING_NodeConnection *pos_connection;
unsigned int num;
void *ret = NULL;
+ cmd = GNUNET_TESTING_interpreter_lookup_command (is,
+ "connect-peers");
+ cps = cmd->cls;
for (pos_connection = cps->node_connections_head; NULL != pos_connection;
pos_connection = pos_connection->next)
{
@@ -217,7 +220,7 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
cps->num = num;
cps->create_label = create_label;
cps->topology = topology;
- cps->notify_connect = ¬ify_connect;
+ cps->notify_connect = notify_connect;
{
struct GNUNET_TESTING_Command cmd = {
diff --git a/src/transport/transport_api_cmd_start_peer.c
b/src/transport/transport_api_cmd_start_peer.c
index da833f1b1..52eacabb2 100644
--- a/src/transport/transport_api_cmd_start_peer.c
+++ b/src/transport/transport_api_cmd_start_peer.c
@@ -147,9 +147,8 @@ notify_connect (void *cls,
GNUNET_free (key);
- sps->notify_connect (cls,
- peer,
- mq);
+ sps->notify_connect (sps->ac.is,
+ peer);
// TODO what does the handler function need?
return ret;
@@ -213,11 +212,11 @@ start_peer_run (void *cls,
GNUNET_asprintf (&bindto_udp,
"2086");
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"node_ip %s\n",
bindto);
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"bind_udp %s\n",
GNUNET_YES == sps->broadcast ?
bindto_udp : bindto);
@@ -247,7 +246,7 @@ start_peer_run (void *cls,
sps->tl_system = tl_system;
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Creating testing library with key number %u\n",
sps->no);
@@ -255,7 +254,7 @@ start_peer_run (void *cls,
GNUNET_TESTING_configuration_create (tl_system,
sps->cfg))
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Testing library failed to create unique configuration based on
`%s'\n",
sps->cfgname);
GNUNET_CONFIGURATION_destroy (sps->cfg);
@@ -359,6 +358,7 @@ start_peer_run (void *cls,
GNUNET_free (tcp_communicator_unix_path);
GNUNET_free (udp_communicator_unix_path);
GNUNET_free (bindto);
+ GNUNET_free (bindto_udp);
}
@@ -589,7 +589,8 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
char *node_ip,
struct GNUNET_MQ_MessageHandler *handlers,
const char *cfgname,
- GNUNET_TRANSPORT_NotifyConnect notify_connect,
+ GNUNET_TRANSPORT_notify_connect_cb
+ notify_connect,
unsigned int broadcast)
{
struct StartPeerState *sps;
--
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: - Fixed header, fixed log level, changed block until connect logic, fixed memory issues.,
gnunet <=