131 int end_i = future ?
is->
ip + 1 : 0;
134 "start_i: %u end_i: %u\n",
140 "Attempt to lookup command for empty label\n");
143 for (
int i = start_i; i >= end_i; i--)
147 if (NULL != cmd->
run)
149 "label to compare %s\n",
152 if ( (NULL != cmd->
run) &&
170 for (
unsigned int j = 0;
171 NULL != (icmd = &(*batch)[j])->
run;
176 if ( (NULL != icmd->
run) &&
186 "Command `%s' not found\n",
257 const char *barrier_name,
258 unsigned int global_node_number)
265 "send barrier crossable for barrier `%s'\n",
267 name_len = strlen (barrier_name);
271 adm->
header.
size = htons ((uint16_t) msg_length);
272 memcpy (&adm[1], barrier_name, name_len);
274 "send message of type %u to locals\n",
318 "free_barrier_node_cb\n");
347 &free_barrier_node_cb_cls);
364 while (NULL != (pos = barrier->
cmds_head))
394 "Interpreter finishes at `%s' with status %d\n",
397 for (
unsigned int j = 0;
402 "Cleaning up cmd %s\n",
406 "Cleaned up cmd %s\n",
452 static unsigned long long ipc;
462 if (0 == (ipc % 1000))
466 "Interpreter executed 1000 instructions in %s\n",
491 "Failed at command `%s'\n",
497 "Failed in batch at command `%s'\n",
504 "Failed with CMD being NULL!\n");
567 if (NULL == cmd->
run)
570 "Running command END\n");
576 "Running command `%s'\n",
579 "start time of %p expected 0 is `%" PRIu64
"'\n",
620 "Terminating test due to global timeout\n");
641 for (i = 0; NULL !=
commands[i].run; i++)
695 len = strlen (
value);
752 "Test exits with status %d\n",
755 mp->
rv = EXIT_FAILURE;
805 const char *barrier_name)
811 strlen (barrier_name),
815 sizeof (create_key));
835 "Adding barrier %s locally\n",
838 strlen (barrier->
name),
842 sizeof (create_key));
852 const char *barrier_name)
861 while (NULL != (pos = barrier->
cmds_head))
864 "command label %s\n",
870 "command label %s finish\n",
882 "command entry label %s removed\n",
886 "command entry freed\n");
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run by the scheduler.
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
struct GNUNET_TESTING_Interpreter * is
static struct VoipCommand commands[]
List of supported commands.
struct GNUNET_HashCode key
The key used in the DHT.
static void cleanup(void *cls)
Disconnect and shutdown.
static char * value
Value of the record to add/remove.
static int result
Global testing status.
void(* GNUNET_TESTING_CommandRunRoutine)(void *cls, struct GNUNET_TESTING_Interpreter *is)
Signature of a function used to start executing a command of a test.
void(* GNUNET_TESTING_CommandCleanupRoutine)(void *cls)
Signature of a function used to clean up resources allocated by a command.
void(* GNUNET_TESTING_ResultCallback)(void *cls, enum GNUNET_GenericReturnValue rv)
Function called with the final result of the test.
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.
#define GNUNET_TESTING_CMD_MAX_LABEL_LENGTH
Central interpreter and command loop for writing an interpreter to test asynchronous systems.
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_batch_cmds(const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Command ***ret)
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
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).
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.
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_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multishortmap_remove(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, const void *value)
Remove the given key-value pair from the map.
@ 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...
void GNUNET_HELPER_send_cancel(struct GNUNET_HELPER_SendHandle *sh)
Cancel a GNUNET_HELPER_send operation.
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.
#define GNUNET_log(kind,...)
GNUNET_GenericReturnValue
Named constants for return values.
#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_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_MESSAGE
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_malloc_large(size)
Wrapper around malloc.
#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_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
void GNUNET_SCHEDULER_run(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Initialize and run scheduler.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
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_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Message send to a child loop to inform the child loop about a barrier being advanced.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE.
struct GNUNET_TESTING_Command * command
Closure for free_barrier_node_cb().
struct GNUNET_TESTING_Interpreter * is
The interpreter.
struct GNUNET_TESTING_Barrier * barrier
The barrier from which the nodes are freed.
Internal representation of the hash map.
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.
GNUNET_SCHEDULER_TaskCallback cont
Function to call when done.
void * cont_cls
Closure for cont.
struct GNUNET_TESTING_Interpreter * is
Interpreter we are part of.
enum GNUNET_GenericReturnValue finished
Indication if the command finished (GNUNET_OK).
const char * name
Name of the barrier.
struct GNUNET_CONTAINER_MultiShortmap * nodes
Hash map containing the global known nodes which are not natted.
struct CommandListEntry * cmds_tail
Tail of the DLL with local commands the barrier is attached too.
struct CommandListEntry * cmds_head
Head of the DLL with local commands the barrier is attached too.
Structure with storage space for a label.
A command to be run by the interpreter.
GNUNET_TESTING_CommandCleanupRoutine cleanup
Clean up after the command.
struct GNUNET_TIME_Absolute finish_time
When did the execution of this command finish?
struct GNUNET_TESTING_CommandLabel label
Label for the command.
struct GNUNET_TIME_Absolute last_req_time
When did we start the last run of this command? Delta to finish_time gives the latency for the last s...
struct GNUNET_TESTING_AsyncContext * ac
Pointer to the asynchronous context in the command's closure.
bool asynchronous_finish
If "true", the interpreter should not immediately call finish, even if finish is non-NULL.
GNUNET_TESTING_CommandGetTraits traits
Extract information from a command that is useful for other commands.
GNUNET_TESTING_CommandRunRoutine run
Runs the command.
unsigned int num_tries
How often did we try to execute this command? (In case it is a request that is repated....
struct GNUNET_TIME_Absolute start_time
When did the execution of this command start?
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.
GNUNET_TESTING_ResultCallback rc
Function to call with the test result.
struct GNUNET_CONTAINER_MultiShortmap * barriers
Map with barriers for this loop.
unsigned int cmds_n
Number of GNUNET_TESTING_Command in commands.
unsigned int n_helper
Size of the array helper.
void * rc_cls
Closure for rc.
struct GNUNET_SCHEDULER_Task * final_task
Final task that returns the result.
struct GNUNET_SCHEDULER_Task * timeout_task
Task run on timeout.
int ip
Instruction pointer.
struct GNUNET_HELPER_SendHandle * send_handle
Handle to a send op.
struct GNUNET_SCHEDULER_Task * task
Interpreter task (if one is scheduled).
const struct GNUNET_HELPER_Handle ** helper
Array with handles of helper processes for communication with netjails.
struct GNUNET_TESTING_Command * commands
Commands the interpreter will run.
bool finishing
Is the interpreter finishing?
enum GNUNET_GenericReturnValue result
Result of the testcases, GNUNET_OK on success.
Node in the netjail topology.
unsigned int node_number
The overall number of the node in the whole test system.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
int rv
Set to #EXIT_FAILURE on error.
struct GNUNET_TIME_Relative timeout
Global timeout for the test.
struct GNUNET_TESTING_Command * commands
NULL-label terminated array of commands.
struct GNUNET_TESTING_Command * GNUNET_TESTING_cmd_batch_get_current_(const struct GNUNET_TESTING_Command *cmd)
Obtain what command the batch is at.
bool GNUNET_TESTING_cmd_batch_next_(void *cls)
Advance internal pointer to next command.
bool GNUNET_TESTING_cmd_is_batch_(const struct GNUNET_TESTING_Command *cmd)
Test if this command is a batch command.
struct GNUNET_TESTING_Barrier * GNUNET_TESTING_get_barrier_(struct GNUNET_TESTING_Interpreter *is, const char *barrier_name)
Getting a barrier from the interpreter.
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.
static void free_barrier_nodes(struct GNUNET_TESTING_Interpreter *is, struct GNUNET_TESTING_Barrier *barrier)
static void do_timeout(void *cls)
Function run when the test terminates (good or bad) with timeout.
static void interpreter_run(void *cls)
Run the main interpreter loop that performs exchange operations.
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_future_command(struct GNUNET_TESTING_Interpreter *is, const char *label)
Lookup command by label.
static void interpreter_next(void *cls)
Current command is done, run the next one.
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.
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_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.
static void handle_result(void *cls, enum GNUNET_GenericReturnValue rv)
Function called with the final result of the test.
static enum GNUNET_GenericReturnValue free_barriers_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
static void send_barrier_crossable(struct GNUNET_TESTING_Interpreter *is, const char *barrier_name, unsigned int global_node_number)
Send message to a netjail node that a barrier can be crossed.
void GNUNET_TESTING_add_netjail_helper_(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_HELPER_Handle *helper)
Adding a helper handle to the interpreter.
void GNUNET_TESTING_finish_barrier_(struct GNUNET_TESTING_Interpreter *is, const char *barrier_name)
Finish all "barrier reached" commands attached to this barrier.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_end(void)
Create command array terminator.
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command_all(struct GNUNET_TESTING_Interpreter *is, const char *label)
Lookup command by label.
struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_get_current_command(struct GNUNET_TESTING_Interpreter *is)
Returns the actual running command.
void GNUNET_TESTING_set_label(struct GNUNET_TESTING_CommandLabel *label, const char *value)
Set label to value.
static const struct GNUNET_TESTING_Command * get_command(struct GNUNET_TESTING_Interpreter *is, const char *label, bool future)
Lookup command by label.
void GNUNET_TESTING_interpreter_fail(struct GNUNET_TESTING_Interpreter *is)
Current command failed, clean up and fail the test case.
static enum GNUNET_GenericReturnValue free_barrier_node_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
void GNUNET_TESTING_add_barrier_(struct GNUNET_TESTING_Interpreter *is, struct GNUNET_TESTING_Barrier *barrier)
Add a barrier to the interpreter.
static void finish_test(void *cls)
Finish the test run, return the final result.
static void loop_run(void *cls)
Main function to run the test cases.
int GNUNET_TESTING_main(struct GNUNET_TESTING_Command *commands, struct GNUNET_TIME_Relative timeout)
Start a GNUnet scheduler event loop and run the testsuite.
static void clear_msg(void *cls, enum GNUNET_GenericReturnValue result)
Continuation function from GNUNET_HELPER_send()