aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2021-11-09 17:38:47 +0100
committert3sserakt <t3ss@posteo.de>2021-11-09 17:43:25 +0100
commit8cd4dadfb9ebd4db232fda79d5c4353eacb15690 (patch)
treea063e52d71d1b6611371f6c129c6ae1b0215cf99 /src/testing
parent6fb788ca2ec44837ea10a36be7fd0030fb08955b (diff)
downloadgnunet-8cd4dadfb9ebd4db232fda79d5c4353eacb15690.tar.gz
gnunet-8cd4dadfb9ebd4db232fda79d5c4353eacb15690.zip
- moved global netjail methods to its own header file.dev/t3ss/tng
- added configuration by string in test skript instead of config file. - moved netjail scripts to contrib/netjail and install them into the share/gnunet directory.
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/Makefile.am40
-rw-r--r--src/testing/gnunet-cmds-helper.c41
-rw-r--r--src/testing/test_testing_api_cmd_netjail.c87
-rw-r--r--src/testing/test_testing_hello_world.c68
-rw-r--r--src/testing/test_testing_plugin_testcmd.c123
-rw-r--r--src/testing/test_testing_topology.c44
-rw-r--r--src/testing/testing.c99
-rw-r--r--src/testing/testing_api_cmd_block_until_all_peers_started.c107
-rw-r--r--src/testing/testing_api_cmd_block_until_external_trigger.c1
-rw-r--r--src/testing/testing_api_cmd_finish.c2
-rw-r--r--src/testing/testing_api_cmd_hello_world.c126
-rw-r--r--src/testing/testing_api_cmd_hello_world_birth.c161
-rw-r--r--src/testing/testing_api_cmd_local_test_finished.c1
-rw-r--r--src/testing/testing_api_cmd_local_test_prepared.c1
-rw-r--r--src/testing/testing_api_cmd_netjail_start.c43
-rw-r--r--src/testing/testing_api_cmd_netjail_start_testsystem.c187
-rw-r--r--src/testing/testing_api_cmd_netjail_stop.c77
-rw-r--r--src/testing/testing_api_cmd_netjail_stop_testsystem.c14
-rw-r--r--src/testing/testing_api_cmd_send_peer_ready.c1
-rw-r--r--src/testing/testing_api_cmd_system_create.c1
-rw-r--r--src/testing/testing_api_cmd_system_destroy.c1
21 files changed, 262 insertions, 963 deletions
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 3daa29e1e..a9a1b5a02 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -18,9 +18,6 @@ libexec_PROGRAMS = \
18 18
19plugindir = $(libdir)/gnunet 19plugindir = $(libdir)/gnunet
20 20
21plugin_LTLIBRARIES = \
22 libgnunet_test_testing_plugin_testcmd.la
23
24lib_LTLIBRARIES = \ 21lib_LTLIBRARIES = \
25 libgnunettesting.la 22 libgnunettesting.la
26 23
@@ -31,25 +28,12 @@ gnunet_cmds_helper_LDADD = $(XLIB) \
31 libgnunettesting.la \ 28 libgnunettesting.la \
32 $(LTLIBINTL) $(Z_LIBS) 29 $(LTLIBINTL) $(Z_LIBS)
33 30
34libgnunet_test_testing_plugin_testcmd_la_SOURCES = \
35 test_testing_plugin_testcmd.c
36libgnunet_test_testing_plugin_testcmd_la_LIBADD = \
37 $(top_builddir)/src/util/libgnunetutil.la \
38 $(top_builddir)/src/arm/libgnunetarm.la \
39 libgnunettesting.la \
40 $(top_builddir)/src/statistics/libgnunetstatistics.la \
41 $(LTLIBINTL)
42libgnunet_test_testing_plugin_testcmd_la_LDFLAGS = \
43 $(GN_PLUGIN_LDFLAGS)
44
45
46libgnunettesting_la_SOURCES = \ 31libgnunettesting_la_SOURCES = \
47 testing_api_cmd_end.c \ 32 testing_api_cmd_end.c \
48 testing_api_cmd_finish.c \ 33 testing_api_cmd_finish.c \
49 testing_api_cmd_local_test_finished.c \ 34 testing_api_cmd_local_test_finished.c \
50 testing_api_cmd_local_test_prepared.c \ 35 testing_api_cmd_local_test_prepared.c \
51 testing_api_cmd_send_peer_ready.c \ 36 testing_api_cmd_send_peer_ready.c \
52 testing_api_cmd_block_until_all_peers_started.c \
53 testing_api_cmd_block_until_external_trigger.c \ 37 testing_api_cmd_block_until_external_trigger.c \
54 testing_api_cmd_netjail_start.c \ 38 testing_api_cmd_netjail_start.c \
55 testing_api_cmd_netjail_start_testsystem.c \ 39 testing_api_cmd_netjail_start_testsystem.c \
@@ -59,8 +43,6 @@ libgnunettesting_la_SOURCES = \
59 testing_api_cmd_system_create.c \ 43 testing_api_cmd_system_create.c \
60 testing_api_cmd_system_destroy.c \ 44 testing_api_cmd_system_destroy.c \
61 testing_api_cmd_batch.c \ 45 testing_api_cmd_batch.c \
62 testing_api_cmd_hello_world.c \
63 testing_api_cmd_hello_world_birth.c \
64 testing_api_loop.c \ 46 testing_api_loop.c \
65 testing_api_trait_cmd.c \ 47 testing_api_trait_cmd.c \
66 testing_api_trait_process.c \ 48 testing_api_trait_process.c \
@@ -94,8 +76,6 @@ list_keys_LDADD = \
94 76
95 77
96check_PROGRAMS = \ 78check_PROGRAMS = \
97 test_testing_api_cmd_netjail \
98 test_testing_hello_world \
99 test_testing_portreservation \ 79 test_testing_portreservation \
100 test_testing_servicestartup \ 80 test_testing_servicestartup \
101 test_testing_peerstartup \ 81 test_testing_peerstartup \
@@ -105,32 +85,12 @@ check_PROGRAMS = \
105if ENABLE_TEST_RUN 85if ENABLE_TEST_RUN
106AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; 86AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
107TESTS = \ 87TESTS = \
108 test_testing_api_cmd_netjail \
109 test_testing_hello_world \
110 test_testing_portreservation \ 88 test_testing_portreservation \
111 test_testing_peerstartup \ 89 test_testing_peerstartup \
112 test_testing_peerstartup2 \ 90 test_testing_peerstartup2 \
113 test_testing_servicestartup 91 test_testing_servicestartup
114endif 92endif
115 93
116#test_testing_topology_SOURCES = \
117# test_testing_topology.c
118#test_testing_topology_LDADD = \
119# libgnunettesting.la \
120# $(top_builddir)/src/util/libgnunetutil.la
121
122test_testing_api_cmd_netjail_SOURCES = \
123 test_testing_api_cmd_netjail.c
124test_testing_api_cmd_netjail_LDADD = \
125 libgnunettesting.la \
126 $(top_builddir)/src/util/libgnunetutil.la
127
128test_testing_hello_world_SOURCES = \
129 test_testing_hello_world.c
130test_testing_hello_world_LDADD = \
131 libgnunettesting.la \
132 $(top_builddir)/src/util/libgnunetutil.la
133
134test_testing_portreservation_SOURCES = \ 94test_testing_portreservation_SOURCES = \
135 test_testing_portreservation.c 95 test_testing_portreservation.c
136test_testing_portreservation_LDADD = \ 96test_testing_portreservation_LDADD = \
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c
index 4aeccb115..f90cc3cc4 100644
--- a/src/testing/gnunet-cmds-helper.c
+++ b/src/testing/gnunet-cmds-helper.c
@@ -142,6 +142,16 @@ struct NodeIdentifier
142 * 142 *
143 */ 143 */
144 char *local_m; 144 char *local_m;
145
146 /**
147 * Shall we read the topology from file, or from a string.
148 */
149 unsigned int *read_file;
150
151 /**
152 * String with topology data or name of topology file.
153 */
154 char *topology_data;
145}; 155};
146 156
147/** 157/**
@@ -402,7 +412,8 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message)
402 strcat (node_ip, plugin->m); 412 strcat (node_ip, plugin->m);
403 413
404 plugin->api->start_testcase (&write_message, router_ip, node_ip, plugin->m, 414 plugin->api->start_testcase (&write_message, router_ip, node_ip, plugin->m,
405 plugin->n, plugin->local_m); 415 plugin->n, plugin->local_m, ni->topology_data,
416 ni->read_file);
406 417
407 GNUNET_free (binary); 418 GNUNET_free (binary);
408 419
@@ -559,6 +570,10 @@ main (int argc, char **argv)
559 struct GNUNET_GETOPT_CommandLineOption options[] = 570 struct GNUNET_GETOPT_CommandLineOption options[] =
560 { GNUNET_GETOPT_OPTION_END }; 571 { GNUNET_GETOPT_OPTION_END };
561 int ret; 572 int ret;
573 int i;
574 size_t topology_data_length = 0;
575 unsigned int read_file;
576 char cr[1] = "\n";
562 577
563 GNUNET_log_setup ("gnunet-cmds-helper", 578 GNUNET_log_setup ("gnunet-cmds-helper",
564 "DEBUG", 579 "DEBUG",
@@ -569,6 +584,30 @@ main (int argc, char **argv)
569 ni->m = argv[3]; 584 ni->m = argv[3];
570 ni->n = argv[4]; 585 ni->n = argv[4];
571 586
587 sscanf (argv[5], "%u", &read_file);
588
589 if (1 == read_file)
590 ni->topology_data = argv[6];
591 else
592 {
593 for (i = 6; i<argc; i++)
594 topology_data_length += strlen (argv[i]) + 1;
595 LOG (GNUNET_ERROR_TYPE_DEBUG,
596 "topo data length %lu\n",
597 topology_data_length);
598 ni->topology_data = GNUNET_malloc (topology_data_length);
599 for (i = 6; i<argc; i++)
600 {
601 strcat (ni->topology_data, argv[i]);
602 strcat (ni->topology_data, cr);
603 }
604 }
605 ni->read_file = &read_file;
606 ni->topology_data[topology_data_length - 1] = '\0';
607 LOG (GNUNET_ERROR_TYPE_DEBUG,
608 "topo data %s\n",
609 ni->topology_data);
610
572 status = GNUNET_OK; 611 status = GNUNET_OK;
573 if (NULL == 612 if (NULL ==
574 (sigpipe = GNUNET_DISK_pipe (GNUNET_DISK_PF_NONE))) 613 (sigpipe = GNUNET_DISK_pipe (GNUNET_DISK_PF_NONE)))
diff --git a/src/testing/test_testing_api_cmd_netjail.c b/src/testing/test_testing_api_cmd_netjail.c
deleted file mode 100644
index aeddfb7c9..000000000
--- a/src/testing/test_testing_api_cmd_netjail.c
+++ /dev/null
@@ -1,87 +0,0 @@
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/test_testbed_api_cmd_netjail.c
23 * @brief Test case executing a script in a network name space.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_testing_ng_lib.h"
28#include "gnunet_util_lib.h"
29
30
31/**
32 * Return value of the test.
33 *
34 */
35static unsigned int rv = 0;
36
37
38/**
39 * Main function to run the test cases.
40 *
41 * @param cls not used.
42 *
43 */
44static void
45run (void *cls)
46{
47 struct GNUNET_TESTING_Command commands[] = {
48 GNUNET_TESTING_cmd_netjail_start ("netjail-start-1",
49 "2",
50 "2"),
51 GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed-1",
52 "2",
53 "2",
54 "libgnunet_plugin_testcmd",
55 &rv),
56 GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed",
57 "netjail-start-testbed-1",
58 "2",
59 "2"),
60 GNUNET_TESTING_cmd_netjail_stop ("netjail-stop-1",
61 "2",
62 "2"),
63 GNUNET_TESTING_cmd_end ()
64 };
65
66 GNUNET_TESTING_run (NULL,
67 commands,
68 GNUNET_TIME_UNIT_FOREVER_REL);
69}
70
71
72int
73main (int argc,
74 char *const *argv)
75{
76 int rv = 0;
77
78 GNUNET_log_setup ("test-netjail",
79 "DEBUG",
80 NULL);
81 GNUNET_SCHEDULER_run (&run,
82 NULL);
83
84 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
85 "Test finished!\n");
86 return rv;
87}
diff --git a/src/testing/test_testing_hello_world.c b/src/testing/test_testing_hello_world.c
deleted file mode 100644
index 6300e26a4..000000000
--- a/src/testing/test_testing_hello_world.c
+++ /dev/null
@@ -1,68 +0,0 @@
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/test_testing_hello_world.c
23 * @brief hello world test case
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_testing_ng_lib.h"
28#include "gnunet_util_lib.h"
29
30/**
31 * Main function to run the test cases.
32 *
33 * @param cls not used.
34 *
35 */
36static void
37run (void *cls)
38{
39 (void *) cls;
40 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
41
42 struct GNUNET_TESTING_Command commands[] = {
43 GNUNET_TESTING_cmd_hello_world_birth ("hello-world-birth-0",
44 &now),
45 GNUNET_TESTING_cmd_hello_world ("hello-world-0","hello-world-birth-0",""),
46 GNUNET_TESTING_cmd_end ()
47 };
48
49 GNUNET_TESTING_run (NULL,
50 commands,
51 GNUNET_TIME_UNIT_FOREVER_REL);
52}
53
54int
55main (int argc,
56 char *const *argv)
57{
58 int rv = 0;
59
60 GNUNET_log_setup ("test-hello-world",
61 "DEBUG",
62 NULL);
63
64 GNUNET_SCHEDULER_run (&run,
65 NULL);
66
67 return rv;
68}
diff --git a/src/testing/test_testing_plugin_testcmd.c b/src/testing/test_testing_plugin_testcmd.c
deleted file mode 100644
index 32e2b38a7..000000000
--- a/src/testing/test_testing_plugin_testcmd.c
+++ /dev/null
@@ -1,123 +0,0 @@
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 * @file testbed/plugin_testcmd.c
22 * @brief a plugin to provide the API for running test cases.
23 * @author t3sserakt
24 *
25 * // FIXME: too verbose, no logic to return final status, will segv!
26 */
27#include "platform.h"
28#include "gnunet_testing_ng_lib.h"
29#include "gnunet_util_lib.h"
30#include "gnunet_testing_ng_lib.h"
31
32/**
33 * Generic logging shortcut
34 */
35#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
36
37
38// FIXME: bad global!
39unsigned int are_all_peers_started;
40
41
42static void
43all_peers_started ()
44{
45 are_all_peers_started = GNUNET_YES;
46 LOG (GNUNET_ERROR_TYPE_ERROR,
47 "setting are_all_peers_started: %d\n",
48 are_all_peers_started);
49}
50
51
52static void
53start_testcase (TESTING_CMD_HELPER_write_cb write_message,
54 char *router_ip,
55 char *node_ip,
56 char *n,
57 char *m,
58 char *local_m)
59{
60 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
61
62 LOG (GNUNET_ERROR_TYPE_ERROR,
63 "We got here 6!\n");
64
65 are_all_peers_started = GNUNET_NO;
66
67 struct GNUNET_TESTING_Command commands[] = {
68 GNUNET_TESTING_cmd_hello_world_birth ("hello-world-birth-0",
69 &now),
70 GNUNET_TESTING_cmd_hello_world ("hello-world-0","hello-world-birth-0",""),
71 GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready-1",
72 write_message),
73 GNUNET_TESTING_cmd_block_until_all_peers_started ("block-1",
74 &are_all_peers_started),
75 GNUNET_TESTING_cmd_local_test_finished ("local-test-finished-1",
76 write_message)
77 };
78
79 GNUNET_TESTING_run (commands,
80 GNUNET_TIME_UNIT_FOREVER_REL,
81 NULL, /* FIXME: pass continuation! */
82 NULL);
83 LOG (GNUNET_ERROR_TYPE_ERROR,
84 "We got here 7!\n");
85
86}
87
88
89/**
90 * Entry point for the plugin.
91 *
92 * @param cls NULL
93 * @return the exported block API
94 */
95void *
96libgnunet_plugin_testcmd_init (void *cls)
97{
98 struct GNUNET_TESTING_PluginFunctions *api;
99
100 api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
101 api->start_testcase = &start_testcase;
102 api->all_peers_started = &all_peers_started;
103 return api;
104}
105
106
107/**
108 * Exit point from the plugin.
109 *
110 * @param cls the return value from #libgnunet_plugin_block_test_init
111 * @return NULL
112 */
113void *
114libgnunet_plugin_testcmd_done (void *cls)
115{
116 struct GNUNET_TESTING_PluginFunctions *api = cls;
117
118 GNUNET_free (api);
119 return NULL;
120}
121
122
123
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c
deleted file mode 100644
index cfc91e609..000000000
--- a/src/testing/test_testing_topology.c
+++ /dev/null
@@ -1,44 +0,0 @@
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_testcmd.c
23 * @brief a plugin to provide the API for running test cases.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h"
29
30#define LOG(kind, ...) GNUNET_log_from (kind, "testing-api", __VA_ARGS__)
31
32int
33main (int argc,
34 char *const *argv)
35{
36 GNUNET_log_setup ("test-topology",
37 "DEBUG",
38 NULL);
39 LOG (GNUNET_ERROR_TYPE_DEBUG,
40 "Test\n");
41 GNUNET_TESTING_get_topo_from_file ("topo.conf");
42 LOG (GNUNET_ERROR_TYPE_DEBUG,
43 "Test2\n");
44}
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 02cedc744..4ccf93c6b 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -33,7 +33,7 @@
33#include "gnunet_util_lib.h" 33#include "gnunet_util_lib.h"
34#include "gnunet_arm_service.h" 34#include "gnunet_arm_service.h"
35#include "gnunet_testing_lib.h" 35#include "gnunet_testing_lib.h"
36#include "gnunet_testing_ng_lib.h" 36#include "gnunet_testing_netjail_lib.h"
37#include "testing_cmds.h" 37#include "testing_cmds.h"
38 38
39#define LOG(kind, ...) GNUNET_log_from (kind, "testing-api", __VA_ARGS__) 39#define LOG(kind, ...) GNUNET_log_from (kind, "testing-api", __VA_ARGS__)
@@ -2102,6 +2102,7 @@ GNUNET_TESTING_get_connections (unsigned int num, struct
2102 struct GNUNET_HashCode hc; 2102 struct GNUNET_HashCode hc;
2103 struct GNUNET_TESTING_NetjailNamespace *namespace; 2103 struct GNUNET_TESTING_NetjailNamespace *namespace;
2104 unsigned int namespace_n, node_m; 2104 unsigned int namespace_n, node_m;
2105 struct GNUNET_TESTING_NodeConnection *node_connections = NULL;
2105 2106
2106 LOG (GNUNET_ERROR_TYPE_DEBUG, 2107 LOG (GNUNET_ERROR_TYPE_DEBUG,
2107 "gaga 1\n"); 2108 "gaga 1\n");
@@ -2121,6 +2122,7 @@ GNUNET_TESTING_get_connections (unsigned int num, struct
2121 sizeof (*hkey)); 2122 sizeof (*hkey));
2122 node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals, 2123 node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals,
2123 hkey); 2124 hkey);
2125 node_connections = node->node_connections_head;
2124 } 2126 }
2125 else 2127 else
2126 { 2128 {
@@ -2147,10 +2149,11 @@ GNUNET_TESTING_get_connections (unsigned int num, struct
2147 sizeof (*hkey)); 2149 sizeof (*hkey));
2148 node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes, 2150 node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes,
2149 hkey); 2151 hkey);
2152 node_connections = node->node_connections_head;
2150 } 2153 }
2151 2154
2152 GNUNET_free (hkey); 2155 GNUNET_free (hkey);
2153 return node->node_connections_head; 2156 return node_connections;
2154} 2157}
2155 2158
2156 2159
@@ -2355,16 +2358,14 @@ GNUNET_TESTING_send_local_test_finished_msg (enum GNUNET_GenericReturnValue rv)
2355 2358
2356 2359
2357/** 2360/**
2358 * Getting the topology from file. 2361 * Parse the topology data.
2359 * 2362 *
2360 * @param filename The name of the topology file. 2363 * @param data The topology data.
2361 * @return The GNUNET_TESTING_NetjailTopology 2364 * @return The GNUNET_TESTING_NetjailTopology
2362 */ 2365 */
2363struct GNUNET_TESTING_NetjailTopology * 2366struct GNUNET_TESTING_NetjailTopology *
2364GNUNET_TESTING_get_topo_from_file (const char *filename) 2367GNUNET_TESTING_get_topo_from_string (char *data)
2365{ 2368{
2366 uint64_t fs;
2367 char *data;
2368 char *token; 2369 char *token;
2369 char *key = NULL; 2370 char *key = NULL;
2370 unsigned int out; 2371 unsigned int out;
@@ -2379,36 +2380,9 @@ GNUNET_TESTING_get_topo_from_file (const char *filename)
2379 struct GNUNET_ShortHashCode *hkey; 2380 struct GNUNET_ShortHashCode *hkey;
2380 struct GNUNET_HashCode hc; 2381 struct GNUNET_HashCode hc;
2381 2382
2382 if (GNUNET_YES != GNUNET_DISK_file_test (filename))
2383 {
2384 LOG (GNUNET_ERROR_TYPE_ERROR,
2385 _ ("Topology file %s not found\n"),
2386 filename);
2387 return NULL;
2388 }
2389 if (GNUNET_OK !=
2390 GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
2391 {
2392 LOG (GNUNET_ERROR_TYPE_ERROR,
2393 _ ("Topology file %s has no data\n"),
2394 filename);
2395 return NULL;
2396 }
2397 data = GNUNET_malloc (fs);
2398 if (fs != GNUNET_DISK_fn_read (filename, data, fs))
2399 {
2400 LOG (GNUNET_ERROR_TYPE_ERROR,
2401 _ ("Topology file %s cannot be read\n"),
2402 filename);
2403 GNUNET_free (data);
2404 return NULL;
2405 }
2406
2407 LOG (GNUNET_ERROR_TYPE_DEBUG, 2383 LOG (GNUNET_ERROR_TYPE_DEBUG,
2408 "data: %s\n", 2384 "data %s\n",
2409 data); 2385 data);
2410
2411 data[fs] = '\0';
2412 token = strtok_r (data, "\n", &rest); 2386 token = strtok_r (data, "\n", &rest);
2413 topo = GNUNET_new (struct GNUNET_TESTING_NetjailTopology); 2387 topo = GNUNET_new (struct GNUNET_TESTING_NetjailTopology);
2414 topo->map_namespaces = 2388 topo->map_namespaces =
@@ -2626,7 +2600,62 @@ GNUNET_TESTING_get_topo_from_file (const char *filename)
2626 node_connections (token, node); 2600 node_connections (token, node);
2627 } 2601 }
2628 token = strtok_r (NULL, "\n", &rest); 2602 token = strtok_r (NULL, "\n", &rest);
2603 if (NULL != token)
2604 LOG (GNUNET_ERROR_TYPE_ERROR,
2605 "Next token %s\n",
2606 token);
2607 }
2608
2609 return topo;
2610}
2611
2612
2613/**
2614 * Getting the topology from file.
2615 *
2616 * @param filename The name of the topology file.
2617 * @return The GNUNET_TESTING_NetjailTopology
2618 */
2619struct GNUNET_TESTING_NetjailTopology *
2620GNUNET_TESTING_get_topo_from_file (const char *filename)
2621{
2622 uint64_t fs;
2623 char *data;
2624 struct GNUNET_TESTING_NetjailTopology *topo;
2625
2626 if (GNUNET_YES != GNUNET_DISK_file_test (filename))
2627 {
2628 LOG (GNUNET_ERROR_TYPE_ERROR,
2629 _ ("Topology file %s not found\n"),
2630 filename);
2631 return NULL;
2632 }
2633 if (GNUNET_OK !=
2634 GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
2635 {
2636 LOG (GNUNET_ERROR_TYPE_ERROR,
2637 _ ("Topology file %s has no data\n"),
2638 filename);
2639 return NULL;
2629 } 2640 }
2641 data = GNUNET_malloc (fs);
2642 if (fs != GNUNET_DISK_fn_read (filename, data, fs))
2643 {
2644 LOG (GNUNET_ERROR_TYPE_ERROR,
2645 _ ("Topology file %s cannot be read\n"),
2646 filename);
2647 GNUNET_free (data);
2648 return NULL;
2649 }
2650
2651 LOG (GNUNET_ERROR_TYPE_DEBUG,
2652 "data: %s\n",
2653 data);
2654
2655 data[fs] = '\0';
2656
2657 topo = GNUNET_TESTING_get_topo_from_string (data);
2658
2630 GNUNET_free (data); 2659 GNUNET_free (data);
2631 2660
2632 return topo; 2661 return topo;
diff --git a/src/testing/testing_api_cmd_block_until_all_peers_started.c b/src/testing/testing_api_cmd_block_until_all_peers_started.c
deleted file mode 100644
index 763713e15..000000000
--- a/src/testing/testing_api_cmd_block_until_all_peers_started.c
+++ /dev/null
@@ -1,107 +0,0 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file testing_api_cmd_block_until_all_peers_started.c
23 * @brief cmd to block the interpreter loop until all peers started.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h"
29
30/**
31 * Generic logging shortcut
32 */
33#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
34
35/**
36 * Struct with information for callbacks.
37 *
38 */
39struct BlockState
40{
41 /**
42 * Context for our asynchronous completion.
43 */
44 struct GNUNET_TESTING_AsyncContext ac;
45
46 /**
47 * Flag to indicate if all peers have started.
48 *
49 */
50 unsigned int *all_peers_started;
51};
52
53
54/**
55 * The cleanup function of this cmd frees resources the cmd allocated.
56 *
57 */
58static void
59block_until_all_peers_started_cleanup (void *cls)
60{
61 struct BlockState *bs = cls;
62
63 GNUNET_free (bs);
64}
65
66
67/**
68 * This function does nothing but to start the cmd.
69 *
70 */
71static void
72block_until_all_peers_started_run (void *cls,
73 struct GNUNET_TESTING_Interpreter *is)
74{
75 LOG (GNUNET_ERROR_TYPE_DEBUG,
76 "block_until_all_peers_started_run!\n");
77}
78
79
80/**
81 * Create command.
82 *
83 * @param label name for command.
84 * @param all_peers_started Flag which will be set from outside.
85 * @return command.
86 */
87struct GNUNET_TESTING_Command
88GNUNET_TESTING_cmd_block_until_all_peers_started (const char *label,
89 unsigned int *
90 all_peers_started)
91{
92 struct BlockState *bs;
93
94 bs = GNUNET_new (struct BlockState);
95 bs->all_peers_started = all_peers_started;
96 {
97 struct GNUNET_TESTING_Command cmd = {
98 .cls = bs,
99 .label = label,
100 .run = &block_until_all_peers_started_run,
101 .ac = &bs->ac,
102 .cleanup = &block_until_all_peers_started_cleanup
103 };
104
105 return cmd;
106 }
107}
diff --git a/src/testing/testing_api_cmd_block_until_external_trigger.c b/src/testing/testing_api_cmd_block_until_external_trigger.c
index aeb9ffda3..7ff554280 100644
--- a/src/testing/testing_api_cmd_block_until_external_trigger.c
+++ b/src/testing/testing_api_cmd_block_until_external_trigger.c
@@ -26,6 +26,7 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h" 28#include "gnunet_testing_ng_lib.h"
29#include "gnunet_testing_netjail_lib.h"
29 30
30/** 31/**
31 * Generic logging shortcut 32 * Generic logging shortcut
diff --git a/src/testing/testing_api_cmd_finish.c b/src/testing/testing_api_cmd_finish.c
index 3ac0871a5..47199d3d6 100644
--- a/src/testing/testing_api_cmd_finish.c
+++ b/src/testing/testing_api_cmd_finish.c
@@ -25,6 +25,8 @@
25#include "platform.h" 25#include "platform.h"
26#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
27#include "gnunet_testing_ng_lib.h" 27#include "gnunet_testing_ng_lib.h"
28#include "gnunet_testing_netjail_lib.h"
29
28 30
29/** 31/**
30 * Struct to use for command-specific context information closure of a command waiting 32 * Struct to use for command-specific context information closure of a command waiting
diff --git a/src/testing/testing_api_cmd_hello_world.c b/src/testing/testing_api_cmd_hello_world.c
deleted file mode 100644
index 73dcd6dff..000000000
--- a/src/testing/testing_api_cmd_hello_world.c
+++ /dev/null
@@ -1,126 +0,0 @@
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/testing_api_cmd_hello_world.c
23 * @brief implementation of a hello world command.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_testing_ng_lib.h"
28
29struct HelloWorldState
30{
31 char *message;
32 const char *birthLabel;
33};
34
35
36/**
37 *
38 *
39 * @param cls closure
40 */
41static void
42hello_world_cleanup (void *cls)
43{
44 struct HelloWorldState *hs = cls;
45
46 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
47 "Cleaning up message %s\n",
48 hs->message);
49 GNUNET_free (hs);
50}
51
52
53/**
54 *
55 *
56 * @param cls closure.
57 * @param[out] ret result
58 * @param trait name of the trait.
59 * @param index index number of the object to offer.
60 * @return #GNUNET_OK on success.
61 */
62static enum GNUNET_GenericReturnValue
63hello_world_traits (void *cls,
64 const void **ret,
65 const char *trait,
66 unsigned int index)
67{
68 return GNUNET_NO;
69}
70
71
72/**
73* Run the "hello world" CMD.
74*
75* @param cls closure.
76* @param is interpreter state.
77*/
78static void
79hello_world_run (void *cls,
80 struct GNUNET_TESTING_Interpreter *is)
81{
82 struct HelloWorldState *hs = cls;
83 const struct GNUNET_TESTING_Command *birth_cmd;
84
85 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
86 "%s\n",
87 hs->message);
88 birth_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
89 hs->birthLabel);
90 GNUNET_TESTING_get_trait_what_am_i (birth_cmd,
91 &hs->message);
92 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
93 "Now I am a %s\n",
94 hs->message);
95}
96
97
98/**
99 * Create command.
100 *
101 * @param label name for command.
102 * @param message initial message.
103 * @return command.
104 */
105struct GNUNET_TESTING_Command
106GNUNET_TESTING_cmd_hello_world (const char *label,
107 const char *birthLabel,
108 char *message)
109{
110 struct HelloWorldState *hs;
111
112 hs = GNUNET_new (struct HelloWorldState);
113 hs->message = "Hello World, I was nobody!";
114 hs->birthLabel = birthLabel;
115 {
116 struct GNUNET_TESTING_Command cmd = {
117 .cls = hs,
118 .label = label,
119 .run = &hello_world_run,
120 .cleanup = &hello_world_cleanup,
121 .traits = &hello_world_traits
122 };
123
124 return cmd;
125 }
126}
diff --git a/src/testing/testing_api_cmd_hello_world_birth.c b/src/testing/testing_api_cmd_hello_world_birth.c
deleted file mode 100644
index 8415b99f0..000000000
--- a/src/testing/testing_api_cmd_hello_world_birth.c
+++ /dev/null
@@ -1,161 +0,0 @@
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/testing_api_cmd_hello_world.c
23 * @brief implementation of a hello world command.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h"
29
30struct HelloWorldBirthState
31{
32 struct GNUNET_TIME_Absolute *date;
33 char *what_am_i;
34};
35
36/**
37*
38*
39* @param cls closure
40* @param cmd current CMD being cleaned up.
41*/
42static void
43hello_world_birth_cleanup (void *cls)
44{
45 struct HelloWorldBirthState *hbs = cls;
46 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
47 "Finished birth of %s\n",
48 hbs->what_am_i);
49}
50
51
52/**
53*
54*
55* @param cls closure.
56* @param[out] ret result
57* @param trait name of the trait.
58* @param index index number of the object to offer.
59* @return #GNUNET_OK on success.
60*/
61static int
62hello_world_birth_traits (void *cls,
63 const void **ret,
64 const char *trait,
65 unsigned int index)
66{
67 struct HelloWorldBirthState *hbs = cls;
68 const char *what_am_i = hbs->what_am_i;
69
70 struct GNUNET_TESTING_Trait traits[] = {
71 {
72 .index = 0,
73 .trait_name = "what_am_i",
74 .ptr = (const void *) what_am_i,
75 },
76 GNUNET_TESTING_trait_end ()
77 };
78
79 return GNUNET_TESTING_get_trait (traits,
80 ret,
81 trait,
82 index);
83}
84
85
86/**
87* Run the "hello world" CMD.
88*
89* @param cls closure.
90* @param cmd CMD being run.
91* @param is interpreter state.
92*/
93static void
94hello_world_birth_run (void *cls,
95 struct GNUNET_TESTING_Interpreter *is)
96{
97 struct HelloWorldBirthState *hbs = cls;
98 struct GNUNET_TIME_Relative relative;
99
100 relative = GNUNET_TIME_absolute_get_difference (*hbs->date,
101 GNUNET_TIME_absolute_get ());
102
103 if (0 == relative.rel_value_us % 10)
104 {
105 hbs->what_am_i = "creature!";
106 }
107 else if (0 == relative.rel_value_us % 2)
108 {
109 hbs->what_am_i = "girl!";
110 }
111 else
112 {
113 hbs->what_am_i = "boy!";
114 }
115}
116
117
118/**
119 * Offer data from trait
120 *
121 * @param cmd command to extract the message from.
122 * @param pt pointer to message.
123 * @return #GNUNET_OK on success.
124 */
125int
126GNUNET_TESTING_get_trait_what_am_i (const struct GNUNET_TESTING_Command *cmd,
127 char **what_am_i)
128{
129 return cmd->traits (cmd->cls,
130 (const void **) what_am_i,
131 "what_am_i",
132 (unsigned int) 0);
133}
134
135
136/**
137 * Create command.
138 *
139 * @param label name for command.
140 * @param now when the command was started.
141 * @return command.
142 */
143struct GNUNET_TESTING_Command
144GNUNET_TESTING_cmd_hello_world_birth (const char *label,
145 struct GNUNET_TIME_Absolute *now)
146{
147 struct HelloWorldBirthState *hbs;
148
149 hbs = GNUNET_new (struct HelloWorldBirthState);
150 hbs->date = now;
151
152 struct GNUNET_TESTING_Command cmd = {
153 .cls = hbs,
154 .label = label,
155 .run = &hello_world_birth_run,
156 .cleanup = &hello_world_birth_cleanup,
157 .traits = &hello_world_birth_traits
158 };
159
160 return cmd;
161}
diff --git a/src/testing/testing_api_cmd_local_test_finished.c b/src/testing/testing_api_cmd_local_test_finished.c
index 8f8a8230c..709c6b62f 100644
--- a/src/testing/testing_api_cmd_local_test_finished.c
+++ b/src/testing/testing_api_cmd_local_test_finished.c
@@ -26,6 +26,7 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h" 28#include "gnunet_testing_ng_lib.h"
29#include "gnunet_testing_netjail_lib.h"
29#include "testing_cmds.h" 30#include "testing_cmds.h"
30 31
31/** 32/**
diff --git a/src/testing/testing_api_cmd_local_test_prepared.c b/src/testing/testing_api_cmd_local_test_prepared.c
index 2554d6fec..9dc7dfa9a 100644
--- a/src/testing/testing_api_cmd_local_test_prepared.c
+++ b/src/testing/testing_api_cmd_local_test_prepared.c
@@ -26,6 +26,7 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h" 28#include "gnunet_testing_ng_lib.h"
29#include "gnunet_testing_netjail_lib.h"
29#include "testing_cmds.h" 30#include "testing_cmds.h"
30 31
31/** 32/**
diff --git a/src/testing/testing_api_cmd_netjail_start.c b/src/testing/testing_api_cmd_netjail_start.c
index 35fb90f3c..2ff70c33e 100644
--- a/src/testing/testing_api_cmd_netjail_start.c
+++ b/src/testing/testing_api_cmd_netjail_start.c
@@ -26,8 +26,11 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h" 28#include "gnunet_testing_ng_lib.h"
29#include "gnunet_testing_netjail_lib.h"
29 30
30#define NETJAIL_START_SCRIPT "./../testing/netjail_start.sh" 31#define NETJAIL_START_SCRIPT "netjail_start.sh"
32
33#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
31 34
32/** 35/**
33 * Struct to hold information for callbacks. 36 * Struct to hold information for callbacks.
@@ -53,6 +56,10 @@ struct NetJailState
53 */ 56 */
54 char *topology_config; 57 char *topology_config;
55 58
59 /**
60 * Shall we read the topology from file, or from a string.
61 */
62 unsigned int *read_file;
56}; 63};
57 64
58 65
@@ -70,11 +77,15 @@ netjail_start_cleanup (void *cls)
70 77
71 if (NULL != ns->cwh) 78 if (NULL != ns->cwh)
72 { 79 {
80 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
81 "Cancel child\n");
73 GNUNET_wait_child_cancel (ns->cwh); 82 GNUNET_wait_child_cancel (ns->cwh);
74 ns->cwh = NULL; 83 ns->cwh = NULL;
75 } 84 }
76 if (NULL != ns->start_proc) 85 if (NULL != ns->start_proc)
77 { 86 {
87 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
88 "Kill process\n");
78 GNUNET_assert (0 == 89 GNUNET_assert (0 ==
79 GNUNET_OS_process_kill (ns->start_proc, 90 GNUNET_OS_process_kill (ns->start_proc,
80 SIGKILL)); 91 SIGKILL));
@@ -100,6 +111,7 @@ child_completed_callback (void *cls,
100 111
101 GNUNET_OS_process_destroy (ns->start_proc); 112 GNUNET_OS_process_destroy (ns->start_proc);
102 ns->start_proc = NULL; 113 ns->start_proc = NULL;
114 ns->cwh = NULL;
103 if (0 == exit_code) 115 if (0 == exit_code)
104 { 116 {
105 GNUNET_TESTING_async_finish (&ns->ac); 117 GNUNET_TESTING_async_finish (&ns->ac);
@@ -127,20 +139,28 @@ netjail_start_run (void *cls,
127 struct NetJailState *ns = cls; 139 struct NetJailState *ns = cls;
128 char pid[15]; 140 char pid[15];
129 enum GNUNET_GenericReturnValue helper_check; 141 enum GNUNET_GenericReturnValue helper_check;
142 char *data_dir;
143 char *script_name;
144 char *read_file;
145
146 data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
147 GNUNET_asprintf (&script_name, "%s%s", data_dir, NETJAIL_START_SCRIPT);
148 GNUNET_asprintf (&read_file, "%u", *(ns->read_file));
130 149
131 // FIXME: NETJAIL_START_SCRIPT like this is bad,
132 // use location from share/gnunet/ of installed
133 // binary in case libgnunettesting is used as a lib!
134 helper_check = GNUNET_OS_check_helper_binary ( 150 helper_check = GNUNET_OS_check_helper_binary (
135 NETJAIL_START_SCRIPT, 151 script_name,
136 GNUNET_YES, 152 GNUNET_YES,
137 NULL); 153 NULL);
138 154
155 LOG (GNUNET_ERROR_TYPE_DEBUG,
156 "script_name %s\n",
157 script_name);
158
139 if (GNUNET_NO == helper_check) 159 if (GNUNET_NO == helper_check)
140 { 160 {
141 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 161 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
142 "No SUID for %s!\n", 162 "No SUID for %s!\n",
143 NETJAIL_START_SCRIPT); 163 script_name);
144 GNUNET_TESTING_interpreter_fail (is); 164 GNUNET_TESTING_interpreter_fail (is);
145 return; 165 return;
146 } 166 }
@@ -148,7 +168,7 @@ netjail_start_run (void *cls,
148 { 168 {
149 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 169 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
150 "%s not found!\n", 170 "%s not found!\n",
151 NETJAIL_START_SCRIPT); 171 script_name);
152 GNUNET_TESTING_interpreter_fail (is); 172 GNUNET_TESTING_interpreter_fail (is);
153 return; 173 return;
154 } 174 }
@@ -159,9 +179,10 @@ netjail_start_run (void *cls,
159 getpid ()); 179 getpid ());
160 { 180 {
161 char *const script_argv[] = { 181 char *const script_argv[] = {
162 NETJAIL_START_SCRIPT, 182 script_name,
163 ns->topology_config, 183 ns->topology_config,
164 pid, 184 pid,
185 read_file,
165 NULL 186 NULL
166 }; 187 };
167 188
@@ -170,7 +191,7 @@ netjail_start_run (void *cls,
170 NULL, 191 NULL,
171 NULL, 192 NULL,
172 NULL, 193 NULL,
173 NETJAIL_START_SCRIPT, 194 script_name,
174 script_argv); 195 script_argv);
175 } 196 }
176 ns->cwh = GNUNET_wait_child (ns->start_proc, 197 ns->cwh = GNUNET_wait_child (ns->start_proc,
@@ -189,12 +210,14 @@ netjail_start_run (void *cls,
189 */ 210 */
190struct GNUNET_TESTING_Command 211struct GNUNET_TESTING_Command
191GNUNET_TESTING_cmd_netjail_start (const char *label, 212GNUNET_TESTING_cmd_netjail_start (const char *label,
192 char *topology_config) 213 char *topology_config,
214 unsigned int *read_file)
193{ 215{
194 struct NetJailState *ns; 216 struct NetJailState *ns;
195 217
196 ns = GNUNET_new (struct NetJailState); 218 ns = GNUNET_new (struct NetJailState);
197 ns->topology_config = topology_config; 219 ns->topology_config = topology_config;
220 ns->read_file = read_file;
198 { 221 {
199 struct GNUNET_TESTING_Command cmd = { 222 struct GNUNET_TESTING_Command cmd = {
200 .cls = ns, 223 .cls = ns,
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem.c b/src/testing/testing_api_cmd_netjail_start_testsystem.c
index c3598d174..89c193de5 100644
--- a/src/testing/testing_api_cmd_netjail_start_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_start_testsystem.c
@@ -25,9 +25,10 @@
25 */ 25 */
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_testing_netjail_lib.h"
28#include "testing_cmds.h" 29#include "testing_cmds.h"
29 30
30#define NETJAIL_EXEC_SCRIPT "./../testing/netjail_exec.sh" 31#define NETJAIL_EXEC_SCRIPT "netjail_exec.sh"
31 32
32/** 33/**
33 * Generic logging shortcut 34 * Generic logging shortcut
@@ -83,18 +84,6 @@ struct NetJailState
83 struct GNUNET_TESTING_NetjailTopology *topology; 84 struct GNUNET_TESTING_NetjailTopology *topology;
84 85
85 /** 86 /**
86 * Head of the DLL which stores messages received by the helper.
87 *
88 */
89 struct HelperMessage *hp_messages_head;
90
91 /**
92 * Tail of the DLL which stores messages received by the helper.
93 *
94 */
95 struct HelperMessage *hp_messages_tail;
96
97 /**
98 * Array with handles of helper processes. 87 * Array with handles of helper processes.
99 */ 88 */
100 struct GNUNET_HELPER_Handle **helper; 89 struct GNUNET_HELPER_Handle **helper;
@@ -123,27 +112,6 @@ struct NetJailState
123 */ 112 */
124 unsigned int known; 113 unsigned int known;
125 114
126 /**
127 * The send handle for the helper
128 */
129 // struct GNUNET_HELPER_SendHandle **shandle;
130
131 /**
132 * Size of the array NetJailState#shandle.
133 *
134 */
135 // unsigned int n_shandle;
136
137 /**
138 * The messages send to the helper.
139 */
140 struct GNUNET_MessageHeader **msg;
141
142 /**
143 * Size of the array NetJailState#msg.
144 *
145 */
146 unsigned int n_msg;
147 115
148 /** 116 /**
149 * Number of test environments started. 117 * Number of test environments started.
@@ -176,16 +144,14 @@ struct NetJailState
176 char *plugin_name; 144 char *plugin_name;
177 145
178 /** 146 /**
179 * HEAD of the DLL containing TestingSystemCount. 147 * Shall we read the topology from file, or from a string.
180 *
181 */ 148 */
182 struct TestingSystemCount *tbcs_head; 149 unsigned int *read_file;
183 150
184 /** 151 /**
185 * TAIL of the DLL containing TestingSystemCount. 152 * String with topology data or name of topology file.
186 *
187 */ 153 */
188 struct TestingSystemCount *tbcs_tail; 154 char *topology_data;
189}; 155};
190 156
191/** 157/**
@@ -207,13 +173,7 @@ struct TestingSystemCount
207 /** 173 /**
208 * The send handle for the helper 174 * The send handle for the helper
209 */ 175 */
210 struct GNUNET_HELPER_SendHandle *shandle;// **shandle; 176 struct GNUNET_HELPER_SendHandle *shandle;
211
212 /**
213 * Size of the array NetJailState#shandle.
214 *
215 */
216 // unsigned int n_shandle;
217 177
218 /** 178 /**
219 * The number of the test environment. 179 * The number of the test environment.
@@ -226,6 +186,11 @@ struct TestingSystemCount
226 * 186 *
227 */ 187 */
228 struct NetJailState *ns; 188 struct NetJailState *ns;
189
190 /**
191 * The messages send to the helper.
192 */
193 struct GNUNET_MessageHeader *msg;
229}; 194};
230 195
231/** 196/**
@@ -237,24 +202,7 @@ static void
237netjail_exec_cleanup (void *cls) 202netjail_exec_cleanup (void *cls)
238{ 203{
239 struct NetJailState *ns = cls; 204 struct NetJailState *ns = cls;
240 struct HelperMessage *message_pos;
241 struct TestingSystemCount *tbc_pos;
242 205
243 while (NULL != (message_pos = ns->hp_messages_head))
244 {
245 GNUNET_CONTAINER_DLL_remove (ns->hp_messages_head,
246 ns->hp_messages_tail,
247 message_pos);
248 GNUNET_free (message_pos);
249 }
250 while (NULL != (tbc_pos = ns->tbcs_head))
251 {
252 GNUNET_CONTAINER_DLL_remove (ns->tbcs_head,
253 ns->tbcs_tail,
254 tbc_pos);
255 GNUNET_free (tbc_pos);
256 }
257 GNUNET_TESTING_free_topology (ns->topology);
258 GNUNET_free (ns); 206 GNUNET_free (ns);
259} 207}
260 208
@@ -271,7 +219,6 @@ netjail_exec_traits (void *cls,
271{ 219{
272 struct NetJailState *ns = cls; 220 struct NetJailState *ns = cls;
273 struct GNUNET_HELPER_Handle **helper = ns->helper; 221 struct GNUNET_HELPER_Handle **helper = ns->helper;
274 struct HelperMessage *hp_messages_head = ns->hp_messages_head;
275 222
276 223
277 struct GNUNET_TESTING_Trait traits[] = { 224 struct GNUNET_TESTING_Trait traits[] = {
@@ -280,11 +227,6 @@ netjail_exec_traits (void *cls,
280 .trait_name = "helper_handles", 227 .trait_name = "helper_handles",
281 .ptr = (const void *) helper, 228 .ptr = (const void *) helper,
282 }, 229 },
283 {
284 .index = 1,
285 .trait_name = "hp_msgs_head",
286 .ptr = (const void *) hp_messages_head,
287 },
288 GNUNET_TESTING_trait_end () 230 GNUNET_TESTING_trait_end ()
289 }; 231 };
290 232
@@ -327,12 +269,12 @@ static void
327clear_msg (void *cls, int result) 269clear_msg (void *cls, int result)
328{ 270{
329 struct TestingSystemCount *tbc = cls; 271 struct TestingSystemCount *tbc = cls;
330 struct NetJailState *ns = tbc->ns;
331 272
332 GNUNET_assert (NULL != tbc->shandle);// [tbc->count - 1]); 273 GNUNET_assert (NULL != tbc->shandle);
333 tbc->shandle = NULL;// [tbc->count - 1] = NULL; 274 GNUNET_free (tbc->shandle);
334 GNUNET_free (ns->msg[tbc->count - 1]); 275 tbc->shandle = NULL;
335 ns->msg[tbc->count - 1] = NULL; 276 GNUNET_free (tbc->msg);
277 tbc->msg = NULL;
336} 278}
337 279
338 280
@@ -361,7 +303,7 @@ send_message_to_locals (
361 303
362 helper = ns->helper[tbc->count - 1];// - total_number]; 304 helper = ns->helper[tbc->count - 1];// - total_number];
363 305
364 GNUNET_array_append (ns->msg, ns->n_msg, header); 306
365 307
366 struct GNUNET_HELPER_SendHandle *sh = GNUNET_HELPER_send ( 308 struct GNUNET_HELPER_SendHandle *sh = GNUNET_HELPER_send (
367 helper, 309 helper,
@@ -427,7 +369,7 @@ static int
427helper_mst (void *cls, const struct GNUNET_MessageHeader *message) 369helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
428{ 370{
429 // struct TestingSystemCount *tbc = cls; 371 // struct TestingSystemCount *tbc = cls;
430 struct NetJailState *ns = cls;// tbc->ns; 372 struct NetJailState *ns = cls;
431 struct HelperMessage *hp_msg; 373 struct HelperMessage *hp_msg;
432 unsigned int total_number = ns->local_m * ns->global_n + ns->known; 374 unsigned int total_number = ns->local_m * ns->global_n + ns->known;
433 // uint16_t message_type = ntohs (message->type); 375 // uint16_t message_type = ntohs (message->type);
@@ -543,11 +485,8 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
543 } 485 }
544 else 486 else
545 { 487 {
546 hp_msg = GNUNET_new (struct HelperMessage); 488 // We received a message we can not handle.
547 hp_msg->bytes_msg = message->size; 489 GNUNET_assert (0);
548 memcpy (&hp_msg[1], message, message->size);
549 GNUNET_CONTAINER_DLL_insert (ns->hp_messages_head, ns->hp_messages_tail,
550 hp_msg);
551 } 490 }
552 491
553 492
@@ -629,6 +568,7 @@ start_helper (struct NetJailState *ns,
629 char *known_char; 568 char *known_char;
630 char *node_id; 569 char *node_id;
631 char *plugin; 570 char *plugin;
571 char *read_file;
632 pid_t pid; 572 pid_t pid;
633 unsigned int script_num; 573 unsigned int script_num;
634 struct GNUNET_ShortHashCode *hkey; 574 struct GNUNET_ShortHashCode *hkey;
@@ -636,6 +576,9 @@ start_helper (struct NetJailState *ns,
636 struct GNUNET_TESTING_NetjailTopology *topology = ns->topology; 576 struct GNUNET_TESTING_NetjailTopology *topology = ns->topology;
637 struct GNUNET_TESTING_NetjailNode *node; 577 struct GNUNET_TESTING_NetjailNode *node;
638 struct GNUNET_TESTING_NetjailNamespace *namespace; 578 struct GNUNET_TESTING_NetjailNamespace *namespace;
579 char *data_dir;
580 char *script_name;
581 char *topology_data;
639 582
640 583
641 if (0 == n) 584 if (0 == n)
@@ -652,47 +595,31 @@ start_helper (struct NetJailState *ns,
652 GNUNET_asprintf (&node_id, "%06x-%08x\n", 595 GNUNET_asprintf (&node_id, "%06x-%08x\n",
653 pid, 596 pid,
654 script_num); 597 script_num);
598 // GNUNET_asprintf (&topology_data, "'%s'", ns->topology_data);
599 GNUNET_asprintf (&read_file, "%u", *(ns->read_file));
655 600
656 601 data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
657 char *const script_argv[] = {NETJAIL_EXEC_SCRIPT, 602 GNUNET_asprintf (&script_name, "%s%s", data_dir, NETJAIL_EXEC_SCRIPT);
658 m_char,
659 n_char,
660 GNUNET_OS_get_libexec_binary_path (
661 HELPER_CMDS_BINARY),
662 global_n_char,
663 local_m_char,
664 node_id,
665 NULL};
666
667 unsigned int helper_check = GNUNET_OS_check_helper_binary ( 603 unsigned int helper_check = GNUNET_OS_check_helper_binary (
668 NETJAIL_EXEC_SCRIPT, 604 script_name,
669 GNUNET_YES, 605 GNUNET_YES,
670 NULL); 606 NULL);
671 607
672 tbc = GNUNET_new (struct TestingSystemCount); 608 tbc = GNUNET_new (struct TestingSystemCount);
673 tbc->ns = ns; 609 tbc->ns = ns;
674 if (0 == n)
675 tbc->count = m;
676 else
677 tbc->count = (n - 1) * ns->local_m + m + ns->known;
678
679 GNUNET_CONTAINER_DLL_insert (ns->tbcs_head,
680 ns->tbcs_tail,
681 tbc);
682
683 610
684 if (GNUNET_NO == helper_check) 611 if (GNUNET_NO == helper_check)
685 { 612 {
686 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 613 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
687 "No SUID for %s!\n", 614 "No SUID for %s!\n",
688 NETJAIL_EXEC_SCRIPT); 615 script_name);
689 GNUNET_TESTING_interpreter_fail (ns->is); 616 GNUNET_TESTING_interpreter_fail (ns->is);
690 } 617 }
691 else if (GNUNET_NO == helper_check) 618 else if (GNUNET_NO == helper_check)
692 { 619 {
693 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 620 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
694 "%s not found!\n", 621 "%s not found!\n",
695 NETJAIL_EXEC_SCRIPT); 622 script_name);
696 GNUNET_TESTING_interpreter_fail (ns->is); 623 GNUNET_TESTING_interpreter_fail (ns->is);
697 } 624 }
698 625
@@ -705,17 +632,29 @@ start_helper (struct NetJailState *ns,
705 ns->local_m, 632 ns->local_m,
706 ns->global_n, 633 ns->global_n,
707 ns->known); 634 ns->known);
635 {
636 char *const script_argv[] = {script_name,
637 m_char,
638 n_char,
639 GNUNET_OS_get_libexec_binary_path (
640 HELPER_CMDS_BINARY),
641 global_n_char,
642 local_m_char,
643 node_id,
644 read_file,
645 ns->topology_data,
646 NULL};
647 helper = GNUNET_HELPER_start (
648 GNUNET_YES,
649 script_name,
650 script_argv,
651 &helper_mst,
652 &exp_cb,
653 ns);
654 GNUNET_array_append (ns->helper, ns->n_helper, helper);
655 }
708 656
709 GNUNET_array_append (ns->helper, ns->n_helper, GNUNET_HELPER_start ( 657 tbc->count = ns->n_helper;
710 GNUNET_YES,
711 NETJAIL_EXEC_SCRIPT,
712 script_argv,
713 &helper_mst,
714 &exp_cb,
715 ns));
716
717 helper = ns->helper[tbc->count - 1];
718
719 hkey = GNUNET_new (struct GNUNET_ShortHashCode); 658 hkey = GNUNET_new (struct GNUNET_ShortHashCode);
720 659
721 plugin = topology->plugin; 660 plugin = topology->plugin;
@@ -767,8 +706,6 @@ start_helper (struct NetJailState *ns,
767 706
768 msg = create_helper_init_msg_ (plugin); 707 msg = create_helper_init_msg_ (plugin);
769 708
770 GNUNET_array_append (ns->msg, ns->n_msg, &msg->header);
771
772 // GNUNET_array_append (tbc->shandle, tbc->n_shandle, 709 // GNUNET_array_append (tbc->shandle, tbc->n_shandle,
773 tbc->shandle = GNUNET_HELPER_send ( 710 tbc->shandle = GNUNET_HELPER_send (
774 helper, 711 helper,
@@ -825,24 +762,28 @@ netjail_exec_run (void *cls,
825 * Create command. 762 * Create command.
826 * 763 *
827 * @param label Name for the command. 764 * @param label Name for the command.
828 * @param topology_config Configuration file for the test topology. 765 * @param topology The complete topology information.
766 * @param read_file Flag indicating if the the name of the topology file is send to the helper, or a string with the topology data.
767 * @param topology_data If read_file is GNUNET_NO, topology_data holds the string with the topology.
829 * @return command. 768 * @return command.
830 */ 769 */
831struct GNUNET_TESTING_Command 770struct GNUNET_TESTING_Command
832GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label, 771GNUNET_TESTING_cmd_netjail_start_testing_system (
833 const char *topology_config) 772 const char *label,
773 struct GNUNET_TESTING_NetjailTopology *topology,
774 unsigned int *read_file,
775 char *topology_data)
834{ 776{
835 struct NetJailState *ns; 777 struct NetJailState *ns;
836 778
837 struct GNUNET_TESTING_NetjailTopology *topology =
838 GNUNET_TESTING_get_topo_from_file (topology_config);
839
840 ns = GNUNET_new (struct NetJailState); 779 ns = GNUNET_new (struct NetJailState);
841 ns->local_m = topology->nodes_m; 780 ns->local_m = topology->nodes_m;
842 ns->global_n = topology->namespaces_n; 781 ns->global_n = topology->namespaces_n;
843 ns->known = topology->nodes_x; 782 ns->known = topology->nodes_x;
844 ns->plugin_name = topology->plugin; 783 ns->plugin_name = topology->plugin;
845 ns->topology = topology; 784 ns->topology = topology;
785 ns->read_file = read_file;
786 ns->topology_data = topology_data;
846 787
847 struct GNUNET_TESTING_Command cmd = { 788 struct GNUNET_TESTING_Command cmd = {
848 .cls = ns, 789 .cls = ns,
diff --git a/src/testing/testing_api_cmd_netjail_stop.c b/src/testing/testing_api_cmd_netjail_stop.c
index 5033272a3..e3bf7da62 100644
--- a/src/testing/testing_api_cmd_netjail_stop.c
+++ b/src/testing/testing_api_cmd_netjail_stop.c
@@ -26,12 +26,10 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h" 28#include "gnunet_testing_ng_lib.h"
29#include "gnunet_testing_netjail_lib.h"
29 30
30 31
31#define NETJAIL_STOP_SCRIPT "./../testing/netjail_stop.sh" 32#define NETJAIL_STOP_SCRIPT "netjail_stop.sh"
32
33// Child Wait handle
34static struct GNUNET_ChildWaitHandle *cwh;
35 33
36/** 34/**
37 * Struct to hold information for callbacks. 35 * Struct to hold information for callbacks.
@@ -44,6 +42,9 @@ struct NetJailState
44 */ 42 */
45 struct GNUNET_TESTING_AsyncContext ac; 43 struct GNUNET_TESTING_AsyncContext ac;
46 44
45 // Child Wait handle
46 struct GNUNET_ChildWaitHandle *cwh;
47
47 /** 48 /**
48 * Configuration file for the test topology. 49 * Configuration file for the test topology.
49 */ 50 */
@@ -54,6 +55,11 @@ struct NetJailState
54 */ 55 */
55 struct GNUNET_OS_Process *stop_proc; 56 struct GNUNET_OS_Process *stop_proc;
56 57
58 /**
59 * Shall we read the topology from file, or from a string.
60 */
61 unsigned int *read_file;
62
57}; 63};
58 64
59 65
@@ -66,10 +72,10 @@ netjail_stop_cleanup (void *cls)
66{ 72{
67 struct NetJailState *ns = cls; 73 struct NetJailState *ns = cls;
68 74
69 if (NULL != cwh) 75 if (NULL != ns->cwh)
70 { 76 {
71 GNUNET_wait_child_cancel (cwh); 77 GNUNET_wait_child_cancel (ns->cwh);
72 cwh = NULL; 78 ns->cwh = NULL;
73 } 79 }
74 if (NULL != ns->stop_proc) 80 if (NULL != ns->stop_proc)
75 { 81 {
@@ -95,7 +101,7 @@ child_completed_callback (void *cls,
95{ 101{
96 struct NetJailState *ns = cls; 102 struct NetJailState *ns = cls;
97 103
98 cwh = NULL; // WTF? globals!?!?! 104 ns->cwh = NULL;
99 GNUNET_OS_process_destroy (ns->stop_proc); 105 GNUNET_OS_process_destroy (ns->stop_proc);
100 ns->stop_proc = NULL; 106 ns->stop_proc = NULL;
101 if (0 == exit_code) 107 if (0 == exit_code)
@@ -121,16 +127,16 @@ netjail_stop_run (void *cls,
121{ 127{
122 struct NetJailState *ns = cls; 128 struct NetJailState *ns = cls;
123 char *pid; 129 char *pid;
130 char *data_dir;
131 char *script_name;
132 char *read_file;
124 133
125 GNUNET_asprintf (&pid, 134
126 "%u", 135 data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
127 getpid ()); 136 GNUNET_asprintf (&script_name, "%s%s", data_dir, NETJAIL_STOP_SCRIPT);
128 char *const script_argv[] = {NETJAIL_STOP_SCRIPT, 137 GNUNET_asprintf (&read_file, "%u", *(ns->read_file));
129 ns->topology_config,
130 pid,
131 NULL};
132 unsigned int helper_check = GNUNET_OS_check_helper_binary ( 138 unsigned int helper_check = GNUNET_OS_check_helper_binary (
133 NETJAIL_STOP_SCRIPT, 139 script_name,
134 GNUNET_YES, 140 GNUNET_YES,
135 NULL); 141 NULL);
136 142
@@ -138,39 +144,50 @@ netjail_stop_run (void *cls,
138 { 144 {
139 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 145 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
140 "No SUID for %s!\n", 146 "No SUID for %s!\n",
141 NETJAIL_STOP_SCRIPT); 147 script_name);
142 GNUNET_TESTING_interpreter_fail (is); 148 GNUNET_TESTING_interpreter_fail (is);
143 } 149 }
144 else if (GNUNET_NO == helper_check) 150 else if (GNUNET_NO == helper_check)
145 { 151 {
146 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 152 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
147 "%s not found!\n", 153 "%s not found!\n",
148 NETJAIL_STOP_SCRIPT); 154 script_name);
149 GNUNET_TESTING_interpreter_fail (is); 155 GNUNET_TESTING_interpreter_fail (is);
150 } 156 }
151 157
152 ns->stop_proc = GNUNET_OS_start_process_vap (GNUNET_OS_INHERIT_STD_ERR, 158 GNUNET_asprintf (&pid,
153 NULL, 159 "%u",
154 NULL, 160 getpid ());
155 NULL, 161 {
156 NETJAIL_STOP_SCRIPT, 162 char *const script_argv[] = {script_name,
157 script_argv); 163 ns->topology_config,
158 164 pid,
159 cwh = GNUNET_wait_child (ns->stop_proc, 165 read_file,
160 &child_completed_callback, 166 NULL};
161 ns); 167 ns->stop_proc = GNUNET_OS_start_process_vap (GNUNET_OS_INHERIT_STD_ERR,
162 GNUNET_break (NULL != cwh); 168 NULL,
169 NULL,
170 NULL,
171 script_name,
172 script_argv);
173 }
174 ns->cwh = GNUNET_wait_child (ns->stop_proc,
175 &child_completed_callback,
176 ns);
177 GNUNET_break (NULL != ns->cwh);
163} 178}
164 179
165 180
166struct GNUNET_TESTING_Command 181struct GNUNET_TESTING_Command
167GNUNET_TESTING_cmd_netjail_stop (const char *label, 182GNUNET_TESTING_cmd_netjail_stop (const char *label,
168 char *topology_config) 183 char *topology_config,
184 unsigned int *read_file)
169{ 185{
170 struct NetJailState *ns; 186 struct NetJailState *ns;
171 187
172 ns = GNUNET_new (struct NetJailState); 188 ns = GNUNET_new (struct NetJailState);
173 ns->topology_config = topology_config; 189 ns->topology_config = topology_config;
190 ns->read_file = read_file;
174 { 191 {
175 struct GNUNET_TESTING_Command cmd = { 192 struct GNUNET_TESTING_Command cmd = {
176 .cls = ns, 193 .cls = ns,
diff --git a/src/testing/testing_api_cmd_netjail_stop_testsystem.c b/src/testing/testing_api_cmd_netjail_stop_testsystem.c
index e37e955be..4b52878c4 100644
--- a/src/testing/testing_api_cmd_netjail_stop_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_stop_testsystem.c
@@ -25,6 +25,7 @@
25 */ 25 */
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_testing_netjail_lib.h"
28#include "testing_cmds.h" 29#include "testing_cmds.h"
29 30
30 31
@@ -70,7 +71,6 @@ stop_testing_system_cleanup (void *cls)
70{ 71{
71 struct StopHelperState *shs = cls; 72 struct StopHelperState *shs = cls;
72 73
73 GNUNET_TESTING_free_topology (shs->topology);
74 GNUNET_free (shs); 74 GNUNET_free (shs);
75} 75}
76 76
@@ -124,19 +124,17 @@ stop_testing_system_run (void *cls,
124 * 124 *
125 * @param label name for command. 125 * @param label name for command.
126 * @param helper_start_label label of the cmd to start the test system. 126 * @param helper_start_label label of the cmd to start the test system.
127 * @param topology_config Configuration file for the test topology. 127 * @param topology The complete topology information.
128 * @return command. 128 * @return command.
129 */ 129 */
130struct GNUNET_TESTING_Command 130struct GNUNET_TESTING_Command
131GNUNET_TESTING_cmd_stop_testing_system (const char *label, 131GNUNET_TESTING_cmd_stop_testing_system (
132 const char *helper_start_label, 132 const char *label,
133 const char *topology_config) 133 const char *helper_start_label,
134 struct GNUNET_TESTING_NetjailTopology *topology)
134{ 135{
135 struct StopHelperState *shs; 136 struct StopHelperState *shs;
136 137
137 struct GNUNET_TESTING_NetjailTopology *topology =
138 GNUNET_TESTING_get_topo_from_file (topology_config);
139
140 shs = GNUNET_new (struct StopHelperState); 138 shs = GNUNET_new (struct StopHelperState);
141 shs->helper_start_label = helper_start_label; 139 shs->helper_start_label = helper_start_label;
142 shs->local_m = topology->nodes_m; 140 shs->local_m = topology->nodes_m;
diff --git a/src/testing/testing_api_cmd_send_peer_ready.c b/src/testing/testing_api_cmd_send_peer_ready.c
index 8eef1d8f1..5bbabce51 100644
--- a/src/testing/testing_api_cmd_send_peer_ready.c
+++ b/src/testing/testing_api_cmd_send_peer_ready.c
@@ -26,6 +26,7 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h" 28#include "gnunet_testing_ng_lib.h"
29#include "gnunet_testing_netjail_lib.h"
29#include "testing_cmds.h" 30#include "testing_cmds.h"
30 31
31 32
diff --git a/src/testing/testing_api_cmd_system_create.c b/src/testing/testing_api_cmd_system_create.c
index 820adf1bd..275132684 100644
--- a/src/testing/testing_api_cmd_system_create.c
+++ b/src/testing/testing_api_cmd_system_create.c
@@ -26,6 +26,7 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h" 28#include "gnunet_testing_ng_lib.h"
29#include "gnunet_testing_netjail_lib.h"
29#include "gnunet_testing_lib.h" 30#include "gnunet_testing_lib.h"
30 31
31/** 32/**
diff --git a/src/testing/testing_api_cmd_system_destroy.c b/src/testing/testing_api_cmd_system_destroy.c
index 338123d91..cdfc65d53 100644
--- a/src/testing/testing_api_cmd_system_destroy.c
+++ b/src/testing/testing_api_cmd_system_destroy.c
@@ -26,6 +26,7 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h" 28#include "gnunet_testing_ng_lib.h"
29#include "gnunet_testing_netjail_lib.h"
29#include "gnunet_testing_lib.h" 30#include "gnunet_testing_lib.h"
30 31
31 32