34 #define NETJAIL_EXEC_SCRIPT "netjail_exec.sh"
36 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
41 #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
284 "send message of type %u to locals\n",
291 count = (i - 1) *
ns->local_m + j +
ns->known;
293 helper =
ns->helper[count - 1];
320 reply->
header.
size = htons ((uint16_t) msg_length);
337 reply->
header.
size = htons ((uint16_t) msg_length);
353 const char *barrier_name;
356 barrier_name = (
const char *) &am[1];
366 memcpy (&
key, &hc,
sizeof (
key));
382 const char *barrier_name;
387 barrier_name = (
const char *) &rm[1];
392 "barrier %s reached %p %u\n",
404 "%s can be crossed\n",
409 "barrier %s reached finished\n",
430 unsigned int total_number =
ns->local_m *
ns->global_n +
ns->known;
431 uint16_t message_type = ntohs (message->
type);
434 switch (message_type)
443 ns->number_of_testsystems_started++;
446 ns->number_of_peers_started++;
447 if (
ns->number_of_peers_started == total_number)
449 for (
int i = 1; i <=
ns->known; i++)
453 for (
int i = 1; i <=
ns->global_n; i++)
455 for (
int j = 1; j <=
ns->local_m; j++)
460 ns->number_of_peers_started = 0;
464 ns->number_of_local_tests_prepared++;
465 if (
ns->number_of_local_tests_prepared == total_number)
467 for (
int i = 1; i <=
ns->known; i++)
472 for (
int i = 1; i <=
ns->global_n; i++)
474 for (
int j = 1; j <=
ns->local_m; j++)
484 ns->number_of_local_tests_finished++;
488 }
else if (
ns->number_of_local_tests_finished == total_number)
491 ns->timeout_task = NULL;
501 "total %u sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n",
503 ns->number_of_testsystems_started,
504 ns->number_of_peers_started,
505 ns->number_of_local_tests_prepared,
506 ns->number_of_local_tests_finished,
528 if (NULL !=
ns->timeout_task)
544 uint16_t plugin_name_len;
551 msg->header.
size = htons (msg_size);
553 msg->plugin_name_size = htons (plugin_name_len);
583 unsigned int script_num;
596 unsigned int node_num;
606 node_num = (n - 1) *
ns->local_m +
m +
ns->known;
607 script_num = n - 1 + (n - 1) *
ns->local_m +
m +
ns->known;
651 "sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n",
652 ns->number_of_testsystems_started,
653 ns->number_of_peers_started,
654 ns->number_of_local_tests_prepared,
655 ns->number_of_local_tests_finished,
660 char *
const script_argv[] = {script_name,
734 for (pos = barriers->
head; NULL != pos; pos = pos->
next)
740 "barrier %s added\n",
755 "barrier %p %s node %u added \n",
765 "number_to_be_reached %u\n",
770 "number_to_be_reached %u\n",
773 memcpy (&
key, &hc,
sizeof (
key));
794 "Send handle is NULL!\n");
825 ns->timeout_task = NULL;
827 "Terminating cmd due to global timeout\n");
847 for (
int i = 1; i <=
ns->known; i++)
857 for (
int i = 1; i <=
ns->global_n; i++)
859 for (
int j = 1; j <=
ns->local_m; j++)
871 "Adding timeout %s\n",
struct GNUNET_MessageHeader * msg
enum GNUNET_TESTBED_TopologyOption topology
The topology to generate.
static int ret
Return value of the commandline.
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
static struct SolverHandle * sh
struct TestcasePlugin * plugin
The process handle to the testbed service.
struct GNUNET_TESTING_Interpreter * is
struct GNUNET_HashCode key
The key used in the DHT.
static int result
Global testing status.
static char * plugin_name
Name of our plugin.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_helper_handles(const struct GNUNET_HELPER_Handle **value)
void GNUNET_TESTING_async_finish(struct GNUNET_TESTING_AsyncContext *ac)
The asynchronous command of ac has finished.
void GNUNET_TESTING_async_fail(struct GNUNET_TESTING_AsyncContext *ac)
The asynchronous command of ac has failed.
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.
struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end(void)
"end" 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.
void GNUNET_TESTING_interpreter_fail(struct GNUNET_TESTING_Interpreter *is)
Current command failed, clean up and fail the test case.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multishortmap_put(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
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).
void * GNUNET_CONTAINER_multishortmap_get(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Given a key find a value in the map matching the key.
int GNUNET_CONTAINER_multishortmap_contains(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
struct GNUNET_HELPER_SendHandle * GNUNET_HELPER_send(struct GNUNET_HELPER_Handle *h, const struct GNUNET_MessageHeader *msg, int can_drop, GNUNET_HELPER_Continuation cont, void *cont_cls)
Send an message to the helper.
struct GNUNET_HELPER_Handle * GNUNET_HELPER_start(int with_control_pipe, const char *binary_name, char *const binary_argv[], GNUNET_MessageTokenizerCallback cb, GNUNET_HELPER_ExceptionCallback exp_cb, void *cb_cls)
Starts a helper and begins reading from it.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
#define GNUNET_free(ptr)
Wrapper around free.
char * GNUNET_OS_get_libexec_binary_path(const char *progname)
Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary, try to prefix it with the ...
enum GNUNET_GenericReturnValue GNUNET_OS_check_helper_binary(const char *binary, bool check_suid, const char *params)
Check whether an executable exists and possibly if the suid bit is set on the file.
char * GNUNET_OS_installation_get_path(enum GNUNET_OS_InstallationPathKind dirkind)
Get the path to a specific GNUnet installation directory or, with GNUNET_OS_IPK_SELF_PREFIX,...
@ GNUNET_OS_IPK_DATADIR
Return the directory where data is installed (share/gnunet/)
void * GNUNET_PLUGIN_load(const char *library_name, void *arg)
Setup plugin (runs the "init" callback and returns whatever "init" returned).
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY
The reply message from gnunet-cmds-helper.
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT
The initialization message towards gnunet-cmds-helper.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
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.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_subtract(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Subtract relative timestamp from the other.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
enum GNUNET_GenericReturnValue read_file(char const *const filename, char **buffer)
Message send by a child loop to inform the master loop how much GNUNET_CMDS_BARRIER_REACHED messages ...
uint32_t expected_reaches
How often the child loop will reach the barrier.
uint32_t node_number
The number of the node the barrier is running on.
The handle to a helper process.
Entry in the queue of messages we need to transmit to the helper.
Entry in list of pending tasks.
State each asynchronous command must have in its closure.
An entry for a barrier list.
unsigned int expected_reaches
Number of commands attached to the barrier.
struct GNUNET_TESTING_BarrierListEntry * next
A list to hold barriers provided by plugins.
struct GNUNET_TESTING_BarrierListEntry * head
List head.
const char * name
Name of the barrier.
unsigned int number_to_be_reached
Number of commands which need to reach the barrier to change state.
struct GNUNET_CONTAINER_MultiShortmap * nodes
Hash map containing the global known nodes which are not natted.
unsigned int reached
Number of commands which reached this barrier.
unsigned int expected_reaches
Number of commands attached to this barrier.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED.
Initialization message for gnunet-cmds-testbed to start cmd binary.
A command to be run by the interpreter.
char label[127+1]
Label for the command.
struct GNUNET_TESTING_AsyncContext * ac
Pointer to the asynchronous context in the command's closure.
void * cls
Closure for all commands with command-specific context information.
Global state of the interpreter, used by a command to access information about other commands.
Node in the netjail topology.
unsigned int node_number
The overall number of the node in the whole test system.
char * plugin
Plugin for the test case to be run on this node.
unsigned int expected_reaches
The number of cmds waiting for a specific barrier.
Toplogy of our netjail setup.
GNUNET_TESTING_PLUGIN_GET_WAITING_FOR_BARRIERS get_waiting_for_barriers
A struct GNUNET_TESTING_Trait can be used to exchange data between cmds.
unsigned int index
Index number associated with the trait.
Time for relative time used by GNUnet, in microseconds.
Struct to store messages send/received by the helper into a DLL.
struct HelperMessage * prev
Kept in a DLL.
uint16_t bytes_msg
Size of the original message.
struct HelperMessage * next
Kept in a DLL.
Struct to hold information for callbacks.
unsigned int number_of_local_tests_finished
Number of local tests finished.
unsigned int n_helper
Size of the array NetJailState::helper.
struct GNUNET_TESTING_NetjailTopology * topology
The complete topology information.
char * topology_data
String with topology data or name of topology file.
char * plugin_name
Name of the test case plugin the helper will load.
unsigned int number_of_peers_started
Number of peers started.
unsigned int local_m
Number of nodes in a natted subnet.
struct GNUNET_TESTING_Interpreter * is
Global state of the interpreter, used by a command to access information about other commands.
unsigned int number_of_testsystems_started
Number of test environments started.
unsigned int * read_file
Shall we read the topology from file, or from a string.
const struct GNUNET_HELPER_Handle ** helper
Array with handles of helper processes.
unsigned int known
Number of global known nodes.
unsigned int global_n
Number of natted subnets.
unsigned int number_of_local_tests_prepared
Number of local tests prepared to finish.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
struct GNUNET_TIME_Relative timeout
Time after this cmd has to finish.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
struct GNUNET_TESTING_PluginFunctions * api
Plugin API.
Struct containing the number of the netjail node and the NetJailState which will be handed to callbac...
struct GNUNET_HELPER_SendHandle * shandle
The send handle for the helper.
struct GNUNET_MessageHeader * msg
The messages send to the helper.
struct TestingSystemCount * next
Kept in a DLL.
struct TestingSystemCount * prev
Kept in a DLL.
struct NetJailState * ns
Struct to store information handed over to callbacks.
struct TestcasePlugin * plugin
The plugin correlated to this netjail node.
struct GNUNET_TESTING_NetjailNode * GNUNET_TESTING_barrier_get_node(struct GNUNET_TESTING_Barrier *barrier, unsigned int node_number)
Getting a node from a map by global node number.
void TST_interpreter_add_barrier(struct GNUNET_TESTING_Interpreter *is, struct GNUNET_TESTING_Barrier *barrier)
Add a barrier to the loop.
struct GNUNET_TESTING_Barrier * TST_interpreter_get_barrier(struct GNUNET_TESTING_Interpreter *is, const char *barrier_name)
Getting a barrier from the interpreter.
void TST_interpreter_finish_attached_cmds(struct GNUNET_TESTING_Interpreter *is, const char *barrier_name)
Finish all "barrier reached" comands attached to this barrier.
unsigned int GNUNET_TESTING_barrier_crossable(struct GNUNET_TESTING_Barrier *barrier)
This function checks, if a barrier can be crossed, which actually means that the cmd representing the...
static struct GNUNET_TESTING_CommandHelperInit * create_helper_init_msg_(const char *plugin_name)
Function to initialize a init message for the helper.
static void exp_cb(void *cls)
Callback called if there was an exception during execution of the helper.
static void clear_msg(void *cls, int result)
Continuation function from GNUNET_HELPER_send()
static void do_timeout(void *cls)
Function run when the cmd terminates (good or bad) with timeout.
static void netjail_exec_cleanup(void *cls)
Code to clean up resource this cmd used.
static void netjail_exec_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
This function starts a helper process for each node.
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.
static void start_helper(struct NetJailState *ns, unsigned int m, unsigned int n)
Function which start a single helper process.
#define NETJAIL_EXEC_SCRIPT
void barrier_attached(struct NetJailState *ns, const struct GNUNET_MessageHeader *message)
static void send_message_to_locals(unsigned int i, unsigned int j, struct NetJailState *ns, struct GNUNET_MessageHeader *header)
static void send_all_peers_started(unsigned int i, unsigned int j, struct NetJailState *ns)
static void send_all_local_tests_prepared(unsigned int i, unsigned int j, struct NetJailState *ns)
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.
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.
#define LOG(kind,...)
Generic logging shortcut.
void barrier_reached(struct NetJailState *ns, const struct GNUNET_MessageHeader *message)
struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_get_current_command(struct GNUNET_TESTING_Interpreter *is)
Returns the actual running command.
void GNUNET_TESTING_add_netjail_helper(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_HELPER_Handle *helper)
Adding a helper handle to the interpreter.
Message formats for communication between testing cmds helper and testcase plugins.
#define HELPER_CMDS_BINARY