GNUnet 0.21.2
testing_api_loop.c File Reference

main interpreter loop for testcases More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_lib.h"
#include "testing_api_loop.h"
#include "testing_api_cmd_batch.h"
#include "testing_api_topology.h"
#include "testing_cmds.h"
Include dependency graph for testing_api_loop.c:

Go to the source code of this file.

Data Structures

struct  SendContext
 
struct  GNUNET_TESTING_Interpreter
 Global state of the interpreter, used by a command to access information about other commands. More...
 
struct  RewindIpState
 State for a "rewind" CMD. More...
 

Functions

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_get_command (struct GNUNET_TESTING_Interpreter *is, const char *name)
 Get command from hash map by variable name. More...
 
static void send_finished (void *cls, enum GNUNET_GenericReturnValue result)
 
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). More...
 
void GNUNET_TESTING_loop_notify_parent_ (struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_MessageHeader *hdr)
 Send message to our parent. More...
 
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...
 
void GNUNET_TESTING_interpreter_next_ (void *cls)
 Current command is done, run the next one. More...
 
void GNUNET_TESTING_interpreter_run_cmd_ (struct GNUNET_TESTING_Interpreter *is, struct GNUNET_TESTING_Command *cmd)
 
void GNUNET_TESTING_interpreter_fail (struct GNUNET_TESTING_Interpreter *is)
 Current command failed, clean up and fail the test case. More...
 
void GNUNET_TESTING_interpreter_skip (struct GNUNET_TESTING_Interpreter *is)
 Skips the current test, the environment is not prepared correctly. 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...
 
static void do_timeout (void *cls)
 Function run when the test terminates (good or bad) with timeout. More...
 
static void setup_is (struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_TESTING_Command *bcommand, const struct GNUNET_TESTING_Command *commands)
 
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...
 
static struct GNUNET_TESTING_Interpreterstart_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)
 
struct GNUNET_TESTING_PluginFunctionsGNUNET_TESTING_make_plugin (const struct GNUNET_TESTING_Command *commands)
 
void GNUNET_TESTING_add_netjail_helper_ (struct GNUNET_TESTING_Interpreter *is, struct GNUNET_HELPER_Handle *helper)
 Adding a helper handle to the interpreter. More...
 
struct GNUNET_TESTING_BarrierGNUNET_TESTING_get_barrier2_ (struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_ShortHashCode *create_key)
 
struct GNUNET_TESTING_BarrierGNUNET_TESTING_get_barrier_ (struct GNUNET_TESTING_Interpreter *is, const char *barrier_name)
 
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. More...
 
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_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. More...
 
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. More...
 
void GNUNET_TESTING_interpreter_current_cmd_inc_tries (struct GNUNET_TESTING_Interpreter *is)
 Increment the 'num_tries' counter for the current command. More...
 
const char * GNUNET_TESTING_interpreter_current_cmd_get_label (struct GNUNET_TESTING_Interpreter *is)
 Obtain label of the command being now run. More...
 
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). More...
 
static void rewind_ip_run (void *cls, struct GNUNET_TESTING_Interpreter *is)
 Run the "rewind" CMD. More...
 
static void rewind_ip_free (void *cls)
 
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. 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

◆ 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 147 of file testing_api_loop.c.

150{
151 if (NULL == label)
152 {
154 "Attempt to lookup command for empty label\n");
155 return NULL;
156 }
157 for (int i = is->ip; i >= 0; i--)
158 {
159 const struct GNUNET_TESTING_Command *cmd = &is->commands[i];
160
161 /* Give precedence to top-level commands. */
162 if ( (NULL != cmd->run) &&
163 (0 == strcmp (cmd->label.value,
164 label)) )
165 return cmd;
166
168 {
169 struct GNUNET_TESTING_Command **batch;
170 const struct GNUNET_TESTING_Command *current;
171 const struct GNUNET_TESTING_Command *icmd;
172 const struct GNUNET_TESTING_Command *match;
173
176 &current));
179 &batch));
180 /* We must do the loop forward, but we can find the last match */
181 match = NULL;
182 for (unsigned int j = 0;
183 NULL != (icmd = &(*batch)[j])->run;
184 j++)
185 {
186 if (current == icmd)
187 break; /* do not go past current command */
188 if ( (NULL != icmd->run) &&
189 (0 == strcmp (icmd->label.value,
190 label)) )
191 match = icmd;
192 }
193 if (NULL != match)
194 return match;
195 }
196 }
198 "Command `%s' not found\n",
199 label);
200 return NULL;
201}
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
static struct GNUNET_TESTING_Interpreter * is
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_cmd(const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_TESTING_Command **ret)
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
A command to be run by the interpreter.
struct GNUNET_TESTING_CommandLabel label
Label for the command.
GNUNET_TESTING_CommandRunRoutine run
Runs the command.
int ip
Instruction pointer.
struct GNUNET_TESTING_Command * commands
Commands the interpreter will run.
bool GNUNET_TESTING_cmd_is_batch_(const struct GNUNET_TESTING_Command *cmd)
Test if this command is a batch command.

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

Referenced by backchannel_check_run(), connect_peers_run(), join_room_run(), netjail_exec_run(), netjail_start_run(), rewind_ip_run(), run_finish(), send_simple_run(), signal_run(), start_peer_run(), start_service_run(), stop_peer_run(), and stop_service_run().

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

◆ GNUNET_TESTING_interpreter_get_command()

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.

Parameters
isinterpreter state.
namename of the variable to get command by
Returns
the command, if it is found, or NULL.

Definition at line 205 of file testing_api_loop.c.

208{
209 const struct GNUNET_TESTING_Command *cmd;
210 struct GNUNET_HashCode h_name;
211
213 strlen (name),
214 &h_name);
216 &h_name);
217 if (NULL == cmd)
219 "Command not found by variable name: %s\n",
220 name);
221 return cmd;
222}
static char * name
Name (label) of the records to list.
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_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.
A 512-bit hashcode.
struct GNUNET_CONTAINER_MultiHashMap * vars
Hash map mapping variable names to commands.

References GNUNET_CONTAINER_multihashmap_get(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, is, name, and GNUNET_TESTING_Interpreter::vars.

Here is the call graph for this function:

◆ send_finished()

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

Definition at line 226 of file testing_api_loop.c.

228{
229 struct SendContext *sctx = cls;
230 struct GNUNET_TESTING_Interpreter *is = sctx->is;
231
235 sctx);
236 GNUNET_free (sctx);
237}
static int result
Global testing status.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_free(ptr)
Wrapper around free.
Global state of the interpreter, used by a command to access information about other commands.
struct SendContext * sender_tail
struct SendContext * sender_head
struct GNUNET_TESTING_Interpreter * is

References GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_OK, is, SendContext::is, result, GNUNET_TESTING_Interpreter::sender_head, and GNUNET_TESTING_Interpreter::sender_tail.

Referenced by GNUNET_TESTING_loop_notify_children_().

Here is the caller graph for this function:

◆ GNUNET_TESTING_loop_notify_children_()

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).

Parameters
isThe interpreter loop.

Definition at line 241 of file testing_api_loop.c.

243{
245 "Send notification to children of type %u\n",
246 (unsigned int) ntohs (hdr->type));
247 for (unsigned int i = 0; i<is->n_helpers; i++)
248 {
249 struct SendContext *sctx;
250
251 sctx = GNUNET_new (struct SendContext);
252 sctx->is = is;
255 sctx);
256 sctx->send_handle
258 hdr,
259 false, /* never drop */
261 sctx);
262 }
263}
#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.
Definition: helper.c:613
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_HELPER_Handle ** helpers
Array with handles of helper processes for communication with netjails.
unsigned int n_helpers
Size of the array helpers.
struct GNUNET_HELPER_SendHandle * send_handle
Handle to a send op.
static void send_finished(void *cls, enum GNUNET_GenericReturnValue result)

References GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_HELPER_send(), GNUNET_log, GNUNET_new, GNUNET_TESTING_Interpreter::helpers, is, SendContext::is, GNUNET_TESTING_Interpreter::n_helpers, send_finished(), SendContext::send_handle, GNUNET_TESTING_Interpreter::sender_head, GNUNET_TESTING_Interpreter::sender_tail, and GNUNET_MessageHeader::type.

Referenced by barrier_reached_run(), handle_helper_barrier_crossable(), and handle_helper_barrier_reached().

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

◆ GNUNET_TESTING_loop_notify_parent_()

void GNUNET_TESTING_loop_notify_parent_ ( struct GNUNET_TESTING_Interpreter is,
const struct GNUNET_MessageHeader hdr 
)

Send message to our parent.

Fails very hard if we do not have one.

Parameters
isThe interpreter loop.

Definition at line 267 of file testing_api_loop.c.

269{
270 /* We must have a parent */
271 if (NULL == is->parent_writer)
273 is->parent_writer (hdr);
274}
#define GNUNET_TESTING_FAIL(is)
Print failing line number and trigger shutdown.
GNUNET_TESTING_cmd_helper_write_cb parent_writer
Function to call to send messages to our parent.

References GNUNET_TESTING_FAIL, is, and GNUNET_TESTING_Interpreter::parent_writer.

Referenced by barrier_reached_run(), and handle_helper_barrier_reached().

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 283 of file testing_api_loop.c.

284{
285 struct GNUNET_TESTING_Interpreter *is = cls;
286 struct GNUNET_TESTING_Command *cmd;
287 const char *label;
288
289 is->finishing = true;
290 is->final_task = NULL;
292 if (NULL == is->commands[is->ip].run)
293 label = "END";
295 "Interpreter finishes at `%s' with status %d\n",
296 label,
297 is->result);
298 for (unsigned int j = 0;
299 NULL != (cmd = &is->commands[j])->run;
300 j++)
301 if (NULL != cmd->cleanup)
302 cmd->cleanup (cmd->cls);
303 if (NULL != is->task)
304 {
306 is->task = NULL;
307 }
308 if (NULL != is->timeout_task)
309 {
311 is->timeout_task = NULL;
312 }
313 {
314 struct SendContext *sctx;
315
316 while (NULL != (sctx = is->sender_head))
317 {
320 sctx);
322 GNUNET_free (sctx);
323 }
324 }
326 is->rc (is->rc_cls,
327 is->skip ? GNUNET_NO : is->result);
328 if (NULL != is->barriers)
329 {
331 is->barriers = NULL;
332 }
333 if (NULL != is->vars)
334 {
336 is->vars = NULL;
337 }
339 GNUNET_free (is);
340}
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
void GNUNET_HELPER_send_cancel(struct GNUNET_HELPER_SendHandle *sh)
Cancel a GNUNET_HELPER_send operation.
Definition: helper.c:653
@ GNUNET_NO
@ 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.
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.
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).
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.

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, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_HELPER_send_cancel(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_TESTING_Interpreter::helpers, 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, SendContext::send_handle, GNUNET_TESTING_Interpreter::sender_head, GNUNET_TESTING_Interpreter::sender_tail, GNUNET_TESTING_Interpreter::skip, GNUNET_TESTING_Interpreter::task, GNUNET_TESTING_Interpreter::timeout_task, GNUNET_TESTING_CommandLabel::value, and GNUNET_TESTING_Interpreter::vars.

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 442 of file testing_api_loop.c.

443{
444 struct GNUNET_TESTING_Interpreter *is = cls;
445 struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
446
447 is->task = NULL;
448 if (NULL == cmd->run)
449 {
451 "Running command END\n");
453 finish_test (is);
454 return;
455 }
457 "Running command `%s'\n",
458 cmd->label.value);
460 cmd);
461}
void GNUNET_TESTING_interpreter_run_cmd_(struct GNUNET_TESTING_Interpreter *is, struct GNUNET_TESTING_Command *cmd)
static void finish_test(void *cls)
Finish the test run, return the final result.

References GNUNET_TESTING_Interpreter::commands, finish_test(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_OK, GNUNET_TESTING_interpreter_run_cmd_(), GNUNET_TESTING_Interpreter::ip, is, GNUNET_TESTING_Command::label, GNUNET_TESTING_Interpreter::result, GNUNET_TESTING_Command::run, GNUNET_TESTING_Interpreter::task, and GNUNET_TESTING_CommandLabel::value.

Referenced by GNUNET_TESTING_interpreter_next_(), and setup_is().

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

◆ GNUNET_TESTING_interpreter_next_()

void GNUNET_TESTING_interpreter_next_ ( void *  cls)

Current command is done, run the next one.

Definition at line 353 of file testing_api_loop.c.

354{
355 static unsigned long long ipc;
356 static struct GNUNET_TIME_Absolute last_report;
357 struct GNUNET_TESTING_Interpreter *is = cls;
358 struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
359
360 if (GNUNET_SYSERR == is->result)
361 return; /* ignore, we already failed! */
362
364 {
366 {
367 /* batch is done */
369 is->ip++;
370 }
371 }
372 else
373 {
375 is->ip++;
376 }
377
378 if (0 == (ipc % 1000))
379 {
380 if (0 != ipc)
382 "Interpreter executed 1000 instructions in %s\n",
385 true));
386 last_report = GNUNET_TIME_absolute_get ();
387 }
388 ipc++;
390 is);
391}
@ 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 GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
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(), interpreter_run(), GNUNET_TESTING_Interpreter::ip, is, GNUNET_TESTING_Interpreter::result, and GNUNET_TESTING_Interpreter::task.

Referenced by batch_run(), GNUNET_TESTING_async_finish(), and GNUNET_TESTING_interpreter_run_cmd_().

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

◆ GNUNET_TESTING_interpreter_run_cmd_()

void GNUNET_TESTING_interpreter_run_cmd_ ( struct GNUNET_TESTING_Interpreter is,
struct GNUNET_TESTING_Command cmd 
)

Definition at line 395 of file testing_api_loop.c.

398{
399 cmd->last_req_time
401 if (0 == cmd->num_tries)
402 cmd->start_time = cmd->last_req_time;
403 cmd->num_tries = 1;
404 if (NULL != cmd->name)
405 {
406 struct GNUNET_HashCode h_name;
407
409 strlen (cmd->name),
410 &h_name);
412 is->vars,
413 &h_name,
414 cmd,
416 }
417 if (NULL != cmd->ac)
418 {
419 cmd->ac->is = is;
420 cmd->ac->finished = GNUNET_NO;
421 cmd->ac->next_called = false;
422 }
423 cmd->run (cmd->cls,
424 is);
425 if ( (! GNUNET_TESTING_cmd_is_batch_ (cmd)) &&
426 ( (NULL == cmd->ac) ||
427 (cmd->asynchronous_finish) ) )
428 {
429 if (NULL != cmd->ac)
430 cmd->ac->next_called = true;
432 }
433}
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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE
If a value with the given key exists, replace it.
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).
const char * name
Variable name for the command, NULL for none.
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 ...
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 GNUNET_TESTING_interpreter_next_(void *cls)
Current command is done, run the next one.

References GNUNET_TESTING_Command::ac, GNUNET_TESTING_Command::asynchronous_finish, GNUNET_TESTING_Command::cls, GNUNET_TESTING_AsyncContext::finished, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE, GNUNET_CRYPTO_hash(), GNUNET_NO, GNUNET_TESTING_cmd_is_batch_(), GNUNET_TESTING_interpreter_next_(), GNUNET_TIME_absolute_get(), GNUNET_TESTING_AsyncContext::is, is, GNUNET_TESTING_Command::last_req_time, GNUNET_TESTING_Command::name, GNUNET_TESTING_AsyncContext::next_called, GNUNET_TESTING_Command::num_tries, GNUNET_TESTING_Command::run, GNUNET_TESTING_Command::start_time, and GNUNET_TESTING_Interpreter::vars.

Referenced by batch_run(), and 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 465 of file testing_api_loop.c.

466{
467 struct GNUNET_TESTING_Command *cmd
468 = &is->commands[is->ip];
469
470 if (GNUNET_SYSERR == is->result)
471 {
472 GNUNET_break (0);
473 return; /* ignore, we already failed! */
474 }
475 if (NULL == cmd)
476 {
478 "Failed with CMD being NULL!\n");
479 }
480 else
481 {
482 const struct GNUNET_TESTING_Command *pos = cmd;
483
485 "Failed during command `%s'\n",
486 cmd->label.value);
487 while (GNUNET_TESTING_cmd_is_batch_ (pos))
488 {
491 &pos));
493 "Failed in batch during command `%s'\n",
494 pos->label.value);
495 }
496 }
497 if (NULL != is->timeout_task)
498 {
500 is->timeout_task = NULL;
501 }
503 GNUNET_assert (NULL == is->final_task);
505 is);
506}

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

Referenced by connect_peers_run(), do_shutdown(), GNUNET_TESTING_async_fail(), GNUNET_TESTING_interpreter_skip(), join_room_run(), on_message_cb(), rewind_ip_run(), seek_batch(), 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_interpreter_skip()

void GNUNET_TESTING_interpreter_skip ( struct GNUNET_TESTING_Interpreter is)

Skips the current test, the environment is not prepared correctly.

Parameters
isinterpreter state.

Definition at line 510 of file testing_api_loop.c.

512{
513 is->skip = true;
515}
void GNUNET_TESTING_interpreter_fail(struct GNUNET_TESTING_Interpreter *is)
Current command failed, clean up and fail the test case.

References GNUNET_TESTING_interpreter_fail(), is, and GNUNET_TESTING_Interpreter::skip.

Referenced by netjail_start_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 519 of file testing_api_loop.c.

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

Referenced by barrier_reached_run(), child_completed_callback(), conn_status(), exp_cb(), handle_helper_barrier_reached(), handle_helper_local_finished(), helper_mst(), stop_cb(), 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->notify_finished)
533 {
535 ac->notify_finished = NULL;
536 }
537 if (! ac->next_called)
538 {
539 ac->next_called = true;
541 }
542}
GNUNET_SCHEDULER_TaskCallback notify_finished
Function to call when async operation is done.
void * notify_finished_cls
Closure for notify_finished.

References GNUNET_TESTING_Command::ac, GNUNET_TESTING_AsyncContext::finished, GNUNET_assert, GNUNET_NO, GNUNET_OK, GNUNET_TESTING_interpreter_next_(), GNUNET_TESTING_AsyncContext::is, GNUNET_TESTING_AsyncContext::next_called, GNUNET_TESTING_AsyncContext::notify_finished, and GNUNET_TESTING_AsyncContext::notify_finished_cls.

Referenced by backchannel_check_run(), barrier_reached_run(), child_completed_callback(), conn_status(), do_timeout(), done_finish(), handle_helper_barrier_crossable(), handle_helper_barrier_reached(), handle_helper_local_finished(), hello_iter_cb(), notify_connect(), read_from_log(), run_finish(), send_run(), send_simple_single(), and stop_cb().

Here is the call graph for this function:
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 551 of file testing_api_loop.c.

552{
553 struct GNUNET_TESTING_Interpreter *is = cls;
554
555 is->timeout_task = NULL;
557 "Terminating test due to global timeout\n");
559 finish_test (is);
560}

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:

◆ setup_is()

static void setup_is ( struct GNUNET_TESTING_Interpreter is,
const struct GNUNET_TESTING_Command bcommand,
const struct GNUNET_TESTING_Command commands 
)
static

Definition at line 564 of file testing_api_loop.c.

567{
568 unsigned int i;
569
571 false);
572 /* get the number of commands */
573 for (i = 0; NULL != commands[i].run; i++)
574 ;
575 if (NULL != bcommand)
576 i++;
577 is->cmds_n = i + 1;
579 "Got %u commands\n",
580 i);
582 (i + 1)
583 * sizeof (struct GNUNET_TESTING_Command));
584 GNUNET_assert (NULL != is->commands);
585 if (NULL == bcommand)
586 {
587 memcpy (is->commands,
588 commands,
589 sizeof (struct GNUNET_TESTING_Command) * i);
590 }
591 else
592 {
593 is->commands[0] = *bcommand;
594 memcpy (&is->commands[1],
595 commands,
596 sizeof (struct GNUNET_TESTING_Command) * i);
597 }
599 is);
600}
static struct VoipCommand commands[]
List of supported commands.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
#define GNUNET_malloc_large(size)
Wrapper around malloc.
unsigned int cmds_n
Number of GNUNET_TESTING_Command in commands.

References GNUNET_TESTING_Interpreter::cmds_n, commands, GNUNET_TESTING_Interpreter::commands, GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_malloc_large, GNUNET_SCHEDULER_add_now(), interpreter_run(), is, GNUNET_TESTING_Interpreter::task, and GNUNET_TESTING_Interpreter::vars.

Referenced by GNUNET_TESTING_run(), and start_testcase().

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 604 of file testing_api_loop.c.

608{
610
614 &do_timeout,
615 is);
616 is->rc = rc;
617 is->rc_cls = rc_cls;
618 setup_is (is,
619 NULL,
620 commands);
621 return is;
622}
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:119
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 setup_is(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_TESTING_Command *bcommand, const struct GNUNET_TESTING_Command *commands)
static void do_timeout(void *cls)
Function run when the test terminates (good or bad) with timeout.

References commands, do_timeout(), GNUNET_new, GNUNET_SCHEDULER_add_delayed(), is, GNUNET_TESTING_Interpreter::rc, GNUNET_TESTING_Interpreter::rc_cls, setup_is(), 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:

◆ start_testcase()

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 
)
static

Definition at line 626 of file testing_api_loop.c.

634{
635 const struct GNUNET_TESTING_Command *commands = cls;
637
639 if (0 != inherited_barrier_count)
640 {
641 is->barriers
642 = GNUNET_CONTAINER_multishortmap_create (inherited_barrier_count * 4 / 3,
643 true);
644 for (unsigned int j = 0; j<inherited_barrier_count; j++)
645 {
646 struct GNUNET_TESTING_Barrier *barrier;
647
648 barrier = GNUNET_new (struct GNUNET_TESTING_Barrier);
649 barrier->barrier_id = inherited_barriers[j];
650 barrier->inherited = true;
652 is->barriers,
653 &barrier->barrier_id,
654 barrier,
656 }
657 }
658 is->parent_writer = parent_writer;
659 is->rc = finish_cb;
660 is->rc_cls = finish_cb_cls;
661 {
662 struct GNUNET_TESTING_Command bcmd;
663
665 "topology",
667 "_boot_",
668 topology_data));
669 setup_is (is,
670 &bcmd,
671 commands);
672 }
673 return is;
674
675}
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_load_topology_from_string(const char *label, const char *topology_data)
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.
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.
An entry for a barrier list.
bool inherited
Did we inherit the barrier from our parent loop?
struct GNUNET_ShortHashCode barrier_id

References GNUNET_TESTING_Barrier::barrier_id, GNUNET_TESTING_Interpreter::barriers, GNUNET_TESTING_Command::cls, commands, GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE, GNUNET_CONTAINER_multishortmap_create(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_new, GNUNET_TESTING_cmd_load_topology_from_string(), GNUNET_TESTING_cmd_set_var(), GNUNET_TESTING_Barrier::inherited, is, GNUNET_TESTING_Interpreter::parent_writer, GNUNET_TESTING_Interpreter::rc, GNUNET_TESTING_Interpreter::rc_cls, and setup_is().

Referenced by GNUNET_TESTING_make_plugin().

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

◆ GNUNET_TESTING_make_plugin()

struct GNUNET_TESTING_PluginFunctions * GNUNET_TESTING_make_plugin ( const struct GNUNET_TESTING_Command commands)

Definition at line 679 of file testing_api_loop.c.

681{
683 struct GNUNET_TESTING_Command *commands_copy;
684 unsigned int i;
685
686 for (i = 0; NULL != commands[i].run; i++)
687 ;
688 commands_copy = GNUNET_malloc_large ( (i + 1)
689 * sizeof (struct
691 memcpy (commands_copy,
692 commands,
693 sizeof (struct GNUNET_TESTING_Command) * i + 1);
694
696 api->cls = (void *) commands_copy;
698 return api;
699}
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.
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)

References GNUNET_TESTING_PluginFunctions::cls, commands, GNUNET_malloc_large, GNUNET_new, start_testcase(), and GNUNET_TESTING_PluginFunctions::start_testcase.

Here is the call graph for this function:

◆ GNUNET_TESTING_add_netjail_helper_()

void GNUNET_TESTING_add_netjail_helper_ ( struct GNUNET_TESTING_Interpreter is,
struct GNUNET_HELPER_Handle helper 
)

Adding a helper handle to the interpreter.

Parameters
isThe interpreter.
helperThe helper handle.

Definition at line 703 of file testing_api_loop.c.

705{
707 is->n_helpers,
708 helper);
709}
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).

References GNUNET_array_append, GNUNET_TESTING_Interpreter::helpers, is, and GNUNET_TESTING_Interpreter::n_helpers.

Referenced by start_helper().

Here is the caller graph for this function:

◆ GNUNET_TESTING_get_barrier2_()

struct GNUNET_TESTING_Barrier * GNUNET_TESTING_get_barrier2_ ( struct GNUNET_TESTING_Interpreter is,
const struct GNUNET_ShortHashCode create_key 
)

Definition at line 713 of file testing_api_loop.c.

715{
717 create_key);
718}
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.

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

Referenced by GNUNET_TESTING_get_barrier_(), handle_helper_barrier_crossable(), and handle_helper_barrier_reached().

Here is the call graph for this function:
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 
)

Definition at line 722 of file testing_api_loop.c.

724{
725 struct GNUNET_ShortHashCode create_key;
726
727 if (NULL == is->barriers)
728 return NULL;
730 &create_key);
732 &create_key);
733}
A 256-bit hashcode.
void GNUNET_TESTING_barrier_name_hash_(const char *barrier_name, struct GNUNET_ShortHashCode *bkey)
struct GNUNET_TESTING_Barrier * GNUNET_TESTING_get_barrier2_(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_ShortHashCode *create_key)

References GNUNET_TESTING_Interpreter::barriers, GNUNET_TESTING_barrier_name_hash_(), GNUNET_TESTING_get_barrier2_(), and is.

Referenced by barrier_reached_run().

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 to share it with all children as an inherited barrier.

Parameters
isThe interpreter.
barrierThe barrier to add.

Definition at line 737 of file testing_api_loop.c.

739{
740 if (NULL == is->barriers)
741 is->barriers
743 true);
744 /* We always use the barrier we encountered
745 most recently under a given label, thus replace */
747 is->barriers,
748 &barrier->barrier_id,
749 barrier,
751}

References GNUNET_TESTING_Barrier::barrier_id, GNUNET_TESTING_Interpreter::barriers, GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE, GNUNET_CONTAINER_multishortmap_create(), GNUNET_CONTAINER_multishortmap_put(), and is.

Referenced by barrier_run().

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

◆ GNUNET_TESTING_barrier_count_()

unsigned int GNUNET_TESTING_barrier_count_ ( struct GNUNET_TESTING_Interpreter is)

Definition at line 755 of file testing_api_loop.c.

757{
759}
unsigned int GNUNET_CONTAINER_multishortmap_size(const struct GNUNET_CONTAINER_MultiShortmap *map)
Get the number of key-value pairs in the map.

References GNUNET_TESTING_Interpreter::barriers, GNUNET_CONTAINER_multishortmap_size(), and is.

Referenced by send_start_messages().

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

◆ GNUNET_TESTING_barrier_iterate_()

void GNUNET_TESTING_barrier_iterate_ ( struct GNUNET_TESTING_Interpreter is,
GNUNET_CONTAINER_ShortmapIterator  cb,
void *  cb_cls 
)

Definition at line 763 of file testing_api_loop.c.

767{
768 if (NULL != is->barriers)
770 cb,
771 cb_cls);
772}
int GNUNET_CONTAINER_multishortmap_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.

References GNUNET_TESTING_Interpreter::barriers, GNUNET_CONTAINER_multishortmap_iterate(), and is.

Referenced by send_start_messages().

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

◆ GNUNET_TESTING_interpreter_commands_iterate()

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.

Parameters
[in]isinterpreter to iterate over
asctrue in execution order, false for reverse execution order
cbfunction to call on each command
cb_clsclosure for cb

Definition at line 776 of file testing_api_loop.c.

781{
782 unsigned int start;
783 unsigned int end;
784 int inc;
785
786 if (asc)
787 {
788 inc = 1;
789 start = 0;
790 end = is->ip;
791 }
792 else
793 {
794 inc = -1;
795 start = is->ip;
796 end = 0;
797 }
798 for (unsigned int off = start; off != end + inc; off += inc)
799 {
800 const struct GNUNET_TESTING_Command *cmd
801 = &is->commands[off];
802
803 cb (cb_cls,
804 cmd);
805 }
806}
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34

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

Referenced by stat_run().

Here is the caller graph for this function:

◆ GNUNET_TESTING_interpreter_current_cmd_touch()

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.

Parameters
[in,out]isinterpreter state where to show that we are doing something

Definition at line 810 of file testing_api_loop.c.

812{
815}

References GNUNET_TESTING_Interpreter::commands, GNUNET_TIME_absolute_get(), GNUNET_TESTING_Interpreter::ip, is, and GNUNET_TESTING_Command::last_req_time.

Here is the call graph for this function:

◆ GNUNET_TESTING_interpreter_current_cmd_inc_tries()

void GNUNET_TESTING_interpreter_current_cmd_inc_tries ( struct GNUNET_TESTING_Interpreter is)

Increment the 'num_tries' counter for the current command.

Parameters
[in,out]isinterpreter state where to increment the counter

Definition at line 819 of file testing_api_loop.c.

821{
823}

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

◆ GNUNET_TESTING_interpreter_current_cmd_get_label()

const char * GNUNET_TESTING_interpreter_current_cmd_get_label ( struct GNUNET_TESTING_Interpreter is)

Obtain label of the command being now run.

Parameters
isinterpreter state.
Returns
the label.

Definition at line 827 of file testing_api_loop.c.

829{
830 return is->commands[is->ip].label.value;
831}

References GNUNET_TESTING_Interpreter::commands, GNUNET_TESTING_Interpreter::ip, is, GNUNET_TESTING_Command::label, and GNUNET_TESTING_CommandLabel::value.

◆ seek_batch()

static enum GNUNET_GenericReturnValue seek_batch ( struct GNUNET_TESTING_Interpreter is,
const struct GNUNET_TESTING_Command cmd,
const struct GNUNET_TESTING_Command target 
)
static

Seek for the target command in batch (and rewind to it if successful).

Parameters
isthe interpreter state (for failures)
cmdbatch to search for target
targetcommand to search for
Returns
GNUNET_OK on success, GNUNET_NO if target was not found, GNUNET_SYSERR if target is in the future and we failed

Definition at line 864 of file testing_api_loop.c.

867{
868 unsigned int new_ip;
869 struct GNUNET_TESTING_Command **batch;
870 const struct GNUNET_TESTING_Command *current;
871 const struct GNUNET_TESTING_Command *icmd;
872 bool found = false;
873
876 &current));
879 &batch));
880 for (new_ip = 0;
881 NULL != (icmd = &((*batch)[new_ip]))->run;
882 new_ip++)
883 {
884 if (current == target)
885 current = NULL;
886 if (icmd == target)
887 {
888 found = true;
889 break;
890 }
892 {
894 = seek_batch (is,
895 icmd,
896 target);
897 if (GNUNET_SYSERR == ret)
898 return GNUNET_SYSERR; /* failure! */
899 if (GNUNET_OK == ret)
900 {
901 found = true;
902 break;
903 }
904 }
905 }
906 if (! found)
907 return GNUNET_NO; /* not found */
908 if (NULL == current)
909 {
910 /* refuse to jump forward */
911 GNUNET_break (0);
913 return GNUNET_SYSERR;
914 }
916 new_ip);
917 return GNUNET_OK;
918}
static int ret
Final status code.
Definition: gnunet-arm.c:94
GNUNET_GenericReturnValue
Named constants for return values.
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.
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).

References GNUNET_assert, GNUNET_break, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTING_cmd_batch_set_current_(), GNUNET_TESTING_cmd_is_batch_(), GNUNET_TESTING_get_trait_batch_cmds(), GNUNET_TESTING_get_trait_cmd(), GNUNET_TESTING_interpreter_fail(), is, ret, and seek_batch().

Referenced by rewind_ip_run(), and seek_batch().

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

◆ rewind_ip_run()

static void rewind_ip_run ( void *  cls,
struct GNUNET_TESTING_Interpreter is 
)
static

Run the "rewind" CMD.

Parameters
clsclosure.
cmdcommand being executed now.
isthe interpreter state.

Definition at line 929 of file testing_api_loop.c.

931{
932 struct RewindIpState *ris = cls;
933 const struct GNUNET_TESTING_Command *target;
934 const struct GNUNET_TESTING_Command *icmd;
935 unsigned int new_ip;
936 bool found = false;
937
938 if (0 == ris->counter)
939 return;
940 target
942 ris->target_label);
943 if (NULL == target)
944 {
945 GNUNET_break (0);
947 return;
948 }
949 ris->counter--;
950 for (new_ip = 0;
951 NULL != (icmd = &is->commands[new_ip])->run;
952 new_ip++)
953 {
954 if (icmd == target)
955 {
956 found = true;
957 break;
958 }
960 {
962 = seek_batch (is,
963 icmd,
964 target);
965 if (GNUNET_SYSERR == ret)
966 {
967 /* failure! */
968 GNUNET_break (0);
970 return;
971 }
972 if (GNUNET_OK == ret)
973 {
974 /* counter subtraction below for batch */
975 found = true;
976 break;
977 }
978 }
979 }
980 if (! found)
981 {
982 GNUNET_break (0);
984 return;
985 }
986 if (new_ip > (unsigned int) is->ip)
987 {
988 /* refuse to jump forward */
989 GNUNET_break (0);
991 return;
992 }
993 is->ip = new_ip;
994}
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.
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command(struct GNUNET_TESTING_Interpreter *is, const char *label)
Lookup command by label.

References GNUNET_TESTING_Interpreter::commands, RewindIpState::counter, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTING_cmd_is_batch_(), GNUNET_TESTING_interpreter_fail(), GNUNET_TESTING_interpreter_lookup_command(), GNUNET_TESTING_Interpreter::ip, is, ret, run(), seek_batch(), and RewindIpState::target_label.

Referenced by GNUNET_TESTING_cmd_rewind_ip().

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

◆ rewind_ip_free()

static void rewind_ip_free ( void *  cls)
static

Definition at line 998 of file testing_api_loop.c.

999{
1000 struct RewindIpState *ris = cls;
1001
1002 GNUNET_free (ris);
1003}

References GNUNET_free.

Referenced by GNUNET_TESTING_cmd_rewind_ip().

Here is the caller graph for this function:

◆ GNUNET_TESTING_cmd_rewind_ip()

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.

Note that the command that will be executed next in this case is the one AFTER target_label, as the command we jump to is skipped by the advancing IP after the rewind.

Parameters
labelcommand label
target_labellabel of the new instruction pointer's destination after the jump; must be before the current instruction (and the command at the target_label itself will not be run, but the one afterwards)
countercounts how many times the rewinding is to happen.

Definition at line 1007 of file testing_api_loop.c.

1010{
1011 struct RewindIpState *ris;
1012
1013 ris = GNUNET_new (struct RewindIpState);
1015 ris->counter = counter;
1016 return GNUNET_TESTING_command_new (ris,
1017 label,
1020 NULL);
1021}
#define GNUNET_TESTING_command_new(cls, label, run, cleanup, traits)
Create a new command.
static void rewind_ip_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
Run the "rewind" CMD.
static void rewind_ip_free(void *cls)

References RewindIpState::counter, GNUNET_new, GNUNET_TESTING_command_new, rewind_ip_free(), rewind_ip_run(), and RewindIpState::target_label.

Here is the call graph for this function: