diff options
author | t3sserakt <t3ss@posteo.de> | 2022-10-10 14:59:55 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2022-10-10 14:59:55 +0200 |
commit | 9b39fb6ea253b89ec6588e0814fc473c12e7317b (patch) | |
tree | cfedf7141d7d0a804efc4b6b16a9001542fb01d4 /src/transport | |
parent | 8e4312d5e44a83e2baeb3fc15465b5e70919e6cf (diff) | |
download | gnunet-9b39fb6ea253b89ec6588e0814fc473c12e7317b.tar.gz gnunet-9b39fb6ea253b89ec6588e0814fc473c12e7317b.zip |
- some bug fixes and enhancements to test NG tear done
Diffstat (limited to 'src/transport')
4 files changed, 26 insertions, 146 deletions
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c index a59452449..ee6b9669b 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send.c +++ b/src/transport/test_transport_plugin_cmd_simple_send.c | |||
@@ -40,32 +40,6 @@ | |||
40 | 40 | ||
41 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" | 41 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" |
42 | 42 | ||
43 | struct TestState | ||
44 | { | ||
45 | /** | ||
46 | * Callback to write messages to the master loop. | ||
47 | * | ||
48 | */ | ||
49 | TESTING_CMD_HELPER_write_cb write_message; | ||
50 | |||
51 | /** | ||
52 | * The name for a specific test environment directory. | ||
53 | * | ||
54 | */ | ||
55 | char *testdir; | ||
56 | |||
57 | /** | ||
58 | * The name for the configuration file of the specific node. | ||
59 | * | ||
60 | */ | ||
61 | char *cfgname; | ||
62 | |||
63 | /** | ||
64 | * The complete topology information. | ||
65 | */ | ||
66 | struct GNUNET_TESTING_NetjailTopology *topology; | ||
67 | }; | ||
68 | |||
69 | static struct GNUNET_TESTING_Command block_send; | 43 | static struct GNUNET_TESTING_Command block_send; |
70 | 44 | ||
71 | static struct GNUNET_TESTING_Command block_receive; | 45 | static struct GNUNET_TESTING_Command block_receive; |
@@ -144,14 +118,10 @@ handle_result (void *cls, | |||
144 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 118 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
145 | "Local test exits with status %d\n", | 119 | "Local test exits with status %d\n", |
146 | rv); | 120 | rv); |
147 | reply = GNUNET_TESTING_send_local_test_finished_msg (rv); | ||
148 | 121 | ||
149 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 122 | reply = GNUNET_TESTING_send_local_test_finished_msg (); |
150 | "message prepared\n"); | 123 | |
151 | ts->write_message (reply, | 124 | ts->finished_cb (); |
152 | ntohs (reply->size)); | ||
153 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
154 | "message send\n"); | ||
155 | GNUNET_free (ts->testdir); | 125 | GNUNET_free (ts->testdir); |
156 | GNUNET_free (ts->cfgname); | 126 | GNUNET_free (ts->cfgname); |
157 | GNUNET_TESTING_free_topology (ts->topology); | 127 | GNUNET_TESTING_free_topology (ts->topology); |
@@ -218,7 +188,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
218 | char *n, | 188 | char *n, |
219 | char *local_m, | 189 | char *local_m, |
220 | char *topology_data, | 190 | char *topology_data, |
221 | unsigned int *read_file) | 191 | unsigned int *read_file, |
192 | TESTING_CMD_HELPER_finish_cb finished_cb) | ||
222 | { | 193 | { |
223 | 194 | ||
224 | unsigned int n_int; | 195 | unsigned int n_int; |
@@ -229,6 +200,12 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
229 | struct GNUNET_TESTING_NetjailTopology *topology; | 200 | struct GNUNET_TESTING_NetjailTopology *topology; |
230 | unsigned int sscanf_ret = 0; | 201 | unsigned int sscanf_ret = 0; |
231 | 202 | ||
203 | ts->finished_cb = finished_cb; | ||
204 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
205 | "n %s m %s\n", | ||
206 | n, | ||
207 | m); | ||
208 | |||
232 | if (GNUNET_YES == *read_file) | 209 | if (GNUNET_YES == *read_file) |
233 | { | 210 | { |
234 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 211 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -241,21 +218,21 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
241 | ts->topology = topology; | 218 | ts->topology = topology; |
242 | 219 | ||
243 | errno = 0; | 220 | errno = 0; |
244 | sscanf (m, "%u", &m_int); | 221 | sscanf_ret = sscanf (m, "%u", &m_int); |
245 | if (errno != 0) | 222 | if (errno != 0) |
246 | { | 223 | { |
247 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); | 224 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); |
248 | } | 225 | } |
249 | GNUNET_assert (0 < sscanf_ret); | 226 | GNUNET_assert (0 < sscanf_ret); |
250 | errno = 0; | 227 | errno = 0; |
251 | sscanf (n, "%u", &n_int); | 228 | sscanf_ret = sscanf (n, "%u", &n_int); |
252 | if (errno != 0) | 229 | if (errno != 0) |
253 | { | 230 | { |
254 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); | 231 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); |
255 | } | 232 | } |
256 | GNUNET_assert (0 < sscanf_ret); | 233 | GNUNET_assert (0 < sscanf_ret); |
257 | errno = 0; | 234 | errno = 0; |
258 | sscanf (local_m, "%u", &local_m_int); | 235 | sscanf_ret = sscanf (local_m, "%u", &local_m_int); |
259 | if (errno != 0) | 236 | if (errno != 0) |
260 | { | 237 | { |
261 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); | 238 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf"); |
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c index 9d6844be1..6254dba36 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c +++ b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c | |||
@@ -40,32 +40,6 @@ | |||
40 | 40 | ||
41 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" | 41 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" |
42 | 42 | ||
43 | struct TestState | ||
44 | { | ||
45 | /** | ||
46 | * Callback to write messages to the master loop. | ||
47 | * | ||
48 | */ | ||
49 | TESTING_CMD_HELPER_write_cb write_message; | ||
50 | |||
51 | /** | ||
52 | * The name for a specific test environment directory. | ||
53 | * | ||
54 | */ | ||
55 | char *testdir; | ||
56 | |||
57 | /** | ||
58 | * The name for the configuration file of the specific node. | ||
59 | * | ||
60 | */ | ||
61 | char *cfgname; | ||
62 | |||
63 | /** | ||
64 | * The complete topology information. | ||
65 | */ | ||
66 | struct GNUNET_TESTING_NetjailTopology *topology; | ||
67 | }; | ||
68 | |||
69 | static struct GNUNET_TESTING_Command block_send; | 43 | static struct GNUNET_TESTING_Command block_send; |
70 | 44 | ||
71 | static struct GNUNET_TESTING_Command block_receive; | 45 | static struct GNUNET_TESTING_Command block_receive; |
@@ -140,19 +114,11 @@ handle_result (void *cls, | |||
140 | enum GNUNET_GenericReturnValue rv) | 114 | enum GNUNET_GenericReturnValue rv) |
141 | { | 115 | { |
142 | struct TestState *ts = cls; | 116 | struct TestState *ts = cls; |
143 | struct GNUNET_MessageHeader *reply; | ||
144 | 117 | ||
145 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 118 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
146 | "Local test exits with status %d\n", | 119 | "Local test exits with status %d\n", |
147 | rv); | 120 | rv); |
148 | reply = GNUNET_TESTING_send_local_test_finished_msg (rv); | 121 | ts->finished_cb (); |
149 | |||
150 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
151 | "message prepared\n"); | ||
152 | ts->write_message (reply, | ||
153 | ntohs (reply->size)); | ||
154 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
155 | "message send\n"); | ||
156 | GNUNET_free (ts->testdir); | 122 | GNUNET_free (ts->testdir); |
157 | GNUNET_free (ts->cfgname); | 123 | GNUNET_free (ts->cfgname); |
158 | GNUNET_TESTING_free_topology (ts->topology); | 124 | GNUNET_TESTING_free_topology (ts->topology); |
@@ -251,7 +217,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
251 | char *n, | 217 | char *n, |
252 | char *local_m, | 218 | char *local_m, |
253 | char *topology_data, | 219 | char *topology_data, |
254 | unsigned int *read_file) | 220 | unsigned int *read_file, |
221 | TESTING_CMD_HELPER_finish_cb finished_cb) | ||
255 | { | 222 | { |
256 | unsigned int n_int; | 223 | unsigned int n_int; |
257 | unsigned int m_int; | 224 | unsigned int m_int; |
@@ -261,7 +228,7 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
261 | struct GNUNET_TESTING_NetjailTopology *topology; | 228 | struct GNUNET_TESTING_NetjailTopology *topology; |
262 | 229 | ||
263 | 230 | ||
264 | 231 | ts->finished_cb = finished_cb; | |
265 | if (GNUNET_YES == *read_file) | 232 | if (GNUNET_YES == *read_file) |
266 | { | 233 | { |
267 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 234 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_dv.c b/src/transport/test_transport_plugin_cmd_simple_send_dv.c index 3ef2f64cd..ea0c9aea8 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send_dv.c +++ b/src/transport/test_transport_plugin_cmd_simple_send_dv.c | |||
@@ -40,33 +40,6 @@ | |||
40 | 40 | ||
41 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" | 41 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" |
42 | 42 | ||
43 | struct TestState | ||
44 | { | ||
45 | /** | ||
46 | * Callback to write messages to the master loop. | ||
47 | * | ||
48 | */ | ||
49 | TESTING_CMD_HELPER_write_cb write_message; | ||
50 | |||
51 | /** | ||
52 | * The name for a specific test environment directory. | ||
53 | * | ||
54 | */ | ||
55 | char *testdir; | ||
56 | |||
57 | /** | ||
58 | * The name for the configuration file of the specific node. | ||
59 | * | ||
60 | */ | ||
61 | char *cfgname; | ||
62 | |||
63 | /** | ||
64 | * The complete topology information. | ||
65 | */ | ||
66 | struct GNUNET_TESTING_NetjailTopology *topology; | ||
67 | |||
68 | }; | ||
69 | |||
70 | /** | 43 | /** |
71 | * The number of messages received. | 44 | * The number of messages received. |
72 | */ | 45 | */ |
@@ -193,19 +166,11 @@ handle_result (void *cls, | |||
193 | enum GNUNET_GenericReturnValue rv) | 166 | enum GNUNET_GenericReturnValue rv) |
194 | { | 167 | { |
195 | struct TestState *ts = cls; | 168 | struct TestState *ts = cls; |
196 | struct GNUNET_MessageHeader *reply; | ||
197 | 169 | ||
198 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 170 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
199 | "Local test exits with status %d\n", | 171 | "Local test exits with status %d\n", |
200 | rv); | 172 | rv); |
201 | reply = GNUNET_TESTING_send_local_test_finished_msg (rv); | 173 | ts->finished_cb (); |
202 | |||
203 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
204 | "message prepared\n"); | ||
205 | ts->write_message (reply, | ||
206 | ntohs (reply->size)); | ||
207 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
208 | "message send\n"); | ||
209 | GNUNET_free (ts->testdir); | 174 | GNUNET_free (ts->testdir); |
210 | GNUNET_free (ts->cfgname); | 175 | GNUNET_free (ts->cfgname); |
211 | GNUNET_TESTING_free_topology (ts->topology); | 176 | GNUNET_TESTING_free_topology (ts->topology); |
@@ -275,7 +240,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
275 | char *n, | 240 | char *n, |
276 | char *local_m, | 241 | char *local_m, |
277 | char *topology_data, | 242 | char *topology_data, |
278 | unsigned int *read_file) | 243 | unsigned int *read_file, |
244 | TESTING_CMD_HELPER_finish_cb finished_cb) | ||
279 | { | 245 | { |
280 | unsigned int n_int; | 246 | unsigned int n_int; |
281 | unsigned int m_int; | 247 | unsigned int m_int; |
@@ -291,6 +257,7 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
291 | GNUNET_MQ_handler_end () | 257 | GNUNET_MQ_handler_end () |
292 | }; | 258 | }; |
293 | 259 | ||
260 | ts->finished_cb = finished_cb; | ||
294 | if (GNUNET_YES == *read_file) | 261 | if (GNUNET_YES == *read_file) |
295 | { | 262 | { |
296 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 263 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c index 537832e61..87065e340 100644 --- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c +++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c | |||
@@ -40,32 +40,6 @@ | |||
40 | 40 | ||
41 | #define TOPOLOGY_CONFIG "test_transport_udp_backchannel_topo.conf" | 41 | #define TOPOLOGY_CONFIG "test_transport_udp_backchannel_topo.conf" |
42 | 42 | ||
43 | struct TestState | ||
44 | { | ||
45 | /** | ||
46 | * Callback to write messages to the master loop. | ||
47 | * | ||
48 | */ | ||
49 | TESTING_CMD_HELPER_write_cb write_message; | ||
50 | |||
51 | /** | ||
52 | * The name for a specific test environment directory. | ||
53 | * | ||
54 | */ | ||
55 | char *testdir; | ||
56 | |||
57 | /** | ||
58 | * The name for the configuration file of the specific node. | ||
59 | * | ||
60 | */ | ||
61 | char *cfgname; | ||
62 | |||
63 | /** | ||
64 | * The complete topology information. | ||
65 | */ | ||
66 | struct GNUNET_TESTING_NetjailTopology *topology; | ||
67 | }; | ||
68 | |||
69 | static struct GNUNET_TESTING_Command block_send; | 43 | static struct GNUNET_TESTING_Command block_send; |
70 | 44 | ||
71 | static struct GNUNET_TESTING_Command connect_peers; | 45 | static struct GNUNET_TESTING_Command connect_peers; |
@@ -136,18 +110,12 @@ handle_result (void *cls, | |||
136 | enum GNUNET_GenericReturnValue rv) | 110 | enum GNUNET_GenericReturnValue rv) |
137 | { | 111 | { |
138 | struct TestState *ts = cls; | 112 | struct TestState *ts = cls; |
139 | struct GNUNET_MessageHeader *reply; | ||
140 | 113 | ||
141 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 114 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
142 | "Local test exits with status %d\n", | 115 | "Local test exits with status %d\n", |
143 | rv); | 116 | rv); |
144 | reply = GNUNET_TESTING_send_local_test_finished_msg (rv); | ||
145 | |||
146 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
147 | "message prepared\n"); | ||
148 | ts->write_message (reply, | ||
149 | ntohs (reply->size)); | ||
150 | 117 | ||
118 | ts->finished_cb (); | ||
151 | GNUNET_free (ts->testdir); | 119 | GNUNET_free (ts->testdir); |
152 | GNUNET_free (ts->cfgname); | 120 | GNUNET_free (ts->cfgname); |
153 | GNUNET_TESTING_free_topology (ts->topology); | 121 | GNUNET_TESTING_free_topology (ts->topology); |
@@ -209,7 +177,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
209 | char *n, | 177 | char *n, |
210 | char *local_m, | 178 | char *local_m, |
211 | char *topology_data, | 179 | char *topology_data, |
212 | unsigned int *read_file) | 180 | unsigned int *read_file, |
181 | TESTING_CMD_HELPER_finish_cb finished_cb) | ||
213 | { | 182 | { |
214 | 183 | ||
215 | unsigned int n_int; | 184 | unsigned int n_int; |
@@ -217,9 +186,9 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
217 | unsigned int local_m_int; | 186 | unsigned int local_m_int; |
218 | unsigned int num; | 187 | unsigned int num; |
219 | struct TestState *ts = GNUNET_new (struct TestState); | 188 | struct TestState *ts = GNUNET_new (struct TestState); |
220 | |||
221 | struct GNUNET_TESTING_NetjailTopology *topology; | 189 | struct GNUNET_TESTING_NetjailTopology *topology; |
222 | 190 | ||
191 | ts->finished_cb = finished_cb; | ||
223 | if (GNUNET_YES == *read_file) | 192 | if (GNUNET_YES == *read_file) |
224 | topology = GNUNET_TESTING_get_topo_from_file (topology_data); | 193 | topology = GNUNET_TESTING_get_topo_from_file (topology_data); |
225 | else | 194 | else |