GNUnet 0.22.2
testing_api_cmds.c File Reference
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_lib.h"
Include dependency graph for testing_api_cmds.c:

Go to the source code of this file.

Functions

struct GNUNET_TESTING_Command GNUNET_TESTING_command_new_ac (void *cls, const char *label, GNUNET_TESTING_CommandRunRoutine run, GNUNET_TESTING_CommandCleanupRoutine cleanup, GNUNET_TESTING_CommandGetTraits traits, struct GNUNET_TESTING_AsyncContext *ac)
 Create a new command that may be asynchronous. More...
 
void GNUNET_TESTING_set_label (struct GNUNET_TESTING_CommandLabel *label, const char *value)
 Set label to value. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_set_var (const char *name, struct GNUNET_TESTING_Command cmd)
 Set variable to command as side-effect of running a command. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_end (void)
 Create command array terminator. More...
 

Function Documentation

◆ GNUNET_TESTING_command_new_ac()

struct GNUNET_TESTING_Command GNUNET_TESTING_command_new_ac ( void *  cls,
const char *  label,
GNUNET_TESTING_CommandRunRoutine  run,
GNUNET_TESTING_CommandCleanupRoutine  cleanup,
GNUNET_TESTING_CommandGetTraits  traits,
struct GNUNET_TESTING_AsyncContext ac 
)

Create a new command that may be asynchronous.

Parameters
clsthe closure
labelthe Label. Maximum length is GNUNET_TESTING_CMD_MAX_LABEL_LENGTH
runthe run routing
cleanupthe cleanup function
traitsthe traits function (optional)
acthe async context, NULL if command is always synchronous
Returns
the command the function cannot fail

Definition at line 34 of file testing_api_cmds.c.

41{
42 struct GNUNET_TESTING_Command cmd = {
43 .cls = cls,
44 .run = run,
45 .ac = ac,
46 .cleanup = cleanup,
47 .traits = traits
48 };
49
50 GNUNET_assert (NULL != run);
51 if (NULL != label)
53 label);
54 return cmd;
55}
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run by the scheduler.
Definition: gnunet-arm.c:918
static void cleanup(void *cls)
Disconnect and shutdown.
Definition: gnunet-did.c:130
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
A command to be run by the interpreter.
struct GNUNET_TESTING_CommandLabel label
Label for the command.
struct GNUNET_TESTING_AsyncContext * ac
Pointer to the asynchronous context in the command's closure.
void * cls
Closure for all commands with command-specific context information.
static enum GNUNET_GenericReturnValue traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.
void GNUNET_TESTING_set_label(struct GNUNET_TESTING_CommandLabel *label, const char *value)
Set label to value.

References GNUNET_TESTING_Command::ac, cleanup(), GNUNET_TESTING_Command::cls, GNUNET_assert, GNUNET_TESTING_set_label(), GNUNET_TESTING_Command::label, run(), and traits().

Referenced by GNUNET_CORE_cmd_connect_peers(), GNUNET_TESTING_ARM_cmd_start_peer(), GNUNET_TESTING_cmd_barrier_reached(), GNUNET_TESTING_cmd_exec(), GNUNET_TESTING_cmd_exec_va(), GNUNET_TESTING_cmd_finish(), GNUNET_TESTING_cmd_load_topology_from_file(), GNUNET_TESTING_cmd_load_topology_from_string(), GNUNET_TESTING_cmd_netjail_setup(), GNUNET_TESTING_cmd_netjail_start_helpers(), GNUNET_TESTING_cmd_stop_peer(), GNUNET_TRANSPORT_cmd_backchannel_check(), GNUNET_TRANSPORT_cmd_connect_peers(), GNUNET_TRANSPORT_cmd_send_simple_performance(), and GNUNET_TRANSPORT_cmd_start_peer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTING_set_label()

void GNUNET_TESTING_set_label ( struct GNUNET_TESTING_CommandLabel label,
const char *  value 
)

Set label to value.

Asserts that value is not longer than GNUNET_TESTING_CMD_MAX_LABEL_LENGTH.

Parameters
[out]labellabel to initialize
valuevalue to store into label

Definition at line 59 of file testing_api_cmds.c.

62{
63 size_t len;
64
65 len = strlen (value);
66 GNUNET_assert (len <=
68 memcpy (label->value,
69 value,
70 len + 1);
71}
static char * value
Value of the record to add/remove.
#define GNUNET_TESTING_CMD_MAX_LABEL_LENGTH
Central interpreter and command loop for writing an interpreter to test asynchronous systems.

References GNUNET_assert, GNUNET_TESTING_CMD_MAX_LABEL_LENGTH, GNUNET_TESTING_Command::label, value, and GNUNET_TESTING_CommandLabel::value.

Referenced by GNUNET_TESTING_cmd_batch(), GNUNET_TESTING_command_new_ac(), and GNUNET_TESTING_DHTU_cmd_send().

Here is the caller graph for this function:

◆ GNUNET_TESTING_cmd_set_var()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_set_var ( const char *  name,
struct GNUNET_TESTING_Command  cmd 
)

Set variable to command as side-effect of running a command.

Parameters
namename of the variable to set
cmdcommand to set to variable when run
Returns
modified command

Definition at line 75 of file testing_api_cmds.c.

78{
79 cmd.name = name;
80 return cmd;
81}
static char * name
Name (label) of the records to list.
const char * name
Variable name for the command, NULL for none.

References GNUNET_TESTING_Command::name.

Referenced by start_testcase().

Here is the caller graph for this function:

◆ GNUNET_TESTING_cmd_end()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_end ( void  )

Create command array terminator.

Returns
a end-command.

Definition at line 85 of file testing_api_cmds.c.

86{
87 struct GNUNET_TESTING_Command cmd = {
88 .run = NULL
89 };
90
91 return cmd;
92}
GNUNET_TESTING_CommandRunRoutine run
Runs the command.

References GNUNET_TESTING_Command::run.

Referenced by main().

Here is the caller graph for this function: