aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2021-11-19 15:18:24 +0100
committert3sserakt <t3ss@posteo.de>2021-11-19 15:18:24 +0100
commit6a043a9228022fcce97fd50739db74abdabde055 (patch)
tree8cba6d9a87731cce5d20a3f8f2cf0cb2cb8ef37d /src/include
parent154d13fcb10205edf5fb56c12ac47e65abfec5a6 (diff)
downloadgnunet-6a043a9228022fcce97fd50739db74abdabde055.tar.gz
gnunet-6a043a9228022fcce97fd50739db74abdabde055.zip
- Fixed header, fixed log level, changed block until connect logic, fixed memory issues.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_testing_netjail_lib.h91
-rw-r--r--src/include/gnunet_testing_ng_lib.h452
2 files changed, 126 insertions, 417 deletions
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 */
307struct 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
344struct GNUNET_TESTING_Command
345GNUNET_TESTING_cmd_system_destroy (const char *label,
346 const char *create_label);
347
348
349struct GNUNET_TESTING_Command
350GNUNET_TESTING_cmd_system_create (const char *label,
351 const char *testdir);
352
353
354int
355GNUNET_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 */
329struct GNUNET_TESTING_Command 368struct 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 */
342struct GNUNET_TESTING_Command 382struct GNUNET_TESTING_Command
343GNUNET_TESTING_cmd_netjail_start_testing_system ( 383GNUNET_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 */
355struct GNUNET_TESTING_Command 397struct GNUNET_TESTING_Command
356GNUNET_TESTING_cmd_netjail_stop (const char *label, 398GNUNET_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 */
417struct GNUNET_TESTING_Command 469struct GNUNET_TESTING_Command
418GNUNET_TESTING_cmd_block_until_external_trigger ( 470GNUNET_TESTING_cmd_block_until_external_trigger (
419 const char *label); 471 const char *label);
420 472
473
421struct GNUNET_TESTING_Command 474struct GNUNET_TESTING_Command
422GNUNET_TESTING_cmd_send_peer_ready (const char *label, 475GNUNET_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 */
523int
524GNUNET_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 */
54struct 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 */
72enum 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!
87struct 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!
107struct GNUNET_TESTING_NetjailNode;
108
109/**
110 * Connection to another node.
111 * // FIXME: this does not belong here!
112 */
113struct 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 */
161struct 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 */
199struct 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 */
221struct 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 */
214const struct GNUNET_TESTING_Command *
215GNUNET_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 */
388struct GNUNET_TESTING_Command *
389GNUNET_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 */
399enum GNUNET_GenericReturnValue
400GNUNET_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 */
409enum GNUNET_GenericReturnValue
410GNUNET_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 */
1072struct 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 */
1096int
1097GNUNET_TESTING_get_trait_what_am_i (const struct GNUNET_TESTING_Command *cmd,
1098 char **what_am_i);
1099
1100
1101int
1102GNUNET_TESTING_get_trait_test_system (const struct
1103 GNUNET_TESTING_Command *cmd,
1104 struct GNUNET_TESTING_System **test_system);
1105
1106
1107struct GNUNET_TESTING_Command
1108GNUNET_TESTING_cmd_system_create (const char *label,
1109 const char *testdir);
1110
1111
1112struct GNUNET_TESTING_Command
1113GNUNET_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 */
1124struct GNUNET_TESTING_Command
1125GNUNET_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 */
1139struct GNUNET_TESTING_Command
1140GNUNET_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 */
1154struct GNUNET_TESTING_Command
1155GNUNET_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 */
1168struct GNUNET_TESTING_Command
1169GNUNET_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*/
1181struct GNUNET_MessageHeader *
1182GNUNET_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 */
1191int
1192GNUNET_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 */
1204enum GNUNET_GenericReturnValue
1205GNUNET_TESTING_get_trait_helper_handles (
1206 const struct GNUNET_TESTING_Command *cmd,
1207 struct GNUNET_HELPER_Handle ***helper);
1208
1209
1210struct GNUNET_TESTING_Command
1211GNUNET_TESTING_cmd_block_until_all_peers_started (
1212 const char *label,
1213 unsigned int *all_peers_started);
1214
1215
1216struct GNUNET_TESTING_Command
1217GNUNET_TESTING_cmd_block_until_external_trigger (
1218 const char *label);
1219
1220struct GNUNET_TESTING_Command
1221GNUNET_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 */
1232struct GNUNET_TESTING_Command
1233GNUNET_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 */
1245struct GNUNET_TESTING_Command
1246GNUNET_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 */
1257enum GNUNET_GenericReturnValue
1258GNUNET_TESTING_get_trait_local_prepared_state (
1259 const struct GNUNET_TESTING_Command *cmd,
1260 struct LocalPreparedState **lfs);
1261
1262#endif 906#endif