GNUnet  0.20.0
testing_api_loop.c File Reference

main interpreter loop for testcases More...

Include dependency graph for testing_api_loop.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_TESTING_Interpreter
 Global state of the interpreter, used by a command to access information about other commands. More...
 
struct  FreeBarrierNodeCbCls
 
struct  MainParams
 Closure for loop_run(). More...
 

Functions

static const struct GNUNET_TESTING_Commandget_command (struct GNUNET_TESTING_Interpreter *is, const char *label, unsigned int future)
 
const struct GNUNET_TESTING_CommandGNUNET_TESTING_interpreter_lookup_future_command (struct GNUNET_TESTING_Interpreter *is, const char *label)
 Lookup command by label. More...
 
const struct GNUNET_TESTING_CommandGNUNET_TESTING_interpreter_lookup_command (struct GNUNET_TESTING_Interpreter *is, const char *label)
 Lookup command by label. More...
 
const struct GNUNET_TESTING_CommandGNUNET_TESTING_interpreter_lookup_command_all (struct GNUNET_TESTING_Interpreter *is, const char *label)
 Lookup command by label. More...
 
int free_barrier_node_cb (void *cls, const struct GNUNET_ShortHashCode *key, void *value)
 
static int free_barriers_cb (void *cls, const struct GNUNET_ShortHashCode *key, void *value)
 
static void interpreter_delete_barriers (struct GNUNET_TESTING_Interpreter *is)
 Deleting all barriers create in the context of this interpreter. More...
 
static void finish_test (void *cls)
 Finish the test run, return the final result. More...
 
static void interpreter_run (void *cls)
 Run the main interpreter loop that performs exchange operations. More...
 
static void interpreter_next (void *cls)
 Current command is done, run the next one. More...
 
void GNUNET_TESTING_interpreter_fail (struct GNUNET_TESTING_Interpreter *is)
 Current command failed, clean up and fail the test case. More...
 
struct GNUNET_TESTING_CommandGNUNET_TESTING_interpreter_get_current_command (struct GNUNET_TESTING_Interpreter *is)
 Returns the actual running command. More...
 
const char * GNUNET_TESTING_interpreter_get_current_label (struct GNUNET_TESTING_Interpreter *is)
 Obtain label of the command being now run. More...
 
static void do_timeout (void *cls)
 Function run when the test terminates (good or bad) with timeout. More...
 
enum GNUNET_GenericReturnValue GNUNET_TESTING_running (const struct GNUNET_TESTING_Command *command)
 Check if the command is running. More...
 
enum GNUNET_GenericReturnValue GNUNET_TESTING_finished (const struct GNUNET_TESTING_Command *command)
 Check if a command is finished. More...
 
struct GNUNET_TESTING_InterpreterGNUNET_TESTING_run (const struct GNUNET_TESTING_Command *commands, struct GNUNET_TIME_Relative timeout, GNUNET_TESTING_ResultCallback rc, void *rc_cls)
 Run the testsuite. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_command_new (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. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_end (void)
 Create command array terminator. More...
 
static void handle_result (void *cls, enum GNUNET_GenericReturnValue rv)
 Function called with the final result of the test. More...
 
static void loop_run (void *cls)
 Main function to run the test cases. More...
 
static void clear_msg (void *cls, int result)
 Continuation function from GNUNET_HELPER_send() More...
 
void GNUNET_TESTING_add_netjail_helper (struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_HELPER_Handle *helper)
 Adding a helper handle to the interpreter. More...
 
void send_message_to_netjail (struct GNUNET_TESTING_Interpreter *is, unsigned int global_node_number, struct GNUNET_MessageHeader *header)
 Send Message to netjail nodes. More...
 
void TST_interpreter_send_barrier_crossable (struct GNUNET_TESTING_Interpreter *is, const char *barrier_name, unsigned int global_node_number)
 Send Message to a netjail node that a barrier can be crossed. More...
 
struct GNUNET_TESTING_BarrierTST_interpreter_get_barrier (struct GNUNET_TESTING_Interpreter *is, const char *barrier_name)
 Getting a barrier from the interpreter. More...
 
void TST_interpreter_finish_attached_cmds (struct GNUNET_TESTING_Interpreter *is, const char *barrier_name)
 Finish all "barrier reached" comands attached to this barrier. More...
 
void TST_interpreter_add_barrier (struct GNUNET_TESTING_Interpreter *is, struct GNUNET_TESTING_Barrier *barrier)
 Add a barrier to the loop. 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...
 
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...
 

Detailed Description

main interpreter loop for testcases

Author
Christian Grothoff (GNU Taler testing)
Marcello Stanisci (GNU Taler testing)
t3sserakt

Definition in file testing_api_loop.c.

Function Documentation

◆ get_command()

static const struct GNUNET_TESTING_Command* get_command ( struct GNUNET_TESTING_Interpreter is,
const char *  label,
unsigned int  future 
)
static

Definition at line 127 of file testing_api_loop.c.

130 {
131  int start_i = GNUNET_NO == future ? is->ip : is->cmds_n - 1;
132  int end_i = GNUNET_NO == future ? 0 : is->ip + 1;
133 
135  "start_i: %u end_i: %u\n",
136  start_i,
137  end_i);
138  if (NULL == label)
139  {
141  "Attempt to lookup command for empty label\n");
142  return NULL;
143  }
144 
145  for (int i = start_i; i >= end_i; i--)
146  {
147  const struct GNUNET_TESTING_Command *cmd = &is->commands[i];
148 
149  if (NULL != cmd->run)
151  "label to compare %s\n",
152  cmd->label);
153  /* Give precedence to top-level commands. */
154  if ( (NULL != cmd->run) &&
155  (0 == strcmp (cmd->label,
156  label)) )
157  return cmd;
158 
160  {
161  struct GNUNET_TESTING_Command **batch;
162  struct GNUNET_TESTING_Command *current;
163  const struct GNUNET_TESTING_Command *icmd;
164  const struct GNUNET_TESTING_Command *match;
165 
169  &batch));
170  /* We must do the loop forward, but we can find the last match */
171  match = NULL;
172  for (unsigned int j = 0;
173  NULL != (icmd = &(*batch)[j])->run;
174  j++)
175  {
176  if (current == icmd)
177  break; /* do not go past current command */
178  if ( (NULL != icmd->run) &&
179  (0 == strcmp (icmd->label,
180  label)) )
181  match = icmd;
182  }
183  if (NULL != match)
184  return match;
185  }
186  }
188  "Command `%s' not found\n",
189  label);
190  return NULL;
191 }
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run.
Definition: gnunet-abd.c:757
struct GNUNET_TESTING_Interpreter * is
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_batch_cmds(const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Command ***ret)
#define GNUNET_log(kind,...)
@ GNUNET_OK
@ GNUNET_NO
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
A command to be run by the interpreter.
char label[127+1]
Label for the command.
GNUNET_TESTING_CommandRunRoutine run
Runs the command.
unsigned int cmds_n
Number of GNUNET_TESTING_Command in commands.
int ip
Instruction pointer.
struct GNUNET_TESTING_Command * commands
Commands the interpreter will run.
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.

References GNUNET_TESTING_Interpreter::cmds_n, GNUNET_TESTING_Interpreter::commands, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_TESTING_cmd_batch_get_current_(), GNUNET_TESTING_cmd_is_batch_(), GNUNET_TESTING_get_trait_batch_cmds(), GNUNET_TESTING_Interpreter::ip, is, GNUNET_TESTING_Command::label, run(), and GNUNET_TESTING_Command::run.

Referenced by GNUNET_TESTING_interpreter_lookup_command(), GNUNET_TESTING_interpreter_lookup_command_all(), and GNUNET_TESTING_interpreter_lookup_future_command().

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

◆ GNUNET_TESTING_interpreter_lookup_future_command()

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

Lookup command by label.

Only future commands are looked up.

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

Definition at line 203 of file testing_api_loop.c.

206 {
207  return get_command (is, label, GNUNET_YES);
208 }
@ GNUNET_YES
static const struct GNUNET_TESTING_Command * get_command(struct GNUNET_TESTING_Interpreter *is, const char *label, unsigned int future)

References get_command(), GNUNET_YES, is, and GNUNET_TESTING_Command::label.

Here is the call graph for this function:

◆ 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.

Only commands from current command to commands in the past are looked up.

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

Definition at line 220 of file testing_api_loop.c.

223 {
224  return get_command (is, label, GNUNET_NO);
225 }

References get_command(), GNUNET_NO, is, and GNUNET_TESTING_Command::label.

Referenced by backchannel_check_run(), connect_peers_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_lookup_command_all()

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

Lookup command by label.

All commands, first into the past, then into the future are looked up.

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

Definition at line 229 of file testing_api_loop.c.

232 {
233  const struct GNUNET_TESTING_Command *cmd;
234 
235  cmd = get_command (is, label, GNUNET_NO);
236  if (NULL == cmd)
237  cmd = get_command (is, label, GNUNET_YES);
238  return cmd;
239 }

References get_command(), GNUNET_NO, GNUNET_YES, is, and GNUNET_TESTING_Command::label.

Referenced by notify_connect().

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

◆ free_barrier_node_cb()

int free_barrier_node_cb ( void *  cls,
const struct GNUNET_ShortHashCode key,
void *  value 
)

Definition at line 243 of file testing_api_loop.c.

246 {
247  struct FreeBarrierNodeCbCls *free_barrier_node_cb_cls = cls;
248  struct GNUNET_TESTING_NetjailNode *node = value;
249  struct GNUNET_TESTING_Barrier *barrier = free_barrier_node_cb_cls->barrier;
250  struct GNUNET_TESTING_Interpreter *is = free_barrier_node_cb_cls->is;
251 
253  "free_barrier_node_cb\n");
254  if (GNUNET_NO == is->finishing)
255  {
257  "TST_interpreter_send_barrier_crossable\n");
259  barrier->name,
260  node->node_number);
261  }
263  barrier->nodes, key, node));
264  return GNUNET_YES;
265 }
struct GNUNET_HashCode key
The key used in the DHT.
static char * value
Value of the record to add/remove.
int GNUNET_CONTAINER_multishortmap_remove(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, const void *value)
Remove the given key-value pair from the map.
struct GNUNET_TESTING_Interpreter * is
The interpreter.
struct GNUNET_TESTING_Barrier * barrier
The barrier from which the nodes are freed.
const char * name
Name of the barrier.
Definition: testing.h:182
struct GNUNET_CONTAINER_MultiShortmap * nodes
Hash map containing the global known nodes which are not natted.
Definition: testing.h:177
Global state of the interpreter, used by a command to access information about other commands.
unsigned int finishing
Is the interpreter finishing?
Node in the netjail topology.
unsigned int node_number
The overall number of the node in the whole test system.
void TST_interpreter_send_barrier_crossable(struct GNUNET_TESTING_Interpreter *is, const char *barrier_name, unsigned int global_node_number)
Send Message to a netjail node that a barrier can be crossed.

References FreeBarrierNodeCbCls::barrier, GNUNET_TESTING_Interpreter::finishing, GNUNET_assert, GNUNET_CONTAINER_multishortmap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_YES, is, FreeBarrierNodeCbCls::is, key, GNUNET_TESTING_Barrier::name, GNUNET_TESTING_NetjailNode::node_number, GNUNET_TESTING_Barrier::nodes, TST_interpreter_send_barrier_crossable(), and value.

Referenced by free_barriers_cb(), and TST_interpreter_finish_attached_cmds().

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

◆ free_barriers_cb()

static int free_barriers_cb ( void *  cls,
const struct GNUNET_ShortHashCode key,
void *  value 
)
static

Definition at line 269 of file testing_api_loop.c.

272 {
273  struct GNUNET_TESTING_Interpreter *is = cls;
274  struct GNUNET_TESTING_Barrier *barrier = value;
275  struct CommandListEntry *pos;
276  struct FreeBarrierNodeCbCls *free_barrier_node_cb_cls;
277 
278  if (NULL != barrier->nodes)
279  {
280  free_barrier_node_cb_cls = GNUNET_new (struct FreeBarrierNodeCbCls);
281  free_barrier_node_cb_cls->barrier = barrier;
282  free_barrier_node_cb_cls->is = is;
285  free_barrier_node_cb_cls);
287  barrier->nodes = NULL;
288  }
289 
290  while (NULL != (pos = barrier->cmds_head))
291  {
294  pos);
295  GNUNET_free (pos);
296  }
298  return GNUNET_YES;
299 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
int GNUNET_CONTAINER_multishortmap_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
struct CommandListEntry * cmds_tail
Tail of the DLL with local commands the barrier is attached too.
Definition: testing.h:172
struct CommandListEntry * cmds_head
Head of the DLL with local commands the barrier is attached too.
Definition: testing.h:167
int free_barrier_node_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)

References FreeBarrierNodeCbCls::barrier, GNUNET_TESTING_Barrier::cmds_head, GNUNET_TESTING_Barrier::cmds_tail, free_barrier_node_cb(), GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_free, GNUNET_new, GNUNET_YES, is, FreeBarrierNodeCbCls::is, GNUNET_TESTING_Barrier::nodes, and value.

Referenced by interpreter_delete_barriers().

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

◆ interpreter_delete_barriers()

static void interpreter_delete_barriers ( struct GNUNET_TESTING_Interpreter is)
static

Deleting all barriers create in the context of this interpreter.

Parameters
isThe interpreter.

Definition at line 308 of file testing_api_loop.c.

309 {
312  is);
314 }
struct GNUNET_CONTAINER_MultiShortmap * barriers
Map with barriers for this loop.
static int free_barriers_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)

References GNUNET_TESTING_Interpreter::barriers, free_barriers_cb(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_CONTAINER_multishortmap_iterate(), and is.

Referenced by finish_test().

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

◆ finish_test()

static void finish_test ( void *  cls)
static

Finish the test run, return the final result.

Parameters
clsthe struct GNUNET_TESTING_Interpreter

Definition at line 323 of file testing_api_loop.c.

324 {
325  struct GNUNET_TESTING_Interpreter *is = cls;
326  struct GNUNET_TESTING_Command *cmd;
327  const char *label;
328 
330  is->final_task = NULL;
331  label = is->commands[is->ip].label;
332  if (NULL == is->commands[is->ip].run)
333  label = "END";
335  "Interpreter finishes at `%s' with status %d\n",
336  label,
337  is->result);
338  for (unsigned int j = 0;
339  NULL != (cmd = &is->commands[j])->run;
340  j++)
341  {
343  "Cleaning up cmd %s\n",
344  cmd->label);
345  cmd->cleanup (cmd->cls);
347  "Cleaned up cmd %s\n",
348  cmd->label);
349  }
350  if (NULL != is->task)
351  {
353  is->task = NULL;
354  }
355  if (NULL != is->timeout_task)
356  {
358  is->timeout_task = NULL;
359  }
361  is->rc (is->rc_cls,
362  is->result);
364  GNUNET_free (is->helper);
365  GNUNET_free (is);
366 }
@ GNUNET_ERROR_TYPE_INFO
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
GNUNET_TESTING_CommandCleanupRoutine cleanup
Clean up after the command.
void * cls
Closure for all commands with command-specific context information.
GNUNET_TESTING_ResultCallback rc
Function to call with the test result.
void * rc_cls
Closure for rc.
struct GNUNET_SCHEDULER_Task * final_task
Final task that returns the result.
struct GNUNET_SCHEDULER_Task * timeout_task
Task run on timeout.
struct GNUNET_SCHEDULER_Task * task
Interpreter task (if one is scheduled).
const struct GNUNET_HELPER_Handle ** helper
Array with handles of helper processes for communication with netjails.
enum GNUNET_GenericReturnValue result
Result of the testcases, GNUNET_OK on success.
static void interpreter_delete_barriers(struct GNUNET_TESTING_Interpreter *is)
Deleting all barriers create in the context of this interpreter.

References GNUNET_TESTING_Command::cleanup, GNUNET_TESTING_Command::cls, GNUNET_TESTING_Interpreter::commands, GNUNET_TESTING_Interpreter::final_task, GNUNET_TESTING_Interpreter::finishing, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_SCHEDULER_cancel(), GNUNET_YES, GNUNET_TESTING_Interpreter::helper, interpreter_delete_barriers(), GNUNET_TESTING_Interpreter::ip, is, GNUNET_TESTING_Command::label, GNUNET_TESTING_Interpreter::rc, GNUNET_TESTING_Interpreter::rc_cls, GNUNET_TESTING_Interpreter::result, run(), GNUNET_TESTING_Command::run, GNUNET_TESTING_Interpreter::task, and GNUNET_TESTING_Interpreter::timeout_task.

Referenced by do_timeout(), GNUNET_TESTING_interpreter_fail(), and interpreter_run().

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

◆ interpreter_run()

static void interpreter_run ( void *  cls)
static

Run the main interpreter loop that performs exchange operations.

Run the main interpreter loop.

Parameters
clscontains the struct InterpreterState
clscontains the struct GNUNET_TESTING_Interpreter

Definition at line 477 of file testing_api_loop.c.

478 {
479  struct GNUNET_TESTING_Interpreter *is = cls;
480  struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
481 
482  is->task = NULL;
483  if (NULL == cmd->run)
484  {
486  "Running command END\n");
487  is->result = GNUNET_OK;
488  finish_test (is);
489  return;
490  }
492  "Running command `%s'\n",
493  cmd->label);
495  "start time of %p expected 0 is `%" PRIu64 "'\n",
496  cmd,
497  cmd->start_time.abs_value_us);
498  cmd->start_time
499  = cmd->last_req_time
502  "start time of %p expected something is `%" PRIu64 "'\n",
503  cmd,
504  cmd->start_time.abs_value_us);
505  cmd->num_tries = 1;
506  if (NULL != cmd->ac)
507  {
508  cmd->ac->is = is;
509  cmd->ac->cont = &interpreter_next;
510  cmd->ac->cont_cls = is;
511  cmd->ac->finished = GNUNET_NO;
512  }
513  cmd->run (cmd->cls,
514  is);
515  if (NULL == cmd->ac)
516  {
518  }
519  else if ( (cmd->asynchronous_finish) &&
520  (NULL != cmd->ac->cont) )
521  {
522  cmd->ac->cont = NULL;
524  }
525 }
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
GNUNET_SCHEDULER_TaskCallback cont
Function to call when done.
void * cont_cls
Closure for cont.
struct GNUNET_TESTING_Interpreter * is
Interpreter we are part of.
enum GNUNET_GenericReturnValue finished
Indication if the command finished (GNUNET_OK).
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 s...
struct GNUNET_TESTING_AsyncContext * ac
Pointer to the asynchronous context in the command's closure.
bool asynchronous_finish
If "true", the interpreter should not immediately call finish, even if finish is non-NULL.
unsigned int num_tries
How often did we try to execute this command? (In case it is a request that is repated....
struct GNUNET_TIME_Absolute start_time
When did the execution of this command start?
uint64_t abs_value_us
The actual value.
static void interpreter_next(void *cls)
Current command is done, run the next one.
static void finish_test(void *cls)
Finish the test run, return the final result.

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_TESTING_Command::ac, GNUNET_TESTING_Command::asynchronous_finish, GNUNET_TESTING_Command::cls, GNUNET_TESTING_Interpreter::commands, GNUNET_TESTING_AsyncContext::cont, GNUNET_TESTING_AsyncContext::cont_cls, finish_test(), GNUNET_TESTING_AsyncContext::finished, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_TIME_absolute_get(), interpreter_next(), GNUNET_TESTING_Interpreter::ip, GNUNET_TESTING_AsyncContext::is, is, GNUNET_TESTING_Command::label, GNUNET_TESTING_Command::last_req_time, GNUNET_TESTING_Command::num_tries, GNUNET_TESTING_Interpreter::result, GNUNET_TESTING_Command::run, GNUNET_TESTING_Command::start_time, and GNUNET_TESTING_Interpreter::task.

Referenced by GNUNET_TESTING_cmd_end(), and interpreter_next().

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

◆ interpreter_next()

static void interpreter_next ( void *  cls)
static

Current command is done, run the next one.

Definition at line 382 of file testing_api_loop.c.

383 {
384  struct GNUNET_TESTING_Interpreter *is = cls;
385  static unsigned long long ipc;
386  static struct GNUNET_TIME_Absolute last_report;
387  struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
388 
389  if (GNUNET_SYSERR == is->result)
390  return; /* ignore, we already failed! */
392  if ( (! GNUNET_TESTING_cmd_is_batch_ (cmd)) ||
394  is->ip++;
395  if (0 == (ipc % 1000))
396  {
397  if (0 != ipc)
399  "Interpreter executed 1000 instructions in %s\n",
401  GNUNET_TIME_absolute_get_duration (last_report),
402  GNUNET_YES));
403  last_report = GNUNET_TIME_absolute_get ();
404  }
405  ipc++;
407  is);
408 }
@ GNUNET_SYSERR
@ GNUNET_ERROR_TYPE_MESSAGE
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:1299
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:436
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:569
struct GNUNET_TIME_Absolute finish_time
When did the execution of this command finish?
Time for absolute times used by GNUnet, in microseconds.
bool GNUNET_TESTING_cmd_batch_next_(void *cls)
Advance internal pointer to next command.
static void interpreter_run(void *cls)
Run the main interpreter loop that performs exchange operations.

References GNUNET_TESTING_Command::cls, GNUNET_TESTING_Interpreter::commands, GNUNET_TESTING_Command::finish_time, GNUNET_ERROR_TYPE_MESSAGE, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TESTING_cmd_batch_next_(), GNUNET_TESTING_cmd_is_batch_(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, interpreter_run(), GNUNET_TESTING_Interpreter::ip, is, GNUNET_TESTING_Interpreter::result, and GNUNET_TESTING_Interpreter::task.

Referenced by interpreter_run().

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

◆ 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 412 of file testing_api_loop.c.

413 {
414  struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
415 
416  if (GNUNET_SYSERR == is->result)
417  {
418  GNUNET_break (0);
419  return; /* ignore, we already failed! */
420  }
421  if (NULL != cmd)
422  {
424  "Failed at command `%s'\n",
425  cmd->label);
426  while (GNUNET_TESTING_cmd_is_batch_ (cmd))
427  {
430  "Failed in batch at command `%s'\n",
431  cmd->label);
432  }
433  }
434  else
435  {
437  "Failed with CMD being NULL!\n");
438  }
440  GNUNET_assert (NULL == is->final_task);
442  is);
443 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.

References GNUNET_TESTING_Interpreter::commands, GNUNET_TESTING_Interpreter::final_task, 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_(), GNUNET_TESTING_Interpreter::ip, is, GNUNET_TESTING_Command::label, and GNUNET_TESTING_Interpreter::result.

Referenced by 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_interpreter_get_current_command()

struct GNUNET_TESTING_Command* GNUNET_TESTING_interpreter_get_current_command ( struct GNUNET_TESTING_Interpreter is)

Returns the actual running command.

Parameters
isGlobal state of the interpreter, used by a command to access information about other commands.
Returns
The actual running command.

Definition at line 454 of file testing_api_loop.c.

456 {
457  return &is->commands[is->ip];
458 }

References GNUNET_TESTING_Interpreter::commands, GNUNET_TESTING_Interpreter::ip, and is.

Referenced by barrier_reached_run(), block_until_all_peers_started_run(), and do_timeout().

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 462 of file testing_api_loop.c.

464 {
465  struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
466 
467  return cmd->label;
468 }

References GNUNET_TESTING_Interpreter::commands, GNUNET_TESTING_Interpreter::ip, is, and GNUNET_TESTING_Command::label.

◆ do_timeout()

static void do_timeout ( void *  cls)
static

Function run when the test terminates (good or bad) with timeout.

Parameters
clsthe interpreter state

Definition at line 534 of file testing_api_loop.c.

535 {
536  struct GNUNET_TESTING_Interpreter *is = cls;
537 
538  is->timeout_task = NULL;
540  "Terminating test due to global timeout\n");
542  finish_test (is);
543 }

References finish_test(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SYSERR, is, GNUNET_TESTING_Interpreter::result, and GNUNET_TESTING_Interpreter::timeout_task.

Referenced by GNUNET_TESTING_cmd_end().

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

◆ GNUNET_TESTING_running()

enum GNUNET_GenericReturnValue GNUNET_TESTING_running ( const struct GNUNET_TESTING_Command command)

Check if the command is running.

FIXME: Unused function.

Parameters
commandThe command to check.
Returns
GNUNET_NO if the command is not running, GNUNET_YES if it is running.

Definition at line 534 of file testing_api_loop.c.

548 {
549  return 0 != command->start_time.abs_value_us && 0 ==
550  command->finish_time.abs_value_us;
551 }

◆ GNUNET_TESTING_finished()

enum GNUNET_GenericReturnValue GNUNET_TESTING_finished ( const struct GNUNET_TESTING_Command command)

Check if a command is finished.

FIXME: Unused function

Parameters
commandThe command to check.
Returns
GNUNET_NO if the command is not finished, GNUNET_YES if it is finished.

Definition at line 534 of file testing_api_loop.c.

556 {
559  command->finish_time,
560  now);
561  return 0 < diff.rel_value_us;
562 }
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
Compute the time difference between the given start and end times.
Definition: time.c:421
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.

◆ GNUNET_TESTING_run()

struct GNUNET_TESTING_Interpreter* GNUNET_TESTING_run ( const 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 array of command to execute
timeouthow long to wait for each command to execute
rcfunction to call with the final result
rc_clsclosure for rc
Returns
The interpreter.

Definition at line 566 of file testing_api_loop.c.

570 {
572  unsigned int i;
573 
575  is->rc = rc;
576  is->rc_cls = rc_cls;
578  false);
579  /* get the number of commands */
580  for (i = 0; NULL != commands[i].run; i++)
581  ;
582  is->cmds_n = i + 1;
584  "Got %u commands\n",
585  i);
586  is->commands = GNUNET_malloc_large ( (i + 1)
587  * sizeof (struct
589  GNUNET_assert (NULL != is->commands);
590  memcpy (is->commands,
591  commands,
592  sizeof (struct GNUNET_TESTING_Command) * i);
595  &do_timeout,
596  is);
598  is);
599 
600  return is;
601 }
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
Definition: gnunet-abd.c:61
static struct VoipCommand commands[]
List of supported commands.
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).
#define GNUNET_malloc_large(size)
Wrapper around malloc.
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:1272
static void do_timeout(void *cls)
Function run when the test terminates (good or bad) with timeout.

Referenced by loop_run().

Here is the caller graph for this function:

◆ GNUNET_TESTING_command_new()

struct GNUNET_TESTING_Command GNUNET_TESTING_command_new ( 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.

Parameters
clsthe closure
labelthe Label. Maximum length is GNUNET_TESTING_CMD_MAX_LABEL_LENGTH
runthe run routing
cleanupthe cleanup function
traitsthe traits function (optional)
theasync context
Returns
the command the function cannot fail

Definition at line 566 of file testing_api_loop.c.

611 {
612  struct GNUNET_TESTING_Command cmd = {
613  .cls = cls,
614  .run = run,
615  .ac = ac,
616  .cleanup = cleanup,
617  .traits = traits
618  };
619 
620  GNUNET_assert (NULL != run);
621  if (NULL != label)
622  {
623  GNUNET_assert (strlen (label) <=
625  strncpy (cmd.label,
626  label,
628  }
629  return cmd;
630 }
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
#define GNUNET_TESTING_CMD_MAX_LABEL_LENGTH
API for writing an interpreter to test GNUnet components.
GNUNET_TESTING_CommandGetTraits traits
Extract information from a command that is useful for other commands.

◆ GNUNET_TESTING_cmd_end()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_end ( void  )

Create command array terminator.

Returns
a end-command.

Definition at line 566 of file testing_api_loop.c.

635 {
636  struct GNUNET_TESTING_Command cmd = {
637  .run = NULL
638  };
639 
640  return cmd;
641 }

References GNUNET_TESTING_Interpreter::barriers, GNUNET_TESTING_Interpreter::cmds_n, commands, GNUNET_TESTING_Interpreter::commands, do_timeout(), GNUNET_assert, GNUNET_CONTAINER_multishortmap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_malloc_large, GNUNET_new, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), interpreter_run(), is, GNUNET_TESTING_Interpreter::rc, GNUNET_TESTING_Interpreter::rc_cls, GNUNET_TESTING_Interpreter::task, timeout, and GNUNET_TESTING_Interpreter::timeout_task.

Here is the call graph for this function:

◆ handle_result()

static void handle_result ( void *  cls,
enum GNUNET_GenericReturnValue  rv 
)
static

Function called with the final result of the test.

Parameters
clsthe struct MainParams
rvGNUNET_OK if the test passed

Definition at line 674 of file testing_api_loop.c.

676 {
677  struct MainParams *mp = cls;
678 
680  "Test exits with status %d\n",
681  rv);
682  if (GNUNET_OK != rv)
683  mp->rv = EXIT_FAILURE;
685 }
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:562
Closure for loop_run().
int rv
Set to #EXIT_FAILURE on error.

References GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_OK, GNUNET_SCHEDULER_shutdown(), and MainParams::rv.

Referenced by loop_run().

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

◆ loop_run()

static void loop_run ( void *  cls)
static

Main function to run the test cases.

Parameters
clsa struct MainParams *

Definition at line 694 of file testing_api_loop.c.

695 {
696  struct MainParams *mp = cls;
697 
699  mp->timeout,
700  &handle_result,
701  mp);
702 }
struct GNUNET_TIME_Relative timeout
Global timeout for the test.
struct GNUNET_TESTING_Command * commands
NULL-label terminated array of commands.
static void handle_result(void *cls, enum GNUNET_GenericReturnValue rv)
Function called with the final result of the test.
struct GNUNET_TESTING_Interpreter * GNUNET_TESTING_run(const struct GNUNET_TESTING_Command *commands, struct GNUNET_TIME_Relative timeout, GNUNET_TESTING_ResultCallback rc, void *rc_cls)
Run the testsuite.

References MainParams::commands, GNUNET_TESTING_run(), handle_result(), and MainParams::timeout.

Referenced by GNUNET_TESTING_main().

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

◆ clear_msg()

static void clear_msg ( void *  cls,
int  result 
)
static

Continuation function from GNUNET_HELPER_send()

Parameters
clsclosure
resultGNUNET_OK on success, GNUNET_NO if helper process died GNUNET_SYSERR during GNUNET_HELPER_stop()

Definition at line 714 of file testing_api_loop.c.

715 {
717 }
static int result
Global testing status.

References GNUNET_assert, GNUNET_YES, and result.

Referenced by send_message_to_netjail().

Here is the caller graph for this function:

◆ GNUNET_TESTING_add_netjail_helper()

void GNUNET_TESTING_add_netjail_helper ( struct GNUNET_TESTING_Interpreter is,
const struct GNUNET_HELPER_Handle helper 
)

Adding a helper handle to the interpreter.

Parameters
isThe interpreter.
helperThe helper handle.

Definition at line 727 of file testing_api_loop.c.

729 {
730  GNUNET_array_append (is->helper, is->n_helper, helper);
731 }
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
unsigned int n_helper
Size of the array helper.

References GNUNET_array_append, GNUNET_TESTING_Interpreter::helper, is, and GNUNET_TESTING_Interpreter::n_helper.

Referenced by start_helper().

Here is the caller graph for this function:

◆ send_message_to_netjail()

void send_message_to_netjail ( struct GNUNET_TESTING_Interpreter is,
unsigned int  global_node_number,
struct GNUNET_MessageHeader header 
)

Send Message to netjail nodes.

Parameters
isThe interpreter.
global_node_numberThe netjail node to inform.
headerThe message to send.

Definition at line 742 of file testing_api_loop.c.

745 {
746  const struct GNUNET_HELPER_Handle *helper;
747 
749  "send message of type %u to locals\n",
750  ntohs (header->type));
751  helper = is->helper[global_node_number - 1];
753  (struct GNUNET_HELPER_Handle *) helper,
754  header,
755  GNUNET_NO,
756  &clear_msg,
757  NULL);
758 }
static struct SolverHandle * sh
struct GNUNET_HELPER_SendHandle * GNUNET_HELPER_send(struct GNUNET_HELPER_Handle *h, const struct GNUNET_MessageHeader *msg, int can_drop, GNUNET_HELPER_Continuation cont, void *cont_cls)
Send an message to the helper.
Definition: helper.c:615
The handle to a helper process.
Definition: helper.c:79
Entry in the queue of messages we need to transmit to the helper.
Definition: helper.c:37
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
static void clear_msg(void *cls, int result)
Continuation function from GNUNET_HELPER_send()

References clear_msg(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELPER_send(), GNUNET_log, GNUNET_NO, GNUNET_TESTING_Interpreter::helper, is, sh, and GNUNET_MessageHeader::type.

Referenced by TST_interpreter_send_barrier_crossable().

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

◆ TST_interpreter_send_barrier_crossable()

void TST_interpreter_send_barrier_crossable ( struct GNUNET_TESTING_Interpreter is,
const char *  barrier_name,
unsigned int  global_node_number 
)

Send Message to a netjail node that a barrier can be crossed.

Parameters
isThe interpreter loop.
barrier_nameThe name of the barrier to cross.
global_node_numberThe global number of the node to inform.

Definition at line 762 of file testing_api_loop.c.

765 {
766  struct CommandBarrierCrossable *adm;
767  size_t msg_length;
768  size_t name_len;
769 
771  "send barrier name %s barrier_name\n",
772  barrier_name);
773  name_len = strlen (barrier_name);
774  msg_length = sizeof(struct CommandBarrierCrossable) + name_len + 1;
775  adm = GNUNET_malloc (msg_length);
777  adm->header.size = htons ((uint16_t) msg_length);
778  memcpy (&adm[1], barrier_name, name_len);
780  global_node_number,
781  &adm->header);
782  GNUNET_free (adm);
783 }
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE
Message send to a child loop to inform the child loop about a barrier being advanced.
Definition: testing.h:35
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE.
Definition: testing.h:39
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
void send_message_to_netjail(struct GNUNET_TESTING_Interpreter *is, unsigned int global_node_number, struct GNUNET_MessageHeader *header)
Send Message to netjail nodes.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE, CommandBarrierCrossable::header, is, send_message_to_netjail(), GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by free_barrier_node_cb().

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

◆ TST_interpreter_get_barrier()

struct GNUNET_TESTING_Barrier* TST_interpreter_get_barrier ( struct GNUNET_TESTING_Interpreter is,
const char *  barrier_name 
)

Getting a barrier from the interpreter.

Parameters
isThe interpreter.
barrier_nameThe name of the barrier.
Returns
The barrier.

Definition at line 794 of file testing_api_loop.c.

796 {
797  struct GNUNET_HashCode hc;
798  struct GNUNET_ShortHashCode create_key;
799  struct GNUNET_TESTING_Barrier *barrier;
800 
801  GNUNET_CRYPTO_hash (barrier_name, strlen (barrier_name), &hc);
802  memcpy (&create_key,
803  &hc,
804  sizeof (create_key));
805  barrier = GNUNET_CONTAINER_multishortmap_get (is->barriers, &create_key);
806  return barrier;
807 }
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
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.
A 512-bit hashcode.
A 256-bit hashcode.

References GNUNET_TESTING_Interpreter::barriers, GNUNET_CONTAINER_multishortmap_get(), GNUNET_CRYPTO_hash(), and is.

Referenced by barrier_attached(), barrier_reached(), barrier_reached_run(), start_helper(), and TST_interpreter_finish_attached_cmds().

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

◆ TST_interpreter_finish_attached_cmds()

void TST_interpreter_finish_attached_cmds ( struct GNUNET_TESTING_Interpreter is,
const char *  barrier_name 
)

Finish all "barrier reached" comands attached to this barrier.

Parameters
barrierThe barrier in question.

Definition at line 816 of file testing_api_loop.c.

818 {
819  struct CommandListEntry *pos;
821  barrier_name);
822 
823  while (NULL != barrier && NULL != (pos = barrier->cmds_head))
824  {
826  "command label %s\n",
827  pos->command->label);
828  if (GNUNET_NO == pos->command->ac->finished &&
830  {
832  "command label %s finish\n",
833  pos->command->label);
835  }
836  else if (GNUNET_NO == pos->command->ac->finished)
837  {
839  }
841  barrier->cmds_tail,
842  pos);
844  "command entry label %s removed\n",
845  pos->command->label);
846  GNUNET_free (pos);
848  "command entry freed\n");
849  }
850  if (NULL != barrier->nodes)
851  {
852  struct FreeBarrierNodeCbCls free_barrier_node_cb_cls = {
853  .barrier = barrier,
854  .is = is
855  };
856 
858  "freeing nodes\n");
861  &free_barrier_node_cb_cls);
863  "nodes freed\n");
865  barrier->nodes = NULL;
866  }
867 }
struct GNUNET_TESTING_Command * command
Definition: testing.h:148
void GNUNET_TESTING_async_finish(struct GNUNET_TESTING_AsyncContext *ac)
The asynchronous command of ac has finished.
struct GNUNET_TESTING_Barrier * TST_interpreter_get_barrier(struct GNUNET_TESTING_Interpreter *is, const char *barrier_name)
Getting a barrier from the interpreter.

References GNUNET_TESTING_Command::ac, GNUNET_TESTING_Command::asynchronous_finish, FreeBarrierNodeCbCls::barrier, GNUNET_TESTING_Barrier::cmds_head, GNUNET_TESTING_Barrier::cmds_tail, CommandListEntry::command, GNUNET_TESTING_AsyncContext::finished, free_barrier_node_cb(), GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_TESTING_async_finish(), GNUNET_YES, is, GNUNET_TESTING_Command::label, GNUNET_TESTING_Barrier::nodes, and TST_interpreter_get_barrier().

Referenced by barrier_reached(), and barrier_reached_run().

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

◆ TST_interpreter_add_barrier()

void TST_interpreter_add_barrier ( struct GNUNET_TESTING_Interpreter is,
struct GNUNET_TESTING_Barrier barrier 
)

Add a barrier to the loop.

Parameters
isThe interpreter.
barrierThe barrier to add.

Definition at line 877 of file testing_api_loop.c.

879 {
880  struct GNUNET_HashCode hc;
881  struct GNUNET_ShortHashCode create_key;
882 
883  GNUNET_CRYPTO_hash (barrier->name, strlen (barrier->name), &hc);
884  memcpy (&create_key,
885  &hc,
886  sizeof (create_key));
888  &create_key,
889  barrier,
891 }
enum GNUNET_GenericReturnValue 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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...

References GNUNET_TESTING_Interpreter::barriers, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multishortmap_put(), GNUNET_CRYPTO_hash(), is, and GNUNET_TESTING_Barrier::name.

Referenced by barrier_reached_run(), barrier_run(), and start_helper().

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(). FIXME: Why is this commands array here not const?

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 895 of file testing_api_loop.c.

897 {
898  struct MainParams mp = {
899  .commands = commands,
900  .timeout = timeout,
901  .rv = EXIT_SUCCESS
902  };
903 
905  &mp);
906  return mp.rv;
907 }
void GNUNET_SCHEDULER_run(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Initialize and run scheduler.
Definition: scheduler.c:720
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_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 911 of file testing_api_loop.c.

912 {
913  GNUNET_assert (GNUNET_NO == ac->finished);
914  ac->finished = GNUNET_SYSERR;
916  if (NULL != ac->cont)
917  {
918  ac->cont (ac->cont_cls);
919  ac->cont = NULL;
920  }
921 }
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(), exp_cb(), helper_mst(), 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 925 of file testing_api_loop.c.

926 {
927  GNUNET_assert (GNUNET_NO == ac->finished);
928  ac->finished = GNUNET_OK;
929  if (NULL != ac->cont)
930  {
931  ac->cont (ac->cont_cls);
932  ac->cont = NULL;
933  }
934 }

References ac, GNUNET_assert, GNUNET_NO, and GNUNET_OK.

Referenced by backchannel_check_run(), child_completed_callback(), do_timeout(), done_finish(), hello_iter_cb(), helper_mst(), notify_connect(), read_from_log(), run_finish(), send_simple_single(), and TST_interpreter_finish_attached_cmds().

Here is the caller graph for this function: