diff options
author | t3sserakt <t3ss@posteo.de> | 2021-11-19 15:18:24 +0100 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-11-19 15:18:24 +0100 |
commit | 6a043a9228022fcce97fd50739db74abdabde055 (patch) | |
tree | 8cba6d9a87731cce5d20a3f8f2cf0cb2cb8ef37d /src/include/gnunet_testing_ng_lib.h | |
parent | 154d13fcb10205edf5fb56c12ac47e65abfec5a6 (diff) | |
download | gnunet-6a043a9228022fcce97fd50739db74abdabde055.tar.gz gnunet-6a043a9228022fcce97fd50739db74abdabde055.zip |
- Fixed header, fixed log level, changed block until connect logic, fixed memory issues.
Diffstat (limited to 'src/include/gnunet_testing_ng_lib.h')
-rw-r--r-- | src/include/gnunet_testing_ng_lib.h | 452 |
1 files changed, 48 insertions, 404 deletions
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 |