152 "Attempt to lookup command for empty label\n");
155 for (
int i =
is->
ip; i >= 0; i--)
160 if ( (NULL != cmd->
run) &&
180 for (
unsigned int j = 0;
181 NULL != (icmd = &(*batch)[j])->
run;
186 if ( (NULL != icmd->
run) &&
196 "Command `%s' not found\n",
217 "Command not found by variable name: %s\n",
243 "Send notification to children of type %u\n",
244 (
unsigned int) ntohs (hdr->
type));
293 "Interpreter finishes at `%s' with status %d\n",
296 for (
unsigned int j = 0;
353 static unsigned long long ipc;
376 if (0 == (ipc % 1000))
380 "Interpreter executed 1000 instructions in %s\n",
402 if (NULL != cmd->
name)
424 ( (NULL == cmd->
ac) ||
446 if (NULL == cmd->
run)
449 "Running command END\n");
455 "Running command `%s'\n",
476 "Failed with CMD being NULL!\n");
483 "Failed during command `%s'\n",
491 "Failed in batch during command `%s'\n",
555 "Terminating test due to global timeout\n");
571 for (i = 0; NULL !=
commands[i].run; i++)
573 if (NULL != bcommand)
583 if (NULL == bcommand)
626 const char *topology_data,
627 uint32_t inherited_barrier_count,
637 if (0 != inherited_barrier_count)
642 for (
unsigned int j = 0; j<inherited_barrier_count; j++)
684 for (i = 0; NULL !=
commands[i].run; i++)
689 memcpy (commands_copy,
694 api->
cls = (
void *) commands_copy;
721 const char *barrier_name)
796 for (
unsigned int off =
start; off !=
end + inc; off += inc)
879 NULL != (icmd = &((*batch)[new_ip]))->run;
882 if (current == target)
984 if (new_ip > (
unsigned int)
is->
ip)
1006 const char *target_label,
1007 unsigned int counter)
static int start
Set if we are to start default services (including ARM).
static int ret
Final status code.
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.
static int end
Set if we are to shutdown all services (including ARM).
static struct GNUNET_TESTING_Interpreter * is
static struct VoipCommand commands[]
List of supported commands.
static char * name
Name (label) of the records to list.
static int result
Global testing status.
#define GNUNET_TESTING_FAIL(is)
Print failing line number and trigger shutdown.
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_cmd(const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_TESTING_Command **ret)
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_load_topology_from_string(const char *label, const char *topology_data)
void(* GNUNET_TESTING_CommandIterator)(void *cls, const struct GNUNET_TESTING_Command *cmd)
Callback over commands of an interpreter.
void(* GNUNET_TESTING_ResultCallback)(void *cls, enum GNUNET_GenericReturnValue rv)
Function called with the final result of the test.
#define GNUNET_TESTING_command_new(cls, label, run, cleanup, traits)
Create a new command.
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.
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.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
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_ShortmapIterator)(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
Iterator over hash map entries.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
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.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *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.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multishortmap_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
unsigned int GNUNET_CONTAINER_multishortmap_size(const struct GNUNET_CONTAINER_MultiShortmap *map)
Get the number of key-value pairs in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE
If a value with the given key exists, replace it.
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, bool can_drop, GNUNET_HELPER_Continuation cont, void *cont_cls)
Send an message to the helper.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#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_array_append(arr, len, element)
Append an element to an array (growing the array by one).
#define GNUNET_free(ptr)
Wrapper around free.
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.
Internal representation of the hash map.
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 notify_finished
Function to call when async operation is done.
bool next_called
Set to true if interpreter_next() has already been called for this command.
struct GNUNET_TESTING_Interpreter * is
Interpreter we are part of.
enum GNUNET_GenericReturnValue finished
Indication if the command finished (GNUNET_OK).
void * notify_finished_cls
Closure for notify_finished.
An entry for a barrier list.
bool inherited
Did we inherit the barrier from our parent loop?
struct GNUNET_ShortHashCode barrier_id
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?
const char * name
Variable name for the command, NULL for none.
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 run the next command, even if this command did not ...
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.
bool skip
Is the real result to "skip" because we could not get the environment working?
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.
GNUNET_TESTING_cmd_helper_write_cb parent_writer
Function to call to send messages to our parent.
void * rc_cls
Closure for rc.
struct GNUNET_CONTAINER_MultiHashMap * vars
Hash map mapping variable names to commands.
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 SendContext * sender_tail
struct GNUNET_SCHEDULER_Task * task
Interpreter task (if one is scheduled).
struct GNUNET_HELPER_Handle ** helpers
Array with handles of helper processes for communication with netjails.
struct SendContext * sender_head
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, GNUNET_SYSERR on failure, GNUNET_NO if undecided.
unsigned int n_helpers
Size of the array helpers.
The plugin API every test case plugin has to implement.
void * cls
Closure to pass to start_testcase.
struct GNUNET_TESTING_Interpreter *(* start_testcase)(void *cls, const char *topology_data, uint32_t barrier_count, const struct GNUNET_ShortHashCode *barriers, GNUNET_TESTING_cmd_helper_write_cb write_message, GNUNET_TESTING_ResultCallback finish_cb, void *finish_cb_cls)
Function to be implemented for each test case plugin which starts the test case on a netjail node.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
State for a "rewind" CMD.
const char * target_label
Instruction pointer to set into the interpreter.
unsigned int counter
How many times this set should take place.
struct SendContext * next
struct SendContext * prev
struct GNUNET_HELPER_SendHandle * send_handle
Handle to a send op.
struct GNUNET_TESTING_Interpreter * is
void GNUNET_TESTING_barrier_name_hash_(const char *barrier_name, struct GNUNET_ShortHashCode *bkey)
void GNUNET_TESTING_cmd_batch_set_current_(const struct GNUNET_TESTING_Command *cmd, unsigned int new_ip)
Set what command the batch should be 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_barrier2_(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_ShortHashCode *create_key)
struct GNUNET_TESTING_Barrier * GNUNET_TESTING_get_barrier_(struct GNUNET_TESTING_Interpreter *is, const char *barrier_name)
void GNUNET_TESTING_async_finish(struct GNUNET_TESTING_AsyncContext *ac)
The asynchronous command of ac has finished.
unsigned int GNUNET_TESTING_barrier_count_(struct GNUNET_TESTING_Interpreter *is)
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.
void GNUNET_TESTING_barrier_iterate_(struct GNUNET_TESTING_Interpreter *is, GNUNET_CONTAINER_ShortmapIterator cb, void *cb_cls)
void GNUNET_TESTING_async_fail(struct GNUNET_TESTING_AsyncContext *ac)
The asynchronous command of ac has failed.
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.
static void setup_is(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_TESTING_Command *bcommand, const struct GNUNET_TESTING_Command *commands)
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.
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 char * GNUNET_TESTING_interpreter_current_cmd_get_label(struct GNUNET_TESTING_Interpreter *is)
Obtain label of the command being now run.
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.
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_interpreter_skip(struct GNUNET_TESTING_Interpreter *is)
Skips the current test, the environment is not prepared correctly.
static void send_finished(void *cls, enum GNUNET_GenericReturnValue result)
void GNUNET_TESTING_interpreter_current_cmd_inc_tries(struct GNUNET_TESTING_Interpreter *is)
Increment the 'num_tries' counter for the current command.
static struct GNUNET_TESTING_Interpreter * start_testcase(void *cls, const char *topology_data, uint32_t inherited_barrier_count, const struct GNUNET_ShortHashCode *inherited_barriers, GNUNET_TESTING_cmd_helper_write_cb parent_writer, GNUNET_TESTING_ResultCallback finish_cb, void *finish_cb_cls)
void GNUNET_TESTING_interpreter_run_cmd_(struct GNUNET_TESTING_Interpreter *is, struct GNUNET_TESTING_Command *cmd)
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).
struct GNUNET_TESTING_PluginFunctions * GNUNET_TESTING_make_plugin(const struct GNUNET_TESTING_Command *commands)
void GNUNET_TESTING_interpreter_fail(struct GNUNET_TESTING_Interpreter *is)
Current command failed, clean up and fail the test case.
void GNUNET_TESTING_add_barrier_(struct GNUNET_TESTING_Interpreter *is, struct GNUNET_TESTING_Barrier *barrier)
Add a barrier to the interpreter to share it with all children as an inherited barrier.
static void finish_test(void *cls)
Finish the test run, return the final result.
void GNUNET_TESTING_interpreter_next_(void *cls)
Current command is done, run the next one.
static void rewind_ip_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
Run the "rewind" CMD.
static void rewind_ip_free(void *cls)
static enum GNUNET_GenericReturnValue seek_batch(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_TESTING_Command *target)
Seek for the target command in batch (and rewind to it if successful).
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.
void(* GNUNET_TESTING_cmd_helper_write_cb)(const struct GNUNET_MessageHeader *message)
Callback function to write messages from the helper process running on a netjail node to the master p...