GNUnet  0.11.x
Data Structures | Macros | Typedefs | Enumerations | Functions
gnunet_testing_ng_lib.h File Reference
#include "gnunet_util_lib.h"
#include "gnunet_testing_plugin.h"
#include "gnunet_testing_lib.h"
Include dependency graph for gnunet_testing_ng_lib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GNUNET_TESTING_NetjailRouter
 Router of a network namespace. More...
 
struct  GNUNET_TESTING_ADDRESS_PREFIX
 
struct  GNUNET_TESTING_NodeConnection
 Connection to another node. More...
 
struct  GNUNET_TESTING_NetjailNode
 Node in the netjail topology. More...
 
struct  GNUNET_TESTING_NetjailNamespace
 Namespace in a topology. More...
 
struct  GNUNET_TESTING_NetjailTopology
 Toplogy of our netjail setup. More...
 
struct  GNUNET_TESTING_AsyncContext
 State each asynchronous command must have in its closure. More...
 
struct  GNUNET_TESTING_Command
 A command to be run by the interpreter. More...
 
struct  GNUNET_TESTING_Timer
 Performance counter. More...
 
struct  GNUNET_TESTING_Trait
 A trait. More...
 

Macros

#define GNUNET_TESTING_FAIL(is)
 API for writing an interpreter to test GNUnet components. More...
 

Typedefs

typedef void(* GNUNET_TESTING_ResultCallback) (void *cls, enum GNUNET_GenericReturnValue rv)
 Function called with the final result of the test. More...
 

Enumerations

enum  GNUNET_TESTING_NODE_TYPE { GNUNET_TESTING_SUBNET_NODE , GNUNET_TESTING_GLOBAL_NODE }
 Enum for the different types of nodes. More...
 

Functions

const struct GNUNET_TESTING_CommandGNUNET_TESTING_interpreter_lookup_command (struct GNUNET_TESTING_Interpreter *is, const char *label)
 Lookup command by label. More...
 
const char * GNUNET_TESTING_interpreter_get_current_label (struct GNUNET_TESTING_Interpreter *is)
 Obtain label of the command being now run. More...
 
void GNUNET_TESTING_interpreter_fail (struct GNUNET_TESTING_Interpreter *is)
 Current command failed, clean up and fail the test case. More...
 
void GNUNET_TESTING_async_fail (struct GNUNET_TESTING_AsyncContext *ac)
 The asynchronous command of ac has failed. More...
 
void GNUNET_TESTING_async_finish (struct GNUNET_TESTING_AsyncContext *ac)
 The asynchronous command of ac has finished. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_end (void)
 Create command array terminator. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_make_unblocking (struct GNUNET_TESTING_Command cmd)
 Turn asynchronous command into non blocking command by setting asynchronous_finish to true. More...
 
const struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_finish (const char *finish_label, const char *cmd_ref, struct GNUNET_TIME_Relative timeout)
 Create (synchronous) command that waits for another command to finish. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_rewind_ip (const char *label, const char *target_label, unsigned int counter)
 Make the instruction pointer point to target_label only if counter is greater than zero. More...
 
void GNUNET_TESTING_run (struct GNUNET_TESTING_Command *commands, struct GNUNET_TIME_Relative timeout, GNUNET_TESTING_ResultCallback rc, void *rc_cls)
 Run the testsuite. More...
 
int GNUNET_TESTING_main (struct GNUNET_TESTING_Command *commands, struct GNUNET_TIME_Relative timeout)
 Start a GNUnet scheduler event loop and run the testsuite. More...
 
int GNUNET_TESTING_has_in_name (const char *prog, const char *marker)
 Look for substring in a programs' name. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_signal (const char *label, const char *process_label, unsigned int process_index, int signal)
 Create a "signal" CMD. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_sleep (const char *label, struct GNUNET_TIME_Relative duration)
 Sleep for duration. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_batch (const char *label, struct GNUNET_TESTING_Command *batch)
 Create a "batch" command. More...
 
struct GNUNET_TESTING_NetjailTopologyGNUNET_TESTING_get_topo_from_file (const char *filename)
 Getting the topology from file. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_stat (struct GNUNET_TESTING_Timer *timers)
 Obtain performance data from the interpreter. More...
 
struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end (void)
 "end" trait. More...
 
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits, const void **ret, const char *trait, unsigned int index)
 Extract a trait. More...
 
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_process (const struct GNUNET_TESTING_Command *cmd, unsigned int index, struct GNUNET_OS_Process ***processp)
 Obtain location where a command stores a pointer to a process. More...
 
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_process (unsigned int index, struct GNUNET_OS_Process **processp)
 Offer location where a command stores a pointer to a process. More...
 
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_uint32 (unsigned int index, const uint32_t *n)
 Offer number trait, 32-bit version. More...
 
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_uint32 (const struct GNUNET_TESTING_Command *cmd, unsigned int index, const uint32_t **n)
 Obtain a "number" value from cmd, 32-bit version. More...
 
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_uint64 (unsigned int index, const uint64_t *n)
 Offer number trait, 64-bit version. More...
 
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_uint64 (const struct GNUNET_TESTING_Command *cmd, unsigned int index, const uint64_t **n)
 Obtain a "number" value from cmd, 64-bit version. More...
 
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_int64 (unsigned int index, const int64_t *n)
 Offer number trait, 64-bit signed version. More...
 
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_int64 (const struct GNUNET_TESTING_Command *cmd, unsigned int index, const int64_t **n)
 Obtain a "number" value from cmd, 64-bit signed version. More...
 
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_uint (unsigned int index, const unsigned int *i)
 Offer a number. More...
 
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_uint (const struct GNUNET_TESTING_Command *cmd, unsigned int index, const unsigned int **n)
 Obtain a number from cmd. More...
 
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_string (const struct GNUNET_TESTING_Command *cmd, unsigned int index, const char **s)
 Obtain a string from cmd. More...
 
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_string (unsigned int index, const char *s)
 Offer string subject. More...
 
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_cmd (unsigned int index, const struct GNUNET_TESTING_Command *cmd)
 Offer a command in a trait. More...
 
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_cmd (const struct GNUNET_TESTING_Command *cmd, unsigned int index, struct GNUNET_TESTING_Command **_cmd)
 Obtain a command from cmd. More...
 
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_uuid (const struct GNUNET_TESTING_Command *cmd, unsigned int index, struct GNUNET_Uuid **uuid)
 Obtain a uuid from cmd. More...
 
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_uuid (unsigned int index, const struct GNUNET_Uuid *uuid)
 Offer a uuid in a trait. More...
 
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_absolute_time (const struct GNUNET_TESTING_Command *cmd, unsigned int index, const struct GNUNET_TIME_Absolute **time)
 Obtain a absolute time from cmd. More...
 
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_absolute_time (unsigned int index, const struct GNUNET_TIME_Absolute *time)
 Offer a absolute time. More...
 
int GNUNET_TESTING_get_trait_relative_time (const struct GNUNET_TESTING_Command *cmd, unsigned int index, const struct GNUNET_TIME_Relative **time)
 Obtain a relative time from cmd. More...
 
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_relative_time (unsigned int index, const struct GNUNET_TIME_Relative *time)
 Offer a relative time. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_hello_world_birth (const char *label, struct GNUNET_TIME_Absolute *now)
 Create command. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_hello_world (const char *label, const char *birthLabel, char *message)
 Create command. More...
 
int GNUNET_TESTING_get_trait_what_am_i (const struct GNUNET_TESTING_Command *cmd, char **what_am_i)
 Offer data from trait. More...
 
int GNUNET_TESTING_get_trait_test_system (const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_System **test_system)
 Function to get the trait with struct GNUNET_TESTING_System. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_system_create (const char *label, const char *testdir)
 Create command. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_system_destroy (const char *label, const char *create_label)
 Create command. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_netjail_start (const char *label, char *topology_config)
 Create command. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label, const char *topology_config)
 Create command. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_netjail_stop (const char *label, char *topology_config)
 Create command. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_stop_testing_system (const char *label, const char *helper_start_label, const char *topology_config)
 Create command. More...
 
struct GNUNET_MessageHeaderGNUNET_TESTING_send_local_test_finished_msg (enum GNUNET_GenericReturnValue rv)
 Create a GNUNET_CMDS_LOCAL_FINISHED message. More...
 
int GNUNET_TESTING_get_trait_async_context (const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_AsyncContext **ac)
 Function to get the trait with the async context. More...
 
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_helper_handles (const struct GNUNET_TESTING_Command *cmd, struct GNUNET_HELPER_Handle ***helper)
 Offer handles to testing cmd helper from trait. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_block_until_all_peers_started (const char *label, unsigned int *all_peers_started)
 Create command. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_block_until_external_trigger (const char *label)
 Create command. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_send_peer_ready (const char *label, TESTING_CMD_HELPER_write_cb write_message)
 Create command. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_local_test_finished (const char *label, TESTING_CMD_HELPER_write_cb write_message)
 Create command. More...
 

Macro Definition Documentation

◆ GNUNET_TESTING_FAIL

#define GNUNET_TESTING_FAIL (   is)
Value:
do \
{ \
GNUNET_break (0); \
GNUNET_TESTING_interpreter_fail (is); \
return; \
} while (0)
static struct GNUNET_NT_InterfaceScanner * is
Network scanner to determine network types.

API for writing an interpreter to test GNUnet components.

Author
Christian Grothoff chris.nosp@m.tian.nosp@m.@grot.nosp@m.hoff.nosp@m..org
Marcello Stanisci
t3sserakt Print failing line number and trigger shutdown. Useful quite any time after the command "run" method has been called.

Definition at line 40 of file gnunet_testing_ng_lib.h.

Typedef Documentation

◆ GNUNET_TESTING_ResultCallback

typedef void(* GNUNET_TESTING_ResultCallback) (void *cls, enum GNUNET_GenericReturnValue rv)

Function called with the final result of the test.

Parameters
clsclosure
rvGNUNET_OK if the test passed

Definition at line 519 of file gnunet_testing_ng_lib.h.

Enumeration Type Documentation

◆ GNUNET_TESTING_NODE_TYPE

Enum for the different types of nodes.

// FIXME: this does not belong here!

Enumerator
GNUNET_TESTING_SUBNET_NODE 

Node in a subnet.

GNUNET_TESTING_GLOBAL_NODE 

Global known node.

Definition at line 71 of file gnunet_testing_ng_lib.h.

72 {
77 
82 };
@ GNUNET_TESTING_SUBNET_NODE
Node in a subnet.
@ GNUNET_TESTING_GLOBAL_NODE
Global known node.

Function Documentation

◆ GNUNET_TESTING_interpreter_lookup_command()

const struct GNUNET_TESTING_Command* GNUNET_TESTING_interpreter_lookup_command ( struct GNUNET_TESTING_Interpreter is,
const char *  label 
)

Lookup command by label.

Parameters
isinterpreter to lookup command in
labellabel of the command to lookup.
Returns
the command, if it is found, or NULL.

Definition at line 86 of file testing_api_loop.c.

89 {
90  if (NULL == label)
91  {
93  "Attempt to lookup command for empty label\n");
94  return NULL;
95  }
96  /* Search backwards as we most likely reference recent commands */
97  for (int i = is->ip; i >= 0; i--)
98  {
99  const struct GNUNET_TESTING_Command *cmd = &is->commands[i];
100 
101  /* Give precedence to top-level commands. */
102  if ( (NULL != cmd->label) &&
103  (0 == strcmp (cmd->label,
104  label)) )
105  return cmd;
106 
108  {
109 #define BATCH_INDEX 1
110  struct GNUNET_TESTING_Command *batch;
111  struct GNUNET_TESTING_Command *current;
112  struct GNUNET_TESTING_Command *icmd;
113  const struct GNUNET_TESTING_Command *match;
114 
118  BATCH_INDEX,
119  &batch));
120  /* We must do the loop forward, but we can find the last match */
121  match = NULL;
122  for (unsigned int j = 0;
123  NULL != (icmd = &batch[j])->label;
124  j++)
125  {
126  if (current == icmd)
127  break; /* do not go past current command */
128  if ( (NULL != icmd->label) &&
129  (0 == strcmp (icmd->label,
130  label)) )
131  match = icmd;
132  }
133  if (NULL != match)
134  return match;
135  }
136  }
138  "Command `%s' not found\n",
139  label);
140  return NULL;
141 }
#define GNUNET_log(kind,...)
@ GNUNET_OK
Definition: gnunet_common.h:95
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_cmd(const struct GNUNET_TESTING_Command *cmd, unsigned int index, struct GNUNET_TESTING_Command **_cmd)
Obtain a command from cmd.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
A command to be run by the interpreter.
const char * label
Label for the command.
struct GNUNET_TESTING_Command * GNUNET_TESTING_cmd_batch_get_current_(const struct GNUNET_TESTING_Command *cmd)
Obtain what command the batch is at.
bool GNUNET_TESTING_cmd_is_batch_(const struct GNUNET_TESTING_Command *cmd)
Test if this command is a batch command.
#define BATCH_INDEX

References BATCH_INDEX, GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_OK, GNUNET_TESTING_cmd_batch_get_current_(), GNUNET_TESTING_cmd_is_batch_(), GNUNET_TESTING_get_trait_cmd(), is, and GNUNET_TESTING_Command::label.

Referenced by connect_peers_run(), hello_world_run(), run_finish(), send_simple_run(), start_peer_run(), stop_peer_run(), stop_testing_system_run(), and system_destroy_run().

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

◆ GNUNET_TESTING_interpreter_get_current_label()

const char* GNUNET_TESTING_interpreter_get_current_label ( struct GNUNET_TESTING_Interpreter is)

Obtain label of the command being now run.

Parameters
isinterpreter state.
Returns
the label.

Definition at line 271 of file testing_api_loop.c.

273 {
274  struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
275 
276  return cmd->label;
277 }

References is, and GNUNET_TESTING_Command::label.

◆ GNUNET_TESTING_interpreter_fail()

void GNUNET_TESTING_interpreter_fail ( struct GNUNET_TESTING_Interpreter is)

Current command failed, clean up and fail the test case.

Parameters
isinterpreter state.

Definition at line 236 of file testing_api_loop.c.

237 {
238  struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
239 
240  if (GNUNET_SYSERR == is->result)
241  {
242  GNUNET_break (0);
243  return; /* ignore, we already failed! */
244  }
245  if (NULL != cmd)
246  {
248  "Failed at command `%s'\n",
249  cmd->label);
250  while (GNUNET_TESTING_cmd_is_batch_ (cmd))
251  {
254  "Failed in batch at command `%s'\n",
255  cmd->label);
256  }
257  }
258  else
259  {
261  "Failed with CMD being NULL!\n");
262  }
263  is->result = GNUNET_SYSERR;
264  GNUNET_assert (NULL == is->final_task);
265  is->final_task = GNUNET_SCHEDULER_add_now (&finish_test,
266  is);
267 }
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1296
static void finish_test(void *cls)
Finish the test run, return the final result.

References finish_test(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SYSERR, GNUNET_TESTING_cmd_batch_get_current_(), GNUNET_TESTING_cmd_is_batch_(), is, and GNUNET_TESTING_Command::label.

Referenced by exp_cb(), GNUNET_TESTING_async_fail(), netjail_stop_run(), run_finish(), start_helper(), and start_peer_run().

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

◆ GNUNET_TESTING_async_fail()

void GNUNET_TESTING_async_fail ( struct GNUNET_TESTING_AsyncContext ac)

The asynchronous command of ac has failed.

Parameters
accommand-specific context

Definition at line 454 of file testing_api_loop.c.

455 {
456  GNUNET_assert (GNUNET_NO == ac->finished);
457  ac->finished = GNUNET_SYSERR;
459  if (NULL != ac->cont)
460  {
461  ac->cont (ac->cont_cls);
462  ac->cont = NULL;
463  }
464 }
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
@ GNUNET_NO
Definition: gnunet_common.h:94
void GNUNET_TESTING_interpreter_fail(struct GNUNET_TESTING_Interpreter *is)
Current command failed, clean up and fail the test case.

References ac, GNUNET_assert, GNUNET_NO, GNUNET_SYSERR, and GNUNET_TESTING_interpreter_fail().

Referenced by child_completed_callback(), and timeout_finish().

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

◆ GNUNET_TESTING_async_finish()

void GNUNET_TESTING_async_finish ( struct GNUNET_TESTING_AsyncContext ac)

The asynchronous command of ac has finished.

Parameters
accommand-specific context

Definition at line 468 of file testing_api_loop.c.

469 {
470  GNUNET_assert (GNUNET_NO == ac->finished);
471  ac->finished = GNUNET_OK;
472  if (NULL != ac->cont)
473  {
474  ac->cont (ac->cont_cls);
475  ac->cont = NULL;
476  }
477 }

References ac, GNUNET_assert, GNUNET_NO, and GNUNET_OK.

Referenced by child_completed_callback(), done_finish(), hello_iter_cb(), helper_mst(), notify_connect(), and run_finish().

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 1 of file testing_api_cmd_end.c.

31 {
32  static struct GNUNET_TESTING_Command cmd = {
33  .label = NULL
34  };
35 
36  return cmd;
37 }

References GNUNET_TESTING_Command::label.

◆ GNUNET_TESTING_cmd_make_unblocking()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_make_unblocking ( struct GNUNET_TESTING_Command  cmd)

Turn asynchronous command into non blocking command by setting asynchronous_finish to true.

Parameters
cmdcommand to make synchronous.
Returns
a finish-command.

Definition at line 153 of file testing_api_cmd_finish.c.

192 {
193  /* do not permit this function to be used on
194  a finish command! */
195  GNUNET_assert (cmd.run != &run_finish);
196  cmd.asynchronous_finish = true;
197  return cmd;
198 }
void(* run)(void *cls, struct GNUNET_TESTING_Interpreter *is)
Runs the command.
bool asynchronous_finish
If "true", the interpreter should not immediately call finish, even if finish is non-NULL.
static void run_finish(void *cls, struct GNUNET_TESTING_Interpreter *is)
Run method of the command created by the interpreter to wait for another command to finish.

◆ GNUNET_TESTING_cmd_finish()

const struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_finish ( const char *  finish_label,
const char *  cmd_ref,
struct GNUNET_TIME_Relative  timeout 
)

Create (synchronous) command that waits for another command to finish.

If cmd_ref did not finish after timeout, this command will fail the test case.

Parameters
finish_labellabel for this command
cmd_refreference to a previous command which we should wait for (call finish() on)
timeouthow long to wait at most for cmd_ref to finish
Returns
a finish-command.

Definition at line 153 of file testing_api_cmd_finish.c.

170 {
171  struct FinishState *finish_state;
172 
173  finish_state = GNUNET_new (struct FinishState);
174  finish_state->async_label = cmd_ref;
175  finish_state->timeout = timeout;
176  {
177  struct GNUNET_TESTING_Command cmd = {
178  .cls = finish_state,
179  .label = finish_label,
180  .run = &run_finish,
181  .ac = &finish_state->ac,
182  .cleanup = &cleanup_finish
183  };
184 
185  return cmd;
186  }
187 }
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
Definition: gnunet-abd.c:61
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Struct to use for command-specific context information closure of a command waiting for another comma...
struct GNUNET_TESTING_AsyncContext ac
Function to call when done.
const char * async_label
Label of the asynchronous command the synchronous command of this closure waits for.
struct GNUNET_TIME_Relative timeout
How long to wait until finish fails hard?
void * cls
Closure for all commands with command-specific context information.
static void cleanup_finish(void *cls)
Cleanup state of a finish command.

◆ GNUNET_TESTING_cmd_rewind_ip()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_rewind_ip ( const char *  label,
const char *  target_label,
unsigned int  counter 
)

Make the instruction pointer point to target_label only if counter is greater than zero.

Parameters
labelcommand label
target_labellabel of the new instruction pointer's destination after the jump; must be before the current instruction
countercounts how many times the rewinding is to happen.

◆ GNUNET_TESTING_run()

void GNUNET_TESTING_run ( struct GNUNET_TESTING_Command commands,
struct GNUNET_TIME_Relative  timeout,
GNUNET_TESTING_ResultCallback  rc,
void *  rc_cls 
)

Run the testsuite.

Note, CMDs are copied into the interpreter state because they are usually defined into the "run" method that returns after having scheduled the test interpreter.

Parameters
commandsthe list of command to execute
timeouthow long to wait for each command to execute
rcfunction to call with the final result
rc_clsclosure for rc

Definition at line 348 of file testing_api_loop.c.

352 {
354  unsigned int i;
355 
357  is->rc = rc;
358  is->rc_cls = rc_cls;
359  /* get the number of commands */
360  for (i = 0; NULL != commands[i].label; i++)
361  ;
362  is->commands = GNUNET_new_array (i + 1,
363  struct GNUNET_TESTING_Command);
364  memcpy (is->commands,
365  commands,
366  sizeof (struct GNUNET_TESTING_Command) * i);
367  is->timeout_task
369  &do_timeout,
370  is);
372  is);
373 }
static struct VoipCommand commands[]
List of supported commands.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1269
Global state of the interpreter, used by a command to access information about other commands.
GNUNET_TESTING_ResultCallback rc
Function to call with the test result.
void * rc_cls
Closure for rc.
static void do_timeout(void *cls)
Function run when the test terminates (good or bad) with timeout.
static void interpreter_run(void *cls)
Run the main interpreter loop that performs exchange operations.

References commands, do_timeout(), GNUNET_new, GNUNET_new_array, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), interpreter_run(), is, GNUNET_TESTING_Interpreter::rc, GNUNET_TESTING_Interpreter::rc_cls, and timeout.

Referenced by loop_run().

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

◆ GNUNET_TESTING_main()

int GNUNET_TESTING_main ( struct GNUNET_TESTING_Command commands,
struct GNUNET_TIME_Relative  timeout 
)

Start a GNUnet scheduler event loop and run the testsuite.

Return 0 upon success. Expected to be called directly from main().

Parameters
commandsthe list of command to execute
timeouthow long to wait for each command to execute
Returns
EXIT_SUCCESS on success, EXIT_FAILURE on failure

Definition at line 438 of file testing_api_loop.c.

440 {
441  struct MainParams mp = {
442  .commands = commands,
443  .timeout = timeout,
444  .rv = EXIT_SUCCESS
445  };
446 
448  &mp);
449  return mp.rv;
450 }
void GNUNET_SCHEDULER_run(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Initialize and run scheduler.
Definition: scheduler.c:720
Closure for loop_run().
int rv
Set to #EXIT_FAILURE on error.
struct GNUNET_TESTING_Command * commands
NULL-label terminated array of commands.
static void loop_run(void *cls)
Main function to run the test cases.

References commands, MainParams::commands, GNUNET_SCHEDULER_run(), loop_run(), MainParams::rv, and timeout.

Here is the call graph for this function:

◆ GNUNET_TESTING_has_in_name()

int GNUNET_TESTING_has_in_name ( const char *  prog,
const char *  marker 
)

Look for substring in a programs' name.

Parameters
progprogram's name to look into
markerchunk to find in prog // FIXME: this does not belong here! => libgnunetutil, maybe? // FIXME: return bool? document return value!

◆ GNUNET_TESTING_cmd_signal()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_signal ( const char *  label,
const char *  process_label,
unsigned int  process_index,
int  signal 
)

Create a "signal" CMD.

Parameters
labelcommand label.
process_labellabel of a command that has a process trait
process_indexindex of the process trait at process_label // FIXME: enum? needed?
signalsignal to send to process.
Returns
the command.

◆ GNUNET_TESTING_cmd_sleep()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_sleep ( const char *  label,
struct GNUNET_TIME_Relative  duration 
)

Sleep for duration.

Parameters
labelcommand label.
durationtime to sleep
Returns
the command.

◆ GNUNET_TESTING_cmd_batch()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_batch ( const char *  label,
struct GNUNET_TESTING_Command batch 
)

Create a "batch" command.

Such command takes a end_CMD-terminated array of CMDs and executed them. Once it hits the end CMD, it passes the control to the next top-level CMD, regardless of it being another batch or ordinary CMD.

Parameters
labelthe command label.
batcharray of CMDs to execute.
Returns
the command.

Definition at line 94 of file testing_api_cmd_batch.c.

157 {
158  struct BatchState *bs;
159  unsigned int i;
160 
161  bs = GNUNET_new (struct BatchState);
162  bs->label = label;
163  /* Get number of commands. */
164  for (i = 0; NULL != batch[i].label; i++)
165  /* noop */
166  ;
167 
168  bs->batch = GNUNET_new_array (i + 1,
169  struct GNUNET_TESTING_Command);
170  memcpy (bs->batch,
171  batch,
172  sizeof (struct GNUNET_TESTING_Command) * i);
173  {
174  struct GNUNET_TESTING_Command cmd = {
175  .cls = bs,
176  .label = label,
177  .run = &batch_run,
178  .cleanup = &batch_cleanup,
179  .traits = &batch_traits
180  };
181 
182  return cmd;
183  }
184 }
State for a "batch" CMD.
const char * label
Our label.
struct GNUNET_TESTING_Command * batch
CMDs batch.
static void batch_cleanup(void *cls)
Cleanup the state from a "reserve status" CMD, and possibly cancel a pending operation thereof.
static void batch_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
Run the command.
static enum GNUNET_GenericReturnValue batch_traits(void *cls, const void **ret, const char *trait, unsigned int index)
Offer internal data from a "batch" CMD, to other commands.

◆ GNUNET_TESTING_get_topo_from_file()

struct GNUNET_TESTING_NetjailTopology* GNUNET_TESTING_get_topo_from_file ( const char *  filename)

Getting the topology from file.

Parameters
filenameThe name of the topology file.
Returns
The GNUNET_TESTING_NetjailTopology

Definition at line 2038 of file testing.c.

2039 {
2040  uint64_t fs;
2041  char *data;
2042  char *token;
2043  char *key;
2044  unsigned int out;
2045  char *rest = NULL;
2046  char *value;
2047  int ret;
2048  struct GNUNET_TESTING_NetjailTopology *topo = GNUNET_new (struct
2050  struct GNUNET_TESTING_NetjailNode *node;
2051  struct GNUNET_TESTING_NetjailRouter *router;
2052  struct GNUNET_TESTING_NetjailNamespace *namespace;
2053  struct GNUNET_ShortHashCode *hkey;
2054  struct GNUNET_HashCode hc;
2055 
2056  topo->map_namespaces =
2058  topo->map_globals =
2060 
2062  {
2064  _ ("Topology file %s not found\n"),
2065  filename);
2066  return NULL;
2067  }
2068  if (GNUNET_OK !=
2070  {
2072  _ ("Topology file %s has no data\n"),
2073  filename);
2074  return NULL;
2075  }
2076  data = GNUNET_malloc (fs);
2077  if (fs != GNUNET_DISK_fn_read (filename, data, fs))
2078  {
2080  _ ("Topology file %s cannot be read\n"),
2081  filename);
2082  GNUNET_free (data);
2083  return NULL;
2084  }
2085 
2087  "data: %s\n",
2088  data);
2089 
2090  token = strtok_r (data, "\n", &rest);
2091 
2092  while (NULL != token)
2093  {
2094  key = get_key (token);
2096  "In the loop with token: %s beginning with %s\n",
2097  token,
2098  key);
2099  if (0 == strcmp (key, "M"))
2100  {
2102  "Get first Value for M.\n");
2103  out = get_first_value (token);
2105  "M: %u\n",
2106  out);
2107  topo->nodes_m = out;
2108  }
2109  else if (0 == strcmp (key, "N"))
2110  {
2112  "Get first Value for N.\n");
2113  out = get_first_value (token);
2115  "N: %u\n",
2116  out);
2117  topo->namespaces_n = out;
2118  }
2119  else if (0 == strcmp (key, "X"))
2120  {
2122  "Get first Value for X.\n");
2123  out = get_first_value (token);
2125  "X: %u\n",
2126  out);
2127  topo->nodes_x = out;
2128  }
2129  else if (0 == strcmp (key, "T"))
2130  {
2132  "Get first string value for T.\n");
2133  value = get_first_string_value (token);
2135  "value: %s\n",
2136  value);
2137  topo->plugin = value;
2138  }
2139  else if (0 == strcmp (key, "K"))
2140  {
2141  hkey = GNUNET_new (struct GNUNET_ShortHashCode);
2142  node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
2143 
2145  "Get first Value for K.\n");
2146  out = get_first_value (token);
2148  "K: %u\n",
2149  out);
2150  node->node_n = out;
2151  GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
2152  memcpy (hkey,
2153  &hc,
2154  sizeof (*hkey));
2155  node->is_global = GNUNET_YES;
2156 
2158  topo->map_globals,
2159  hkey))
2160  GNUNET_break (0);
2161  else
2163  hkey,
2164  node,
2167  "Get value for key value on K.\n");
2168  value = get_value ("plugin", token);
2170  "value: %s\n",
2171  value);
2172  node->plugin = value;
2173  node_connections (token, node);
2174  }
2175  else if (0 == strcmp (key, "R"))
2176  {
2177  hkey = GNUNET_new (struct GNUNET_ShortHashCode);
2178  router = GNUNET_new (struct GNUNET_TESTING_NetjailRouter);
2179  node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
2180 
2182  "Get first Value for R.\n");
2183  out = get_first_value (token);
2185  "R: %u\n",
2186  out);
2187  node->node_n = out;
2188  GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
2189  memcpy (hkey,
2190  &hc,
2191  sizeof (*hkey));
2193  "Get value for key tcp_port on R.\n");
2194  value = get_value ("tcp_port", token);
2196  "tcp_port: %s\n",
2197  value);
2198  ret = sscanf (value, "%u", &(router->tcp_port));
2199 
2200  GNUNET_break (0 != ret && 1 >= router->tcp_port);
2201 
2203  "Get value for key udp_port on R.\n");
2204  value = get_value ("udp_port", token);
2205  ret = sscanf (value, "%u", &(router->udp_port));
2206  GNUNET_break (0 != ret && 1 >= router->udp_port);
2208  "udp_port: %s\n",
2209  value);
2210 
2212  topo->map_namespaces,
2213  hkey))
2214  {
2215  namespace = GNUNET_CONTAINER_multishortmap_get (topo->map_namespaces,
2216  hkey);
2217  }
2218  else
2219  {
2220  namespace = GNUNET_new (struct GNUNET_TESTING_NetjailNamespace);
2221  namespace->namespace_n = out;
2222  namespace->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
2224  hkey,
2225  namespace,
2227  }
2228  namespace->router = router;
2229 
2230  }
2231  else if (0 == strcmp (key, "P"))
2232  {
2233  hkey = GNUNET_new (struct GNUNET_ShortHashCode);
2234  node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
2235 
2237  "Get first Value for P.\n");
2238  out = get_first_value (token);
2240  "P: %u\n",
2241  out);
2242  GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
2243  memcpy (hkey,
2244  &hc,
2245  sizeof (*hkey));
2246 
2248  topo->map_namespaces,
2249  hkey))
2250  {
2251  namespace = GNUNET_CONTAINER_multishortmap_get (topo->map_namespaces,
2252  hkey);
2253  }
2254  else
2255  {
2256  namespace = GNUNET_new (struct GNUNET_TESTING_NetjailNamespace);
2257  namespace->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
2258  namespace->namespace_n = out;
2260  hkey,
2261  namespace,
2263  }
2265  "Get second Value for P.\n");
2266  out = get_second_value (token);
2268  "P: %u\n",
2269  out);
2270  GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
2271  memcpy (hkey,
2272  &hc,
2273  sizeof (*hkey));
2275  namespace->nodes,
2276  hkey))
2277  {
2278  GNUNET_break (0);
2279  }
2280  else
2281  {
2282  node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
2283  GNUNET_CONTAINER_multishortmap_put (namespace->nodes,
2284  hkey,
2285  node,
2288  "Get value for key plugin on P.\n");
2289  value = get_value ("plugin", token);
2291  "plugin: %s\n",
2292  value);
2293  node->plugin = value;
2294  node->node_n = out;
2295  node->namespace_n = namespace->namespace_n;
2296  }
2297  node_connections (token, node);
2298  }
2299  token = strtok_r (NULL, "\n", &rest);
2300  }
2301 
2302  return topo;
2303 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_HashCode key
The key used in the DHT.
static char * filename
static struct GNUNET_FS_Handle * fs
Handle to FS service.
Definition: gnunet-fs.c:36
uint32_t data
The data value.
static char * value
Value of the record to add/remove.
@ GNUNET_YES
Definition: gnunet_common.h:97
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory).
Definition: disk.c:482
enum GNUNET_GenericReturnValue GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
Definition: disk.c:222
ssize_t GNUNET_DISK_fn_read(const char *fn, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: disk.c:664
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
int GNUNET_CONTAINER_multishortmap_put(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
void * GNUNET_CONTAINER_multishortmap_get(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Given a key find a value in the map matching the key.
int GNUNET_CONTAINER_multishortmap_contains(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
A 512-bit hashcode.
A 256-bit hashcode.
Node in the netjail topology.
unsigned int namespace_n
The number of the namespace this node is running in.
unsigned int is_global
Flag indicating if this node is a global known node.
char * plugin
Plugin for the test case to be run on this node.
unsigned int node_n
The number of this node in the namespace.
Router of a network namespace.
unsigned int tcp_port
Will tcp be forwarded?
unsigned int udp_port
Will udp be forwarded?
Toplogy of our netjail setup.
struct GNUNET_CONTAINER_MultiShortmap * map_globals
Hash map containing the global known nodes which are not natted.
char * plugin
Default plugin for the test case to be run on nodes.
unsigned int nodes_m
Number of nodes per namespace.
unsigned int nodes_x
Number of global known nodes per namespace.
unsigned int namespaces_n
Number of namespaces.
struct GNUNET_CONTAINER_MultiShortmap * map_namespaces
Hash map containing the namespaces (for natted nodes) of the topology.
static char * get_value(char *key, char *line)
Definition: testing.c:1865
static void node_connections(char *line, struct GNUNET_TESTING_NetjailNode *node)
Definition: testing.c:1970
static unsigned int get_second_value(char *line)
Definition: testing.c:1844
static unsigned int get_first_value(char *line)
Definition: testing.c:1779
static char * get_key(char *line)
Definition: testing.c:1799
static char * get_first_string_value(char *line)
Definition: testing.c:1819
#define LOG(kind,...)
Definition: testing.c:39

References _, data, filename, fs, get_first_string_value(), get_first_value(), get_key(), get_second_value(), get_value(), GNUNET_break, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multishortmap_contains(), GNUNET_CONTAINER_multishortmap_create(), GNUNET_CONTAINER_multishortmap_get(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_CRYPTO_hash(), GNUNET_DISK_file_size(), GNUNET_DISK_file_test(), GNUNET_DISK_fn_read(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_malloc, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_TESTING_NetjailNode::is_global, key, LOG, GNUNET_TESTING_NetjailTopology::map_globals, GNUNET_TESTING_NetjailTopology::map_namespaces, GNUNET_TESTING_NetjailNode::namespace_n, GNUNET_TESTING_NetjailTopology::namespaces_n, node_connections(), GNUNET_TESTING_NetjailNode::node_n, GNUNET_TESTING_NetjailTopology::nodes_m, GNUNET_TESTING_NetjailTopology::nodes_x, GNUNET_TESTING_NetjailNode::plugin, GNUNET_TESTING_NetjailTopology::plugin, ret, GNUNET_TESTING_NetjailRouter::tcp_port, GNUNET_TESTING_NetjailRouter::udp_port, and value.

Here is the call graph for this function:

◆ GNUNET_TESTING_cmd_stat()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_stat ( struct GNUNET_TESTING_Timer timers)

Obtain performance data from the interpreter.

Parameters
timerswhat commands (by label) to obtain runtimes for
Returns
the command

◆ GNUNET_TESTING_trait_end()

struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end ( void  )

"end" trait.

Because traits are offered into arrays, this type of trait is used to mark the end of such arrays; useful when iterating over those.

"end" trait.

Usually, commands offer several traits, and put them in arrays.

Definition at line 1 of file testing_api_traits.c.

38 {
39  struct GNUNET_TESTING_Trait end = {
40  .index = 0,
41  .trait_name = NULL,
42  .ptr = NULL
43  };
44 
45  return end;
46 }
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34

Referenced by block_until_external_trigger_traits(), connect_peers_traits(), hello_world_birth_traits(), netjail_exec_traits(), start_peer_traits(), and system_create_traits().

Here is the caller graph for this function:

◆ GNUNET_TESTING_get_trait()

enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait ( const struct GNUNET_TESTING_Trait traits,
const void **  ret,
const char *  trait,
unsigned int  index 
)

Extract a trait.

Parameters
traitsthe array of all the traits.
[out]retwhere to store the result.
traittype of the trait to extract.
indexindex number of the trait to extract.
Returns
GNUNET_OK when the trait is found.

Extract a trait.

Parameters
traitsthe traits array.
retwhere to store the result.
traittype of the trait to extract.
indexindex number of the object to extract.
Returns
GNUNET_OK if no error occurred, GNUNET_SYSERR otherwise.

Definition at line 1 of file testing_api_traits.c.

63 {
64  for (unsigned int i = 0; NULL != traits[i].trait_name; i++)
65  {
66  if ( (0 == strcmp (trait, traits[i].trait_name)) &&
67  (index == traits[i].index) )
68  {
69  *ret = (void *) traits[i].ptr;
70  return GNUNET_OK;
71  }
72  }
74  "Trait %s/%u not found.\n",
75  trait, index);
76 
77  return GNUNET_SYSERR;
78 }
@ GNUNET_ERROR_TYPE_INFO
const char * trait_name
Trait type, for example "reserve-pub" or "coin-priv".

References end.

Referenced by block_until_external_trigger_traits(), connect_peers_traits(), hello_world_birth_traits(), netjail_exec_traits(), start_peer_traits(), and system_create_traits().

Here is the caller graph for this function:

◆ GNUNET_TESTING_get_trait_process()

enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_process ( const struct GNUNET_TESTING_Command cmd,
unsigned int  index,
struct GNUNET_OS_Process ***  processp 
)

Obtain location where a command stores a pointer to a process.

Parameters
cmdcommand to extract trait from.
indexwhich process to pick if cmd has multiple on offer. – FIXME: remove?
[out]processpset to the address of the pointer to the process.
Returns
GNUNET_OK on success.
Parameters
cmdcommand to extract trait from.
indexwhich process to pick if cmd has multiple on offer.
[out]processpset to the address of the pointer to the process.
Returns
GNUNET_OK on success.

Definition at line 45 of file testing_api_trait_process.c.

49 {
50  return cmd->traits (cmd->cls,
51  (const void **) processp,
53  index);
54 }
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.
#define GNUNET_TESTING_TRAIT_PROCESS

References GNUNET_TESTING_Command::cls, GNUNET_TESTING_TRAIT_PROCESS, and GNUNET_TESTING_Command::traits.

◆ GNUNET_TESTING_make_trait_process()

struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_process ( unsigned int  index,
struct GNUNET_OS_Process **  processp 
)

Offer location where a command stores a pointer to a process.

Parameters
indexoffered location index number, in case there are multiple on offer. // FIXME: remove?
processpprocess location to offer.
Returns
the trait.
Parameters
indexoffered location index number, in case there are multiple on offer.
processpprocess location to offer.
Returns
the trait.

Definition at line 45 of file testing_api_trait_process.c.

70 {
71  struct GNUNET_TESTING_Trait ret = {
72  .index = index,
73  .trait_name = GNUNET_TESTING_TRAIT_PROCESS,
74  .ptr = (const void *) processp
75  };
76 
77  return ret;
78 }
unsigned int index
Index number associated with the trait.

◆ GNUNET_TESTING_make_trait_uint32()

struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_uint32 ( unsigned int  index,
const uint32_t *  n 
)

Offer number trait, 32-bit version.

Parameters
indexthe number's index number. // FIXME: introduce enum?
nnumber to offer.

◆ GNUNET_TESTING_get_trait_uint32()

enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_uint32 ( const struct GNUNET_TESTING_Command cmd,
unsigned int  index,
const uint32_t **  n 
)

Obtain a "number" value from cmd, 32-bit version.

Parameters
cmdcommand to extract the number from.
indexthe number's index number. // FIXME: introduce enum?
[out]nset to the number coming from cmd.
Returns
GNUNET_OK on success.

◆ GNUNET_TESTING_make_trait_uint64()

struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_uint64 ( unsigned int  index,
const uint64_t *  n 
)

Offer number trait, 64-bit version.

Parameters
indexthe number's index number. // FIXME: introduce enum?
nnumber to offer.

◆ GNUNET_TESTING_get_trait_uint64()

enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_uint64 ( const struct GNUNET_TESTING_Command cmd,
unsigned int  index,
const uint64_t **  n 
)

Obtain a "number" value from cmd, 64-bit version.

Parameters
cmdcommand to extract the number from.
indexthe number's index number. // FIXME: introduce enum?
[out]nset to the number coming from cmd.
Returns
GNUNET_OK on success.

◆ GNUNET_TESTING_make_trait_int64()

struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_int64 ( unsigned int  index,
const int64_t *  n 
)

Offer number trait, 64-bit signed version.

Parameters
indexthe number's index number. // FIXME: introduce enum?
nnumber to offer.

◆ GNUNET_TESTING_get_trait_int64()

enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_int64 ( const struct GNUNET_TESTING_Command cmd,
unsigned int  index,
const int64_t **  n 
)

Obtain a "number" value from cmd, 64-bit signed version.

Parameters
cmdcommand to extract the number from.
indexthe number's index number. // FIXME: introduce enum?
[out]nset to the number coming from cmd.
Returns
GNUNET_OK on success.

◆ GNUNET_TESTING_make_trait_uint()

struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_uint ( unsigned int  index,
const unsigned int *  i 
)

Offer a number.

Parameters
indexthe number's index number.
nthe number to offer. // FIXME: introduce enum?
Returns
GNUNET_OK on success.

◆ GNUNET_TESTING_get_trait_uint()

enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_uint ( const struct GNUNET_TESTING_Command cmd,
unsigned int  index,
const unsigned int **  n 
)

Obtain a number from cmd.

Parameters
cmdcommand to extract the number from.
indexthe number's index number. // FIXME: introduce enum?
[out]nset to the number coming from cmd.
Returns
GNUNET_OK on success.

◆ GNUNET_TESTING_get_trait_string()

enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_string ( const struct GNUNET_TESTING_Command cmd,
unsigned int  index,
const char **  s 
)

Obtain a string from cmd.

Parameters
cmdcommand to extract the subject from.
indexindex number associated with the transfer subject to offer. // FIXME: introduce enum?
[out]swhere to write the offered string.
Returns
GNUNET_OK on success.

◆ GNUNET_TESTING_make_trait_string()

struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_string ( unsigned int  index,
const char *  s 
)

Offer string subject.

Parameters
indexindex number associated with the transfer subject being offered. // FIXME: introduce enum?
sstring to offer.
Returns
the trait.

◆ GNUNET_TESTING_make_trait_cmd()

struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_cmd ( unsigned int  index,
const struct GNUNET_TESTING_Command cmd 
)

Offer a command in a trait.

Parameters
indexalways zero. Commands offering this kind of traits do not need this index. For example, a "meta" CMD returns always the CMD currently being executed. FIXME: remove!
cmdwire details to offer.
Returns
the trait.
Parameters
indexalways zero. Commands offering this kind of traits do not need this index. For example, a "meta" CMD returns always the CMD currently being executed.
cmdwire details to offer.
Returns
the trait.

Definition at line 1 of file testing_api_trait_cmd.c.

69 {
70  struct GNUNET_TESTING_Trait ret = {
71  .index = index,
72  .trait_name = GNUNET_TESTING_TRAIT_CMD,
73  .ptr = (const struct GNUNET_TESTING_Command *) cmd
74  };
75  return ret;
76 }
#define GNUNET_TESTING_TRAIT_CMD

◆ GNUNET_TESTING_get_trait_cmd()

enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_cmd ( const struct GNUNET_TESTING_Command cmd,
unsigned int  index,
struct GNUNET_TESTING_Command **  _cmd 
)

Obtain a command from cmd.

Parameters
cmdcommand to extract the command from.
indexalways zero. Commands offering this kind of traits do not need this index. For example, a "meta" CMD returns always the CMD currently being executed. FIXME: remove!
[out]_cmdwhere to write the wire details.
Returns
GNUNET_OK on success.
Parameters
cmdcommand to extract the command from.
indexalways zero. Commands offering this kind of traits do not need this index. For example, a "batch" CMD returns always the CMD currently being executed.
[out]_cmdwhere to write the wire details.
Returns
GNUNET_OK on success.

Definition at line 1 of file testing_api_trait_cmd.c.

48 {
49  return cmd->traits (cmd->cls,
50  (const void **) _cmd,
52  index);
53 }

Referenced by GNUNET_TESTING_interpreter_lookup_command().

Here is the caller graph for this function:

◆ GNUNET_TESTING_get_trait_uuid()

enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_uuid ( const struct GNUNET_TESTING_Command cmd,
unsigned int  index,
struct GNUNET_Uuid **  uuid 
)

Obtain a uuid from cmd.

Parameters
cmdcommand to extract the uuid from.
indexwhich amount to pick if cmd has multiple on offer // FIXME: introduce enum?
[out]uuidwhere to write the uuid.
Returns
GNUNET_OK on success.

◆ GNUNET_TESTING_make_trait_uuid()

struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_uuid ( unsigned int  index,
const struct GNUNET_Uuid uuid 
)

Offer a uuid in a trait.

Parameters
indexwhich uuid to offer, in case there are multiple available. // FIXME: introduce enum?
uuidthe uuid to offer.
Returns
the trait.

◆ GNUNET_TESTING_get_trait_absolute_time()

enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_absolute_time ( const struct GNUNET_TESTING_Command cmd,
unsigned int  index,
const struct GNUNET_TIME_Absolute **  time 
)

Obtain a absolute time from cmd.

Parameters
cmdcommand to extract trait from
indexwhich time stamp to pick if cmd has multiple on offer // FIXME: introduce enum?
[out]timeset to the wanted WTID.
Returns
GNUNET_OK on success

◆ GNUNET_TESTING_make_trait_absolute_time()

struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_absolute_time ( unsigned int  index,
const struct GNUNET_TIME_Absolute time 
)

Offer a absolute time.

Parameters
indexassociate the object with this index
timewhich object should be returned
Returns
the trait.

◆ GNUNET_TESTING_get_trait_relative_time()

int GNUNET_TESTING_get_trait_relative_time ( const struct GNUNET_TESTING_Command cmd,
unsigned int  index,
const struct GNUNET_TIME_Relative **  time 
)

Obtain a relative time from cmd.

Parameters
cmdcommand to extract trait from
indexwhich time to pick if cmd has multiple on offer.
[out]timeset to the wanted WTID.
Returns
GNUNET_OK on success

◆ GNUNET_TESTING_make_trait_relative_time()

struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_relative_time ( unsigned int  index,
const struct GNUNET_TIME_Relative time 
)

Offer a relative time.

Parameters
indexassociate the object with this index
timewhich object should be returned
Returns
the trait.

◆ GNUNET_TESTING_cmd_hello_world_birth()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_hello_world_birth ( const char *  label,
struct GNUNET_TIME_Absolute now 
)

Create command.

Parameters
labelname for command.
nowwhen the command was started.
Returns
command.

Definition at line 126 of file testing_api_cmd_hello_world_birth.c.

146 {
147  struct HelloWorldBirthState *hbs;
148 
149  hbs = GNUNET_new (struct HelloWorldBirthState);
150  hbs->date = now;
151 
152  struct GNUNET_TESTING_Command cmd = {
153  .cls = hbs,
154  .label = label,
155  .run = &hello_world_birth_run,
156  .cleanup = &hello_world_birth_cleanup,
157  .traits = &hello_world_birth_traits
158  };
159 
160  return cmd;
161 }
struct GNUNET_TIME_Absolute * date
static void hello_world_birth_cleanup(void *cls)
static int hello_world_birth_traits(void *cls, const void **ret, const char *trait, unsigned int index)
static void hello_world_birth_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
Run the "hello world" CMD.

References GNUNET_TESTING_Command::cls, and GNUNET_TESTING_Command::traits.

◆ GNUNET_TESTING_cmd_hello_world()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_hello_world ( const char *  label,
const char *  birthLabel,
char *  message 
)

Create command.

Parameters
labelname for command.
messageinitial message.
Returns
command.

Definition at line 79 of file testing_api_cmd_hello_world.c.

109 {
110  struct HelloWorldState *hs;
111 
112  hs = GNUNET_new (struct HelloWorldState);
113  hs->message = "Hello World, I was nobody!";
114  hs->birthLabel = birthLabel;
115  {
116  struct GNUNET_TESTING_Command cmd = {
117  .cls = hs,
118  .label = label,
119  .run = &hello_world_run,
120  .cleanup = &hello_world_cleanup,
121  .traits = &hello_world_traits
122  };
123 
124  return cmd;
125  }
126 }
static enum GNUNET_GenericReturnValue hello_world_traits(void *cls, const void **ret, const char *trait, unsigned int index)
static void hello_world_cleanup(void *cls)
static void hello_world_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
Run the "hello world" CMD.

◆ GNUNET_TESTING_get_trait_what_am_i()

int GNUNET_TESTING_get_trait_what_am_i ( const struct GNUNET_TESTING_Command cmd,
char **  what_am_i 
)

Offer data from trait.

Parameters
cmdcommand to extract the url from.
ptwhich url is to be picked, in case multiple are offered.
[out]urlwhere to write the url.
Returns
GNUNET_OK on success.
Parameters
cmdcommand to extract the message from.
ptpointer to message.
Returns
GNUNET_OK on success.

Definition at line 126 of file testing_api_cmd_hello_world_birth.c.

128 {
129  return cmd->traits (cmd->cls,
130  (const void **) what_am_i,
131  "what_am_i",
132  (unsigned int) 0);
133 }

Referenced by hello_world_run().

Here is the caller graph for this function:

◆ GNUNET_TESTING_get_trait_test_system()

int GNUNET_TESTING_get_trait_test_system ( const struct GNUNET_TESTING_Command cmd,
struct GNUNET_TESTING_System **  test_system 
)

Function to get the trait with struct GNUNET_TESTING_System.

Parameters
[out]test_systemThe struct GNUNET_TESTING_System.
Returns
GNUNET_OK if no error occurred, GNUNET_SYSERR otherwise.

Definition at line 101 of file testing_api_cmd_system_create.c.

104 {
105  return cmd->traits (cmd->cls,
106  (const void **) test_system,
107  "test_system",
108  (unsigned int) 0);
109 }
static struct GNUNET_TESTING_System * test_system
Handle to the testing system.

References GNUNET_TESTING_Command::cls, test_system, and GNUNET_TESTING_Command::traits.

Referenced by connect_peers_run(), start_peer_run(), and system_destroy_run().

Here is the caller graph for this function:

◆ GNUNET_TESTING_cmd_system_create()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_system_create ( const char *  label,
const char *  testdir 
)

Create command.

Parameters
labelname for command.
labelname for the test environment directory.
Returns
command.

Definition at line 117 of file testing_api_cmd_system_create.c.

135 {
136  struct TestSystemState *tss;
137 
138  tss = GNUNET_new (struct TestSystemState);
139  tss->testdir = testdir;
140 
141  struct GNUNET_TESTING_Command cmd = {
142  .cls = tss,
143  .label = label,
144  .run = &system_create_run,
145  .cleanup = &system_create_cleanup,
146  .traits = &system_create_traits
147  };
148 
149  return cmd;
150 }
Struct to hold information for callbacks.
static void system_create_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will setup a test environment for a node.
static int system_create_traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.
static void system_create_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.

◆ GNUNET_TESTING_cmd_system_destroy()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_system_destroy ( const char *  label,
const char *  create_label 
)

Create command.

Parameters
labelname for command.
create_labelLabel of the cmd which started the test system.
Returns
command.

Definition at line 69 of file testing_api_cmd_system_destroy.c.

101 {
102  struct TestSystemState *tss;
103 
104  tss = GNUNET_new (struct TestSystemState);
105  tss->create_label = create_label;
106  {
107  struct GNUNET_TESTING_Command cmd = {
108  .cls = tss,
109  .label = label,
110  .run = &system_destroy_run,
111  .cleanup = &system_destroy_cleanup,
112  .traits = &system_destroy_traits
113  };
114 
115  return cmd;
116  }
117 }
static void system_destroy_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.
static void system_destroy_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will remove the test environment for a node.
static enum GNUNET_GenericReturnValue system_destroy_traits(void *cls, const void **ret, const char *trait, unsigned int index)
Trait function of this cmd does nothing.

◆ GNUNET_TESTING_cmd_netjail_start()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_netjail_start ( const char *  label,
char *  topology_config 
)

Create command.

Parameters
labelname for command.
topology_configConfiguration file for the test topology.
Returns
command.

Definition at line 124 of file testing_api_cmd_netjail_start.c.

193 {
194  struct NetJailState *ns;
195 
196  ns = GNUNET_new (struct NetJailState);
197  ns->topology_config = topology_config;
198  {
199  struct GNUNET_TESTING_Command cmd = {
200  .cls = ns,
201  .label = label,
202  .run = &netjail_start_run,
203  .ac = &ns->ac,
204  .cleanup = &netjail_start_cleanup
205  };
206 
207  return cmd;
208  }
209 }
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
Definition: gnunet-abd.c:41
Struct to hold information for callbacks.
char * topology_config
Configuration file for the test topology.
static void netjail_start_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
The run method starts the script which setup the network namespaces.
static void netjail_start_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.

◆ GNUNET_TESTING_cmd_netjail_start_testing_system()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_netjail_start_testing_system ( const char *  label,
const char *  topology_config 
)

Create command.

Parameters
labelName for the command.
topology_configConfiguration file for the test topology.
rvPointer to the return value of the test.
Returns
command.
Parameters
labelName for the command.
topology_configConfiguration file for the test topology.
Returns
command.

Definition at line 636 of file testing_api_cmd_netjail_start_testsystem.c.

672 {
673  struct NetJailState *ns;
674 
676  GNUNET_TESTING_get_topo_from_file (topology_config);
677 
678  ns = GNUNET_new (struct NetJailState);
679  ns->local_m = topology->nodes_m;
680  ns->global_n = topology->namespaces_n;
681  ns->known = topology->nodes_x;
682  ns->plugin_name = topology->plugin;
683  ns->topology = topology;
684 
685  struct GNUNET_TESTING_Command cmd = {
686  .cls = ns,
687  .label = label,
688  .run = &netjail_exec_run,
689  .ac = &ns->ac,
690  .cleanup = &netjail_exec_cleanup,
691  .traits = &netjail_exec_traits
692  };
693 
694  return cmd;
695 }
enum GNUNET_TESTBED_TopologyOption topology
The topology to generate.
struct GNUNET_TESTING_NetjailTopology * GNUNET_TESTING_get_topo_from_file(const char *filename)
Getting the topology from file.
Definition: testing.c:2038
static int netjail_exec_traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.
static void netjail_exec_cleanup(void *cls)
Code to clean up resource this cmd used.
static void netjail_exec_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
This function starts a helper process for each node.

◆ GNUNET_TESTING_cmd_netjail_stop()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_netjail_stop ( const char *  label,
char *  topology_config 
)

Create command.

Parameters
labelname for command.
topology_configConfiguration file for the test topology.
Returns
command.

Definition at line 119 of file testing_api_cmd_netjail_stop.c.

169 {
170  struct NetJailState *ns;
171 
172  ns = GNUNET_new (struct NetJailState);
173  ns->topology_config = topology_config;
174  {
175  struct GNUNET_TESTING_Command cmd = {
176  .cls = ns,
177  .label = label,
178  .run = &netjail_stop_run,
179  .ac = &ns->ac,
180  .cleanup = &netjail_stop_cleanup
181  };
182 
183  return cmd;
184  }
185 }
static void netjail_stop_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.
static void netjail_stop_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
The run method starts the script which deletes the network namespaces.

◆ GNUNET_TESTING_cmd_stop_testing_system()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_stop_testing_system ( const char *  label,
const char *  helper_start_label,
const char *  topology_config 
)

Create command.

Parameters
labelname for command.
topology_configConfiguration file for the test topology.
Returns
command.
Parameters
labelname for command.
helper_start_labellabel of the cmd to start the test system.
topology_configConfiguration file for the test topology.
Returns
command.

Definition at line 91 of file testing_api_cmd_netjail_stop_testsystem.c.

140 {
141  struct StopHelperState *shs;
142 
144  GNUNET_TESTING_get_topo_from_file (topology_config);
145 
146  shs = GNUNET_new (struct StopHelperState);
147  shs->helper_start_label = helper_start_label;
148  shs->local_m = topology->nodes_m;
149  shs->global_n = topology->namespaces_n;
150  shs->known = topology->nodes_x;
151 
152  struct GNUNET_TESTING_Command cmd = {
153  .cls = shs,
154  .label = label,
155  .run = &stop_testing_system_run,
156  .cleanup = &stop_testing_system_cleanup,
157  .traits = &stop_testing_system_traits
158  };
159 
160  return cmd;
161 }
Struct to store information handed over to callbacks.
unsigned int known
Number of global known nodes.
static void stop_testing_system_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
This function stops the helper process for each node.
static int stop_testing_system_traits(void *cls, const void **ret, const char *trait, unsigned int index)
Trait function of this cmd does nothing.
static void stop_testing_system_cleanup(void *cls)
Code to clean up resource this cmd used.

◆ GNUNET_TESTING_send_local_test_finished_msg()

struct GNUNET_MessageHeader* GNUNET_TESTING_send_local_test_finished_msg ( enum GNUNET_GenericReturnValue  rv)

Create a GNUNET_CMDS_LOCAL_FINISHED message.

Parameters
rvThe result of the local test as GNUNET_GenericReturnValue.
Returns
The GNUNET_CMDS_LOCAL_FINISHED message.

Definition at line 2013 of file testing.c.

2014 {
2015  struct GNUNET_CMDS_LOCAL_FINISHED *reply;
2016  size_t msg_length;
2017 
2019  "Local test exits with status %d\n",
2020  rv);
2021  msg_length = sizeof(struct GNUNET_CMDS_LOCAL_FINISHED);
2022  reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_FINISHED);
2024  reply->header.size = htons ((uint16_t) msg_length);
2025  reply->result = htons (rv);
2026 
2027  return (struct GNUNET_MessageHeader *) reply;
2028 }
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED.
Definition: testing_cmds.h:85
enum GNUNET_GenericReturnValue result
Definition: testing_cmds.h:87
Header for all communications.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED, GNUNET_new, GNUNET_CMDS_LOCAL_FINISHED::header, GNUNET_CMDS_LOCAL_FINISHED::result, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

◆ GNUNET_TESTING_get_trait_async_context()

int GNUNET_TESTING_get_trait_async_context ( const struct GNUNET_TESTING_Command cmd,
struct GNUNET_TESTING_AsyncContext **  ac 
)

Function to get the trait with the async context.

Parameters
[out]acGNUNET_TESTING_AsyncContext.
Returns
GNUNET_OK if no error occurred, GNUNET_SYSERR otherwise.

Definition at line 96 of file testing_api_cmd_block_until_external_trigger.c.

99 {
100  return cmd->traits (cmd->cls,
101  (const void **) ac,
102  "async_context",
103  (unsigned int) 0);
104 }

References ac, GNUNET_TESTING_Command::cls, and GNUNET_TESTING_Command::traits.

◆ GNUNET_TESTING_get_trait_helper_handles()

enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_helper_handles ( const struct GNUNET_TESTING_Command cmd,
struct GNUNET_HELPER_Handle ***  helper 
)

Offer handles to testing cmd helper from trait.

Parameters
cmdcommand to extract the message from.
ptpointer to message.
Returns
GNUNET_OK on success.

Definition at line 283 of file testing_api_cmd_netjail_start_testsystem.c.

287 {
288  return cmd->traits (cmd->cls,
289  (const void **) helper,
290  "helper_handles",
291  (unsigned int) 0);
292 }

References GNUNET_TESTING_Command::cls, and GNUNET_TESTING_Command::traits.

Referenced by stop_testing_system_run().

Here is the caller graph for this function:

◆ GNUNET_TESTING_cmd_block_until_all_peers_started()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_block_until_all_peers_started ( const char *  label,
unsigned int *  all_peers_started 
)

Create command.

Parameters
labelname for command.
all_peers_startedFlag which will be set from outside.
Returns
command.

Definition at line 72 of file testing_api_cmd_block_until_all_peers_started.c.

91 {
92  struct BlockState *bs;
93 
94  bs = GNUNET_new (struct BlockState);
96  {
97  struct GNUNET_TESTING_Command cmd = {
98  .cls = bs,
99  .label = label,
101  .ac = &bs->ac,
103  };
104 
105  return cmd;
106  }
107 }
Struct with information for callbacks.
unsigned int * all_peers_started
Flag to indicate if all peers have started.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
const char * label
The label of this command.
static void block_until_all_peers_started_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.
static void block_until_all_peers_started_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
This function does nothing but to start the cmd.

◆ GNUNET_TESTING_cmd_block_until_external_trigger()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_block_until_external_trigger ( const char *  label)

Create command.

Parameters
labelname for command.
all_peers_startedFlag which will be set from outside.
Returns
command.

Definition at line 112 of file testing_api_cmd_block_until_external_trigger.c.

132 {
133  struct BlockState *bs;
134 
135  bs = GNUNET_new (struct BlockState);
136  bs->label = label;
137  {
138  struct GNUNET_TESTING_Command cmd = {
139  .cls = bs,
140  .label = label,
142  .ac = &bs->ac,
145  };
146 
147  return cmd;
148  }
149 }
static void block_until_all_peers_started_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.
static int block_until_external_trigger_traits(void *cls, const void **ret, const char *trait, unsigned int index)
static void block_until_all_peers_started_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
This function does nothing but to start the cmd.

◆ GNUNET_TESTING_cmd_send_peer_ready()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_send_peer_ready ( const char *  label,
TESTING_CMD_HELPER_write_cb  write_message 
)

Create command.

Parameters
labelname for command.
write_messageCallback to write messages to the master loop.
Returns
command.

Definition at line 85 of file testing_api_cmd_send_peer_ready.c.

111 {
112  struct SendPeerReadyState *sprs;
113 
114  sprs = GNUNET_new (struct SendPeerReadyState);
116  {
117  struct GNUNET_TESTING_Command cmd = {
118  .cls = sprs,
119  .label = label,
120  .run = &send_peer_ready_run,
121  .cleanup = &send_peer_ready_cleanup,
122  .traits = &send_peer_ready_traits
123  };
124 
125  return cmd;
126  }
127 }
static int write_message(uint16_t message_type, const char *data, size_t data_length)
Write message to the master process.
Struct to hold information for callbacks.
TESTING_CMD_HELPER_write_cb write_message
Callback to write messages to the master loop.
static void send_peer_ready_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED message to the master loop.
static void send_peer_ready_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.
static enum GNUNET_GenericReturnValue send_peer_ready_traits(void *cls, const void **ret, const char *trait, unsigned int index)
Trait function of this cmd does nothing.

◆ GNUNET_TESTING_cmd_local_test_finished()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_local_test_finished ( const char *  label,
TESTING_CMD_HELPER_write_cb  write_message 
)

Create command.

Parameters
labelname for command.
write_messageCallback to write messages to the master loop.
Returns
command.

Definition at line 77 of file testing_api_cmd_local_test_finished.c.

105 {
106  struct LocalFinishedState *lfs;
107 
108  lfs = GNUNET_new (struct LocalFinishedState);
110  {
111  struct GNUNET_TESTING_Command cmd = {
112  .cls = lfs,
113  .label = label,
114  .run = &local_test_finished_run,
115  .cleanup = &local_test_finished_cleanup,
116  };
117 
118  return cmd;
119  }
120 }
Struct to hold information for callbacks.
TESTING_CMD_HELPER_write_cb write_message
Callback to write messages to the master loop.
static void local_test_finished_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED message to the master loop.
static void local_test_finished_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.