GNUnet  0.20.0
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...
 
char label [127+1]
 Label for the command. More...
 
GNUNET_TESTING_CommandRunRoutine run
 Runs the command. More...
 
struct GNUNET_TESTING_AsyncContextac
 Pointer to the asynchronous context in the command's closure. More...
 
GNUNET_TESTING_CommandCleanupRoutine cleanup
 Clean up after the command. More...
 
GNUNET_TESTING_CommandGetTraits traits
 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...
 
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...
 
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...
 
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 131 of file gnunet_testing_ng_lib.h.

Field Documentation

◆ cls

void* GNUNET_TESTING_Command::cls

Closure for all commands with command-specific context information.

Definition at line 136 of file gnunet_testing_ng_lib.h.

Referenced by batch_cleanup(), batch_run(), finish_test(), GNUNET_TESTING_cmd_batch_get_current_(), GNUNET_TESTING_cmd_batch_set_current_(), interpreter_next(), interpreter_run(), and notify_connect().

◆ label

◆ run

GNUNET_TESTING_CommandRunRoutine GNUNET_TESTING_Command::run

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
isinterpreter state

Definition at line 158 of file gnunet_testing_ng_lib.h.

Referenced by batch_cleanup(), batch_run(), finish_test(), get_command(), GNUNET_TESTING_cmd_batch_next_(), GNUNET_TESTING_cmd_is_batch_(), interpreter_run(), gnunet_testing.Check::run_blocking(), and gnunet_testing.Check::run_once().

◆ ac

struct GNUNET_TESTING_AsyncContext* GNUNET_TESTING_Command::ac

Pointer to the asynchronous context in the command's closure.

Used by the GNUNET_TESTING_async_finish() and GNUNET_TESTING_async_fail() functions.

Must be NULL if a command is synchronous.

Definition at line 168 of file gnunet_testing_ng_lib.h.

Referenced by do_timeout(), interpreter_run(), run_finish(), and TST_interpreter_finish_attached_cmds().

◆ cleanup

GNUNET_TESTING_CommandCleanupRoutine GNUNET_TESTING_Command::cleanup

Clean up after the command.

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

Parameters
clsclosure

Definition at line 176 of file gnunet_testing_ng_lib.h.

Referenced by batch_cleanup(), and finish_test().

◆ traits

GNUNET_TESTING_CommandGetTraits GNUNET_TESTING_Command::traits

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

Can be NULL if a command has no traits.

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

Definition at line 189 of file gnunet_testing_ng_lib.h.

◆ start_time

struct GNUNET_TIME_Absolute GNUNET_TESTING_Command::start_time

When did the execution of this command start?

Definition at line 189 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 189 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 189 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 189 of file gnunet_testing_ng_lib.h.

◆ 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 225 of file gnunet_testing_ng_lib.h.

Referenced by batch_run(), and interpreter_run().

◆ asynchronous_finish

bool GNUNET_TESTING_Command::asynchronous_finish

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

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

Definition at line 233 of file gnunet_testing_ng_lib.h.

Referenced by barrier_reached_run(), block_until_all_peers_started_run(), interpreter_run(), run_finish(), and TST_interpreter_finish_attached_cmds().


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