summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2021-12-06 14:20:25 +0100
committert3sserakt <t3ss@posteo.de>2021-12-06 14:20:25 +0100
commit1816cee6455627543262711524837164bbf48385 (patch)
tree931909154494dd49d8c9008ba3d3cca0c117b7e8 /src
parent7a7f3d5e0f7b76c07a395e6e0b4af4f39c4a2895 (diff)
fixed timeout for netjail tests, removed duplicated function declaration from header, using GNUNET_TESTING_get_trait_batch_cmds in loop, fixed tng service shutdown logic, added missing GNUNET_SERVICE_client_continue, changed default log level for udp backchannel test to debug
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_testing_netjail_lib.h4
-rw-r--r--src/include/gnunet_testing_ng_lib.h67
-rw-r--r--src/testing/gnunet-cmds-helper.c11
-rw-r--r--src/testing/testing_api_cmd_netjail_start_testsystem.c45
-rw-r--r--src/testing/testing_api_cmd_netjail_stop_testsystem.c2
-rw-r--r--src/testing/testing_api_loop.c12
-rw-r--r--src/transport/gnunet-service-tng.c15
-rw-r--r--src/transport/test_transport_start_with_config.c5
-rwxr-xr-xsrc/transport/test_transport_udp_backchannel.sh5
9 files changed, 73 insertions, 93 deletions
diff --git a/src/include/gnunet_testing_netjail_lib.h b/src/include/gnunet_testing_netjail_lib.h
index a1e14ec9f..69d6e7a7d 100644
--- a/src/include/gnunet_testing_netjail_lib.h
+++ b/src/include/gnunet_testing_netjail_lib.h
@@ -386,6 +386,7 @@ GNUNET_TESTING_cmd_netjail_stop (const char *label,
* @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.
+ * @param timeout Before this timeout is reached this cmd MUST finish.
* @return command.
*/
struct GNUNET_TESTING_Command
@@ -393,7 +394,8 @@ GNUNET_TESTING_cmd_netjail_start_testing_system (
const char *label,
struct GNUNET_TESTING_NetjailTopology *topology,
unsigned int *read_file,
- char *topology_data);
+ char *topology_data,
+ struct GNUNET_TIME_Relative timeout);
/**
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h
index c0e534594..7e1ee4249 100644
--- a/src/include/gnunet_testing_ng_lib.h
+++ b/src/include/gnunet_testing_ng_lib.h
@@ -510,72 +510,6 @@ struct GNUNET_TESTING_Timer
/**
- * Getting the topology from file.
- *
- * @param filename The name of the topology file.
- * @return The GNUNET_TESTING_NetjailTopology
- */
-struct GNUNET_TESTING_NetjailTopology *
-GNUNET_TESTING_get_topo_from_file (const char *filename);
-
-
-/**
- * Parse the topology data.
- *
- * @param data The topology data.
- * @return The GNUNET_TESTING_NetjailTopology
- */
-struct GNUNET_TESTING_NetjailTopology *
-GNUNET_TESTING_get_topo_from_string (char *data);
-
-
-/**
- * Get the connections to other nodes for a specific node.
- *
- * @param num The specific node we want the connections for.
- * @param topology The topology we get the connections from.
- * @return The connections of the node.
- */
-struct GNUNET_TESTING_NodeConnection *
-GNUNET_TESTING_get_connections (unsigned int num, struct
- GNUNET_TESTING_NetjailTopology *topology);
-
-
-/**
- * Get the address for a specific communicator from a connection.
- *
- * @param connection The connection we like to have the address from.
- * @param prefix The communicator protocol prefix.
- * @return The address of the communicator.
- */
-char *
-GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection,
- char *prefix);
-
-
-/**
- * Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.
- *
- * @param topology The GNUNET_TESTING_NetjailTopology to be deallocated.
- */
-void
-GNUNET_TESTING_free_topology (struct GNUNET_TESTING_NetjailTopology *topology);
-
-
-/**
- * Calculate the unique id identifying a node from a given connction.
- *
- * @param node_connection The connection we calculate the id from.
- * @param topology The topology we get all needed information from.
- * @return The unique id of the node from the connection.
- */
-unsigned int
-GNUNET_TESTING_calculate_num (struct
- GNUNET_TESTING_NodeConnection *node_connection,
- struct GNUNET_TESTING_NetjailTopology *topology);
-
-
-/**
* Retrieve the public key from the test system with the unique node id.
*
* @param num The unique node id.
@@ -744,6 +678,7 @@ GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits,
* Call #op on all simple traits.
*/
#define GNUNET_TESTING_SIMPLE_TRAITS(op) \
+ op (batch_cmds, struct GNUNET_TESTING_Command *) \
op (process, struct GNUNET_OS_Process *)
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c
index 5ff7c04ea..f6f079802 100644
--- a/src/testing/gnunet-cmds-helper.c
+++ b/src/testing/gnunet-cmds-helper.c
@@ -186,11 +186,6 @@ static struct GNUNET_OS_Process *cmd_binary_process;*/
struct Plugin *plugin;
/**
- * Handle to the testing system
- */
-static struct GNUNET_TESTING_System *test_system;
-
-/**
* Our message stream tokenizer
*/
struct GNUNET_MessageStreamTokenizer *tokenizer;
@@ -262,12 +257,6 @@ shutdown_task (void *cls)
(void) GNUNET_DISK_file_close (stdout_fd);
GNUNET_MST_destroy (tokenizer);
tokenizer = NULL;
-
- if (NULL != test_system)
- {
- GNUNET_TESTING_system_destroy (test_system, GNUNET_YES);
- test_system = NULL;
- }
}
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem.c b/src/testing/testing_api_cmd_netjail_start_testsystem.c
index 04d7eef44..9f39fbfda 100644
--- a/src/testing/testing_api_cmd_netjail_start_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_start_testsystem.c
@@ -30,6 +30,8 @@
#define NETJAIL_EXEC_SCRIPT "netjail_exec.sh"
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
+
/**
* Generic logging shortcut
*/
@@ -152,6 +154,16 @@ struct NetJailState
* String with topology data or name of topology file.
*/
char *topology_data;
+
+ /**
+ * Time after this cmd has to finish.
+ */
+ struct GNUNET_TIME_Relative timeout;
+
+ /**
+ * Timeout task.
+ */
+ struct GNUNET_SCHEDULER_Task *timeout_task;
};
/**
@@ -393,6 +405,7 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
ns->number_of_local_tests_finished++;
if (ns->number_of_local_tests_finished == total_number)
{
+ GNUNET_SCHEDULER_cancel (ns->timeout_task);
GNUNET_TESTING_async_finish (&ns->ac);
}
break;
@@ -489,6 +502,7 @@ exp_cb (void *cls)
struct TestingSystemCount *tbc = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called exp_cb.\n");
+ GNUNET_SCHEDULER_cancel (tbc->ns->timeout_task);
GNUNET_TESTING_async_fail (&(tbc->ns->ac));
}
@@ -696,6 +710,25 @@ start_helper (struct NetJailState *ns,
/**
+ * Function run when the cmd terminates (good or bad) with timeout.
+ *
+ * @param cls the interpreter state
+ */
+static void
+do_timeout (void *cls)
+{
+ struct NetJailState *ns = cls;
+ struct GNUNET_TESTING_Command *cmd;
+
+ ns->timeout_task = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Terminating cmd due to global timeout\n");
+ cmd = GNUNET_TESTING_interpreter_get_current_command (ns->is);
+ GNUNET_TESTING_async_finish (cmd->ac);
+}
+
+
+/**
* This function starts a helper process for each node.
*
* @param cls closure.
@@ -725,6 +758,13 @@ netjail_exec_run (void *cls,
i);
}
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding timeout %s\n",
+ GNUNET_STRINGS_relative_time_to_string (ns->timeout, GNUNET_NO));
+ ns->timeout_task
+ = GNUNET_SCHEDULER_add_delayed (ns->timeout,
+ &do_timeout,
+ ns);
}
@@ -735,6 +775,7 @@ netjail_exec_run (void *cls,
* @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.
+ * @param timeout Before this timeout is reached this cmd MUST finish.
* @return command.
*/
struct GNUNET_TESTING_Command
@@ -742,7 +783,8 @@ GNUNET_TESTING_cmd_netjail_start_testing_system (
const char *label,
struct GNUNET_TESTING_NetjailTopology *topology,
unsigned int *read_file,
- char *topology_data)
+ char *topology_data,
+ struct GNUNET_TIME_Relative timeout)
{
struct NetJailState *ns;
@@ -754,6 +796,7 @@ GNUNET_TESTING_cmd_netjail_start_testing_system (
ns->topology = topology;
ns->read_file = read_file;
ns->topology_data = topology_data;
+ ns->timeout = GNUNET_TIME_relative_subtract (timeout, TIMEOUT);
struct GNUNET_TESTING_Command cmd = {
.cls = ns,
diff --git a/src/testing/testing_api_cmd_netjail_stop_testsystem.c b/src/testing/testing_api_cmd_netjail_stop_testsystem.c
index 2e42056dc..4215beef6 100644
--- a/src/testing/testing_api_cmd_netjail_stop_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_stop_testsystem.c
@@ -118,7 +118,7 @@ stop_testing_system_run (void *cls,
+ j
+ shs->known
- 1],
- GNUNET_YES);
+ GNUNET_NO);
}
}
}
diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c
index 36e9da220..95d6b88e6 100644
--- a/src/testing/testing_api_loop.c
+++ b/src/testing/testing_api_loop.c
@@ -122,21 +122,19 @@ get_command (struct GNUNET_TESTING_Interpreter *is,
if (GNUNET_TESTING_cmd_is_batch_ (cmd))
{
-#define BATCH_INDEX 1
- const struct GNUNET_TESTING_Command *batch;
+ struct GNUNET_TESTING_Command **batch;
struct GNUNET_TESTING_Command *current;
const struct GNUNET_TESTING_Command *icmd;
const struct GNUNET_TESTING_Command *match;
current = GNUNET_TESTING_cmd_batch_get_current_ (cmd);
GNUNET_assert (GNUNET_OK ==
- GNUNET_TESTING_get_trait_cmd (cmd,
- BATCH_INDEX,
- &batch));
+ GNUNET_TESTING_get_trait_batch_cmds (cmd,
+ &batch));
/* We must do the loop forward, but we can find the last match */
match = NULL;
for (unsigned int j = 0;
- NULL != (icmd = &batch[j])->label;
+ NULL != (icmd = &(*batch)[j])->label;
j++)
{
if (current == icmd)
@@ -383,7 +381,7 @@ interpreter_run (void *cls)
finish_test (is);
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Running command `%s'\n",
cmd->label);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index f67bc0db5..e7c320eb1 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -3259,7 +3259,10 @@ client_connect_cb (void *cls,
tc->client = client;
tc->mq = mq;
GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, tc);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", tc);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client %p of type %u connected\n",
+ tc,
+ tc->type);
return tc;
}
@@ -5071,6 +5074,7 @@ handle_client_send (void *cls, const struct OutboundMessage *obm)
vl->pending_msg_tail,
pm);
check_vl_transmission (vl);
+ GNUNET_SERVICE_client_continue (tc->client);
}
@@ -10370,6 +10374,8 @@ do_shutdown (void *cls)
{
struct LearnLaunchEntry *lle;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "shutdown logic\n");
(void) cls;
GNUNET_CONTAINER_multipeermap_iterate (neighbours,
&free_neighbour_cb, NULL);
@@ -10450,7 +10456,9 @@ shutdown_task (void *cls)
{
in_shutdown = GNUNET_YES;
- if (NULL == clients_head)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Shutdown task executed\n");
+ if (NULL != clients_head)
{
for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
{
@@ -10459,7 +10467,8 @@ shutdown_task (void *cls)
tc->type);
}
}
- do_shutdown (cls);
+ else
+ do_shutdown (cls);
}
diff --git a/src/transport/test_transport_start_with_config.c b/src/transport/test_transport_start_with_config.c
index c3411becc..4705eb9b2 100644
--- a/src/transport/test_transport_start_with_config.c
+++ b/src/transport/test_transport_start_with_config.c
@@ -29,7 +29,7 @@
#include "transport-testing-cmds.h"
#include "gnunet_util_lib.h"
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
int
@@ -97,7 +97,8 @@ main (int argc,
GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed",
topology,
&read_file,
- topology_data_script),
+ topology_data_script,
+ TIMEOUT),
GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed",
"netjail-start-testbed",
topology),
diff --git a/src/transport/test_transport_udp_backchannel.sh b/src/transport/test_transport_udp_backchannel.sh
index 1b0e283b5..c52734a55 100755
--- a/src/transport/test_transport_udp_backchannel.sh
+++ b/src/transport/test_transport_udp_backchannel.sh
@@ -1,10 +1,13 @@
#!/bin/bash
+if [ -f "test.out" ]; then
+ rm test.out
+fi
if ! [ -d "/run/netns" ]; then
echo You have to create the directory /run/netns.
fi
if [ "$(cat /proc/sys/kernel/unprivileged_userns_clone)" == 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; GNUNET_FORCE_LOG='transport;;;;DEBUG' GNUNET_FORCE_LOGFILE='test.out' ./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; GNUNET_FORCE_LOG=';;;;DEBUG' GNUNET_FORCE_LOGFILE='test.out' ./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"
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"