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, struct GNUNET_TESTING_Interpreter *is)
 Runs the command. More...
 
struct GNUNET_TESTING_AsyncContextac
 Pointer to the asynchronous context in the command's closure. More...
 
void(* cleanup )(void *cls)
 Clean up after the command. More...
 
enum GNUNET_GenericReturnValue(* 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...
 
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 296 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, struct GNUNET_TESTING_Interpreter *is)

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

Referenced by batch_run(), 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 336 of file gnunet_testing_ng_lib.h.

Referenced by interpreter_run(), and run_finish().

◆ cleanup

void(* GNUNET_TESTING_Command::cleanup) (void *cls)

Clean up after the command.

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

Parameters
clsclosure

Definition at line 344 of file gnunet_testing_ng_lib.h.

Referenced by batch_cleanup(), and finish_test().

◆ traits

enum GNUNET_GenericReturnValue(* 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.

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

Referenced by GNUNET_TESTING_cmd_hello_world_birth(), GNUNET_TESTING_get_trait_async_context(), GNUNET_TESTING_get_trait_connect_peer_state(), GNUNET_TESTING_get_trait_helper_handles(), GNUNET_TESTING_get_trait_process(), GNUNET_TESTING_get_trait_test_system(), GNUNET_TRANSPORT_cmd_start_peer(), GNUNET_TRANSPORT_get_trait_application_handle(), GNUNET_TRANSPORT_get_trait_connected_peers_map(), GNUNET_TRANSPORT_get_trait_hello(), GNUNET_TRANSPORT_get_trait_hello_size(), and GNUNET_TRANSPORT_get_trait_state().

◆ start_time

struct GNUNET_TIME_Absolute GNUNET_TESTING_Command::start_time

When did the execution of this command start?

Definition at line 344 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 344 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 344 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 344 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 398 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, #TALER_TESTING_cmd_finish() must be used to ensure that a command actually completed.

Definition at line 406 of file gnunet_testing_ng_lib.h.

Referenced by interpreter_run(), and run_finish().


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