diff options
author | t3sserakt <t3ss@posteo.de> | 2022-10-10 14:59:55 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2022-10-10 14:59:55 +0200 |
commit | 9b39fb6ea253b89ec6588e0814fc473c12e7317b (patch) | |
tree | cfedf7141d7d0a804efc4b6b16a9001542fb01d4 /src/testing/gnunet-cmds-helper.c | |
parent | 8e4312d5e44a83e2baeb3fc15465b5e70919e6cf (diff) | |
download | gnunet-9b39fb6ea253b89ec6588e0814fc473c12e7317b.tar.gz gnunet-9b39fb6ea253b89ec6588e0814fc473c12e7317b.zip |
- some bug fixes and enhancements to test NG tear done
Diffstat (limited to 'src/testing/gnunet-cmds-helper.c')
-rw-r--r-- | src/testing/gnunet-cmds-helper.c | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c index 178b1b133..be58f6f6a 100644 --- a/src/testing/gnunet-cmds-helper.c +++ b/src/testing/gnunet-cmds-helper.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include "gnunet_util_lib.h" | 40 | #include "gnunet_util_lib.h" |
41 | #include "gnunet_testing_lib.h" | 41 | #include "gnunet_testing_lib.h" |
42 | #include "gnunet_testing_ng_lib.h" | 42 | #include "gnunet_testing_ng_lib.h" |
43 | #include "gnunet_testing_netjail_lib.h" | ||
43 | #include "testing_cmds.h" | 44 | #include "testing_cmds.h" |
44 | #include "gnunet_testing_plugin.h" | 45 | #include "gnunet_testing_plugin.h" |
45 | #include <zlib.h> | 46 | #include <zlib.h> |
@@ -61,6 +62,8 @@ testing_api_cmd_block_until_all_peers_started.c */ | |||
61 | 62 | ||
62 | #define ROUTER_BASE_IP "92.68.150." | 63 | #define ROUTER_BASE_IP "92.68.150." |
63 | 64 | ||
65 | struct GNUNET_SCHEDULER_Task *finished_task; | ||
66 | |||
64 | /** | 67 | /** |
65 | * Handle for a plugin. | 68 | * Handle for a plugin. |
66 | */ | 69 | */ |
@@ -232,7 +235,7 @@ static int status; | |||
232 | * @param cls NULL | 235 | * @param cls NULL |
233 | */ | 236 | */ |
234 | static void | 237 | static void |
235 | shutdown_task (void *cls) | 238 | do_shutdown (void *cls) |
236 | { | 239 | { |
237 | 240 | ||
238 | LOG_DEBUG ("Shutting down.\n"); | 241 | LOG_DEBUG ("Shutting down.\n"); |
@@ -276,6 +279,8 @@ write_task (void *cls) | |||
276 | bytes_wrote = GNUNET_DISK_file_write (stdout_fd, | 279 | bytes_wrote = GNUNET_DISK_file_write (stdout_fd, |
277 | wc->data + wc->pos, | 280 | wc->data + wc->pos, |
278 | wc->length - wc->pos); | 281 | wc->length - wc->pos); |
282 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
283 | "message send to master loop\n"); | ||
279 | if (GNUNET_SYSERR == bytes_wrote) | 284 | if (GNUNET_SYSERR == bytes_wrote) |
280 | { | 285 | { |
281 | LOG (GNUNET_ERROR_TYPE_WARNING, | 286 | LOG (GNUNET_ERROR_TYPE_WARNING, |
@@ -307,6 +312,8 @@ write_message (struct GNUNET_MessageHeader *message, size_t msg_length) | |||
307 | { | 312 | { |
308 | struct WriteContext *wc; | 313 | struct WriteContext *wc; |
309 | 314 | ||
315 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
316 | "write message to master loop\n"); | ||
310 | wc = GNUNET_new (struct WriteContext); | 317 | wc = GNUNET_new (struct WriteContext); |
311 | wc->length = msg_length; | 318 | wc->length = msg_length; |
312 | wc->data = message; | 319 | wc->data = message; |
@@ -317,6 +324,35 @@ write_message (struct GNUNET_MessageHeader *message, size_t msg_length) | |||
317 | wc); | 324 | wc); |
318 | } | 325 | } |
319 | 326 | ||
327 | static void | ||
328 | delay_shutdown_cb () | ||
329 | { | ||
330 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
331 | "doing shutdown after delay\n"); | ||
332 | GNUNET_SCHEDULER_shutdown (); | ||
333 | } | ||
334 | |||
335 | |||
336 | static void | ||
337 | finished_cb () | ||
338 | { | ||
339 | struct GNUNET_MessageHeader *reply; | ||
340 | |||
341 | reply = GNUNET_TESTING_send_local_test_finished_msg (); | ||
342 | |||
343 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
344 | "message prepared\n"); | ||
345 | write_message (reply, ntohs (reply->size)); | ||
346 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
347 | "message send\n"); | ||
348 | |||
349 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
350 | "delaying shutdown\n"); | ||
351 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
352 | delay_shutdown_cb, | ||
353 | NULL); | ||
354 | } | ||
355 | |||
320 | 356 | ||
321 | /** | 357 | /** |
322 | * Functions with this signature are called whenever a | 358 | * Functions with this signature are called whenever a |
@@ -341,11 +377,16 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message) | |||
341 | char *plugin_name; | 377 | char *plugin_name; |
342 | size_t plugin_name_size; | 378 | size_t plugin_name_size; |
343 | uint16_t msize; | 379 | uint16_t msize; |
380 | uint16_t type; | ||
344 | size_t msg_length; | 381 | size_t msg_length; |
345 | char *router_ip; | 382 | char *router_ip; |
346 | char *node_ip; | 383 | char *node_ip; |
347 | unsigned int namespace_n; | 384 | unsigned int namespace_n; |
348 | 385 | ||
386 | type = ntohs (message->type); | ||
387 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
388 | "Received message type %u\n", | ||
389 | type); | ||
349 | msize = ntohs (message->size); | 390 | msize = ntohs (message->size); |
350 | if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT == ntohs (message->type)) | 391 | if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT == ntohs (message->type)) |
351 | { | 392 | { |
@@ -402,7 +443,7 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message) | |||
402 | 443 | ||
403 | plugin->api->start_testcase (&write_message, router_ip, node_ip, plugin->m, | 444 | plugin->api->start_testcase (&write_message, router_ip, node_ip, plugin->m, |
404 | plugin->n, plugin->local_m, ni->topology_data, | 445 | plugin->n, plugin->local_m, ni->topology_data, |
405 | ni->read_file); | 446 | ni->read_file, &finished_cb); |
406 | 447 | ||
407 | msg_length = sizeof(struct GNUNET_CMDS_HelperReply); | 448 | msg_length = sizeof(struct GNUNET_CMDS_HelperReply); |
408 | reply = GNUNET_new (struct GNUNET_CMDS_HelperReply); | 449 | reply = GNUNET_new (struct GNUNET_CMDS_HelperReply); |
@@ -522,7 +563,7 @@ run (void *cls, | |||
522 | stdin_fd, | 563 | stdin_fd, |
523 | &read_task, | 564 | &read_task, |
524 | NULL); | 565 | NULL); |
525 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); | 566 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
526 | } | 567 | } |
527 | 568 | ||
528 | 569 | ||
@@ -629,6 +670,8 @@ main (int argc, char **argv) | |||
629 | &run, | 670 | &run, |
630 | ni); | 671 | ni); |
631 | 672 | ||
673 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
674 | "Finishing helper\n"); | ||
632 | GNUNET_SIGNAL_handler_uninstall (shc_chld); | 675 | GNUNET_SIGNAL_handler_uninstall (shc_chld); |
633 | shc_chld = NULL; | 676 | shc_chld = NULL; |
634 | GNUNET_DISK_pipe_close (sigpipe); | 677 | GNUNET_DISK_pipe_close (sigpipe); |