37#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
166 if ( (!
ns->failed) &&
207 = htons (
sizeof (cbs)),
220 for (
unsigned int i = 0; i<barrier->
cnt_waiting; i++)
238 if ( (!
ns->failed) &&
245 if (
ns->n_finished ==
ns->n_helpers)
248 ns->timeout_task = NULL;
271 helper_barrier_reached,
276 helper_local_finished,
309 if (NULL !=
ns->timeout_task)
312 ns->timeout_task = NULL;
328 *bar_posp = bar_pos + 1;
348 topo_length = strlen (
ns->topology_data) + 1;
355 msg_len =
sizeof (*msg) + topo_length
357 if (msg_len > UINT16_MAX)
367 msg->header.
size = htons ((uint16_t) msg_len);
369 msg->barrier_count = htonl (num_barriers);
376 memcpy (&bar[num_barriers],
391 "Send handle is NULL!\n");
408 unsigned int script_num)
410 char *gnunet_cmds_helper
425 (
unsigned int) getpid (),
428 char *
const script_argv[] = {
471 ns->timeout_task = NULL;
473 "Terminating cmd due to global timeout\n");
496 ns->topology_cmd_label);
497 if (NULL == topo_cmd)
500 GNUNET_TESTING_get_trait_topology_string (topo_cmd,
505 for (
unsigned int i = 1; i <= topology->
total; i++)
537 if (NULL !=
ns->timeout_task)
540 ns->timeout_task = NULL;
542 for (
unsigned int i = 0; i<
ns->n_helpers; i++)
582 const char *topology_cmd_label,
struct GNUNET_MQ_MessageHandlers handlers[]
struct GNUNET_MessageHeader * msg
static int ret
Final status code.
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
static struct GNUNET_TESTING_Interpreter * is
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_NAMECACHE_Handle * ns
Handle to the namecache.
static char * value
Value of the record to add/remove.
static int result
Global testing status.
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.
void GNUNET_TESTING_async_finish(struct GNUNET_TESTING_AsyncContext *ac)
The asynchronous command of ac has finished.
#define GNUNET_TESTING_FAIL(is)
Print failing line number and trigger shutdown.
void GNUNET_TESTING_async_fail(struct GNUNET_TESTING_AsyncContext *ac)
The asynchronous command of ac has failed.
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command(struct GNUNET_TESTING_Interpreter *is, const char *label)
Lookup command by label.
struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end(void)
"end" of traits array.
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.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_HELPER_SendHandle * GNUNET_HELPER_send(struct GNUNET_HELPER_Handle *h, const struct GNUNET_MessageHeader *msg, bool 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.
void GNUNET_HELPER_stop(struct GNUNET_HELPER_Handle *h, int soft_kill)
Kills the helper, closes the pipe, frees the handle and calls wait() on the helper process.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_log(kind,...)
void * cls
Closure for mv and cb.
GNUNET_GenericReturnValue
Named constants for return values.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#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
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#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.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
enum GNUNET_GenericReturnValue GNUNET_MQ_handle_message(const struct GNUNET_MQ_MessageHandler *handlers, const struct GNUNET_MessageHeader *mh)
Call the message message handler that was registered for the type of the given message in the given h...
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
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,...
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 ...
@ GNUNET_OS_IPK_DATADIR
Return the directory where data is installed (share/gnunet/)
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE
#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.
The handle to a helper process.
Entry in the queue of messages we need to transmit to the helper.
Message handler for a specific message type.
Entry in list of pending tasks.
State each asynchronous command must have in its closure.
An entry for a barrier list.
bool inherited
Did we inherit the barrier from our parent loop?
unsigned int reached
Number of times the barrier has been reached.
unsigned int expected_reaches
Number of total commands expected to be reached by the barrier.
struct GNUNET_TESTING_AsyncContext ** waiting
Context of barrier reached commands of our local interpreter that are currently blocked on this barri...
unsigned int cnt_waiting
Length of the waiting array.
bool satisfied
Did we reach expected_reaches? Used in particular if inherited is true and we cannot compute locally.
Child to parent: I reached the given barrier, increment the counter (or pass to grandparent).
struct GNUNET_ShortHashCode barrier_key
struct GNUNET_MessageHeader header
Parent to child: this barrier was satisfied.
struct GNUNET_MessageHeader header
Initialization message for gnunet-cmds-testbed to start cmd binary.
A command to be run by the interpreter.
struct GNUNET_TESTING_CommandLabel label
Label for the command.
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.
Toplogy of our netjail setup.
unsigned int total
Total number of namespaces in the topology.
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 hold information for callbacks.
struct GNUNET_HELPER_Handle ** helpers
Array with handles of helper processes.
struct TestingSystemCount * tbc_tail
Kept in a DLL.
const char * topology_data
Data about our topology as a string.
struct GNUNET_TESTING_Interpreter * is
Global state of the interpreter, used by a command to access information about other commands.
const char * topology_cmd_label
Configuration file for the test topology.
struct TestingSystemCount * tbc_head
Kept in a DLL.
unsigned int n_finished
Counts number of helpers that finished.
bool failed
Set to true if we already failed the command.
unsigned int n_helpers
Size of the array helpers.
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 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 TestingSystemCount * next
Kept in a DLL.
struct TestingSystemCount * prev
Kept in a DLL.
struct NetJailState * ns
Struct to store information handed over to callbacks.
static enum GNUNET_GenericReturnValue traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.
static bool start_helper(struct NetJailState *ns, unsigned int script_num)
Function which start a single helper process.
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.
static enum GNUNET_GenericReturnValue helper_mst(void *cls, const struct GNUNET_MessageHeader *message)
Functions with this signature are called whenever a complete message is received by the tokenizer.
static void exp_cb(void *cls)
Callback called if there was an exception during execution of the helper.
static void do_timeout(void *cls)
Function run when the cmd terminates (good or bad) with timeout.
static enum GNUNET_GenericReturnValue add_barrier(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
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 handle_helper_barrier_reached(void *cls, const struct GNUNET_TESTING_CommandBarrierReached *rm)
static bool send_start_messages(struct NetJailState *ns, struct GNUNET_HELPER_Handle *helper)
static void handle_helper_local_finished(void *cls, const struct GNUNET_TESTING_CommandLocalFinished *lf)
static void clear_msg(void *cls, enum GNUNET_GenericReturnValue result)
Continuation function from GNUNET_HELPER_send()
struct GNUNET_TESTING_Barrier * GNUNET_TESTING_get_barrier2_(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_ShortHashCode *create_key)
unsigned int GNUNET_TESTING_barrier_count_(struct GNUNET_TESTING_Interpreter *is)
void GNUNET_TESTING_barrier_iterate_(struct GNUNET_TESTING_Interpreter *is, GNUNET_CONTAINER_ShortmapIterator cb, void *cb_cls)
void GNUNET_TESTING_add_netjail_helper_(struct GNUNET_TESTING_Interpreter *is, struct GNUNET_HELPER_Handle *helper)
Adding a helper handle to the interpreter.
void GNUNET_TESTING_loop_notify_parent_(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_MessageHeader *hdr)
Send message to our parent.
void GNUNET_TESTING_loop_notify_children_(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_MessageHeader *hdr)
Send message to all netjail children (if there are any).
void GNUNET_TESTING_free_topology(struct GNUNET_TESTING_NetjailTopology *topology)
Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.
struct GNUNET_TESTING_NetjailTopology * GNUNET_TESTING_get_topo_from_string_(const char *input)
Parse the topology data.
Message formats for communication between testing cmds helper and testcase plugins.
#define HELPER_CMDS_BINARY
#define NETJAIL_EXEC_SCRIPT