#include "platform.h"
#include "gnunet_testing_ng_lib.h"
#include "gnunet_testing_plugin.h"
#include "gnunet_testing_barrier.h"
#include "gnunet_testing_netjail_lib.h"
#include "testing.h"
#include "testing_cmds.h"
Go to the source code of this file.
Data Structures | |
struct | HelperMessage |
Struct to store messages send/received by the helper into a DLL. More... | |
struct | NetJailState |
Struct to hold information for callbacks. More... | |
struct | TestingSystemCount |
Struct containing the number of the netjail node and the NetJailState which will be handed to callbacks specific to a test environment. More... | |
Macros | |
#define | NETJAIL_EXEC_SCRIPT "netjail_exec.sh" |
#define | TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
#define | LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) |
Generic logging shortcut. More... | |
Functions | |
static void | netjail_exec_cleanup (void *cls) |
Code to clean up resource this cmd used. More... | |
static enum GNUNET_GenericReturnValue | netjail_exec_traits (void *cls, const void **ret, const char *trait, unsigned int index) |
This function prepares an array with traits. More... | |
static void | clear_msg (void *cls, int result) |
Continuation function from GNUNET_HELPER_send() More... | |
static void | send_message_to_locals (unsigned int i, unsigned int j, struct NetJailState *ns, struct GNUNET_MessageHeader *header) |
static void | send_all_local_tests_prepared (unsigned int i, unsigned int j, struct NetJailState *ns) |
static void | send_all_peers_started (unsigned int i, unsigned int j, struct NetJailState *ns) |
void | barrier_attached (struct NetJailState *ns, const struct GNUNET_MessageHeader *message) |
void | barrier_reached (struct NetJailState *ns, const struct GNUNET_MessageHeader *message) |
static int | helper_mst (void *cls, const struct GNUNET_MessageHeader *message) |
Functions with this signature are called whenever a complete message is received by the tokenizer. More... | |
static void | exp_cb (void *cls) |
Callback called if there was an exception during execution of the helper. More... | |
static struct GNUNET_TESTING_CommandHelperInit * | create_helper_init_msg_ (const char *plugin_name) |
Function to initialize a init message for the helper. More... | |
static void | start_helper (struct NetJailState *ns, unsigned int m, unsigned int n) |
Function which start a single helper process. More... | |
static void | do_timeout (void *cls) |
Function run when the cmd terminates (good or bad) with timeout. More... | |
static void | netjail_exec_run (void *cls, struct GNUNET_TESTING_Interpreter *is) |
This function starts a helper process for each node. More... | |
struct GNUNET_TESTING_Command | GNUNET_TESTING_cmd_netjail_start_cmds_helper (const char *label, struct GNUNET_TESTING_NetjailTopology *topology, unsigned int *read_file, char *topology_data, struct GNUNET_TIME_Relative timeout) |
Create command. More... | |
#define NETJAIL_EXEC_SCRIPT "netjail_exec.sh" |
Definition at line 34 of file testing_api_cmd_netjail_start_cmds_helper.c.
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
Definition at line 36 of file testing_api_cmd_netjail_start_cmds_helper.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log (kind, __VA_ARGS__) |
Generic logging shortcut.
Definition at line 41 of file testing_api_cmd_netjail_start_cmds_helper.c.
|
static |
Code to clean up resource this cmd used.
cls | closure |
Definition at line 217 of file testing_api_cmd_netjail_start_cmds_helper.c.
References GNUNET_free, and ns.
|
static |
This function prepares an array with traits.
Definition at line 217 of file testing_api_cmd_netjail_start_cmds_helper.c.
|
static |
Continuation function from GNUNET_HELPER_send()
cls | closure |
result | GNUNET_OK on success, GNUNET_NO if helper process died GNUNET_SYSERR during GNUNET_HELPER_stop |
Definition at line 259 of file testing_api_cmd_netjail_start_cmds_helper.c.
References GNUNET_assert, GNUNET_free, TestingSystemCount::plugin, and TestingSystemCount::shandle.
Referenced by send_message_to_locals(), and start_helper().
|
static |
Definition at line 272 of file testing_api_cmd_netjail_start_cmds_helper.c.
References clear_msg(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELPER_send(), GNUNET_new, GNUNET_NO, LOG, ns, TestingSystemCount::ns, sh, TestingSystemCount::shandle, and GNUNET_MessageHeader::type.
Referenced by send_all_local_tests_prepared(), and send_all_peers_started().
|
static |
Definition at line 308 of file testing_api_cmd_netjail_start_cmds_helper.c.
References GNUNET_free, GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED, GNUNET_new, GNUNET_TESTING_CommandAllLocalTestsPrepared::header, ns, send_message_to_locals(), GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by helper_mst().
|
static |
Definition at line 327 of file testing_api_cmd_netjail_start_cmds_helper.c.
References GNUNET_free, GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED, GNUNET_new, GNUNET_TESTING_CommandAllPeersStarted::header, ns, send_message_to_locals(), GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by helper_mst().
void barrier_attached | ( | struct NetJailState * | ns, |
const struct GNUNET_MessageHeader * | message | ||
) |
Definition at line 344 of file testing_api_cmd_netjail_start_cmds_helper.c.
References GNUNET_TESTING_NetjailNode::expected_reaches, CommandBarrierAttached::expected_reaches, GNUNET_TESTING_Barrier::expected_reaches, GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multishortmap_put(), GNUNET_CRYPTO_hash(), GNUNET_new, GNUNET_TESTING_barrier_get_node(), key, GNUNET_TESTING_NetjailNode::node_number, CommandBarrierAttached::node_number, GNUNET_TESTING_Barrier::nodes, ns, and TST_interpreter_get_barrier().
Referenced by helper_mst().
void barrier_reached | ( | struct NetJailState * | ns, |
const struct GNUNET_MessageHeader * | message | ||
) |
Definition at line 377 of file testing_api_cmd_netjail_start_cmds_helper.c.
References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_TESTING_barrier_crossable(), LOG, GNUNET_TESTING_Barrier::name, ns, GNUNET_TESTING_Barrier::reached, TST_interpreter_finish_attached_cmds(), and TST_interpreter_get_barrier().
Referenced by helper_mst().
|
static |
Functions with this signature are called whenever a complete message is received by the tokenizer.
Do not call GNUNET_SERVER_mst_destroy in callback
cls | closure |
client | identification of the client |
message | the actual message |
Definition at line 426 of file testing_api_cmd_netjail_start_cmds_helper.c.
References barrier_attached(), barrier_reached(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED, GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED, GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED, GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED, GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED, GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY, GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_TESTING_async_fail(), GNUNET_TESTING_async_finish(), lf(), LOG, ns, send_all_local_tests_prepared(), send_all_peers_started(), and GNUNET_MessageHeader::type.
Referenced by start_helper().
|
static |
Callback called if there was an exception during execution of the helper.
Definition at line 521 of file testing_api_cmd_netjail_start_cmds_helper.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SCHEDULER_cancel(), GNUNET_TESTING_async_fail(), and ns.
Referenced by GNUNET_HELPER_start(), and start_helper().
|
static |
Function to initialize a init message for the helper.
plugin_name | Name of the test case plugin the helper will load. |
Definition at line 539 of file testing_api_cmd_netjail_start_cmds_helper.c.
References GNUNET_assert, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT, msg, plugin_name, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by start_helper().
|
static |
Function which start a single helper process.
Definition at line 564 of file testing_api_cmd_netjail_start_cmds_helper.c.
References TestcasePlugin::api, GNUNET_TESTING_BarrierListEntry::barrier_name, clear_msg(), create_helper_init_msg_(), exp_cb(), GNUNET_TESTING_BarrierListEntry::expected_reaches, GNUNET_TESTING_NetjailNode::expected_reaches, GNUNET_TESTING_Barrier::expected_reaches, GNUNET_TESTING_PluginFunctions::get_waiting_for_barriers, GNUNET_array_append, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multishortmap_contains(), GNUNET_CONTAINER_multishortmap_create(), GNUNET_CONTAINER_multishortmap_get(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_HELPER_send(), GNUNET_HELPER_start(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_OS_check_helper_binary(), GNUNET_OS_get_libexec_binary_path(), GNUNET_OS_installation_get_path(), GNUNET_OS_IPK_DATADIR, GNUNET_PLUGIN_load(), GNUNET_TESTING_add_netjail_helper(), GNUNET_TESTING_interpreter_fail(), GNUNET_YES, GNUNET_TESTING_BarrierList::head, HELPER_CMDS_BINARY, helper_mst(), key, LOG, m, msg, GNUNET_TESTING_Barrier::name, NETJAIL_EXEC_SCRIPT, GNUNET_TESTING_BarrierListEntry::next, GNUNET_TESTING_NetjailNode::node_number, GNUNET_TESTING_Barrier::nodes, ns, TestingSystemCount::ns, GNUNET_TESTING_Barrier::number_to_be_reached, pid, GNUNET_TESTING_NetjailNode::plugin, plugin, TestingSystemCount::plugin, plugin_name, GNUNET_TESTING_Barrier::reached, read_file(), GNUNET_TESTING_Barrier::shadow, TestingSystemCount::shandle, topology, TST_interpreter_add_barrier(), and TST_interpreter_get_barrier().
Referenced by netjail_exec_run().
|
static |
Function run when the cmd terminates (good or bad) with timeout.
cls | the interpreter state |
Definition at line 818 of file testing_api_cmd_netjail_start_cmds_helper.c.
References GNUNET_TESTING_Command::ac, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_TESTING_async_finish(), GNUNET_TESTING_interpreter_get_current_command(), and ns.
Referenced by netjail_exec_run().
|
static |
This function starts a helper process for each node.
cls | closure. |
cmd | CMD being run. |
is | interpreter state. |
Definition at line 839 of file testing_api_cmd_netjail_start_cmds_helper.c.
References do_timeout(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_relative_time_to_string(), is, ns, and start_helper().
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_netjail_start_cmds_helper | ( | const char * | label, |
struct GNUNET_TESTING_NetjailTopology * | topology, | ||
unsigned int * | read_file, | ||
char * | topology_data, | ||
struct GNUNET_TIME_Relative | timeout | ||
) |
Create command.
This command executes a shell script which starts a helper process.
label | Name for the command. |
topology | The complete topology information. |
read_file | Flag indicating if the the name of the topology file is send to the helper, or a string with the topology data. |
topology_data | If read_file is GNUNET_NO, topology_data holds the string with the topology. |
timeout | Before this timeout is reached this cmd MUST finish. |
Definition at line 839 of file testing_api_cmd_netjail_start_cmds_helper.c.