GNUnet  0.11.x
Data Fields
GNUNET_TESTING_Command Struct Reference

A command to be run by the interpreter. More...

#include <gnunet_testing_ng_lib.h>

Collaboration diagram for GNUNET_TESTING_Command:
[legend]

Data Fields

void * cls
 Closure for all commands with command-specific context information. More...
 
const char * label
 Label for the command. More...
 
void(* run )(void *cls, const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Interpreter *i)
 Runs the command. More...
 
bool(* finish )(void *cls, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
 Wait for any asynchronous execution of run to conclude, then call finish_cont. More...
 
struct GNUNET_SCHEDULER_Taskfinish_task
 Task for running the finish function. More...
 
void(* cleanup )(void *cls, const struct GNUNET_TESTING_Command *cmd)
 Clean up after the command. More...
 
int(* traits )(void *cls, const void **ret, const char *trait, unsigned int index)
 Extract information from a command that is useful for other commands. More...
 
struct GNUNET_TIME_Absolute start_time
 When did the execution of this command start? More...
 
struct GNUNET_TIME_Absolute finish_time
 When did the execution of this command finish? More...
 
struct GNUNET_TIME_Absolute last_req_time
 When did we start the last run of this command? Delta to finish_time gives the latency for the last successful run. More...
 
unsigned int num_tries
 How often did we try to execute this command? (In case it is a request that is repated.) Note that a command must have some built-in retry mechanism for this value to be useful. More...
 
struct GNUNET_TIME_Relative default_timeout
 In case asynchronous_finish is true, how long should we wait for this command to complete? If finish did not complete after this amount of time, the interpreter will fail. More...
 
bool asynchronous_finish
 If "true", the interpreter should not immediately call finish, even if finish is non-NULL. More...
 

Detailed Description

A command to be run by the interpreter.

Definition at line 59 of file gnunet_testing_ng_lib.h.

Field Documentation

◆ cls

void* GNUNET_TESTING_Command::cls

◆ label

const char* GNUNET_TESTING_Command::label

◆ run

void(* GNUNET_TESTING_Command::run) (void *cls, const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Interpreter *i)

Runs the command.

Note that upon return, the interpreter will not automatically run the next command, as the command may continue asynchronously in other scheduler tasks. Thus, the command must ensure to eventually call #GNUNET_TESTING_interpreter_next() or GNUNET_TESTING_interpreter_fail().

If this function creates some asynchronous activity, it should initialize finish to a function that can be used to wait for the asynchronous activity to terminate.

Parameters
clsclosure
cmdcommand being run
iinterpreter state

Definition at line 89 of file gnunet_testing_ng_lib.h.

Referenced by batch_run(), GNUNET_TESTING_cmd_batch_get_current(), GNUNET_TESTING_cmd_batch_set_current(), GNUNET_TESTING_cmd_finish(), GNUNET_TESTING_cmd_is_batch(), interpreter_run(), gnunet_testing.Check::run_blocking(), and gnunet_testing.Check::run_once().

◆ finish

bool(* GNUNET_TESTING_Command::finish) (void *cls, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)

Wait for any asynchronous execution of run to conclude, then call finish_cont.

Finish may only be called once per command.

This member may be NULL if this command is a synchronous command, and also should be set to NULL once the command has finished.

Parameters
clsclosure
contfunction to call upon completion, can be NULL
cont_clsclosure for cont

Definition at line 105 of file gnunet_testing_ng_lib.h.

Referenced by interpreter_run(), run_finish_task_next(), and run_finish_task_sync().

◆ finish_task

struct GNUNET_SCHEDULER_Task* GNUNET_TESTING_Command::finish_task

Task for running the finish function.

Definition at line 112 of file gnunet_testing_ng_lib.h.

Referenced by do_shutdown(), and interpreter_run().

◆ cleanup

void(* GNUNET_TESTING_Command::cleanup) (void *cls, const struct GNUNET_TESTING_Command *cmd)

Clean up after the command.

Run during forced termination (CTRL-C) or test failure or test success.

Parameters
clsclosure
cmdcommand being cleaned up

Definition at line 122 of file gnunet_testing_ng_lib.h.

Referenced by batch_cleanup(), and do_shutdown().

◆ traits

int(* GNUNET_TESTING_Command::traits) (void *cls, const void **ret, const char *trait, unsigned int index)

Extract information from a command that is useful for other commands.

Parameters
clsclosure
[out]retresult (could be anything)
traitname of the trait
indexindex number of the object to extract.
Returns
GNUNET_OK on success

Definition at line 136 of file gnunet_testing_ng_lib.h.

Referenced by GNUNET_TESTBED_get_trait_controller(), GNUNET_TESTBED_get_trait_peer(), GNUNET_TESTING_get_trait_cmd(), GNUNET_TESTING_get_trait_process(), and GNUNET_TESTING_get_trait_what_am_i().

◆ start_time

struct GNUNET_TIME_Absolute GNUNET_TESTING_Command::start_time

When did the execution of this command start?

Definition at line 144 of file gnunet_testing_ng_lib.h.

Referenced by batch_run(), and interpreter_run().

◆ finish_time

struct GNUNET_TIME_Absolute GNUNET_TESTING_Command::finish_time

When did the execution of this command finish?

Definition at line 149 of file gnunet_testing_ng_lib.h.

Referenced by GNUNET_TESTING_cmd_batch_next(), and interpreter_next().

◆ last_req_time

struct GNUNET_TIME_Absolute GNUNET_TESTING_Command::last_req_time

When did we start the last run of this command? Delta to finish_time gives the latency for the last successful run.

Useful in case num_tries was positive and the command was run multiple times. In that case, the start_time gives the time when we first tried to run the command, so the difference between start_time and finish_time would be the time all of the num_tries took, while the delta to last_req_time is the time the last (successful) execution took.

Definition at line 160 of file gnunet_testing_ng_lib.h.

Referenced by batch_run(), and interpreter_run().

◆ num_tries

unsigned int GNUNET_TESTING_Command::num_tries

How often did we try to execute this command? (In case it is a request that is repated.) Note that a command must have some built-in retry mechanism for this value to be useful.

Definition at line 167 of file gnunet_testing_ng_lib.h.

Referenced by batch_run(), and interpreter_run().

◆ default_timeout

struct GNUNET_TIME_Relative GNUNET_TESTING_Command::default_timeout

In case asynchronous_finish is true, how long should we wait for this command to complete? If finish did not complete after this amount of time, the interpreter will fail.

Should be set generously to ensure tests do not fail on slow systems.

Definition at line 175 of file gnunet_testing_ng_lib.h.

Referenced by run_finish_task_sync().

◆ asynchronous_finish

bool GNUNET_TESTING_Command::asynchronous_finish

If "true", the interpreter should not immediately call finish, even if finish is non-NULL.

Otherwise, #TALER_TESTING_cmd_finish() must be used to ensure that a command actually completed.

Definition at line 183 of file gnunet_testing_ng_lib.h.

Referenced by interpreter_run().


The documentation for this struct was generated from the following file: