GNUnet 0.21.1
testing_api_loop.c File Reference

main interpreter loop for testcases More...

Include dependency graph for testing_api_loop.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_TESTING_Interpreter
 Global state of the interpreter, used by a command to access information about other commands. More...
 
struct  FreeBarrierNodeCbCls
 Closure for free_barrier_node_cb(). More...
 
struct  MainParams
 Closure for loop_run(). More...
 

Functions

static const struct GNUNET_TESTING_Commandget_command (struct GNUNET_TESTING_Interpreter *is, const char *label, bool future)
 Lookup command by label. More...
 
const struct GNUNET_TESTING_CommandGNUNET_TESTING_interpreter_lookup_future_command (struct GNUNET_TESTING_Interpreter *is, const char *label)
 Lookup command by label. More...
 
const struct GNUNET_TESTING_CommandGNUNET_TESTING_interpreter_lookup_command (struct GNUNET_TESTING_Interpreter *is, const char *label)
 Lookup command by label. More...
 
const struct GNUNET_TESTING_CommandGNUNET_TESTING_interpreter_lookup_command_all (struct GNUNET_TESTING_Interpreter *is, const char *label)
 Lookup command by label. More...
 
static void clear_msg (void *cls, enum GNUNET_GenericReturnValue result)
 Continuation function from GNUNET_HELPER_send() More...
 
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. More...
 
static enum GNUNET_GenericReturnValue free_barrier_node_cb (void *cls, const struct GNUNET_ShortHashCode *key, void *value)
 
static void free_barrier_nodes (struct GNUNET_TESTING_Interpreter *is, struct GNUNET_TESTING_Barrier *barrier)
 
static enum GNUNET_GenericReturnValue free_barriers_cb (void *cls, const struct GNUNET_ShortHashCode *key, void *value)
 
static void finish_test (void *cls)
 Finish the test run, return the final result. More...
 
static void interpreter_run (void *cls)
 Run the main interpreter loop that performs exchange operations. More...
 
static void interpreter_next (void *cls)
 Current command is done, run the next one. More...
 
void GNUNET_TESTING_interpreter_fail (struct GNUNET_TESTING_Interpreter *is)
 Current command failed, clean up and fail the test case. More...
 
void GNUNET_TESTING_async_fail (struct GNUNET_TESTING_AsyncContext *ac)
 The asynchronous command of ac has failed. More...
 
void GNUNET_TESTING_async_finish (struct GNUNET_TESTING_AsyncContext *ac)
 The asynchronous command of ac has finished. More...
 
struct GNUNET_TESTING_CommandGNUNET_TESTING_interpreter_get_current_command (struct GNUNET_TESTING_Interpreter *is)
 Returns the actual running command. More...
 
static void do_timeout (void *cls)
 Function run when the test terminates (good or bad) with timeout. More...
 
struct GNUNET_TESTING_InterpreterGNUNET_TESTING_run (const struct GNUNET_TESTING_Command *commands, struct GNUNET_TIME_Relative timeout, GNUNET_TESTING_ResultCallback rc, void *rc_cls)
 Run the testsuite. More...
 
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. More...
 
void GNUNET_TESTING_set_label (struct GNUNET_TESTING_CommandLabel *label, const char *value)
 Set label to value. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_end (void)
 Create command array terminator. More...
 
static void handle_result (void *cls, enum GNUNET_GenericReturnValue rv)
 Function called with the final result of the test. More...
 
static void loop_run (void *cls)
 Main function to run the test cases. More...
 
int GNUNET_TESTING_main (struct GNUNET_TESTING_Command *commands, struct GNUNET_TIME_Relative timeout)
 Start a GNUnet scheduler event loop and run the testsuite. More...
 
void GNUNET_TESTING_add_netjail_helper_ (struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_HELPER_Handle *helper)
 Adding a helper handle to the interpreter. More...
 
struct GNUNET_TESTING_BarrierGNUNET_TESTING_get_barrier_ (struct GNUNET_TESTING_Interpreter *is, const char *barrier_name)
 Getting a barrier from the interpreter. More...
 
void GNUNET_TESTING_add_barrier_ (struct GNUNET_TESTING_Interpreter *is, struct GNUNET_TESTING_Barrier *barrier)
 Add a barrier to the interpreter. More...
 
void GNUNET_TESTING_finish_barrier_ (struct GNUNET_TESTING_Interpreter *is, const char *barrier_name)
 Finish all "barrier reached" commands attached to this barrier. More...
 

Detailed Description

main interpreter loop for testcases

Author
Christian Grothoff (GNU Taler testing)
Marcello Stanisci (GNU Taler testing)
t3sserakt

Definition in file testing_api_loop.c.

Function Documentation

◆ get_command()

static const struct GNUNET_TESTING_Command * get_command ( struct GNUNET_TESTING_Interpreter is,
const char *  label,
bool  future 
)
static

Lookup command by label.

Parameters
isinterpreter to lookup command in
labellabel of the command to lookup.
futuretrue to look into the future, false to look into the past
Returns
the command, if it is found, or NULL.

Definition at line 126 of file testing_api_loop.c.

129{
130 int start_i = future ? is->cmds_n - 1 : is->ip;
131 int end_i = future ? is->ip + 1 : 0;
132
134 "start_i: %u end_i: %u\n",
135 start_i,
136 end_i);
137 if (NULL == label)
138 {
140 "Attempt to lookup command for empty label\n");
141 return NULL;
142 }
143 for (int i = start_i; i >= end_i; i--)
144 {
145 const struct GNUNET_TESTING_Command *cmd = &is->commands[i];
146
147 if (NULL != cmd->run)
149 "label to compare %s\n",
150 cmd->label.value);
151 /* Give precedence to top-level commands. */
152 if ( (NULL != cmd->run) &&
153 (0 == strcmp (cmd->label.value,
154 label)) )
155 return cmd;
156
158 {
159 struct GNUNET_TESTING_Command **batch;
160 struct GNUNET_TESTING_Command *current;
161 const struct GNUNET_TESTING_Command *icmd;
162 const struct GNUNET_TESTING_Command *match;
163
167 &batch));
168 /* We must do the loop forward, but we can find the last match */
169 match = NULL;
170 for (unsigned int j = 0;
171 NULL != (icmd = &(*batch)[j])->run;
172 j++)
173 {
174 if (current == icmd)
175 break; /* do not go past current command */
176 if ( (NULL != icmd->run) &&
177 (0 == strcmp (icmd->label.value,
178 label)) )
179 match = icmd;
180 }
181 if (NULL != match)
182 return match;
183 }
184 }
186 "Command `%s' not found\n",
187 label);
188 return NULL;
189}
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.
Definition: gnunet-arm.c:917
struct GNUNET_TESTING_Interpreter * is
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_batch_cmds(const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Command ***ret)
#define GNUNET_log(kind,...)
@ GNUNET_OK
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
A command to be run by the interpreter.
struct GNUNET_TESTING_CommandLabel label
Label for the command.
GNUNET_TESTING_CommandRunRoutine run
Runs the command.
unsigned int cmds_n
Number of GNUNET_TESTING_Command in commands.
int ip
Instruction pointer.
struct GNUNET_TESTING_Command * commands
Commands the interpreter will run.
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_is_batch_(const struct GNUNET_TESTING_Command *cmd)
Test if this command is a batch command.

References GNUNET_TESTING_Interpreter::cmds_n, GNUNET_TESTING_Interpreter::commands, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_OK, GNUNET_TESTING_cmd_batch_get_current_(), GNUNET_TESTING_cmd_is_batch_(), GNUNET_TESTING_get_trait_batch_cmds(), GNUNET_TESTING_Interpreter::ip, is, GNUNET_TESTING_Command::label, run(), GNUNET_TESTING_Command::run, and GNUNET_TESTING_CommandLabel::value.

Referenced by GNUNET_TESTING_interpreter_lookup_command(), GNUNET_TESTING_interpreter_lookup_command_all(), and GNUNET_TESTING_interpreter_lookup_future_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTING_interpreter_lookup_future_command()

const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_future_command ( struct GNUNET_TESTING_Interpreter is,
const char *  label 
)

Lookup command by label.

Only future commands are looked up.

Parameters
isinterpreter to lookup command in
labellabel of the command to lookup.
Returns
the command, if it is found, or NULL.
Deprecated:
(still in use in a very odd way)

Definition at line 193 of file testing_api_loop.c.

196{
197 return get_command (is,
198 label,
199 true);
200}
static const struct GNUNET_TESTING_Command * get_command(struct GNUNET_TESTING_Interpreter *is, const char *label, bool future)
Lookup command by label.

References get_command(), is, and GNUNET_TESTING_Command::label.

Here is the call graph for this function:

◆ GNUNET_TESTING_interpreter_lookup_command()

const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command ( struct GNUNET_TESTING_Interpreter is,
const char *  label 
)

Lookup command by label.

Parameters
isinterpreter to lookup command in
labellabel of the command to lookup.
Returns
the command, if it is found, or NULL.

Definition at line 204 of file testing_api_loop.c.

207{
208 return get_command (is,
209 label,
210 false);
211}

References get_command(), is, and GNUNET_TESTING_Command::label.

Referenced by backchannel_check_run(), connect_peers_run(), join_room_run(), run_finish(), send_simple_run(), start_peer_run(), start_service_run(), stop_peer_run(), stop_service_run(), stop_testing_system_run(), and system_destroy_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTING_interpreter_lookup_command_all()

const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command_all ( struct GNUNET_TESTING_Interpreter is,
const char *  label 
)

Lookup command by label.

All commands, first into the past, then into the future are looked up.

Parameters
isinterpreter to lookup command in
labellabel of the command to lookup.
Returns
the command, if it is found, or NULL.
Deprecated:
(still in use in a very odd way)

Definition at line 215 of file testing_api_loop.c.

218{
219 const struct GNUNET_TESTING_Command *cmd;
220
221 cmd = get_command (is,
222 label,
223 false);
224 if (NULL == cmd)
225 cmd = get_command (is,
226 label,
227 true);
228 return cmd;
229}

References get_command(), is, and GNUNET_TESTING_Command::label.

Referenced by notify_connect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear_msg()

static void clear_msg ( void *  cls,
enum GNUNET_GenericReturnValue  result 
)
static

Continuation function from GNUNET_HELPER_send()

Parameters
clsclosure
resultGNUNET_OK on success, GNUNET_NO if helper process died GNUNET_SYSERR during GNUNET_HELPER_stop()

Definition at line 241 of file testing_api_loop.c.

243{
245}
static int result
Global testing status.
@ GNUNET_YES

References GNUNET_assert, GNUNET_YES, and result.

Referenced by send_barrier_crossable().

Here is the caller graph for this function:

◆ send_barrier_crossable()

static void send_barrier_crossable ( struct GNUNET_TESTING_Interpreter is,
const char *  barrier_name,
unsigned int  global_node_number 
)
static

Send message to a netjail node that a barrier can be crossed.

Parameters
isThe interpreter loop.
barrier_nameThe name of the barrier to cross.
global_node_numberThe global number of the node to inform.

FIXME: This should probably be put into a linked list inside is and cleaned up at some point.

Definition at line 256 of file testing_api_loop.c.

259{
260 struct CommandBarrierCrossable *adm;
261 size_t msg_length;
262 size_t name_len;
263
265 "send barrier crossable for barrier `%s'\n",
266 barrier_name);
267 name_len = strlen (barrier_name);
268 msg_length = sizeof(struct CommandBarrierCrossable) + name_len + 1;
269 adm = GNUNET_malloc (msg_length);
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",
275 ntohs (adm->header.type));
281 (struct GNUNET_HELPER_Handle *) is->helper[global_node_number - 1],
282 &adm->header,
283 GNUNET_NO,
284 &clear_msg,
285 NULL);
286 GNUNET_free (adm);
287}
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.
Definition: helper.c:613
@ GNUNET_NO
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE
Message send to a child loop to inform the child loop about a barrier being advanced.
Definition: testing.h:35
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE.
Definition: testing.h:39
The handle to a helper process.
Definition: helper.c:77
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
struct GNUNET_HELPER_SendHandle * send_handle
Handle to a send op.
const struct GNUNET_HELPER_Handle ** helper
Array with handles of helper processes for communication with netjails.
static void clear_msg(void *cls, enum GNUNET_GenericReturnValue result)
Continuation function from GNUNET_HELPER_send()

References clear_msg(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_HELPER_send(), GNUNET_log, GNUNET_malloc, GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE, GNUNET_NO, CommandBarrierCrossable::header, GNUNET_TESTING_Interpreter::helper, is, GNUNET_TESTING_Interpreter::send_handle, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by free_barrier_node_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_barrier_node_cb()

static enum GNUNET_GenericReturnValue free_barrier_node_cb ( void *  cls,
const struct GNUNET_ShortHashCode key,
void *  value 
)
static

Definition at line 308 of file testing_api_loop.c.

311{
312 struct FreeBarrierNodeCbCls *free_barrier_node_cb_cls = cls;
313 struct GNUNET_TESTING_NetjailNode *node = value;
314 struct GNUNET_TESTING_Barrier *barrier = free_barrier_node_cb_cls->barrier;
315 struct GNUNET_TESTING_Interpreter *is = free_barrier_node_cb_cls->is;
316
318 "free_barrier_node_cb\n");
319 if (! is->finishing)
320 {
322 barrier->name,
323 node->node_number);
324 }
327 barrier->nodes,
328 key,
329 node));
330 return GNUNET_YES;
331}
struct GNUNET_HashCode key
The key used in the DHT.
static char * value
Value of the record to add/remove.
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.
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.
const char * name
Name of the barrier.
Definition: testing.h:182
struct GNUNET_CONTAINER_MultiShortmap * nodes
Hash map containing the global known nodes which are not natted.
Definition: testing.h:177
Global state of the interpreter, used by a command to access information about other commands.
bool finishing
Is the interpreter finishing?
Node in the netjail topology.
unsigned int node_number
The overall number of the node in the whole test system.
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.

References FreeBarrierNodeCbCls::barrier, GNUNET_TESTING_Interpreter::finishing, GNUNET_assert, GNUNET_CONTAINER_multishortmap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_YES, is, FreeBarrierNodeCbCls::is, key, GNUNET_TESTING_Barrier::name, GNUNET_TESTING_NetjailNode::node_number, GNUNET_TESTING_Barrier::nodes, send_barrier_crossable(), and value.

Referenced by free_barrier_nodes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_barrier_nodes()

static void free_barrier_nodes ( struct GNUNET_TESTING_Interpreter is,
struct GNUNET_TESTING_Barrier barrier 
)
static

Definition at line 335 of file testing_api_loop.c.

337{
338 struct FreeBarrierNodeCbCls free_barrier_node_cb_cls = {
339 .barrier = barrier,
340 .is = is
341 };
342
343 if (NULL == barrier->nodes)
344 return;
347 &free_barrier_node_cb_cls);
349 barrier->nodes = NULL;
350}
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.
static enum GNUNET_GenericReturnValue free_barrier_node_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)

References FreeBarrierNodeCbCls::barrier, free_barrier_node_cb(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_CONTAINER_multishortmap_iterate(), is, and GNUNET_TESTING_Barrier::nodes.

Referenced by free_barriers_cb(), and GNUNET_TESTING_finish_barrier_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_barriers_cb()

static enum GNUNET_GenericReturnValue free_barriers_cb ( void *  cls,
const struct GNUNET_ShortHashCode key,
void *  value 
)
static

Definition at line 354 of file testing_api_loop.c.

357{
358 struct GNUNET_TESTING_Interpreter *is = cls;
359 struct GNUNET_TESTING_Barrier *barrier = value;
360 struct CommandListEntry *pos;
361
363 barrier);
364 while (NULL != (pos = barrier->cmds_head))
365 {
367 barrier->cmds_tail,
368 pos);
369 GNUNET_free (pos);
370 }
371 GNUNET_free (barrier);
372 return GNUNET_YES;
373}
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct CommandListEntry * cmds_tail
Tail of the DLL with local commands the barrier is attached too.
Definition: testing.h:172
struct CommandListEntry * cmds_head
Head of the DLL with local commands the barrier is attached too.
Definition: testing.h:167
static void free_barrier_nodes(struct GNUNET_TESTING_Interpreter *is, struct GNUNET_TESTING_Barrier *barrier)

References GNUNET_TESTING_Barrier::cmds_head, GNUNET_TESTING_Barrier::cmds_tail, free_barrier_nodes(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_YES, is, and value.

Referenced by finish_test().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ finish_test()

static void finish_test ( void *  cls)
static

Finish the test run, return the final result.

Parameters
clsthe struct GNUNET_TESTING_Interpreter

Definition at line 382 of file testing_api_loop.c.

383{
384 struct GNUNET_TESTING_Interpreter *is = cls;
385 struct GNUNET_TESTING_Command *cmd;
386 const char *label;
387
388 is->finishing = true;
389 is->final_task = NULL;
391 if (NULL == is->commands[is->ip].run)
392 label = "END";
394 "Interpreter finishes at `%s' with status %d\n",
395 label,
396 is->result);
397 for (unsigned int j = 0;
398 NULL != (cmd = &is->commands[j])->run;
399 j++)
400 {
402 "Cleaning up cmd %s\n",
403 cmd->label.value);
404 cmd->cleanup (cmd->cls);
406 "Cleaned up cmd %s\n",
407 cmd->label.value);
408 }
409 if (NULL != is->task)
410 {
412 is->task = NULL;
413 }
414 if (NULL != is->timeout_task)
415 {
417 is->timeout_task = NULL;
418 }
419 if (NULL != is->send_handle)
420 {
422 is->send_handle = NULL;
423 }
425 is->rc (is->rc_cls,
426 is->result);
429 is);
432 GNUNET_free (is);
433}
void GNUNET_HELPER_send_cancel(struct GNUNET_HELPER_SendHandle *sh)
Cancel a GNUNET_HELPER_send operation.
Definition: helper.c:653
@ GNUNET_ERROR_TYPE_INFO
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:981
GNUNET_TESTING_CommandCleanupRoutine cleanup
Clean up after the command.
void * cls
Closure for all commands with command-specific context information.
GNUNET_TESTING_ResultCallback rc
Function to call with the test result.
struct GNUNET_CONTAINER_MultiShortmap * barriers
Map with barriers for this loop.
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.
struct GNUNET_SCHEDULER_Task * task
Interpreter task (if one is scheduled).
enum GNUNET_GenericReturnValue result
Result of the testcases, GNUNET_OK on success.
static enum GNUNET_GenericReturnValue free_barriers_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)

References GNUNET_TESTING_Interpreter::barriers, GNUNET_TESTING_Command::cleanup, GNUNET_TESTING_Command::cls, GNUNET_TESTING_Interpreter::commands, GNUNET_TESTING_Interpreter::final_task, GNUNET_TESTING_Interpreter::finishing, free_barriers_cb(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_HELPER_send_cancel(), GNUNET_log, GNUNET_SCHEDULER_cancel(), GNUNET_TESTING_Interpreter::helper, GNUNET_TESTING_Interpreter::ip, is, GNUNET_TESTING_Command::label, GNUNET_TESTING_Interpreter::rc, GNUNET_TESTING_Interpreter::rc_cls, GNUNET_TESTING_Interpreter::result, run(), GNUNET_TESTING_Command::run, GNUNET_TESTING_Interpreter::send_handle, GNUNET_TESTING_Interpreter::task, GNUNET_TESTING_Interpreter::timeout_task, and GNUNET_TESTING_CommandLabel::value.

Referenced by do_timeout(), GNUNET_TESTING_interpreter_fail(), and interpreter_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ interpreter_run()

static void interpreter_run ( void *  cls)
static

Run the main interpreter loop that performs exchange operations.

Run the main interpreter loop.

Parameters
clscontains the struct InterpreterState
clscontains the struct GNUNET_TESTING_Interpreter

Definition at line 561 of file testing_api_loop.c.

562{
563 struct GNUNET_TESTING_Interpreter *is = cls;
564 struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
565
566 is->task = NULL;
567 if (NULL == cmd->run)
568 {
570 "Running command END\n");
572 finish_test (is);
573 return;
574 }
576 "Running command `%s'\n",
577 cmd->label.value);
579 "start time of %p expected 0 is `%" PRIu64 "'\n",
580 cmd,
582 cmd->start_time
583 = cmd->last_req_time
585 cmd->num_tries = 1;
586 if (NULL != cmd->ac)
587 {
588 cmd->ac->is = is;
589 cmd->ac->cont = &interpreter_next;
590 cmd->ac->cont_cls = is;
591 cmd->ac->finished = false;
592 }
593 cmd->run (cmd->cls,
594 is);
595 if (NULL == cmd->ac)
596 {
598 }
599 else if ( (cmd->asynchronous_finish) &&
600 (NULL != cmd->ac->cont) )
601 {
602 cmd->ac->cont = NULL;
604 }
605}
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
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).
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.
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?
uint64_t abs_value_us
The actual value.
static void interpreter_next(void *cls)
Current command is done, run the next one.
static void finish_test(void *cls)
Finish the test run, return the final result.

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_TESTING_Command::ac, GNUNET_TESTING_Command::asynchronous_finish, GNUNET_TESTING_Command::cls, GNUNET_TESTING_Interpreter::commands, GNUNET_TESTING_AsyncContext::cont, GNUNET_TESTING_AsyncContext::cont_cls, finish_test(), GNUNET_TESTING_AsyncContext::finished, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_OK, GNUNET_TIME_absolute_get(), interpreter_next(), GNUNET_TESTING_Interpreter::ip, GNUNET_TESTING_AsyncContext::is, is, GNUNET_TESTING_Command::label, GNUNET_TESTING_Command::last_req_time, GNUNET_TESTING_Command::num_tries, GNUNET_TESTING_Interpreter::result, GNUNET_TESTING_Command::run, GNUNET_TESTING_Command::start_time, GNUNET_TESTING_Interpreter::task, and GNUNET_TESTING_CommandLabel::value.

Referenced by GNUNET_TESTING_run(), and interpreter_next().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ interpreter_next()

static void interpreter_next ( void *  cls)
static

Current command is done, run the next one.

Definition at line 449 of file testing_api_loop.c.

450{
451 struct GNUNET_TESTING_Interpreter *is = cls;
452 static unsigned long long ipc;
453 static struct GNUNET_TIME_Absolute last_report;
454 struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
455
456 if (GNUNET_SYSERR == is->result)
457 return; /* ignore, we already failed! */
459 if ( (! GNUNET_TESTING_cmd_is_batch_ (cmd)) ||
461 is->ip++;
462 if (0 == (ipc % 1000))
463 {
464 if (0 != ipc)
466 "Interpreter executed 1000 instructions in %s\n",
469 GNUNET_YES));
470 last_report = GNUNET_TIME_absolute_get ();
471 }
472 ipc++;
474 is);
475}
@ GNUNET_SYSERR
@ GNUNET_ERROR_TYPE_MESSAGE
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.
Definition: scheduler.c:1305
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...
Definition: time.c:436
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:570
struct GNUNET_TIME_Absolute finish_time
When did the execution of this command finish?
Time for absolute times used by GNUnet, in microseconds.
bool GNUNET_TESTING_cmd_batch_next_(void *cls)
Advance internal pointer to next command.
static void interpreter_run(void *cls)
Run the main interpreter loop that performs exchange operations.

References GNUNET_TESTING_Command::cls, GNUNET_TESTING_Interpreter::commands, GNUNET_TESTING_Command::finish_time, GNUNET_ERROR_TYPE_MESSAGE, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TESTING_cmd_batch_next_(), GNUNET_TESTING_cmd_is_batch_(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, interpreter_run(), GNUNET_TESTING_Interpreter::ip, is, GNUNET_TESTING_Interpreter::result, and GNUNET_TESTING_Interpreter::task.

Referenced by interpreter_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTING_interpreter_fail()

void GNUNET_TESTING_interpreter_fail ( struct GNUNET_TESTING_Interpreter is)

Current command failed, clean up and fail the test case.

Parameters
isinterpreter state.

Definition at line 479 of file testing_api_loop.c.

480{
481 struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
482
483 if (GNUNET_SYSERR == is->result)
484 {
485 GNUNET_break (0);
486 return; /* ignore, we already failed! */
487 }
488 if (NULL != cmd)
489 {
491 "Failed at command `%s'\n",
492 cmd->label.value);
493 while (GNUNET_TESTING_cmd_is_batch_ (cmd))
494 {
497 "Failed in batch at command `%s'\n",
498 cmd->label.value);
499 }
500 }
501 else
502 {
504 "Failed with CMD being NULL!\n");
505 }
507 GNUNET_assert (NULL == is->final_task);
509 is);
510}
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.

References GNUNET_TESTING_Interpreter::commands, GNUNET_TESTING_Interpreter::final_task, finish_test(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SCHEDULER_add_now(), GNUNET_SYSERR, GNUNET_TESTING_cmd_batch_get_current_(), GNUNET_TESTING_cmd_is_batch_(), GNUNET_TESTING_Interpreter::ip, is, GNUNET_TESTING_Command::label, GNUNET_TESTING_Interpreter::result, and GNUNET_TESTING_CommandLabel::value.

Referenced by connect_peers_run(), exec_bash_script_run(), GNUNET_TESTING_async_fail(), join_room_run(), netjail_start_run(), netjail_stop_run(), on_message_cb(), run_finish(), start_helper(), start_peer_run(), and start_service_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTING_async_fail()

void GNUNET_TESTING_async_fail ( struct GNUNET_TESTING_AsyncContext ac)

The asynchronous command of ac has failed.

Parameters
accommand-specific context

Definition at line 514 of file testing_api_loop.c.

515{
519 if (NULL != ac->cont)
520 {
521 ac->cont (ac->cont_cls);
522 ac->cont = NULL;
523 }
524}
void GNUNET_TESTING_interpreter_fail(struct GNUNET_TESTING_Interpreter *is)
Current command failed, clean up and fail the test case.

References GNUNET_TESTING_Command::ac, GNUNET_TESTING_AsyncContext::cont, GNUNET_TESTING_AsyncContext::cont_cls, GNUNET_TESTING_AsyncContext::finished, GNUNET_assert, GNUNET_NO, GNUNET_SYSERR, GNUNET_TESTING_interpreter_fail(), and GNUNET_TESTING_AsyncContext::is.

Referenced by child_completed_callback(), exp_cb(), helper_mst(), and timeout_finish().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTING_async_finish()

void GNUNET_TESTING_async_finish ( struct GNUNET_TESTING_AsyncContext ac)

The asynchronous command of ac has finished.

Parameters
accommand-specific context

Definition at line 528 of file testing_api_loop.c.

529{
531 ac->finished = GNUNET_OK;
532 if (NULL != ac->cont)
533 {
534 ac->cont (ac->cont_cls);
535 ac->cont = NULL;
536 }
537}

References GNUNET_TESTING_Command::ac, GNUNET_TESTING_AsyncContext::cont, GNUNET_TESTING_AsyncContext::cont_cls, GNUNET_TESTING_AsyncContext::finished, GNUNET_assert, GNUNET_NO, and GNUNET_OK.

Referenced by backchannel_check_run(), child_completed_callback(), do_timeout(), done_finish(), GNUNET_TESTING_finish_barrier_(), hello_iter_cb(), helper_mst(), notify_connect(), read_from_log(), run_finish(), send_run(), and send_simple_single().

Here is the caller graph for this function:

◆ GNUNET_TESTING_interpreter_get_current_command()

struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_get_current_command ( struct GNUNET_TESTING_Interpreter is)

Returns the actual running command.

Parameters
isGlobal state of the interpreter, used by a command to access information about other commands.
Returns
The actual running command.

Definition at line 548 of file testing_api_loop.c.

550{
551 return &is->commands[is->ip];
552}

References GNUNET_TESTING_Interpreter::commands, GNUNET_TESTING_Interpreter::ip, and is.

Referenced by barrier_reached_run(), block_until_all_peers_started_run(), and do_timeout().

Here is the caller graph for this function:

◆ do_timeout()

static void do_timeout ( void *  cls)
static

Function run when the test terminates (good or bad) with timeout.

Parameters
clsthe interpreter state

Definition at line 614 of file testing_api_loop.c.

615{
616 struct GNUNET_TESTING_Interpreter *is = cls;
617
618 is->timeout_task = NULL;
620 "Terminating test due to global timeout\n");
622 finish_test (is);
623}

References finish_test(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SYSERR, is, GNUNET_TESTING_Interpreter::result, and GNUNET_TESTING_Interpreter::timeout_task.

Referenced by GNUNET_TESTING_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTING_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.

Note, CMDs are copied into the interpreter state because they are usually defined into the "run" method that returns after having scheduled the test interpreter.

Parameters
commandsthe array of command to execute
timeouthow long to wait for each command to execute
rcfunction to call with the final result
rc_clsclosure for rc
Returns
The interpreter.

Definition at line 627 of file testing_api_loop.c.

631{
633 unsigned int i;
634
636 is->rc = rc;
637 is->rc_cls = rc_cls;
639 false);
640 /* get the number of commands */
641 for (i = 0; NULL != commands[i].run; i++)
642 ;
643 is->cmds_n = i + 1;
645 "Got %u commands\n",
646 i);
647 is->commands = GNUNET_malloc_large ( (i + 1)
648 * sizeof (struct
650 GNUNET_assert (NULL != is->commands);
651 memcpy (is->commands,
652 commands,
653 sizeof (struct GNUNET_TESTING_Command) * i);
656 &do_timeout,
657 is);
659 is);
660
661 return is;
662}
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:119
static struct VoipCommand commands[]
List of supported commands.
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).
#define GNUNET_malloc_large(size)
Wrapper around malloc.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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.
Definition: scheduler.c:1278
static void do_timeout(void *cls)
Function run when the test terminates (good or bad) with timeout.

References GNUNET_TESTING_Interpreter::barriers, GNUNET_TESTING_Interpreter::cmds_n, commands, GNUNET_TESTING_Interpreter::commands, do_timeout(), GNUNET_assert, GNUNET_CONTAINER_multishortmap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_malloc_large, GNUNET_new, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), interpreter_run(), is, GNUNET_TESTING_Interpreter::rc, GNUNET_TESTING_Interpreter::rc_cls, GNUNET_TESTING_Interpreter::task, timeout, and GNUNET_TESTING_Interpreter::timeout_task.

Referenced by loop_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTING_command_new()

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.

Parameters
clsthe closure
labelthe Label. Maximum length is GNUNET_TESTING_CMD_MAX_LABEL_LENGTH
runthe run routing
cleanupthe cleanup function
traitsthe traits function (optional)
theasync context
Returns
the command the function cannot fail

Definition at line 666 of file testing_api_loop.c.

672{
673 struct GNUNET_TESTING_Command cmd = {
674 .cls = cls,
675 .run = run,
676 .ac = ac,
677 .cleanup = cleanup,
678 .traits = traits
679 };
680
681 GNUNET_assert (NULL != run);
682 if (NULL != label)
684 label);
685 return cmd;
686}
static void cleanup(void *cls)
Disconnect and shutdown.
Definition: gnunet-did.c:131
GNUNET_TESTING_CommandGetTraits traits
Extract information from a command that is useful for other commands.
void GNUNET_TESTING_set_label(struct GNUNET_TESTING_CommandLabel *label, const char *value)
Set label to value.

References GNUNET_TESTING_Command::ac, cleanup(), GNUNET_TESTING_Command::cls, GNUNET_assert, GNUNET_TESTING_set_label(), GNUNET_TESTING_Command::label, run(), and GNUNET_TESTING_Command::traits.

Referenced by GNUNET_CORE_cmd_connect_peers(), GNUNET_MESSENGER_cmd_join_room(), GNUNET_MESSENGER_cmd_start_service(), GNUNET_MESSENGER_cmd_stop_service(), GNUNET_TESTING_cmd_barrier_create(), GNUNET_TESTING_cmd_barrier_reached(), GNUNET_TESTING_cmd_batch(), GNUNET_TESTING_cmd_block_until_external_trigger(), GNUNET_TESTING_cmd_exec_bash_script(), GNUNET_TESTING_cmd_finish(), GNUNET_TESTING_cmd_local_test_prepared(), GNUNET_TESTING_cmd_netjail_start(), GNUNET_TESTING_cmd_netjail_start_cmds_helper(), GNUNET_TESTING_cmd_netjail_stop(), GNUNET_TESTING_cmd_send_peer_ready(), GNUNET_TESTING_cmd_start_peer(), GNUNET_TESTING_cmd_stop_cmds_helper(), GNUNET_TESTING_cmd_stop_peer(), GNUNET_TESTING_cmd_system_create(), GNUNET_TESTING_cmd_system_destroy(), GNUNET_TRANSPORT_cmd_backchannel_check(), GNUNET_TRANSPORT_cmd_connect_peers(), GNUNET_TRANSPORT_cmd_send_simple(), GNUNET_TRANSPORT_cmd_send_simple_performance(), GNUNET_TRANSPORT_cmd_start_peer(), and GNUNET_TRANSPORT_cmd_stop_peer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTING_set_label()

void GNUNET_TESTING_set_label ( struct GNUNET_TESTING_CommandLabel label,
const char *  value 
)

Set label to value.

Asserts that value is not longer than GNUNET_TESTING_CMD_MAX_LABEL_LENGTH.

Parameters
[out]labellabel to initialize
valuevalue to store into label

Definition at line 690 of file testing_api_loop.c.

692{
693 size_t len;
694
695 len = strlen (value);
696 GNUNET_assert (len <=
698 memcpy (label->value,
699 value,
700 len + 1);
701}
#define GNUNET_TESTING_CMD_MAX_LABEL_LENGTH
Central interpreter and command loop for writing an interpreter to test asynchronous systems.

References GNUNET_assert, GNUNET_TESTING_CMD_MAX_LABEL_LENGTH, GNUNET_TESTING_Command::label, value, and GNUNET_TESTING_CommandLabel::value.

Referenced by GNUNET_TESTING_cmd_batch(), GNUNET_TESTING_command_new(), and GNUNET_TESTING_DHTU_cmd_send().

Here is the caller graph for this function:

◆ GNUNET_TESTING_cmd_end()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_end ( void  )

Create command array terminator.

Returns
a end-command.

Definition at line 706 of file testing_api_loop.c.

707{
708 struct GNUNET_TESTING_Command cmd = {
709 .run = NULL
710 };
711
712 return cmd;
713}

References GNUNET_TESTING_Command::run.

◆ handle_result()

static void handle_result ( void *  cls,
enum GNUNET_GenericReturnValue  rv 
)
static

Function called with the final result of the test.

Parameters
clsthe struct MainParams
rvGNUNET_OK if the test passed

Definition at line 746 of file testing_api_loop.c.

748{
749 struct MainParams *mp = cls;
750
752 "Test exits with status %d\n",
753 rv);
754 if (GNUNET_OK != rv)
755 mp->rv = EXIT_FAILURE;
757}
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
Closure for loop_run().
int rv
Set to #EXIT_FAILURE on error.

References GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_OK, GNUNET_SCHEDULER_shutdown(), and MainParams::rv.

Referenced by loop_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loop_run()

static void loop_run ( void *  cls)
static

Main function to run the test cases.

Parameters
clsa struct MainParams *

Definition at line 766 of file testing_api_loop.c.

767{
768 struct MainParams *mp = cls;
769
771 mp->timeout,
773 mp);
774}
struct GNUNET_TIME_Relative timeout
Global timeout for the test.
struct GNUNET_TESTING_Command * commands
NULL-label terminated array of commands.
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.
static void handle_result(void *cls, enum GNUNET_GenericReturnValue rv)
Function called with the final result of the test.

References MainParams::commands, GNUNET_TESTING_run(), handle_result(), and MainParams::timeout.

Referenced by GNUNET_TESTING_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTING_main()

int GNUNET_TESTING_main ( struct GNUNET_TESTING_Command commands,
struct GNUNET_TIME_Relative  timeout 
)

Start a GNUnet scheduler event loop and run the testsuite.

Return 0 upon success. Expected to be called directly from main(). FIXME: Why is this commands array here not const?

Parameters
commandsthe list of command to execute
timeouthow long to wait for each command to execute
Returns
EXIT_SUCCESS on success, EXIT_FAILURE on failure

Definition at line 778 of file testing_api_loop.c.

780{
781 struct MainParams mp = {
783 .timeout = timeout,
784 .rv = EXIT_SUCCESS
785 };
786
788 &mp);
789 return mp.rv;
790}
void GNUNET_SCHEDULER_run(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Initialize and run scheduler.
Definition: scheduler.c:725
static void loop_run(void *cls)
Main function to run the test cases.

References commands, MainParams::commands, GNUNET_SCHEDULER_run(), loop_run(), MainParams::rv, and timeout.

Here is the call graph for this function:

◆ GNUNET_TESTING_add_netjail_helper_()

void GNUNET_TESTING_add_netjail_helper_ ( struct GNUNET_TESTING_Interpreter is,
const struct GNUNET_HELPER_Handle helper 
)

Adding a helper handle to the interpreter.

Parameters
isThe interpreter.
helperThe helper handle.

Definition at line 794 of file testing_api_loop.c.

796{
798 is->n_helper,
799 helper);
800}
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
unsigned int n_helper
Size of the array helper.

References GNUNET_array_append, GNUNET_TESTING_Interpreter::helper, is, and GNUNET_TESTING_Interpreter::n_helper.

Referenced by start_helper().

Here is the caller graph for this function:

◆ GNUNET_TESTING_get_barrier_()

struct GNUNET_TESTING_Barrier * GNUNET_TESTING_get_barrier_ ( struct GNUNET_TESTING_Interpreter is,
const char *  barrier_name 
)

Getting a barrier from the interpreter.

Parameters
isThe interpreter.
barrier_nameThe name of the barrier.
Returns
The barrier.

Definition at line 804 of file testing_api_loop.c.

806{
807 struct GNUNET_HashCode hc;
808 struct GNUNET_ShortHashCode create_key;
809
810 GNUNET_CRYPTO_hash (barrier_name,
811 strlen (barrier_name),
812 &hc);
813 memcpy (&create_key,
814 &hc,
815 sizeof (create_key));
817 &create_key);
818}
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
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.
A 512-bit hashcode.
A 256-bit hashcode.

References GNUNET_TESTING_Interpreter::barriers, GNUNET_CONTAINER_multishortmap_get(), GNUNET_CRYPTO_hash(), and is.

Referenced by barrier_attached(), barrier_reached(), barrier_reached_run(), GNUNET_TESTING_finish_barrier_(), and start_helper().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTING_add_barrier_()

void GNUNET_TESTING_add_barrier_ ( struct GNUNET_TESTING_Interpreter is,
struct GNUNET_TESTING_Barrier barrier 
)

Add a barrier to the interpreter.

Add a barrier to the loop.

Parameters
isThe interpreter.
barrierThe barrier to add.

Definition at line 828 of file testing_api_loop.c.

830{
831 struct GNUNET_HashCode hc;
832 struct GNUNET_ShortHashCode create_key;
833
835 "Adding barrier %s locally\n",
836 barrier->name);
837 GNUNET_CRYPTO_hash (barrier->name,
838 strlen (barrier->name),
839 &hc);
840 memcpy (&create_key,
841 &hc,
842 sizeof (create_key));
844 &create_key,
845 barrier,
847}
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.
@ 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...

References GNUNET_TESTING_Interpreter::barriers, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multishortmap_put(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, is, and GNUNET_TESTING_Barrier::name.

Referenced by barrier_reached_run(), barrier_run(), and start_helper().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTING_finish_barrier_()

void GNUNET_TESTING_finish_barrier_ ( struct GNUNET_TESTING_Interpreter is,
const char *  barrier_name 
)

Finish all "barrier reached" commands attached to this barrier.

Parameters
barrierThe barrier in question.

Definition at line 851 of file testing_api_loop.c.

853{
854 struct CommandListEntry *pos;
855 struct GNUNET_TESTING_Barrier *barrier;
856
858 barrier_name);
859 if (NULL == barrier)
860 return;
861 while (NULL != (pos = barrier->cmds_head))
862 {
864 "command label %s\n",
865 pos->command->label.value);
866 if ( (GNUNET_NO == pos->command->ac->finished) &&
868 {
870 "command label %s finish\n",
871 pos->command->label.value);
873 }
874 else if (GNUNET_NO == pos->command->ac->finished)
875 {
877 }
879 barrier->cmds_tail,
880 pos);
882 "command entry label %s removed\n",
883 pos->command->label.value);
884 GNUNET_free (pos);
886 "command entry freed\n");
887 }
889 barrier);
890}
struct GNUNET_TESTING_Command * command
Definition: testing.h:148
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.

References GNUNET_TESTING_Command::ac, GNUNET_TESTING_Command::asynchronous_finish, GNUNET_TESTING_Barrier::cmds_head, GNUNET_TESTING_Barrier::cmds_tail, CommandListEntry::command, GNUNET_TESTING_AsyncContext::finished, free_barrier_nodes(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_TESTING_async_finish(), GNUNET_TESTING_get_barrier_(), GNUNET_YES, is, GNUNET_TESTING_Command::label, and GNUNET_TESTING_CommandLabel::value.

Referenced by barrier_reached(), barrier_reached_run(), and tokenizer_cb().

Here is the call graph for this function:
Here is the caller graph for this function: