diff options
author | t3sserakt <t3ss@posteo.de> | 2022-12-07 12:42:31 +0100 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2022-12-07 12:42:31 +0100 |
commit | 34e1c58cb39a649c9a4c551681cedf19807b85f0 (patch) | |
tree | 79ea7222958c3ae086b2b2367f22cb66936ad045 /src/transport | |
parent | 8804d3efd5bccce3a5d7638a5fcb33450ade2f07 (diff) | |
download | gnunet-34e1c58cb39a649c9a4c551681cedf19807b85f0.tar.gz gnunet-34e1c58cb39a649c9a4c551681cedf19807b85f0.zip |
- added configuration to be able to start executables on a router node
- added barrier functionality
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/Makefile.am | 20 | ||||
-rw-r--r-- | src/transport/gnunet-service-tng.c | 5 | ||||
-rwxr-xr-x | src/transport/test_transport_nat_upnp.sh (renamed from src/transport/test_transport_simple_send_dv.sh) | 2 | ||||
-rw-r--r-- | src/transport/test_transport_plugin_cmd_nat_upnp.c | 397 | ||||
-rw-r--r-- | src/transport/test_transport_plugin_cmd_simple_send.c | 29 | ||||
-rw-r--r-- | src/transport/test_transport_plugin_cmd_simple_send_broadcast.c | 30 | ||||
-rw-r--r-- | src/transport/test_transport_plugin_cmd_simple_send_dv.c | 30 | ||||
-rw-r--r-- | src/transport/test_transport_plugin_cmd_udp_backchannel.c | 30 |
8 files changed, 534 insertions, 9 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 363f8b199..f56ae1753 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -357,11 +357,29 @@ plugin_LTLIBRARIES = \ | |||
357 | $(HTTPS_SERVER_PLUGIN_LA) \ | 357 | $(HTTPS_SERVER_PLUGIN_LA) \ |
358 | $(WLAN_PLUGIN_LA) \ | 358 | $(WLAN_PLUGIN_LA) \ |
359 | $(BT_PLUGIN_LA) \ | 359 | $(BT_PLUGIN_LA) \ |
360 | libgnunet_test_transport_plugin_cmd_nat_upnp.la \ | ||
360 | libgnunet_test_transport_plugin_cmd_simple_send.la \ | 361 | libgnunet_test_transport_plugin_cmd_simple_send.la \ |
361 | libgnunet_test_transport_plugin_cmd_simple_send_broadcast.la \ | 362 | libgnunet_test_transport_plugin_cmd_simple_send_broadcast.la \ |
362 | libgnunet_test_transport_plugin_cmd_simple_send_dv.la \ | 363 | libgnunet_test_transport_plugin_cmd_simple_send_dv.la \ |
363 | libgnunet_test_transport_plugin_cmd_udp_backchannel.la | 364 | libgnunet_test_transport_plugin_cmd_udp_backchannel.la |
364 | 365 | ||
366 | libgnunet_test_transport_plugin_cmd_nat_upnp_la_SOURCES = \ | ||
367 | test_transport_plugin_cmd_nat_upnp.c | ||
368 | libgnunet_test_transport_plugin_cmd_nat_upnp_la_LIBADD = \ | ||
369 | libgnunettransporttesting2.la \ | ||
370 | libgnunettransportapplication.la \ | ||
371 | libgnunettransportcore.la \ | ||
372 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
373 | $(top_builddir)/src/peerstore/libgnunetpeerstore.la \ | ||
374 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
375 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
376 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
377 | $(top_builddir)/src/arm/libgnunetarm.la \ | ||
378 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
379 | $(LTLIBINTL) | ||
380 | libgnunet_test_transport_plugin_cmd_nat_upnp_la_LDFLAGS = \ | ||
381 | $(GN_PLUGIN_LDFLAGS) | ||
382 | |||
365 | libgnunet_test_transport_plugin_cmd_udp_backchannel_la_SOURCES = \ | 383 | libgnunet_test_transport_plugin_cmd_udp_backchannel_la_SOURCES = \ |
366 | test_transport_plugin_cmd_udp_backchannel.c | 384 | test_transport_plugin_cmd_udp_backchannel.c |
367 | libgnunet_test_transport_plugin_cmd_udp_backchannel_la_LIBADD = \ | 385 | libgnunet_test_transport_plugin_cmd_udp_backchannel_la_LIBADD = \ |
@@ -742,6 +760,7 @@ endif | |||
742 | # Only test TNG if we run experimental | 760 | # Only test TNG if we run experimental |
743 | if HAVE_EXPERIMENTAL | 761 | if HAVE_EXPERIMENTAL |
744 | check_SCRIPTS= \ | 762 | check_SCRIPTS= \ |
763 | test_transport_nat_upnp.sh \ | ||
745 | test_transport_simple_send_string.sh \ | 764 | test_transport_simple_send_string.sh \ |
746 | test_transport_simple_send.sh \ | 765 | test_transport_simple_send.sh \ |
747 | test_transport_simple_send_broadcast.sh \ | 766 | test_transport_simple_send_broadcast.sh \ |
@@ -1490,6 +1509,7 @@ test_transport_api_slow_ats_LDADD = \ | |||
1490 | 1509 | ||
1491 | 1510 | ||
1492 | EXTRA_DIST = \ | 1511 | EXTRA_DIST = \ |
1512 | test_transport_nat_upnp.sh \ | ||
1493 | test_transport_simple_send_string.sh \ | 1513 | test_transport_simple_send_string.sh \ |
1494 | test_transport_simple_send.sh \ | 1514 | test_transport_simple_send.sh \ |
1495 | test_transport_simple_send_broadcast.sh \ | 1515 | test_transport_simple_send_broadcast.sh \ |
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index 5976bd5b1..512b77a9d 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -4489,8 +4489,13 @@ queue_send_msg (struct Queue *queue, | |||
4489 | GNUNET_assert (CT_COMMUNICATOR == queue->tc->type); | 4489 | GNUNET_assert (CT_COMMUNICATOR == queue->tc->type); |
4490 | queue->queue_length++; | 4490 | queue->queue_length++; |
4491 | queue->tc->details.communicator.total_queue_length++; | 4491 | queue->tc->details.communicator.total_queue_length++; |
4492 | //FIXME Probably this if statement here is completely wrong in this method, | ||
4493 | // and only fixed a symptom, but not an actual bug. | ||
4492 | if (0 == queue->q_capacity) | 4494 | if (0 == queue->q_capacity) |
4495 | { | ||
4496 | GNUNET_free (env); | ||
4493 | return; | 4497 | return; |
4498 | } | ||
4494 | if (GNUNET_NO == queue->unlimited_length) | 4499 | if (GNUNET_NO == queue->unlimited_length) |
4495 | queue->q_capacity--; | 4500 | queue->q_capacity--; |
4496 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4501 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
diff --git a/src/transport/test_transport_simple_send_dv.sh b/src/transport/test_transport_nat_upnp.sh index b57ee0629..f9dfca71f 100755 --- a/src/transport/test_transport_simple_send_dv.sh +++ b/src/transport/test_transport_nat_upnp.sh | |||
@@ -8,4 +8,4 @@ if [ -f /proc/sys/kernel/unprivileged_userns_clone ]; then | |||
8 | exit 78 | 8 | exit 78 |
9 | fi | 9 | fi |
10 | fi | 10 | fi |
11 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_distance_vector_topo.conf" | 11 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_nat_upnp_topo.conf" |
diff --git a/src/transport/test_transport_plugin_cmd_nat_upnp.c b/src/transport/test_transport_plugin_cmd_nat_upnp.c new file mode 100644 index 000000000..86280c66b --- /dev/null +++ b/src/transport/test_transport_plugin_cmd_nat_upnp.c | |||
@@ -0,0 +1,397 @@ | |||
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 testbed/plugin_cmd_simple_send.c | ||
23 | * @brief a plugin to provide the API for running test cases. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_testing_ng_lib.h" | ||
28 | #include "gnunet_testing_netjail_lib.h" | ||
29 | #include "gnunet_util_lib.h" | ||
30 | #include "gnunet_transport_application_service.h" | ||
31 | #include "transport-testing2.h" | ||
32 | #include "transport-testing-cmds.h" | ||
33 | #include "gnunet_testing_barrier.h" | ||
34 | |||
35 | /** | ||
36 | * Generic logging shortcut | ||
37 | */ | ||
38 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
39 | |||
40 | #define BASE_DIR "testdir" | ||
41 | |||
42 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" | ||
43 | |||
44 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600) | ||
45 | |||
46 | static struct GNUNET_TESTING_Command block_send; | ||
47 | |||
48 | static struct GNUNET_TESTING_Command block_receive; | ||
49 | |||
50 | static struct GNUNET_TESTING_Command connect_peers; | ||
51 | |||
52 | static struct GNUNET_TESTING_Command local_prepared; | ||
53 | |||
54 | static struct GNUNET_TESTING_Interpreter *is; | ||
55 | |||
56 | /** | ||
57 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being | ||
58 | * received. | ||
59 | * | ||
60 | */ | ||
61 | static int | ||
62 | check_test (void *cls, | ||
63 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | ||
64 | { | ||
65 | return GNUNET_OK; | ||
66 | } | ||
67 | |||
68 | |||
69 | /** | ||
70 | * Function called to handle a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE | ||
71 | * being received. | ||
72 | * | ||
73 | */ | ||
74 | static void | ||
75 | handle_test (void *cls, | ||
76 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | ||
77 | { | ||
78 | const struct GNUNET_TESTING_AsyncContext *ac; | ||
79 | |||
80 | GNUNET_TESTING_get_trait_async_context (&block_receive, | ||
81 | &ac); | ||
82 | GNUNET_assert (NULL != ac); | ||
83 | if (NULL == ac->cont) | ||
84 | GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) ac); | ||
85 | else | ||
86 | GNUNET_TESTING_async_finish ((struct GNUNET_TESTING_AsyncContext *) ac); | ||
87 | } | ||
88 | |||
89 | |||
90 | struct GNUNET_TESTING_Barrier * | ||
91 | get_waiting_for_barriers () | ||
92 | { | ||
93 | struct GNUNET_TESTING_Barrier *barriers_head; | ||
94 | struct GNUNET_TESTING_Barrier *barriers_tail; | ||
95 | struct GNUNET_TESTING_Barrier *ready_to_connect; | ||
96 | struct GNUNET_TESTING_Barrier *test_case_finished; | ||
97 | |||
98 | ready_to_connect = GNUNET_new (struct GNUNET_TESTING_Barrier); | ||
99 | ready_to_connect->name = "ready-to-connect"; | ||
100 | test_case_finished = GNUNET_new (struct GNUNET_TESTING_Barrier); | ||
101 | test_case_finished->name = "test-case-finished"; | ||
102 | GNUNET_CONTAINER_DLL_insert (barriers_head, barriers_tail, ready_to_connect); | ||
103 | GNUNET_CONTAINER_DLL_insert (barriers_head, barriers_tail, test_case_finished); | ||
104 | return barriers_head; | ||
105 | } | ||
106 | |||
107 | |||
108 | static void | ||
109 | barrier_advanced (const char *barrier_name) | ||
110 | { | ||
111 | struct GNUNET_TESTING_Barrier *barrier = GNUNET_TESTING_get_barrier (is, barrier_name); | ||
112 | |||
113 | GNUNET_TESTING_finish_attached_cmds (is, barrier); | ||
114 | } | ||
115 | |||
116 | |||
117 | /** | ||
118 | * Callback to set the flag indicating all peers started. Will be called via the plugin api. | ||
119 | * | ||
120 | */ | ||
121 | static void | ||
122 | all_peers_started () | ||
123 | { | ||
124 | const struct GNUNET_TESTING_AsyncContext *ac; | ||
125 | |||
126 | GNUNET_TESTING_get_trait_async_context (&block_send, | ||
127 | &ac); | ||
128 | GNUNET_assert (NULL != ac); | ||
129 | if (NULL == ac->cont) | ||
130 | GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) ac); | ||
131 | else | ||
132 | GNUNET_TESTING_async_finish ((struct GNUNET_TESTING_AsyncContext *) ac); | ||
133 | } | ||
134 | |||
135 | |||
136 | /** | ||
137 | * Function called with the final result of the test. | ||
138 | * | ||
139 | * @param cls the `struct MainParams` | ||
140 | * @param rv #GNUNET_OK if the test passed | ||
141 | */ | ||
142 | static void | ||
143 | handle_result (void *cls, | ||
144 | enum GNUNET_GenericReturnValue rv) | ||
145 | { | ||
146 | struct TestState *ts = cls; | ||
147 | |||
148 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
149 | "Local test exits with status %d\n", | ||
150 | rv); | ||
151 | |||
152 | ts->finished_cb (); | ||
153 | GNUNET_free (ts->testdir); | ||
154 | GNUNET_free (ts->cfgname); | ||
155 | GNUNET_TESTING_free_topology (ts->topology); | ||
156 | GNUNET_free (ts); | ||
157 | } | ||
158 | |||
159 | |||
160 | /** | ||
161 | * Callback from start peer cmd for signaling a peer got connected. | ||
162 | * | ||
163 | */ | ||
164 | static void * | ||
165 | notify_connect (struct GNUNET_TESTING_Interpreter *is, | ||
166 | const struct GNUNET_PeerIdentity *peer) | ||
167 | { | ||
168 | const struct ConnectPeersState *cps; | ||
169 | const struct GNUNET_TESTING_Command *cmd; | ||
170 | |||
171 | cmd = GNUNET_TESTING_interpreter_lookup_command (is, | ||
172 | "connect-peers"); | ||
173 | GNUNET_TRANSPORT_get_trait_connect_peer_state (cmd, | ||
174 | &cps); | ||
175 | void *ret = NULL; | ||
176 | |||
177 | cps->notify_connect (is, | ||
178 | peer); | ||
179 | return ret; | ||
180 | } | ||
181 | |||
182 | |||
183 | /** | ||
184 | * Callback to set the flag indicating all peers are prepared to finish. Will be called via the plugin api. | ||
185 | */ | ||
186 | static void | ||
187 | all_local_tests_prepared () | ||
188 | { | ||
189 | const struct LocalPreparedState *lfs; | ||
190 | |||
191 | GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared, | ||
192 | &lfs); | ||
193 | GNUNET_assert (NULL != &lfs->ac); | ||
194 | if (NULL == lfs->ac.cont) | ||
195 | GNUNET_TESTING_async_fail ((struct GNUNET_TESTING_AsyncContext *) &lfs->ac); | ||
196 | else | ||
197 | GNUNET_TESTING_async_finish ((struct | ||
198 | GNUNET_TESTING_AsyncContext *) &lfs->ac); | ||
199 | } | ||
200 | |||
201 | |||
202 | /** | ||
203 | * Function to start a local test case. | ||
204 | * | ||
205 | * @param write_message Callback to send a message to the master loop. | ||
206 | * @param router_ip Global address of the network namespace. | ||
207 | * @param node_ip Local address of a node i a network namespace. | ||
208 | * @param m The number of the node in a network namespace. | ||
209 | * @param n The number of the network namespace. | ||
210 | * @param local_m The number of nodes in a network namespace. | ||
211 | */ | ||
212 | static void | ||
213 | start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | ||
214 | char *node_ip, | ||
215 | char *m, | ||
216 | char *n, | ||
217 | char *local_m, | ||
218 | char *topology_data, | ||
219 | unsigned int *read_file, | ||
220 | TESTING_CMD_HELPER_finish_cb finished_cb) | ||
221 | { | ||
222 | |||
223 | unsigned int n_int; | ||
224 | unsigned int m_int; | ||
225 | unsigned int local_m_int; | ||
226 | unsigned int num; | ||
227 | struct TestState *ts = GNUNET_new (struct TestState); | ||
228 | struct GNUNET_TESTING_NetjailTopology *topology; | ||
229 | unsigned int sscanf_ret = 0; | ||
230 | |||
231 | ts->finished_cb = finished_cb; | ||
232 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
233 | "n %s m %s\n", | ||
234 | n, | ||
235 | m); | ||
236 | |||
237 | if (GNUNET_YES == *read_file) | ||
238 | { | ||
239 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
240 | "read from file\n"); | ||
241 | topology = GNUNET_TESTING_get_topo_from_file (topology_data); | ||
242 | } | ||
243 | else | ||
244 | topology = GNUNET_TESTING_get_topo_from_string (topology_data); | ||
245 | |||
246 | ts->topology = topology; | ||
247 | |||
248 | errno = 0; | ||
249 | sscanf_ret = sscanf (m, "%u", &m_int); | ||
250 | if (errno != 0) | ||
251 | { | ||
252 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); | ||
253 | } | ||
254 | GNUNET_assert (0 < sscanf_ret); | ||
255 | errno = 0; | ||
256 | sscanf_ret = sscanf (n, "%u", &n_int); | ||
257 | if (errno != 0) | ||
258 | { | ||
259 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); | ||
260 | } | ||
261 | GNUNET_assert (0 < sscanf_ret); | ||
262 | errno = 0; | ||
263 | sscanf_ret = sscanf (local_m, "%u", &local_m_int); | ||
264 | if (errno != 0) | ||
265 | { | ||
266 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); | ||
267 | } | ||
268 | GNUNET_assert (0 < sscanf_ret); | ||
269 | |||
270 | if (0 == n_int) | ||
271 | num = m_int; | ||
272 | else | ||
273 | num = (n_int - 1) * local_m_int + m_int + topology->nodes_x; | ||
274 | |||
275 | block_send = GNUNET_TESTING_cmd_block_until_external_trigger ( | ||
276 | "block"); | ||
277 | block_receive = GNUNET_TESTING_cmd_block_until_external_trigger ( | ||
278 | "block-receive"); | ||
279 | connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers", | ||
280 | "start-peer", | ||
281 | "system-create", | ||
282 | num, | ||
283 | topology, | ||
284 | 0); | ||
285 | local_prepared = GNUNET_TESTING_cmd_local_test_prepared ( | ||
286 | "local-test-prepared", | ||
287 | write_message); | ||
288 | |||
289 | |||
290 | GNUNET_asprintf (&ts->cfgname, | ||
291 | "test_transport_api2_tcp_node1.conf"); | ||
292 | |||
293 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
294 | "plugin cfgname: %s\n", | ||
295 | ts->cfgname); | ||
296 | |||
297 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
298 | "node ip: %s\n", | ||
299 | node_ip); | ||
300 | |||
301 | GNUNET_asprintf (&ts->testdir, | ||
302 | "%s%s%s", | ||
303 | BASE_DIR, | ||
304 | m, | ||
305 | n); | ||
306 | |||
307 | struct GNUNET_MQ_MessageHandler handlers[] = { | ||
308 | GNUNET_MQ_hd_var_size (test, | ||
309 | GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE, | ||
310 | struct GNUNET_TRANSPORT_TESTING_TestMessage, | ||
311 | ts), | ||
312 | GNUNET_MQ_handler_end () | ||
313 | }; | ||
314 | |||
315 | struct GNUNET_TESTING_Command commands[] = { | ||
316 | GNUNET_TESTING_cmd_system_create ("system-create", | ||
317 | ts->testdir), | ||
318 | GNUNET_TRANSPORT_cmd_start_peer ("start-peer", | ||
319 | "system-create", | ||
320 | num, | ||
321 | node_ip, | ||
322 | handlers, | ||
323 | ts->cfgname, | ||
324 | notify_connect, | ||
325 | GNUNET_NO), | ||
326 | GNUNET_TESTING_cmd_barrier_create ("ready-to-connect", | ||
327 | 0.0, | ||
328 | 2), | ||
329 | connect_peers, | ||
330 | GNUNET_TRANSPORT_cmd_send_simple ("send-simple", | ||
331 | "start-peer", | ||
332 | "system-create", | ||
333 | num, | ||
334 | topology), | ||
335 | block_receive, | ||
336 | GNUNET_TESTING_cmd_barrier_create ("test-case-finished", | ||
337 | 0.0, | ||
338 | 2), | ||
339 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", | ||
340 | "start-peer"), | ||
341 | GNUNET_TESTING_cmd_system_destroy ("system-destroy", | ||
342 | "system-create"), | ||
343 | GNUNET_TESTING_cmd_end () | ||
344 | }; | ||
345 | |||
346 | ts->write_message = write_message; | ||
347 | |||
348 | is = GNUNET_TESTING_run (commands, | ||
349 | TIMEOUT, | ||
350 | &handle_result, | ||
351 | ts); | ||
352 | |||
353 | } | ||
354 | |||
355 | |||
356 | /** | ||
357 | * Entry point for the plugin. | ||
358 | * | ||
359 | * @param cls NULL | ||
360 | * @return the exported block API | ||
361 | */ | ||
362 | void * | ||
363 | libgnunet_test_transport_plugin_cmd_nat_upnp_init (void *cls) | ||
364 | { | ||
365 | struct GNUNET_TESTING_PluginFunctions *api; | ||
366 | |||
367 | GNUNET_log_setup ("simple-send", | ||
368 | "DEBUG", | ||
369 | NULL); | ||
370 | |||
371 | api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions); | ||
372 | api->start_testcase = &start_testcase; | ||
373 | api->all_peers_started = &all_peers_started; | ||
374 | api->all_local_tests_prepared = all_local_tests_prepared; | ||
375 | api->barrier_advanced = barrier_advanced; | ||
376 | api->get_waiting_for_barriers = get_waiting_for_barriers; | ||
377 | return api; | ||
378 | } | ||
379 | |||
380 | |||
381 | /** | ||
382 | * Exit point from the plugin. | ||
383 | * | ||
384 | * @param cls the return value from #libgnunet_test_transport_plugin_block_test_init | ||
385 | * @return NULL | ||
386 | */ | ||
387 | void * | ||
388 | libgnunet_test_transport_plugin_cmd_simple_send_done (void *cls) | ||
389 | { | ||
390 | struct GNUNET_TESTING_PluginFunctions *api = cls; | ||
391 | |||
392 | GNUNET_free (api); | ||
393 | return NULL; | ||
394 | } | ||
395 | |||
396 | |||
397 | /* end of plugin_cmd_simple_send.c */ | ||
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c index 5941a991b..c9acb0431 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send.c +++ b/src/transport/test_transport_plugin_cmd_simple_send.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "gnunet_transport_application_service.h" | 30 | #include "gnunet_transport_application_service.h" |
31 | #include "transport-testing2.h" | 31 | #include "transport-testing2.h" |
32 | #include "transport-testing-cmds.h" | 32 | #include "transport-testing-cmds.h" |
33 | #include "gnunet_testing_barrier.h" | ||
33 | 34 | ||
34 | /** | 35 | /** |
35 | * Generic logging shortcut | 36 | * Generic logging shortcut |
@@ -40,6 +41,8 @@ | |||
40 | 41 | ||
41 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" | 42 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" |
42 | 43 | ||
44 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600) | ||
45 | |||
43 | static struct GNUNET_TESTING_Command block_send; | 46 | static struct GNUNET_TESTING_Command block_send; |
44 | 47 | ||
45 | static struct GNUNET_TESTING_Command block_receive; | 48 | static struct GNUNET_TESTING_Command block_receive; |
@@ -48,6 +51,7 @@ static struct GNUNET_TESTING_Command connect_peers; | |||
48 | 51 | ||
49 | static struct GNUNET_TESTING_Command local_prepared; | 52 | static struct GNUNET_TESTING_Command local_prepared; |
50 | 53 | ||
54 | static struct GNUNET_TESTING_Interpreter *is; | ||
51 | 55 | ||
52 | /** | 56 | /** |
53 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being | 57 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being |
@@ -83,6 +87,25 @@ handle_test (void *cls, | |||
83 | } | 87 | } |
84 | 88 | ||
85 | 89 | ||
90 | struct GNUNET_TESTING_Barrier * | ||
91 | get_waiting_for_barriers () | ||
92 | { | ||
93 | struct GNUNET_TESTING_Barrier *barrier; | ||
94 | |||
95 | //No Barrier | ||
96 | return NULL; | ||
97 | } | ||
98 | |||
99 | |||
100 | static void | ||
101 | barrier_advanced (const char *barrier_name) | ||
102 | { | ||
103 | struct GNUNET_TESTING_Barrier *barrier = GNUNET_TESTING_get_barrier (is, barrier_name); | ||
104 | |||
105 | GNUNET_TESTING_finish_attached_cmds (is, barrier); | ||
106 | } | ||
107 | |||
108 | |||
86 | /** | 109 | /** |
87 | * Callback to set the flag indicating all peers started. Will be called via the plugin api. | 110 | * Callback to set the flag indicating all peers started. Will be called via the plugin api. |
88 | * | 111 | * |
@@ -312,8 +335,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
312 | 335 | ||
313 | ts->write_message = write_message; | 336 | ts->write_message = write_message; |
314 | 337 | ||
315 | GNUNET_TESTING_run (commands, | 338 | is = GNUNET_TESTING_run (commands, |
316 | GNUNET_TIME_UNIT_FOREVER_REL, | 339 | TIMEOUT, |
317 | &handle_result, | 340 | &handle_result, |
318 | ts); | 341 | ts); |
319 | 342 | ||
@@ -339,6 +362,8 @@ libgnunet_test_transport_plugin_cmd_simple_send_init (void *cls) | |||
339 | api->start_testcase = &start_testcase; | 362 | api->start_testcase = &start_testcase; |
340 | api->all_peers_started = &all_peers_started; | 363 | api->all_peers_started = &all_peers_started; |
341 | api->all_local_tests_prepared = all_local_tests_prepared; | 364 | api->all_local_tests_prepared = all_local_tests_prepared; |
365 | api->barrier_advanced = barrier_advanced; | ||
366 | api->get_waiting_for_barriers = get_waiting_for_barriers; | ||
342 | return api; | 367 | return api; |
343 | } | 368 | } |
344 | 369 | ||
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c index 3a282bb11..f7a4b117f 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c +++ b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "gnunet_transport_application_service.h" | 30 | #include "gnunet_transport_application_service.h" |
31 | #include "transport-testing2.h" | 31 | #include "transport-testing2.h" |
32 | #include "transport-testing-cmds.h" | 32 | #include "transport-testing-cmds.h" |
33 | #include "gnunet_testing_barrier.h" | ||
33 | 34 | ||
34 | /** | 35 | /** |
35 | * Generic logging shortcut | 36 | * Generic logging shortcut |
@@ -40,6 +41,8 @@ | |||
40 | 41 | ||
41 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" | 42 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" |
42 | 43 | ||
44 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600) | ||
45 | |||
43 | static struct GNUNET_TESTING_Command block_send; | 46 | static struct GNUNET_TESTING_Command block_send; |
44 | 47 | ||
45 | static struct GNUNET_TESTING_Command block_receive; | 48 | static struct GNUNET_TESTING_Command block_receive; |
@@ -48,6 +51,8 @@ static struct GNUNET_TESTING_Command connect_peers; | |||
48 | 51 | ||
49 | static struct GNUNET_TESTING_Command local_prepared; | 52 | static struct GNUNET_TESTING_Command local_prepared; |
50 | 53 | ||
54 | static struct GNUNET_TESTING_Interpreter *is; | ||
55 | |||
51 | /** | 56 | /** |
52 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being | 57 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being |
53 | * received. | 58 | * received. |
@@ -82,6 +87,25 @@ handle_test (void *cls, | |||
82 | } | 87 | } |
83 | 88 | ||
84 | 89 | ||
90 | struct GNUNET_TESTING_Barrier * | ||
91 | get_waiting_for_barriers () | ||
92 | { | ||
93 | struct GNUNET_TESTING_Barrier *barrier; | ||
94 | |||
95 | //No Barrier | ||
96 | return NULL; | ||
97 | } | ||
98 | |||
99 | |||
100 | static void | ||
101 | barrier_advanced (const char *barrier_name) | ||
102 | { | ||
103 | struct GNUNET_TESTING_Barrier *barrier = GNUNET_TESTING_get_barrier (is, barrier_name); | ||
104 | |||
105 | GNUNET_TESTING_finish_attached_cmds (is, barrier); | ||
106 | } | ||
107 | |||
108 | |||
85 | /** | 109 | /** |
86 | * Callback to set the flag indicating all peers started. Will be called via the plugin api. | 110 | * Callback to set the flag indicating all peers started. Will be called via the plugin api. |
87 | * | 111 | * |
@@ -338,8 +362,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
338 | 362 | ||
339 | ts->write_message = write_message; | 363 | ts->write_message = write_message; |
340 | 364 | ||
341 | GNUNET_TESTING_run (commands, | 365 | is = GNUNET_TESTING_run (commands, |
342 | GNUNET_TIME_UNIT_FOREVER_REL, | 366 | TIMEOUT, |
343 | &handle_result, | 367 | &handle_result, |
344 | ts); | 368 | ts); |
345 | 369 | ||
@@ -365,6 +389,8 @@ libgnunet_test_transport_plugin_cmd_simple_send_broadcast_init (void *cls) | |||
365 | api->start_testcase = &start_testcase; | 389 | api->start_testcase = &start_testcase; |
366 | api->all_peers_started = &all_peers_started; | 390 | api->all_peers_started = &all_peers_started; |
367 | api->all_local_tests_prepared = all_local_tests_prepared; | 391 | api->all_local_tests_prepared = all_local_tests_prepared; |
392 | api->barrier_advanced = barrier_advanced; | ||
393 | api->get_waiting_for_barriers = get_waiting_for_barriers; | ||
368 | return api; | 394 | return api; |
369 | } | 395 | } |
370 | 396 | ||
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_dv.c b/src/transport/test_transport_plugin_cmd_simple_send_dv.c index 8bfa1fd0a..674c0d576 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send_dv.c +++ b/src/transport/test_transport_plugin_cmd_simple_send_dv.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "gnunet_transport_application_service.h" | 30 | #include "gnunet_transport_application_service.h" |
31 | #include "transport-testing2.h" | 31 | #include "transport-testing2.h" |
32 | #include "transport-testing-cmds.h" | 32 | #include "transport-testing-cmds.h" |
33 | #include "gnunet_testing_barrier.h" | ||
33 | 34 | ||
34 | /** | 35 | /** |
35 | * Generic logging shortcut | 36 | * Generic logging shortcut |
@@ -40,6 +41,8 @@ | |||
40 | 41 | ||
41 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" | 42 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" |
42 | 43 | ||
44 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600) | ||
45 | |||
43 | /** | 46 | /** |
44 | * The number of messages received. | 47 | * The number of messages received. |
45 | */ | 48 | */ |
@@ -55,6 +58,8 @@ static struct GNUNET_TESTING_Command local_prepared; | |||
55 | 58 | ||
56 | static struct GNUNET_TESTING_Command start_peer; | 59 | static struct GNUNET_TESTING_Command start_peer; |
57 | 60 | ||
61 | static struct GNUNET_TESTING_Interpreter *is; | ||
62 | |||
58 | /** | 63 | /** |
59 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being | 64 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being |
60 | * received. | 65 | * received. |
@@ -134,6 +139,25 @@ handle_test (void *cls, | |||
134 | } | 139 | } |
135 | 140 | ||
136 | 141 | ||
142 | struct GNUNET_TESTING_Barrier * | ||
143 | get_waiting_for_barriers () | ||
144 | { | ||
145 | struct GNUNET_TESTING_Barrier *barrier; | ||
146 | |||
147 | //No Barrier | ||
148 | return NULL; | ||
149 | } | ||
150 | |||
151 | |||
152 | static void | ||
153 | barrier_advanced (const char *barrier_name) | ||
154 | { | ||
155 | struct GNUNET_TESTING_Barrier *barrier = GNUNET_TESTING_get_barrier (is, barrier_name); | ||
156 | |||
157 | GNUNET_TESTING_finish_attached_cmds (is, barrier); | ||
158 | } | ||
159 | |||
160 | |||
137 | /** | 161 | /** |
138 | * Callback to set the flag indicating all peers started. Will be called via the plugin api. | 162 | * Callback to set the flag indicating all peers started. Will be called via the plugin api. |
139 | * | 163 | * |
@@ -366,8 +390,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
366 | 390 | ||
367 | ts->write_message = write_message; | 391 | ts->write_message = write_message; |
368 | 392 | ||
369 | GNUNET_TESTING_run (commands, | 393 | is = GNUNET_TESTING_run (commands, |
370 | GNUNET_TIME_UNIT_FOREVER_REL, | 394 | TIMEOUT, |
371 | &handle_result, | 395 | &handle_result, |
372 | ts); | 396 | ts); |
373 | 397 | ||
@@ -393,6 +417,8 @@ libgnunet_test_transport_plugin_cmd_simple_send_dv_init (void *cls) | |||
393 | api->start_testcase = &start_testcase; | 417 | api->start_testcase = &start_testcase; |
394 | api->all_peers_started = &all_peers_started; | 418 | api->all_peers_started = &all_peers_started; |
395 | api->all_local_tests_prepared = all_local_tests_prepared; | 419 | api->all_local_tests_prepared = all_local_tests_prepared; |
420 | api->barrier_advanced = barrier_advanced; | ||
421 | api->get_waiting_for_barriers = get_waiting_for_barriers; | ||
396 | return api; | 422 | return api; |
397 | } | 423 | } |
398 | 424 | ||
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c index 5a0dac32b..38b81da85 100644 --- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c +++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "gnunet_transport_application_service.h" | 30 | #include "gnunet_transport_application_service.h" |
31 | #include "transport-testing2.h" | 31 | #include "transport-testing2.h" |
32 | #include "transport-testing-cmds.h" | 32 | #include "transport-testing-cmds.h" |
33 | #include "gnunet_testing_barrier.h" | ||
33 | 34 | ||
34 | /** | 35 | /** |
35 | * Generic logging shortcut | 36 | * Generic logging shortcut |
@@ -40,12 +41,16 @@ | |||
40 | 41 | ||
41 | #define TOPOLOGY_CONFIG "test_transport_udp_backchannel_topo.conf" | 42 | #define TOPOLOGY_CONFIG "test_transport_udp_backchannel_topo.conf" |
42 | 43 | ||
44 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600) | ||
45 | |||
43 | static struct GNUNET_TESTING_Command block_send; | 46 | static struct GNUNET_TESTING_Command block_send; |
44 | 47 | ||
45 | static struct GNUNET_TESTING_Command connect_peers; | 48 | static struct GNUNET_TESTING_Command connect_peers; |
46 | 49 | ||
47 | static struct GNUNET_TESTING_Command local_prepared; | 50 | static struct GNUNET_TESTING_Command local_prepared; |
48 | 51 | ||
52 | static struct GNUNET_TESTING_Interpreter *is; | ||
53 | |||
49 | 54 | ||
50 | /** | 55 | /** |
51 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being | 56 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being |
@@ -80,6 +85,25 @@ handle_test (void *cls, | |||
80 | } | 85 | } |
81 | 86 | ||
82 | 87 | ||
88 | struct GNUNET_TESTING_Barrier * | ||
89 | get_waiting_for_barriers () | ||
90 | { | ||
91 | struct GNUNET_TESTING_Barrier *barrier; | ||
92 | |||
93 | //No Barrier | ||
94 | return NULL; | ||
95 | } | ||
96 | |||
97 | |||
98 | static void | ||
99 | barrier_advanced (const char *barrier_name) | ||
100 | { | ||
101 | struct GNUNET_TESTING_Barrier *barrier = GNUNET_TESTING_get_barrier (is, barrier_name); | ||
102 | |||
103 | GNUNET_TESTING_finish_attached_cmds (is, barrier); | ||
104 | } | ||
105 | |||
106 | |||
83 | /** | 107 | /** |
84 | * Callback to set the flag indicating all peers started. Will be called via the plugin api. | 108 | * Callback to set the flag indicating all peers started. Will be called via the plugin api. |
85 | * | 109 | * |
@@ -303,8 +327,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
303 | 327 | ||
304 | ts->write_message = write_message; | 328 | ts->write_message = write_message; |
305 | 329 | ||
306 | GNUNET_TESTING_run (commands, | 330 | is = GNUNET_TESTING_run (commands, |
307 | GNUNET_TIME_UNIT_FOREVER_REL, | 331 | TIMEOUT, |
308 | &handle_result, | 332 | &handle_result, |
309 | ts); | 333 | ts); |
310 | 334 | ||
@@ -330,6 +354,8 @@ libgnunet_test_transport_plugin_cmd_udp_backchannel_init (void *cls) | |||
330 | api->start_testcase = &start_testcase; | 354 | api->start_testcase = &start_testcase; |
331 | api->all_peers_started = &all_peers_started; | 355 | api->all_peers_started = &all_peers_started; |
332 | api->all_local_tests_prepared = all_local_tests_prepared; | 356 | api->all_local_tests_prepared = all_local_tests_prepared; |
357 | api->barrier_advanced = barrier_advanced; | ||
358 | api->get_waiting_for_barriers = get_waiting_for_barriers; | ||
333 | return api; | 359 | return api; |
334 | } | 360 | } |
335 | 361 | ||