GNUnet  0.16.x
Data Structures | Functions
testing_api_loop.c File Reference

main interpreter loop for testcases More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
#include "testing.h"
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  MainParams
 Closure for loop_run(). More...
 

Functions

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...
 
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 (struct GNUNET_TESTING_Command *command)
 Check if a command is finished. 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...
 
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...
 
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()

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

Definition at line 91 of file testing_api_loop.c.

94 {
95  int start_i = GNUNET_NO == future ? is->ip : is->cmds_n - 1;
96  int end_i = GNUNET_NO == future ? 0 : is->ip + 1;
97 
99  "start_i: %u end_i: %u\n",
100  start_i,
101  end_i);
102  if (NULL == label)
103  {
105  "Attempt to lookup command for empty label\n");
106  return NULL;
107  }
108 
109  for (int i = start_i; i >= end_i; i--)
110  {
111  const struct GNUNET_TESTING_Command *cmd = &is->commands[i];
112 
113  if (NULL != cmd->label)
115  "label to compare %s\n",
116  cmd->label);
117  /* Give precedence to top-level commands. */
118  if ( (NULL != cmd->label) &&
119  (0 == strcmp (cmd->label,
120  label)) )
121  return cmd;
122 
124  {
125  struct GNUNET_TESTING_Command **batch;
126  struct GNUNET_TESTING_Command *current;
127  const struct GNUNET_TESTING_Command *icmd;
128  const struct GNUNET_TESTING_Command *match;
129 
133  &batch));
134  /* We must do the loop forward, but we can find the last match */
135  match = NULL;
136  for (unsigned int j = 0;
137  NULL != (icmd = &(*batch)[j])->label;
138  j++)
139  {
140  if (current == icmd)
141  break; /* do not go past current command */
142  if ( (NULL != icmd->label) &&
143  (0 == strcmp (icmd->label,
144  label)) )
145  match = icmd;
146  }
147  if (NULL != match)
148  return match;
149  }
150  }
152  "Command `%s' not found\n",
153  label);
154  return NULL;
155 }
static struct GNUNET_NT_InterfaceScanner * is
Network scanner to determine network types.
#define GNUNET_log(kind,...)
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_NO
Definition: gnunet_common.h:94
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_batch_cmds(const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Command ***ret)
#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.
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.

References 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(), is, and GNUNET_TESTING_Command::label.

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

170 {
171  return get_command (is, label, GNUNET_YES);
172 }
@ GNUNET_YES
Definition: gnunet_common.h:97
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 184 of file testing_api_loop.c.

187 {
188  return get_command (is, label, GNUNET_NO);
189 }

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

204 {
205  const struct GNUNET_TESTING_Command *cmd;
206 
207  cmd = get_command (is, label, GNUNET_NO);
208  if (NULL == cmd)
209  cmd = get_command (is, label, GNUNET_YES);
210  return cmd;
211 }

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:

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

221 {
222  struct GNUNET_TESTING_Interpreter *is = cls;
223  struct GNUNET_TESTING_Command *cmd;
224  const char *label;
225 
226  is->final_task = NULL;
227  label = is->commands[is->ip].label;
228  if (NULL == label)
229  label = "END";
231  "Interpreter finishes at `%s' with status %d\n",
232  label,
233  is->result);
234  for (unsigned int j = 0;
235  NULL != (cmd = &is->commands[j])->label;
236  j++)
237  {
239  "Cleaning up cmd %s\n",
240  cmd->label);
241  cmd->cleanup (cmd->cls);
243  "Cleaned up cmd %s\n",
244  cmd->label);
245  }
246  if (NULL != is->task)
247  {
248  GNUNET_SCHEDULER_cancel (is->task);
249  is->task = NULL;
250  }
251  if (NULL != is->timeout_task)
252  {
253  GNUNET_SCHEDULER_cancel (is->timeout_task);
254  is->timeout_task = NULL;
255  }
256  GNUNET_free (is->commands);
257  is->rc (is->rc_cls,
258  is->result);
259  GNUNET_free (is);
260 }
@ GNUNET_ERROR_TYPE_INFO
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:957
void(* cleanup)(void *cls)
Clean up after the command.
void * cls
Closure for all commands with command-specific context information.
Global state of the interpreter, used by a command to access information about other commands.

References GNUNET_TESTING_Command::cleanup, GNUNET_TESTING_Command::cls, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_SCHEDULER_cancel(), is, and GNUNET_TESTING_Command::label.

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

371 {
372  struct GNUNET_TESTING_Interpreter *is = cls;
373  struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
374 
375  is->task = NULL;
376  if (NULL == cmd->label)
377  {
379  "Running command END\n");
380  is->result = GNUNET_OK;
381  finish_test (is);
382  return;
383  }
385  "Running command `%s'\n",
386  cmd->label);
388  "start time of %p expected 0 is `%lu'\n",
389  cmd,
390  cmd->start_time.abs_value_us);
391  cmd->start_time
392  = cmd->last_req_time
395  "start time of %p expected something is `%lu'\n",
396  cmd,
397  cmd->start_time.abs_value_us);
398  cmd->num_tries = 1;
399  if (NULL != cmd->ac)
400  {
401  cmd->ac->is = is;
402  cmd->ac->cont = &interpreter_next;
403  cmd->ac->cont_cls = is;
404  cmd->ac->finished = GNUNET_NO;
405  }
406  cmd->run (cmd->cls,
407  is);
408  if (NULL == cmd->ac)
409  {
411  }
412  else if ( (cmd->asynchronous_finish) &&
413  (NULL != cmd->ac->cont) )
414  {
415  cmd->ac->cont = NULL;
417  }
418 }
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:110
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.
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.
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_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_AsyncContext::is, is, GNUNET_TESTING_Command::label, GNUNET_TESTING_Command::last_req_time, GNUNET_TESTING_Command::num_tries, GNUNET_TESTING_Command::run, and GNUNET_TESTING_Command::start_time.

Referenced by GNUNET_TESTING_run(), 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 276 of file testing_api_loop.c.

277 {
278  struct GNUNET_TESTING_Interpreter *is = cls;
279  static unsigned long long ipc;
280  static struct GNUNET_TIME_Absolute last_report;
281  struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
282 
283  if (GNUNET_SYSERR == is->result)
284  return; /* ignore, we already failed! */
286  if ( (! GNUNET_TESTING_cmd_is_batch_ (cmd)) ||
288  is->ip++;
289  if (0 == (ipc % 1000))
290  {
291  if (0 != ipc)
293  "Interpreter executed 1000 instructions in %s\n",
295  GNUNET_TIME_absolute_get_duration (last_report),
296  GNUNET_YES));
297  last_report = GNUNET_TIME_absolute_get ();
298  }
299  ipc++;
301  is);
302 }
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
@ 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:1281
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:435
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:570
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_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(), and is.

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

307 {
308  struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
309 
310  if (GNUNET_SYSERR == is->result)
311  {
312  GNUNET_break (0);
313  return; /* ignore, we already failed! */
314  }
315  if (NULL != cmd)
316  {
318  "Failed at command `%s'\n",
319  cmd->label);
320  while (GNUNET_TESTING_cmd_is_batch_ (cmd))
321  {
324  "Failed in batch at command `%s'\n",
325  cmd->label);
326  }
327  }
328  else
329  {
331  "Failed with CMD being NULL!\n");
332  }
333  is->result = GNUNET_SYSERR;
334  GNUNET_assert (NULL == is->final_task);
335  is->final_task = GNUNET_SCHEDULER_add_now (&finish_test,
336  is);
337 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.

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

350 {
351  return &is->commands[is->ip];
352 }

References is.

Referenced by 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 355 of file testing_api_loop.c.

357 {
358  struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
359 
360  return cmd->label;
361 }

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

428 {
429  struct GNUNET_TESTING_Interpreter *is = cls;
430 
431  is->timeout_task = NULL;
433  "Terminating test due to global timeout\n");
434  is->result = GNUNET_SYSERR;
435  finish_test (is);
436 }

References finish_test(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SYSERR, and is.

Referenced by GNUNET_TESTING_run().

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.

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

Definition at line 427 of file testing_api_loop.c.

447 {
448  return 0 != command->start_time.abs_value_us && 0 ==
449  command->finish_time.abs_value_us;
450 }

◆ GNUNET_TESTING_finished()

enum GNUNET_GenericReturnValue GNUNET_TESTING_finished ( struct GNUNET_TESTING_Command command)

Check if a command is finished.

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

Definition at line 427 of file testing_api_loop.c.

461 {
464  command->finish_time,
465  now);
466  return 0 < diff.rel_value_us;
467 }
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:420
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.

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

475 {
477  unsigned int i;
478 
480  is->rc = rc;
481  is->rc_cls = rc_cls;
482  /* get the number of commands */
483  for (i = 0; NULL != commands[i].label; i++)
484  ;
485  is->cmds_n = i + 1;
486  is->commands = GNUNET_new_array (is->cmds_n,
487  struct GNUNET_TESTING_Command);
488  memcpy (is->commands,
489  commands,
490  sizeof (struct GNUNET_TESTING_Command) * i);
491  is->timeout_task
493  &do_timeout,
494  is);
496  is);
497 }
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.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#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:1254
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.

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:

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

532 {
533  struct MainParams *mp = cls;
534 
536  "Test exits with status %d\n",
537  rv);
538  if (GNUNET_OK != rv)
539  mp->rv = EXIT_FAILURE;
541 }
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:533
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 550 of file testing_api_loop.c.

551 {
552  struct MainParams *mp = cls;
553 
555  mp->timeout,
556  &handle_result,
557  mp);
558 }
struct GNUNET_TIME_Relative timeout
Global timeout for the test.
struct GNUNET_TESTING_Command * commands
NULL-label terminated array of commands.
void GNUNET_TESTING_run(struct GNUNET_TESTING_Command *commands, struct GNUNET_TIME_Relative timeout, GNUNET_TESTING_ResultCallback rc, void *rc_cls)
Run the testsuite.
static void handle_result(void *cls, enum GNUNET_GenericReturnValue rv)
Function called with the final result of the test.

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:

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

564 {
565  struct MainParams mp = {
566  .commands = commands,
567  .timeout = timeout,
568  .rv = EXIT_SUCCESS
569  };
570 
572  &mp);
573  return mp.rv;
574 }
void GNUNET_SCHEDULER_run(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Initialize and run scheduler.
Definition: scheduler.c:705
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 578 of file testing_api_loop.c.

579 {
580  GNUNET_assert (GNUNET_NO == ac->finished);
581  ac->finished = GNUNET_SYSERR;
583  if (NULL != ac->cont)
584  {
585  ac->cont (ac->cont_cls);
586  ac->cont = NULL;
587  }
588 }
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
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(), 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 592 of file testing_api_loop.c.

593 {
594  GNUNET_assert (GNUNET_NO == ac->finished);
595  ac->finished = GNUNET_OK;
596  if (NULL != ac->cont)
597  {
598  ac->cont (ac->cont_cls);
599  ac->cont = NULL;
600  }
601 }

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(), and run_finish().

Here is the caller graph for this function: