diff options
-rw-r--r-- | po/POTFILES.in | 8 | ||||
-rw-r--r-- | src/include/gnunet_testing_ng_lib.h | 6 | ||||
-rw-r--r-- | src/testing/Makefile.am | 1 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_block_until_external_trigger.c | 139 | ||||
-rw-r--r-- | src/transport/Makefile.am | 12 | ||||
-rw-r--r-- | src/transport/test_transport_plugin_cmd_simple_send.c | 8 | ||||
-rw-r--r-- | src/transport/test_transport_plugin_cmd_simple_send_v2.c | 44 |
7 files changed, 176 insertions, 42 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in index f3c82b259..385aa00c4 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in | |||
@@ -429,8 +429,12 @@ src/testing/testing_api_cmd_hello_world_birth.c | |||
429 | src/testing/testing_api_cmd_local_test_finished.c | 429 | src/testing/testing_api_cmd_local_test_finished.c |
430 | src/testing/testing_api_cmd_netjail_start.c | 430 | src/testing/testing_api_cmd_netjail_start.c |
431 | src/testing/testing_api_cmd_netjail_start_testsystem.c | 431 | src/testing/testing_api_cmd_netjail_start_testsystem.c |
432 | src/testing/testing_api_cmd_netjail_start_testsystem_v2.c | ||
433 | src/testing/testing_api_cmd_netjail_start_v2.c | ||
432 | src/testing/testing_api_cmd_netjail_stop.c | 434 | src/testing/testing_api_cmd_netjail_stop.c |
433 | src/testing/testing_api_cmd_netjail_stop_testsystem.c | 435 | src/testing/testing_api_cmd_netjail_stop_testsystem.c |
436 | src/testing/testing_api_cmd_netjail_stop_testsystem_v2.c | ||
437 | src/testing/testing_api_cmd_netjail_stop_v2.c | ||
434 | src/testing/testing_api_cmd_send_peer_ready.c | 438 | src/testing/testing_api_cmd_send_peer_ready.c |
435 | src/testing/testing_api_cmd_system_create.c | 439 | src/testing/testing_api_cmd_system_create.c |
436 | src/testing/testing_api_cmd_system_destroy.c | 440 | src/testing/testing_api_cmd_system_destroy.c |
@@ -491,8 +495,11 @@ src/transport/transport_api2_monitor.c | |||
491 | src/transport/transport_api_address_to_string.c | 495 | src/transport/transport_api_address_to_string.c |
492 | src/transport/transport_api_blacklist.c | 496 | src/transport/transport_api_blacklist.c |
493 | src/transport/transport_api_cmd_connecting_peers.c | 497 | src/transport/transport_api_cmd_connecting_peers.c |
498 | src/transport/transport_api_cmd_connecting_peers_v2.c | ||
494 | src/transport/transport_api_cmd_send_simple.c | 499 | src/transport/transport_api_cmd_send_simple.c |
500 | src/transport/transport_api_cmd_send_simple_v2.c | ||
495 | src/transport/transport_api_cmd_start_peer.c | 501 | src/transport/transport_api_cmd_start_peer.c |
502 | src/transport/transport_api_cmd_start_peer_v2.c | ||
496 | src/transport/transport_api_cmd_stop_peer.c | 503 | src/transport/transport_api_cmd_stop_peer.c |
497 | src/transport/transport_api_core.c | 504 | src/transport/transport_api_core.c |
498 | src/transport/transport_api_hello_get.c | 505 | src/transport/transport_api_hello_get.c |
@@ -510,6 +517,7 @@ src/util/common_allocation.c | |||
510 | src/util/common_endian.c | 517 | src/util/common_endian.c |
511 | src/util/common_logging.c | 518 | src/util/common_logging.c |
512 | src/util/configuration.c | 519 | src/util/configuration.c |
520 | src/util/configuration_helper.c | ||
513 | src/util/consttime_memcmp.c | 521 | src/util/consttime_memcmp.c |
514 | src/util/container_bloomfilter.c | 522 | src/util/container_bloomfilter.c |
515 | src/util/container_heap.c | 523 | src/util/container_heap.c |
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h index a6f8429f4..9ef42a3aa 100644 --- a/src/include/gnunet_testing_ng_lib.h +++ b/src/include/gnunet_testing_ng_lib.h | |||
@@ -1085,6 +1085,12 @@ GNUNET_TESTING_cmd_block_until_all_peers_started (const char *label, | |||
1085 | unsigned int * | 1085 | unsigned int * |
1086 | all_peers_started); | 1086 | all_peers_started); |
1087 | 1087 | ||
1088 | |||
1089 | struct GNUNET_TESTING_Command | ||
1090 | GNUNET_TESTING_cmd_block_until_external_trigger (const char *label, | ||
1091 | unsigned int * | ||
1092 | stop_blocking); | ||
1093 | |||
1088 | struct GNUNET_TESTING_Command | 1094 | struct GNUNET_TESTING_Command |
1089 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, | 1095 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, |
1090 | TESTING_CMD_HELPER_write_cb write_message); | 1096 | TESTING_CMD_HELPER_write_cb write_message); |
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am index 3e9d15986..a584ad761 100644 --- a/src/testing/Makefile.am +++ b/src/testing/Makefile.am | |||
@@ -44,6 +44,7 @@ libgnunettesting_la_SOURCES = \ | |||
44 | testing_api_cmd_local_test_finished.c \ | 44 | testing_api_cmd_local_test_finished.c \ |
45 | testing_api_cmd_send_peer_ready.c \ | 45 | testing_api_cmd_send_peer_ready.c \ |
46 | testing_api_cmd_block_until_all_peers_started.c \ | 46 | testing_api_cmd_block_until_all_peers_started.c \ |
47 | testing_api_cmd_block_until_external_trigger.c \ | ||
47 | testing_api_cmd_netjail_start.c \ | 48 | testing_api_cmd_netjail_start.c \ |
48 | testing_api_cmd_netjail_start_v2.c \ | 49 | testing_api_cmd_netjail_start_v2.c \ |
49 | testing_api_cmd_netjail_start_testsystem.c \ | 50 | testing_api_cmd_netjail_start_testsystem.c \ |
diff --git a/src/testing/testing_api_cmd_block_until_external_trigger.c b/src/testing/testing_api_cmd_block_until_external_trigger.c new file mode 100644 index 000000000..2439afeaf --- /dev/null +++ b/src/testing/testing_api_cmd_block_until_external_trigger.c | |||
@@ -0,0 +1,139 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testing_api_cmd_block_until_all_peers_started.c | ||
23 | * @brief cmd to block the interpreter loop until all peers started. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testing_ng_lib.h" | ||
29 | |||
30 | /** | ||
31 | * Generic logging shortcut | ||
32 | */ | ||
33 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
34 | |||
35 | /** | ||
36 | * Struct with information for callbacks. | ||
37 | * | ||
38 | */ | ||
39 | struct BlockState | ||
40 | { | ||
41 | /** | ||
42 | * Flag to indicate if all peers have started. | ||
43 | * | ||
44 | */ | ||
45 | unsigned int *stop_blocking; | ||
46 | }; | ||
47 | |||
48 | |||
49 | /** | ||
50 | * Trait function of this cmd does nothing. | ||
51 | * | ||
52 | */ | ||
53 | static int | ||
54 | block_until_all_peers_started_traits (void *cls, | ||
55 | const void **ret, | ||
56 | const char *trait, | ||
57 | unsigned int index) | ||
58 | { | ||
59 | return GNUNET_OK; | ||
60 | } | ||
61 | |||
62 | |||
63 | /** | ||
64 | * The cleanup function of this cmd frees resources the cmd allocated. | ||
65 | * | ||
66 | */ | ||
67 | static void | ||
68 | block_until_all_peers_started_cleanup (void *cls, | ||
69 | const struct GNUNET_TESTING_Command *cmd) | ||
70 | { | ||
71 | struct BlockState *bs = cls; | ||
72 | |||
73 | GNUNET_free (bs); | ||
74 | } | ||
75 | |||
76 | |||
77 | /** | ||
78 | * This function does nothing but to start the cmd. | ||
79 | * | ||
80 | */ | ||
81 | static void | ||
82 | block_until_all_peers_started_run (void *cls, | ||
83 | const struct GNUNET_TESTING_Command *cmd, | ||
84 | struct GNUNET_TESTING_Interpreter *is) | ||
85 | { | ||
86 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
87 | "block_until_all_peers_started_run!\n"); | ||
88 | } | ||
89 | |||
90 | |||
91 | /** | ||
92 | * Function to check if BlockState#all_peers_started is GNUNET_YES. In that case interpreter_next will be called. | ||
93 | * | ||
94 | */ | ||
95 | static int | ||
96 | block_until_all_peers_started_finish (void *cls, | ||
97 | GNUNET_SCHEDULER_TaskCallback cont, | ||
98 | void *cont_cls) | ||
99 | { | ||
100 | struct BlockState *bs = cls; | ||
101 | unsigned int *ret = bs->stop_blocking; | ||
102 | |||
103 | if (GNUNET_YES == *ret) | ||
104 | { | ||
105 | cont (cont_cls); | ||
106 | } | ||
107 | |||
108 | return *ret; | ||
109 | } | ||
110 | |||
111 | |||
112 | /** | ||
113 | * Create command. | ||
114 | * | ||
115 | * @param label name for command. | ||
116 | * @param all_peers_started Flag which will be set from outside. | ||
117 | * @return command. | ||
118 | */ | ||
119 | struct GNUNET_TESTING_Command | ||
120 | GNUNET_TESTING_cmd_block_until_external_trigger (const char *label, | ||
121 | unsigned int * | ||
122 | stop_blocking) | ||
123 | { | ||
124 | struct BlockState *bs; | ||
125 | |||
126 | bs = GNUNET_new (struct BlockState); | ||
127 | bs->stop_blocking = stop_blocking; | ||
128 | |||
129 | struct GNUNET_TESTING_Command cmd = { | ||
130 | .cls = bs, | ||
131 | .label = label, | ||
132 | .run = &block_until_all_peers_started_run, | ||
133 | .finish = &block_until_all_peers_started_finish, | ||
134 | .cleanup = &block_until_all_peers_started_cleanup, | ||
135 | .traits = &block_until_all_peers_started_traits | ||
136 | }; | ||
137 | |||
138 | return cmd; | ||
139 | } | ||
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 8bd35b5a3..561ac5e60 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -401,7 +401,7 @@ libgnunet_test_transport_plugin_cmd_simple_send_la_SOURCES = \ | |||
401 | libgnunet_test_transport_plugin_cmd_simple_send_la_LIBADD = \ | 401 | libgnunet_test_transport_plugin_cmd_simple_send_la_LIBADD = \ |
402 | libgnunettransporttesting2.la \ | 402 | libgnunettransporttesting2.la \ |
403 | libgnunettransportapplication.la \ | 403 | libgnunettransportapplication.la \ |
404 | libgnunettransport.la \ | 404 | libgnunettransportcore.la \ |
405 | $(top_builddir)/src/testing/libgnunettesting.la \ | 405 | $(top_builddir)/src/testing/libgnunettesting.la \ |
406 | $(top_builddir)/src/peerstore/libgnunetpeerstore.la \ | 406 | $(top_builddir)/src/peerstore/libgnunetpeerstore.la \ |
407 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 407 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
@@ -418,7 +418,7 @@ libgnunet_test_transport_plugin_cmd_simple_send_v2_la_SOURCES = \ | |||
418 | libgnunet_test_transport_plugin_cmd_simple_send_v2_la_LIBADD = \ | 418 | libgnunet_test_transport_plugin_cmd_simple_send_v2_la_LIBADD = \ |
419 | libgnunettransporttesting2.la \ | 419 | libgnunettransporttesting2.la \ |
420 | libgnunettransportapplication.la \ | 420 | libgnunettransportapplication.la \ |
421 | libgnunettransport.la \ | 421 | libgnunettransportcore.la \ |
422 | $(top_builddir)/src/testing/libgnunettesting.la \ | 422 | $(top_builddir)/src/testing/libgnunettesting.la \ |
423 | $(top_builddir)/src/peerstore/libgnunetpeerstore.la \ | 423 | $(top_builddir)/src/peerstore/libgnunetpeerstore.la \ |
424 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 424 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
@@ -756,8 +756,8 @@ test_transport_simple_send_LDADD = \ | |||
756 | $(top_builddir)/src/util/libgnunetutil.la \ | 756 | $(top_builddir)/src/util/libgnunetutil.la \ |
757 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | 757 | $(top_builddir)/src/testbed/libgnunettestbed.la \ |
758 | $(top_builddir)/src/hello/libgnunethello.la \ | 758 | $(top_builddir)/src/hello/libgnunethello.la \ |
759 | libgnunettransport.la \ | 759 | libgnunettransportcore.la \ |
760 | libgnunettransporttesting.la | 760 | libgnunettransporttesting2.la |
761 | 761 | ||
762 | test_transport_simple_send_v2_SOURCES = \ | 762 | test_transport_simple_send_v2_SOURCES = \ |
763 | test_transport_simple_send_v2.c | 763 | test_transport_simple_send_v2.c |
@@ -766,8 +766,8 @@ test_transport_simple_send_v2_LDADD = \ | |||
766 | $(top_builddir)/src/util/libgnunetutil.la \ | 766 | $(top_builddir)/src/util/libgnunetutil.la \ |
767 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | 767 | $(top_builddir)/src/testbed/libgnunettestbed.la \ |
768 | $(top_builddir)/src/hello/libgnunethello.la \ | 768 | $(top_builddir)/src/hello/libgnunethello.la \ |
769 | libgnunettransport.la \ | 769 | libgnunettransportcore.la \ |
770 | libgnunettransporttesting.la | 770 | libgnunettransporttesting2.la |
771 | 771 | ||
772 | test_transport_testing_startstop_SOURCES = \ | 772 | test_transport_testing_startstop_SOURCES = \ |
773 | test_transport_testing_startstop.c | 773 | test_transport_testing_startstop.c |
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c index 1dc44c945..35aa07ecd 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send.c +++ b/src/transport/test_transport_plugin_cmd_simple_send.c | |||
@@ -55,6 +55,11 @@ char *cfgname; | |||
55 | */ | 55 | */ |
56 | unsigned int are_all_peers_started; | 56 | unsigned int are_all_peers_started; |
57 | 57 | ||
58 | /** | ||
59 | * Flag indicating a received message. | ||
60 | */ | ||
61 | unsigned int message_received; | ||
62 | |||
58 | 63 | ||
59 | /** | 64 | /** |
60 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being | 65 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being |
@@ -80,6 +85,7 @@ handle_test (void *cls, | |||
80 | { | 85 | { |
81 | LOG (GNUNET_ERROR_TYPE_ERROR, | 86 | LOG (GNUNET_ERROR_TYPE_ERROR, |
82 | "message received\n"); | 87 | "message received\n"); |
88 | message_received = GNUNET_YES; | ||
83 | } | 89 | } |
84 | 90 | ||
85 | 91 | ||
@@ -203,6 +209,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
203 | (atoi (n) - 1) * atoi (local_m) + atoi ( | 209 | (atoi (n) - 1) * atoi (local_m) + atoi ( |
204 | m), | 210 | m), |
205 | "start-peer"), | 211 | "start-peer"), |
212 | GNUNET_TESTING_cmd_block_until_external_trigger ("block-receive", | ||
213 | &message_received), | ||
206 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", | 214 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", |
207 | "start-peer"), | 215 | "start-peer"), |
208 | GNUNET_TESTING_cmd_system_destroy ("system-destroy", | 216 | GNUNET_TESTING_cmd_system_destroy ("system-destroy", |
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_v2.c b/src/transport/test_transport_plugin_cmd_simple_send_v2.c index ce1245296..c79b5c7e2 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send_v2.c +++ b/src/transport/test_transport_plugin_cmd_simple_send_v2.c | |||
@@ -57,6 +57,11 @@ char *cfgname; | |||
57 | */ | 57 | */ |
58 | unsigned int are_all_peers_started; | 58 | unsigned int are_all_peers_started; |
59 | 59 | ||
60 | /** | ||
61 | * Flag indicating a received message. | ||
62 | */ | ||
63 | unsigned int message_received; | ||
64 | |||
60 | 65 | ||
61 | /** | 66 | /** |
62 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being | 67 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being |
@@ -80,35 +85,7 @@ static void | |||
80 | handle_test (void *cls, | 85 | handle_test (void *cls, |
81 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | 86 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) |
82 | { | 87 | { |
83 | LOG (GNUNET_ERROR_TYPE_ERROR, | 88 | message_received = GNUNET_YES; |
84 | "message received\n"); | ||
85 | } | ||
86 | |||
87 | |||
88 | /** | ||
89 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2 | ||
90 | * being received. | ||
91 | * | ||
92 | */ | ||
93 | static int | ||
94 | check_test2 (void *cls, | ||
95 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | ||
96 | { | ||
97 | return GNUNET_OK; | ||
98 | } | ||
99 | |||
100 | |||
101 | /** | ||
102 | * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2 | ||
103 | * being received. | ||
104 | * | ||
105 | */ | ||
106 | static void | ||
107 | handle_test2 (void *cls, | ||
108 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | ||
109 | { | ||
110 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
111 | "message received\n"); | ||
112 | } | 89 | } |
113 | 90 | ||
114 | 91 | ||
@@ -120,9 +97,6 @@ static void | |||
120 | all_peers_started () | 97 | all_peers_started () |
121 | { | 98 | { |
122 | are_all_peers_started = GNUNET_YES; | 99 | are_all_peers_started = GNUNET_YES; |
123 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
124 | "setting are_all_peers_started: %d\n", | ||
125 | are_all_peers_started); | ||
126 | } | 100 | } |
127 | 101 | ||
128 | 102 | ||
@@ -181,10 +155,6 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
181 | GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE, | 155 | GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE, |
182 | struct GNUNET_TRANSPORT_TESTING_TestMessage, | 156 | struct GNUNET_TRANSPORT_TESTING_TestMessage, |
183 | NULL), | 157 | NULL), |
184 | GNUNET_MQ_hd_var_size (test2, | ||
185 | GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2, | ||
186 | struct GNUNET_TRANSPORT_TESTING_TestMessage, | ||
187 | NULL), | ||
188 | GNUNET_MQ_handler_end () | 158 | GNUNET_MQ_handler_end () |
189 | }; | 159 | }; |
190 | 160 | ||
@@ -208,6 +178,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
208 | GNUNET_TRANSPORT_cmd_send_simple_v2 ("send-simple", | 178 | GNUNET_TRANSPORT_cmd_send_simple_v2 ("send-simple", |
209 | "start-peer", | 179 | "start-peer", |
210 | num), | 180 | num), |
181 | GNUNET_TESTING_cmd_block_until_external_trigger ("block-receive", | ||
182 | &message_received), | ||
211 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", | 183 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", |
212 | "start-peer"), | 184 | "start-peer"), |
213 | GNUNET_TESTING_cmd_system_destroy ("system-destroy", | 185 | GNUNET_TESTING_cmd_system_destroy ("system-destroy", |