GNUnet  0.17.6
Functions
testing.h File Reference
#include "gnunet_util_lib.h"
Include dependency graph for testing.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool GNUNET_TESTING_cmd_batch_next_ (void *cls)
 Advance internal pointer to next command. More...
 
bool GNUNET_TESTING_cmd_is_batch_ (const struct GNUNET_TESTING_Command *cmd)
 Test if this command is a batch command. More...
 
struct GNUNET_TESTING_CommandGNUNET_TESTING_cmd_batch_get_current_ (const struct GNUNET_TESTING_Command *cmd)
 Obtain what command the batch is at. More...
 
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. More...
 

Function Documentation

◆ GNUNET_TESTING_cmd_batch_next_()

bool GNUNET_TESTING_cmd_batch_next_ ( void *  cls)

Advance internal pointer to next command.

Author
t3sserakt
Parameters
clsbatch internal state
Returns
true if we could advance, false if the batch has completed and cannot advance anymore

Definition at line 188 of file testing_api_cmd_batch.c.

189 {
190  struct BatchState *bs = cls;
191 
192  if (NULL == bs->batch[bs->batch_ip].label)
193  return false;
194  bs->batch[bs->batch_ip].finish_time
196  bs->batch_ip++;
197  return true;
198 }
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:110
State for a "batch" CMD.
unsigned int batch_ip
Internal command pointer.
struct GNUNET_TESTING_Command * batch
CMDs batch.
struct GNUNET_TIME_Absolute finish_time
When did the execution of this command finish?
const char * label
Label for the command.

References BatchState::batch, BatchState::batch_ip, GNUNET_TESTING_Command::finish_time, GNUNET_TIME_absolute_get(), and GNUNET_TESTING_Command::label.

Referenced by interpreter_next().

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

◆ GNUNET_TESTING_cmd_is_batch_()

bool GNUNET_TESTING_cmd_is_batch_ ( const struct GNUNET_TESTING_Command cmd)

Test if this command is a batch command.

Returns
false if not, true if it is a batch command

Definition at line 202 of file testing_api_cmd_batch.c.

203 {
204  return cmd->run == &batch_run;
205 }
void(* run)(void *cls, struct GNUNET_TESTING_Interpreter *is)
Runs the command.
static void batch_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
Run the command.

References batch_run(), and GNUNET_TESTING_Command::run.

Referenced by get_command(), GNUNET_TESTING_cmd_batch_get_current_(), GNUNET_TESTING_cmd_batch_set_current_(), GNUNET_TESTING_interpreter_fail(), and interpreter_next().

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

◆ GNUNET_TESTING_cmd_batch_get_current_()

struct GNUNET_TESTING_Command* GNUNET_TESTING_cmd_batch_get_current_ ( const struct GNUNET_TESTING_Command cmd)

Obtain what command the batch is at.

Returns
cmd current batch command

Definition at line 209 of file testing_api_cmd_batch.c.

210 {
211  struct BatchState *bs = cmd->cls;
212 
214  return &bs->batch[bs->batch_ip];
215 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void * cls
Closure for all commands with command-specific context information.
bool GNUNET_TESTING_cmd_is_batch_(const struct GNUNET_TESTING_Command *cmd)
Test if this command is a batch command.

References BatchState::batch, BatchState::batch_ip, GNUNET_TESTING_Command::cls, GNUNET_assert, and GNUNET_TESTING_cmd_is_batch_().

Referenced by get_command(), and GNUNET_TESTING_interpreter_fail().

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

◆ GNUNET_TESTING_cmd_batch_set_current_()

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.

Needed for loops. We may want to change this to take a label and/or expose it in the public API in the future. Not used for now.

Parameters
cmdcurrent batch command
new_ipwhere to move the IP

Definition at line 219 of file testing_api_cmd_batch.c.

221 {
222  struct BatchState *bs = cmd->cls;
223 
224  /* sanity checks */
226  for (unsigned int i = 0; i < new_ip; i++)
227  GNUNET_assert (NULL != bs->batch[i].label);
228  /* actual logic */
229  bs->batch_ip = new_ip;
230 }

References BatchState::batch, BatchState::batch_ip, GNUNET_TESTING_Command::cls, GNUNET_assert, GNUNET_TESTING_cmd_is_batch_(), and GNUNET_TESTING_Command::label.

Here is the call graph for this function: