diff options
author | t3sserakt <t3ss@posteo.de> | 2021-12-06 14:20:25 +0100 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-12-06 14:20:25 +0100 |
commit | 1816cee6455627543262711524837164bbf48385 (patch) | |
tree | 931909154494dd49d8c9008ba3d3cca0c117b7e8 /src/testing/testing_api_cmd_netjail_start_testsystem.c | |
parent | 7a7f3d5e0f7b76c07a395e6e0b4af4f39c4a2895 (diff) | |
download | gnunet-1816cee6455627543262711524837164bbf48385.tar.gz gnunet-1816cee6455627543262711524837164bbf48385.zip |
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/testing/testing_api_cmd_netjail_start_testsystem.c')
-rw-r--r-- | src/testing/testing_api_cmd_netjail_start_testsystem.c | 45 |
1 files changed, 44 insertions, 1 deletions
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 | */ | ||
717 | static void | ||
718 | do_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 | */ |
740 | struct GNUNET_TESTING_Command | 781 | struct 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, |