diff options
author | t3sserakt <t3ss@posteo.de> | 2021-08-17 14:21:53 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-08-17 14:21:53 +0200 |
commit | 1e063cd73452396778cf00127346b9b08a922317 (patch) | |
tree | dc0c119ecf8511c5c56a469e580fee09800fc45a /src/testbed | |
parent | 0f00c002810907f4edf740203bdf24d81124fd32 (diff) | |
download | gnunet-1e063cd73452396778cf00127346b9b08a922317.tar.gz gnunet-1e063cd73452396778cf00127346b9b08a922317.zip |
- renamed methods and variables to prepare moving files from testbed to testing, to fix circular dependency problem
Diffstat (limited to 'src/testbed')
-rw-r--r-- | src/testbed/Makefile.am | 11 | ||||
-rw-r--r-- | src/testbed/gnunet-cmd.c | 123 | ||||
-rw-r--r-- | src/testbed/plugin_testcmd.c | 2 | ||||
-rw-r--r-- | src/testbed/test_testbed_api_cmd_netjail.c | 20 | ||||
-rw-r--r-- | src/testbed/testbed_api_cmd_controller.c | 203 | ||||
-rw-r--r-- | src/testbed/testbed_api_cmd_local_test_finished.c | 4 | ||||
-rw-r--r-- | src/testbed/testbed_api_cmd_netjail_start.c | 11 | ||||
-rw-r--r-- | src/testbed/testbed_api_cmd_netjail_start_testbed.c | 99 | ||||
-rw-r--r-- | src/testbed/testbed_api_cmd_netjail_stop.c | 11 | ||||
-rw-r--r-- | src/testbed/testbed_api_cmd_netjail_stop_testbed.c | 36 | ||||
-rw-r--r-- | src/testbed/testbed_api_cmd_peer.c | 281 | ||||
-rw-r--r-- | src/testbed/testbed_api_cmd_peer_store.c | 60 | ||||
-rw-r--r-- | src/testbed/testbed_api_cmd_send_peer_ready.c | 4 | ||||
-rw-r--r-- | src/testbed/testbed_api_cmd_tng_connect.c | 55 | ||||
-rw-r--r-- | src/testbed/testbed_api_cmd_tng_service.c | 276 |
15 files changed, 81 insertions, 1115 deletions
diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am index b4b2cff97..5a221cd69 100644 --- a/src/testbed/Makefile.am +++ b/src/testbed/Makefile.am | |||
@@ -23,7 +23,6 @@ if HAVE_SQLITE | |||
23 | endif | 23 | endif |
24 | 24 | ||
25 | libexec_PROGRAMS = \ | 25 | libexec_PROGRAMS = \ |
26 | gnunet-cmd \ | ||
27 | gnunet-cmds-helper \ | 26 | gnunet-cmds-helper \ |
28 | gnunet-service-testbed \ | 27 | gnunet-service-testbed \ |
29 | gnunet-helper-testbed \ | 28 | gnunet-helper-testbed \ |
@@ -90,14 +89,6 @@ gnunet_helper_testbed_LDADD = $(XLIB) \ | |||
90 | libgnunettestbed.la \ | 89 | libgnunettestbed.la \ |
91 | $(LTLIBINTL) $(Z_LIBS) | 90 | $(LTLIBINTL) $(Z_LIBS) |
92 | 91 | ||
93 | gnunet_cmd_SOURCES = \ | ||
94 | gnunet-cmd.c | ||
95 | gnunet_cmd_LDADD = $(XLIB) \ | ||
96 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
97 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
98 | libgnunettestbed.la \ | ||
99 | $(LTLIBINTL) $(Z_LIBS) | ||
100 | |||
101 | gnunet_cmds_helper_SOURCES = \ | 92 | gnunet_cmds_helper_SOURCES = \ |
102 | gnunet-cmds-helper.c | 93 | gnunet-cmds-helper.c |
103 | gnunet_cmds_helper_LDADD = $(XLIB) \ | 94 | gnunet_cmds_helper_LDADD = $(XLIB) \ |
@@ -138,8 +129,6 @@ libgnunettestbed_la_SOURCES = \ | |||
138 | testbed_api_cmd_netjail_stop.c \ | 129 | testbed_api_cmd_netjail_stop.c \ |
139 | testbed_api.c testbed_api.h testbed.h \ | 130 | testbed_api.c testbed_api.h testbed.h \ |
140 | testbed_api_hosts.c testbed_api_hosts.h testbed_helper.h \ | 131 | testbed_api_hosts.c testbed_api_hosts.h testbed_helper.h \ |
141 | testbed_api_cmd_controller.c \ | ||
142 | testbed_api_cmd_peer.c \ | ||
143 | testbed_api_operations.c testbed_api_operations.h \ | 132 | testbed_api_operations.c testbed_api_operations.h \ |
144 | testbed_api_peers.c testbed_api_peers.h \ | 133 | testbed_api_peers.c testbed_api_peers.h \ |
145 | testbed_api_services.c \ | 134 | testbed_api_services.c \ |
diff --git a/src/testbed/gnunet-cmd.c b/src/testbed/gnunet-cmd.c deleted file mode 100644 index 0ba94fdd9..000000000 --- a/src/testbed/gnunet-cmd.c +++ /dev/null | |||
@@ -1,123 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2008--2013, 2016 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/gnunet-cmd.c | ||
23 | * | ||
24 | * @brief Binary to start testcase plugins | ||
25 | * | ||
26 | * @author t3sserakt | ||
27 | */ | ||
28 | |||
29 | #include "platform.h" | ||
30 | #include "gnunet_util_lib.h" | ||
31 | #include "gnunet_testing_lib.h" | ||
32 | #include "gnunet_testing_plugin.h" | ||
33 | |||
34 | /** | ||
35 | * Generic logging shortcut | ||
36 | */ | ||
37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
38 | |||
39 | #define NODE_BASE_IP "192.168.15." | ||
40 | |||
41 | #define ROUTER_BASE_IP "92.68.150." | ||
42 | |||
43 | /** | ||
44 | * Handle for a plugin. | ||
45 | */ | ||
46 | struct Plugin | ||
47 | { | ||
48 | /** | ||
49 | * Name of the shared library. | ||
50 | */ | ||
51 | char *library_name; | ||
52 | |||
53 | /** | ||
54 | * Plugin API. | ||
55 | */ | ||
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; | ||
69 | }; | ||
70 | |||
71 | |||
72 | /** | ||
73 | * Main function to run the test cases. | ||
74 | * | ||
75 | * @param cls plugin to use. | ||
76 | * | ||
77 | */ | ||
78 | static void | ||
79 | run (void *cls) | ||
80 | { | ||
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, NULL, NULL, NULL); | ||
94 | |||
95 | } | ||
96 | |||
97 | |||
98 | int | ||
99 | main (int argc, char *const *argv) | ||
100 | { | ||
101 | int rv = 0; | ||
102 | struct Plugin *plugin; | ||
103 | |||
104 | GNUNET_log_setup ("gnunet-cmd", | ||
105 | "DEBUG", | ||
106 | NULL); | ||
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 | |||
118 | GNUNET_SCHEDULER_run (&run, | ||
119 | plugin); | ||
120 | |||
121 | GNUNET_free (plugin); | ||
122 | return rv; | ||
123 | } | ||
diff --git a/src/testbed/plugin_testcmd.c b/src/testbed/plugin_testcmd.c index e08ec067d..b74b67240 100644 --- a/src/testbed/plugin_testcmd.c +++ b/src/testbed/plugin_testcmd.c | |||
@@ -45,7 +45,7 @@ all_peers_started () | |||
45 | } | 45 | } |
46 | 46 | ||
47 | static void | 47 | static void |
48 | start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip, | 48 | start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, |
49 | char *node_ip, | 49 | char *node_ip, |
50 | char *n, | 50 | char *n, |
51 | char *m, | 51 | char *m, |
diff --git a/src/testbed/test_testbed_api_cmd_netjail.c b/src/testbed/test_testbed_api_cmd_netjail.c index 8bb9e40e8..85da39f0e 100644 --- a/src/testbed/test_testbed_api_cmd_netjail.c +++ b/src/testbed/test_testbed_api_cmd_netjail.c | |||
@@ -39,18 +39,18 @@ static void | |||
39 | run (void *cls) | 39 | run (void *cls) |
40 | { | 40 | { |
41 | struct GNUNET_TESTING_Command commands[] = { | 41 | struct GNUNET_TESTING_Command commands[] = { |
42 | GNUNET_TESTBED_cmd_netjail_start ("netjail-start-1", | 42 | GNUNET_TESTING_cmd_netjail_start ("netjail-start-1", |
43 | "2", | 43 | "2", |
44 | "2"), | 44 | "2"), |
45 | GNUNET_TESTBED_cmd_netjail_start_testbed ("netjail-start-testbed-1", | 45 | GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed-1", |
46 | "2", | 46 | "2", |
47 | "2", | 47 | "2", |
48 | "libgnunet_plugin_testcmd"), | 48 | "libgnunet_plugin_testcmd"), |
49 | GNUNET_TESTBED_cmd_stop_testbed ("stop-testbed", | 49 | GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed", |
50 | "netjail-start-testbed-1", | 50 | "netjail-start-testbed-1", |
51 | "2", | 51 | "2", |
52 | "2"), | 52 | "2"), |
53 | GNUNET_TESTBED_cmd_netjail_stop ("netjail-stop-1", | 53 | GNUNET_TESTING_cmd_netjail_stop ("netjail-stop-1", |
54 | "2", | 54 | "2", |
55 | "2"), | 55 | "2"), |
56 | GNUNET_TESTING_cmd_end () | 56 | GNUNET_TESTING_cmd_end () |
diff --git a/src/testbed/testbed_api_cmd_controller.c b/src/testbed/testbed_api_cmd_controller.c deleted file mode 100644 index 794b1ccf3..000000000 --- a/src/testbed/testbed_api_cmd_controller.c +++ /dev/null | |||
@@ -1,203 +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/testbed_api_cmd_controller.c | ||
23 | * @brief Command to create a controller. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testing_ng_lib.h" | ||
29 | #include "gnunet-service-testbed.h" | ||
30 | #include "testbed_api_hosts.h" | ||
31 | #include "gnunet_testbed_ng_service.h" | ||
32 | |||
33 | |||
34 | /** | ||
35 | * Generic logging shortcut | ||
36 | */ | ||
37 | #define LOG(kind, ...) \ | ||
38 | GNUNET_log (kind, __VA_ARGS__) | ||
39 | |||
40 | |||
41 | /** | ||
42 | * | ||
43 | * | ||
44 | * @param cls closure | ||
45 | * @param cmd current CMD being cleaned up. | ||
46 | */ | ||
47 | static void | ||
48 | controller_cleanup (void *cls, | ||
49 | const struct GNUNET_TESTING_Command *cmd) | ||
50 | { | ||
51 | (void) cls; | ||
52 | } | ||
53 | |||
54 | |||
55 | /** | ||
56 | * Signature of the event handler function called by the | ||
57 | * respective event controller. | ||
58 | * | ||
59 | * @param cls closure | ||
60 | * @param event information about the event | ||
61 | */ | ||
62 | static void | ||
63 | controller_cb (void *cls, | ||
64 | const struct GNUNET_TESTBED_EventInformation *event) | ||
65 | { | ||
66 | struct ControllerState *cs = cls; | ||
67 | |||
68 | if (NULL != event->details.operation_finished.emsg) | ||
69 | { | ||
70 | LOG (GNUNET_ERROR_TYPE_ERROR, "There was an operation error: %s\n", | ||
71 | event->details.operation_finished.emsg); | ||
72 | GNUNET_TESTBED_shutdown_controller (cs); | ||
73 | } | ||
74 | else if (NULL == event->details.operation_finished.generic) | ||
75 | { | ||
76 | GNUNET_TESTBED_operation_done (event->op); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | |||
81 | static void | ||
82 | controller_run (void *cls, | ||
83 | const struct GNUNET_TESTING_Command *cmd, | ||
84 | struct GNUNET_TESTING_Interpreter *is) | ||
85 | { | ||
86 | struct ControllerState *cs = cls; | ||
87 | |||
88 | cs->is = is; | ||
89 | |||
90 | cs->controller = | ||
91 | GNUNET_TESTBED_controller_connect (cs->host, cs->event_mask, &controller_cb, | ||
92 | cs); | ||
93 | |||
94 | |||
95 | } | ||
96 | |||
97 | /** | ||
98 | * | ||
99 | * | ||
100 | * @param cls closure. | ||
101 | * @param[out] ret result | ||
102 | * @param trait name of the trait. | ||
103 | * @param index index number of the object to offer. | ||
104 | * @return #GNUNET_OK on success. | ||
105 | */ | ||
106 | static int | ||
107 | controller_traits (void *cls, | ||
108 | const void **ret, | ||
109 | const char *trait, | ||
110 | unsigned int index) | ||
111 | { | ||
112 | (void) cls; | ||
113 | |||
114 | struct ControllerState *cs = cls; | ||
115 | |||
116 | |||
117 | struct GNUNET_TESTING_Trait traits[] = { | ||
118 | { | ||
119 | .index = 0, | ||
120 | .trait_name = "controller", | ||
121 | .ptr = (const void *) cs->controller, | ||
122 | }, | ||
123 | GNUNET_TESTING_trait_end () | ||
124 | }; | ||
125 | |||
126 | return GNUNET_TESTING_get_trait (traits, | ||
127 | ret, | ||
128 | trait, | ||
129 | index); | ||
130 | return GNUNET_OK; | ||
131 | } | ||
132 | |||
133 | |||
134 | /** | ||
135 | * Offer data from trait | ||
136 | * | ||
137 | * @param cmd command to extract the controller from. | ||
138 | * @param pt pointer to controller. | ||
139 | * @return #GNUNET_OK on success. | ||
140 | */ | ||
141 | int | ||
142 | GNUNET_TESTBED_get_trait_controller (const struct GNUNET_TESTING_Command *cmd, | ||
143 | struct GNUNET_TESTBED_Controller ** | ||
144 | controller) | ||
145 | { | ||
146 | return cmd->traits (cmd->cls, | ||
147 | (const void **) controller, | ||
148 | "controller", | ||
149 | (unsigned int) 0); | ||
150 | } | ||
151 | |||
152 | |||
153 | /** | ||
154 | * Shutdown nicely | ||
155 | * | ||
156 | * @param cs controller state. | ||
157 | */ | ||
158 | void | ||
159 | GNUNET_TESTBED_shutdown_controller (struct ControllerState *cs) | ||
160 | { | ||
161 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
162 | "Shutting down...\n"); | ||
163 | |||
164 | cs->controller_going_down = GNUNET_YES; | ||
165 | |||
166 | if (NULL != cs->abort_task) | ||
167 | GNUNET_SCHEDULER_cancel (cs->abort_task); | ||
168 | if (NULL != cs->reg_handle) | ||
169 | GNUNET_TESTBED_cancel_registration (cs->reg_handle); | ||
170 | if (NULL != cs->controller) | ||
171 | GNUNET_TESTBED_controller_disconnect (cs->controller); | ||
172 | if (NULL != cs->cfg) | ||
173 | GNUNET_CONFIGURATION_destroy (cs->cfg); | ||
174 | if (NULL != cs->cp) | ||
175 | GNUNET_TESTBED_controller_stop (cs->cp); | ||
176 | if (NULL != cs->host) | ||
177 | GNUNET_TESTBED_host_destroy (cs->host); | ||
178 | } | ||
179 | |||
180 | |||
181 | |||
182 | struct GNUNET_TESTING_Command | ||
183 | GNUNET_TESTBED_cmd_controller (const char *label, | ||
184 | const char *host, | ||
185 | uint64_t event_mask) | ||
186 | { | ||
187 | struct ControllerState *cs; | ||
188 | |||
189 | cs = GNUNET_new (struct ControllerState); | ||
190 | cs->event_mask = event_mask; | ||
191 | cs->hostname = host; | ||
192 | |||
193 | |||
194 | struct GNUNET_TESTING_Command cmd = { | ||
195 | .cls = cs, | ||
196 | .label = label, | ||
197 | .run = &controller_run, | ||
198 | .cleanup = &controller_cleanup, | ||
199 | .traits = &controller_traits | ||
200 | }; | ||
201 | |||
202 | return cmd; | ||
203 | } | ||
diff --git a/src/testbed/testbed_api_cmd_local_test_finished.c b/src/testbed/testbed_api_cmd_local_test_finished.c index b5f4b8b31..c02546945 100644 --- a/src/testbed/testbed_api_cmd_local_test_finished.c +++ b/src/testbed/testbed_api_cmd_local_test_finished.c | |||
@@ -35,7 +35,7 @@ | |||
35 | 35 | ||
36 | struct LocalFinishedState | 36 | struct LocalFinishedState |
37 | { | 37 | { |
38 | TESTBED_CMD_HELPER_write_cb write_message; | 38 | TESTING_CMD_HELPER_write_cb write_message; |
39 | 39 | ||
40 | struct GNUNET_CMDS_LOCAL_FINISHED *reply; | 40 | struct GNUNET_CMDS_LOCAL_FINISHED *reply; |
41 | }; | 41 | }; |
@@ -107,7 +107,7 @@ local_test_finished_finish (void *cls, | |||
107 | */ | 107 | */ |
108 | struct GNUNET_TESTING_Command | 108 | struct GNUNET_TESTING_Command |
109 | GNUNET_TESTING_cmd_local_test_finished (const char *label, | 109 | GNUNET_TESTING_cmd_local_test_finished (const char *label, |
110 | TESTBED_CMD_HELPER_write_cb | 110 | TESTING_CMD_HELPER_write_cb |
111 | write_message) | 111 | write_message) |
112 | { | 112 | { |
113 | struct LocalFinishedState *lfs; | 113 | struct LocalFinishedState *lfs; |
diff --git a/src/testbed/testbed_api_cmd_netjail_start.c b/src/testbed/testbed_api_cmd_netjail_start.c index 8edfb8b62..0cc020275 100644 --- a/src/testbed/testbed_api_cmd_netjail_start.c +++ b/src/testbed/testbed_api_cmd_netjail_start.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include "gnunet_testing_ng_lib.h" | 28 | #include "gnunet_testing_ng_lib.h" |
29 | #include "gnunet_testbed_ng_service.h" | 29 | #include "gnunet_testbed_ng_service.h" |
30 | 30 | ||
31 | #define NETJAIL_START_SCRIPT "./../testbed/netjail_start.sh" | 31 | #define NETJAIL_START_SCRIPT "./../testing/netjail_start.sh" |
32 | 32 | ||
33 | struct NetJailState | 33 | struct NetJailState |
34 | { | 34 | { |
@@ -139,9 +139,10 @@ netjail_start_run (void *cls, | |||
139 | ns->local_m, | 139 | ns->local_m, |
140 | ns->global_n, | 140 | ns->global_n, |
141 | NULL}; | 141 | NULL}; |
142 | unsigned int helper_check = GNUNET_OS_check_helper_binary (NETJAIL_START_SCRIPT, | 142 | unsigned int helper_check = GNUNET_OS_check_helper_binary ( |
143 | GNUNET_YES, | 143 | NETJAIL_START_SCRIPT, |
144 | NULL); | 144 | GNUNET_YES, |
145 | NULL); | ||
145 | 146 | ||
146 | if (GNUNET_NO == helper_check) | 147 | if (GNUNET_NO == helper_check) |
147 | { | 148 | { |
@@ -193,7 +194,7 @@ netjail_start_finish (void *cls, | |||
193 | * @return command. | 194 | * @return command. |
194 | */ | 195 | */ |
195 | struct GNUNET_TESTING_Command | 196 | struct GNUNET_TESTING_Command |
196 | GNUNET_TESTBED_cmd_netjail_start (const char *label, | 197 | GNUNET_TESTING_cmd_netjail_start (const char *label, |
197 | char *local_m, | 198 | char *local_m, |
198 | char *global_n) | 199 | char *global_n) |
199 | { | 200 | { |
diff --git a/src/testbed/testbed_api_cmd_netjail_start_testbed.c b/src/testbed/testbed_api_cmd_netjail_start_testbed.c index db9cf7508..3d1a1d893 100644 --- a/src/testbed/testbed_api_cmd_netjail_start_testbed.c +++ b/src/testbed/testbed_api_cmd_netjail_start_testbed.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include "testbed_api_hosts.h" | 30 | #include "testbed_api_hosts.h" |
31 | #include "testbed_helper.h" | 31 | #include "testbed_helper.h" |
32 | 32 | ||
33 | #define NETJAIL_EXEC_SCRIPT "./../testbed/netjail_exec.sh" | 33 | #define NETJAIL_EXEC_SCRIPT "./../testing/netjail_exec.sh" |
34 | 34 | ||
35 | struct HelperMessage; | 35 | struct HelperMessage; |
36 | 36 | ||
@@ -87,23 +87,16 @@ struct NetJailState | |||
87 | 87 | ||
88 | unsigned int n_msg; | 88 | unsigned int n_msg; |
89 | 89 | ||
90 | unsigned int number_of_testbeds_started; | 90 | unsigned int number_of_testsystems_started; |
91 | 91 | ||
92 | unsigned int number_of_peers_started; | 92 | unsigned int number_of_peers_started; |
93 | 93 | ||
94 | unsigned int number_of_local_test_finished; | 94 | unsigned int number_of_local_test_finished; |
95 | 95 | ||
96 | /** | ||
97 | * The host where the controller is running | ||
98 | */ | ||
99 | struct GNUNET_TESTBED_Host **host; | ||
100 | |||
101 | unsigned int n_host; | ||
102 | |||
103 | char *plugin_name; | 96 | char *plugin_name; |
104 | }; | 97 | }; |
105 | 98 | ||
106 | struct TestbedCount | 99 | struct TestingSystemCount |
107 | { | 100 | { |
108 | unsigned int count; | 101 | unsigned int count; |
109 | 102 | ||
@@ -168,14 +161,14 @@ netjail_exec_traits (void *cls, | |||
168 | 161 | ||
169 | 162 | ||
170 | /** | 163 | /** |
171 | * Offer handles to testbed helper from trait | 164 | * Offer handles to testing cmd helper from trait |
172 | * | 165 | * |
173 | * @param cmd command to extract the message from. | 166 | * @param cmd command to extract the message from. |
174 | * @param pt pointer to message. | 167 | * @param pt pointer to message. |
175 | * @return #GNUNET_OK on success. | 168 | * @return #GNUNET_OK on success. |
176 | */ | 169 | */ |
177 | int | 170 | int |
178 | GNUNET_TESTBED_get_trait_helper_handles (const struct | 171 | GNUNET_TESTING_get_trait_helper_handles (const struct |
179 | GNUNET_TESTING_Command *cmd, | 172 | GNUNET_TESTING_Command *cmd, |
180 | struct GNUNET_HELPER_Handle ***helper) | 173 | struct GNUNET_HELPER_Handle ***helper) |
181 | { | 174 | { |
@@ -186,14 +179,14 @@ GNUNET_TESTBED_get_trait_helper_handles (const struct | |||
186 | } | 179 | } |
187 | 180 | ||
188 | /** | 181 | /** |
189 | * Offer handles to testbed helper from trait | 182 | * Offer messages received via testing cmd helper from trait |
190 | * | 183 | * |
191 | * @param cmd command to extract the message from. | 184 | * @param cmd command to extract the message from. |
192 | * @param pt pointer to message. | 185 | * @param pt pointer to message. |
193 | * @return #GNUNET_OK on success. | 186 | * @return #GNUNET_OK on success. |
194 | */ | 187 | */ |
195 | int | 188 | int |
196 | GNUNET_TESTBED_get_trait_helper_messages (const struct | 189 | GNUNET_TESTING_get_trait_helper_messages (const struct |
197 | GNUNET_TESTING_Command *cmd, | 190 | GNUNET_TESTING_Command *cmd, |
198 | struct HelperMessage *** | 191 | struct HelperMessage *** |
199 | hp_messages_head) | 192 | hp_messages_head) |
@@ -216,7 +209,7 @@ GNUNET_TESTBED_get_trait_helper_messages (const struct | |||
216 | static void | 209 | static void |
217 | clear_msg (void *cls, int result) | 210 | clear_msg (void *cls, int result) |
218 | { | 211 | { |
219 | struct TestbedCount *tbc = cls; | 212 | struct TestingSystemCount *tbc = cls; |
220 | struct NetJailState *ns = tbc->ns; | 213 | struct NetJailState *ns = tbc->ns; |
221 | 214 | ||
222 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 215 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -244,7 +237,7 @@ clear_msg (void *cls, int result) | |||
244 | static int | 237 | static int |
245 | helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | 238 | helper_mst (void *cls, const struct GNUNET_MessageHeader *message) |
246 | { | 239 | { |
247 | struct TestbedCount *tbc = cls; | 240 | struct TestingSystemCount *tbc = cls; |
248 | struct NetJailState *ns = tbc->ns; | 241 | struct NetJailState *ns = tbc->ns; |
249 | struct HelperMessage *hp_msg; | 242 | struct HelperMessage *hp_msg; |
250 | 243 | ||
@@ -253,10 +246,9 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | |||
253 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 246 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
254 | "helper_mst tbc->count: %d\n", | 247 | "helper_mst tbc->count: %d\n", |
255 | tbc->count); | 248 | tbc->count); |
256 | // GNUNET_TESTBED_extract_cfg (host, message); | ||
257 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 249 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
258 | "Received message from helper.\n"); | 250 | "Received message from helper.\n"); |
259 | ns->number_of_testbeds_started++; | 251 | ns->number_of_testsystems_started++; |
260 | } | 252 | } |
261 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED == ntohs ( | 253 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED == ntohs ( |
262 | message->type)) | 254 | message->type)) |
@@ -320,57 +312,38 @@ create_helper_init_msg_ (char *m_char, | |||
320 | 312 | ||
321 | 313 | ||
322 | static void | 314 | static void |
323 | start_testbed (struct NetJailState *ns, struct | 315 | start_helper (struct NetJailState *ns, struct |
324 | GNUNET_CONFIGURATION_Handle *config, | 316 | GNUNET_CONFIGURATION_Handle *config, |
325 | char *m_char, | 317 | char *m_char, |
326 | char *n_char) | 318 | char *n_char) |
327 | { | 319 | { |
328 | // struct GNUNET_CONFIGURATION_Handle *cfg; | 320 | // struct GNUNET_CONFIGURATION_Handle *cfg; |
329 | struct GNUNET_CMDS_HelperInit *msg; | 321 | struct GNUNET_CMDS_HelperInit *msg; |
330 | struct TestbedCount *tbc; | 322 | struct TestingSystemCount *tbc; |
331 | char *const script_argv[] = {NETJAIL_EXEC_SCRIPT, | 323 | char *const script_argv[] = {NETJAIL_EXEC_SCRIPT, |
332 | m_char, | 324 | m_char, |
333 | n_char, | 325 | n_char, |
334 | GNUNET_OS_get_libexec_binary_path(HELPER_CMDS_BINARY), | 326 | GNUNET_OS_get_libexec_binary_path ( |
327 | HELPER_CMDS_BINARY), | ||
335 | ns->global_n, | 328 | ns->global_n, |
336 | ns->local_m, | 329 | ns->local_m, |
337 | NULL}; | 330 | NULL}; |
338 | unsigned int m = atoi (m_char); | 331 | unsigned int m = atoi (m_char); |
339 | unsigned int n = atoi (n_char); | 332 | unsigned int n = atoi (n_char); |
340 | unsigned int helper_check = GNUNET_OS_check_helper_binary (NETJAIL_EXEC_SCRIPT, | 333 | unsigned int helper_check = GNUNET_OS_check_helper_binary ( |
341 | GNUNET_YES, | 334 | NETJAIL_EXEC_SCRIPT, |
342 | NULL); | 335 | GNUNET_YES, |
336 | NULL); | ||
343 | 337 | ||
344 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 338 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
345 | "m: %d n: %d\n", | 339 | "m: %d n: %d\n", |
346 | m, | 340 | m, |
347 | n); | 341 | n); |
348 | 342 | ||
349 | tbc = GNUNET_new (struct TestbedCount); | 343 | tbc = GNUNET_new (struct TestingSystemCount); |
350 | tbc->ns = ns; | 344 | tbc->ns = ns; |
351 | tbc->count = (n - 1) * atoi (ns->local_m) + m; | 345 | tbc->count = (n - 1) * atoi (ns->local_m) + m; |
352 | 346 | ||
353 | // cfg = GNUNET_CONFIGURATION_dup (config); | ||
354 | |||
355 | // TODO We do not need this? | ||
356 | /*GNUNET_array_append (ns->host, ns->n_host, | ||
357 | GNUNET_TESTBED_host_create_with_id (tbc->count - 1, | ||
358 | NULL, | ||
359 | NULL, | ||
360 | cfg, | ||
361 | 0));*/ | ||
362 | |||
363 | /*if ((GNUNET_YES != GNUNET_DISK_file_test ("test_testbed_api.conf")) || | ||
364 | (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (config, | ||
365 | "test_testbed_api.conf"))) | ||
366 | { | ||
367 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
368 | _ ( | ||
369 | "Unreadable or malformed configuration file `%s', exit ...\n"), | ||
370 | "test_testbed_api.conf"); | ||
371 | }*/ | ||
372 | |||
373 | |||
374 | 347 | ||
375 | if (GNUNET_NO == helper_check) | 348 | if (GNUNET_NO == helper_check) |
376 | { | 349 | { |
@@ -396,13 +369,13 @@ start_testbed (struct NetJailState *ns, struct | |||
396 | tbc)); | 369 | tbc)); |
397 | 370 | ||
398 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 371 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
399 | "First using helper %d %d\n", | 372 | "First using helper %d %d\n", |
400 | tbc->count - 1, | 373 | tbc->count - 1, |
401 | ns->n_helper); | 374 | ns->n_helper); |
402 | struct GNUNET_HELPER_Handle *helper = ns->helper[tbc->count - 1]; | 375 | struct GNUNET_HELPER_Handle *helper = ns->helper[tbc->count - 1]; |
403 | 376 | ||
404 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 377 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
405 | "First using helper %d %d %p\n", | 378 | "First using helper %d %d %p\n", |
406 | tbc->count - 1, | 379 | tbc->count - 1, |
407 | ns->n_helper, | 380 | ns->n_helper, |
408 | helper); | 381 | helper); |
@@ -456,9 +429,9 @@ netjail_exec_run (void *cls, | |||
456 | { | 429 | { |
457 | sprintf (str_n, "%d", i); | 430 | sprintf (str_n, "%d", i); |
458 | sprintf (str_m, "%d", j); | 431 | sprintf (str_m, "%d", j); |
459 | start_testbed (ns, config, | 432 | start_helper (ns, config, |
460 | str_m, | 433 | str_m, |
461 | str_n); | 434 | str_n); |
462 | } | 435 | } |
463 | } | 436 | } |
464 | } | 437 | } |
@@ -475,7 +448,7 @@ netjail_start_finish (void *cls, | |||
475 | struct GNUNET_CMDS_ALL_PEERS_STARTED *reply; | 448 | struct GNUNET_CMDS_ALL_PEERS_STARTED *reply; |
476 | size_t msg_length; | 449 | size_t msg_length; |
477 | struct GNUNET_HELPER_Handle *helper; | 450 | struct GNUNET_HELPER_Handle *helper; |
478 | struct TestbedCount *tbc; | 451 | struct TestingSystemCount *tbc; |
479 | 452 | ||
480 | if (ns->number_of_local_test_finished == total_number) | 453 | if (ns->number_of_local_test_finished == total_number) |
481 | { | 454 | { |
@@ -483,11 +456,11 @@ netjail_start_finish (void *cls, | |||
483 | cont (cont_cls); | 456 | cont (cont_cls); |
484 | } | 457 | } |
485 | 458 | ||
486 | if (ns->number_of_testbeds_started == total_number) | 459 | if (ns->number_of_testsystems_started == total_number) |
487 | { | 460 | { |
488 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 461 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
489 | "All helpers started!\n"); | 462 | "All helpers started!\n"); |
490 | ns->number_of_testbeds_started = 0; | 463 | ns->number_of_testsystems_started = 0; |
491 | } | 464 | } |
492 | 465 | ||
493 | if (ns->number_of_peers_started == total_number) | 466 | if (ns->number_of_peers_started == total_number) |
@@ -498,7 +471,7 @@ netjail_start_finish (void *cls, | |||
498 | for (int i = 1; i <= atoi (ns->global_n); i++) { | 471 | for (int i = 1; i <= atoi (ns->global_n); i++) { |
499 | for (int j = 1; j <= atoi (ns->local_m); j++) | 472 | for (int j = 1; j <= atoi (ns->local_m); j++) |
500 | { | 473 | { |
501 | tbc = GNUNET_new (struct TestbedCount); | 474 | tbc = GNUNET_new (struct TestingSystemCount); |
502 | tbc->ns = ns; | 475 | tbc->ns = ns; |
503 | // TODO This needs to be more generic. As we send more messages back and forth, we can not grow the arrays again and again, because this is to error prone. | 476 | // TODO This needs to be more generic. As we send more messages back and forth, we can not grow the arrays again and again, because this is to error prone. |
504 | tbc->count = (i - 1) * atoi (ns->local_m) + j + total_number; | 477 | tbc->count = (i - 1) * atoi (ns->local_m) + j + total_number; |
@@ -544,11 +517,11 @@ netjail_start_finish (void *cls, | |||
544 | * @return command. | 517 | * @return command. |
545 | */ | 518 | */ |
546 | struct GNUNET_TESTING_Command | 519 | struct GNUNET_TESTING_Command |
547 | GNUNET_TESTBED_cmd_netjail_start_testbed (const char *label, | 520 | GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label, |
548 | char *local_m, | 521 | char *local_m, |
549 | char *global_n, | 522 | char *global_n, |
550 | char *plugin_name, | 523 | char *plugin_name, |
551 | unsigned int *rv) | 524 | unsigned int *rv) |
552 | { | 525 | { |
553 | struct NetJailState *ns; | 526 | struct NetJailState *ns; |
554 | 527 | ||
diff --git a/src/testbed/testbed_api_cmd_netjail_stop.c b/src/testbed/testbed_api_cmd_netjail_stop.c index 947384fed..f837ec08c 100644 --- a/src/testbed/testbed_api_cmd_netjail_stop.c +++ b/src/testbed/testbed_api_cmd_netjail_stop.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "gnunet_testbed_ng_service.h" | 29 | #include "gnunet_testbed_ng_service.h" |
30 | 30 | ||
31 | 31 | ||
32 | #define NETJAIL_STOP_SCRIPT "./../testbed/netjail_stop.sh" | 32 | #define NETJAIL_STOP_SCRIPT "./../testing/netjail_stop.sh" |
33 | 33 | ||
34 | struct GNUNET_ChildWaitHandle *cwh; | 34 | struct GNUNET_ChildWaitHandle *cwh; |
35 | 35 | ||
@@ -135,9 +135,10 @@ netjail_stop_run (void *cls, | |||
135 | ns->local_m, | 135 | ns->local_m, |
136 | ns->global_n, | 136 | ns->global_n, |
137 | NULL}; | 137 | NULL}; |
138 | unsigned int helper_check = GNUNET_OS_check_helper_binary (NETJAIL_STOP_SCRIPT, | 138 | unsigned int helper_check = GNUNET_OS_check_helper_binary ( |
139 | GNUNET_YES, | 139 | NETJAIL_STOP_SCRIPT, |
140 | NULL); | 140 | GNUNET_YES, |
141 | NULL); | ||
141 | 142 | ||
142 | if (GNUNET_NO == helper_check) | 143 | if (GNUNET_NO == helper_check) |
143 | { | 144 | { |
@@ -192,7 +193,7 @@ netjail_stop_finish (void *cls, | |||
192 | * @return command. | 193 | * @return command. |
193 | */ | 194 | */ |
194 | struct GNUNET_TESTING_Command | 195 | struct GNUNET_TESTING_Command |
195 | GNUNET_TESTBED_cmd_netjail_stop (const char *label, | 196 | GNUNET_TESTING_cmd_netjail_stop (const char *label, |
196 | char *local_m, | 197 | char *local_m, |
197 | char *global_n) | 198 | char *global_n) |
198 | { | 199 | { |
diff --git a/src/testbed/testbed_api_cmd_netjail_stop_testbed.c b/src/testbed/testbed_api_cmd_netjail_stop_testbed.c index 9a9d489a7..c74c1e94f 100644 --- a/src/testbed/testbed_api_cmd_netjail_stop_testbed.c +++ b/src/testbed/testbed_api_cmd_netjail_stop_testbed.c | |||
@@ -53,8 +53,8 @@ struct StopHelperState | |||
53 | * @param cmd current CMD being cleaned up. | 53 | * @param cmd current CMD being cleaned up. |
54 | */ | 54 | */ |
55 | static void | 55 | static void |
56 | stop_testbed_cleanup (void *cls, | 56 | stop_testing_system_cleanup (void *cls, |
57 | const struct GNUNET_TESTING_Command *cmd) | 57 | const struct GNUNET_TESTING_Command *cmd) |
58 | { | 58 | { |
59 | 59 | ||
60 | } | 60 | } |
@@ -70,10 +70,10 @@ stop_testbed_cleanup (void *cls, | |||
70 | * @return #GNUNET_OK on success. | 70 | * @return #GNUNET_OK on success. |
71 | */ | 71 | */ |
72 | static int | 72 | static int |
73 | stop_testbed_traits (void *cls, | 73 | stop_testing_system_traits (void *cls, |
74 | const void **ret, | 74 | const void **ret, |
75 | const char *trait, | 75 | const char *trait, |
76 | unsigned int index) | 76 | unsigned int index) |
77 | { | 77 | { |
78 | return GNUNET_OK; | 78 | return GNUNET_OK; |
79 | } | 79 | } |
@@ -87,9 +87,9 @@ stop_testbed_traits (void *cls, | |||
87 | * @param is interpreter state. | 87 | * @param is interpreter state. |
88 | */ | 88 | */ |
89 | static void | 89 | static void |
90 | stop_testbed_run (void *cls, | 90 | stop_testing_system_run (void *cls, |
91 | const struct GNUNET_TESTING_Command *cmd, | 91 | const struct GNUNET_TESTING_Command *cmd, |
92 | struct GNUNET_TESTING_Interpreter *is) | 92 | struct GNUNET_TESTING_Interpreter *is) |
93 | { | 93 | { |
94 | struct StopHelperState *shs = cls; | 94 | struct StopHelperState *shs = cls; |
95 | struct GNUNET_HELPER_Handle **helper; | 95 | struct GNUNET_HELPER_Handle **helper; |
@@ -97,7 +97,7 @@ stop_testbed_run (void *cls, | |||
97 | 97 | ||
98 | start_helper_cmd = GNUNET_TESTING_interpreter_lookup_command ( | 98 | start_helper_cmd = GNUNET_TESTING_interpreter_lookup_command ( |
99 | shs->helper_start_label); | 99 | shs->helper_start_label); |
100 | GNUNET_TESTBED_get_trait_helper_handles (start_helper_cmd, | 100 | GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd, |
101 | &helper); | 101 | &helper); |
102 | 102 | ||
103 | for (int i = 1; i <= atoi (shs->global_n); i++) { | 103 | for (int i = 1; i <= atoi (shs->global_n); i++) { |
@@ -118,11 +118,11 @@ stop_testbed_run (void *cls, | |||
118 | * @return command. | 118 | * @return command. |
119 | */ | 119 | */ |
120 | struct GNUNET_TESTING_Command | 120 | struct GNUNET_TESTING_Command |
121 | GNUNET_TESTBED_cmd_stop_testbed (const char *label, | 121 | GNUNET_TESTING_cmd_stop_testing_system (const char *label, |
122 | const char *helper_start_label, | 122 | const char *helper_start_label, |
123 | char *local_m, | 123 | char *local_m, |
124 | char *global_n | 124 | char *global_n |
125 | ) | 125 | ) |
126 | { | 126 | { |
127 | struct StopHelperState *shs; | 127 | struct StopHelperState *shs; |
128 | 128 | ||
@@ -134,9 +134,9 @@ GNUNET_TESTBED_cmd_stop_testbed (const char *label, | |||
134 | struct GNUNET_TESTING_Command cmd = { | 134 | struct GNUNET_TESTING_Command cmd = { |
135 | .cls = shs, | 135 | .cls = shs, |
136 | .label = label, | 136 | .label = label, |
137 | .run = &stop_testbed_run, | 137 | .run = &stop_testing_system_run, |
138 | .cleanup = &stop_testbed_cleanup, | 138 | .cleanup = &stop_testing_system_cleanup, |
139 | .traits = &stop_testbed_traits | 139 | .traits = &stop_testing_system_traits |
140 | }; | 140 | }; |
141 | 141 | ||
142 | return cmd; | 142 | return cmd; |
diff --git a/src/testbed/testbed_api_cmd_peer.c b/src/testbed/testbed_api_cmd_peer.c deleted file mode 100644 index 2e253e408..000000000 --- a/src/testbed/testbed_api_cmd_peer.c +++ /dev/null | |||
@@ -1,281 +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 | /** | ||
23 | * @file testbed/testbed_api_cmd_peer.c | ||
24 | * @brief Command to create a peer. | ||
25 | * @author t3sserakt | ||
26 | */ | ||
27 | #include "platform.h" | ||
28 | #include "gnunet_util_lib.h" | ||
29 | #include "gnunet_testing_ng_lib.h" | ||
30 | #include "gnunet_testbed_ng_service.h" | ||
31 | #include "gnunet-service-testbed.h" | ||
32 | #include "testbed_api_peers.h" | ||
33 | |||
34 | |||
35 | /** | ||
36 | * Generic logging shortcut | ||
37 | */ | ||
38 | #define LOG(kind, ...) \ | ||
39 | GNUNET_log (kind, __VA_ARGS__) | ||
40 | |||
41 | |||
42 | /** | ||
43 | * | ||
44 | * | ||
45 | * @param cls closure. | ||
46 | * @param[out] ret result | ||
47 | * @param trait name of the trait. | ||
48 | * @param index index number of the object to offer. | ||
49 | * @return #GNUNET_OK on success. | ||
50 | */ | ||
51 | static int | ||
52 | peer_traits (void *cls, | ||
53 | const void **ret, | ||
54 | const char *trait, | ||
55 | unsigned int index) | ||
56 | { | ||
57 | struct PeerCmdState *ps = cls; | ||
58 | |||
59 | struct GNUNET_TESTING_Trait traits[] = { | ||
60 | { | ||
61 | .index = 0, | ||
62 | .trait_name = "peer", | ||
63 | .ptr = (const void *) ps->peer, | ||
64 | }, | ||
65 | GNUNET_TESTING_trait_end () | ||
66 | }; | ||
67 | |||
68 | return GNUNET_TESTING_get_trait (traits, | ||
69 | ret, | ||
70 | trait, | ||
71 | index); | ||
72 | |||
73 | return GNUNET_OK; | ||
74 | } | ||
75 | |||
76 | /** | ||
77 | * Offer data from trait | ||
78 | * | ||
79 | * @param cmd command to extract the controller from. | ||
80 | * @param peer pointer GNUNET_TESTBED_PEER | ||
81 | * @return #GNUNET_OK on success. | ||
82 | */ | ||
83 | int | ||
84 | GNUNET_TESTBED_get_trait_peer (const struct GNUNET_TESTING_Command *cmd, | ||
85 | struct GNUNET_TESTBED_Peer ** | ||
86 | peer) | ||
87 | { | ||
88 | return cmd->traits (cmd->cls, | ||
89 | (const void **) peer, | ||
90 | "peer", | ||
91 | (unsigned int) 0); | ||
92 | } | ||
93 | |||
94 | |||
95 | /** | ||
96 | * | ||
97 | * | ||
98 | * @param cls closure | ||
99 | * @param cmd current CMD being cleaned up. | ||
100 | */ | ||
101 | static void | ||
102 | peer_cleanup (void *cls, | ||
103 | const struct GNUNET_TESTING_Command *cmd) | ||
104 | { | ||
105 | (void) cls; | ||
106 | } | ||
107 | |||
108 | |||
109 | /** | ||
110 | * abort task to run on test timed out | ||
111 | * | ||
112 | * @param cls NULL | ||
113 | * @param tc the task context | ||
114 | */ | ||
115 | static void | ||
116 | do_abort (void *cls) | ||
117 | { | ||
118 | struct PeerCmdState *ps = cls; | ||
119 | |||
120 | if (GNUNET_NO == ps->peer_ready) | ||
121 | { | ||
122 | LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n"); | ||
123 | ps->abort_task = NULL; | ||
124 | GNUNET_TESTBED_shutdown_peer (ps); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | |||
129 | /** | ||
130 | * Functions of this signature are called when a peer has been successfully | ||
131 | * created | ||
132 | * | ||
133 | * @param cls the closure from GNUNET_TESTBED_peer_create() | ||
134 | * @param emsg MAY contain an error description, if starting peer failed. | ||
135 | */ | ||
136 | static void | ||
137 | peer_started_cb (void *cls, | ||
138 | const char *emsg) | ||
139 | { | ||
140 | struct PeerCmdState *ps = cls; | ||
141 | |||
142 | GNUNET_TESTBED_operation_done (ps->operation); | ||
143 | if (NULL == emsg) | ||
144 | { | ||
145 | ps->peer_ready = GNUNET_YES; | ||
146 | } | ||
147 | else | ||
148 | { | ||
149 | LOG (GNUNET_ERROR_TYPE_ERROR, "There was an error starting a peer: %s\n", | ||
150 | emsg); | ||
151 | } | ||
152 | |||
153 | } | ||
154 | |||
155 | |||
156 | /** | ||
157 | * Functions of this signature are called when a peer has been successfully | ||
158 | * created | ||
159 | * | ||
160 | * @param cls the closure from GNUNET_TESTBED_peer_create() | ||
161 | * @param peer the handle for the created peer; NULL on any error during | ||
162 | * creation | ||
163 | * @param emsg NULL if peer is not NULL; else MAY contain the error description | ||
164 | */ | ||
165 | static void | ||
166 | peer_create_cb (void *cls, | ||
167 | struct GNUNET_TESTBED_Peer *peer, | ||
168 | const char *emsg) | ||
169 | { | ||
170 | struct PeerCmdState *ps = cls; | ||
171 | |||
172 | ps->peer = peer; | ||
173 | GNUNET_TESTBED_operation_done (ps->operation); | ||
174 | ps->operation = GNUNET_TESTBED_peer_start (NULL, | ||
175 | peer, | ||
176 | &peer_started_cb, | ||
177 | ps); | ||
178 | } | ||
179 | |||
180 | |||
181 | static void | ||
182 | peer_run (void *cls, | ||
183 | const struct GNUNET_TESTING_Command *cmd, | ||
184 | struct GNUNET_TESTING_Interpreter *is) | ||
185 | { | ||
186 | struct PeerCmdState *ps = cls; | ||
187 | const struct GNUNET_TESTING_Command *controller_cmd; | ||
188 | struct GNUNET_TESTBED_Controller *controller; | ||
189 | |||
190 | ps->is = is; | ||
191 | controller_cmd = GNUNET_TESTING_interpreter_lookup_command ( | ||
192 | ps->controller_label); | ||
193 | GNUNET_TESTBED_get_trait_controller (controller_cmd, | ||
194 | &controller); | ||
195 | ps->host = GNUNET_TESTBED_host_create (ps->hostname, ps->username, ps->cfg, | ||
196 | ps->port); | ||
197 | ps->operation = | ||
198 | GNUNET_TESTBED_peer_create (controller, | ||
199 | ps->host, | ||
200 | ps->cfg, | ||
201 | &peer_create_cb, | ||
202 | ps); | ||
203 | |||
204 | ps->abort_task = | ||
205 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | ||
206 | (GNUNET_TIME_UNIT_MINUTES, 5), | ||
207 | &do_abort, | ||
208 | ps); | ||
209 | } | ||
210 | |||
211 | |||
212 | void | ||
213 | peer_stopped_cb (void *cls, | ||
214 | const char *emsg) | ||
215 | { | ||
216 | struct PeerCmdState *ps = cls; | ||
217 | |||
218 | if (NULL != emsg) | ||
219 | { | ||
220 | LOG (GNUNET_ERROR_TYPE_ERROR, "There was an error stopping a peer: %s\n", | ||
221 | emsg); | ||
222 | } | ||
223 | GNUNET_TESTBED_operation_done (ps->operation); | ||
224 | GNUNET_TESTBED_peer_destroy (ps->peer); | ||
225 | } | ||
226 | |||
227 | |||
228 | /** | ||
229 | * Shutdown nicely | ||
230 | * | ||
231 | * @param cs controller state. | ||
232 | */ | ||
233 | void | ||
234 | GNUNET_TESTBED_shutdown_peer (struct PeerCmdState *ps) | ||
235 | { | ||
236 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
237 | "Shutting down...\n"); | ||
238 | |||
239 | ps->peer_going_down = GNUNET_YES; | ||
240 | |||
241 | if (NULL != ps->abort_task) | ||
242 | GNUNET_SCHEDULER_cancel (ps->abort_task); | ||
243 | if (NULL != ps->cfg) | ||
244 | GNUNET_CONFIGURATION_destroy (ps->cfg); | ||
245 | if (NULL != ps->host) | ||
246 | GNUNET_TESTBED_host_destroy (ps->host); | ||
247 | |||
248 | GNUNET_TESTBED_operation_done (ps->operation); | ||
249 | ps->operation = GNUNET_TESTBED_peer_stop (NULL, ps->peer, peer_stopped_cb, | ||
250 | ps); | ||
251 | |||
252 | } | ||
253 | |||
254 | |||
255 | struct GNUNET_TESTING_Command | ||
256 | GNUNET_TESTBED_cmd_peer (const char *label, | ||
257 | const char *controller_label, | ||
258 | const char *hostname, | ||
259 | const char *username, | ||
260 | uint16_t port, | ||
261 | struct GNUNET_CONFIGURATION_Handle *cfg) | ||
262 | { | ||
263 | struct PeerCmdState *ps; | ||
264 | |||
265 | ps = GNUNET_new (struct PeerCmdState); | ||
266 | ps->hostname = hostname; | ||
267 | ps->username = username; | ||
268 | ps->port = port; | ||
269 | ps->cfg = cfg; | ||
270 | ps->controller_label = controller_label; | ||
271 | |||
272 | struct GNUNET_TESTING_Command cmd = { | ||
273 | .cls = ps, | ||
274 | .label = label, | ||
275 | .run = &peer_run, | ||
276 | .cleanup = &peer_cleanup, | ||
277 | .traits = &peer_traits | ||
278 | }; | ||
279 | |||
280 | return cmd; | ||
281 | } | ||
diff --git a/src/testbed/testbed_api_cmd_peer_store.c b/src/testbed/testbed_api_cmd_peer_store.c deleted file mode 100644 index fc96f589c..000000000 --- a/src/testbed/testbed_api_cmd_peer_store.c +++ /dev/null | |||
@@ -1,60 +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/testbed_api_cmd_peer_store.c | ||
23 | * @brief Command to start the peer store service of a peer. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | |||
27 | |||
28 | static void | ||
29 | service_run (void *cls, | ||
30 | const struct GNUNET_TESTING_Command *cmd, | ||
31 | struct GNUNET_TESTING_Interpreter *is) | ||
32 | { | ||
33 | struct PeerStoreState *pss = cls; | ||
34 | |||
35 | pss->psh = GNUNET_PEERSTORE_connect (pss->cfg); | ||
36 | GNUNET_TESTING_interpreter_next (ps->is); | ||
37 | } | ||
38 | |||
39 | |||
40 | struct GNUNET_TESTING_Command | ||
41 | GNUNET_TESTBED_cmd_peer_store (const char *label, | ||
42 | struct GNUNET_CONFIGURATION_Handle *cfg) | ||
43 | { | ||
44 | |||
45 | struct PeerStoreState *pss; | ||
46 | |||
47 | pss = GNUNET_new (struct PeerStoreState); | ||
48 | pss->cfg = cfg; | ||
49 | |||
50 | struct GNUNET_TESTING_Command cmd = { | ||
51 | .cls = pss, | ||
52 | .label = label, | ||
53 | .run = &peer_store_run, | ||
54 | .cleanup = &peer_store_cleanup, | ||
55 | .traits = &peer_store_traits | ||
56 | }; | ||
57 | |||
58 | return cmd; | ||
59 | |||
60 | } | ||
diff --git a/src/testbed/testbed_api_cmd_send_peer_ready.c b/src/testbed/testbed_api_cmd_send_peer_ready.c index f175a3e18..987f0853e 100644 --- a/src/testbed/testbed_api_cmd_send_peer_ready.c +++ b/src/testbed/testbed_api_cmd_send_peer_ready.c | |||
@@ -31,7 +31,7 @@ | |||
31 | 31 | ||
32 | struct SendPeerReadyState | 32 | struct SendPeerReadyState |
33 | { | 33 | { |
34 | TESTBED_CMD_HELPER_write_cb write_message; | 34 | TESTING_CMD_HELPER_write_cb write_message; |
35 | 35 | ||
36 | struct GNUNET_CMDS_PEER_STARTED *reply; | 36 | struct GNUNET_CMDS_PEER_STARTED *reply; |
37 | }; | 37 | }; |
@@ -84,7 +84,7 @@ send_peer_ready_run (void *cls, | |||
84 | */ | 84 | */ |
85 | struct GNUNET_TESTING_Command | 85 | struct GNUNET_TESTING_Command |
86 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, | 86 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, |
87 | TESTBED_CMD_HELPER_write_cb write_message) | 87 | TESTING_CMD_HELPER_write_cb write_message) |
88 | { | 88 | { |
89 | struct SendPeerReadyState *sprs; | 89 | struct SendPeerReadyState *sprs; |
90 | 90 | ||
diff --git a/src/testbed/testbed_api_cmd_tng_connect.c b/src/testbed/testbed_api_cmd_tng_connect.c deleted file mode 100644 index e52cd3c76..000000000 --- a/src/testbed/testbed_api_cmd_tng_connect.c +++ /dev/null | |||
@@ -1,55 +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 | /** | ||
23 | * @file testbed/testbed_api_cmd_peer.c | ||
24 | * @brief Command to create a peer. | ||
25 | * @author t3sserakt | ||
26 | */ | ||
27 | |||
28 | |||
29 | static void | ||
30 | tng_connect_run (void *cls, | ||
31 | const struct GNUNET_TESTING_Command *cmd, | ||
32 | struct GNUNET_TESTING_Interpreter *is) | ||
33 | { | ||
34 | struct TngConnectState *tcs = cls; | ||
35 | |||
36 | tcs->ah = GNUNET_TRANSPORT_application_init (tcs->cfg); | ||
37 | } | ||
38 | |||
39 | struct GNUNET_TESTING_Command | ||
40 | GNUNET_TESTBED_cmd_tng_connect (const char *label) | ||
41 | { | ||
42 | struct TngConnectState *tcs; | ||
43 | |||
44 | ts = GNUNET_new (struct TngConnectState); | ||
45 | |||
46 | struct GNUNET_TESTING_Command cmd = { | ||
47 | .cls = tcs, | ||
48 | .label = label, | ||
49 | .run = &tng_connect_run, | ||
50 | .cleanup = &tmg_connect_cleanup, | ||
51 | .traits = &tng_connect_traits | ||
52 | }; | ||
53 | |||
54 | return cmd; | ||
55 | } | ||
diff --git a/src/testbed/testbed_api_cmd_tng_service.c b/src/testbed/testbed_api_cmd_tng_service.c deleted file mode 100644 index cce2e14e3..000000000 --- a/src/testbed/testbed_api_cmd_tng_service.c +++ /dev/null | |||
@@ -1,276 +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/testbed_api_cmd_tng.c | ||
23 | * @brief Command to start the transport service of a peer. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testing_ng_lib.h" | ||
29 | #include "gnunet-service-testbed.h" | ||
30 | #include "testbed_api_hosts.h" | ||
31 | #include "gnunet_testbed_ng_service.h" | ||
32 | |||
33 | /** | ||
34 | * Generic logging shortcut | ||
35 | */ | ||
36 | #define LOG(kind, ...) \ | ||
37 | GNUNET_log (kind, __VA_ARGS__) | ||
38 | |||
39 | |||
40 | /** | ||
41 | * abort task to run on test timed out | ||
42 | * | ||
43 | * @param cls NULL | ||
44 | * @param tc the task context | ||
45 | */ | ||
46 | static void | ||
47 | do_abort (void *cls) | ||
48 | { | ||
49 | struct TngState *ts = cls; | ||
50 | |||
51 | if (GNUNET_NO == ts->service_ready) | ||
52 | { | ||
53 | LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n"); | ||
54 | ts->abort_task = NULL; | ||
55 | GNUNET_TESTBED_shutdown_service (ts); | ||
56 | } | ||
57 | } | ||
58 | |||
59 | /** | ||
60 | * | ||
61 | * | ||
62 | * @param cls closure | ||
63 | * @param cmd current CMD being cleaned up. | ||
64 | */ | ||
65 | static void | ||
66 | tng_service_cleanup (void *cls, | ||
67 | const struct GNUNET_TESTING_Command *cmd) | ||
68 | { | ||
69 | (void) cls; | ||
70 | } | ||
71 | |||
72 | /** | ||
73 | * | ||
74 | * | ||
75 | * @param cls closure. | ||
76 | * @param[out] ret result | ||
77 | * @param trait name of the trait. | ||
78 | * @param index index number of the object to offer. | ||
79 | * @return #GNUNET_OK on success. | ||
80 | */ | ||
81 | static int | ||
82 | tng_service_traits (void *cls, | ||
83 | const void **ret, | ||
84 | const char *trait, | ||
85 | unsigned int index) | ||
86 | { | ||
87 | (void) cls; | ||
88 | return GNUNET_OK; | ||
89 | } | ||
90 | |||
91 | |||
92 | static void * | ||
93 | notify_connect (void *cls, | ||
94 | const struct GNUNET_PeerIdentity *peer, | ||
95 | struct GNUNET_MQ_Handle *mq) | ||
96 | { | ||
97 | struct TngState *ts = cls; | ||
98 | |||
99 | if (NULL != emsg) | ||
100 | { | ||
101 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
102 | "There was an error starting the transport subsystem: %s\n", | ||
103 | emsg); | ||
104 | } | ||
105 | GNUNET_TESTING_interpreter_next (ps->is); | ||
106 | return ts->nc (ts->cb_cls); | ||
107 | |||
108 | } | ||
109 | |||
110 | |||
111 | static void | ||
112 | notify_disconnect (void *cls, | ||
113 | const struct GNUNET_PeerIdentity *peer, | ||
114 | void *handler_cls) | ||
115 | { | ||
116 | } | ||
117 | |||
118 | |||
119 | |||
120 | |||
121 | /** | ||
122 | * Adapter function called to establish a connection to | ||
123 | * a service. | ||
124 | * | ||
125 | * @param cls closure | ||
126 | * @param cfg configuration of the peer to connect to; will be available until | ||
127 | * GNUNET_TESTBED_operation_done() is called on the operation returned | ||
128 | * from GNUNET_TESTBED_service_connect() | ||
129 | * @return service handle to return in 'op_result', NULL on error | ||
130 | */ | ||
131 | static void * | ||
132 | connect_adapter (void *cls, | ||
133 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
134 | { | ||
135 | struct TngState *ts = cls; | ||
136 | |||
137 | service_handle = GNUNET_TRANSPORT_core_connect (cfg, | ||
138 | ts->peer_identity, | ||
139 | ts->handlers, | ||
140 | ts, | ||
141 | ¬ify_connect, | ||
142 | ¬ify_disconnect); | ||
143 | return service_handle; | ||
144 | } | ||
145 | |||
146 | |||
147 | /** | ||
148 | * Adapter function called to destroy a connection to | ||
149 | * a service. | ||
150 | * | ||
151 | * @param cls closure | ||
152 | * @param op_result service handle returned from the connect adapter | ||
153 | */ | ||
154 | static void | ||
155 | disconnect_adapter (void *cls, | ||
156 | void *op_result) | ||
157 | { | ||
158 | } | ||
159 | |||
160 | /** | ||
161 | * Callback to be called when a service connect operation is completed | ||
162 | * | ||
163 | * @param cls the callback closure from functions generating an operation | ||
164 | * @param op the operation that has been finished | ||
165 | * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter() | ||
166 | * @param emsg error message in case the operation has failed; will be NULL if | ||
167 | * operation has executed successfully. | ||
168 | */ | ||
169 | static void | ||
170 | service_connect_comp_cb (void *cls, | ||
171 | struct GNUNET_TESTBED_Operation *op, | ||
172 | void *ca_result, | ||
173 | const char *emsg) | ||
174 | { | ||
175 | struct TngState *ts = cls; | ||
176 | |||
177 | if (NULL != emsg) | ||
178 | { | ||
179 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
180 | "An error occurred connecting to service %s\n", | ||
181 | emsg); | ||
182 | GNUNET_TESTBED_operation_done (ts->operation); | ||
183 | } | ||
184 | } | ||
185 | |||
186 | |||
187 | /** | ||
188 | * Callback to be called when the requested peer information is available | ||
189 | * | ||
190 | * @param cls the closure from GNUNET_TESTBED_peer_getinformation() | ||
191 | * @param op the operation this callback corresponds to | ||
192 | * @param pinfo the result; will be NULL if the operation has failed | ||
193 | * @param emsg error message if the operation has failed; | ||
194 | * NULL if the operation is successful | ||
195 | */ | ||
196 | static void | ||
197 | pi_cb (void *cls, | ||
198 | struct GNUNET_TESTBED_Operation *op, | ||
199 | const struct GNUNET_TESTBED_PeerInformation *pinfo, | ||
200 | const char *emsg) | ||
201 | { | ||
202 | struct TngState *ts = cls; | ||
203 | |||
204 | ts->peer_identity = pinfo->id; | ||
205 | ts->operation = | ||
206 | GNUNET_TESTBED_service_connect (NULL, peer, NULL, | ||
207 | &service_connect_comp_cb, ts, | ||
208 | &connect_adapter, | ||
209 | &disconnect_adapter, | ||
210 | ts); | ||
211 | } | ||
212 | |||
213 | |||
214 | static void | ||
215 | tng_service_run (void *cls, | ||
216 | const struct GNUNET_TESTING_Command *cmd, | ||
217 | struct GNUNET_TESTING_Interpreter *is) | ||
218 | { | ||
219 | struct TngState *ts = cls; | ||
220 | struct GNUNET_TESTBED_Peer *peer; | ||
221 | const struct GNUNET_TESTING_Command *peer_cmd; | ||
222 | |||
223 | ts->is = is; | ||
224 | peer_cmd = GNUNET_TESTING_interpreter_lookup_command ( | ||
225 | ts->peer_label); | ||
226 | GNUNET_TESTBED_get_trait_peer (peer_cmd, | ||
227 | &peer); | ||
228 | |||
229 | ts->operation = GNUNET_TESTBED_peer_get_information (peer, | ||
230 | GNUNET_TESTBED_PIT_IDENTITY, | ||
231 | &pi_cb, | ||
232 | ts); | ||
233 | } | ||
234 | |||
235 | /** | ||
236 | * Shutdown nicely | ||
237 | * | ||
238 | * @param cs service state. | ||
239 | */ | ||
240 | void | ||
241 | GNUNET_TESTBED_shutdown_service (struct TngState *cs) | ||
242 | { | ||
243 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
244 | "Shutting down...\n"); | ||
245 | } | ||
246 | |||
247 | |||
248 | struct GNUNET_TESTING_Command | ||
249 | GNUNET_TESTBED_cmd_tng_service (const char *label, | ||
250 | const char *peer_label, | ||
251 | const struct GNUNET_MQ_MessageHandler *handlers, | ||
252 | GNUNET_TRANSPORT_NotifyConnect nc, | ||
253 | void *cb_cls) | ||
254 | |||
255 | { | ||
256 | struct TngState *ts; | ||
257 | |||
258 | ts = GNUNET_new (struct TngState); | ||
259 | ts->servicename = servicename; | ||
260 | ts->peer_label = peer_label; | ||
261 | ts->handlers = handlers; | ||
262 | ts->nc = nc; | ||
263 | ts->nd = nd; | ||
264 | ts->cb_cls; | ||
265 | |||
266 | |||
267 | struct GNUNET_TESTING_Command cmd = { | ||
268 | .cls = ts, | ||
269 | .label = label, | ||
270 | .run = &tng_service_run, | ||
271 | .cleanup = &tmg_service_cleanup, | ||
272 | .traits = &tng_service_traits | ||
273 | }; | ||
274 | |||
275 | return cmd; | ||
276 | } | ||