diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-10-08 21:50:34 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-10-08 21:50:34 +0200 |
commit | bd8f79f628b254f4f02c08284ba65d23486d6127 (patch) | |
tree | 8729cfd715433db91b0fbb72d0aac164082b7f24 /src/include/gnunet_testing_ng_lib.h | |
parent | 6ef071b8ccea72da6a9e1eee6483c326b6ebc082 (diff) | |
download | gnunet-bd8f79f628b254f4f02c08284ba65d23486d6127.tar.gz gnunet-bd8f79f628b254f4f02c08284ba65d23486d6127.zip |
-clean up testing-NG finish logic
Diffstat (limited to 'src/include/gnunet_testing_ng_lib.h')
-rw-r--r-- | src/include/gnunet_testing_ng_lib.h | 81 |
1 files changed, 56 insertions, 25 deletions
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h index 4ef9aac18..0cab64504 100644 --- a/src/include/gnunet_testing_ng_lib.h +++ b/src/include/gnunet_testing_ng_lib.h | |||
@@ -82,7 +82,7 @@ enum GNUNET_TESTING_NODE_TYPE | |||
82 | }; | 82 | }; |
83 | 83 | ||
84 | 84 | ||
85 | // FIXME: this does not belong here! | 85 | // FIXME: this does not belong here! |
86 | struct GNUNET_TESTING_ADDRESS_PREFIX | 86 | struct GNUNET_TESTING_ADDRESS_PREFIX |
87 | { | 87 | { |
88 | /** | 88 | /** |
@@ -261,6 +261,36 @@ struct GNUNET_TESTING_NetjailTopology | |||
261 | struct GNUNET_TESTING_Interpreter; | 261 | struct GNUNET_TESTING_Interpreter; |
262 | 262 | ||
263 | /** | 263 | /** |
264 | * State each asynchronous command must have in its closure. | ||
265 | */ | ||
266 | struct GNUNET_TESTING_AsyncContext | ||
267 | { | ||
268 | |||
269 | /** | ||
270 | * Interpreter we are part of. | ||
271 | */ | ||
272 | struct GNUNET_TESTING_Interpreter *is; | ||
273 | |||
274 | /** | ||
275 | * Function to call when done. | ||
276 | */ | ||
277 | GNUNET_SCHEDULER_TaskCallback cont; | ||
278 | |||
279 | /** | ||
280 | * Closure for @e cont. | ||
281 | */ | ||
282 | void *cont_cls; | ||
283 | |||
284 | /** | ||
285 | * Indication if the command finished (#GNUNET_OK). | ||
286 | * #GNUNET_NO if it is still running, | ||
287 | * #GNUNET_SYSERR if it failed. | ||
288 | */ | ||
289 | enum GNUNET_GenericReturnValue finished; | ||
290 | }; | ||
291 | |||
292 | |||
293 | /** | ||
264 | * A command to be run by the interpreter. | 294 | * A command to be run by the interpreter. |
265 | */ | 295 | */ |
266 | struct GNUNET_TESTING_Command | 296 | struct GNUNET_TESTING_Command |
@@ -296,27 +326,14 @@ struct GNUNET_TESTING_Command | |||
296 | struct GNUNET_TESTING_Interpreter *is); | 326 | struct GNUNET_TESTING_Interpreter *is); |
297 | 327 | ||
298 | /** | 328 | /** |
299 | * FIXME: logic is basically always the same! | 329 | * Pointer to the asynchronous context in the command's |
300 | * => Refactor API to avoid duplication! | 330 | * closure. Used by the |
331 | * #GNUNET_TESTING_async_finish() and | ||
332 | * #GNUNET_TESTING_async_fail() functions. | ||
301 | * | 333 | * |
302 | * Wait for any asynchronous execution of @e run to conclude, | 334 | * Must be NULL if a command is synchronous. |
303 | * then call finish_cont. Finish may only be called once per command. | ||
304 | * | ||
305 | * This member may be NULL if this command is a synchronous command, | ||
306 | * and also should be set to NULL once the command has finished. | ||
307 | * | ||
308 | * @param cls closure | ||
309 | * @param cont function to call upon completion, can be NULL | ||
310 | * @param cont_cls closure for @a cont | ||
311 | * @return | ||
312 | * #GNUNET_NO if the command is still running and @a cont will be called later | ||
313 | * #GNUNET_OK if the command completed successfully and @a cont was called | ||
314 | * #GNUNET_SYSERR if the operation @a cont was NOT called | ||
315 | */ | 335 | */ |
316 | enum GNUNET_GenericReturnValue | 336 | struct GNUNET_TESTING_AsyncContext *ac; |
317 | (*finish)(void *cls, | ||
318 | GNUNET_SCHEDULER_TaskCallback cont, | ||
319 | void *cont_cls); | ||
320 | 337 | ||
321 | /** | 338 | /** |
322 | * Clean up after the command. Run during forced termination | 339 | * Clean up after the command. Run during forced termination |
@@ -328,11 +345,8 @@ struct GNUNET_TESTING_Command | |||
328 | (*cleanup)(void *cls); | 345 | (*cleanup)(void *cls); |
329 | 346 | ||
330 | /** | 347 | /** |
331 | * FIXME: logic is often the same! | ||
332 | * => Think about refactoring API to reduce duplication! | ||
333 | * | ||
334 | * Extract information from a command that is useful for other | 348 | * Extract information from a command that is useful for other |
335 | * commands. | 349 | * commands. Can be NULL if a command has no traits. |
336 | * | 350 | * |
337 | * @param cls closure | 351 | * @param cls closure |
338 | * @param[out] ret result (could be anything) | 352 | * @param[out] ret result (could be anything) |
@@ -428,6 +442,24 @@ GNUNET_TESTING_interpreter_fail (struct GNUNET_TESTING_Interpreter *is); | |||
428 | 442 | ||
429 | 443 | ||
430 | /** | 444 | /** |
445 | * The asynchronous command of @a ac has failed. | ||
446 | * | ||
447 | * @param ac command-specific context | ||
448 | */ | ||
449 | void | ||
450 | GNUNET_TESTING_async_fail (struct GNUNET_TESTING_AsyncContext *ac); | ||
451 | |||
452 | |||
453 | /** | ||
454 | * The asynchronous command of @a ac has finished. | ||
455 | * | ||
456 | * @param ac command-specific context | ||
457 | */ | ||
458 | void | ||
459 | GNUNET_TESTING_async_finish (struct GNUNET_TESTING_AsyncContext *ac); | ||
460 | |||
461 | |||
462 | /** | ||
431 | * Create command array terminator. | 463 | * Create command array terminator. |
432 | * | 464 | * |
433 | * @return a end-command. | 465 | * @return a end-command. |
@@ -1116,7 +1148,6 @@ GNUNET_TESTING_cmd_stop_testing_system_v2 (const char *label, | |||
1116 | const char *topology_config); | 1148 | const char *topology_config); |
1117 | 1149 | ||
1118 | 1150 | ||
1119 | |||
1120 | // FIXME: document! | 1151 | // FIXME: document! |
1121 | enum GNUNET_GenericReturnValue | 1152 | enum GNUNET_GenericReturnValue |
1122 | GNUNET_TESTING_get_trait_helper_handles (const struct | 1153 | GNUNET_TESTING_get_trait_helper_handles (const struct |