aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_testing_ng_lib.h
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2021-10-15 21:02:03 +0200
committert3sserakt <t3ss@posteo.de>2021-10-15 21:02:03 +0200
commit513f23e74650db9408267e82ef8bcb8f770d1015 (patch)
tree312db7072dc444e9d1e6a13000b79482eb14de82 /src/include/gnunet_testing_ng_lib.h
parentd190d23831dae1a77075557f2ff6e0c713d747d5 (diff)
parentd64ac269856744b9bab170964e1d6f36896ecc55 (diff)
downloadgnunet-513f23e74650db9408267e82ef8bcb8f770d1015.tar.gz
gnunet-513f23e74650db9408267e82ef8bcb8f770d1015.zip
Merge branch 'master' into dev/t3ss/tng
Diffstat (limited to 'src/include/gnunet_testing_ng_lib.h')
-rw-r--r--src/include/gnunet_testing_ng_lib.h412
1 files changed, 180 insertions, 232 deletions
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h
index 6138f567b..96e9af252 100644
--- a/src/include/gnunet_testing_ng_lib.h
+++ b/src/include/gnunet_testing_ng_lib.h
@@ -49,6 +49,7 @@
49 49
50/** 50/**
51 * Router of a network namespace. 51 * Router of a network namespace.
52 * // FIXME: this does not belong here!
52 */ 53 */
53struct GNUNET_TESTING_NetjailRouter 54struct GNUNET_TESTING_NetjailRouter
54{ 55{
@@ -63,8 +64,10 @@ struct GNUNET_TESTING_NetjailRouter
63 unsigned int udp_port; 64 unsigned int udp_port;
64}; 65};
65 66
67
66/** 68/**
67 * Enum for the different types of nodes. 69 * Enum for the different types of nodes.
70 * // FIXME: this does not belong here!
68 */ 71 */
69enum GNUNET_TESTING_NODE_TYPE 72enum GNUNET_TESTING_NODE_TYPE
70{ 73{
@@ -79,6 +82,8 @@ enum GNUNET_TESTING_NODE_TYPE
79 GNUNET_TESTING_GLOBAL_NODE 82 GNUNET_TESTING_GLOBAL_NODE
80}; 83};
81 84
85
86// FIXME: this does not belong here!
82struct GNUNET_TESTING_AddressPrefix 87struct GNUNET_TESTING_AddressPrefix
83{ 88{
84 /** 89 /**
@@ -97,10 +102,13 @@ struct GNUNET_TESTING_AddressPrefix
97 char *address_prefix; 102 char *address_prefix;
98}; 103};
99 104
105
106// FIXME: this does not belong here!
100struct GNUNET_TESTING_NetjailNode; 107struct GNUNET_TESTING_NetjailNode;
101 108
102/** 109/**
103 * Connection to another node. 110 * Connection to another node.
111 * // FIXME: this does not belong here!
104 */ 112 */
105struct GNUNET_TESTING_NodeConnection 113struct GNUNET_TESTING_NodeConnection
106{ 114{
@@ -148,6 +156,7 @@ struct GNUNET_TESTING_NodeConnection
148 156
149/** 157/**
150 * Node in the netjail topology. 158 * Node in the netjail topology.
159 * // FIXME: this does not belong here!
151 */ 160 */
152struct GNUNET_TESTING_NetjailNode 161struct GNUNET_TESTING_NetjailNode
153{ 162{
@@ -185,6 +194,7 @@ struct GNUNET_TESTING_NetjailNode
185 194
186/** 195/**
187 * Namespace in a topology. 196 * Namespace in a topology.
197 * // FIXME: this does not belong here!
188 */ 198 */
189struct GNUNET_TESTING_NetjailNamespace 199struct GNUNET_TESTING_NetjailNamespace
190{ 200{
@@ -206,6 +216,7 @@ struct GNUNET_TESTING_NetjailNamespace
206 216
207/** 217/**
208 * Toplogy of our netjail setup. 218 * Toplogy of our netjail setup.
219 * // FIXME: this does not belong here!
209 */ 220 */
210struct GNUNET_TESTING_NetjailTopology 221struct GNUNET_TESTING_NetjailTopology
211{ 222{
@@ -251,6 +262,36 @@ struct GNUNET_TESTING_NetjailTopology
251struct GNUNET_TESTING_Interpreter; 262struct GNUNET_TESTING_Interpreter;
252 263
253/** 264/**
265 * State each asynchronous command must have in its closure.
266 */
267struct GNUNET_TESTING_AsyncContext
268{
269
270 /**
271 * Interpreter we are part of.
272 */
273 struct GNUNET_TESTING_Interpreter *is;
274
275 /**
276 * Function to call when done.
277 */
278 GNUNET_SCHEDULER_TaskCallback cont;
279
280 /**
281 * Closure for @e cont.
282 */
283 void *cont_cls;
284
285 /**
286 * Indication if the command finished (#GNUNET_OK).
287 * #GNUNET_NO if it is still running,
288 * #GNUNET_SYSERR if it failed.
289 */
290 enum GNUNET_GenericReturnValue finished;
291};
292
293
294/**
254 * A command to be run by the interpreter. 295 * A command to be run by the interpreter.
255 */ 296 */
256struct GNUNET_TESTING_Command 297struct GNUNET_TESTING_Command
@@ -279,57 +320,43 @@ struct GNUNET_TESTING_Command
279 * the asynchronous activity to terminate. 320 * the asynchronous activity to terminate.
280 * 321 *
281 * @param cls closure 322 * @param cls closure
282 * @param cmd command being run 323 * @param is interpreter state
283 * @param i interpreter state
284 */ 324 */
285 void 325 void
286 (*run)(void *cls, 326 (*run)(void *cls,
287 const struct GNUNET_TESTING_Command *cmd, 327 struct GNUNET_TESTING_Interpreter *is);
288 struct GNUNET_TESTING_Interpreter *i);
289 328
290 /** 329 /**
291 * Wait for any asynchronous execution of @e run to conclude, 330 * Pointer to the asynchronous context in the command's
292 * then call finish_cont. Finish may only be called once per command. 331 * closure. Used by the
293 * 332 * #GNUNET_TESTING_async_finish() and
294 * This member may be NULL if this command is a synchronous command, 333 * #GNUNET_TESTING_async_fail() functions.
295 * and also should be set to NULL once the command has finished.
296 * 334 *
297 * @param cls closure 335 * Must be NULL if a command is synchronous.
298 * @param cont function to call upon completion, can be NULL
299 * @param cont_cls closure for @a cont
300 */
301 int
302 (*finish)(void *cls,
303 GNUNET_SCHEDULER_TaskCallback cont,
304 void *cont_cls);
305
306 /**
307 * Task for running the finish function.
308 */ 336 */
309 struct GNUNET_SCHEDULER_Task *finish_task; 337 struct GNUNET_TESTING_AsyncContext *ac;
310 338
311 /** 339 /**
312 * Clean up after the command. Run during forced termination 340 * Clean up after the command. Run during forced termination
313 * (CTRL-C) or test failure or test success. 341 * (CTRL-C) or test failure or test success.
314 * 342 *
315 * @param cls closure 343 * @param cls closure
316 * @param cmd command being cleaned up
317 */ 344 */
318 void 345 void
319 (*cleanup)(void *cls, 346 (*cleanup)(void *cls);
320 const struct GNUNET_TESTING_Command *cmd);
321 347
322 /** 348 /**
323 * Extract information from a command that is useful for other 349 * Extract information from a command that is useful for other
324 * commands. 350 * commands. Can be NULL if a command has no traits.
325 * 351 *
326 * @param cls closure 352 * @param cls closure
327 * @param[out] ret result (could be anything) 353 * @param[out] ret result (could be anything)
328 * @param trait name of the trait 354 * @param trait name of the trait
329 * @param index index number of the object to extract. 355 * @param index index number of the object to extract.
330 * @return #GNUNET_OK on success 356 * @return #GNUNET_OK on success,
357 * #GNUNET_NO if no trait was found
331 */ 358 */
332 int 359 enum GNUNET_GenericReturnValue
333 (*traits)(void *cls, 360 (*traits)(void *cls,
334 const void **ret, 361 const void **ret,
335 const char *trait, 362 const char *trait,
@@ -357,13 +384,6 @@ struct GNUNET_TESTING_Command
357 struct GNUNET_TIME_Absolute last_req_time; 384 struct GNUNET_TIME_Absolute last_req_time;
358 385
359 /** 386 /**
360 * How often did we try to execute this command? (In case it is a request
361 * that is repated.) Note that a command must have some built-in retry
362 * mechanism for this value to be useful.
363 */
364 unsigned int num_tries;
365
366 /**
367 * In case @e asynchronous_finish is true, how long should we wait for this 387 * In case @e asynchronous_finish is true, how long should we wait for this
368 * command to complete? If @e finish did not complete after this amount of 388 * command to complete? If @e finish did not complete after this amount of
369 * time, the interpreter will fail. Should be set generously to ensure 389 * time, the interpreter will fail. Should be set generously to ensure
@@ -372,6 +392,13 @@ struct GNUNET_TESTING_Command
372 struct GNUNET_TIME_Relative default_timeout; 392 struct GNUNET_TIME_Relative default_timeout;
373 393
374 /** 394 /**
395 * How often did we try to execute this command? (In case it is a request
396 * that is repated.) Note that a command must have some built-in retry
397 * mechanism for this value to be useful.
398 */
399 unsigned int num_tries;
400
401 /**
375 * If "true", the interpreter should not immediately call 402 * If "true", the interpreter should not immediately call
376 * @e finish, even if @e finish is non-NULL. Otherwise, 403 * @e finish, even if @e finish is non-NULL. Otherwise,
377 * #TALER_TESTING_cmd_finish() must be used 404 * #TALER_TESTING_cmd_finish() must be used
@@ -379,49 +406,19 @@ struct GNUNET_TESTING_Command
379 */ 406 */
380 bool asynchronous_finish; 407 bool asynchronous_finish;
381 408
382 /**
383 * Shall the scheduler shutdown, when end cmd is reach?
384 */
385 bool shutdown_on_end;
386
387}; 409};
388 410
389 411
390/** 412/**
391 * Struct to use for command-specific context information closure of a command waiting
392 * for another command.
393 */
394struct SyncState
395{
396 /**
397 * Closure for all commands with command-specific context information.
398 */
399 void *cls;
400
401 /**
402 * The asynchronous command the synchronous command of this closure waits for.
403 */
404 const struct GNUNET_TESTING_Command *async_cmd;
405
406 /**
407 * Task for running the finish method of the asynchronous task the command is waiting for.
408 */
409 struct GNUNET_SCHEDULER_Task *finish_task;
410
411 /**
412 * When did the execution of this commands finish function start?
413 */
414 struct GNUNET_TIME_Absolute start_finish_time;
415};
416
417/**
418 * Lookup command by label. 413 * Lookup command by label.
419 * 414 *
415 * @param is interpreter to lookup command in
420 * @param label label of the command to lookup. 416 * @param label label of the command to lookup.
421 * @return the command, if it is found, or NULL. 417 * @return the command, if it is found, or NULL.
422 */ 418 */
423const struct GNUNET_TESTING_Command * 419const struct GNUNET_TESTING_Command *
424GNUNET_TESTING_interpreter_lookup_command ( 420GNUNET_TESTING_interpreter_lookup_command (
421 struct GNUNET_TESTING_Interpreter *is,
425 const char *label); 422 const char *label);
426 423
427 424
@@ -442,25 +439,34 @@ GNUNET_TESTING_interpreter_get_current_label (
442 * @param is interpreter state. 439 * @param is interpreter state.
443 */ 440 */
444void 441void
445GNUNET_TESTING_interpreter_fail (); 442GNUNET_TESTING_interpreter_fail (struct GNUNET_TESTING_Interpreter *is);
446 443
447 444
448/** 445/**
449 * Create command array terminator. 446 * The asynchronous command of @a ac has failed.
450 * 447 *
451 * @return a end-command. 448 * @param ac command-specific context
452 */ 449 */
453struct GNUNET_TESTING_Command 450void
454GNUNET_TESTING_cmd_end (void); 451GNUNET_TESTING_async_fail (struct GNUNET_TESTING_AsyncContext *ac);
455 452
456 453
457/** 454/**
458 * Create command array terminator without shutdown. 455 * The asynchronous command of @a ac has finished.
456 *
457 * @param ac command-specific context
458 */
459void
460GNUNET_TESTING_async_finish (struct GNUNET_TESTING_AsyncContext *ac);
461
462
463/**
464 * Create command array terminator.
459 * 465 *
460 * @return a end-command. 466 * @return a end-command.
461 */ 467 */
462struct GNUNET_TESTING_Command 468struct GNUNET_TESTING_Command
463GNUNET_TESTING_cmd_end_without_shutdown (void); 469GNUNET_TESTING_cmd_end (void);
464 470
465 471
466/** 472/**
@@ -469,8 +475,8 @@ GNUNET_TESTING_cmd_end_without_shutdown (void);
469 * @param cmd command to make synchronous. 475 * @param cmd command to make synchronous.
470 * @return a finish-command. 476 * @return a finish-command.
471 */ 477 */
472const struct GNUNET_TESTING_Command 478struct GNUNET_TESTING_Command
473GNUNET_TESTING_cmd_make_unblocking (const struct GNUNET_TESTING_Command cmd); 479GNUNET_TESTING_cmd_make_unblocking (struct GNUNET_TESTING_Command cmd);
474 480
475 481
476/** 482/**
@@ -506,31 +512,46 @@ GNUNET_TESTING_cmd_rewind_ip (const char *label,
506 512
507 513
508/** 514/**
509 * Wait until we receive SIGCHLD signal. Then obtain the process trait of the 515 * Function called with the final result of the test.
510 * current command, wait on the the zombie and continue with the next command.
511 * 516 *
512 * @param is interpreter state. 517 * @param cls closure
518 * @param rv #GNUNET_OK if the test passed
519 */
520typedef void
521(*GNUNET_TESTING_ResultCallback)(void *cls,
522 enum GNUNET_GenericReturnValue rv);
523
524
525/**
526 * Run the testsuite. Note, CMDs are copied into
527 * the interpreter state because they are _usually_
528 * defined into the "run" method that returns after
529 * having scheduled the test interpreter.
530 *
531 * @param commands the list of command to execute
532 * @param timeout how long to wait for each command to execute
533 * @param rc function to call with the final result
534 * @param rc_cls closure for @a rc
513 */ 535 */
514// void 536void
515// GNUNET_TESTING_wait_for_sigchld (struct GNUNET_TESTING_Interpreter *is); 537GNUNET_TESTING_run (struct GNUNET_TESTING_Command *commands,
516// => replace with child_management.c 538 struct GNUNET_TIME_Relative timeout,
539 GNUNET_TESTING_ResultCallback rc,
540 void *rc_cls);
517 541
518 542
519/** 543/**
520 * Start scheduling loop with signal handlers and run the 544 * Start a GNUnet scheduler event loop and
521 * test suite with the @a commands. 545 * run the testsuite. Return 0 upon success.
546 * Expected to be called directly from main().
522 * 547 *
523 * @param cfg_name name of configuration file to use
524 * @param commands the list of command to execute 548 * @param commands the list of command to execute
525 * @param timeout how long to wait for each command to execute 549 * @param timeout how long to wait for each command to execute
526 * @return #GNUNET_OK if all is okay, != #GNUNET_OK otherwise. 550 * @return EXIT_SUCCESS on success, EXIT_FAILURE on failure
527 * non-GNUNET_OK codes are #GNUNET_SYSERR most of the
528 * times.
529 */ 551 */
530int 552int
531GNUNET_TESTING_run (const char *cfg_filename, 553GNUNET_TESTING_main (struct GNUNET_TESTING_Command *commands,
532 struct GNUNET_TESTING_Command *commands, 554 struct GNUNET_TIME_Relative timeout);
533 struct GNUNET_TIME_Relative timeout);
534 555
535 556
536/** 557/**
@@ -538,6 +559,8 @@ GNUNET_TESTING_run (const char *cfg_filename,
538 * 559 *
539 * @param prog program's name to look into 560 * @param prog program's name to look into
540 * @param marker chunk to find in @a prog 561 * @param marker chunk to find in @a prog
562 * // FIXME: this does not belong here! => libgnunetutil, maybe?
563 * // FIXME: return bool? document return value!
541 */ 564 */
542int 565int
543GNUNET_TESTING_has_in_name (const char *prog, 566GNUNET_TESTING_has_in_name (const char *prog,
@@ -551,7 +574,7 @@ GNUNET_TESTING_has_in_name (const char *prog,
551 * 574 *
552 * @param label command label. 575 * @param label command label.
553 * @param process_label label of a command that has a process trait 576 * @param process_label label of a command that has a process trait
554 * @param process_index index of the process trait at @a process_label 577 * @param process_index index of the process trait at @a process_label // FIXME: enum? needed?
555 * @param signal signal to send to @a process. 578 * @param signal signal to send to @a process.
556 * @return the command. 579 * @return the command.
557 */ 580 */
@@ -590,49 +613,8 @@ GNUNET_TESTING_cmd_batch (const char *label,
590 613
591 614
592/** 615/**
593 * Test if this command is a batch command.
594 *
595 * @return false if not, true if it is a batch command
596 */
597// TODO: figure out if this needs to be exposed in the public API.
598int
599GNUNET_TESTING_cmd_is_batch (const struct GNUNET_TESTING_Command *cmd);
600
601
602/**
603 * Advance internal pointer to next command.
604 *
605 * @param is interpreter state.
606 */
607// TODO: figure out if this needs to be exposed in the public API.
608void
609GNUNET_TESTING_cmd_batch_next (struct GNUNET_TESTING_Interpreter *is);
610
611
612/**
613 * Obtain what command the batch is at.
614 *
615 * @return cmd current batch command
616 */
617// TODO: figure out if this needs to be exposed in the public API.
618struct GNUNET_TESTING_Command *
619GNUNET_TESTING_cmd_batch_get_current (const struct GNUNET_TESTING_Command *cmd);
620
621
622/**
623 * Set what command the batch should be at.
624 *
625 * @param cmd current batch command
626 * @param new_ip where to move the IP
627 */
628// TODO: figure out if this needs to be exposed in the public API.
629void
630GNUNET_TESTING_cmd_batch_set_current (const struct GNUNET_TESTING_Command *cmd,
631 unsigned int new_ip);
632
633
634/**
635 * Performance counter. 616 * Performance counter.
617 * // FIXME: this might not belong here!
636 */ 618 */
637struct GNUNET_TESTING_Timer 619struct GNUNET_TESTING_Timer
638{ 620{
@@ -777,7 +759,7 @@ GNUNET_TESTING_trait_end (void);
777 * @param index index number of the trait to extract. 759 * @param index index number of the trait to extract.
778 * @return #GNUNET_OK when the trait is found. 760 * @return #GNUNET_OK when the trait is found.
779 */ 761 */
780int 762enum GNUNET_GenericReturnValue
781GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits, 763GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits,
782 const void **ret, 764 const void **ret,
783 const char *trait, 765 const char *trait,
@@ -791,12 +773,12 @@ GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits,
791 * 773 *
792 * @param cmd command to extract trait from. 774 * @param cmd command to extract trait from.
793 * @param index which process to pick if @a cmd 775 * @param index which process to pick if @a cmd
794 * has multiple on offer. 776 * has multiple on offer. -- FIXME: remove?
795 * @param[out] processp set to the address of the pointer to the 777 * @param[out] processp set to the address of the pointer to the
796 * process. 778 * process.
797 * @return #GNUNET_OK on success. 779 * @return #GNUNET_OK on success.
798 */ 780 */
799int 781enum GNUNET_GenericReturnValue
800GNUNET_TESTING_get_trait_process (const struct GNUNET_TESTING_Command *cmd, 782GNUNET_TESTING_get_trait_process (const struct GNUNET_TESTING_Command *cmd,
801 unsigned int index, 783 unsigned int index,
802 struct GNUNET_OS_Process ***processp); 784 struct GNUNET_OS_Process ***processp);
@@ -806,7 +788,7 @@ GNUNET_TESTING_get_trait_process (const struct GNUNET_TESTING_Command *cmd,
806 * Offer location where a command stores a pointer to a process. 788 * Offer location where a command stores a pointer to a process.
807 * 789 *
808 * @param index offered location index number, in case there are 790 * @param index offered location index number, in case there are
809 * multiple on offer. 791 * multiple on offer. // FIXME: remove?
810 * @param processp process location to offer. 792 * @param processp process location to offer.
811 * @return the trait. 793 * @return the trait.
812 */ 794 */
@@ -818,7 +800,7 @@ GNUNET_TESTING_make_trait_process (unsigned int index,
818/** 800/**
819 * Offer number trait, 32-bit version. 801 * Offer number trait, 32-bit version.
820 * 802 *
821 * @param index the number's index number. 803 * @param index the number's index number. // FIXME: introduce enum?
822 * @param n number to offer. 804 * @param n number to offer.
823 */ 805 */
824struct GNUNET_TESTING_Trait 806struct GNUNET_TESTING_Trait
@@ -830,11 +812,11 @@ GNUNET_TESTING_make_trait_uint32 (unsigned int index,
830 * Obtain a "number" value from @a cmd, 32-bit version. 812 * Obtain a "number" value from @a cmd, 32-bit version.
831 * 813 *
832 * @param cmd command to extract the number from. 814 * @param cmd command to extract the number from.
833 * @param index the number's index number. 815 * @param index the number's index number. // FIXME: introduce enum?
834 * @param[out] n set to the number coming from @a cmd. 816 * @param[out] n set to the number coming from @a cmd.
835 * @return #GNUNET_OK on success. 817 * @return #GNUNET_OK on success.
836 */ 818 */
837int 819enum GNUNET_GenericReturnValue
838GNUNET_TESTING_get_trait_uint32 (const struct GNUNET_TESTING_Command *cmd, 820GNUNET_TESTING_get_trait_uint32 (const struct GNUNET_TESTING_Command *cmd,
839 unsigned int index, 821 unsigned int index,
840 const uint32_t **n); 822 const uint32_t **n);
@@ -843,7 +825,7 @@ GNUNET_TESTING_get_trait_uint32 (const struct GNUNET_TESTING_Command *cmd,
843/** 825/**
844 * Offer number trait, 64-bit version. 826 * Offer number trait, 64-bit version.
845 * 827 *
846 * @param index the number's index number. 828 * @param index the number's index number. // FIXME: introduce enum?
847 * @param n number to offer. 829 * @param n number to offer.
848 */ 830 */
849struct GNUNET_TESTING_Trait 831struct GNUNET_TESTING_Trait
@@ -855,11 +837,11 @@ GNUNET_TESTING_make_trait_uint64 (unsigned int index,
855 * Obtain a "number" value from @a cmd, 64-bit version. 837 * Obtain a "number" value from @a cmd, 64-bit version.
856 * 838 *
857 * @param cmd command to extract the number from. 839 * @param cmd command to extract the number from.
858 * @param index the number's index number. 840 * @param index the number's index number. // FIXME: introduce enum?
859 * @param[out] n set to the number coming from @a cmd. 841 * @param[out] n set to the number coming from @a cmd.
860 * @return #GNUNET_OK on success. 842 * @return #GNUNET_OK on success.
861 */ 843 */
862int 844enum GNUNET_GenericReturnValue
863GNUNET_TESTING_get_trait_uint64 (const struct GNUNET_TESTING_Command *cmd, 845GNUNET_TESTING_get_trait_uint64 (const struct GNUNET_TESTING_Command *cmd,
864 unsigned int index, 846 unsigned int index,
865 const uint64_t **n); 847 const uint64_t **n);
@@ -868,7 +850,7 @@ GNUNET_TESTING_get_trait_uint64 (const struct GNUNET_TESTING_Command *cmd,
868/** 850/**
869 * Offer number trait, 64-bit signed version. 851 * Offer number trait, 64-bit signed version.
870 * 852 *
871 * @param index the number's index number. 853 * @param index the number's index number. // FIXME: introduce enum?
872 * @param n number to offer. 854 * @param n number to offer.
873 */ 855 */
874struct GNUNET_TESTING_Trait 856struct GNUNET_TESTING_Trait
@@ -880,11 +862,11 @@ GNUNET_TESTING_make_trait_int64 (unsigned int index,
880 * Obtain a "number" value from @a cmd, 64-bit signed version. 862 * Obtain a "number" value from @a cmd, 64-bit signed version.
881 * 863 *
882 * @param cmd command to extract the number from. 864 * @param cmd command to extract the number from.
883 * @param index the number's index number. 865 * @param index the number's index number. // FIXME: introduce enum?
884 * @param[out] n set to the number coming from @a cmd. 866 * @param[out] n set to the number coming from @a cmd.
885 * @return #GNUNET_OK on success. 867 * @return #GNUNET_OK on success.
886 */ 868 */
887int 869enum GNUNET_GenericReturnValue
888GNUNET_TESTING_get_trait_int64 (const struct GNUNET_TESTING_Command *cmd, 870GNUNET_TESTING_get_trait_int64 (const struct GNUNET_TESTING_Command *cmd,
889 unsigned int index, 871 unsigned int index,
890 const int64_t **n); 872 const int64_t **n);
@@ -894,7 +876,7 @@ GNUNET_TESTING_get_trait_int64 (const struct GNUNET_TESTING_Command *cmd,
894 * Offer a number. 876 * Offer a number.
895 * 877 *
896 * @param index the number's index number. 878 * @param index the number's index number.
897 * @param n the number to offer. 879 * @param n the number to offer. // FIXME: introduce enum?
898 * @return #GNUNET_OK on success. 880 * @return #GNUNET_OK on success.
899 */ 881 */
900struct GNUNET_TESTING_Trait 882struct GNUNET_TESTING_Trait
@@ -906,11 +888,11 @@ GNUNET_TESTING_make_trait_uint (unsigned int index,
906 * Obtain a number from @a cmd. 888 * Obtain a number from @a cmd.
907 * 889 *
908 * @param cmd command to extract the number from. 890 * @param cmd command to extract the number from.
909 * @param index the number's index number. 891 * @param index the number's index number. // FIXME: introduce enum?
910 * @param[out] n set to the number coming from @a cmd. 892 * @param[out] n set to the number coming from @a cmd.
911 * @return #GNUNET_OK on success. 893 * @return #GNUNET_OK on success.
912 */ 894 */
913int 895enum GNUNET_GenericReturnValue
914GNUNET_TESTING_get_trait_uint (const struct GNUNET_TESTING_Command *cmd, 896GNUNET_TESTING_get_trait_uint (const struct GNUNET_TESTING_Command *cmd,
915 unsigned int index, 897 unsigned int index,
916 const unsigned int **n); 898 const unsigned int **n);
@@ -920,12 +902,12 @@ GNUNET_TESTING_get_trait_uint (const struct GNUNET_TESTING_Command *cmd,
920 * 902 *
921 * @param cmd command to extract the subject from. 903 * @param cmd command to extract the subject from.
922 * @param index index number associated with the transfer 904 * @param index index number associated with the transfer
923 * subject to offer. 905 * subject to offer. // FIXME: introduce enum?
924 * @param[out] s where to write the offered 906 * @param[out] s where to write the offered
925 * string. 907 * string.
926 * @return #GNUNET_OK on success. 908 * @return #GNUNET_OK on success.
927 */ 909 */
928int 910enum GNUNET_GenericReturnValue
929GNUNET_TESTING_get_trait_string ( 911GNUNET_TESTING_get_trait_string (
930 const struct GNUNET_TESTING_Command *cmd, 912 const struct GNUNET_TESTING_Command *cmd,
931 unsigned int index, 913 unsigned int index,
@@ -936,7 +918,7 @@ GNUNET_TESTING_get_trait_string (
936 * Offer string subject. 918 * Offer string subject.
937 * 919 *
938 * @param index index number associated with the transfer 920 * @param index index number associated with the transfer
939 * subject being offered. 921 * subject being offered. // FIXME: introduce enum?
940 * @param s string to offer. 922 * @param s string to offer.
941 * @return the trait. 923 * @return the trait.
942 */ 924 */
@@ -950,9 +932,8 @@ GNUNET_TESTING_make_trait_string (unsigned int index,
950 * @param index always zero. Commands offering this 932 * @param index always zero. Commands offering this
951 * kind of traits do not need this index. For 933 * kind of traits do not need this index. For
952 * example, a "meta" CMD returns always the 934 * example, a "meta" CMD returns always the
953 * CMD currently being executed. 935 * CMD currently being executed. FIXME: remove!
954 * @param cmd wire details to offer. 936 * @param cmd wire details to offer.
955 *
956 * @return the trait. 937 * @return the trait.
957 */ 938 */
958struct GNUNET_TESTING_Trait 939struct GNUNET_TESTING_Trait
@@ -967,11 +948,11 @@ GNUNET_TESTING_make_trait_cmd (unsigned int index,
967 * @param index always zero. Commands offering this 948 * @param index always zero. Commands offering this
968 * kind of traits do not need this index. For 949 * kind of traits do not need this index. For
969 * example, a "meta" CMD returns always the 950 * example, a "meta" CMD returns always the
970 * CMD currently being executed. 951 * CMD currently being executed. FIXME: remove!
971 * @param[out] _cmd where to write the wire details. 952 * @param[out] _cmd where to write the wire details.
972 * @return #GNUNET_OK on success. 953 * @return #GNUNET_OK on success.
973 */ 954 */
974int 955enum GNUNET_GenericReturnValue
975GNUNET_TESTING_get_trait_cmd (const struct GNUNET_TESTING_Command *cmd, 956GNUNET_TESTING_get_trait_cmd (const struct GNUNET_TESTING_Command *cmd,
976 unsigned int index, 957 unsigned int index,
977 struct GNUNET_TESTING_Command **_cmd); 958 struct GNUNET_TESTING_Command **_cmd);
@@ -982,11 +963,11 @@ GNUNET_TESTING_get_trait_cmd (const struct GNUNET_TESTING_Command *cmd,
982 * 963 *
983 * @param cmd command to extract the uuid from. 964 * @param cmd command to extract the uuid from.
984 * @param index which amount to pick if @a cmd has multiple 965 * @param index which amount to pick if @a cmd has multiple
985 * on offer 966 * on offer // FIXME: introduce enum?
986 * @param[out] uuid where to write the uuid. 967 * @param[out] uuid where to write the uuid.
987 * @return #GNUNET_OK on success. 968 * @return #GNUNET_OK on success.
988 */ 969 */
989int 970enum GNUNET_GenericReturnValue
990GNUNET_TESTING_get_trait_uuid (const struct GNUNET_TESTING_Command *cmd, 971GNUNET_TESTING_get_trait_uuid (const struct GNUNET_TESTING_Command *cmd,
991 unsigned int index, 972 unsigned int index,
992 struct GNUNET_Uuid **uuid); 973 struct GNUNET_Uuid **uuid);
@@ -996,9 +977,8 @@ GNUNET_TESTING_get_trait_uuid (const struct GNUNET_TESTING_Command *cmd,
996 * Offer a uuid in a trait. 977 * Offer a uuid in a trait.
997 * 978 *
998 * @param index which uuid to offer, in case there are 979 * @param index which uuid to offer, in case there are
999 * multiple available. 980 * multiple available. // FIXME: introduce enum?
1000 * @param uuid the uuid to offer. 981 * @param uuid the uuid to offer.
1001 *
1002 * @return the trait. 982 * @return the trait.
1003 */ 983 */
1004struct GNUNET_TESTING_Trait 984struct GNUNET_TESTING_Trait
@@ -1011,11 +991,11 @@ GNUNET_TESTING_make_trait_uuid (unsigned int index,
1011 * 991 *
1012 * @param cmd command to extract trait from 992 * @param cmd command to extract trait from
1013 * @param index which time stamp to pick if 993 * @param index which time stamp to pick if
1014 * @a cmd has multiple on offer. 994 * @a cmd has multiple on offer // FIXME: introduce enum?
1015 * @param[out] time set to the wanted WTID. 995 * @param[out] time set to the wanted WTID.
1016 * @return #GNUNET_OK on success 996 * @return #GNUNET_OK on success
1017 */ 997 */
1018int 998enum GNUNET_GenericReturnValue
1019GNUNET_TESTING_get_trait_absolute_time ( 999GNUNET_TESTING_get_trait_absolute_time (
1020 const struct GNUNET_TESTING_Command *cmd, 1000 const struct GNUNET_TESTING_Command *cmd,
1021 unsigned int index, 1001 unsigned int index,
@@ -1064,6 +1044,9 @@ GNUNET_TESTING_make_trait_relative_time (
1064 const struct GNUNET_TIME_Relative *time); 1044 const struct GNUNET_TIME_Relative *time);
1065 1045
1066 1046
1047// FIXME: move these commands into a separate libgnunetestingnetjail lib or so!
1048
1049
1067/** 1050/**
1068 * Create command. 1051 * Create command.
1069 * 1052 *
@@ -1121,40 +1104,12 @@ GNUNET_TESTING_cmd_system_destroy (const char *label,
1121 * Create command. 1104 * Create command.
1122 * 1105 *
1123 * @param label name for command. 1106 * @param label name for command.
1124 * @param local_m Number of local nodes in each namespace.
1125 * @param global_n The number of namespaces.
1126 * @return command.
1127 */
1128struct GNUNET_TESTING_Command
1129GNUNET_TESTING_cmd_netjail_start (const char *label,
1130 char *local_m,
1131 char *global_n);
1132
1133/**
1134 * Create command.
1135 *
1136 * @param label name for command.
1137 * @param topology_config Configuration file for the test topology. 1107 * @param topology_config Configuration file for the test topology.
1138 * @return command. 1108 * @return command.
1139 */ 1109 */
1140struct GNUNET_TESTING_Command 1110struct GNUNET_TESTING_Command
1141GNUNET_TESTING_cmd_netjail_start_v2 (const char *label, 1111GNUNET_TESTING_cmd_netjail_start (const char *label,
1142 char *topology_config); 1112 char *topology_config);
1143
1144
1145/**
1146 * Create command.
1147 *
1148 * @param label name for command.
1149 * @param binaryname to exec.
1150 * @return command.
1151 */
1152struct GNUNET_TESTING_Command
1153GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label,
1154 char *local_m,
1155 char *global_n,
1156 char *plugin_name,
1157 unsigned int *rv);
1158 1113
1159 1114
1160/** 1115/**
@@ -1166,22 +1121,20 @@ GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label,
1166 * @return command. 1121 * @return command.
1167 */ 1122 */
1168struct GNUNET_TESTING_Command 1123struct GNUNET_TESTING_Command
1169GNUNET_TESTING_cmd_netjail_start_testing_system_v2 (const char *label, 1124GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label,
1170 const char *topology_config, 1125 const char *topology_config);
1171 unsigned int *rv);
1172 1126
1173 1127
1174/** 1128/**
1175 * Create command. 1129 * Create command.
1176 * 1130 *
1177 * @param label name for command. 1131 * @param label name for command.
1178 * @param binaryname to stop. 1132 * @param topology_config Configuration file for the test topology.
1179 * @return command. 1133 * @return command.
1180 */ 1134 */
1181struct GNUNET_TESTING_Command 1135struct GNUNET_TESTING_Command
1182GNUNET_TESTING_cmd_netjail_stop (const char *label, 1136GNUNET_TESTING_cmd_netjail_stop (const char *label,
1183 char *local_m, 1137 char *topology_config);
1184 char *global_n);
1185 1138
1186 1139
1187/** 1140/**
@@ -1192,33 +1145,31 @@ GNUNET_TESTING_cmd_netjail_stop (const char *label,
1192 * @return command. 1145 * @return command.
1193 */ 1146 */
1194struct GNUNET_TESTING_Command 1147struct GNUNET_TESTING_Command
1195GNUNET_TESTING_cmd_netjail_stop_v2 (const char *label,
1196 char *topology_config);
1197
1198
1199struct GNUNET_TESTING_Command
1200GNUNET_TESTING_cmd_stop_testing_system (const char *label, 1148GNUNET_TESTING_cmd_stop_testing_system (const char *label,
1201 const char *helper_start_label, 1149 const char *helper_start_label,
1202 char *local_m, 1150 const char *topology_config);
1203 char *global_n); 1151
1204 1152
1205/** 1153/**
1206 * Create command. 1154 * Create a GNUNET_CMDS_LOCAL_FINISHED message.
1207 * 1155 *
1208 * @param label name for command. 1156 * @param rv The result of the local test as GNUNET_GenericReturnValue.
1209 * @param topology_config Configuration file for the test topology. 1157 * @return The GNUNET_CMDS_LOCAL_FINISHED message.
1210 * @return command. 1158*/
1211 */ 1159struct GNUNET_MessageHeader *
1212struct GNUNET_TESTING_Command 1160GNUNET_TESTING_send_local_test_finished_msg (enum GNUNET_GenericReturnValue rv);
1213GNUNET_TESTING_cmd_stop_testing_system_v2 (const char *label,
1214 const char *helper_start_label,
1215 const char *topology_config);
1216 1161
1217 1162
1163/**
1164 * Function to get the trait with the async context.
1165 *
1166 * @param[out] ac GNUNET_TESTING_AsyncContext.
1167 * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
1168 */
1218int 1169int
1219GNUNET_TESTING_get_trait_helper_handles (const struct 1170GNUNET_TESTING_get_trait_async_context (
1220 GNUNET_TESTING_Command *cmd, 1171 const struct GNUNET_TESTING_Command *cmd,
1221 struct GNUNET_HELPER_Handle ***helper); 1172 struct GNUNET_TESTING_AsyncContext **ac);
1222 1173
1223 1174
1224/** 1175/**
@@ -1228,24 +1179,21 @@ GNUNET_TESTING_get_trait_helper_handles (const struct
1228 * @param pt pointer to message. 1179 * @param pt pointer to message.
1229 * @return #GNUNET_OK on success. 1180 * @return #GNUNET_OK on success.
1230 */ 1181 */
1231int 1182enum GNUNET_GenericReturnValue
1232GNUNET_TESTING_get_trait_helper_handles_v2 (const struct 1183GNUNET_TESTING_get_trait_helper_handles (
1233 GNUNET_TESTING_Command *cmd, 1184 const struct GNUNET_TESTING_Command *cmd,
1234 struct GNUNET_HELPER_Handle *** 1185 struct GNUNET_HELPER_Handle ***helper);
1235 helper);
1236 1186
1237 1187
1238struct GNUNET_TESTING_Command 1188struct GNUNET_TESTING_Command
1239GNUNET_TESTING_cmd_block_until_all_peers_started (const char *label, 1189GNUNET_TESTING_cmd_block_until_all_peers_started (
1240 unsigned int * 1190 const char *label,
1241 all_peers_started); 1191 unsigned int *all_peers_started);
1242 1192
1243 1193
1244struct GNUNET_TESTING_Command 1194struct GNUNET_TESTING_Command
1245GNUNET_TESTING_cmd_block_until_external_trigger (const char *label, 1195GNUNET_TESTING_cmd_block_until_external_trigger (
1246 unsigned int * 1196 const char *label);
1247 stop_blocking);
1248
1249 1197
1250struct GNUNET_TESTING_Command 1198struct GNUNET_TESTING_Command
1251GNUNET_TESTING_cmd_send_peer_ready (const char *label, 1199GNUNET_TESTING_cmd_send_peer_ready (const char *label,
@@ -1260,9 +1208,9 @@ GNUNET_TESTING_cmd_send_peer_ready (const char *label,
1260 * @return command. 1208 * @return command.
1261 */ 1209 */
1262struct GNUNET_TESTING_Command 1210struct GNUNET_TESTING_Command
1263GNUNET_TESTING_cmd_local_test_finished (const char *label, 1211GNUNET_TESTING_cmd_local_test_finished (
1264 TESTING_CMD_HELPER_write_cb 1212 const char *label,
1265 write_message); 1213 TESTING_CMD_HELPER_write_cb write_message);
1266 1214
1267/** 1215/**
1268 * Create command. 1216 * Create command.