GNUnet  0.19.4
gnunet_testing_ng_lib.h File Reference
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_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 struct GNUNET_TESTING_Trait can be used to exchange data between cmds. More...
 

Macros

#define GNUNET_S(a)   #a
 API for writing an interpreter to test GNUnet components. More...
 
#define GNUNET_TESTING_CMD_MAX_LABEL_LENGTH   127
 Maximum length of label in command. More...
 
#define GNUNET_TESTING_FAIL(is)
 Print failing line number and trigger shutdown. More...
 
#define GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT(name, type)
 Create headers for a trait with name name for statically allocated data of type type. More...
 
#define GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT(name, type)
 Create C implementation for a trait with name name for statically allocated data of type type. More...
 
#define GNUNET_TESTING_MAKE_DECL_INDEXED_TRAIT(name, type)
 Create headers for a trait with name name for statically allocated data of type type. More...
 
#define GNUNET_TESTING_MAKE_IMPL_INDEXED_TRAIT(name, type)
 Create C implementation for a trait with name name for statically allocated data of type type. More...
 
#define GNUNET_TESTING_SIMPLE_TRAITS(op)
 Call op on all simple traits. More...
 
#define GNUNET_TESTING_INDEXED_TRAITS(op)
 Call op on all indexed traits. More...
 

Typedefs

typedef void(* GNUNET_TESTING_CommandRunRoutine) (void *cls, struct GNUNET_TESTING_Interpreter *is)
 
typedef void(* GNUNET_TESTING_CommandCleanupRoutine) (void *cls)
 
typedef enum GNUNET_GenericReturnValue(* GNUNET_TESTING_CommandGetTraits) (void *cls, const void **ret, const char *trait, unsigned int index)
 
typedef void(* GNUNET_TESTING_ResultCallback) (void *cls, enum GNUNET_GenericReturnValue rv)
 Function called with the final result of the test. More...
 

Functions

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...
 
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...
 
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...
 
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...
 
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...
 
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_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_PeerIdentityGNUNET_TESTING_get_peer (unsigned int num, const struct GNUNET_TESTING_System *tl_system)
 Retrieve peer identity from the test system with the unique node id. 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_batch_cmds (const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Command ***ret)
 
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_batch_cmds (struct GNUNET_TESTING_Command **value)
 
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_process (const struct GNUNET_TESTING_Command *cmd, struct GNUNET_OS_Process ***ret)
 
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_process (struct GNUNET_OS_Process **value)
 

Macro Definition Documentation

◆ GNUNET_S

#define GNUNET_S (   a)    #a

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 Stringify operator.
Parameters
asome expression to stringify. Must NOT be a macro.
Returns
same expression as a constant string.

Definition at line 40 of file gnunet_testing_ng_lib.h.

◆ GNUNET_TESTING_CMD_MAX_LABEL_LENGTH

#define GNUNET_TESTING_CMD_MAX_LABEL_LENGTH   127

Maximum length of label in command.

Definition at line 45 of file gnunet_testing_ng_lib.h.

◆ GNUNET_TESTING_FAIL

#define GNUNET_TESTING_FAIL (   is)
Value:
do \
{ \
GNUNET_break (0); \
GNUNET_TESTING_interpreter_fail (is); \
return; \
} while (0)
struct GNUNET_TESTING_Interpreter * is

Print failing line number and trigger shutdown.

Useful quite any time after the command "run" method has been called.

Definition at line 53 of file gnunet_testing_ng_lib.h.

◆ GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT

#define GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT (   name,
  type 
)
Value:
enum GNUNET_GenericReturnValue \
GNUNET_TESTING_get_trait_ ## name ( \
const struct GNUNET_TESTING_Command *cmd, \
type **ret); \
struct GNUNET_TESTING_Trait \
GNUNET_TESTING_make_trait_ ## name ( \
type * value);
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static char * value
Value of the record to add/remove.
const char * name
A command to be run by the interpreter.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model

Create headers for a trait with name name for statically allocated data of type type.

Definition at line 610 of file gnunet_testing_ng_lib.h.

◆ GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT

#define GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT (   name,
  type 
)
Value:
enum GNUNET_GenericReturnValue \
GNUNET_TESTING_get_trait_ ## name ( \
const struct GNUNET_TESTING_Command *cmd, \
type * *ret) \
{ \
if (NULL == cmd->traits) return GNUNET_SYSERR; \
return cmd->traits (cmd->cls, \
(const void **) ret, \
0); \
} \
GNUNET_TESTING_make_trait_ ## name ( \
type * value) \
{ \
struct GNUNET_TESTING_Trait ret = { \
.trait_name = GNUNET_S (name), \
.ptr = (const void *) value \
}; \
return ret; \
}
#define GNUNET_S(a)
API for writing an interpreter to test GNUnet components.
@ GNUNET_SYSERR
A struct GNUNET_TESTING_Trait can be used to exchange data between cmds.

Create C implementation for a trait with name name for statically allocated data of type type.

Definition at line 624 of file gnunet_testing_ng_lib.h.

◆ GNUNET_TESTING_MAKE_DECL_INDEXED_TRAIT

#define GNUNET_TESTING_MAKE_DECL_INDEXED_TRAIT (   name,
  type 
)
Value:
enum GNUNET_GenericReturnValue \
GNUNET_TESTING_get_trait_ ## name ( \
const struct GNUNET_TESTING_Command *cmd, \
unsigned int index, \
type **ret); \
struct GNUNET_TESTING_Trait \
GNUNET_TESTING_make_trait_ ## name ( \
unsigned int index, \

Create headers for a trait with name name for statically allocated data of type type.

Definition at line 652 of file gnunet_testing_ng_lib.h.

◆ GNUNET_TESTING_MAKE_IMPL_INDEXED_TRAIT

#define GNUNET_TESTING_MAKE_IMPL_INDEXED_TRAIT (   name,
  type 
)
Value:
enum GNUNET_GenericReturnValue \
GNUNET_TESTING_get_trait_ ## name ( \
const struct GNUNET_TESTING_Command *cmd, \
unsigned int index, \
type * *ret) \
{ \
if (NULL == cmd->traits) return GNUNET_SYSERR; \
return cmd->traits (cmd->cls, \
(const void **) ret, \
index); \
} \
GNUNET_TESTING_make_trait_ ## name ( \
unsigned int index, \
type * value) \
{ \
struct GNUNET_TESTING_Trait ret = { \
.index = index, \
.trait_name = GNUNET_S (name), \
.ptr = (const void *) value \
}; \
return ret; \
}

Create C implementation for a trait with name name for statically allocated data of type type.

Definition at line 668 of file gnunet_testing_ng_lib.h.

◆ GNUNET_TESTING_SIMPLE_TRAITS

#define GNUNET_TESTING_SIMPLE_TRAITS (   op)
Value:
op (batch_cmds, struct GNUNET_TESTING_Command *) \
op (process, struct GNUNET_OS_Process *)
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
process($line, $c)
Definition: log.php:48

Call op on all simple traits.

Definition at line 698 of file gnunet_testing_ng_lib.h.

◆ GNUNET_TESTING_INDEXED_TRAITS

#define GNUNET_TESTING_INDEXED_TRAITS (   op)
Value:
op (uint32, const uint32_t) \
op (uint64, const uint64_t) \
op (int64, const int64_t) \
op (uint, const unsigned int) \
op (string, const char) \
op (cmd, const struct GNUNET_TESTING_Command) \
op (uuid, const struct GNUNET_Uuid) \
op (time, const struct GNUNET_TIME_Absolute) \
op (absolute_time, const struct GNUNET_TIME_Absolute) \
op (relative_time, const struct GNUNET_TIME_Relative)
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
A UUID, a 128 bit "random" value.

Call op on all indexed traits.

Definition at line 706 of file gnunet_testing_ng_lib.h.

Typedef Documentation

◆ GNUNET_TESTING_CommandRunRoutine

typedef void(* GNUNET_TESTING_CommandRunRoutine) (void *cls, struct GNUNET_TESTING_Interpreter *is)

Definition at line 99 of file gnunet_testing_ng_lib.h.

◆ GNUNET_TESTING_CommandCleanupRoutine

typedef void(* GNUNET_TESTING_CommandCleanupRoutine) (void *cls)

Definition at line 103 of file gnunet_testing_ng_lib.h.

◆ GNUNET_TESTING_CommandGetTraits

typedef enum GNUNET_GenericReturnValue(* GNUNET_TESTING_CommandGetTraits) (void *cls, const void **ret, const char *trait, unsigned int index)

Definition at line 103 of file gnunet_testing_ng_lib.h.

◆ GNUNET_TESTING_ResultCallback

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

Function called with the final result of the test.

FIXME: This may want to use a GNUNET_ErrorCode (namespaced, e.g. GNUNET_EC_TESTING_*)

Parameters
clsclosure
rvGNUNET_OK if the test passed

Definition at line 382 of file gnunet_testing_ng_lib.h.

Function Documentation

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

606 {
607  struct GNUNET_TESTING_Command cmd = {
608  .cls = cls,
609  .run = run,
610  .ac = ac,
611  .cleanup = cleanup,
612  .traits = traits
613  };
614  memset (&cmd.label, 0, sizeof (cmd.label));
615  if (NULL != label)
617 
618  return cmd;
619 
620 }
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
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
Maximum length of label in command.
char label[127+1]
Label for the command.
GNUNET_TESTING_CommandGetTraits traits
Extract information from a command that is useful for other commands.
void * cls
Closure for all commands with command-specific context information.

References GNUNET_TESTING_Interpreter::barriers, GNUNET_TESTING_Interpreter::cmds_n, commands, GNUNET_TESTING_Interpreter::commands, do_timeout(), GNUNET_CONTAINER_multishortmap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_new_array, GNUNET_NO, 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.

Referenced by GNUNET_TESTING_cmd_end().

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

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

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 }
@ GNUNET_NO

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:

◆ 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 }
int ip
Instruction pointer.
struct GNUNET_TESTING_Command * commands
Commands the interpreter will run.

References GNUNET_TESTING_Interpreter::commands, GNUNET_TESTING_Interpreter::ip, 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 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_log(kind,...)
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
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_SCHEDULER_Task * final_task
Final task that returns the result.
enum GNUNET_GenericReturnValue result
Result of the testcases, GNUNET_OK on success.
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.
static void finish_test(void *cls)
Finish the test run, return the final result.

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

892 {
893  GNUNET_assert (GNUNET_NO == ac->finished);
894  ac->finished = GNUNET_SYSERR;
896  if (NULL != ac->cont)
897  {
898  ac->cont (ac->cont_cls);
899  ac->cont = NULL;
900  }
901 }
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 905 of file testing_api_loop.c.

906 {
907  GNUNET_assert (GNUNET_NO == ac->finished);
908  ac->finished = GNUNET_OK;
909  if (NULL != ac->cont)
910  {
911  ac->cont (ac->cont_cls);
912  ac->cont = NULL;
913  }
914 }
@ GNUNET_OK

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:

◆ 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  return GNUNET_TESTING_command_new (NULL, NULL,
33  NULL, NULL,
34  NULL, NULL);
35 }
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.

References GNUNET_TESTING_command_new().

Here is the call graph for this function:

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

FIXME: what is this API doing? Is it returning a new cmd which is unblocking? Is it modifying cmd? Looking at the code, it both modifying cmd AND returning a copy oO

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

Definition at line 157 of file testing_api_cmd_finish.c.

189 {
190  /* do not permit this function to be used on
191  a finish command! */
192  GNUNET_assert (cmd.run != &run_finish);
193  cmd.asynchronous_finish = true;
194  return cmd;
195 }
bool asynchronous_finish
If "true", the interpreter should not immediately call finish, even if finish is non-NULL.
GNUNET_TESTING_CommandRunRoutine run
Runs the command.
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 157 of file testing_api_cmd_finish.c.

174 {
175  struct FinishState *finish_state;
176 
177  finish_state = GNUNET_new (struct FinishState);
178  finish_state->async_label = cmd_ref;
179  finish_state->timeout = timeout;
180  return GNUNET_TESTING_command_new (finish_state, finish_label,
181  &run_finish,
183  NULL, &finish_state->ac);
184 }
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?
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()

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  /* get the number of commands */
579  for (i = 0; NULL != commands[i].run; i++)
580  ;
581  is->cmds_n = i + 1;
582  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got %u commands\n", i);
584  struct GNUNET_TESTING_Command);
585  memcpy (is->commands,
586  commands,
587  sizeof (struct GNUNET_TESTING_Command) * i);
590  &do_timeout,
591  is);
593  is);
594 
595  return is;
596 }
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).
@ GNUNET_ERROR_TYPE_DEBUG
#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:1272
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.
struct GNUNET_CONTAINER_MultiShortmap * barriers
Map with barriers for this loop.
unsigned int cmds_n
Number of GNUNET_TESTING_Command in commands.
void * rc_cls
Closure for rc.
struct GNUNET_SCHEDULER_Task * timeout_task
Task run on timeout.
struct GNUNET_SCHEDULER_Task * task
Interpreter task (if one is scheduled).
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.

Referenced by loop_run().

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

877 {
878  struct MainParams mp = {
879  .commands = commands,
880  .timeout = timeout,
881  .rv = EXIT_SUCCESS
882  };
883 
885  &mp);
886  return mp.rv;
887 }
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_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 }
struct GNUNET_TIME_Absolute finish_time
When did the execution of this command finish?
struct GNUNET_TIME_Absolute start_time
When did the execution of this command start?
uint64_t abs_value_us
The actual value.

◆ 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_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
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
uint64_t rel_value_us
The actual 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].run; 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  return GNUNET_TESTING_command_new (bs, label,
174  &batch_run,
175  &batch_cleanup,
176  &batch_traits, NULL);
177 }
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_peer()

struct GNUNET_PeerIdentity* GNUNET_TESTING_get_peer ( unsigned int  num,
const struct GNUNET_TESTING_System tl_system 
)

Retrieve peer identity from the test system with the unique node id.

Parameters
numThe unique node id.
tl_systemThe test system.
Returns
The peer identity wrapping the public key.

Retrieve peer identity from the test system with the unique node id.

Parameters
numThe unique node id.
tl_systemThe test system.
Returns
The peer identity wrapping the public key.

Definition at line 2309 of file testing.c.

2311 {
2313  struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key;
2314 
2315  priv_key = GNUNET_TESTING_hostkey_get (tl_system,
2316  num,
2317  peer);
2318 
2320  &peer->public_key);
2321  GNUNET_free (priv_key);
2322  return peer;
2323 }
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:197
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_TESTING_hostkey_get(const struct GNUNET_TESTING_System *system, uint32_t key_number, struct GNUNET_PeerIdentity *id)
Testing includes a number of pre-created hostkeys for faster peer startup.
Definition: testing.c:732
Private ECC key encoded for transmission.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

References GNUNET_CRYPTO_eddsa_key_get_public(), GNUNET_free, GNUNET_new, GNUNET_TESTING_hostkey_get(), and peer.

Referenced by add_search_string(), connect_peers_run(), and notify_connect().

Here is the call graph for this function:
Here is the caller 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.

47 {
48  struct GNUNET_TESTING_Trait end = {
49  .index = 0,
50  .trait_name = NULL,
51  .ptr = NULL
52  };
53 
54  return end;
55 }
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(), 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.

FIXME: Naming. This is something like "contains 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.

72 {
73  for (unsigned int i = 0; NULL != traits[i].trait_name; i++)
74  {
75  if ( (0 == strcmp (trait, traits[i].trait_name)) &&
76  (index == traits[i].index) )
77  {
78  *ret = (void *) traits[i].ptr;
79  return GNUNET_OK;
80  }
81  }
83  "Trait %s/%u not found.\n",
84  trait, index);
85 
86  return GNUNET_SYSERR;
87 }
@ 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(), start_peer_traits(), and system_create_traits().

Here is the caller graph for this function:

◆ GNUNET_TESTING_get_trait_batch_cmds()

enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_batch_cmds ( const struct GNUNET_TESTING_Command cmd,
struct GNUNET_TESTING_Command ***  ret 
)

Referenced by get_command().

Here is the caller graph for this function:

◆ GNUNET_TESTING_make_trait_batch_cmds()

struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_batch_cmds ( struct GNUNET_TESTING_Command **  value)

◆ GNUNET_TESTING_get_trait_process()

enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_process ( const struct GNUNET_TESTING_Command cmd,
struct GNUNET_OS_Process ***  ret 
)

◆ GNUNET_TESTING_make_trait_process()

struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_process ( struct GNUNET_OS_Process **  value)