#include "gnunet_util_lib.h"
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_CommandLabel |
Structure with storage space for a label. 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_TESTING_CMD_MAX_LABEL_LENGTH 127 |
Central interpreter and command loop for writing an interpreter to test asynchronous systems. More... | |
#define | GNUNET_TESTING_FAIL(is) |
Print failing line number and trigger shutdown. More... | |
#define | GNUNET_TESTING_command_incomplete(is, label) |
Log an error message about a command not having run to completion. More... | |
#define | GNUNET_TESTING_command_new(cls, label, run, cleanup, traits) GNUNET_TESTING_command_new_ac (cls,label,run,cleanup,traits,NULL) |
Create a new command. More... | |
#define | GNUNET_TESTING_NETJAIL_START_SCRIPT "netjail_start_new.sh" |
#define | GNUNET_TESTING_NETJAIL_STOP_SCRIPT "netjail_stop.sh" |
#define | GNUNET_TESTING_MAKE_PLUGIN(prefix, name, ...) |
#define | GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT(prefix, 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(prefix, 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(prefix, 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(prefix, 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, prefix) |
Call op on all simple traits needed by testing core logic. More... | |
Typedefs | |
typedef void(* | GNUNET_TESTING_CommandRunRoutine) (void *cls, struct GNUNET_TESTING_Interpreter *is) |
Signature of a function used to start executing a command of a test. More... | |
typedef void(* | GNUNET_TESTING_CommandCleanupRoutine) (void *cls) |
Signature of a function used to clean up resources allocated by a command. More... | |
typedef enum GNUNET_GenericReturnValue(* | GNUNET_TESTING_CommandGetTraits) (void *cls, const void **ret, const char *trait, unsigned int index) |
Signature of a function used to extract traits exposed by a command. More... | |
typedef void(* | GNUNET_TESTING_CommandIterator) (void *cls, const struct GNUNET_TESTING_Command *cmd) |
Callback over commands of an interpreter. More... | |
typedef void(* | GNUNET_TESTING_ResultCallback) (void *cls, enum GNUNET_GenericReturnValue rv) |
Function called with the final result of the test. More... | |
Functions | |
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_command_new_ac (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 that may be asynchronous. More... | |
void | GNUNET_TESTING_set_label (struct GNUNET_TESTING_CommandLabel *label, const char *value) |
Set label to value. More... | |
const struct GNUNET_TESTING_Command * | GNUNET_TESTING_interpreter_lookup_command (struct GNUNET_TESTING_Interpreter *is, const char *label) |
Lookup command by label. More... | |
const struct GNUNET_TESTING_Command * | GNUNET_TESTING_interpreter_get_command (struct GNUNET_TESTING_Interpreter *is, const char *name) |
Get command from hash map by variable name. More... | |
void | GNUNET_TESTING_interpreter_current_cmd_touch (struct GNUNET_TESTING_Interpreter *is) |
Update the last request time of the current command to the current time. More... | |
void | GNUNET_TESTING_interpreter_current_cmd_inc_tries (struct GNUNET_TESTING_Interpreter *is) |
Increment the 'num_tries' counter for the current command. More... | |
const char * | GNUNET_TESTING_interpreter_current_cmd_get_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_interpreter_skip (struct GNUNET_TESTING_Interpreter *is) |
Skips the current test, the environment is not prepared correctly. More... | |
void | GNUNET_TESTING_interpreter_commands_iterate (struct GNUNET_TESTING_Interpreter *is, bool asc, GNUNET_TESTING_CommandIterator cb, void *cb_cls) |
Iterates over all of the top-level commands of an interpreter. More... | |
struct GNUNET_TESTING_Command | GNUNET_TESTING_cmd_end (void) |
Create command array terminator. More... | |
struct GNUNET_TESTING_Command | GNUNET_TESTING_cmd_batch (const char *label, struct GNUNET_TESTING_Command *batch) |
Create a "batch" command. More... | |
struct GNUNET_TESTING_Command | GNUNET_TESTING_cmd_stat (const char *label, struct GNUNET_TESTING_Timer *timers) |
Obtain performance data from the interpreter. More... | |
struct GNUNET_TESTING_Command | GNUNET_TESTING_cmd_set_var (const char *name, struct GNUNET_TESTING_Command cmd) |
Set variable to command as side-effect of running a command. More... | |
struct GNUNET_TESTING_Command | GNUNET_TESTING_cmd_barrier_create (const char *label, unsigned int number_to_be_reached) |
Command to create a barrier. More... | |
struct GNUNET_TESTING_Command | GNUNET_TESTING_cmd_barrier_reached (const char *label, const char *barrier_label) |
If this command is executed the the process is signaling the master process that it reached a barrier. More... | |
struct GNUNET_TESTING_Command | GNUNET_TESTING_cmd_netjail_start_helpers (const char *label, const char *topology_cmd_label, struct GNUNET_TIME_Relative timeout) |
Create command. More... | |
struct GNUNET_TESTING_Command | GNUNET_TESTING_cmd_netjail_setup (const char *label, const char *script, const char *topology_cmd_label) |
This command executes a shell script to setup the netjail environment. More... | |
struct GNUNET_TESTING_Command | GNUNET_TESTING_cmd_load_topology_from_file (const char *label, const char *filename) |
struct GNUNET_TESTING_Command | GNUNET_TESTING_cmd_load_topology_from_string (const char *label, const char *topology_data) |
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_signal (const char *label, const char *process_label, 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... | |
const struct GNUNET_TESTING_Command | GNUNET_TESTING_cmd_exec (const char *label, enum GNUNET_OS_ProcessStatusType expected_type, unsigned long int expected_exit_code, char *const script_argv[]) |
Command to execute a command. More... | |
const struct GNUNET_TESTING_Command | GNUNET_TESTING_cmd_exec_va (const char *label, enum GNUNET_OS_ProcessStatusType expected_type, unsigned long int expected_exit_code,...) |
Command to execute a command. 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_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. More... | |
int | GNUNET_TESTING_main (const struct GNUNET_TESTING_Command *commands, struct GNUNET_TIME_Relative timeout) |
Start a GNUnet scheduler event loop and run the testsuite. More... | |
struct GNUNET_TESTING_PluginFunctions * | GNUNET_TESTING_make_plugin (const struct GNUNET_TESTING_Command *commands) |
struct GNUNET_TESTING_Trait | GNUNET_TESTING_trait_end (void) |
"end" of traits array. More... | |
enum GNUNET_GenericReturnValue | GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits, const void **ret, const char *trait, unsigned int index) |
Obtain value of a trait from a command. More... | |
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) |
enum GNUNET_GenericReturnValue | GNUNET_TESTING_get_trait_cmd (const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_TESTING_Command **ret) |
struct GNUNET_TESTING_Trait | GNUNET_TESTING_make_trait_cmd (const struct GNUNET_TESTING_Command *value) |
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) |
#define GNUNET_TESTING_CMD_MAX_LABEL_LENGTH 127 |
Central interpreter and command loop for writing an interpreter to test asynchronous systems.
Definition at line 35 of file gnunet_testing_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. Returns from the current function.
Definition at line 44 of file gnunet_testing_lib.h.
#define GNUNET_TESTING_command_incomplete | ( | is, | |
label | |||
) |
Log an error message about a command not having run to completion.
is | interpreter |
label | command label of the incomplete command |
Definition at line 58 of file gnunet_testing_lib.h.
#define GNUNET_TESTING_command_new | ( | cls, | |
label, | |||
run, | |||
cleanup, | |||
traits | |||
) | GNUNET_TESTING_command_new_ac (cls,label,run,cleanup,traits,NULL) |
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) |
Definition at line 209 of file gnunet_testing_lib.h.
#define GNUNET_TESTING_NETJAIL_START_SCRIPT "netjail_start_new.sh" |
Definition at line 568 of file gnunet_testing_lib.h.
#define GNUNET_TESTING_NETJAIL_STOP_SCRIPT "netjail_stop.sh" |
Definition at line 570 of file gnunet_testing_lib.h.
Definition at line 784 of file gnunet_testing_lib.h.
Create headers for a trait with name name for statically allocated data of type type.
prefix | symbol prefix to use |
name | name of the trait |
type | data type for the trait |
Definition at line 868 of file gnunet_testing_lib.h.
Create C implementation for a trait with name name for statically allocated data of type type.
prefix | symbol prefix to use |
name | name of the trait |
type | data type for the trait |
Definition at line 886 of file gnunet_testing_lib.h.
Create headers for a trait with name name for statically allocated data of type type.
prefix | symbol prefix to use |
name | name of the trait |
type | data type for the trait |
Definition at line 918 of file gnunet_testing_lib.h.
Create C implementation for a trait with name name for statically allocated data of type type.
Definition at line 934 of file gnunet_testing_lib.h.
Call op on all simple traits needed by testing core logic.
op | operation to perform |
prefix | prefix to pass to op |
Definition at line 967 of file gnunet_testing_lib.h.
typedef void(* GNUNET_TESTING_CommandRunRoutine) (void *cls, struct GNUNET_TESTING_Interpreter *is) |
Signature of a function used to start executing a command of a test.
Runs the command. Note that upon return, the interpreter will not automatically run the next command if this is an asynchronous command unless the command was wrapped in GNUNET_TESTING_cmd_make_unblocking(), as the command may then continue asynchronously in other scheduler tasks. In this case, GNUNET_TESTING_async_finish() must be called to run the next task.
cls | closure |
is | interpreter running the command |
Definition at line 145 of file gnunet_testing_lib.h.
typedef void(* GNUNET_TESTING_CommandCleanupRoutine) (void *cls) |
Signature of a function used to clean up resources allocated by a command.
cls | closure |
Definition at line 157 of file gnunet_testing_lib.h.
typedef enum GNUNET_GenericReturnValue(* GNUNET_TESTING_CommandGetTraits) (void *cls, const void **ret, const char *trait, unsigned int index) |
Signature of a function used to extract traits exposed by a command.
cls | closure | |
[out] | ret | where to return the trait data |
trait | name of the trait to return | |
index | index of the trait (for traits that are indexed) |
Definition at line 157 of file gnunet_testing_lib.h.
typedef void(* GNUNET_TESTING_CommandIterator) (void *cls, const struct GNUNET_TESTING_Command *cmd) |
Callback over commands of an interpreter.
cls | closure |
cmd | a command to process |
Definition at line 430 of file gnunet_testing_lib.h.
typedef void(* GNUNET_TESTING_ResultCallback) (void *cls, enum GNUNET_GenericReturnValue rv) |
Function called with the final result of the test.
cls | closure |
rv | GNUNET_OK if the test passed |
Definition at line 732 of file gnunet_testing_lib.h.
void GNUNET_TESTING_async_fail | ( | struct GNUNET_TESTING_AsyncContext * | ac | ) |
The asynchronous command of ac has failed.
ac | command-specific context |
Definition at line 517 of file testing_api_loop.c.
References GNUNET_TESTING_Command::ac, GNUNET_TESTING_AsyncContext::finished, GNUNET_assert, GNUNET_NO, GNUNET_SYSERR, GNUNET_TESTING_interpreter_fail(), and GNUNET_TESTING_AsyncContext::is.
Referenced by barrier_reached_run(), child_completed_callback(), conn_status(), exp_cb(), handle_helper_barrier_reached(), handle_helper_local_finished(), helper_mst(), stop_cb(), 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 526 of file testing_api_loop.c.
References GNUNET_TESTING_Command::ac, GNUNET_TESTING_AsyncContext::finished, GNUNET_assert, GNUNET_NO, GNUNET_OK, GNUNET_TESTING_interpreter_next_(), GNUNET_TESTING_AsyncContext::is, GNUNET_TESTING_AsyncContext::next_called, GNUNET_TESTING_AsyncContext::notify_finished, and GNUNET_TESTING_AsyncContext::notify_finished_cls.
Referenced by backchannel_check_run(), barrier_reached_run(), child_completed_callback(), conn_status(), do_timeout(), done_finish(), handle_helper_barrier_crossable(), handle_helper_barrier_reached(), handle_helper_local_finished(), hello_iter_cb(), notify_connect(), read_from_log(), run_finish(), send_run(), send_simple_single(), and stop_cb().
struct GNUNET_TESTING_Command GNUNET_TESTING_command_new_ac | ( | 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 that may be asynchronous.
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) |
ac | the async context, NULL if command is always synchronous |
Definition at line 34 of file testing_api_cmds.c.
References GNUNET_TESTING_Command::ac, cleanup(), GNUNET_TESTING_Command::cls, GNUNET_assert, GNUNET_TESTING_set_label(), GNUNET_TESTING_Command::label, run(), and traits().
Referenced by GNUNET_CORE_cmd_connect_peers(), GNUNET_TESTING_ARM_cmd_start_peer(), GNUNET_TESTING_cmd_barrier_reached(), GNUNET_TESTING_cmd_exec(), GNUNET_TESTING_cmd_exec_va(), GNUNET_TESTING_cmd_finish(), GNUNET_TESTING_cmd_load_topology_from_file(), GNUNET_TESTING_cmd_load_topology_from_string(), GNUNET_TESTING_cmd_netjail_setup(), GNUNET_TESTING_cmd_netjail_start_helpers(), GNUNET_TESTING_cmd_stop_peer(), GNUNET_TRANSPORT_cmd_backchannel_check(), GNUNET_TRANSPORT_cmd_connect_peers(), GNUNET_TRANSPORT_cmd_send_simple_performance(), and GNUNET_TRANSPORT_cmd_start_peer().
void GNUNET_TESTING_set_label | ( | struct GNUNET_TESTING_CommandLabel * | label, |
const char * | value | ||
) |
Set label to value.
Asserts that value is not longer than GNUNET_TESTING_CMD_MAX_LABEL_LENGTH.
[out] | label | label to initialize |
value | value to store into label |
Definition at line 59 of file testing_api_cmds.c.
References GNUNET_assert, GNUNET_TESTING_CMD_MAX_LABEL_LENGTH, GNUNET_TESTING_Command::label, value, and GNUNET_TESTING_CommandLabel::value.
Referenced by GNUNET_TESTING_cmd_batch(), GNUNET_TESTING_command_new_ac(), and GNUNET_TESTING_DHTU_cmd_send().
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. |
Definition at line 145 of file testing_api_loop.c.
References GNUNET_TESTING_Interpreter::commands, GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_OK, GNUNET_TESTING_cmd_is_batch_(), GNUNET_TESTING_get_trait_batch_cmds(), GNUNET_TESTING_get_trait_cmd(), GNUNET_TESTING_Interpreter::ip, is, GNUNET_TESTING_Command::label, run(), GNUNET_TESTING_Command::run, and GNUNET_TESTING_CommandLabel::value.
Referenced by backchannel_check_run(), connect_peers_run(), join_room_run(), netjail_exec_run(), netjail_start_run(), rewind_ip_run(), run_finish(), send_simple_run(), signal_run(), start_peer_run(), start_service_run(), stop_peer_run(), and stop_service_run().
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_get_command | ( | struct GNUNET_TESTING_Interpreter * | is, |
const char * | name | ||
) |
Get command from hash map by variable name.
is | interpreter state. |
name | name of the variable to get command by |
Definition at line 203 of file testing_api_loop.c.
References GNUNET_CONTAINER_multihashmap_get(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, is, name, and GNUNET_TESTING_Interpreter::vars.
void GNUNET_TESTING_interpreter_current_cmd_touch | ( | struct GNUNET_TESTING_Interpreter * | is | ) |
Update the last request time of the current command to the current time.
[in,out] | is | interpreter state where to show that we are doing something |
Definition at line 808 of file testing_api_loop.c.
References GNUNET_TESTING_Interpreter::commands, GNUNET_TIME_absolute_get(), GNUNET_TESTING_Interpreter::ip, is, and GNUNET_TESTING_Command::last_req_time.
void GNUNET_TESTING_interpreter_current_cmd_inc_tries | ( | struct GNUNET_TESTING_Interpreter * | is | ) |
Increment the 'num_tries' counter for the current command.
[in,out] | is | interpreter state where to increment the counter |
Definition at line 817 of file testing_api_loop.c.
References GNUNET_TESTING_Interpreter::commands, GNUNET_TESTING_Interpreter::ip, is, and GNUNET_TESTING_Command::num_tries.
const char * GNUNET_TESTING_interpreter_current_cmd_get_label | ( | struct GNUNET_TESTING_Interpreter * | is | ) |
Obtain label of the command being now run.
is | interpreter state. |
Definition at line 825 of file testing_api_loop.c.
References GNUNET_TESTING_Interpreter::commands, GNUNET_TESTING_Interpreter::ip, is, GNUNET_TESTING_Command::label, and GNUNET_TESTING_CommandLabel::value.
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 463 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_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_SYSERR, GNUNET_TESTING_cmd_is_batch_(), GNUNET_TESTING_get_trait_cmd(), GNUNET_TESTING_Interpreter::ip, is, GNUNET_TESTING_Command::label, GNUNET_TESTING_Interpreter::result, GNUNET_TESTING_Interpreter::timeout_task, and GNUNET_TESTING_CommandLabel::value.
Referenced by connect_peers_run(), do_shutdown(), GNUNET_TESTING_async_fail(), GNUNET_TESTING_interpreter_skip(), join_room_run(), on_message_cb(), rewind_ip_run(), seek_batch(), start_peer_run(), and start_service_run().
void GNUNET_TESTING_interpreter_skip | ( | struct GNUNET_TESTING_Interpreter * | is | ) |
Skips the current test, the environment is not prepared correctly.
is | interpreter state. |
Definition at line 508 of file testing_api_loop.c.
References GNUNET_TESTING_interpreter_fail(), is, and GNUNET_TESTING_Interpreter::skip.
Referenced by netjail_start_run().
void GNUNET_TESTING_interpreter_commands_iterate | ( | struct GNUNET_TESTING_Interpreter * | is, |
bool | asc, | ||
GNUNET_TESTING_CommandIterator | cb, | ||
void * | cb_cls | ||
) |
Iterates over all of the top-level commands of an interpreter.
[in] | is | interpreter to iterate over |
asc | true in execution order, false for reverse execution order | |
cb | function to call on each command | |
cb_cls | closure for cb |
Definition at line 774 of file testing_api_loop.c.
References GNUNET_TESTING_Interpreter::commands, end, GNUNET_TESTING_Interpreter::ip, is, and start.
Referenced by stat_run().
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_end | ( | void | ) |
Create command array terminator.
Definition at line 85 of file testing_api_cmds.c.
References GNUNET_TESTING_Command::run.
Referenced by main().
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 150 of file testing_api_cmd_batch.c.
References BatchState::batch, batch_cleanup(), batch_run(), batch_traits(), GNUNET_new, GNUNET_new_array, GNUNET_TESTING_command_new, GNUNET_TESTING_set_label(), BatchState::label, and GNUNET_TESTING_Command::run.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_stat | ( | const char * | label, |
struct GNUNET_TESTING_Timer * | timers | ||
) |
Obtain performance data from the interpreter.
label | command label. | |
[in,out] | timers | NULL-prefix terminated array that specifies what commands (by label) to obtain runtimes for |
Definition at line 150 of file testing_api_cmd_stat.c.
References GNUNET_TESTING_command_new, and stat_run().
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_set_var | ( | const char * | name, |
struct GNUNET_TESTING_Command | cmd | ||
) |
Set variable to command as side-effect of running a command.
name | name of the variable to set |
cmd | command to set to variable when run |
Definition at line 75 of file testing_api_cmds.c.
References GNUNET_TESTING_Command::name.
Referenced by start_testcase().
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_barrier_create | ( | const char * | label, |
unsigned int | number_to_be_reached | ||
) |
Command to create a barrier.
label | The label of this command. |
number_to_be_reached | If this number of processes reached this barrier, all processes waiting at this barrier can pass it. |
Definition at line 91 of file testing_api_cmd_barrier_create.c.
References barrier_cleanup(), GNUNET_TESTING_Barrier::barrier_id, barrier_run(), barrier_traits(), GNUNET_TESTING_Barrier::expected_reaches, GNUNET_new, GNUNET_TESTING_barrier_name_hash_(), and GNUNET_TESTING_command_new.
Referenced by main().
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_barrier_reached | ( | const char * | label, |
const char * | barrier_label | ||
) |
If this command is executed the the process is signaling the master process that it reached a barrier.
If this command is synchronous it will block.
label | name for command. |
barrier_label | The name of the barrier we waited for and which was reached. |
Definition at line 173 of file testing_api_cmd_barrier_reached.c.
References BarrierReachedState::ac, BarrierReachedState::barrier_name, barrier_reached_cleanup(), barrier_reached_run(), barrier_reached_traits(), GNUNET_new, GNUNET_TESTING_command_new_ac(), and BarrierReachedState::label.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_netjail_start_helpers | ( | const char * | label, |
const char * | topology_cmd_label, | ||
struct GNUNET_TIME_Relative | timeout | ||
) |
Create command.
label | Name for the command. |
topology_data | topology data |
timeout | Before this timeout is reached this cmd MUST finish. |
Definition at line 706 of file testing_api_cmd_netjail_start_cmds_helper.c.
References GNUNET_new, GNUNET_TESTING_command_new_ac(), netjail_exec_cleanup(), netjail_exec_run(), netjail_exec_traits(), ns, timeout, and NetJailState::topology_cmd_label.
Referenced by main().
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_netjail_setup | ( | const char * | label, |
const char * | script, | ||
const char * | topology_cmd_label | ||
) |
This command executes a shell script to setup the netjail environment.
label | name for command. |
script | which script to run, e.g. GNUNET_TESTING_NETJAIL_START_SCRIPT |
topology_config | Configuration file for the test topology. |
read_file | Flag indicating if the the name of the topology file is send to the helper, or a string with the topology data. |
Definition at line 205 of file testing_api_cmd_netjail_start.c.
References GNUNET_new, GNUNET_TESTING_command_new_ac(), netjail_start_cleanup(), netjail_start_run(), ns, NetJailState::script, and NetJailState::topology_cmd_label.
Referenced by main().
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_load_topology_from_file | ( | const char * | label, |
const char * | filename | ||
) |
Definition at line 177 of file testing_api_cmd_get_topo.c.
References cleanup(), file_name, TopologyState::file_name, GNUNET_new, GNUNET_TESTING_command_new_ac(), TopologyState::label, run(), and traits().
Referenced by main().
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_load_topology_from_string | ( | const char * | label, |
const char * | topology_data | ||
) |
Definition at line 197 of file testing_api_cmd_get_topo.c.
References cleanup(), GNUNET_assert, GNUNET_new, GNUNET_strdup, GNUNET_TESTING_command_new_ac(), TopologyState::label, run(), TopologyState::topology_alloc, TopologyState::topology_string, topology_string, and traits().
Referenced by main(), and start_testcase().
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.
Modifies (and then returns) cmd simply setting the bit. By default, most commands are blocking, and by wrapping the command construction in this function a blocking command can be turned into an asynchronous command where the interpreter continues after initiating the asynchronous action. Does nothing if the command is fundamentally synchronous.
[in,out] | cmd | command to make non-blocking |
Definition at line 209 of file testing_api_cmd_finish.c.
References GNUNET_assert, and run_finish().
Referenced by main().
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 188 of file testing_api_cmd_finish.c.
References FinishState::ac, FinishState::async_label, cleanup_finish(), GNUNET_new, GNUNET_TESTING_command_new_ac(), run_finish(), timeout, and FinishState::timeout.
Referenced by main().
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_signal | ( | const char * | label, |
const char * | process_label, | ||
int | signal | ||
) |
Create a "signal" CMD.
label | command label. |
process_label | label of a command that has a process trait |
signal | signal to send to process. |
label | command label. |
process | handle to the process to signal. |
signal | signal to send. |
Definition at line 105 of file testing_api_cmd_signal.c.
References GNUNET_new, GNUNET_TESTING_command_new, SignalState::process_label, SignalState::signal, signal_cleanup(), and signal_run().
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 |
const struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_exec | ( | const char * | label, |
enum GNUNET_OS_ProcessStatusType | expected_type, | ||
unsigned long int | expected_exit_code, | ||
char *const | script_argv[] | ||
) |
Command to execute a command.
label | Label of the command. |
Definition at line 187 of file testing_api_cmd_exec.c.
References BashScriptState::ac, BashScriptState::args, exec_bash_script_cleanup(), exec_bash_script_run(), BashScriptState::expected_exit_code, BashScriptState::expected_type, GNUNET_new, GNUNET_new_array, GNUNET_strdup, GNUNET_TESTING_command_new_ac(), and traits().
const struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_exec_va | ( | const char * | label, |
enum GNUNET_OS_ProcessStatusType | expected_type, | ||
unsigned long int | expected_exit_code, | ||
... | |||
) |
Command to execute a command.
label | Label of the command. |
Definition at line 217 of file testing_api_cmd_exec.c.
References BashScriptState::ac, find_typedefs::arg, BashScriptState::args, exec_bash_script_cleanup(), exec_bash_script_run(), BashScriptState::expected_exit_code, BashScriptState::expected_type, GNUNET_new, GNUNET_new_array, GNUNET_strdup, GNUNET_TESTING_command_new_ac(), and traits().
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.
Note that the command that will be executed next in this case is the one AFTER target_label, as the command we jump to is skipped by the advancing IP after the rewind.
label | command label |
target_label | label of the new instruction pointer's destination after the jump; must be before the current instruction (and the command at the target_label itself will not be run, but the one afterwards) |
counter | counts how many times the rewinding is to happen. |
Definition at line 1005 of file testing_api_loop.c.
References RewindIpState::counter, GNUNET_new, GNUNET_TESTING_command_new, rewind_ip_free(), rewind_ip_run(), and RewindIpState::target_label.
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 602 of file testing_api_loop.c.
References commands, do_timeout(), GNUNET_new, GNUNET_SCHEDULER_add_delayed(), is, GNUNET_TESTING_Interpreter::rc, GNUNET_TESTING_Interpreter::rc_cls, setup_is(), timeout, and GNUNET_TESTING_Interpreter::timeout_task.
Referenced by loop_run().
int GNUNET_TESTING_main | ( | const 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().
commands | the list of command to execute |
timeout | how long to wait for each command to execute |
Definition at line 127 of file testing_api_main.c.
References commands, MainParams::commands, GNUNET_SCHEDULER_run(), loop_run(), MainParams::rv, and timeout.
Referenced by main().
struct GNUNET_TESTING_PluginFunctions * GNUNET_TESTING_make_plugin | ( | const struct GNUNET_TESTING_Command * | commands | ) |
Definition at line 677 of file testing_api_loop.c.
References GNUNET_TESTING_PluginFunctions::cls, commands, GNUNET_malloc_large, GNUNET_new, start_testcase(), and GNUNET_TESTING_PluginFunctions::start_testcase.
struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end | ( | void | ) |
"end" of traits array.
Because traits are offered into arrays, this type of trait is used to mark the end of such arrays; useful when iterating over those.
Referenced by barrier_reached_traits(), barrier_traits(), batch_traits(), connect_peers_traits(), netjail_exec_traits(), start_peer_traits(), start_service_traits(), stop_peer_traits(), system_create_traits(), and traits().
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait | ( | const struct GNUNET_TESTING_Trait * | traits, |
const void ** | ret, | ||
const char * | trait, | ||
unsigned int | index | ||
) |
Obtain value of a trait from a command.
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. |
Obtain value of a trait from a command.
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 62 of file testing_api_traits.c.
References GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTING_Trait::index, GNUNET_TESTING_Trait::ptr, ret, GNUNET_TESTING_Trait::trait_name, and traits().
Referenced by barrier_reached_traits(), barrier_traits(), batch_traits(), connect_peers_traits(), netjail_exec_traits(), start_peer_traits(), start_service_traits(), stop_peer_traits(), system_create_traits(), and traits().
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 | ) |
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_cmd | ( | const struct GNUNET_TESTING_Command * | cmd, |
const struct GNUNET_TESTING_Command ** | ret | ||
) |
Referenced by GNUNET_TESTING_interpreter_fail(), GNUNET_TESTING_interpreter_lookup_command(), and seek_batch().
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_cmd | ( | const struct GNUNET_TESTING_Command * | value | ) |
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_batch_cmds | ( | const struct GNUNET_TESTING_Command * | cmd, |
struct GNUNET_TESTING_Command *** | ret | ||
) |
Referenced by do_stat(), GNUNET_TESTING_interpreter_lookup_command(), and seek_batch().
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_batch_cmds | ( | struct GNUNET_TESTING_Command ** | value | ) |