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... | |
#define GNUNET_S | ( | a | ) | #a |
API for writing an interpreter to test GNUnet components.
a | some expression to stringify. Must NOT be a macro. |
Definition at line 40 of file gnunet_testing_ng_lib.h.
#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.
#define GNUNET_TESTING_FAIL | ( | 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.
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.
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.
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.
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.
#define GNUNET_TESTING_SIMPLE_TRAITS | ( | op | ) |
Call op on all simple traits.
Definition at line 698 of file gnunet_testing_ng_lib.h.
#define GNUNET_TESTING_INDEXED_TRAITS | ( | op | ) |
Call op on all indexed traits.
Definition at line 706 of file gnunet_testing_ng_lib.h.
typedef void(* GNUNET_TESTING_CommandRunRoutine) (void *cls, struct GNUNET_TESTING_Interpreter *is) |
Definition at line 99 of file gnunet_testing_ng_lib.h.
typedef void(* GNUNET_TESTING_CommandCleanupRoutine) (void *cls) |
Definition at line 103 of file gnunet_testing_ng_lib.h.
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.
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_*)
cls | closure |
rv | GNUNET_OK if the test passed |
Definition at line 382 of file gnunet_testing_ng_lib.h.
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.
cls | the closure |
label | the Label. Maximum length is GNUNET_TESTING_CMD_MAX_LABEL_LENGTH |
run | the run routing |
cleanup | the cleanup function |
traits | the traits function (optional) |
the | async context |
Definition at line 566 of file testing_api_loop.c.
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().
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.
is | interpreter to lookup command in |
label | label of the command to lookup. |
Definition at line 203 of file testing_api_loop.c.
References get_command(), GNUNET_YES, is, and GNUNET_TESTING_Command::label.
const struct GNUNET_TESTING_Command* GNUNET_TESTING_interpreter_lookup_command | ( | struct GNUNET_TESTING_Interpreter * | is, |
const char * | label | ||
) |
Lookup command by label.
is | interpreter to lookup command in |
label | label of the command to lookup. |
Only commands from current command to commands in the past are looked up.
is | interpreter to lookup command in |
label | label of the command to lookup. |
Definition at line 220 of file testing_api_loop.c.
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().
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.
is | interpreter to lookup command in |
label | label of the command to lookup. |
Definition at line 229 of file testing_api_loop.c.
References get_command(), GNUNET_NO, GNUNET_YES, is, and GNUNET_TESTING_Command::label.
Referenced by notify_connect().
const char* GNUNET_TESTING_interpreter_get_current_label | ( | struct GNUNET_TESTING_Interpreter * | is | ) |
Obtain label of the command being now run.
is | interpreter state. |
Definition at line 462 of file testing_api_loop.c.
References GNUNET_TESTING_Interpreter::commands, GNUNET_TESTING_Interpreter::ip, is, and GNUNET_TESTING_Command::label.
void GNUNET_TESTING_interpreter_fail | ( | struct GNUNET_TESTING_Interpreter * | is | ) |
Current command failed, clean up and fail the test case.
is | interpreter state. |
Definition at line 412 of file testing_api_loop.c.
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().
void GNUNET_TESTING_async_fail | ( | struct GNUNET_TESTING_AsyncContext * | ac | ) |
The asynchronous command of ac has failed.
ac | command-specific context |
Definition at line 891 of file testing_api_loop.c.
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().
void GNUNET_TESTING_async_finish | ( | struct GNUNET_TESTING_AsyncContext * | ac | ) |
The asynchronous command of ac has finished.
ac | command-specific context |
Definition at line 905 of file testing_api_loop.c.
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().
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_end | ( | void | ) |
Create command array terminator.
Definition at line 1 of file testing_api_cmd_end.c.
References GNUNET_TESTING_command_new().
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
cmd | command to make synchronous. |
Definition at line 157 of file testing_api_cmd_finish.c.
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.
finish_label | label for this command |
cmd_ref | reference to a previous command which we should wait for (call finish() on) |
timeout | how long to wait at most for cmd_ref to finish |
Definition at line 157 of file testing_api_cmd_finish.c.
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.
label | command label |
target_label | label of the new instruction pointer's destination after the jump; must be before the current instruction |
counter | counts how many times the rewinding is to happen. |
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.
commands | the array of command to execute |
timeout | how long to wait for each command to execute |
rc | function to call with the final result |
rc_cls | closure for rc |
Definition at line 566 of file testing_api_loop.c.
Referenced by loop_run().
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?
commands | the list of command to execute |
timeout | how long to wait for each command to execute |
Definition at line 875 of file testing_api_loop.c.
References commands, MainParams::commands, GNUNET_SCHEDULER_run(), loop_run(), MainParams::rv, and timeout.
enum GNUNET_GenericReturnValue GNUNET_TESTING_running | ( | const struct GNUNET_TESTING_Command * | command | ) |
Check if the command is running.
FIXME: Unused function.
command | The command to check. |
Definition at line 534 of file testing_api_loop.c.
enum GNUNET_GenericReturnValue GNUNET_TESTING_finished | ( | const struct GNUNET_TESTING_Command * | command | ) |
Check if a command is finished.
FIXME: Unused function
command | The command to check. |
Definition at line 534 of file testing_api_loop.c.
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.
label | command label. |
process_label | label of a command that has a process trait |
process_index | index of the process trait at process_label // FIXME: enum? needed? |
signal | signal to send to process. |
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_sleep | ( | const char * | label, |
struct GNUNET_TIME_Relative | duration | ||
) |
Sleep for duration.
label | command label. |
duration | time to sleep |
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.
label | the command label. |
batch | array of CMDs to execute. |
Definition at line 94 of file testing_api_cmd_batch.c.
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.
num | The unique node id. |
tl_system | The test system. |
Retrieve peer identity from the test system with the unique node id.
num | The unique node id. |
tl_system | The test system. |
Definition at line 2309 of file testing.c.
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().
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_stat | ( | struct GNUNET_TESTING_Timer * | timers | ) |
Obtain performance data from the interpreter.
timers | what commands (by label) to obtain runtimes for |
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.
Referenced by block_until_external_trigger_traits(), start_peer_traits(), and system_create_traits().
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".
traits | the array of all the traits. | |
[out] | ret | where to store the result. |
trait | type of the trait to extract. | |
index | index number of the trait to extract. |
Extract a trait.
traits | the traits array. |
ret | where to store the result. |
trait | type of the trait to extract. |
index | index number of the object to extract. |
Definition at line 1 of file testing_api_traits.c.
References end.
Referenced by block_until_external_trigger_traits(), start_peer_traits(), and system_create_traits().
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 | ) |