aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2022-10-10 14:59:55 +0200
committert3sserakt <t3ss@posteo.de>2022-10-10 14:59:55 +0200
commit9b39fb6ea253b89ec6588e0814fc473c12e7317b (patch)
treecfedf7141d7d0a804efc4b6b16a9001542fb01d4 /src/testing
parent8e4312d5e44a83e2baeb3fc15465b5e70919e6cf (diff)
downloadgnunet-9b39fb6ea253b89ec6588e0814fc473c12e7317b.tar.gz
gnunet-9b39fb6ea253b89ec6588e0814fc473c12e7317b.zip
- some bug fixes and enhancements to test NG tear done
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/gnunet-cmds-helper.c49
-rw-r--r--src/testing/testing.c78
-rw-r--r--src/testing/testing_api_cmd_netjail_start_testsystem.c60
-rw-r--r--src/testing/testing_cmds.h3
4 files changed, 100 insertions, 90 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
65struct 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 */
234static void 237static void
235shutdown_task (void *cls) 238do_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
327static void
328delay_shutdown_cb ()
329{
330 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
331 "doing shutdown after delay\n");
332 GNUNET_SCHEDULER_shutdown ();
333}
334
335
336static void
337finished_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);
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 4f0b8eaa9..95651830f 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -1319,7 +1319,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
1319 peer->nports = nports; 1319 peer->nports = nports;
1320 return peer; 1320 return peer;
1321 1321
1322err_ret: 1322 err_ret:
1323 GNUNET_free (ss_instances); 1323 GNUNET_free (ss_instances);
1324 GNUNET_free (ports); 1324 GNUNET_free (ports);
1325 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s", emsg_); 1325 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s", emsg_);
@@ -2118,7 +2118,7 @@ get_node_info (unsigned int num,
2118 unsigned int node_m; 2118 unsigned int node_m;
2119 struct GNUNET_TESTING_NetjailNode *node; 2119 struct GNUNET_TESTING_NetjailNode *node;
2120 struct GNUNET_TESTING_NetjailNamespace *namespace; 2120 struct GNUNET_TESTING_NetjailNamespace *namespace;
2121 struct GNUNET_TESTING_NodeConnection *node_connections; 2121 struct GNUNET_TESTING_NodeConnection *node_connections = NULL;
2122 2122
2123 log_topo (topology); 2123 log_topo (topology);
2124 hkey = GNUNET_new (struct GNUNET_ShortHashCode); 2124 hkey = GNUNET_new (struct GNUNET_ShortHashCode);
@@ -2135,7 +2135,10 @@ get_node_info (unsigned int num,
2135 node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals, 2135 node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals,
2136 hkey); 2136 hkey);
2137 if (NULL != node) 2137 if (NULL != node)
2138 node_connections = node->node_connections_head; 2138 {
2139 *node_ex = node;
2140 *node_connections_ex = node->node_connections_head;
2141 }
2139 } 2142 }
2140 else 2143 else
2141 { 2144 {
@@ -2248,8 +2251,15 @@ free_nodes_cb (void *cls,
2248 { 2251 {
2249 while (NULL != (pos_prefix = pos_connection->address_prefixes_head)) 2252 while (NULL != (pos_prefix = pos_connection->address_prefixes_head))
2250 { 2253 {
2254 GNUNET_CONTAINER_DLL_remove (pos_connection->address_prefixes_head,
2255 pos_connection->address_prefixes_tail,
2256 pos_prefix);
2251 GNUNET_free (pos_prefix->address_prefix); 2257 GNUNET_free (pos_prefix->address_prefix);
2258 GNUNET_free (pos_prefix);
2252 } 2259 }
2260 GNUNET_CONTAINER_DLL_remove (node->node_connections_head,
2261 node->node_connections_tail,
2262 pos_connection);
2253 GNUNET_free (pos_connection); 2263 GNUNET_free (pos_connection);
2254 } 2264 }
2255 2265
@@ -2398,9 +2408,11 @@ GNUNET_TESTING_get_additional_connects (unsigned int num,
2398 get_node_info (num, topology, &node, &namespace, &node_connections); 2408 get_node_info (num, topology, &node, &namespace, &node_connections);
2399 2409
2400 LOG (GNUNET_ERROR_TYPE_DEBUG, 2410 LOG (GNUNET_ERROR_TYPE_DEBUG,
2401 "node additional_connects: %u %p\n", 2411 "node additional_connects for node %p\n",
2402 node->additional_connects,
2403 node); 2412 node);
2413 LOG (GNUNET_ERROR_TYPE_DEBUG,
2414 "node additional_connects: %u\n",
2415 node->additional_connects);
2404 2416
2405 return node->additional_connects; 2417 return node->additional_connects;
2406} 2418}
@@ -2409,28 +2421,47 @@ GNUNET_TESTING_get_additional_connects (unsigned int num,
2409/** 2421/**
2410 * Create a GNUNET_CMDS_LOCAL_FINISHED message. 2422 * Create a GNUNET_CMDS_LOCAL_FINISHED message.
2411 * 2423 *
2412 * @param rv The result of the local test as GNUNET_GenericReturnValue.
2413 * @return The GNUNET_CMDS_LOCAL_FINISHED message. 2424 * @return The GNUNET_CMDS_LOCAL_FINISHED message.
2414*/ 2425*/
2415struct GNUNET_MessageHeader * 2426struct GNUNET_MessageHeader *
2416GNUNET_TESTING_send_local_test_finished_msg (enum GNUNET_GenericReturnValue rv) 2427GNUNET_TESTING_send_local_test_finished_msg ()
2417{ 2428{
2418 struct GNUNET_CMDS_LOCAL_FINISHED *reply; 2429 struct GNUNET_CMDS_LOCAL_FINISHED *reply;
2419 size_t msg_length; 2430 size_t msg_length;
2420 2431
2421 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2422 "Local test exits with status %d\n",
2423 rv);
2424 msg_length = sizeof(struct GNUNET_CMDS_LOCAL_FINISHED); 2432 msg_length = sizeof(struct GNUNET_CMDS_LOCAL_FINISHED);
2425 reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_FINISHED); 2433 reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_FINISHED);
2426 reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED); 2434 reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED);
2427 reply->header.size = htons ((uint16_t) msg_length); 2435 reply->header.size = htons ((uint16_t) msg_length);
2428 reply->result = htons (rv);
2429 2436
2430 return (struct GNUNET_MessageHeader *) reply; 2437 return (struct GNUNET_MessageHeader *) reply;
2431} 2438}
2432 2439
2433 2440
2441static void
2442parse_ac (struct GNUNET_TESTING_NetjailNode *p_node, char *token)
2443{
2444 char *ac_value;
2445
2446 ac_value = get_value ("AC", token);
2447 if (NULL != ac_value)
2448 {
2449 LOG (GNUNET_ERROR_TYPE_DEBUG,
2450 "ac value: %s\n",
2451 ac_value);
2452 sscanf (ac_value, "%u", &p_node->additional_connects);
2453 LOG (GNUNET_ERROR_TYPE_DEBUG,
2454 "AC %u\n",
2455 p_node->additional_connects);
2456 }
2457 else
2458 {
2459 p_node->additional_connects = 0;
2460 }
2461 GNUNET_free (ac_value);
2462}
2463
2464
2434/** 2465/**
2435 * Parse the topology data. 2466 * Parse the topology data.
2436 * 2467 *
@@ -2446,7 +2477,6 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2446 char *rest = NULL; 2477 char *rest = NULL;
2447 char *value = NULL; 2478 char *value = NULL;
2448 char *value2; 2479 char *value2;
2449 char *ac_value;
2450 int ret; 2480 int ret;
2451 struct GNUNET_TESTING_NetjailTopology *topo; 2481 struct GNUNET_TESTING_NetjailTopology *topo;
2452 struct GNUNET_TESTING_NetjailRouter *router; 2482 struct GNUNET_TESTING_NetjailRouter *router;
@@ -2555,6 +2585,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2555 "value: %s\n", 2585 "value: %s\n",
2556 value); 2586 value);
2557 k_node->plugin = value; 2587 k_node->plugin = value;
2588 parse_ac (k_node, token);
2558 node_connections (token, k_node); 2589 node_connections (token, k_node);
2559 GNUNET_free (value); 2590 GNUNET_free (value);
2560 } 2591 }
@@ -2617,6 +2648,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2617 { 2648 {
2618 struct GNUNET_TESTING_NetjailNode *p_node = GNUNET_new (struct 2649 struct GNUNET_TESTING_NetjailNode *p_node = GNUNET_new (struct
2619 GNUNET_TESTING_NetjailNode); 2650 GNUNET_TESTING_NetjailNode);
2651 hkey = GNUNET_new (struct GNUNET_ShortHashCode);
2620 2652
2621 LOG (GNUNET_ERROR_TYPE_DEBUG, 2653 LOG (GNUNET_ERROR_TYPE_DEBUG,
2622 "Get first Value for P.\n"); 2654 "Get first Value for P.\n");
@@ -2672,26 +2704,22 @@ GNUNET_TESTING_get_topo_from_string (char *data)
2672 LOG (GNUNET_ERROR_TYPE_DEBUG, 2704 LOG (GNUNET_ERROR_TYPE_DEBUG,
2673 "Get value for key plugin on P.\n"); 2705 "Get value for key plugin on P.\n");
2674 value = get_value ("plugin", token); 2706 value = get_value ("plugin", token);
2675 LOG (GNUNET_ERROR_TYPE_DEBUG, 2707 if (NULL != value)
2676 "plugin: %s\n", 2708 {
2677 value); 2709 LOG (GNUNET_ERROR_TYPE_DEBUG,
2678 memcpy (p_node->plugin, value, sizeof (*value)); 2710 "plugin: %s\n",
2711 value);
2712 p_node->plugin = GNUNET_malloc (sizeof(*value));
2713 memcpy (p_node->plugin, value, sizeof (*value));
2714 }
2679 GNUNET_free (value); 2715 GNUNET_free (value);
2680 p_node->node_n = out; 2716 p_node->node_n = out;
2681 p_node->namespace_n = namespace->namespace_n; 2717 p_node->namespace_n = namespace->namespace_n;
2682 } 2718 }
2683 LOG (GNUNET_ERROR_TYPE_DEBUG, 2719 LOG (GNUNET_ERROR_TYPE_DEBUG,
2684 "Get AC Value for P.\n"); 2720 "Get AC Value for P.\n");
2685 ac_value = get_value ("AC", token); 2721 parse_ac (p_node, token);
2686 LOG (GNUNET_ERROR_TYPE_DEBUG,
2687 "ac value: %s\n",
2688 ac_value);
2689 sscanf (ac_value, "%u", &p_node->additional_connects);
2690 LOG (GNUNET_ERROR_TYPE_DEBUG,
2691 "P:AC %u\n",
2692 p_node->additional_connects);
2693 node_connections (token, p_node); 2722 node_connections (token, p_node);
2694 GNUNET_free (ac_value);
2695 } 2723 }
2696 token = strtok_r (NULL, "\n", &rest); 2724 token = strtok_r (NULL, "\n", &rest);
2697 if (NULL != token) 2725 if (NULL != token)
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem.c b/src/testing/testing_api_cmd_netjail_start_testsystem.c
index 972c566d6..98de0698a 100644
--- a/src/testing/testing_api_cmd_netjail_start_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_start_testsystem.c
@@ -414,66 +414,6 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
414 // We received a message we can not handle. 414 // We received a message we can not handle.
415 GNUNET_assert (0); 415 GNUNET_assert (0);
416 } 416 }
417 /*if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY == ntohs (message->type))
418 {
419 ns->number_of_testsystems_started++;
420 }
421 else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED == ntohs (
422 message->type))
423 {
424 ns->number_of_peers_started++;
425 if (ns->number_of_peers_started == total_number)
426 {
427 for (int i = 1; i <= ns->known; i++)
428 {
429 send_all_peers_started (0,i, ns);
430 }
431
432 for (int i = 1; i <= ns->global_n; i++)
433 {
434 for (int j = 1; j <= ns->local_m; j++)
435 {
436 send_all_peers_started (i,j, ns);
437 }
438 }
439 ns->number_of_peers_started = 0;
440 }
441 }
442 else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED == ntohs (
443 message->type))
444 {
445 ns->number_of_local_tests_prepared++;
446 if (ns->number_of_local_tests_prepared == total_number)
447 {
448 for (int i = 1; i <= ns->known; i++)
449 {
450 send_all_local_tests_prepared (0,i, ns);
451 }
452
453 for (int i = 1; i <= ns->global_n; i++)
454 {
455 for (int j = 1; j <= ns->local_m; j++)
456 {
457 send_all_local_tests_prepared (i,j, ns);
458 }
459 }
460 }
461 }
462 else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED == ntohs (
463 message->type))
464 {
465 ns->number_of_local_tests_finished++;
466 if (ns->number_of_local_tests_finished == total_number)
467 {
468 GNUNET_TESTING_async_finish (&ns->ac);
469 }
470 }
471 else
472 {
473 // We received a message we can not handle.
474 GNUNET_assert (0);
475 }*/
476
477 417
478 LOG (GNUNET_ERROR_TYPE_DEBUG, 418 LOG (GNUNET_ERROR_TYPE_DEBUG,
479 "total %u sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n", 419 "total %u sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n",
diff --git a/src/testing/testing_cmds.h b/src/testing/testing_cmds.h
index 12db87d19..c4246d51e 100644
--- a/src/testing/testing_cmds.h
+++ b/src/testing/testing_cmds.h
@@ -83,10 +83,9 @@ struct GNUNET_CMDS_LOCAL_FINISHED
83 * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED 83 * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED
84 */ 84 */
85 struct GNUNET_MessageHeader header; 85 struct GNUNET_MessageHeader header;
86
87 enum GNUNET_GenericReturnValue result;
88}; 86};
89 87
88
90struct GNUNET_CMDS_LOCAL_TEST_PREPARED 89struct GNUNET_CMDS_LOCAL_TEST_PREPARED
91{ 90{
92 /** 91 /**