aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing')
-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
4 files changed, 50 insertions, 20 deletions
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,