diff options
author | t3sserakt <t3ss@posteo.de> | 2021-07-16 21:05:11 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-07-16 21:05:11 +0200 |
commit | 33830e71f8e80334e0c8cf5527b1f2b20804485e (patch) | |
tree | be8bb3af17046a3e7c77ca6f11639c24e938211d /src/testbed | |
parent | 71f230fbb6f270f6b501934acadb6f57026c353d (diff) | |
download | gnunet-33830e71f8e80334e0c8cf5527b1f2b20804485e.tar.gz gnunet-33830e71f8e80334e0c8cf5527b1f2b20804485e.zip |
- started to implement several cmds to start peers^Ctestcase plugin will be started directly from helper, functionality to communicate between master cmd loop and local cmd loop, code compiles, test is not working atm.
Diffstat (limited to 'src/testbed')
-rw-r--r-- | src/testbed/Makefile.am | 11 | ||||
-rw-r--r-- | src/testbed/gnunet-cmd.c | 54 | ||||
-rw-r--r-- | src/testbed/gnunet-cmds-helper.c (renamed from src/testbed/gnunet-helper-cmds.c) | 480 | ||||
-rwxr-xr-x | src/testbed/netjail_exec.sh | 2 | ||||
-rw-r--r-- | src/testbed/plugin_testcmd.c | 19 | ||||
-rw-r--r-- | src/testbed/testbed_api.h | 3 | ||||
-rw-r--r-- | src/testbed/testbed_api_cmd_block_until_all_peers_started.c | 102 | ||||
-rw-r--r-- | src/testbed/testbed_api_cmd_netjail_start.c | 6 | ||||
-rw-r--r-- | src/testbed/testbed_api_cmd_netjail_start_testbed.c | 162 | ||||
-rw-r--r-- | src/testbed/testbed_api_cmd_send_peer_ready.c | 102 | ||||
-rw-r--r-- | src/testbed/testbed_helper.h | 46 |
11 files changed, 768 insertions, 219 deletions
diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am index 8c4a6342b..dc24eaf26 100644 --- a/src/testbed/Makefile.am +++ b/src/testbed/Makefile.am | |||
@@ -24,7 +24,7 @@ endif | |||
24 | 24 | ||
25 | libexec_PROGRAMS = \ | 25 | libexec_PROGRAMS = \ |
26 | gnunet-cmd \ | 26 | gnunet-cmd \ |
27 | gnunet-helper-cmds \ | 27 | gnunet-cmds-helper \ |
28 | gnunet-service-testbed \ | 28 | gnunet-service-testbed \ |
29 | gnunet-helper-testbed \ | 29 | gnunet-helper-testbed \ |
30 | gnunet-daemon-testbed-blacklist \ | 30 | gnunet-daemon-testbed-blacklist \ |
@@ -45,6 +45,7 @@ libgnunet_plugin_testcmd_la_SOURCES = \ | |||
45 | libgnunet_plugin_testcmd_la_LIBADD = \ | 45 | libgnunet_plugin_testcmd_la_LIBADD = \ |
46 | $(top_builddir)/src/util/libgnunetutil.la \ | 46 | $(top_builddir)/src/util/libgnunetutil.la \ |
47 | $(top_builddir)/src/testing/libgnunettesting.la \ | 47 | $(top_builddir)/src/testing/libgnunettesting.la \ |
48 | $(top_builddir)/src/testbed/libgnunettestbed.la | ||
48 | $(LTLIBINTL) | 49 | $(LTLIBINTL) |
49 | libgnunet_plugin_testcmd_la_LDFLAGS = \ | 50 | libgnunet_plugin_testcmd_la_LDFLAGS = \ |
50 | $(GN_PLUGIN_LDFLAGS) | 51 | $(GN_PLUGIN_LDFLAGS) |
@@ -94,9 +95,9 @@ gnunet_cmd_LDADD = $(XLIB) \ | |||
94 | libgnunettestbed.la \ | 95 | libgnunettestbed.la \ |
95 | $(LTLIBINTL) $(Z_LIBS) | 96 | $(LTLIBINTL) $(Z_LIBS) |
96 | 97 | ||
97 | gnunet_helper_cmds_SOURCES = \ | 98 | gnunet_cmds_helper_SOURCES = \ |
98 | gnunet-helper-cmds.c | 99 | gnunet-cmds-helper.c |
99 | gnunet_helper_cmds_LDADD = $(XLIB) \ | 100 | gnunet_cmds_helper_LDADD = $(XLIB) \ |
100 | $(top_builddir)/src/util/libgnunetutil.la \ | 101 | $(top_builddir)/src/util/libgnunetutil.la \ |
101 | $(top_builddir)/src/testing/libgnunettesting.la \ | 102 | $(top_builddir)/src/testing/libgnunettesting.la \ |
102 | libgnunettestbed.la \ | 103 | libgnunettestbed.la \ |
@@ -124,6 +125,8 @@ lib_LTLIBRARIES = \ | |||
124 | libgnunettestbed.la | 125 | libgnunettestbed.la |
125 | 126 | ||
126 | libgnunettestbed_la_SOURCES = \ | 127 | libgnunettestbed_la_SOURCES = \ |
128 | testbed_api_cmd_send_peer_ready.c \ | ||
129 | testbed_api_cmd_block_until_all_peers_started.c \ | ||
127 | testbed_api_cmd_netjail_start.c \ | 130 | testbed_api_cmd_netjail_start.c \ |
128 | testbed_api_cmd_netjail_start_testbed.c \ | 131 | testbed_api_cmd_netjail_start_testbed.c \ |
129 | testbed_api_cmd_netjail_stop_testbed.c \ | 132 | testbed_api_cmd_netjail_stop_testbed.c \ |
diff --git a/src/testbed/gnunet-cmd.c b/src/testbed/gnunet-cmd.c index 477c3c454..7889750ba 100644 --- a/src/testbed/gnunet-cmd.c +++ b/src/testbed/gnunet-cmd.c | |||
@@ -36,6 +36,9 @@ | |||
36 | */ | 36 | */ |
37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | 37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) |
38 | 38 | ||
39 | #define NODE_BASE_IP "192.168.15." | ||
40 | |||
41 | #define ROUTER_BASE_IP "92.68.150." | ||
39 | 42 | ||
40 | /** | 43 | /** |
41 | * Handle for a plugin. | 44 | * Handle for a plugin. |
@@ -51,29 +54,44 @@ struct Plugin | |||
51 | * Plugin API. | 54 | * Plugin API. |
52 | */ | 55 | */ |
53 | struct GNUNET_TESTING_PluginFunctions *api; | 56 | struct GNUNET_TESTING_PluginFunctions *api; |
57 | |||
58 | char *node_ip; | ||
59 | |||
60 | char *plugin_name; | ||
61 | |||
62 | char *global_n; | ||
63 | |||
64 | char *local_m; | ||
65 | |||
66 | char *n; | ||
67 | |||
68 | char *m; | ||
54 | }; | 69 | }; |
55 | 70 | ||
56 | 71 | ||
57 | /** | 72 | /** |
58 | * Main function to run the test cases. | 73 | * Main function to run the test cases. |
59 | * | 74 | * |
60 | * @param cls not used. | 75 | * @param cls plugin to use. |
61 | * | 76 | * |
62 | */ | 77 | */ |
63 | static void | 78 | static void |
64 | run (void *cls) | 79 | run (void *cls) |
65 | { | 80 | { |
66 | struct Plugin *plugin; | 81 | struct Plugin *plugin = cls; |
82 | char *router_ip; | ||
83 | char *node_ip; | ||
84 | |||
85 | router_ip = GNUNET_malloc (strlen (ROUTER_BASE_IP) + strlen (plugin->m) + 1); | ||
86 | strcpy (router_ip, ROUTER_BASE_IP); | ||
87 | strcat (router_ip, plugin->m); | ||
88 | |||
89 | node_ip = GNUNET_malloc (strlen (NODE_BASE_IP) + strlen (plugin->n) + 1); | ||
90 | strcat (node_ip, NODE_BASE_IP); | ||
91 | strcat (node_ip, plugin->n); | ||
92 | |||
93 | plugin->api->start_testcase (NULL, router_ip, node_ip); | ||
67 | 94 | ||
68 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "gnunet-cmd", | ||
69 | "running plugin.\n"); | ||
70 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
71 | "running plugin.\n"); | ||
72 | plugin = GNUNET_new (struct Plugin); | ||
73 | plugin->api = GNUNET_PLUGIN_load ("libgnunet_plugin_testcmd", | ||
74 | NULL); | ||
75 | plugin->library_name = GNUNET_strdup ("libgnunet_plugin_testcmd"); | ||
76 | plugin->api->start_testcase (); | ||
77 | } | 95 | } |
78 | 96 | ||
79 | 97 | ||
@@ -81,13 +99,25 @@ int | |||
81 | main (int argc, char *const *argv) | 99 | main (int argc, char *const *argv) |
82 | { | 100 | { |
83 | int rv = 0; | 101 | int rv = 0; |
102 | struct Plugin *plugin; | ||
84 | 103 | ||
85 | GNUNET_log_setup ("gnunet-cmd", | 104 | GNUNET_log_setup ("gnunet-cmd", |
86 | "DEBUG", | 105 | "DEBUG", |
87 | NULL); | 106 | NULL); |
88 | 107 | ||
108 | plugin = GNUNET_new (struct Plugin); | ||
109 | plugin->api = GNUNET_PLUGIN_load (argv[0], | ||
110 | NULL); | ||
111 | plugin->library_name = GNUNET_strdup (argv[0]); | ||
112 | |||
113 | plugin->global_n = argv[1]; | ||
114 | plugin->local_m = argv[2]; | ||
115 | plugin->n = argv[3]; | ||
116 | plugin->m = argv[4]; | ||
117 | |||
89 | GNUNET_SCHEDULER_run (&run, | 118 | GNUNET_SCHEDULER_run (&run, |
90 | NULL); | 119 | plugin); |
91 | 120 | ||
121 | GNUNET_free (plugin); | ||
92 | return rv; | 122 | return rv; |
93 | } | 123 | } |
diff --git a/src/testbed/gnunet-helper-cmds.c b/src/testbed/gnunet-cmds-helper.c index 3073ebdfb..693892a9c 100644 --- a/src/testbed/gnunet-helper-cmds.c +++ b/src/testbed/gnunet-cmds-helper.c | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file testbed/gnunet-helper-cmds.c | 22 | * @file testbed/gnunet-cmds-helper.c |
23 | * @brief Helper binary that is started from a remote interpreter loop to start | 23 | * @brief Helper binary that is started from a remote interpreter loop to start |
24 | * a local interpreter loop. | 24 | * a local interpreter loop. |
25 | * | 25 | * |
@@ -42,7 +42,9 @@ | |||
42 | #include "gnunet_testbed_service.h" | 42 | #include "gnunet_testbed_service.h" |
43 | #include "testbed_helper.h" | 43 | #include "testbed_helper.h" |
44 | #include "testbed_api.h" | 44 | #include "testbed_api.h" |
45 | #include "gnunet_testing_plugin.h" | ||
45 | #include <zlib.h> | 46 | #include <zlib.h> |
47 | #include "execinfo.h" | ||
46 | 48 | ||
47 | /** | 49 | /** |
48 | * Generic logging shortcut | 50 | * Generic logging shortcut |
@@ -54,6 +56,50 @@ | |||
54 | */ | 56 | */ |
55 | #define LOG_DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) | 57 | #define LOG_DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) |
56 | 58 | ||
59 | #define NODE_BASE_IP "192.168.15." | ||
60 | |||
61 | #define ROUTER_BASE_IP "92.68.150." | ||
62 | |||
63 | #define MAX_TRACE_DEPTH 50 | ||
64 | |||
65 | /** | ||
66 | * Handle for a plugin. | ||
67 | */ | ||
68 | struct Plugin | ||
69 | { | ||
70 | /** | ||
71 | * Name of the shared library. | ||
72 | */ | ||
73 | char *library_name; | ||
74 | |||
75 | /** | ||
76 | * Plugin API. | ||
77 | */ | ||
78 | struct GNUNET_TESTING_PluginFunctions *api; | ||
79 | |||
80 | char *node_ip; | ||
81 | |||
82 | char *plugin_name; | ||
83 | |||
84 | char *global_n; | ||
85 | |||
86 | char *local_m; | ||
87 | |||
88 | char *n; | ||
89 | |||
90 | char *m; | ||
91 | }; | ||
92 | |||
93 | struct NodeIdentifier | ||
94 | { | ||
95 | char *n; | ||
96 | |||
97 | char *m; | ||
98 | |||
99 | char *global_n; | ||
100 | |||
101 | char *local_m; | ||
102 | }; | ||
57 | 103 | ||
58 | /** | 104 | /** |
59 | * Context for a single write on a chunk of memory | 105 | * Context for a single write on a chunk of memory |
@@ -76,6 +122,8 @@ struct WriteContext | |||
76 | size_t pos; | 122 | size_t pos; |
77 | }; | 123 | }; |
78 | 124 | ||
125 | struct Plugin *plugin; | ||
126 | |||
79 | /** | 127 | /** |
80 | * The process handle to the testbed service | 128 | * The process handle to the testbed service |
81 | */ | 129 | */ |
@@ -132,6 +180,61 @@ static int done_reading; | |||
132 | static int status; | 180 | static int status; |
133 | 181 | ||
134 | 182 | ||
183 | struct BacktraceInfo | ||
184 | { | ||
185 | /** | ||
186 | * Array of strings which make up a backtrace from the point when this | ||
187 | * task was scheduled (essentially, who scheduled the task?) | ||
188 | */ | ||
189 | char **backtrace_strings; | ||
190 | |||
191 | /** | ||
192 | * Size of the backtrace_strings array | ||
193 | */ | ||
194 | int num_backtrace_strings; | ||
195 | }; | ||
196 | |||
197 | /** | ||
198 | * Output stack trace of task @a t. | ||
199 | * | ||
200 | * @param t task to dump stack trace of | ||
201 | */ | ||
202 | static void | ||
203 | dump_backtrace (struct BacktraceInfo *t) | ||
204 | { | ||
205 | |||
206 | for (unsigned int i = 0; i < t->num_backtrace_strings; i++) | ||
207 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
208 | "Task %p trace %u: %s\n", | ||
209 | t, | ||
210 | i, | ||
211 | t->backtrace_strings[i]); | ||
212 | |||
213 | } | ||
214 | |||
215 | |||
216 | /** | ||
217 | * Initialize backtrace data for task @a t | ||
218 | * | ||
219 | * @param t task to initialize | ||
220 | */ | ||
221 | static void | ||
222 | init_backtrace () | ||
223 | { | ||
224 | struct BacktraceInfo *t; | ||
225 | void *backtrace_array[MAX_TRACE_DEPTH]; | ||
226 | |||
227 | t = GNUNET_new (struct BacktraceInfo); | ||
228 | t->num_backtrace_strings | ||
229 | = backtrace (backtrace_array, MAX_TRACE_DEPTH); | ||
230 | t->backtrace_strings = | ||
231 | backtrace_symbols (backtrace_array, | ||
232 | t->num_backtrace_strings); | ||
233 | dump_backtrace (t); | ||
234 | |||
235 | } | ||
236 | |||
237 | |||
135 | /** | 238 | /** |
136 | * Task to shut down cleanly | 239 | * Task to shut down cleanly |
137 | * | 240 | * |
@@ -140,7 +243,11 @@ static int status; | |||
140 | static void | 243 | static void |
141 | shutdown_task (void *cls) | 244 | shutdown_task (void *cls) |
142 | { | 245 | { |
143 | LOG_DEBUG ("Shutting down\n"); | 246 | |
247 | init_backtrace (); | ||
248 | LOG_DEBUG ("Shutting down.\n"); | ||
249 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
250 | "Shutting down tokenizer!\n"); | ||
144 | 251 | ||
145 | if (NULL != read_task_id) | 252 | if (NULL != read_task_id) |
146 | { | 253 | { |
@@ -176,6 +283,8 @@ shutdown_task (void *cls) | |||
176 | } | 283 | } |
177 | 284 | ||
178 | 285 | ||
286 | |||
287 | |||
179 | /** | 288 | /** |
180 | * Task to write to the standard out | 289 | * Task to write to the standard out |
181 | * | 290 | * |
@@ -187,6 +296,9 @@ write_task (void *cls) | |||
187 | struct WriteContext *wc = cls; | 296 | struct WriteContext *wc = cls; |
188 | ssize_t bytes_wrote; | 297 | ssize_t bytes_wrote; |
189 | 298 | ||
299 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
300 | "Writing data!\n"); | ||
301 | |||
190 | GNUNET_assert (NULL != wc); | 302 | GNUNET_assert (NULL != wc); |
191 | write_task_id = NULL; | 303 | write_task_id = NULL; |
192 | bytes_wrote = GNUNET_DISK_file_write (stdout_fd, | 304 | bytes_wrote = GNUNET_DISK_file_write (stdout_fd, |
@@ -194,7 +306,8 @@ write_task (void *cls) | |||
194 | wc->length - wc->pos); | 306 | wc->length - wc->pos); |
195 | if (GNUNET_SYSERR == bytes_wrote) | 307 | if (GNUNET_SYSERR == bytes_wrote) |
196 | { | 308 | { |
197 | LOG (GNUNET_ERROR_TYPE_WARNING, "Cannot reply back configuration\n"); | 309 | LOG (GNUNET_ERROR_TYPE_WARNING, |
310 | "Cannot reply back successful initialization\n"); | ||
198 | GNUNET_free (wc->data); | 311 | GNUNET_free (wc->data); |
199 | GNUNET_free (wc); | 312 | GNUNET_free (wc); |
200 | return; | 313 | return; |
@@ -204,8 +317,12 @@ write_task (void *cls) | |||
204 | { | 317 | { |
205 | GNUNET_free (wc->data); | 318 | GNUNET_free (wc->data); |
206 | GNUNET_free (wc); | 319 | GNUNET_free (wc); |
320 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
321 | "Written successfully!\n"); | ||
207 | return; | 322 | return; |
208 | } | 323 | } |
324 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
325 | "Written data!\n"); | ||
209 | write_task_id = GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, | 326 | write_task_id = GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, |
210 | stdout_fd, | 327 | stdout_fd, |
211 | &write_task, | 328 | &write_task, |
@@ -240,6 +357,52 @@ child_death_task (void *cls) | |||
240 | } | 357 | } |
241 | 358 | ||
242 | 359 | ||
360 | static void | ||
361 | write_message (struct GNUNET_MessageHeader *message, size_t msg_length) | ||
362 | { | ||
363 | struct WriteContext *wc; | ||
364 | |||
365 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
366 | "enter write_message!\n"); | ||
367 | wc = GNUNET_new (struct WriteContext); | ||
368 | wc->length = msg_length; | ||
369 | wc->data = message; | ||
370 | write_task_id = GNUNET_SCHEDULER_add_write_file ( | ||
371 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
372 | stdout_fd, | ||
373 | &write_task, | ||
374 | wc); | ||
375 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
376 | "leave write_message!\n"); | ||
377 | } | ||
378 | |||
379 | |||
380 | /** | ||
381 | * Function to run the test cases. | ||
382 | * | ||
383 | * @param cls plugin to use. | ||
384 | * | ||
385 | */ | ||
386 | static void | ||
387 | run_plugin (void *cls) | ||
388 | { | ||
389 | struct Plugin *plugin = cls; | ||
390 | char *router_ip; | ||
391 | char *node_ip; | ||
392 | |||
393 | router_ip = GNUNET_malloc (strlen (ROUTER_BASE_IP) + strlen (plugin->m) + 1); | ||
394 | strcpy (router_ip, ROUTER_BASE_IP); | ||
395 | strcat (router_ip, plugin->m); | ||
396 | |||
397 | node_ip = GNUNET_malloc (strlen (NODE_BASE_IP) + strlen (plugin->n) + 1); | ||
398 | strcat (node_ip, NODE_BASE_IP); | ||
399 | strcat (node_ip, plugin->n); | ||
400 | |||
401 | plugin->api->start_testcase (&write_message, router_ip, node_ip); | ||
402 | |||
403 | } | ||
404 | |||
405 | |||
243 | /** | 406 | /** |
244 | * Functions with this signature are called whenever a | 407 | * Functions with this signature are called whenever a |
245 | * complete message is received by the tokenizer. | 408 | * complete message is received by the tokenizer. |
@@ -255,191 +418,140 @@ child_death_task (void *cls) | |||
255 | static int | 418 | static int |
256 | tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message) | 419 | tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message) |
257 | { | 420 | { |
258 | const struct GNUNET_TESTBED_HelperInit *msg; | 421 | struct NodeIdentifier *ni = cls; |
259 | struct GNUNET_TESTBED_HelperReply *reply; | 422 | const struct GNUNET_CMDS_HelperInit *msg; |
260 | struct GNUNET_CONFIGURATION_Handle *cfg; | 423 | struct GNUNET_CMDS_HelperReply *reply; |
261 | struct WriteContext *wc; | ||
262 | char *binary; | 424 | char *binary; |
263 | char *trusted_ip; | 425 | char *plugin_name; |
264 | char *hostname; | 426 | size_t plugin_name_size; |
265 | char *config; | ||
266 | char *xconfig; | ||
267 | char *evstr; | ||
268 | // char *str; | ||
269 | size_t config_size; | ||
270 | uLongf ul_config_size; | ||
271 | size_t xconfig_size; | ||
272 | uint16_t trusted_ip_size; | ||
273 | uint16_t hostname_size; | ||
274 | uint16_t msize; | 427 | uint16_t msize; |
428 | size_t msg_length; | ||
429 | char *router_ip; | ||
430 | char *node_ip; | ||
431 | |||
432 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
433 | "tokenizer \n"); | ||
275 | 434 | ||
276 | msize = ntohs (message->size); | 435 | msize = ntohs (message->size); |
277 | if ((sizeof(struct GNUNET_TESTBED_HelperInit) >= msize) || | 436 | if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED == ntohs ( |
278 | (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT != ntohs (message->type))) | 437 | message->type)) |
279 | { | 438 | { |
280 | LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n"); | 439 | plugin->api->all_peers_started (); |
281 | goto error; | ||
282 | } | ||
283 | msg = (const struct GNUNET_TESTBED_HelperInit *) message; | ||
284 | trusted_ip_size = ntohs (msg->trusted_ip_size); | ||
285 | trusted_ip = (char *) &msg[1]; | ||
286 | if ('\0' != trusted_ip[trusted_ip_size]) | ||
287 | { | ||
288 | LOG (GNUNET_ERROR_TYPE_WARNING, "Trusted IP cannot be empty -- exiting\n"); | ||
289 | goto error; | ||
290 | } | ||
291 | hostname_size = ntohs (msg->hostname_size); | ||
292 | if ((sizeof(struct GNUNET_TESTBED_HelperInit) + trusted_ip_size + 1 | ||
293 | + hostname_size) >= msize) | ||
294 | { | ||
295 | GNUNET_break (0); | ||
296 | LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n"); | ||
297 | goto error; | ||
298 | } | 440 | } |
299 | ul_config_size = (uLongf) ntohs (msg->config_size); | 441 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT == ntohs (message->type)) |
300 | config = GNUNET_malloc (ul_config_size); | ||
301 | xconfig_size = msize - (trusted_ip_size + 1 + hostname_size | ||
302 | + sizeof(struct GNUNET_TESTBED_HelperInit)); | ||
303 | int ret = uncompress ((Bytef *) config, | ||
304 | &ul_config_size, | ||
305 | (const Bytef *) (trusted_ip + trusted_ip_size + 1 | ||
306 | + hostname_size), | ||
307 | (uLongf) xconfig_size); | ||
308 | if (Z_OK != ret) | ||
309 | { | 442 | { |
310 | switch (ret) | 443 | msg = (const struct GNUNET_CMDS_HelperInit *) message; |
444 | plugin_name_size = ntohs (msg->plugin_name_size); | ||
445 | if ((sizeof(struct GNUNET_CMDS_HelperInit) + plugin_name_size) > msize) | ||
311 | { | 446 | { |
312 | case Z_MEM_ERROR: | 447 | GNUNET_break (0); |
313 | LOG (GNUNET_ERROR_TYPE_ERROR, "Not enough memory for decompression\n"); | 448 | LOG (GNUNET_ERROR_TYPE_WARNING, |
314 | break; | 449 | "Received unexpected message -- exiting\n"); |
450 | goto error; | ||
451 | } | ||
452 | plugin_name = GNUNET_malloc (plugin_name_size + 1); | ||
453 | GNUNET_strlcpy (plugin_name, | ||
454 | ((char *) &msg[1]), | ||
455 | plugin_name_size + 1); | ||
315 | 456 | ||
316 | case Z_BUF_ERROR: | 457 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-cmd"); |
317 | LOG (GNUNET_ERROR_TYPE_ERROR, "Output buffer too small\n"); | ||
318 | break; | ||
319 | 458 | ||
320 | case Z_DATA_ERROR: | 459 | LOG (GNUNET_ERROR_TYPE_ERROR, |
321 | LOG (GNUNET_ERROR_TYPE_ERROR, "Data corrupted/incomplete\n"); | 460 | "plugin_name: %s \n", |
322 | break; | 461 | plugin_name); |
462 | |||
463 | // cmd_binary_process = GNUNET_OS_start_process ( | ||
464 | /*GNUNET_OS_INHERIT_STD_ERR verbose? , | ||
465 | NULL, | ||
466 | NULL, | ||
467 | NULL, | ||
468 | binary, | ||
469 | plugin_name, | ||
470 | ni->global_n, | ||
471 | ni->local_m, | ||
472 | ni->n, | ||
473 | ni->m, | ||
474 | NULL);*/ | ||
475 | |||
476 | plugin = GNUNET_new (struct Plugin); | ||
477 | plugin->api = GNUNET_PLUGIN_load (plugin_name, | ||
478 | NULL); | ||
479 | plugin->library_name = GNUNET_strdup (plugin_name); | ||
480 | |||
481 | plugin->global_n = ni->global_n; | ||
482 | plugin->local_m = ni->local_m; | ||
483 | plugin->n = ni->n; | ||
484 | plugin->m = ni->m; | ||
485 | |||
486 | router_ip = GNUNET_malloc (strlen (ROUTER_BASE_IP) + strlen (plugin->m) | ||
487 | + 1); | ||
488 | strcpy (router_ip, ROUTER_BASE_IP); | ||
489 | strcat (router_ip, plugin->m); | ||
490 | |||
491 | node_ip = GNUNET_malloc (strlen (NODE_BASE_IP) + strlen (plugin->n) + 1); | ||
492 | strcat (node_ip, NODE_BASE_IP); | ||
493 | strcat (node_ip, plugin->n); | ||
494 | |||
495 | plugin->api->start_testcase (&write_message, router_ip, node_ip); | ||
323 | 496 | ||
324 | default: | ||
325 | GNUNET_break (0); | ||
326 | } | ||
327 | LOG (GNUNET_ERROR_TYPE_ERROR, | 497 | LOG (GNUNET_ERROR_TYPE_ERROR, |
328 | "Error while uncompressing config -- exiting\n"); | 498 | "We got here!\n"); |
329 | GNUNET_free (config); | ||
330 | goto error; | ||
331 | } | ||
332 | cfg = GNUNET_CONFIGURATION_create (); | ||
333 | if (GNUNET_OK != | ||
334 | GNUNET_CONFIGURATION_deserialize (cfg, config, ul_config_size, NULL)) | ||
335 | { | ||
336 | LOG (GNUNET_ERROR_TYPE_ERROR, "Unable to deserialize config -- exiting\n"); | ||
337 | GNUNET_free (config); | ||
338 | goto error; | ||
339 | } | ||
340 | GNUNET_free (config); | ||
341 | hostname = NULL; | ||
342 | if (0 != hostname_size) | ||
343 | { | ||
344 | hostname = GNUNET_malloc (hostname_size + 1); | ||
345 | GNUNET_strlcpy (hostname, | ||
346 | ((char *) &msg[1]) + trusted_ip_size + 1, | ||
347 | hostname_size + 1); | ||
348 | } | ||
349 | /* unset GNUNET_TESTING_PREFIX if present as it is more relevant for testbed */ | ||
350 | evstr = getenv (GNUNET_TESTING_PREFIX); | ||
351 | if (NULL != evstr) | ||
352 | { | ||
353 | /* unsetting the variable will invalidate the pointer! */ | ||
354 | evstr = GNUNET_strdup (evstr); | ||
355 | GNUNET_break (0 == unsetenv (GNUNET_TESTING_PREFIX)); | ||
356 | } | ||
357 | test_system = | ||
358 | GNUNET_TESTING_system_create ("testbed-helper", trusted_ip, hostname, NULL); | ||
359 | if (NULL != evstr) | ||
360 | { | ||
361 | char *evar; | ||
362 | 499 | ||
363 | GNUNET_asprintf (&evar, GNUNET_TESTING_PREFIX "=%s", evstr); | 500 | /*if (NULL == cmd_binary_process) |
364 | GNUNET_assert (0 == putenv (evar)); /* consumes 'evar', | 501 | { |
365 | see putenv(): becomes part of environment! */ | 502 | LOG (GNUNET_ERROR_TYPE_ERROR, |
366 | GNUNET_free (evstr); | 503 | "Starting plugin failed!\n"); |
367 | evstr = NULL; | 504 | return GNUNET_SYSERR; |
368 | } | 505 | }*/ |
369 | GNUNET_free (hostname); | ||
370 | hostname = NULL; | ||
371 | GNUNET_assert (NULL != test_system); | ||
372 | GNUNET_assert (GNUNET_OK == | ||
373 | GNUNET_TESTING_configuration_create (test_system, cfg)); | ||
374 | GNUNET_assert (GNUNET_OK == | ||
375 | GNUNET_CONFIGURATION_get_value_filename (cfg, | ||
376 | "PATHS", | ||
377 | "DEFAULTCONFIG", | ||
378 | &config)); | ||
379 | if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, config)) | ||
380 | { | ||
381 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
382 | "Unable to write config file: %s -- exiting\n", | ||
383 | config); | ||
384 | GNUNET_CONFIGURATION_destroy (cfg); | ||
385 | GNUNET_free (config); | ||
386 | goto error; | ||
387 | } | ||
388 | LOG_DEBUG ("Staring testbed with config: %s\n", config); | ||
389 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-cmd"); | ||
390 | { | ||
391 | char *evar; | ||
392 | 506 | ||
393 | /* expose testbed configuration through env variable */ | 507 | LOG (GNUNET_ERROR_TYPE_ERROR, |
394 | GNUNET_asprintf (&evar, "%s=%s", ENV_TESTBED_CONFIG, config); | 508 | "We got here 2!\n"); |
395 | GNUNET_assert (0 == putenv (evar)); /* consumes 'evar', | 509 | |
396 | see putenv(): becomes part of environment! */ | 510 | LOG (GNUNET_ERROR_TYPE_ERROR, |
397 | evstr = NULL; | 511 | "global_n: %s local_n: %s n: %s m: %s.\n", |
398 | } | 512 | ni->global_n, |
513 | ni->local_m, | ||
514 | ni->n, | ||
515 | ni->m); | ||
516 | |||
517 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
518 | "We got here 3!\n"); | ||
399 | 519 | ||
400 | cmd_binary_process = GNUNET_OS_start_process ( | 520 | GNUNET_free (binary); |
401 | GNUNET_OS_INHERIT_STD_ERR /*verbose? */, | 521 | |
402 | NULL, | 522 | done_reading = GNUNET_YES; |
403 | NULL, | 523 | |
404 | NULL, | 524 | msg_length = sizeof(struct GNUNET_CMDS_HelperReply); |
405 | binary); | 525 | reply = GNUNET_new (struct GNUNET_CMDS_HelperReply); |
526 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY); | ||
527 | reply->header.size = htons ((uint16_t) msg_length); | ||
528 | |||
529 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
530 | "We got here 4!\n"); | ||
406 | 531 | ||
407 | if (NULL == cmd_binary_process) | 532 | write_message ((struct GNUNET_MessageHeader *) reply, msg_length); |
533 | |||
534 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
535 | "We got here 5!\n"); | ||
536 | |||
537 | /*child_death_task_id = GNUNET_SCHEDULER_add_read_file ( | ||
538 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
539 | GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ), | ||
540 | &child_death_task, | ||
541 | NULL);*/ | ||
542 | return GNUNET_OK; | ||
543 | } | ||
544 | else | ||
408 | { | 545 | { |
409 | return GNUNET_SYSERR; | 546 | LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n"); |
547 | goto error; | ||
410 | } | 548 | } |
411 | 549 | ||
412 | GNUNET_free (binary); | ||
413 | GNUNET_free (config); | ||
414 | |||
415 | done_reading = GNUNET_YES; | ||
416 | config = GNUNET_CONFIGURATION_serialize (cfg, &config_size); | ||
417 | GNUNET_CONFIGURATION_destroy (cfg); | ||
418 | cfg = NULL; | ||
419 | xconfig_size = | ||
420 | GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig); | ||
421 | GNUNET_free (config); | ||
422 | wc = GNUNET_new (struct WriteContext); | ||
423 | wc->length = xconfig_size + sizeof(struct GNUNET_TESTBED_HelperReply); | ||
424 | reply = GNUNET_realloc (xconfig, wc->length); | ||
425 | memmove (&reply[1], reply, xconfig_size); | ||
426 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY); | ||
427 | reply->header.size = htons ((uint16_t) wc->length); | ||
428 | reply->config_size = htons ((uint16_t) config_size); | ||
429 | wc->data = reply; | ||
430 | write_task_id = GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, | ||
431 | stdout_fd, | ||
432 | &write_task, | ||
433 | wc); | ||
434 | child_death_task_id = GNUNET_SCHEDULER_add_read_file ( | ||
435 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
436 | GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ), | ||
437 | &child_death_task, | ||
438 | NULL); | ||
439 | return GNUNET_OK; | ||
440 | 550 | ||
441 | error: | 551 | error: |
442 | status = GNUNET_SYSERR; | 552 | status = GNUNET_SYSERR; |
553 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
554 | "tokenizer shuting down!\n"); | ||
443 | GNUNET_SCHEDULER_shutdown (); | 555 | GNUNET_SCHEDULER_shutdown (); |
444 | return GNUNET_SYSERR; | 556 | return GNUNET_SYSERR; |
445 | } | 557 | } |
@@ -461,6 +573,8 @@ read_task (void *cls) | |||
461 | if ((GNUNET_SYSERR == sread) || (0 == sread)) | 573 | if ((GNUNET_SYSERR == sread) || (0 == sread)) |
462 | { | 574 | { |
463 | LOG_DEBUG ("STDIN closed\n"); | 575 | LOG_DEBUG ("STDIN closed\n"); |
576 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
577 | "tokenizer shuting down during reading!\n"); | ||
464 | GNUNET_SCHEDULER_shutdown (); | 578 | GNUNET_SCHEDULER_shutdown (); |
465 | return; | 579 | return; |
466 | } | 580 | } |
@@ -468,6 +582,8 @@ read_task (void *cls) | |||
468 | { | 582 | { |
469 | /* didn't expect any more data! */ | 583 | /* didn't expect any more data! */ |
470 | GNUNET_break_op (0); | 584 | GNUNET_break_op (0); |
585 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
586 | "tokenizer shuting down during reading, didn't expect any more data!\n"); | ||
471 | GNUNET_SCHEDULER_shutdown (); | 587 | GNUNET_SCHEDULER_shutdown (); |
472 | return; | 588 | return; |
473 | } | 589 | } |
@@ -478,6 +594,8 @@ read_task (void *cls) | |||
478 | GNUNET_MST_from_buffer (tokenizer, buf, sread, GNUNET_NO, GNUNET_NO)) | 594 | GNUNET_MST_from_buffer (tokenizer, buf, sread, GNUNET_NO, GNUNET_NO)) |
479 | { | 595 | { |
480 | GNUNET_break (0); | 596 | GNUNET_break (0); |
597 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
598 | "tokenizer shuting down during reading, writing to buffer failed!\n"); | ||
481 | GNUNET_SCHEDULER_shutdown (); | 599 | GNUNET_SCHEDULER_shutdown (); |
482 | return; | 600 | return; |
483 | } | 601 | } |
@@ -503,8 +621,11 @@ run (void *cls, | |||
503 | const char *cfgfile, | 621 | const char *cfgfile, |
504 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 622 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
505 | { | 623 | { |
624 | struct NodeIdentifier *ni = cls; | ||
625 | |||
506 | LOG_DEBUG ("Starting interpreter loop helper...\n"); | 626 | LOG_DEBUG ("Starting interpreter loop helper...\n"); |
507 | tokenizer = GNUNET_MST_create (&tokenizer_cb, NULL); | 627 | |
628 | tokenizer = GNUNET_MST_create (&tokenizer_cb, ni); | ||
508 | stdin_fd = GNUNET_DISK_get_handle_from_native (stdin); | 629 | stdin_fd = GNUNET_DISK_get_handle_from_native (stdin); |
509 | stdout_fd = GNUNET_DISK_get_handle_from_native (stdout); | 630 | stdout_fd = GNUNET_DISK_get_handle_from_native (stdout); |
510 | read_task_id = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 631 | read_task_id = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
@@ -545,14 +666,28 @@ sighandler_child_death () | |||
545 | int | 666 | int |
546 | main (int argc, char **argv) | 667 | main (int argc, char **argv) |
547 | { | 668 | { |
669 | struct NodeIdentifier *ni; | ||
548 | struct GNUNET_SIGNAL_Context *shc_chld; | 670 | struct GNUNET_SIGNAL_Context *shc_chld; |
549 | struct GNUNET_GETOPT_CommandLineOption options[] = | 671 | struct GNUNET_GETOPT_CommandLineOption options[] = |
550 | { GNUNET_GETOPT_OPTION_END }; | 672 | { GNUNET_GETOPT_OPTION_END }; |
551 | int ret; | 673 | int ret; |
552 | 674 | ||
553 | GNUNET_log_setup ("gnunet-helper-cmds", | 675 | GNUNET_log_setup ("gnunet-cmds-helper", |
554 | "DEBUG", | 676 | "DEBUG", |
555 | NULL); | 677 | NULL); |
678 | ni = GNUNET_new (struct NodeIdentifier); | ||
679 | ni->global_n = argv[1]; | ||
680 | ni->local_m = argv[2]; | ||
681 | ni->n = argv[3]; | ||
682 | ni->m = argv[4]; | ||
683 | |||
684 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
685 | "global_n: %s local_n: %s n: %s m: %s.\n", | ||
686 | ni->global_n, | ||
687 | ni->local_m, | ||
688 | ni->n, | ||
689 | ni->m); | ||
690 | |||
556 | status = GNUNET_OK; | 691 | status = GNUNET_OK; |
557 | if (NULL == | 692 | if (NULL == |
558 | (sigpipe = GNUNET_DISK_pipe (GNUNET_DISK_PF_NONE))) | 693 | (sigpipe = GNUNET_DISK_pipe (GNUNET_DISK_PF_NONE))) |
@@ -564,18 +699,21 @@ main (int argc, char **argv) | |||
564 | GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death); | 699 | GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death); |
565 | ret = GNUNET_PROGRAM_run (argc, | 700 | ret = GNUNET_PROGRAM_run (argc, |
566 | argv, | 701 | argv, |
567 | "gnunet-helper-cmds", | 702 | "gnunet-cmds-helper", |
568 | "Helper for starting a local interpreter loop", | 703 | "Helper for starting a local interpreter loop", |
569 | options, | 704 | options, |
570 | &run, | 705 | &run, |
571 | NULL); | 706 | ni); |
707 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
708 | "run finished\n"); | ||
572 | GNUNET_SIGNAL_handler_uninstall (shc_chld); | 709 | GNUNET_SIGNAL_handler_uninstall (shc_chld); |
573 | shc_chld = NULL; | 710 | shc_chld = NULL; |
574 | GNUNET_DISK_pipe_close (sigpipe); | 711 | GNUNET_DISK_pipe_close (sigpipe); |
712 | GNUNET_free (ni); | ||
575 | if (GNUNET_OK != ret) | 713 | if (GNUNET_OK != ret) |
576 | return 1; | 714 | return 1; |
577 | return (GNUNET_OK == status) ? 0 : 1; | 715 | return (GNUNET_OK == status) ? 0 : 1; |
578 | } | 716 | } |
579 | 717 | ||
580 | 718 | ||
581 | /* end of gnunet-helper-testbed.c */ | 719 | /* end of gnunet-cmds-helper.c */ |
diff --git a/src/testbed/netjail_exec.sh b/src/testbed/netjail_exec.sh index 3e5d39c1c..532f4711c 100755 --- a/src/testbed/netjail_exec.sh +++ b/src/testbed/netjail_exec.sh | |||
@@ -13,4 +13,4 @@ NODE=$(netjail_print_name "N" $N $M) | |||
13 | 13 | ||
14 | 14 | ||
15 | 15 | ||
16 | netjail_node_exec_without_fds $NODE $3 | 16 | netjail_node_exec_without_fds $NODE $3 $4 $5 $1 $2 |
diff --git a/src/testbed/plugin_testcmd.c b/src/testbed/plugin_testcmd.c index 90e4a90a1..6f28e102d 100644 --- a/src/testbed/plugin_testcmd.c +++ b/src/testbed/plugin_testcmd.c | |||
@@ -26,21 +26,32 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_testing_ng_lib.h" | 27 | #include "gnunet_testing_ng_lib.h" |
28 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_testing_plugin.h" | 29 | #include "gnunet_testbed_ng_service.h" |
30 | |||
31 | |||
32 | 30 | ||
31 | unsigned int are_all_peers_started; | ||
33 | 32 | ||
33 | static void | ||
34 | all_peers_started () | ||
35 | { | ||
36 | are_all_peers_started = GNUNET_YES; | ||
37 | } | ||
34 | 38 | ||
35 | static void | 39 | static void |
36 | start_testcase () | 40 | start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip, |
41 | char *node_ip) | ||
37 | { | 42 | { |
38 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | 43 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); |
39 | 44 | ||
45 | are_all_peers_started = GNUNET_NO; | ||
46 | |||
40 | struct GNUNET_TESTING_Command commands[] = { | 47 | struct GNUNET_TESTING_Command commands[] = { |
41 | GNUNET_TESTING_cmd_hello_world_birth ("hello-world-birth-0", | 48 | GNUNET_TESTING_cmd_hello_world_birth ("hello-world-birth-0", |
42 | &now), | 49 | &now), |
43 | GNUNET_TESTING_cmd_hello_world ("hello-world-0","hello-world-birth-0",""), | 50 | GNUNET_TESTING_cmd_hello_world ("hello-world-0","hello-world-birth-0",""), |
51 | GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready-1", | ||
52 | write_message), | ||
53 | GNUNET_TESTING_cmd_block_until_all_peers_started ("block-1", | ||
54 | &are_all_peers_started), | ||
44 | GNUNET_TESTING_cmd_end () | 55 | GNUNET_TESTING_cmd_end () |
45 | }; | 56 | }; |
46 | 57 | ||
diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h index ea78a14ff..9a54ca36c 100644 --- a/src/testbed/testbed_api.h +++ b/src/testbed/testbed_api.h | |||
@@ -40,7 +40,7 @@ | |||
40 | /** | 40 | /** |
41 | * Cmds Helper binary name | 41 | * Cmds Helper binary name |
42 | */ | 42 | */ |
43 | #define HELPER_CMDS_BINARY "gnunet-helper-cmds" | 43 | #define HELPER_CMDS_BINARY "gnunet-cmds-helper" |
44 | 44 | ||
45 | 45 | ||
46 | /** | 46 | /** |
@@ -185,7 +185,6 @@ struct OperationContext | |||
185 | typedef void | 185 | typedef void |
186 | (*TESTBED_opcq_empty_cb) (void *cls); | 186 | (*TESTBED_opcq_empty_cb) (void *cls); |
187 | 187 | ||
188 | |||
189 | /** | 188 | /** |
190 | * Handle to interact with a GNUnet testbed controller. Each | 189 | * Handle to interact with a GNUnet testbed controller. Each |
191 | * controller has at least one master handle which is created when the | 190 | * controller has at least one master handle which is created when the |
diff --git a/src/testbed/testbed_api_cmd_block_until_all_peers_started.c b/src/testbed/testbed_api_cmd_block_until_all_peers_started.c new file mode 100644 index 000000000..fc872311d --- /dev/null +++ b/src/testbed/testbed_api_cmd_block_until_all_peers_started.c | |||
@@ -0,0 +1,102 @@ | |||
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 | struct BlockState | ||
31 | { | ||
32 | unsigned int *all_peers_started; | ||
33 | }; | ||
34 | |||
35 | |||
36 | static int | ||
37 | block_until_all_peers_started_traits (void *cls, | ||
38 | const void **ret, | ||
39 | const char *trait, | ||
40 | unsigned int index) | ||
41 | { | ||
42 | return GNUNET_OK; | ||
43 | } | ||
44 | |||
45 | |||
46 | static void | ||
47 | block_until_all_peers_started_cleanup (void *cls, | ||
48 | const struct GNUNET_TESTING_Command *cmd) | ||
49 | { | ||
50 | struct BlockState *bs = cls; | ||
51 | |||
52 | GNUNET_free (bs); | ||
53 | } | ||
54 | |||
55 | |||
56 | static void | ||
57 | block_until_all_peers_started_run (void *cls, | ||
58 | const struct GNUNET_TESTING_Command *cmd, | ||
59 | struct GNUNET_TESTING_Interpreter *is) | ||
60 | { | ||
61 | } | ||
62 | |||
63 | |||
64 | static int | ||
65 | block_until_all_peers_started_finish (void *cls, | ||
66 | GNUNET_SCHEDULER_TaskCallback cont, | ||
67 | void *cont_cls) | ||
68 | { | ||
69 | struct BlockState *bs = cls; | ||
70 | unsigned int *ret = bs->all_peers_started; | ||
71 | |||
72 | return *ret; | ||
73 | } | ||
74 | |||
75 | |||
76 | /** | ||
77 | * Create command. | ||
78 | * | ||
79 | * @param label name for command. | ||
80 | * @return command. | ||
81 | */ | ||
82 | struct GNUNET_TESTING_Command | ||
83 | GNUNET_TESTING_cmd_block_until_all_peers_started (const char *label, | ||
84 | unsigned int * | ||
85 | all_peers_started) | ||
86 | { | ||
87 | struct BlockState *bs; | ||
88 | |||
89 | bs = GNUNET_new (struct BlockState); | ||
90 | bs->all_peers_started = all_peers_started; | ||
91 | |||
92 | struct GNUNET_TESTING_Command cmd = { | ||
93 | .cls = bs, | ||
94 | .label = label, | ||
95 | .run = &block_until_all_peers_started_run, | ||
96 | .finish = &block_until_all_peers_started_finish, | ||
97 | .cleanup = &block_until_all_peers_started_cleanup, | ||
98 | .traits = &block_until_all_peers_started_traits | ||
99 | }; | ||
100 | |||
101 | return cmd; | ||
102 | } | ||
diff --git a/src/testbed/testbed_api_cmd_netjail_start.c b/src/testbed/testbed_api_cmd_netjail_start.c index 320537a61..1e37d5475 100644 --- a/src/testbed/testbed_api_cmd_netjail_start.c +++ b/src/testbed/testbed_api_cmd_netjail_start.c | |||
@@ -59,6 +59,9 @@ netjail_start_cleanup (void *cls, | |||
59 | { | 59 | { |
60 | struct NetJailState *ns = cls; | 60 | struct NetJailState *ns = cls; |
61 | 61 | ||
62 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
63 | "netjail_start_cleanup!\n"); | ||
64 | |||
62 | if (NULL != ns->cwh) | 65 | if (NULL != ns->cwh) |
63 | { | 66 | { |
64 | GNUNET_wait_child_cancel (ns->cwh); | 67 | GNUNET_wait_child_cancel (ns->cwh); |
@@ -74,6 +77,7 @@ netjail_start_cleanup (void *cls, | |||
74 | GNUNET_OS_process_destroy (ns->start_proc); | 77 | GNUNET_OS_process_destroy (ns->start_proc); |
75 | ns->start_proc = NULL; | 78 | ns->start_proc = NULL; |
76 | } | 79 | } |
80 | GNUNET_free (ns); | ||
77 | } | 81 | } |
78 | 82 | ||
79 | 83 | ||
@@ -108,6 +112,8 @@ child_completed_callback (void *cls, | |||
108 | } | 112 | } |
109 | else | 113 | else |
110 | { | 114 | { |
115 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
116 | "Child completed with an error!\n"); | ||
111 | ns->finished = GNUNET_SYSERR; | 117 | ns->finished = GNUNET_SYSERR; |
112 | } | 118 | } |
113 | GNUNET_OS_process_destroy (ns->start_proc); | 119 | GNUNET_OS_process_destroy (ns->start_proc); |
diff --git a/src/testbed/testbed_api_cmd_netjail_start_testbed.c b/src/testbed/testbed_api_cmd_netjail_start_testbed.c index dc8196e94..585825cbc 100644 --- a/src/testbed/testbed_api_cmd_netjail_start_testbed.c +++ b/src/testbed/testbed_api_cmd_netjail_start_testbed.c | |||
@@ -28,13 +28,36 @@ | |||
28 | #include "gnunet_testbed_ng_service.h" | 28 | #include "gnunet_testbed_ng_service.h" |
29 | #include "testbed_api.h" | 29 | #include "testbed_api.h" |
30 | #include "testbed_api_hosts.h" | 30 | #include "testbed_api_hosts.h" |
31 | #include "testbed_helper.h" | ||
31 | 32 | ||
32 | #define NETJAIL_EXEC_SCRIPT "./netjail_exec.sh" | 33 | #define NETJAIL_EXEC_SCRIPT "./netjail_exec.sh" |
33 | 34 | ||
35 | struct HelperMessage; | ||
36 | |||
37 | struct HelperMessage | ||
38 | { | ||
39 | |||
40 | struct HelperMessage *next; | ||
41 | |||
42 | struct HelperMessage *prev; | ||
43 | |||
44 | /** | ||
45 | * Size of the original message. | ||
46 | */ | ||
47 | uint16_t bytes_msg; | ||
48 | |||
49 | /* Followed by @e bytes_msg of msg.*/ | ||
50 | }; | ||
51 | |||
52 | |||
34 | 53 | ||
35 | struct NetJailState | 54 | struct NetJailState |
36 | { | 55 | { |
37 | 56 | ||
57 | struct HelperMessage *hp_messages_head; | ||
58 | |||
59 | struct HelperMessage *hp_messages_tail; | ||
60 | |||
38 | /** | 61 | /** |
39 | * The process handle | 62 | * The process handle |
40 | */ | 63 | */ |
@@ -64,6 +87,8 @@ struct NetJailState | |||
64 | 87 | ||
65 | unsigned int number_of_testbeds_started; | 88 | unsigned int number_of_testbeds_started; |
66 | 89 | ||
90 | unsigned int number_of_peers_started; | ||
91 | |||
67 | /** | 92 | /** |
68 | * The host where the controller is running | 93 | * The host where the controller is running |
69 | */ | 94 | */ |
@@ -112,7 +137,7 @@ netjail_exec_traits (void *cls, | |||
112 | { | 137 | { |
113 | struct NetJailState *ns = cls; | 138 | struct NetJailState *ns = cls; |
114 | struct GNUNET_HELPER_Handle **helper = ns->helper; | 139 | struct GNUNET_HELPER_Handle **helper = ns->helper; |
115 | struct GNUNET_TESTBED_Host **hosts = ns->host; | 140 | struct HelperMessage *hp_messages_head = ns->hp_messages_head; |
116 | 141 | ||
117 | 142 | ||
118 | struct GNUNET_TESTING_Trait traits[] = { | 143 | struct GNUNET_TESTING_Trait traits[] = { |
@@ -123,8 +148,8 @@ netjail_exec_traits (void *cls, | |||
123 | }, | 148 | }, |
124 | { | 149 | { |
125 | .index = 1, | 150 | .index = 1, |
126 | .trait_name = "hosts", | 151 | .trait_name = "hp_msgs_head", |
127 | .ptr = (const void *) hosts, | 152 | .ptr = (const void *) hp_messages_head, |
128 | }, | 153 | }, |
129 | GNUNET_TESTING_trait_end () | 154 | GNUNET_TESTING_trait_end () |
130 | }; | 155 | }; |
@@ -162,13 +187,14 @@ GNUNET_TESTBED_get_trait_helper_handles (const struct | |||
162 | * @return #GNUNET_OK on success. | 187 | * @return #GNUNET_OK on success. |
163 | */ | 188 | */ |
164 | int | 189 | int |
165 | GNUNET_TESTBED_get_trait_hosts (const struct | 190 | GNUNET_TESTBED_get_trait_helper_messages (const struct |
166 | GNUNET_TESTING_Command *cmd, | 191 | GNUNET_TESTING_Command *cmd, |
167 | struct GNUNET_TESTBED_Host ***hosts) | 192 | struct HelperMessage *** |
193 | hp_messages_head) | ||
168 | { | 194 | { |
169 | return cmd->traits (cmd->cls, | 195 | return cmd->traits (cmd->cls, |
170 | (const void **) hosts, | 196 | (const void **) hp_messages_head, |
171 | "hosts", | 197 | "hp_msgs_head", |
172 | (unsigned int) 1); | 198 | (unsigned int) 1); |
173 | } | 199 | } |
174 | 200 | ||
@@ -214,15 +240,32 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | |||
214 | { | 240 | { |
215 | struct TestbedCount *tbc = cls; | 241 | struct TestbedCount *tbc = cls; |
216 | struct NetJailState *ns = tbc->ns; | 242 | struct NetJailState *ns = tbc->ns; |
217 | struct GNUNET_TESTBED_Host *host = ns->host[tbc->count - 1]; | 243 | struct HelperMessage *hp_msg; |
244 | |||
245 | if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY == ntohs (message->type)) | ||
246 | { | ||
247 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
248 | "helper_mst tbc->count: %d\n", | ||
249 | tbc->count); | ||
250 | // GNUNET_TESTBED_extract_cfg (host, message); | ||
251 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
252 | "Received message from helper.\n"); | ||
253 | ns->number_of_testbeds_started++; | ||
254 | } | ||
255 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED == ntohs ( | ||
256 | message->type)) | ||
257 | { | ||
258 | ns->number_of_peers_started++; | ||
259 | } | ||
260 | else | ||
261 | { | ||
262 | hp_msg = GNUNET_new (struct HelperMessage); | ||
263 | hp_msg->bytes_msg = message->size; | ||
264 | memcpy (&hp_msg[1], message, message->size); | ||
265 | GNUNET_CONTAINER_DLL_insert (ns->hp_messages_head, ns->hp_messages_tail, | ||
266 | hp_msg); | ||
267 | } | ||
218 | 268 | ||
219 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
220 | "helper_mst tbc->count: %d\n", | ||
221 | tbc->count); | ||
222 | GNUNET_TESTBED_extract_cfg (host, message); | ||
223 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
224 | "Received message from helper.\n"); | ||
225 | ns->number_of_testbeds_started++; | ||
226 | return GNUNET_OK; | 269 | return GNUNET_OK; |
227 | } | 270 | } |
228 | 271 | ||
@@ -235,6 +278,32 @@ exp_cb (void *cls) | |||
235 | } | 278 | } |
236 | 279 | ||
237 | 280 | ||
281 | static struct GNUNET_CMDS_HelperInit * | ||
282 | create_helper_init_msg_ (char *m_char, | ||
283 | char *n_char, | ||
284 | const char *plugin_name) | ||
285 | { | ||
286 | struct GNUNET_CMDS_HelperInit *msg; | ||
287 | uint16_t plugin_name_len; | ||
288 | uint16_t msg_size; | ||
289 | |||
290 | GNUNET_assert (NULL != plugin_name); | ||
291 | plugin_name_len = strlen (plugin_name); | ||
292 | msg_size = sizeof(struct GNUNET_CMDS_HelperInit) + plugin_name_len; | ||
293 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
294 | "msg_size: %d \n", | ||
295 | msg_size); | ||
296 | msg = GNUNET_malloc (msg_size); | ||
297 | msg->header.size = htons (msg_size); | ||
298 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT); | ||
299 | msg->plugin_name_size = htons (plugin_name_len); | ||
300 | GNUNET_memcpy ((char *) &msg[1], | ||
301 | plugin_name, | ||
302 | plugin_name_len); | ||
303 | return msg; | ||
304 | } | ||
305 | |||
306 | |||
238 | static void | 307 | static void |
239 | start_testbed (struct NetJailState *ns, struct | 308 | start_testbed (struct NetJailState *ns, struct |
240 | GNUNET_CONFIGURATION_Handle *config, | 309 | GNUNET_CONFIGURATION_Handle *config, |
@@ -242,13 +311,15 @@ start_testbed (struct NetJailState *ns, struct | |||
242 | char *m_char) | 311 | char *m_char) |
243 | { | 312 | { |
244 | struct GNUNET_CONFIGURATION_Handle *cfg; | 313 | struct GNUNET_CONFIGURATION_Handle *cfg; |
245 | struct GNUNET_TESTBED_HelperInit *msg; | 314 | struct GNUNET_CMDS_HelperInit *msg; |
246 | struct TestbedCount *tbc; | 315 | struct TestbedCount *tbc; |
247 | char *const script_argv[] = {NETJAIL_EXEC_SCRIPT, | 316 | char *const script_argv[] = {NETJAIL_EXEC_SCRIPT, |
248 | m_char, | ||
249 | n_char, | 317 | n_char, |
318 | m_char, | ||
250 | GNUNET_OS_get_libexec_binary_path ( | 319 | GNUNET_OS_get_libexec_binary_path ( |
251 | HELPER_CMDS_BINARY), | 320 | HELPER_CMDS_BINARY), |
321 | ns->global_n, | ||
322 | ns->local_m, | ||
252 | NULL}; | 323 | NULL}; |
253 | unsigned int m = atoi (m_char); | 324 | unsigned int m = atoi (m_char); |
254 | unsigned int n = atoi (n_char); | 325 | unsigned int n = atoi (n_char); |
@@ -291,7 +362,9 @@ start_testbed (struct NetJailState *ns, struct | |||
291 | 362 | ||
292 | struct GNUNET_HELPER_Handle *helper = ns->helper[tbc->count - 1]; | 363 | struct GNUNET_HELPER_Handle *helper = ns->helper[tbc->count - 1]; |
293 | 364 | ||
294 | msg = GNUNET_TESTBED_create_helper_init_msg_ ("127.0.0.1", NULL, config); | 365 | msg = create_helper_init_msg_ (m_char, |
366 | n_char, | ||
367 | "libgnunet_plugin_testcmd"); | ||
295 | GNUNET_array_append (ns->msg, ns->n_msg, &msg->header); | 368 | GNUNET_array_append (ns->msg, ns->n_msg, &msg->header); |
296 | 369 | ||
297 | GNUNET_array_append (ns->shandle, ns->n_shandle, GNUNET_HELPER_send ( | 370 | GNUNET_array_append (ns->shandle, ns->n_shandle, GNUNET_HELPER_send ( |
@@ -300,6 +373,10 @@ start_testbed (struct NetJailState *ns, struct | |||
300 | GNUNET_NO, | 373 | GNUNET_NO, |
301 | &clear_msg, | 374 | &clear_msg, |
302 | tbc)); | 375 | tbc)); |
376 | |||
377 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
378 | "Message send!\n"); | ||
379 | |||
303 | if (NULL == ns->shandle[tbc->count - 1]) | 380 | if (NULL == ns->shandle[tbc->count - 1]) |
304 | { | 381 | { |
305 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 382 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -348,14 +425,49 @@ netjail_start_finish (void *cls, | |||
348 | { | 425 | { |
349 | unsigned int ret = GNUNET_NO; | 426 | unsigned int ret = GNUNET_NO; |
350 | struct NetJailState *ns = cls; | 427 | struct NetJailState *ns = cls; |
428 | unsigned int total_number = atoi (ns->local_m) * atoi (ns->global_n); | ||
429 | struct GNUNET_CMDS_PEER_STARTED *reply; | ||
430 | size_t msg_length; | ||
431 | struct GNUNET_HELPER_Handle *helper; | ||
432 | struct TestbedCount *tbc; | ||
351 | 433 | ||
352 | if (ns->number_of_testbeds_started == atoi (ns->local_m) * atoi ( | 434 | if (ns->number_of_testbeds_started == total_number) |
353 | ns->global_n)) | ||
354 | { | 435 | { |
355 | ret = GNUNET_YES; | 436 | /* ret = GNUNET_YES; |
356 | cont (cont_cls); | 437 | cont (cont_cls);*/ |
357 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 438 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
358 | "All helper started!\n"); | 439 | "All helpers started!\n"); |
440 | } | ||
441 | |||
442 | if (ns->number_of_peers_started == total_number) | ||
443 | { | ||
444 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
445 | "All peers started!\n"); | ||
446 | |||
447 | for (int i = 1; i <= atoi (ns->global_n); i++) { | ||
448 | for (int j = 1; j <= atoi (ns->local_m); j++) | ||
449 | { | ||
450 | tbc = GNUNET_new (struct TestbedCount); | ||
451 | tbc->ns = ns; | ||
452 | tbc->count = (j - 1) * atoi (ns->local_m) + i + atoi (ns->global_n) | ||
453 | * atoi (ns->local_m); | ||
454 | helper = ns->helper[tbc->count - 1]; | ||
455 | msg_length = sizeof(struct GNUNET_CMDS_ALL_PEERS_STARTED); | ||
456 | reply = GNUNET_new (struct GNUNET_CMDS_ALL_PEERS_STARTED); | ||
457 | reply->header.type = htons ( | ||
458 | GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED); | ||
459 | reply->header.size = htons ((uint16_t) msg_length); | ||
460 | |||
461 | GNUNET_array_append (ns->msg, ns->n_msg, &reply->header); | ||
462 | |||
463 | GNUNET_array_append (ns->shandle, ns->n_shandle, GNUNET_HELPER_send ( | ||
464 | helper, | ||
465 | &reply->header, | ||
466 | GNUNET_NO, | ||
467 | &clear_msg, | ||
468 | tbc)); | ||
469 | } | ||
470 | } | ||
359 | } | 471 | } |
360 | return ret; | 472 | return ret; |
361 | } | 473 | } |
diff --git a/src/testbed/testbed_api_cmd_send_peer_ready.c b/src/testbed/testbed_api_cmd_send_peer_ready.c new file mode 100644 index 000000000..8a82b23a8 --- /dev/null +++ b/src/testbed/testbed_api_cmd_send_peer_ready.c | |||
@@ -0,0 +1,102 @@ | |||
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_send_peer_ready.c | ||
23 | * @brief cmd to send a helper message if peer is ready. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testing_ng_lib.h" | ||
29 | |||
30 | |||
31 | struct SendPeerReadyState | ||
32 | { | ||
33 | TESTBED_CMD_HELPER_write_cb write_message; | ||
34 | |||
35 | struct GNUNET_CMDS_PEER_STARTED *reply; | ||
36 | }; | ||
37 | |||
38 | |||
39 | static int | ||
40 | send_peer_ready_traits (void *cls, | ||
41 | const void **ret, | ||
42 | const char *trait, | ||
43 | unsigned int index) | ||
44 | { | ||
45 | return GNUNET_OK; | ||
46 | } | ||
47 | |||
48 | |||
49 | static void | ||
50 | send_peer_ready_cleanup (void *cls, | ||
51 | const struct GNUNET_TESTING_Command *cmd) | ||
52 | { | ||
53 | struct SendPeerReadyState *sprs = cls; | ||
54 | |||
55 | GNUNET_free (sprs->reply); | ||
56 | GNUNET_free (sprs); | ||
57 | } | ||
58 | |||
59 | |||
60 | static void | ||
61 | send_peer_ready_run (void *cls, | ||
62 | const struct GNUNET_TESTING_Command *cmd, | ||
63 | struct GNUNET_TESTING_Interpreter *is) | ||
64 | { | ||
65 | /*struct SendPeerReadyState *sprs = cls; | ||
66 | struct GNUNET_CMDS_PEER_STARTED *reply; | ||
67 | size_t msg_length; | ||
68 | |||
69 | msg_length = sizeof(struct GNUNET_CMDS_PEER_STARTED); | ||
70 | reply = GNUNET_new (struct GNUNET_CMDS_PEER_STARTED); | ||
71 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED); | ||
72 | reply->header.size = htons ((uint16_t) msg_length); | ||
73 | sprs->reply = reply; | ||
74 | sprs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length);*/ | ||
75 | } | ||
76 | |||
77 | |||
78 | /** | ||
79 | * Create command. | ||
80 | * | ||
81 | * @param label name for command. | ||
82 | * @return command. | ||
83 | */ | ||
84 | struct GNUNET_TESTING_Command | ||
85 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, | ||
86 | TESTBED_CMD_HELPER_write_cb write_message) | ||
87 | { | ||
88 | struct SendPeerReadyState *sprs; | ||
89 | |||
90 | sprs = GNUNET_new (struct SendPeerReadyState); | ||
91 | sprs->write_message = write_message; | ||
92 | |||
93 | struct GNUNET_TESTING_Command cmd = { | ||
94 | .cls = sprs, | ||
95 | .label = label, | ||
96 | .run = &send_peer_ready_run, | ||
97 | .cleanup = &send_peer_ready_cleanup, | ||
98 | .traits = &send_peer_ready_traits | ||
99 | }; | ||
100 | |||
101 | return cmd; | ||
102 | } | ||
diff --git a/src/testbed/testbed_helper.h b/src/testbed/testbed_helper.h index 817ad559d..84059fef2 100644 --- a/src/testbed/testbed_helper.h +++ b/src/testbed/testbed_helper.h | |||
@@ -84,6 +84,52 @@ struct GNUNET_TESTBED_HelperReply | |||
84 | * un-compressed */ | 84 | * un-compressed */ |
85 | }; | 85 | }; |
86 | 86 | ||
87 | /** | ||
88 | * Initialization message for gnunet-cmds-testbed to start cmd binary. | ||
89 | */ | ||
90 | struct GNUNET_CMDS_HelperInit | ||
91 | { | ||
92 | /** | ||
93 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT | ||
94 | */ | ||
95 | struct GNUNET_MessageHeader header; | ||
96 | |||
97 | /** | ||
98 | * | ||
99 | */ | ||
100 | uint16_t plugin_name_size GNUNET_PACKED; | ||
101 | |||
102 | /* Followed by plugin name of the plugin running the test case. This is not NULL | ||
103 | * terminated */ | ||
104 | }; | ||
105 | |||
106 | /** | ||
107 | * Reply message from cmds helper process | ||
108 | */ | ||
109 | struct GNUNET_CMDS_HelperReply | ||
110 | { | ||
111 | /** | ||
112 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY | ||
113 | */ | ||
114 | struct GNUNET_MessageHeader header; | ||
115 | }; | ||
116 | |||
117 | struct GNUNET_CMDS_PEER_STARTED | ||
118 | { | ||
119 | /** | ||
120 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED | ||
121 | */ | ||
122 | struct GNUNET_MessageHeader header; | ||
123 | }; | ||
124 | |||
125 | struct GNUNET_CMDS_ALL_PEERS_STARTED | ||
126 | { | ||
127 | /** | ||
128 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED | ||
129 | */ | ||
130 | struct GNUNET_MessageHeader header; | ||
131 | }; | ||
132 | |||
87 | GNUNET_NETWORK_STRUCT_END | 133 | GNUNET_NETWORK_STRUCT_END |
88 | #endif | 134 | #endif |
89 | /* end of testbed_helper.h */ | 135 | /* end of testbed_helper.h */ |