aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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,
386 * @param topology The complete topology information. 386 * @param topology The complete topology information.
387 * @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. 387 * @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.
388 * @param topology_data If read_file is GNUNET_NO, topology_data holds the string with the topology. 388 * @param topology_data If read_file is GNUNET_NO, topology_data holds the string with the topology.
389 * @param timeout Before this timeout is reached this cmd MUST finish.
389 * @return command. 390 * @return command.
390 */ 391 */
391struct GNUNET_TESTING_Command 392struct GNUNET_TESTING_Command
@@ -393,7 +394,8 @@ GNUNET_TESTING_cmd_netjail_start_testing_system (
393 const char *label, 394 const char *label,
394 struct GNUNET_TESTING_NetjailTopology *topology, 395 struct GNUNET_TESTING_NetjailTopology *topology,
395 unsigned int *read_file, 396 unsigned int *read_file,
396 char *topology_data); 397 char *topology_data,
398 struct GNUNET_TIME_Relative timeout);
397 399
398 400
399/** 401/**
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
510 510
511 511
512/** 512/**
513 * Getting the topology from file.
514 *
515 * @param filename The name of the topology file.
516 * @return The GNUNET_TESTING_NetjailTopology
517 */
518struct GNUNET_TESTING_NetjailTopology *
519GNUNET_TESTING_get_topo_from_file (const char *filename);
520
521
522/**
523 * Parse the topology data.
524 *
525 * @param data The topology data.
526 * @return The GNUNET_TESTING_NetjailTopology
527 */
528struct GNUNET_TESTING_NetjailTopology *
529GNUNET_TESTING_get_topo_from_string (char *data);
530
531
532/**
533 * Get the connections to other nodes for a specific node.
534 *
535 * @param num The specific node we want the connections for.
536 * @param topology The topology we get the connections from.
537 * @return The connections of the node.
538 */
539struct GNUNET_TESTING_NodeConnection *
540GNUNET_TESTING_get_connections (unsigned int num, struct
541 GNUNET_TESTING_NetjailTopology *topology);
542
543
544/**
545 * Get the address for a specific communicator from a connection.
546 *
547 * @param connection The connection we like to have the address from.
548 * @param prefix The communicator protocol prefix.
549 * @return The address of the communicator.
550 */
551char *
552GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection,
553 char *prefix);
554
555
556/**
557 * Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.
558 *
559 * @param topology The GNUNET_TESTING_NetjailTopology to be deallocated.
560 */
561void
562GNUNET_TESTING_free_topology (struct GNUNET_TESTING_NetjailTopology *topology);
563
564
565/**
566 * Calculate the unique id identifying a node from a given connction.
567 *
568 * @param node_connection The connection we calculate the id from.
569 * @param topology The topology we get all needed information from.
570 * @return The unique id of the node from the connection.
571 */
572unsigned int
573GNUNET_TESTING_calculate_num (struct
574 GNUNET_TESTING_NodeConnection *node_connection,
575 struct GNUNET_TESTING_NetjailTopology *topology);
576
577
578/**
579 * Retrieve the public key from the test system with the unique node id. 513 * Retrieve the public key from the test system with the unique node id.
580 * 514 *
581 * @param num The unique node id. 515 * @param num The unique node id.
@@ -744,6 +678,7 @@ GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits,
744 * Call #op on all simple traits. 678 * Call #op on all simple traits.
745 */ 679 */
746#define GNUNET_TESTING_SIMPLE_TRAITS(op) \ 680#define GNUNET_TESTING_SIMPLE_TRAITS(op) \
681 op (batch_cmds, struct GNUNET_TESTING_Command *) \
747 op (process, struct GNUNET_OS_Process *) 682 op (process, struct GNUNET_OS_Process *)
748 683
749 684
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;*/
186struct Plugin *plugin; 186struct Plugin *plugin;
187 187
188/** 188/**
189 * Handle to the testing system
190 */
191static struct GNUNET_TESTING_System *test_system;
192
193/**
194 * Our message stream tokenizer 189 * Our message stream tokenizer
195 */ 190 */
196struct GNUNET_MessageStreamTokenizer *tokenizer; 191struct GNUNET_MessageStreamTokenizer *tokenizer;
@@ -262,12 +257,6 @@ shutdown_task (void *cls)
262 (void) GNUNET_DISK_file_close (stdout_fd); 257 (void) GNUNET_DISK_file_close (stdout_fd);
263 GNUNET_MST_destroy (tokenizer); 258 GNUNET_MST_destroy (tokenizer);
264 tokenizer = NULL; 259 tokenizer = NULL;
265
266 if (NULL != test_system)
267 {
268 GNUNET_TESTING_system_destroy (test_system, GNUNET_YES);
269 test_system = NULL;
270 }
271} 260}
272 261
273 262
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 @@
30 30
31#define NETJAIL_EXEC_SCRIPT "netjail_exec.sh" 31#define NETJAIL_EXEC_SCRIPT "netjail_exec.sh"
32 32
33#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
34
33/** 35/**
34 * Generic logging shortcut 36 * Generic logging shortcut
35 */ 37 */
@@ -152,6 +154,16 @@ struct NetJailState
152 * String with topology data or name of topology file. 154 * String with topology data or name of topology file.
153 */ 155 */
154 char *topology_data; 156 char *topology_data;
157
158 /**
159 * Time after this cmd has to finish.
160 */
161 struct GNUNET_TIME_Relative timeout;
162
163 /**
164 * Timeout task.
165 */
166 struct GNUNET_SCHEDULER_Task *timeout_task;
155}; 167};
156 168
157/** 169/**
@@ -393,6 +405,7 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
393 ns->number_of_local_tests_finished++; 405 ns->number_of_local_tests_finished++;
394 if (ns->number_of_local_tests_finished == total_number) 406 if (ns->number_of_local_tests_finished == total_number)
395 { 407 {
408 GNUNET_SCHEDULER_cancel (ns->timeout_task);
396 GNUNET_TESTING_async_finish (&ns->ac); 409 GNUNET_TESTING_async_finish (&ns->ac);
397 } 410 }
398 break; 411 break;
@@ -489,6 +502,7 @@ exp_cb (void *cls)
489 struct TestingSystemCount *tbc = cls; 502 struct TestingSystemCount *tbc = cls;
490 503
491 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called exp_cb.\n"); 504 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called exp_cb.\n");
505 GNUNET_SCHEDULER_cancel (tbc->ns->timeout_task);
492 GNUNET_TESTING_async_fail (&(tbc->ns->ac)); 506 GNUNET_TESTING_async_fail (&(tbc->ns->ac));
493} 507}
494 508
@@ -696,6 +710,25 @@ start_helper (struct NetJailState *ns,
696 710
697 711
698/** 712/**
713 * Function run when the cmd terminates (good or bad) with timeout.
714 *
715 * @param cls the interpreter state
716 */
717static void
718do_timeout (void *cls)
719{
720 struct NetJailState *ns = cls;
721 struct GNUNET_TESTING_Command *cmd;
722
723 ns->timeout_task = NULL;
724 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
725 "Terminating cmd due to global timeout\n");
726 cmd = GNUNET_TESTING_interpreter_get_current_command (ns->is);
727 GNUNET_TESTING_async_finish (cmd->ac);
728}
729
730
731/**
699* This function starts a helper process for each node. 732* This function starts a helper process for each node.
700* 733*
701* @param cls closure. 734* @param cls closure.
@@ -725,6 +758,13 @@ netjail_exec_run (void *cls,
725 i); 758 i);
726 } 759 }
727 } 760 }
761 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
762 "Adding timeout %s\n",
763 GNUNET_STRINGS_relative_time_to_string (ns->timeout, GNUNET_NO));
764 ns->timeout_task
765 = GNUNET_SCHEDULER_add_delayed (ns->timeout,
766 &do_timeout,
767 ns);
728} 768}
729 769
730 770
@@ -735,6 +775,7 @@ netjail_exec_run (void *cls,
735 * @param topology The complete topology information. 775 * @param topology The complete topology information.
736 * @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. 776 * @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.
737 * @param topology_data If read_file is GNUNET_NO, topology_data holds the string with the topology. 777 * @param topology_data If read_file is GNUNET_NO, topology_data holds the string with the topology.
778 * @param timeout Before this timeout is reached this cmd MUST finish.
738 * @return command. 779 * @return command.
739 */ 780 */
740struct GNUNET_TESTING_Command 781struct GNUNET_TESTING_Command
@@ -742,7 +783,8 @@ GNUNET_TESTING_cmd_netjail_start_testing_system (
742 const char *label, 783 const char *label,
743 struct GNUNET_TESTING_NetjailTopology *topology, 784 struct GNUNET_TESTING_NetjailTopology *topology,
744 unsigned int *read_file, 785 unsigned int *read_file,
745 char *topology_data) 786 char *topology_data,
787 struct GNUNET_TIME_Relative timeout)
746{ 788{
747 struct NetJailState *ns; 789 struct NetJailState *ns;
748 790
@@ -754,6 +796,7 @@ GNUNET_TESTING_cmd_netjail_start_testing_system (
754 ns->topology = topology; 796 ns->topology = topology;
755 ns->read_file = read_file; 797 ns->read_file = read_file;
756 ns->topology_data = topology_data; 798 ns->topology_data = topology_data;
799 ns->timeout = GNUNET_TIME_relative_subtract (timeout, TIMEOUT);
757 800
758 struct GNUNET_TESTING_Command cmd = { 801 struct GNUNET_TESTING_Command cmd = {
759 .cls = ns, 802 .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,
118 + j 118 + j
119 + shs->known 119 + shs->known
120 - 1], 120 - 1],
121 GNUNET_YES); 121 GNUNET_NO);
122 } 122 }
123 } 123 }
124} 124}
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,
122 122
123 if (GNUNET_TESTING_cmd_is_batch_ (cmd)) 123 if (GNUNET_TESTING_cmd_is_batch_ (cmd))
124 { 124 {
125#define BATCH_INDEX 1 125 struct GNUNET_TESTING_Command **batch;
126 const struct GNUNET_TESTING_Command *batch;
127 struct GNUNET_TESTING_Command *current; 126 struct GNUNET_TESTING_Command *current;
128 const struct GNUNET_TESTING_Command *icmd; 127 const struct GNUNET_TESTING_Command *icmd;
129 const struct GNUNET_TESTING_Command *match; 128 const struct GNUNET_TESTING_Command *match;
130 129
131 current = GNUNET_TESTING_cmd_batch_get_current_ (cmd); 130 current = GNUNET_TESTING_cmd_batch_get_current_ (cmd);
132 GNUNET_assert (GNUNET_OK == 131 GNUNET_assert (GNUNET_OK ==
133 GNUNET_TESTING_get_trait_cmd (cmd, 132 GNUNET_TESTING_get_trait_batch_cmds (cmd,
134 BATCH_INDEX, 133 &batch));
135 &batch));
136 /* We must do the loop forward, but we can find the last match */ 134 /* We must do the loop forward, but we can find the last match */
137 match = NULL; 135 match = NULL;
138 for (unsigned int j = 0; 136 for (unsigned int j = 0;
139 NULL != (icmd = &batch[j])->label; 137 NULL != (icmd = &(*batch)[j])->label;
140 j++) 138 j++)
141 { 139 {
142 if (current == icmd) 140 if (current == icmd)
@@ -383,7 +381,7 @@ interpreter_run (void *cls)
383 finish_test (is); 381 finish_test (is);
384 return; 382 return;
385 } 383 }
386 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 384 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
387 "Running command `%s'\n", 385 "Running command `%s'\n",
388 cmd->label); 386 cmd->label);
389 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 387 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,
3259 tc->client = client; 3259 tc->client = client;
3260 tc->mq = mq; 3260 tc->mq = mq;
3261 GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, tc); 3261 GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, tc);
3262 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", tc); 3262 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3263 "Client %p of type %u connected\n",
3264 tc,
3265 tc->type);
3263 return tc; 3266 return tc;
3264} 3267}
3265 3268
@@ -5071,6 +5074,7 @@ handle_client_send (void *cls, const struct OutboundMessage *obm)
5071 vl->pending_msg_tail, 5074 vl->pending_msg_tail,
5072 pm); 5075 pm);
5073 check_vl_transmission (vl); 5076 check_vl_transmission (vl);
5077 GNUNET_SERVICE_client_continue (tc->client);
5074} 5078}
5075 5079
5076 5080
@@ -10370,6 +10374,8 @@ do_shutdown (void *cls)
10370{ 10374{
10371 struct LearnLaunchEntry *lle; 10375 struct LearnLaunchEntry *lle;
10372 10376
10377 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
10378 "shutdown logic\n");
10373 (void) cls; 10379 (void) cls;
10374 GNUNET_CONTAINER_multipeermap_iterate (neighbours, 10380 GNUNET_CONTAINER_multipeermap_iterate (neighbours,
10375 &free_neighbour_cb, NULL); 10381 &free_neighbour_cb, NULL);
@@ -10450,7 +10456,9 @@ shutdown_task (void *cls)
10450{ 10456{
10451 in_shutdown = GNUNET_YES; 10457 in_shutdown = GNUNET_YES;
10452 10458
10453 if (NULL == clients_head) 10459 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
10460 "Shutdown task executed\n");
10461 if (NULL != clients_head)
10454 { 10462 {
10455 for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) 10463 for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
10456 { 10464 {
@@ -10459,7 +10467,8 @@ shutdown_task (void *cls)
10459 tc->type); 10467 tc->type);
10460 } 10468 }
10461 } 10469 }
10462 do_shutdown (cls); 10470 else
10471 do_shutdown (cls);
10463 10472
10464} 10473}
10465 10474
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 @@
29#include "transport-testing-cmds.h" 29#include "transport-testing-cmds.h"
30#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
31 31
32#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) 32#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
33 33
34 34
35int 35int
@@ -97,7 +97,8 @@ main (int argc,
97 GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed", 97 GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed",
98 topology, 98 topology,
99 &read_file, 99 &read_file,
100 topology_data_script), 100 topology_data_script,
101 TIMEOUT),
101 GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed", 102 GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed",
102 "netjail-start-testbed", 103 "netjail-start-testbed",
103 topology), 104 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 @@
1#!/bin/bash 1#!/bin/bash
2if [ -f "test.out" ]; then
3 rm test.out
4fi
2if ! [ -d "/run/netns" ]; then 5if ! [ -d "/run/netns" ]; then
3 echo You have to create the directory /run/netns. 6 echo You have to create the directory /run/netns.
4fi 7fi
5if [ "$(cat /proc/sys/kernel/unprivileged_userns_clone)" == 1 ]; then 8if [ "$(cat /proc/sys/kernel/unprivileged_userns_clone)" == 1 ]; then
6#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" 9#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"
7exec 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" 10exec 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"
8# 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" 11# 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"
9else 12else
10 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" 13 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"