diff options
23 files changed, 455 insertions, 552 deletions
diff --git a/contrib/netjail/netjail_exec.sh b/contrib/netjail/netjail_exec.sh index ab4aad5b8..fa68d90d4 100755 --- a/contrib/netjail/netjail_exec.sh +++ b/contrib/netjail/netjail_exec.sh | |||
@@ -11,4 +11,5 @@ N=$2 | |||
11 | 11 | ||
12 | NODE=$6 | 12 | NODE=$6 |
13 | 13 | ||
14 | #netjail_node_exec_without_fds_and_sudo $NODE valgrind --leak-check=full --track-origins=yes --trace-children=yes $3 $4 $5 $1 $2 $7 $8 | ||
14 | netjail_node_exec_without_fds_and_sudo $NODE $3 $4 $5 $1 $2 $7 $8 | 15 | netjail_node_exec_without_fds_and_sudo $NODE $3 $4 $5 $1 $2 $7 $8 |
diff --git a/src/include/gnunet_testing_netjail_lib.h b/src/include/gnunet_testing_netjail_lib.h index 3a5e9f749..334f43c88 100644 --- a/src/include/gnunet_testing_netjail_lib.h +++ b/src/include/gnunet_testing_netjail_lib.h | |||
@@ -24,8 +24,8 @@ | |||
24 | * @author Marcello Stanisci | 24 | * @author Marcello Stanisci |
25 | * @author t3sserakt | 25 | * @author t3sserakt |
26 | */ | 26 | */ |
27 | #ifndef GNUNET_TESTING_NG_LIB_H | 27 | #ifndef GNUNET_TESTING_NETJAIL_LIB_H |
28 | #define GNUNET_TESTING_NG_LIB_H | 28 | #define GNUNET_TESTING_NETJAIL_LIB_H |
29 | 29 | ||
30 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
31 | #include "gnunet_testing_plugin.h" | 31 | #include "gnunet_testing_plugin.h" |
@@ -301,6 +301,28 @@ GNUNET_TESTING_calculate_num (struct | |||
301 | 301 | ||
302 | 302 | ||
303 | /** | 303 | /** |
304 | * Struct with information for callbacks. | ||
305 | * | ||
306 | */ | ||
307 | struct BlockState | ||
308 | { | ||
309 | /** | ||
310 | * Context for our asynchronous completion. | ||
311 | */ | ||
312 | struct GNUNET_TESTING_AsyncContext ac; | ||
313 | |||
314 | /** | ||
315 | * The label of this command. | ||
316 | */ | ||
317 | const char *label; | ||
318 | |||
319 | /** | ||
320 | * If this command will block. | ||
321 | */ | ||
322 | unsigned int asynchronous_finish; | ||
323 | }; | ||
324 | |||
325 | /** | ||
304 | * Struct to hold information for callbacks. | 326 | * Struct to hold information for callbacks. |
305 | * | 327 | * |
306 | */ | 328 | */ |
@@ -309,7 +331,7 @@ struct LocalPreparedState | |||
309 | /** | 331 | /** |
310 | * Context for our asynchronous completion. | 332 | * Context for our asynchronous completion. |
311 | */ | 333 | */ |
312 | struct GNUNET_TESTING_AsyncContext *ac; | 334 | struct GNUNET_TESTING_AsyncContext ac; |
313 | 335 | ||
314 | /** | 336 | /** |
315 | * Callback to write messages to the master loop. | 337 | * Callback to write messages to the master loop. |
@@ -319,11 +341,28 @@ struct LocalPreparedState | |||
319 | }; | 341 | }; |
320 | 342 | ||
321 | 343 | ||
344 | struct GNUNET_TESTING_Command | ||
345 | GNUNET_TESTING_cmd_system_destroy (const char *label, | ||
346 | const char *create_label); | ||
347 | |||
348 | |||
349 | struct GNUNET_TESTING_Command | ||
350 | GNUNET_TESTING_cmd_system_create (const char *label, | ||
351 | const char *testdir); | ||
352 | |||
353 | |||
354 | int | ||
355 | GNUNET_TESTING_get_trait_test_system (const struct | ||
356 | GNUNET_TESTING_Command *cmd, | ||
357 | struct GNUNET_TESTING_System **test_system); | ||
358 | |||
359 | |||
322 | /** | 360 | /** |
323 | * Create command. | 361 | * Create command. |
324 | * | 362 | * |
325 | * @param label name for command. | 363 | * @param label name for command. |
326 | * @param topology_config Configuration file for the test topology. | 364 | * @param topology_config Configuration file for the test topology. |
365 | * @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. | ||
327 | * @return command. | 366 | * @return command. |
328 | */ | 367 | */ |
329 | struct GNUNET_TESTING_Command | 368 | struct GNUNET_TESTING_Command |
@@ -335,27 +374,32 @@ GNUNET_TESTING_cmd_netjail_start (const char *label, | |||
335 | /** | 374 | /** |
336 | * Create command. | 375 | * Create command. |
337 | * | 376 | * |
338 | * @param label Name for the command. | 377 | * @param label name for command. |
339 | * @param topology The complete topology information. | 378 | * @param topology_config Configuration file for the test topology. |
379 | * @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. | ||
340 | * @return command. | 380 | * @return command. |
341 | */ | 381 | */ |
342 | struct GNUNET_TESTING_Command | 382 | struct GNUNET_TESTING_Command |
343 | GNUNET_TESTING_cmd_netjail_start_testing_system ( | 383 | GNUNET_TESTING_cmd_netjail_stop (const char *label, |
344 | const char *label, | 384 | char *topology_config, |
345 | struct GNUNET_TESTING_NetjailTopology *topology); | 385 | unsigned int *read_file); |
346 | 386 | ||
347 | 387 | ||
348 | /** | 388 | /** |
349 | * Create command. | 389 | * Create command. |
350 | * | 390 | * |
351 | * @param label name for command. | 391 | * @param label Name for the command. |
352 | * @param topology_config Configuration file for the test topology. | 392 | * @param topology The complete topology information. |
393 | * @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. | ||
394 | * @param topology_data If read_file is GNUNET_NO, topology_data holds the string with the topology. | ||
353 | * @return command. | 395 | * @return command. |
354 | */ | 396 | */ |
355 | struct GNUNET_TESTING_Command | 397 | struct GNUNET_TESTING_Command |
356 | GNUNET_TESTING_cmd_netjail_stop (const char *label, | 398 | GNUNET_TESTING_cmd_netjail_start_testing_system ( |
357 | char *topology_config, | 399 | const char *label, |
358 | unsigned int *read_file); | 400 | struct GNUNET_TESTING_NetjailTopology *topology, |
401 | unsigned int *read_file, | ||
402 | char *topology_data); | ||
359 | 403 | ||
360 | 404 | ||
361 | /** | 405 | /** |
@@ -414,10 +458,19 @@ GNUNET_TESTING_cmd_block_until_all_peers_started ( | |||
414 | unsigned int *all_peers_started); | 458 | unsigned int *all_peers_started); |
415 | 459 | ||
416 | 460 | ||
461 | /** | ||
462 | * Create command. | ||
463 | * | ||
464 | * @param label name for command. | ||
465 | * @param all_peers_started Flag which will be set from outside. | ||
466 | * @param asynchronous_finish If GNUNET_YES this command will not block. | ||
467 | * @return command. | ||
468 | */ | ||
417 | struct GNUNET_TESTING_Command | 469 | struct GNUNET_TESTING_Command |
418 | GNUNET_TESTING_cmd_block_until_external_trigger ( | 470 | GNUNET_TESTING_cmd_block_until_external_trigger ( |
419 | const char *label); | 471 | const char *label); |
420 | 472 | ||
473 | |||
421 | struct GNUNET_TESTING_Command | 474 | struct GNUNET_TESTING_Command |
422 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, | 475 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, |
423 | TESTING_CMD_HELPER_write_cb write_message); | 476 | TESTING_CMD_HELPER_write_cb write_message); |
@@ -460,4 +513,16 @@ GNUNET_TESTING_get_trait_local_prepared_state ( | |||
460 | const struct GNUNET_TESTING_Command *cmd, | 513 | const struct GNUNET_TESTING_Command *cmd, |
461 | struct LocalPreparedState **lfs); | 514 | struct LocalPreparedState **lfs); |
462 | 515 | ||
516 | |||
517 | /** | ||
518 | * Function to get the trait with the internal command state BlockState. | ||
519 | * | ||
520 | * * @param[out] ac struct BlockState. | ||
521 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
522 | */ | ||
523 | int | ||
524 | GNUNET_TESTING_get_trait_block_state ( | ||
525 | const struct GNUNET_TESTING_Command *cmd, | ||
526 | struct BlockState **bs); | ||
527 | |||
463 | #endif | 528 | #endif |
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h index 2d040ac21..5011aefd8 100644 --- a/src/include/gnunet_testing_ng_lib.h +++ b/src/include/gnunet_testing_ng_lib.h | |||
@@ -47,212 +47,6 @@ | |||
47 | } while (0) | 47 | } while (0) |
48 | 48 | ||
49 | 49 | ||
50 | /** | ||
51 | * Router of a network namespace. | ||
52 | * // FIXME: this does not belong here! | ||
53 | */ | ||
54 | struct GNUNET_TESTING_NetjailRouter | ||
55 | { | ||
56 | /** | ||
57 | * Will tcp be forwarded? | ||
58 | */ | ||
59 | unsigned int tcp_port; | ||
60 | |||
61 | /** | ||
62 | * Will udp be forwarded? | ||
63 | */ | ||
64 | unsigned int udp_port; | ||
65 | }; | ||
66 | |||
67 | |||
68 | /** | ||
69 | * Enum for the different types of nodes. | ||
70 | * // FIXME: this does not belong here! | ||
71 | */ | ||
72 | enum GNUNET_TESTING_NODE_TYPE | ||
73 | { | ||
74 | /** | ||
75 | * Node in a subnet. | ||
76 | */ | ||
77 | GNUNET_TESTING_SUBNET_NODE, | ||
78 | |||
79 | /** | ||
80 | * Global known node. | ||
81 | */ | ||
82 | GNUNET_TESTING_GLOBAL_NODE | ||
83 | }; | ||
84 | |||
85 | |||
86 | // FIXME: this does not belong here! | ||
87 | struct GNUNET_TESTING_AddressPrefix | ||
88 | { | ||
89 | /** | ||
90 | * Pointer to the previous prefix in the DLL. | ||
91 | */ | ||
92 | struct GNUNET_TESTING_AddressPrefix *prev; | ||
93 | |||
94 | /** | ||
95 | * Pointer to the next prefix in the DLL. | ||
96 | */ | ||
97 | struct GNUNET_TESTING_AddressPrefix *next; | ||
98 | |||
99 | /** | ||
100 | * The address prefix. | ||
101 | */ | ||
102 | char *address_prefix; | ||
103 | }; | ||
104 | |||
105 | |||
106 | // FIXME: this does not belong here! | ||
107 | struct GNUNET_TESTING_NetjailNode; | ||
108 | |||
109 | /** | ||
110 | * Connection to another node. | ||
111 | * // FIXME: this does not belong here! | ||
112 | */ | ||
113 | struct GNUNET_TESTING_NodeConnection | ||
114 | { | ||
115 | /** | ||
116 | * Pointer to the previous connection in the DLL. | ||
117 | */ | ||
118 | struct GNUNET_TESTING_NodeConnection *prev; | ||
119 | |||
120 | /** | ||
121 | * Pointer to the next connection in the DLL. | ||
122 | */ | ||
123 | struct GNUNET_TESTING_NodeConnection *next; | ||
124 | |||
125 | /** | ||
126 | * The number of the subnet of the node this connection points to. This is 0, | ||
127 | * if the node is a global known node. | ||
128 | */ | ||
129 | unsigned int namespace_n; | ||
130 | |||
131 | /** | ||
132 | * The number of the node this connection points to. | ||
133 | */ | ||
134 | unsigned int node_n; | ||
135 | |||
136 | /** | ||
137 | * The type of the node this connection points to. | ||
138 | */ | ||
139 | enum GNUNET_TESTING_NODE_TYPE node_type; | ||
140 | |||
141 | /** | ||
142 | * The node which establish the connection | ||
143 | */ | ||
144 | struct GNUNET_TESTING_NetjailNode *node; | ||
145 | |||
146 | /** | ||
147 | * Head of the DLL with the address prefixes for the protocolls this node is reachable. | ||
148 | */ | ||
149 | struct GNUNET_TESTING_AddressPrefix *address_prefixes_head; | ||
150 | |||
151 | /** | ||
152 | * Tail of the DLL with the address prefixes for the protocolls this node is reachable. | ||
153 | */ | ||
154 | struct GNUNET_TESTING_AddressPrefix *address_prefixes_tail; | ||
155 | }; | ||
156 | |||
157 | /** | ||
158 | * Node in the netjail topology. | ||
159 | * // FIXME: this does not belong here! | ||
160 | */ | ||
161 | struct GNUNET_TESTING_NetjailNode | ||
162 | { | ||
163 | /** | ||
164 | * Plugin for the test case to be run on this node. | ||
165 | */ | ||
166 | char *plugin; | ||
167 | |||
168 | /** | ||
169 | * Flag indicating if this node is a global known node. | ||
170 | */ | ||
171 | unsigned int is_global; | ||
172 | |||
173 | /** | ||
174 | * The number of the namespace this node is running in. | ||
175 | */ | ||
176 | unsigned int namespace_n; | ||
177 | |||
178 | /** | ||
179 | * The number of this node in the namespace. | ||
180 | */ | ||
181 | unsigned int node_n; | ||
182 | |||
183 | /** | ||
184 | * Head of the DLL with the connections which shall be established to other nodes. | ||
185 | */ | ||
186 | struct GNUNET_TESTING_NodeConnection *node_connections_head; | ||
187 | |||
188 | /** | ||
189 | * Tail of the DLL with the connections which shall be established to other nodes. | ||
190 | */ | ||
191 | struct GNUNET_TESTING_NodeConnection *node_connections_tail; | ||
192 | }; | ||
193 | |||
194 | |||
195 | /** | ||
196 | * Namespace in a topology. | ||
197 | * // FIXME: this does not belong here! | ||
198 | */ | ||
199 | struct GNUNET_TESTING_NetjailNamespace | ||
200 | { | ||
201 | /** | ||
202 | * The number of the namespace. | ||
203 | */ | ||
204 | unsigned int namespace_n; | ||
205 | |||
206 | /** | ||
207 | * Router of the namespace. | ||
208 | */ | ||
209 | struct GNUNET_TESTING_NetjailRouter *router; | ||
210 | |||
211 | /** | ||
212 | * Hash map containing the nodes in this namespace. | ||
213 | */ | ||
214 | struct GNUNET_CONTAINER_MultiShortmap *nodes; | ||
215 | }; | ||
216 | |||
217 | /** | ||
218 | * Toplogy of our netjail setup. | ||
219 | * // FIXME: this does not belong here! | ||
220 | */ | ||
221 | struct GNUNET_TESTING_NetjailTopology | ||
222 | { | ||
223 | |||
224 | /** | ||
225 | * Default plugin for the test case to be run on nodes. | ||
226 | */ | ||
227 | char *plugin; | ||
228 | |||
229 | /** | ||
230 | * Number of namespaces. | ||
231 | */ | ||
232 | unsigned int namespaces_n; | ||
233 | |||
234 | /** | ||
235 | * Number of nodes per namespace. | ||
236 | */ | ||
237 | unsigned int nodes_m; | ||
238 | |||
239 | /** | ||
240 | * Number of global known nodes per namespace. | ||
241 | */ | ||
242 | unsigned int nodes_x; | ||
243 | |||
244 | /** | ||
245 | * Hash map containing the namespaces (for natted nodes) of the topology. | ||
246 | */ | ||
247 | struct GNUNET_CONTAINER_MultiShortmap *map_namespaces; | ||
248 | |||
249 | /** | ||
250 | * Hash map containing the global known nodes which are not natted. | ||
251 | */ | ||
252 | struct GNUNET_CONTAINER_MultiShortmap *map_globals; | ||
253 | }; | ||
254 | |||
255 | |||
256 | /* ******************* Generic interpreter logic ************ */ | 50 | /* ******************* Generic interpreter logic ************ */ |
257 | 51 | ||
258 | /** | 52 | /** |
@@ -284,7 +78,7 @@ struct GNUNET_TESTING_AsyncContext | |||
284 | 78 | ||
285 | /** | 79 | /** |
286 | * Indication if the command finished (#GNUNET_OK). | 80 | * Indication if the command finished (#GNUNET_OK). |
287 | * #GNUNET_NO if it is still running, | 81 | * #GNUNET_NO if it did not finish, |
288 | * #GNUNET_SYSERR if it failed. | 82 | * #GNUNET_SYSERR if it failed. |
289 | */ | 83 | */ |
290 | enum GNUNET_GenericReturnValue finished; | 84 | enum GNUNET_GenericReturnValue finished; |
@@ -411,6 +205,20 @@ struct GNUNET_TESTING_Command | |||
411 | 205 | ||
412 | /** | 206 | /** |
413 | * Lookup command by label. | 207 | * Lookup command by label. |
208 | * Only future commands are looked up. | ||
209 | * | ||
210 | * @param is interpreter to lookup command in | ||
211 | * @param label label of the command to lookup. | ||
212 | * @return the command, if it is found, or NULL. | ||
213 | */ | ||
214 | const struct GNUNET_TESTING_Command * | ||
215 | GNUNET_TESTING_interpreter_lookup_future_command ( | ||
216 | struct GNUNET_TESTING_Interpreter *is, | ||
217 | const char *label); | ||
218 | |||
219 | |||
220 | /** | ||
221 | * Lookup command by label. | ||
414 | * | 222 | * |
415 | * @param is interpreter to lookup command in | 223 | * @param is interpreter to lookup command in |
416 | * @param label label of the command to lookup. | 224 | * @param label label of the command to lookup. |
@@ -569,6 +377,39 @@ GNUNET_TESTING_has_in_name (const char *prog, | |||
569 | 377 | ||
570 | /* ************** Specific interpreter commands ************ */ | 378 | /* ************** Specific interpreter commands ************ */ |
571 | 379 | ||
380 | |||
381 | /** | ||
382 | * Returns the actual running command. | ||
383 | * | ||
384 | * @param is Global state of the interpreter, used by a command | ||
385 | * to access information about other commands. | ||
386 | * @return The actual running command. | ||
387 | */ | ||
388 | struct GNUNET_TESTING_Command * | ||
389 | GNUNET_TESTING_interpreter_get_current_command ( | ||
390 | struct GNUNET_TESTING_Interpreter *is); | ||
391 | |||
392 | |||
393 | /** | ||
394 | * Check if the command is running. | ||
395 | * | ||
396 | * @param cmd The command to check. | ||
397 | * @return GNUNET_NO if the command is not running, GNUNET_YES if it is running. | ||
398 | */ | ||
399 | enum GNUNET_GenericReturnValue | ||
400 | GNUNET_TESTING_running (const struct GNUNET_TESTING_Command *command); | ||
401 | |||
402 | |||
403 | /** | ||
404 | * Check if a command is finished. | ||
405 | * | ||
406 | * @param cmd The command to check. | ||
407 | * @return GNUNET_NO if the command is not finished, GNUNET_YES if it is finished. | ||
408 | */ | ||
409 | enum GNUNET_GenericReturnValue | ||
410 | GNUNET_TESTING_finished (struct GNUNET_TESTING_Command *command); | ||
411 | |||
412 | |||
572 | /** | 413 | /** |
573 | * Create a "signal" CMD. | 414 | * Create a "signal" CMD. |
574 | * | 415 | * |
@@ -1062,201 +903,4 @@ GNUNET_TESTING_make_trait_relative_time ( | |||
1062 | unsigned int index, | 903 | unsigned int index, |
1063 | const struct GNUNET_TIME_Relative *time); | 904 | const struct GNUNET_TIME_Relative *time); |
1064 | 905 | ||
1065 | |||
1066 | // FIXME: move these commands into a separate libgnunetestingnetjail lib or so! | ||
1067 | |||
1068 | /** | ||
1069 | * Struct to hold information for callbacks. | ||
1070 | * | ||
1071 | */ | ||
1072 | struct LocalPreparedState | ||
1073 | { | ||
1074 | /** | ||
1075 | * Context for our asynchronous completion. | ||
1076 | */ | ||
1077 | struct GNUNET_TESTING_AsyncContext ac; | ||
1078 | |||
1079 | /** | ||
1080 | * Callback to write messages to the master loop. | ||
1081 | * | ||
1082 | */ | ||
1083 | TESTING_CMD_HELPER_write_cb write_message; | ||
1084 | }; | ||
1085 | |||
1086 | |||
1087 | /** | ||
1088 | * Offer data from trait | ||
1089 | * | ||
1090 | * @param cmd command to extract the url from. | ||
1091 | * @param pt which url is to be picked, in case | ||
1092 | * multiple are offered. | ||
1093 | * @param[out] url where to write the url. | ||
1094 | * @return #GNUNET_OK on success. | ||
1095 | */ | ||
1096 | int | ||
1097 | GNUNET_TESTING_get_trait_what_am_i (const struct GNUNET_TESTING_Command *cmd, | ||
1098 | char **what_am_i); | ||
1099 | |||
1100 | |||
1101 | int | ||
1102 | GNUNET_TESTING_get_trait_test_system (const struct | ||
1103 | GNUNET_TESTING_Command *cmd, | ||
1104 | struct GNUNET_TESTING_System **test_system); | ||
1105 | |||
1106 | |||
1107 | struct GNUNET_TESTING_Command | ||
1108 | GNUNET_TESTING_cmd_system_create (const char *label, | ||
1109 | const char *testdir); | ||
1110 | |||
1111 | |||
1112 | struct GNUNET_TESTING_Command | ||
1113 | GNUNET_TESTING_cmd_system_destroy (const char *label, | ||
1114 | const char *create_label); | ||
1115 | |||
1116 | |||
1117 | /** | ||
1118 | * Create command. | ||
1119 | * | ||
1120 | * @param label name for command. | ||
1121 | * @param topology_config Configuration file for the test topology. | ||
1122 | * @return command. | ||
1123 | */ | ||
1124 | struct GNUNET_TESTING_Command | ||
1125 | GNUNET_TESTING_cmd_netjail_start (const char *label, | ||
1126 | char *topology_config, | ||
1127 | unsigned int *read_file); | ||
1128 | |||
1129 | |||
1130 | /** | ||
1131 | * Create command. | ||
1132 | * | ||
1133 | * @param label Name for the command. | ||
1134 | * @param topology The complete topology information. | ||
1135 | * @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. | ||
1136 | * @param topology_data If read_file is GNUNET_NO, topology_data holds the string with the topology. | ||
1137 | * @return command. | ||
1138 | */ | ||
1139 | struct GNUNET_TESTING_Command | ||
1140 | GNUNET_TESTING_cmd_netjail_start_testing_system ( | ||
1141 | const char *label, | ||
1142 | struct GNUNET_TESTING_NetjailTopology *topology, | ||
1143 | unsigned int *read_file, | ||
1144 | char *topology_data); | ||
1145 | |||
1146 | |||
1147 | /** | ||
1148 | * Create command. | ||
1149 | * | ||
1150 | * @param label name for command. | ||
1151 | * @param topology_config Configuration file for the test topology. | ||
1152 | * @return command. | ||
1153 | */ | ||
1154 | struct GNUNET_TESTING_Command | ||
1155 | GNUNET_TESTING_cmd_netjail_stop (const char *label, | ||
1156 | char *topology_config, | ||
1157 | unsigned int *read_file); | ||
1158 | |||
1159 | |||
1160 | /** | ||
1161 | * Create command. | ||
1162 | * | ||
1163 | * @param label name for command. | ||
1164 | * @param helper_start_label label of the cmd to start the test system. | ||
1165 | * @param topology The complete topology information. | ||
1166 | * @return command. | ||
1167 | */ | ||
1168 | struct GNUNET_TESTING_Command | ||
1169 | GNUNET_TESTING_cmd_stop_testing_system ( | ||
1170 | const char *label, | ||
1171 | const char *helper_start_label, | ||
1172 | struct GNUNET_TESTING_NetjailTopology *topology); | ||
1173 | |||
1174 | |||
1175 | /** | ||
1176 | * Create a GNUNET_CMDS_LOCAL_FINISHED message. | ||
1177 | * | ||
1178 | * @param rv The result of the local test as GNUNET_GenericReturnValue. | ||
1179 | * @return The GNUNET_CMDS_LOCAL_FINISHED message. | ||
1180 | */ | ||
1181 | struct GNUNET_MessageHeader * | ||
1182 | GNUNET_TESTING_send_local_test_finished_msg (enum GNUNET_GenericReturnValue rv); | ||
1183 | |||
1184 | |||
1185 | /** | ||
1186 | * Function to get the trait with the async context. | ||
1187 | * | ||
1188 | * @param[out] ac GNUNET_TESTING_AsyncContext. | ||
1189 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
1190 | */ | ||
1191 | int | ||
1192 | GNUNET_TESTING_get_trait_async_context ( | ||
1193 | const struct GNUNET_TESTING_Command *cmd, | ||
1194 | struct GNUNET_TESTING_AsyncContext **ac); | ||
1195 | |||
1196 | |||
1197 | /** | ||
1198 | * Offer handles to testing cmd helper from trait | ||
1199 | * | ||
1200 | * @param cmd command to extract the message from. | ||
1201 | * @param pt pointer to message. | ||
1202 | * @return #GNUNET_OK on success. | ||
1203 | */ | ||
1204 | enum GNUNET_GenericReturnValue | ||
1205 | GNUNET_TESTING_get_trait_helper_handles ( | ||
1206 | const struct GNUNET_TESTING_Command *cmd, | ||
1207 | struct GNUNET_HELPER_Handle ***helper); | ||
1208 | |||
1209 | |||
1210 | struct GNUNET_TESTING_Command | ||
1211 | GNUNET_TESTING_cmd_block_until_all_peers_started ( | ||
1212 | const char *label, | ||
1213 | unsigned int *all_peers_started); | ||
1214 | |||
1215 | |||
1216 | struct GNUNET_TESTING_Command | ||
1217 | GNUNET_TESTING_cmd_block_until_external_trigger ( | ||
1218 | const char *label); | ||
1219 | |||
1220 | struct GNUNET_TESTING_Command | ||
1221 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, | ||
1222 | TESTING_CMD_HELPER_write_cb write_message); | ||
1223 | |||
1224 | |||
1225 | /** | ||
1226 | * Create command. | ||
1227 | * | ||
1228 | * @param label name for command. | ||
1229 | * @param write_message Callback to write messages to the master loop. | ||
1230 | * @return command. | ||
1231 | */ | ||
1232 | struct GNUNET_TESTING_Command | ||
1233 | GNUNET_TESTING_cmd_local_test_finished ( | ||
1234 | const char *label, | ||
1235 | TESTING_CMD_HELPER_write_cb write_message); | ||
1236 | |||
1237 | /** | ||
1238 | * Create command. | ||
1239 | * | ||
1240 | * @param label name for command. | ||
1241 | * @param write_message Callback to write messages to the master loop. | ||
1242 | * @param all_local_tests_prepared Flag which will be set from outside. | ||
1243 | * @return command. | ||
1244 | */ | ||
1245 | struct GNUNET_TESTING_Command | ||
1246 | GNUNET_TESTING_cmd_local_test_prepared (const char *label, | ||
1247 | TESTING_CMD_HELPER_write_cb | ||
1248 | write_message); | ||
1249 | |||
1250 | /** | ||
1251 | * Function to get the trait with the struct LocalPreparedState. | ||
1252 | * | ||
1253 | * @param[out] lfs struct LocalPreparedState. | ||
1254 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
1255 | * | ||
1256 | */ | ||
1257 | enum GNUNET_GenericReturnValue | ||
1258 | GNUNET_TESTING_get_trait_local_prepared_state ( | ||
1259 | const struct GNUNET_TESTING_Command *cmd, | ||
1260 | struct LocalPreparedState **lfs); | ||
1261 | |||
1262 | #endif | 906 | #endif |
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c index f90cc3cc4..5ff7c04ea 100644 --- a/src/testing/gnunet-cmds-helper.c +++ b/src/testing/gnunet-cmds-helper.c | |||
@@ -415,8 +415,6 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message) | |||
415 | plugin->n, plugin->local_m, ni->topology_data, | 415 | plugin->n, plugin->local_m, ni->topology_data, |
416 | ni->read_file); | 416 | ni->read_file); |
417 | 417 | ||
418 | GNUNET_free (binary); | ||
419 | |||
420 | msg_length = sizeof(struct GNUNET_CMDS_HelperReply); | 418 | msg_length = sizeof(struct GNUNET_CMDS_HelperReply); |
421 | reply = GNUNET_new (struct GNUNET_CMDS_HelperReply); | 419 | reply = GNUNET_new (struct GNUNET_CMDS_HelperReply); |
422 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY); | 420 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY); |
@@ -424,6 +422,10 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message) | |||
424 | 422 | ||
425 | write_message ((struct GNUNET_MessageHeader *) reply, msg_length); | 423 | write_message ((struct GNUNET_MessageHeader *) reply, msg_length); |
426 | 424 | ||
425 | GNUNET_free (binary); | ||
426 | GNUNET_free (router_ip); | ||
427 | GNUNET_free (plugin_name); | ||
428 | |||
427 | return GNUNET_OK; | 429 | return GNUNET_OK; |
428 | } | 430 | } |
429 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED == ntohs ( | 431 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED == ntohs ( |
diff --git a/src/testing/testing.c b/src/testing/testing.c index ced04e65d..9e664292b 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -1838,7 +1838,7 @@ get_first_string_value (char *line) | |||
1838 | memcpy (copy, line, slen); | 1838 | memcpy (copy, line, slen); |
1839 | token = strtok_r (copy, ":", &rest); | 1839 | token = strtok_r (copy, ":", &rest); |
1840 | token = strtok_r (NULL, ":", &rest); | 1840 | token = strtok_r (NULL, ":", &rest); |
1841 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1841 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1842 | "first token %s\n", | 1842 | "first token %s\n", |
1843 | token); | 1843 | token); |
1844 | slen_token = strlen (token); | 1844 | slen_token = strlen (token); |
@@ -1924,7 +1924,7 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node) | |||
1924 | node_connection->node_type = GNUNET_TESTING_GLOBAL_NODE; | 1924 | node_connection->node_type = GNUNET_TESTING_GLOBAL_NODE; |
1925 | token = strtok_r (NULL, ":", &rest); | 1925 | token = strtok_r (NULL, ":", &rest); |
1926 | GNUNET_assert (1 == sscanf (token, "%u", &node_n)); | 1926 | GNUNET_assert (1 == sscanf (token, "%u", &node_n)); |
1927 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1927 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1928 | "node_n %u\n", | 1928 | "node_n %u\n", |
1929 | node_n); | 1929 | node_n); |
1930 | node_connection->node_n = node_n; | 1930 | node_connection->node_n = node_n; |
@@ -1939,7 +1939,7 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node) | |||
1939 | token = strtok_r (NULL, ":", &rest); | 1939 | token = strtok_r (NULL, ":", &rest); |
1940 | sscanf (token, "%u", &node_n); | 1940 | sscanf (token, "%u", &node_n); |
1941 | node_connection->node_n = node_n; | 1941 | node_connection->node_n = node_n; |
1942 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1942 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1943 | "node_n %u namespace_n %u node->node_n %u node->namespace_n %u\n", | 1943 | "node_n %u namespace_n %u node->node_n %u node->namespace_n %u\n", |
1944 | node_n, | 1944 | node_n, |
1945 | namespace_n, | 1945 | namespace_n, |
@@ -1963,14 +1963,14 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node) | |||
1963 | memcpy (prefix->address_prefix, token, slen); | 1963 | memcpy (prefix->address_prefix, token, slen); |
1964 | } | 1964 | } |
1965 | 1965 | ||
1966 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1966 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1967 | "address_prefix %s\n", | 1967 | "address_prefix %s\n", |
1968 | prefix->address_prefix); | 1968 | prefix->address_prefix); |
1969 | 1969 | ||
1970 | GNUNET_CONTAINER_DLL_insert (node_connection->address_prefixes_head, | 1970 | GNUNET_CONTAINER_DLL_insert (node_connection->address_prefixes_head, |
1971 | node_connection->address_prefixes_tail, | 1971 | node_connection->address_prefixes_tail, |
1972 | prefix); | 1972 | prefix); |
1973 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1973 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1974 | "address_prefix %s\n", | 1974 | "address_prefix %s\n", |
1975 | prefix->address_prefix); | 1975 | prefix->address_prefix); |
1976 | } | 1976 | } |
@@ -2028,7 +2028,7 @@ log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value) | |||
2028 | struct GNUNET_TESTING_NodeConnection *pos_connection; | 2028 | struct GNUNET_TESTING_NodeConnection *pos_connection; |
2029 | struct GNUNET_TESTING_AddressPrefix *pos_prefix; | 2029 | struct GNUNET_TESTING_AddressPrefix *pos_prefix; |
2030 | 2030 | ||
2031 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2031 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2032 | "plugin: %s space: %u node: %u global: %u\n", | 2032 | "plugin: %s space: %u node: %u global: %u\n", |
2033 | node->plugin, | 2033 | node->plugin, |
2034 | node->namespace_n, | 2034 | node->namespace_n, |
@@ -2039,7 +2039,7 @@ log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value) | |||
2039 | pos_connection = pos_connection->next) | 2039 | pos_connection = pos_connection->next) |
2040 | { | 2040 | { |
2041 | 2041 | ||
2042 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2042 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2043 | "namespace_n: %u node_n: %u node_type: %u\n", | 2043 | "namespace_n: %u node_n: %u node_type: %u\n", |
2044 | pos_connection->namespace_n, | 2044 | pos_connection->namespace_n, |
2045 | pos_connection->node_n, | 2045 | pos_connection->node_n, |
@@ -2049,7 +2049,7 @@ log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value) | |||
2049 | pos_prefix = | 2049 | pos_prefix = |
2050 | pos_prefix->next) | 2050 | pos_prefix->next) |
2051 | { | 2051 | { |
2052 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2052 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2053 | "prefix: %s\n", | 2053 | "prefix: %s\n", |
2054 | pos_prefix->address_prefix); | 2054 | pos_prefix->address_prefix); |
2055 | } | 2055 | } |
@@ -2071,7 +2071,7 @@ log_namespaces (void *cls, const struct GNUNET_ShortHashCode *id, void *value) | |||
2071 | static int | 2071 | static int |
2072 | log_topo (struct GNUNET_TESTING_NetjailTopology *topology) | 2072 | log_topo (struct GNUNET_TESTING_NetjailTopology *topology) |
2073 | { | 2073 | { |
2074 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2074 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2075 | "plugin: %s spaces: %u nodes: %u known: %u\n", | 2075 | "plugin: %s spaces: %u nodes: %u known: %u\n", |
2076 | topology->plugin, | 2076 | topology->plugin, |
2077 | topology->namespaces_n, | 2077 | topology->namespaces_n, |
@@ -2218,6 +2218,8 @@ free_nodes_cb (void *cls, | |||
2218 | GNUNET_free (pos_connection); | 2218 | GNUNET_free (pos_connection); |
2219 | pos_connection = tmp_connection; | 2219 | pos_connection = tmp_connection; |
2220 | } | 2220 | } |
2221 | GNUNET_free (node->plugin); | ||
2222 | GNUNET_free (node); | ||
2221 | return GNUNET_OK; | 2223 | return GNUNET_OK; |
2222 | } | 2224 | } |
2223 | 2225 | ||
@@ -2248,8 +2250,11 @@ GNUNET_TESTING_free_topology (struct GNUNET_TESTING_NetjailTopology *topology) | |||
2248 | { | 2250 | { |
2249 | GNUNET_CONTAINER_multishortmap_iterate (topology->map_namespaces, | 2251 | GNUNET_CONTAINER_multishortmap_iterate (topology->map_namespaces, |
2250 | free_namespaces_cb, NULL); | 2252 | free_namespaces_cb, NULL); |
2253 | GNUNET_CONTAINER_multishortmap_destroy (topology->map_namespaces); | ||
2251 | GNUNET_CONTAINER_multishortmap_iterate (topology->map_globals, free_nodes_cb, | 2254 | GNUNET_CONTAINER_multishortmap_iterate (topology->map_globals, free_nodes_cb, |
2252 | NULL); | 2255 | NULL); |
2256 | GNUNET_CONTAINER_multishortmap_destroy (topology->map_globals); | ||
2257 | GNUNET_free (topology->plugin); | ||
2253 | GNUNET_free (topology); | 2258 | GNUNET_free (topology); |
2254 | } | 2259 | } |
2255 | 2260 | ||
@@ -2294,7 +2299,7 @@ GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection, | |||
2294 | char *addr; | 2299 | char *addr; |
2295 | char *template; | 2300 | char *template; |
2296 | 2301 | ||
2297 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2302 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2298 | "node_n: %u\n", | 2303 | "node_n: %u\n", |
2299 | connection->node_n); | 2304 | connection->node_n); |
2300 | 2305 | ||
@@ -2374,7 +2379,7 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2374 | char *key = NULL; | 2379 | char *key = NULL; |
2375 | unsigned int out; | 2380 | unsigned int out; |
2376 | char *rest = NULL; | 2381 | char *rest = NULL; |
2377 | char *value; | 2382 | char *value = NULL; |
2378 | char *value2; | 2383 | char *value2; |
2379 | int ret; | 2384 | int ret; |
2380 | struct GNUNET_TESTING_NetjailTopology *topo; | 2385 | struct GNUNET_TESTING_NetjailTopology *topo; |
@@ -2384,9 +2389,6 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2384 | struct GNUNET_ShortHashCode *hkey; | 2389 | struct GNUNET_ShortHashCode *hkey; |
2385 | struct GNUNET_HashCode hc; | 2390 | struct GNUNET_HashCode hc; |
2386 | 2391 | ||
2387 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2388 | "data %s\n", | ||
2389 | data); | ||
2390 | token = strtok_r (data, "\n", &rest); | 2392 | token = strtok_r (data, "\n", &rest); |
2391 | topo = GNUNET_new (struct GNUNET_TESTING_NetjailTopology); | 2393 | topo = GNUNET_new (struct GNUNET_TESTING_NetjailTopology); |
2392 | topo->map_namespaces = | 2394 | topo->map_namespaces = |
@@ -2399,46 +2401,46 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2399 | if (NULL != key) | 2401 | if (NULL != key) |
2400 | free (key); | 2402 | free (key); |
2401 | key = get_key (token); | 2403 | key = get_key (token); |
2402 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2404 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2403 | "In the loop with token: %s beginning with %s\n", | 2405 | "In the loop with token: %s beginning with %s\n", |
2404 | token, | 2406 | token, |
2405 | key); | 2407 | key); |
2406 | if (0 == strcmp (key, "M")) | 2408 | if (0 == strcmp (key, "M")) |
2407 | { | 2409 | { |
2408 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2410 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2409 | "Get first Value for M.\n"); | 2411 | "Get first Value for M.\n"); |
2410 | out = get_first_value (token); | 2412 | out = get_first_value (token); |
2411 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2413 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2412 | "M: %u\n", | 2414 | "M: %u\n", |
2413 | out); | 2415 | out); |
2414 | topo->nodes_m = out; | 2416 | topo->nodes_m = out; |
2415 | } | 2417 | } |
2416 | else if (0 == strcmp (key, "N")) | 2418 | else if (0 == strcmp (key, "N")) |
2417 | { | 2419 | { |
2418 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2420 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2419 | "Get first Value for N.\n"); | 2421 | "Get first Value for N.\n"); |
2420 | out = get_first_value (token); | 2422 | out = get_first_value (token); |
2421 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2423 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2422 | "N: %u\n", | 2424 | "N: %u\n", |
2423 | out); | 2425 | out); |
2424 | topo->namespaces_n = out; | 2426 | topo->namespaces_n = out; |
2425 | } | 2427 | } |
2426 | else if (0 == strcmp (key, "X")) | 2428 | else if (0 == strcmp (key, "X")) |
2427 | { | 2429 | { |
2428 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2430 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2429 | "Get first Value for X.\n"); | 2431 | "Get first Value for X.\n"); |
2430 | out = get_first_value (token); | 2432 | out = get_first_value (token); |
2431 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2433 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2432 | "X: %u\n", | 2434 | "X: %u\n", |
2433 | out); | 2435 | out); |
2434 | topo->nodes_x = out; | 2436 | topo->nodes_x = out; |
2435 | } | 2437 | } |
2436 | else if (0 == strcmp (key, "T")) | 2438 | else if (0 == strcmp (key, "T")) |
2437 | { | 2439 | { |
2438 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2440 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2439 | "Get first string value for T.\n"); | 2441 | "Get first string value for T.\n"); |
2440 | value = get_first_string_value (token); | 2442 | value = get_first_string_value (token); |
2441 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2443 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2442 | "value: %s\n", | 2444 | "value: %s\n", |
2443 | value); | 2445 | value); |
2444 | topo->plugin = value; | 2446 | topo->plugin = value; |
@@ -2448,10 +2450,10 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2448 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | 2450 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); |
2449 | node = GNUNET_new (struct GNUNET_TESTING_NetjailNode); | 2451 | node = GNUNET_new (struct GNUNET_TESTING_NetjailNode); |
2450 | 2452 | ||
2451 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2453 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2452 | "Get first Value for K.\n"); | 2454 | "Get first Value for K.\n"); |
2453 | out = get_first_value (token); | 2455 | out = get_first_value (token); |
2454 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2456 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2455 | "K: %u\n", | 2457 | "K: %u\n", |
2456 | out); | 2458 | out); |
2457 | node->node_n = out; | 2459 | node->node_n = out; |
@@ -2470,10 +2472,10 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2470 | hkey, | 2472 | hkey, |
2471 | node, | 2473 | node, |
2472 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 2474 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
2473 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2475 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2474 | "Get value for key value on K.\n"); | 2476 | "Get value for key value on K.\n"); |
2475 | value = get_value ("plugin", token); | 2477 | value = get_value ("plugin", token); |
2476 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2478 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2477 | "value: %s\n", | 2479 | "value: %s\n", |
2478 | value); | 2480 | value); |
2479 | node->plugin = value; | 2481 | node->plugin = value; |
@@ -2485,10 +2487,10 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2485 | router = GNUNET_new (struct GNUNET_TESTING_NetjailRouter); | 2487 | router = GNUNET_new (struct GNUNET_TESTING_NetjailRouter); |
2486 | node = GNUNET_new (struct GNUNET_TESTING_NetjailNode); | 2488 | node = GNUNET_new (struct GNUNET_TESTING_NetjailNode); |
2487 | 2489 | ||
2488 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2490 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2489 | "Get first Value for R.\n"); | 2491 | "Get first Value for R.\n"); |
2490 | out = get_first_value (token); | 2492 | out = get_first_value (token); |
2491 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2493 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2492 | "R: %u\n", | 2494 | "R: %u\n", |
2493 | out); | 2495 | out); |
2494 | node->node_n = out; | 2496 | node->node_n = out; |
@@ -2496,22 +2498,22 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2496 | memcpy (hkey, | 2498 | memcpy (hkey, |
2497 | &hc, | 2499 | &hc, |
2498 | sizeof (*hkey)); | 2500 | sizeof (*hkey)); |
2499 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2501 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2500 | "Get value for key tcp_port on R.\n"); | 2502 | "Get value for key tcp_port on R.\n"); |
2501 | value = get_value ("tcp_port", token); | 2503 | value = get_value ("tcp_port", token); |
2502 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2504 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2503 | "tcp_port: %s\n", | 2505 | "tcp_port: %s\n", |
2504 | value); | 2506 | value); |
2505 | ret = sscanf (value, "%u", &(router->tcp_port)); | 2507 | ret = sscanf (value, "%u", &(router->tcp_port)); |
2506 | 2508 | ||
2507 | GNUNET_break (0 != ret && 1 >= router->tcp_port); | 2509 | GNUNET_break (0 != ret && 1 >= router->tcp_port); |
2508 | 2510 | ||
2509 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2511 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2510 | "Get value for key udp_port on R.\n"); | 2512 | "Get value for key udp_port on R.\n"); |
2511 | value2 = get_value ("udp_port", token); | 2513 | value2 = get_value ("udp_port", token); |
2512 | ret = sscanf (value2, "%u", &(router->udp_port)); | 2514 | ret = sscanf (value2, "%u", &(router->udp_port)); |
2513 | GNUNET_break (0 != ret && 1 >= router->udp_port); | 2515 | GNUNET_break (0 != ret && 1 >= router->udp_port); |
2514 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2516 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2515 | "udp_port: %s\n", | 2517 | "udp_port: %s\n", |
2516 | value2); | 2518 | value2); |
2517 | 2519 | ||
@@ -2540,10 +2542,10 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2540 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | 2542 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); |
2541 | node = GNUNET_new (struct GNUNET_TESTING_NetjailNode); | 2543 | node = GNUNET_new (struct GNUNET_TESTING_NetjailNode); |
2542 | 2544 | ||
2543 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2545 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2544 | "Get first Value for P.\n"); | 2546 | "Get first Value for P.\n"); |
2545 | out = get_first_value (token); | 2547 | out = get_first_value (token); |
2546 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2548 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2547 | "P: %u\n", | 2549 | "P: %u\n", |
2548 | out); | 2550 | out); |
2549 | GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); | 2551 | GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); |
@@ -2568,10 +2570,10 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2568 | namespace, | 2570 | namespace, |
2569 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 2571 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
2570 | } | 2572 | } |
2571 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2573 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2572 | "Get second Value for P.\n"); | 2574 | "Get second Value for P.\n"); |
2573 | out = get_second_value (token); | 2575 | out = get_second_value (token); |
2574 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2576 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2575 | "P: %u\n", | 2577 | "P: %u\n", |
2576 | out); | 2578 | out); |
2577 | GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); | 2579 | GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); |
@@ -2591,10 +2593,10 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2591 | hkey, | 2593 | hkey, |
2592 | node, | 2594 | node, |
2593 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 2595 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
2594 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2596 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2595 | "Get value for key plugin on P.\n"); | 2597 | "Get value for key plugin on P.\n"); |
2596 | value = get_value ("plugin", token); | 2598 | value = get_value ("plugin", token); |
2597 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2599 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2598 | "plugin: %s\n", | 2600 | "plugin: %s\n", |
2599 | value); | 2601 | value); |
2600 | node->plugin = value; | 2602 | node->plugin = value; |
@@ -2605,10 +2607,14 @@ GNUNET_TESTING_get_topo_from_string (char *data) | |||
2605 | } | 2607 | } |
2606 | token = strtok_r (NULL, "\n", &rest); | 2608 | token = strtok_r (NULL, "\n", &rest); |
2607 | if (NULL != token) | 2609 | if (NULL != token) |
2608 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2610 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2609 | "Next token %s\n", | 2611 | "Next token %s\n", |
2610 | token); | 2612 | token); |
2611 | } | 2613 | } |
2614 | if (NULL != key) | ||
2615 | GNUNET_free (key); | ||
2616 | /*if (NULL != value) | ||
2617 | GNUNET_free (value);*/ | ||
2612 | 2618 | ||
2613 | return topo; | 2619 | return topo; |
2614 | } | 2620 | } |
@@ -2642,7 +2648,7 @@ GNUNET_TESTING_get_topo_from_file (const char *filename) | |||
2642 | filename); | 2648 | filename); |
2643 | return NULL; | 2649 | return NULL; |
2644 | } | 2650 | } |
2645 | data = GNUNET_malloc (fs); | 2651 | data = GNUNET_malloc (fs + 1); |
2646 | if (fs != GNUNET_DISK_fn_read (filename, data, fs)) | 2652 | if (fs != GNUNET_DISK_fn_read (filename, data, fs)) |
2647 | { | 2653 | { |
2648 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2654 | LOG (GNUNET_ERROR_TYPE_ERROR, |
@@ -2653,9 +2659,8 @@ GNUNET_TESTING_get_topo_from_file (const char *filename) | |||
2653 | } | 2659 | } |
2654 | 2660 | ||
2655 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2661 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2656 | "data: %s\n", | 2662 | "file lenght %lu\n", |
2657 | data); | 2663 | fs); |
2658 | |||
2659 | data[fs] = '\0'; | 2664 | data[fs] = '\0'; |
2660 | 2665 | ||
2661 | topo = GNUNET_TESTING_get_topo_from_string (data); | 2666 | topo = GNUNET_TESTING_get_topo_from_string (data); |
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 7ff554280..9360dd02e 100644 --- a/src/testing/testing_api_cmd_block_until_external_trigger.c +++ b/src/testing/testing_api_cmd_block_until_external_trigger.c | |||
@@ -33,23 +33,6 @@ | |||
33 | */ | 33 | */ |
34 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | 34 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) |
35 | 35 | ||
36 | /** | ||
37 | * Struct with information for callbacks. | ||
38 | * | ||
39 | */ | ||
40 | struct BlockState | ||
41 | { | ||
42 | /** | ||
43 | * Context for our asynchronous completion. | ||
44 | */ | ||
45 | struct GNUNET_TESTING_AsyncContext ac; | ||
46 | |||
47 | /** | ||
48 | * The label of this command. | ||
49 | */ | ||
50 | const char *label; | ||
51 | }; | ||
52 | |||
53 | 36 | ||
54 | /** | 37 | /** |
55 | * The cleanup function of this cmd frees resources the cmd allocated. | 38 | * The cleanup function of this cmd frees resources the cmd allocated. |
@@ -77,6 +60,11 @@ block_until_external_trigger_traits (void *cls, | |||
77 | .trait_name = "async_context", | 60 | .trait_name = "async_context", |
78 | .ptr = (const void *) ac, | 61 | .ptr = (const void *) ac, |
79 | }, | 62 | }, |
63 | { | ||
64 | .index = 1, | ||
65 | .trait_name = "block_state", | ||
66 | .ptr = (const void *) bs, | ||
67 | }, | ||
80 | GNUNET_TESTING_trait_end () | 68 | GNUNET_TESTING_trait_end () |
81 | }; | 69 | }; |
82 | 70 | ||
@@ -88,9 +76,27 @@ block_until_external_trigger_traits (void *cls, | |||
88 | 76 | ||
89 | 77 | ||
90 | /** | 78 | /** |
79 | * Function to get the trait with the internal command state BlockState. | ||
80 | * | ||
81 | * * @param[out] ac struct BlockState. | ||
82 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
83 | */ | ||
84 | int | ||
85 | GNUNET_TESTING_get_trait_block_state ( | ||
86 | const struct GNUNET_TESTING_Command *cmd, | ||
87 | struct BlockState **bs) | ||
88 | { | ||
89 | return cmd->traits (cmd->cls, | ||
90 | (const void **) bs, | ||
91 | "block_state", | ||
92 | (unsigned int) 1); | ||
93 | } | ||
94 | |||
95 | |||
96 | /** | ||
91 | * Function to get the trait with the async context. | 97 | * Function to get the trait with the async context. |
92 | * | 98 | * |
93 | * @param[out] ac GNUNET_TESTING_AsyncContext. | 99 | * @param[out] ac struct GNUNET_TESTING_AsyncContext. |
94 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | 100 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. |
95 | */ | 101 | */ |
96 | int | 102 | int |
@@ -114,10 +120,20 @@ block_until_all_peers_started_run (void *cls, | |||
114 | struct GNUNET_TESTING_Interpreter *is) | 120 | struct GNUNET_TESTING_Interpreter *is) |
115 | { | 121 | { |
116 | struct BlockState *bs = cls; | 122 | struct BlockState *bs = cls; |
123 | struct GNUNET_TESTING_Command *cmd = | ||
124 | GNUNET_TESTING_interpreter_get_current_command (is); | ||
117 | 125 | ||
118 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 126 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
119 | "block %s running!\n", | 127 | "block %s running %u!\n", |
120 | bs->label); | 128 | bs->label, |
129 | bs->asynchronous_finish); | ||
130 | if (GNUNET_YES == bs->asynchronous_finish) | ||
131 | { | ||
132 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
133 | "block %s running asynchronous!\n", | ||
134 | bs->label); | ||
135 | cmd->asynchronous_finish = bs->asynchronous_finish; | ||
136 | } | ||
121 | } | 137 | } |
122 | 138 | ||
123 | 139 | ||
@@ -126,15 +142,18 @@ block_until_all_peers_started_run (void *cls, | |||
126 | * | 142 | * |
127 | * @param label name for command. | 143 | * @param label name for command. |
128 | * @param all_peers_started Flag which will be set from outside. | 144 | * @param all_peers_started Flag which will be set from outside. |
145 | * @param asynchronous_finish If GNUNET_YES this command will not block. Can be NULL. | ||
129 | * @return command. | 146 | * @return command. |
130 | */ | 147 | */ |
131 | struct GNUNET_TESTING_Command | 148 | struct GNUNET_TESTING_Command |
132 | GNUNET_TESTING_cmd_block_until_external_trigger (const char *label) | 149 | GNUNET_TESTING_cmd_block_until_external_trigger ( |
150 | const char *label) | ||
133 | { | 151 | { |
134 | struct BlockState *bs; | 152 | struct BlockState *bs; |
135 | 153 | ||
136 | bs = GNUNET_new (struct BlockState); | 154 | bs = GNUNET_new (struct BlockState); |
137 | bs->label = label; | 155 | bs->label = label; |
156 | bs->asynchronous_finish = GNUNET_NO; | ||
138 | { | 157 | { |
139 | struct GNUNET_TESTING_Command cmd = { | 158 | struct GNUNET_TESTING_Command cmd = { |
140 | .cls = bs, | 159 | .cls = bs, |
diff --git a/src/testing/testing_api_cmd_netjail_start.c b/src/testing/testing_api_cmd_netjail_start.c index 2ff70c33e..6cd648c3a 100644 --- a/src/testing/testing_api_cmd_netjail_start.c +++ b/src/testing/testing_api_cmd_netjail_start.c | |||
@@ -193,11 +193,15 @@ netjail_start_run (void *cls, | |||
193 | NULL, | 193 | NULL, |
194 | script_name, | 194 | script_name, |
195 | script_argv); | 195 | script_argv); |
196 | |||
196 | } | 197 | } |
197 | ns->cwh = GNUNET_wait_child (ns->start_proc, | 198 | ns->cwh = GNUNET_wait_child (ns->start_proc, |
198 | &child_completed_callback, | 199 | &child_completed_callback, |
199 | ns); | 200 | ns); |
200 | GNUNET_break (NULL != ns->cwh); | 201 | GNUNET_break (NULL != ns->cwh); |
202 | GNUNET_free (read_file); | ||
203 | GNUNET_free (script_name); | ||
204 | GNUNET_free (data_dir); | ||
201 | } | 205 | } |
202 | 206 | ||
203 | 207 | ||
diff --git a/src/testing/testing_api_cmd_netjail_stop.c b/src/testing/testing_api_cmd_netjail_stop.c index e3bf7da62..f1b2260ab 100644 --- a/src/testing/testing_api_cmd_netjail_stop.c +++ b/src/testing/testing_api_cmd_netjail_stop.c | |||
@@ -87,6 +87,7 @@ netjail_stop_cleanup (void *cls) | |||
87 | GNUNET_OS_process_destroy (ns->stop_proc); | 87 | GNUNET_OS_process_destroy (ns->stop_proc); |
88 | ns->stop_proc = NULL; | 88 | ns->stop_proc = NULL; |
89 | } | 89 | } |
90 | GNUNET_free (ns); | ||
90 | } | 91 | } |
91 | 92 | ||
92 | 93 | ||
diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c index 3727d2543..e82ec33ab 100644 --- a/src/testing/testing_api_loop.c +++ b/src/testing/testing_api_loop.c | |||
@@ -53,6 +53,11 @@ struct GNUNET_TESTING_Interpreter | |||
53 | struct GNUNET_TESTING_Command *commands; | 53 | struct GNUNET_TESTING_Command *commands; |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * Number of GNUNET_TESTING_Command in commands. | ||
57 | */ | ||
58 | unsigned int cmds_n; | ||
59 | |||
60 | /** | ||
56 | * Interpreter task (if one is scheduled). | 61 | * Interpreter task (if one is scheduled). |
57 | */ | 62 | */ |
58 | struct GNUNET_SCHEDULER_Task *task; | 63 | struct GNUNET_SCHEDULER_Task *task; |
@@ -83,21 +88,32 @@ struct GNUNET_TESTING_Interpreter | |||
83 | 88 | ||
84 | 89 | ||
85 | const struct GNUNET_TESTING_Command * | 90 | const struct GNUNET_TESTING_Command * |
86 | GNUNET_TESTING_interpreter_lookup_command ( | 91 | get_command (struct GNUNET_TESTING_Interpreter *is, |
87 | struct GNUNET_TESTING_Interpreter *is, | 92 | const char *label, |
88 | const char *label) | 93 | unsigned int future) |
89 | { | 94 | { |
95 | int start_i = GNUNET_NO == future ? is->ip : is->cmds_n - 1; | ||
96 | int end_i = GNUNET_NO == future ? 0 : is->ip + 1; | ||
97 | |||
98 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
99 | "start_i: %u end_i: %u\n", | ||
100 | start_i, | ||
101 | end_i); | ||
90 | if (NULL == label) | 102 | if (NULL == label) |
91 | { | 103 | { |
92 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 104 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
93 | "Attempt to lookup command for empty label\n"); | 105 | "Attempt to lookup command for empty label\n"); |
94 | return NULL; | 106 | return NULL; |
95 | } | 107 | } |
96 | /* Search backwards as we most likely reference recent commands */ | 108 | |
97 | for (int i = is->ip; i >= 0; i--) | 109 | for (int i = start_i; i >= end_i; i--) |
98 | { | 110 | { |
99 | const struct GNUNET_TESTING_Command *cmd = &is->commands[i]; | 111 | const struct GNUNET_TESTING_Command *cmd = &is->commands[i]; |
100 | 112 | ||
113 | if (NULL != cmd->label) | ||
114 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
115 | "label to compare %s\n", | ||
116 | cmd->label); | ||
101 | /* Give precedence to top-level commands. */ | 117 | /* Give precedence to top-level commands. */ |
102 | if ( (NULL != cmd->label) && | 118 | if ( (NULL != cmd->label) && |
103 | (0 == strcmp (cmd->label, | 119 | (0 == strcmp (cmd->label, |
@@ -142,6 +158,40 @@ GNUNET_TESTING_interpreter_lookup_command ( | |||
142 | 158 | ||
143 | 159 | ||
144 | /** | 160 | /** |
161 | * Lookup command by label. | ||
162 | * Only future commands are looked up. | ||
163 | * | ||
164 | * @param is interpreter to lookup command in | ||
165 | * @param label label of the command to lookup. | ||
166 | * @return the command, if it is found, or NULL. | ||
167 | */ | ||
168 | const struct GNUNET_TESTING_Command * | ||
169 | GNUNET_TESTING_interpreter_lookup_future_command ( | ||
170 | struct GNUNET_TESTING_Interpreter *is, | ||
171 | const char *label) | ||
172 | { | ||
173 | return get_command (is, label, GNUNET_YES); | ||
174 | } | ||
175 | |||
176 | |||
177 | /** | ||
178 | * Lookup command by label. | ||
179 | * Only commands from current command to commands in the past are looked up. | ||
180 | * | ||
181 | * @param is interpreter to lookup command in | ||
182 | * @param label label of the command to lookup. | ||
183 | * @return the command, if it is found, or NULL. | ||
184 | */ | ||
185 | const struct GNUNET_TESTING_Command * | ||
186 | GNUNET_TESTING_interpreter_lookup_command ( | ||
187 | struct GNUNET_TESTING_Interpreter *is, | ||
188 | const char *label) | ||
189 | { | ||
190 | return get_command (is, label, GNUNET_NO); | ||
191 | } | ||
192 | |||
193 | |||
194 | /** | ||
145 | * Finish the test run, return the final result. | 195 | * Finish the test run, return the final result. |
146 | * | 196 | * |
147 | * @param cls the `struct GNUNET_TESTING_Interpreter` | 197 | * @param cls the `struct GNUNET_TESTING_Interpreter` |
@@ -267,6 +317,20 @@ GNUNET_TESTING_interpreter_fail (struct GNUNET_TESTING_Interpreter *is) | |||
267 | } | 317 | } |
268 | 318 | ||
269 | 319 | ||
320 | /** | ||
321 | * Returns the actual running command. | ||
322 | * | ||
323 | * @param is Global state of the interpreter, used by a command | ||
324 | * to access information about other commands. | ||
325 | * @return The actual running command. | ||
326 | */ | ||
327 | struct GNUNET_TESTING_Command * | ||
328 | GNUNET_TESTING_interpreter_get_current_command ( | ||
329 | struct GNUNET_TESTING_Interpreter *is) | ||
330 | { | ||
331 | return &is->commands[is->ip]; | ||
332 | } | ||
333 | |||
270 | const char * | 334 | const char * |
271 | GNUNET_TESTING_interpreter_get_current_label ( | 335 | GNUNET_TESTING_interpreter_get_current_label ( |
272 | struct GNUNET_TESTING_Interpreter *is) | 336 | struct GNUNET_TESTING_Interpreter *is) |
@@ -300,9 +364,17 @@ interpreter_run (void *cls) | |||
300 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 364 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
301 | "Running command `%s'\n", | 365 | "Running command `%s'\n", |
302 | cmd->label); | 366 | cmd->label); |
367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
368 | "start time of %p expected 0 is `%lu'\n", | ||
369 | cmd, | ||
370 | cmd->start_time.abs_value_us); | ||
303 | cmd->start_time | 371 | cmd->start_time |
304 | = cmd->last_req_time | 372 | = cmd->last_req_time |
305 | = GNUNET_TIME_absolute_get (); | 373 | = GNUNET_TIME_absolute_get (); |
374 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
375 | "start time of %p expected something is `%lu'\n", | ||
376 | cmd, | ||
377 | cmd->start_time.abs_value_us); | ||
306 | cmd->num_tries = 1; | 378 | cmd->num_tries = 1; |
307 | if (NULL != cmd->ac) | 379 | if (NULL != cmd->ac) |
308 | { | 380 | { |
@@ -344,6 +416,37 @@ do_timeout (void *cls) | |||
344 | } | 416 | } |
345 | 417 | ||
346 | 418 | ||
419 | /** | ||
420 | * Check if the command is running. | ||
421 | * | ||
422 | * @param cmd The command to check. | ||
423 | * @return GNUNET_NO if the command is not running, GNUNET_YES if it is running. | ||
424 | */ | ||
425 | enum GNUNET_GenericReturnValue | ||
426 | GNUNET_TESTING_running (const struct GNUNET_TESTING_Command *command) | ||
427 | { | ||
428 | return 0 != command->start_time.abs_value_us && 0 == | ||
429 | command->finish_time.abs_value_us; | ||
430 | } | ||
431 | |||
432 | |||
433 | /** | ||
434 | * Check if a command is finished. | ||
435 | * | ||
436 | * @param cmd The command to check. | ||
437 | * @return GNUNET_NO if the command is not finished, GNUNET_YES if it is finished. | ||
438 | */ | ||
439 | enum GNUNET_GenericReturnValue | ||
440 | GNUNET_TESTING_finished (struct GNUNET_TESTING_Command *command) | ||
441 | { | ||
442 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | ||
443 | struct GNUNET_TIME_Relative diff = GNUNET_TIME_absolute_get_difference ( | ||
444 | command->finish_time, | ||
445 | now); | ||
446 | return 0 < diff.rel_value_us; | ||
447 | } | ||
448 | |||
449 | |||
347 | void | 450 | void |
348 | GNUNET_TESTING_run (struct GNUNET_TESTING_Command *commands, | 451 | GNUNET_TESTING_run (struct GNUNET_TESTING_Command *commands, |
349 | struct GNUNET_TIME_Relative timeout, | 452 | struct GNUNET_TIME_Relative timeout, |
@@ -359,7 +462,8 @@ GNUNET_TESTING_run (struct GNUNET_TESTING_Command *commands, | |||
359 | /* get the number of commands */ | 462 | /* get the number of commands */ |
360 | for (i = 0; NULL != commands[i].label; i++) | 463 | for (i = 0; NULL != commands[i].label; i++) |
361 | ; | 464 | ; |
362 | is->commands = GNUNET_new_array (i + 1, | 465 | is->cmds_n = i + 1; |
466 | is->commands = GNUNET_new_array (is->cmds_n, | ||
363 | struct GNUNET_TESTING_Command); | 467 | struct GNUNET_TESTING_Command); |
364 | memcpy (is->commands, | 468 | memcpy (is->commands, |
365 | commands, | 469 | commands, |
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index f17be359e..a53f17fe6 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -123,6 +123,7 @@ endif | |||
123 | 123 | ||
124 | 124 | ||
125 | noinst_PROGRAMS = \ | 125 | noinst_PROGRAMS = \ |
126 | test_transport_start_with_config \ | ||
126 | gnunet-transport-profiler \ | 127 | gnunet-transport-profiler \ |
127 | gnunet-communicator-udp \ | 128 | gnunet-communicator-udp \ |
128 | $(WLAN_BIN_SENDER) \ | 129 | $(WLAN_BIN_SENDER) \ |
@@ -589,7 +590,6 @@ libgnunet_plugin_transport_https_server_la_CFLAGS = \ | |||
589 | $(MHD_CFLAGS) $(AM_CFLAGS) -DBUILD_HTTPS | 590 | $(MHD_CFLAGS) $(AM_CFLAGS) -DBUILD_HTTPS |
590 | 591 | ||
591 | check_PROGRAMS = \ | 592 | check_PROGRAMS = \ |
592 | test_transport_start_with_config \ | ||
593 | test_transport_address_switch_tcp \ | 593 | test_transport_address_switch_tcp \ |
594 | test_transport_testing_startstop \ | 594 | test_transport_testing_startstop \ |
595 | test_transport_testing_restart \ | 595 | test_transport_testing_restart \ |
@@ -766,7 +766,6 @@ test_transport_start_with_config_SOURCES = \ | |||
766 | test_transport_start_with_config_LDADD = \ | 766 | test_transport_start_with_config_LDADD = \ |
767 | $(top_builddir)/src/testing/libgnunettesting.la \ | 767 | $(top_builddir)/src/testing/libgnunettesting.la \ |
768 | $(top_builddir)/src/util/libgnunetutil.la \ | 768 | $(top_builddir)/src/util/libgnunetutil.la \ |
769 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | ||
770 | $(top_builddir)/src/hello/libgnunethello.la \ | 769 | $(top_builddir)/src/hello/libgnunethello.la \ |
771 | libgnunettransportcore.la \ | 770 | libgnunettransportcore.la \ |
772 | libgnunettransporttesting2.la | 771 | libgnunettransporttesting2.la |
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c index 0bf919787..07eb6db3a 100644 --- a/src/transport/gnunet-communicator-tcp.c +++ b/src/transport/gnunet-communicator-tcp.c | |||
@@ -3264,7 +3264,7 @@ init_socket (struct sockaddr *addr, | |||
3264 | return GNUNET_SYSERR; | 3264 | return GNUNET_SYSERR; |
3265 | } | 3265 | } |
3266 | 3266 | ||
3267 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 3267 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3268 | "address %s\n", | 3268 | "address %s\n", |
3269 | GNUNET_a2s (addr, in_len)); | 3269 | GNUNET_a2s (addr, in_len)); |
3270 | 3270 | ||
@@ -3403,15 +3403,17 @@ nat_register () | |||
3403 | socklen_t *saddr_lens; | 3403 | socklen_t *saddr_lens; |
3404 | int i; | 3404 | int i; |
3405 | struct Addresses *pos; | 3405 | struct Addresses *pos; |
3406 | size_t len; | ||
3406 | 3407 | ||
3407 | 3408 | ||
3408 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3409 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3409 | "starting nat register!\n"); | 3410 | "starting nat register!\n"); |
3410 | 3411 | ||
3412 | len = 0; | ||
3411 | i = 0; | 3413 | i = 0; |
3412 | saddrs = GNUNET_malloc ((addrs_lens + 1) * sizeof(struct sockaddr *)); | 3414 | saddrs = GNUNET_malloc ((addrs_lens) * sizeof(struct sockaddr *)); |
3413 | 3415 | ||
3414 | saddr_lens = GNUNET_malloc ((addrs_lens + 1) * sizeof(socklen_t)); | 3416 | saddr_lens = GNUNET_malloc ((addrs_lens) * sizeof(socklen_t)); |
3415 | 3417 | ||
3416 | for (pos = addrs_head; NULL != pos; pos = pos->next) | 3418 | for (pos = addrs_head; NULL != pos; pos = pos->next) |
3417 | { | 3419 | { |
@@ -3421,12 +3423,19 @@ nat_register () | |||
3421 | GNUNET_a2s (addrs_head->addr, addrs_head->addr_len)); | 3423 | GNUNET_a2s (addrs_head->addr, addrs_head->addr_len)); |
3422 | 3424 | ||
3423 | saddr_lens[i] = addrs_head->addr_len; | 3425 | saddr_lens[i] = addrs_head->addr_len; |
3426 | len += saddr_lens[i]; | ||
3424 | saddrs[i] = GNUNET_memdup (addrs_head->addr, saddr_lens[i]); | 3427 | saddrs[i] = GNUNET_memdup (addrs_head->addr, saddr_lens[i]); |
3425 | 3428 | ||
3426 | i++; | 3429 | i++; |
3427 | 3430 | ||
3428 | } | 3431 | } |
3429 | 3432 | ||
3433 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3434 | "registering addresses %lu %lu %lu %lu\n", | ||
3435 | (addrs_lens) * sizeof(struct sockaddr *), | ||
3436 | (addrs_lens) * sizeof(socklen_t), | ||
3437 | len, | ||
3438 | sizeof(COMMUNICATOR_CONFIG_SECTION)); | ||
3430 | nat = GNUNET_NAT_register (cfg, | 3439 | nat = GNUNET_NAT_register (cfg, |
3431 | COMMUNICATOR_CONFIG_SECTION, | 3440 | COMMUNICATOR_CONFIG_SECTION, |
3432 | IPPROTO_TCP, | 3441 | IPPROTO_TCP, |
@@ -3437,7 +3446,7 @@ nat_register () | |||
3437 | NULL /* FIXME: support reversal: #5529 */, | 3446 | NULL /* FIXME: support reversal: #5529 */, |
3438 | NULL /* closure */); | 3447 | NULL /* closure */); |
3439 | 3448 | ||
3440 | i = 0; | 3449 | // i = 0; |
3441 | 3450 | ||
3442 | for (i = addrs_lens - 1; i >= 0; i--) | 3451 | for (i = addrs_lens - 1; i >= 0; i--) |
3443 | GNUNET_free (saddrs[i]); | 3452 | GNUNET_free (saddrs[i]); |
diff --git a/src/transport/test_communicator_tcp_basic_peer1.conf b/src/transport/test_communicator_tcp_basic_peer1.conf index dbc227ac6..d9fff8bbb 100644 --- a/src/transport/test_communicator_tcp_basic_peer1.conf +++ b/src/transport/test_communicator_tcp_basic_peer1.conf | |||
@@ -36,7 +36,7 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock | |||
36 | 36 | ||
37 | [communicator-tcp] | 37 | [communicator-tcp] |
38 | #PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args | 38 | #PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args |
39 | #PREFIX = valgrind --leak-check=full --track-origins=yes | 39 | PREFIX = valgrind --leak-check=full --track-origins=yes |
40 | BINDTO = 60002 | 40 | BINDTO = 60002 |
41 | DISABLE_V6 = YES | 41 | DISABLE_V6 = YES |
42 | 42 | ||
diff --git a/src/transport/test_transport_api2_tcp_node1.conf b/src/transport/test_transport_api2_tcp_node1.conf index 807a9360a..d6932b1b9 100644 --- a/src/transport/test_transport_api2_tcp_node1.conf +++ b/src/transport/test_transport_api2_tcp_node1.conf | |||
@@ -15,6 +15,7 @@ DISABLE_V6 = YES | |||
15 | IMMEDIATE_START = YES | 15 | IMMEDIATE_START = YES |
16 | UNIXPATH = $GNUNET_RUNTIME_DIR/tcp-comm-p1.sock | 16 | UNIXPATH = $GNUNET_RUNTIME_DIR/tcp-comm-p1.sock |
17 | #PREFIX = valgrind --log-file=/tmp/vg_cpeer1-%p | 17 | #PREFIX = valgrind --log-file=/tmp/vg_cpeer1-%p |
18 | PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args | ||
18 | 19 | ||
19 | [communicator-udp] | 20 | [communicator-udp] |
20 | BINARY = gnunet-communicator-udp | 21 | BINARY = gnunet-communicator-udp |
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c index 6829daf84..476fbdf4f 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send.c +++ b/src/transport/test_transport_plugin_cmd_simple_send.c | |||
@@ -164,19 +164,20 @@ handle_result (void *cls, | |||
164 | * | 164 | * |
165 | */ | 165 | */ |
166 | static void * | 166 | static void * |
167 | notify_connect (void *cls, | 167 | notify_connect (struct GNUNET_TESTING_Interpreter *is, |
168 | const struct GNUNET_PeerIdentity *peer, | 168 | const struct GNUNET_PeerIdentity *peer) |
169 | struct GNUNET_MQ_Handle *mq) | ||
170 | { | 169 | { |
171 | struct ConnectPeersState *cps; | 170 | struct ConnectPeersState *cps; |
171 | const struct GNUNET_TESTING_Command *cmd; | ||
172 | 172 | ||
173 | GNUNET_TRANSPORT_get_trait_connect_peer_state (&connect_peers, | 173 | cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
174 | "connect-peers"); | ||
175 | GNUNET_TRANSPORT_get_trait_connect_peer_state (cmd, | ||
174 | &cps); | 176 | &cps); |
175 | void *ret = NULL; | 177 | void *ret = NULL; |
176 | 178 | ||
177 | cps->notify_connect (cps, | 179 | cps->notify_connect (is, |
178 | peer, | 180 | peer); |
179 | mq); | ||
180 | return ret; | 181 | return ret; |
181 | } | 182 | } |
182 | 183 | ||
@@ -246,7 +247,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
246 | else | 247 | else |
247 | num = (n_int - 1) * local_m_int + m_int + topology->nodes_x; | 248 | num = (n_int - 1) * local_m_int + m_int + topology->nodes_x; |
248 | 249 | ||
249 | block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block"); | 250 | block_send = GNUNET_TESTING_cmd_block_until_external_trigger ( |
251 | "block"); | ||
250 | block_receive = GNUNET_TESTING_cmd_block_until_external_trigger ( | 252 | block_receive = GNUNET_TESTING_cmd_block_until_external_trigger ( |
251 | "block-receive"); | 253 | "block-receive"); |
252 | connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers", | 254 | connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers", |
@@ -262,11 +264,11 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
262 | GNUNET_asprintf (&ts->cfgname, | 264 | GNUNET_asprintf (&ts->cfgname, |
263 | "test_transport_api2_tcp_node1.conf"); | 265 | "test_transport_api2_tcp_node1.conf"); |
264 | 266 | ||
265 | LOG (GNUNET_ERROR_TYPE_ERROR, | 267 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
266 | "plugin cfgname: %s\n", | 268 | "plugin cfgname: %s\n", |
267 | ts->cfgname); | 269 | ts->cfgname); |
268 | 270 | ||
269 | LOG (GNUNET_ERROR_TYPE_ERROR, | 271 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
270 | "node ip: %s\n", | 272 | "node ip: %s\n", |
271 | node_ip); | 273 | node_ip); |
272 | 274 | ||
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 986fe6014..e2757671b 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c +++ b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c | |||
@@ -74,7 +74,6 @@ static struct GNUNET_TESTING_Command connect_peers; | |||
74 | 74 | ||
75 | static struct GNUNET_TESTING_Command local_prepared; | 75 | static struct GNUNET_TESTING_Command local_prepared; |
76 | 76 | ||
77 | |||
78 | /** | 77 | /** |
79 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being | 78 | * Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being |
80 | * received. | 79 | * received. |
@@ -164,25 +163,50 @@ handle_result (void *cls, | |||
164 | * | 163 | * |
165 | */ | 164 | */ |
166 | static void * | 165 | static void * |
167 | notify_connect (void *cls, | 166 | notify_connect (struct GNUNET_TESTING_Interpreter *is, |
168 | const struct GNUNET_PeerIdentity *peer, | 167 | const struct GNUNET_PeerIdentity *peer) |
169 | struct GNUNET_MQ_Handle *mq) | ||
170 | { | 168 | { |
171 | struct GNUNET_TESTING_AsyncContext *ac; | 169 | struct GNUNET_TESTING_AsyncContext *ac; |
170 | void *ret = NULL; | ||
171 | const struct GNUNET_TESTING_Command *cmd; | ||
172 | struct BlockState *bs; | ||
173 | |||
172 | 174 | ||
173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
174 | "notify_connect\n"); | 176 | "notify_connect\n"); |
175 | 177 | ||
176 | GNUNET_TESTING_get_trait_async_context (&connect_peers, | 178 | GNUNET_TESTING_get_trait_async_context (&connect_peers, |
177 | &ac); | 179 | &ac); |
178 | void *ret = NULL; | ||
179 | 180 | ||
180 | GNUNET_assert (NULL != ac); | 181 | if (NULL != ac->is) |
181 | if (NULL == ac->cont) | 182 | { |
182 | GNUNET_TESTING_async_fail (ac); | 183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
184 | "notify_connect running\n"); | ||
185 | GNUNET_assert (NULL != ac); | ||
186 | if (NULL == ac->cont) | ||
187 | GNUNET_TESTING_async_fail (ac); | ||
188 | else | ||
189 | GNUNET_TESTING_async_finish (ac); | ||
190 | } | ||
183 | else | 191 | else |
184 | GNUNET_TESTING_async_finish (ac); | 192 | { |
185 | 193 | cmd = GNUNET_TESTING_interpreter_lookup_future_command (is, | |
194 | "connect-peers"); | ||
195 | |||
196 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
197 | "block state %s\n", | ||
198 | cmd->label); | ||
199 | GNUNET_TESTING_get_trait_block_state (cmd,&bs); | ||
200 | |||
201 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
202 | "block state %u\n", | ||
203 | bs->asynchronous_finish); | ||
204 | bs->asynchronous_finish = GNUNET_YES; | ||
205 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
206 | "block state %u\n", | ||
207 | bs->asynchronous_finish); | ||
208 | } | ||
209 | |||
186 | return ret; | 210 | return ret; |
187 | } | 211 | } |
188 | 212 | ||
@@ -224,7 +248,6 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
224 | char *topology_data, | 248 | char *topology_data, |
225 | unsigned int *read_file) | 249 | unsigned int *read_file) |
226 | { | 250 | { |
227 | |||
228 | unsigned int n_int; | 251 | unsigned int n_int; |
229 | unsigned int m_int; | 252 | unsigned int m_int; |
230 | unsigned int local_m_int; | 253 | unsigned int local_m_int; |
@@ -232,6 +255,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
232 | struct TestState *ts = GNUNET_new (struct TestState); | 255 | struct TestState *ts = GNUNET_new (struct TestState); |
233 | struct GNUNET_TESTING_NetjailTopology *topology; | 256 | struct GNUNET_TESTING_NetjailTopology *topology; |
234 | 257 | ||
258 | |||
259 | |||
235 | if (GNUNET_YES == *read_file) | 260 | if (GNUNET_YES == *read_file) |
236 | { | 261 | { |
237 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 262 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -255,7 +280,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
255 | block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block"); | 280 | block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block"); |
256 | block_receive = GNUNET_TESTING_cmd_block_until_external_trigger ( | 281 | block_receive = GNUNET_TESTING_cmd_block_until_external_trigger ( |
257 | "block-receive"); | 282 | "block-receive"); |
258 | connect_peers = GNUNET_TESTING_cmd_block_until_external_trigger ("connect-peers"); | 283 | connect_peers = GNUNET_TESTING_cmd_block_until_external_trigger ( |
284 | "connect-peers"); | ||
259 | local_prepared = GNUNET_TESTING_cmd_local_test_prepared ( | 285 | local_prepared = GNUNET_TESTING_cmd_local_test_prepared ( |
260 | "local-test-prepared", | 286 | "local-test-prepared", |
261 | write_message); | 287 | write_message); |
@@ -264,11 +290,11 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
264 | GNUNET_asprintf (&ts->cfgname, | 290 | GNUNET_asprintf (&ts->cfgname, |
265 | "test_transport_api2_tcp_node1.conf"); | 291 | "test_transport_api2_tcp_node1.conf"); |
266 | 292 | ||
267 | LOG (GNUNET_ERROR_TYPE_ERROR, | 293 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
268 | "plugin cfgname: %s\n", | 294 | "plugin cfgname: %s\n", |
269 | ts->cfgname); | 295 | ts->cfgname); |
270 | 296 | ||
271 | LOG (GNUNET_ERROR_TYPE_ERROR, | 297 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
272 | "node ip: %s\n", | 298 | "node ip: %s\n", |
273 | node_ip); | 299 | node_ip); |
274 | 300 | ||
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c index 11cd177c4..c98a3075d 100644 --- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c +++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c | |||
@@ -160,9 +160,8 @@ handle_result (void *cls, | |||
160 | * | 160 | * |
161 | */ | 161 | */ |
162 | static void * | 162 | static void * |
163 | notify_connect (void *cls, | 163 | notify_connect (struct GNUNET_TESTING_Interpreter *is, |
164 | const struct GNUNET_PeerIdentity *peer, | 164 | const struct GNUNET_PeerIdentity *peer) |
165 | struct GNUNET_MQ_Handle *mq) | ||
166 | { | 165 | { |
167 | struct ConnectPeersState *cps; | 166 | struct ConnectPeersState *cps; |
168 | 167 | ||
@@ -170,9 +169,8 @@ notify_connect (void *cls, | |||
170 | &cps); | 169 | &cps); |
171 | void *ret = NULL; | 170 | void *ret = NULL; |
172 | 171 | ||
173 | cps->notify_connect (cps, | 172 | cps->notify_connect (is, |
174 | peer, | 173 | peer); |
175 | mq); | ||
176 | return ret; | 174 | return ret; |
177 | } | 175 | } |
178 | 176 | ||
@@ -238,7 +236,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
238 | else | 236 | else |
239 | num = (n_int - 1) * local_m_int + m_int + topology->nodes_x; | 237 | num = (n_int - 1) * local_m_int + m_int + topology->nodes_x; |
240 | 238 | ||
241 | block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block"); | 239 | block_send = GNUNET_TESTING_cmd_block_until_external_trigger ( |
240 | "block"); | ||
242 | connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers", | 241 | connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers", |
243 | "start-peer", | 242 | "start-peer", |
244 | "system-create", | 243 | "system-create", |
@@ -251,11 +250,11 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
251 | GNUNET_asprintf (&ts->cfgname, | 250 | GNUNET_asprintf (&ts->cfgname, |
252 | "test_transport_api2_tcp_node1.conf"); | 251 | "test_transport_api2_tcp_node1.conf"); |
253 | 252 | ||
254 | LOG (GNUNET_ERROR_TYPE_ERROR, | 253 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
255 | "plugin cfgname: %s\n", | 254 | "plugin cfgname: %s\n", |
256 | ts->cfgname); | 255 | ts->cfgname); |
257 | 256 | ||
258 | LOG (GNUNET_ERROR_TYPE_ERROR, | 257 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
259 | "node ip: %s\n", | 258 | "node ip: %s\n", |
260 | node_ip); | 259 | node_ip); |
261 | 260 | ||
diff --git a/src/transport/test_transport_simple_send.sh b/src/transport/test_transport_simple_send.sh index 7e3ee032f..e7da65ff7 100755 --- a/src/transport/test_transport_simple_send.sh +++ b/src/transport/test_transport_simple_send.sh | |||
@@ -1,5 +1,8 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | if [ "$(sysctl -n kernel.unprivileged_userns_clone)" == 1 ]; then | 2 | if ! [ -d "/run/netns" ]; then |
3 | echo You have to create the directory /run/netns. | ||
4 | fi | ||
5 | if [ "$(cat /proc/sys/kernel/core_uses_pid)" == 1 ]; then | ||
3 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_simple_send_topo.conf" | 6 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_simple_send_topo.conf" |
4 | else | 7 | else |
5 | echo -e "Error during test setup: The kernel parameter kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n sysctl kernel.unprivileged_userns_clone=1\n" | 8 | echo -e "Error during test setup: The kernel parameter kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n sysctl kernel.unprivileged_userns_clone=1\n" |
diff --git a/src/transport/test_transport_simple_send_broadcast.sh b/src/transport/test_transport_simple_send_broadcast.sh index 6e455f0d5..93572327b 100755 --- a/src/transport/test_transport_simple_send_broadcast.sh +++ b/src/transport/test_transport_simple_send_broadcast.sh | |||
@@ -1,5 +1,9 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | if [ "$(sysctl -n kernel.unprivileged_userns_clone)" == 1 ]; then | 2 | if ! [ -d "/run/netns" ]; then |
3 | echo You have to create the directory /run/netns. | ||
4 | fi | ||
5 | if [ "$(cat /proc/sys/kernel/core_uses_pid)" == 1 ]; then | ||
6 | # exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; valgrind --leak-check=full --track-origins=yes --trace-children=yes --trace-children-skip=/usr/bin/awk,/usr/bin/cut,/usr/bin/seq,/sbin/ip/sed/bash ./test_transport_start_with_config test_transport_simple_send_broadcast_topo.conf" | ||
3 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_simple_send_broadcast_topo.conf" | 7 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_simple_send_broadcast_topo.conf" |
4 | else | 8 | else |
5 | echo -e "Error during test setup: The kernel parameter kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n sysctl kernel.unprivileged_userns_clone=1\n" | 9 | echo -e "Error during test setup: The kernel parameter kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n sysctl kernel.unprivileged_userns_clone=1\n" |
diff --git a/src/transport/test_transport_simple_send_string.sh b/src/transport/test_transport_simple_send_string.sh index 018ea55e8..f9510e6b6 100755 --- a/src/transport/test_transport_simple_send_string.sh +++ b/src/transport/test_transport_simple_send_string.sh | |||
@@ -7,8 +7,11 @@ T:libgnunet_test_transport_plugin_cmd_simple_send | |||
7 | P:1:1|{connect:{P:1:2:tcp}} | 7 | P:1:1|{connect:{P:1:2:tcp}} |
8 | P:1:2|{connect:{P:1:1:tcp}} | 8 | P:1:2|{connect:{P:1:1:tcp}} |
9 | EOF | 9 | EOF |
10 | ) | 10 | ) |
11 | if [ "$(sysctl -n kernel.unprivileged_userns_clone)" == 1 ]; then | 11 | if ! [ -d "/run/netns" ]; then |
12 | echo You have to create the directory /run/netns. | ||
13 | fi | ||
14 | if [ "$(cat /proc/sys/kernel/core_uses_pid)" == 1 ]; then | ||
12 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config -s '$string'" | 15 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config -s '$string'" |
13 | else | 16 | else |
14 | echo -e "Error during test setup: The kernel parameter kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n sysctl kernel.unprivileged_userns_clone=1\n" | 17 | echo -e "Error during test setup: The kernel parameter kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n sysctl kernel.unprivileged_userns_clone=1\n" |
diff --git a/src/transport/test_transport_udp_backchannel.sh b/src/transport/test_transport_udp_backchannel.sh index 9c0b11fad..f93aef7ff 100755 --- a/src/transport/test_transport_udp_backchannel.sh +++ b/src/transport/test_transport_udp_backchannel.sh | |||
@@ -1,5 +1,8 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | if [ "$(sysctl -n kernel.unprivileged_userns_clone)" == 1 ]; then | 2 | if ! [ -d "/run/netns" ]; then |
3 | echo You have to create the directory /run/netns. | ||
4 | fi | ||
5 | if [ "$(cat /proc/sys/kernel/core_uses_pid)" == 1 ]; then | ||
3 | #exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; valgrind --leak-check=full --track-origins=yes --trace-children=yes --trace-children-skip=/usr/bin/awk,/usr/bin/cut,/usr/bin/seq,/sbin/ip ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf" | 6 | #exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; valgrind --leak-check=full --track-origins=yes --trace-children=yes --trace-children-skip=/usr/bin/awk,/usr/bin/cut,/usr/bin/seq,/sbin/ip ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf" |
4 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf" | 7 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf" |
5 | # exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; valgrind --leak-check=full --track-origins=yes ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf" | 8 | # exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; valgrind --leak-check=full --track-origins=yes ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf" |
diff --git a/src/transport/transport-testing-cmds.h b/src/transport/transport-testing-cmds.h index 5d0b902f6..d2e49c0d3 100644 --- a/src/transport/transport-testing-cmds.h +++ b/src/transport/transport-testing-cmds.h | |||
@@ -29,6 +29,10 @@ | |||
29 | #include "gnunet_testing_lib.h" | 29 | #include "gnunet_testing_lib.h" |
30 | 30 | ||
31 | 31 | ||
32 | typedef void * | ||
33 | (*GNUNET_TRANSPORT_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is, | ||
34 | const struct GNUNET_PeerIdentity *peer); | ||
35 | |||
32 | /** | 36 | /** |
33 | * Struct to store information needed in callbacks. | 37 | * Struct to store information needed in callbacks. |
34 | * | 38 | * |
@@ -40,7 +44,7 @@ struct ConnectPeersState | |||
40 | */ | 44 | */ |
41 | struct GNUNET_TESTING_AsyncContext ac; | 45 | struct GNUNET_TESTING_AsyncContext ac; |
42 | 46 | ||
43 | GNUNET_TRANSPORT_NotifyConnect notify_connect; | 47 | GNUNET_TRANSPORT_notify_connect_cb notify_connect; |
44 | 48 | ||
45 | /** | 49 | /** |
46 | * The testing system of this node. | 50 | * The testing system of this node. |
@@ -163,7 +167,7 @@ struct StartPeerState | |||
163 | 167 | ||
164 | struct GNUNET_TESTING_System *tl_system; | 168 | struct GNUNET_TESTING_System *tl_system; |
165 | 169 | ||
166 | GNUNET_TRANSPORT_NotifyConnect notify_connect; | 170 | GNUNET_TRANSPORT_notify_connect_cb notify_connect; |
167 | 171 | ||
168 | /** | 172 | /** |
169 | * Flag indicating, if udp broadcast should be switched on. | 173 | * Flag indicating, if udp broadcast should be switched on. |
@@ -213,7 +217,8 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label, | |||
213 | char *node_ip, | 217 | char *node_ip, |
214 | struct GNUNET_MQ_MessageHandler *handlers, | 218 | struct GNUNET_MQ_MessageHandler *handlers, |
215 | const char *cfgname, | 219 | const char *cfgname, |
216 | GNUNET_TRANSPORT_NotifyConnect notify_connect, | 220 | GNUNET_TRANSPORT_notify_connect_cb |
221 | notify_connect, | ||
217 | unsigned int broadcast); | 222 | unsigned int broadcast); |
218 | 223 | ||
219 | 224 | ||
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c index b50b63c62..3fef7d687 100644 --- a/src/transport/transport_api_cmd_connecting_peers.c +++ b/src/transport/transport_api_cmd_connecting_peers.c | |||
@@ -113,17 +113,20 @@ connect_peers_run (void *cls, | |||
113 | * | 113 | * |
114 | */ | 114 | */ |
115 | static void * | 115 | static void * |
116 | notify_connect (void *cls, | 116 | notify_connect (struct GNUNET_TESTING_Interpreter *is, |
117 | const struct GNUNET_PeerIdentity *peer, | 117 | const struct GNUNET_PeerIdentity *peer) |
118 | struct GNUNET_MQ_Handle *mq) | ||
119 | { | 118 | { |
120 | struct ConnectPeersState *cps = cls; | 119 | const struct GNUNET_TESTING_Command *cmd; |
120 | struct ConnectPeersState *cps; | ||
121 | struct GNUNET_PeerIdentity *peer_connection; | 121 | struct GNUNET_PeerIdentity *peer_connection; |
122 | unsigned int con_num = 0; | 122 | unsigned int con_num = 0; |
123 | struct GNUNET_TESTING_NodeConnection *pos_connection; | 123 | struct GNUNET_TESTING_NodeConnection *pos_connection; |
124 | unsigned int num; | 124 | unsigned int num; |
125 | void *ret = NULL; | 125 | void *ret = NULL; |
126 | 126 | ||
127 | cmd = GNUNET_TESTING_interpreter_lookup_command (is, | ||
128 | "connect-peers"); | ||
129 | cps = cmd->cls; | ||
127 | for (pos_connection = cps->node_connections_head; NULL != pos_connection; | 130 | for (pos_connection = cps->node_connections_head; NULL != pos_connection; |
128 | pos_connection = pos_connection->next) | 131 | pos_connection = pos_connection->next) |
129 | { | 132 | { |
@@ -217,7 +220,7 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label, | |||
217 | cps->num = num; | 220 | cps->num = num; |
218 | cps->create_label = create_label; | 221 | cps->create_label = create_label; |
219 | cps->topology = topology; | 222 | cps->topology = topology; |
220 | cps->notify_connect = ¬ify_connect; | 223 | cps->notify_connect = notify_connect; |
221 | 224 | ||
222 | { | 225 | { |
223 | struct GNUNET_TESTING_Command cmd = { | 226 | struct GNUNET_TESTING_Command cmd = { |
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c index da833f1b1..52eacabb2 100644 --- a/src/transport/transport_api_cmd_start_peer.c +++ b/src/transport/transport_api_cmd_start_peer.c | |||
@@ -147,9 +147,8 @@ notify_connect (void *cls, | |||
147 | 147 | ||
148 | GNUNET_free (key); | 148 | GNUNET_free (key); |
149 | 149 | ||
150 | sps->notify_connect (cls, | 150 | sps->notify_connect (sps->ac.is, |
151 | peer, | 151 | peer); |
152 | mq); | ||
153 | 152 | ||
154 | // TODO what does the handler function need? | 153 | // TODO what does the handler function need? |
155 | return ret; | 154 | return ret; |
@@ -213,11 +212,11 @@ start_peer_run (void *cls, | |||
213 | GNUNET_asprintf (&bindto_udp, | 212 | GNUNET_asprintf (&bindto_udp, |
214 | "2086"); | 213 | "2086"); |
215 | 214 | ||
216 | LOG (GNUNET_ERROR_TYPE_ERROR, | 215 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
217 | "node_ip %s\n", | 216 | "node_ip %s\n", |
218 | bindto); | 217 | bindto); |
219 | 218 | ||
220 | LOG (GNUNET_ERROR_TYPE_ERROR, | 219 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
221 | "bind_udp %s\n", | 220 | "bind_udp %s\n", |
222 | GNUNET_YES == sps->broadcast ? | 221 | GNUNET_YES == sps->broadcast ? |
223 | bindto_udp : bindto); | 222 | bindto_udp : bindto); |
@@ -247,7 +246,7 @@ start_peer_run (void *cls, | |||
247 | 246 | ||
248 | sps->tl_system = tl_system; | 247 | sps->tl_system = tl_system; |
249 | 248 | ||
250 | LOG (GNUNET_ERROR_TYPE_ERROR, | 249 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
251 | "Creating testing library with key number %u\n", | 250 | "Creating testing library with key number %u\n", |
252 | sps->no); | 251 | sps->no); |
253 | 252 | ||
@@ -255,7 +254,7 @@ start_peer_run (void *cls, | |||
255 | GNUNET_TESTING_configuration_create (tl_system, | 254 | GNUNET_TESTING_configuration_create (tl_system, |
256 | sps->cfg)) | 255 | sps->cfg)) |
257 | { | 256 | { |
258 | LOG (GNUNET_ERROR_TYPE_ERROR, | 257 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
259 | "Testing library failed to create unique configuration based on `%s'\n", | 258 | "Testing library failed to create unique configuration based on `%s'\n", |
260 | sps->cfgname); | 259 | sps->cfgname); |
261 | GNUNET_CONFIGURATION_destroy (sps->cfg); | 260 | GNUNET_CONFIGURATION_destroy (sps->cfg); |
@@ -359,6 +358,7 @@ start_peer_run (void *cls, | |||
359 | GNUNET_free (tcp_communicator_unix_path); | 358 | GNUNET_free (tcp_communicator_unix_path); |
360 | GNUNET_free (udp_communicator_unix_path); | 359 | GNUNET_free (udp_communicator_unix_path); |
361 | GNUNET_free (bindto); | 360 | GNUNET_free (bindto); |
361 | GNUNET_free (bindto_udp); | ||
362 | } | 362 | } |
363 | 363 | ||
364 | 364 | ||
@@ -589,7 +589,8 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label, | |||
589 | char *node_ip, | 589 | char *node_ip, |
590 | struct GNUNET_MQ_MessageHandler *handlers, | 590 | struct GNUNET_MQ_MessageHandler *handlers, |
591 | const char *cfgname, | 591 | const char *cfgname, |
592 | GNUNET_TRANSPORT_NotifyConnect notify_connect, | 592 | GNUNET_TRANSPORT_notify_connect_cb |
593 | notify_connect, | ||
593 | unsigned int broadcast) | 594 | unsigned int broadcast) |
594 | { | 595 | { |
595 | struct StartPeerState *sps; | 596 | struct StartPeerState *sps; |