GNUnet debian-0.24.3-28-g4f2a77692
 
Loading...
Searching...
No Matches
gnunet_testing_core_lib.h File Reference
Include dependency graph for gnunet_testing_core_lib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GNUNET_TESTING_ConnectPeersState
 Struct to store information needed in callbacks. More...
 
struct  GNUNET_TESTING_CORE_Channel
 
struct  GNUNET_TESTING_CORE_Message
 
struct  GNUNET_TESTING_CORE_ConnectCb
 
struct  GNUNET_TESTING_CORE_ConnectState
 

Macros

#define MTYPE   12345
 API for cmds working with core sub system provided by libgnunetcoretesting.
 
#define NODE_ID_LEN   16
 
#define GNUNET_CORE_TESTING_SIMPLE_TRAITS(op, prefix)
 Call op on all simple traits.
 

Typedefs

typedef void *(* GNUNET_TESTING_CORE_connect_cb) (void *cls, const struct GNUNET_PeerIdentity *peer_id, struct GNUNET_MQ_Handle *mq)
 
typedef void(* GNUNET_TESTING_CORE_handle_msg) (void *cls, struct GNUNET_TESTING_CORE_Channel *channel, const struct GNUNET_TESTING_CORE_Message *msg)
 

Functions

struct GNUNET_TESTING_Command GNUNET_CORE_cmd_connect_peers (const char *label, const char *start_peer_label, const char *create_label, uint32_t num, struct GNUNET_TESTING_NetjailTopology *topology, unsigned int additional_connects, unsigned int wait_for_connect, struct GNUNET_MQ_MessageHandler *handlers)
 FIXME: document properly! Create command.
 
const struct GNUNET_TESTING_Command GNUNET_TESTING_CORE_cmd_connect (const char *label, const char *node_id, char *arm_service_label)
 
const struct GNUNET_TESTING_Command GNUNET_TESTING_CORE_cmd_recv (const char *label, uint64_t num_messages)
 
const struct GNUNET_TESTING_Command GNUNET_TESTING_CORE_cmd_send (const char *label, uint64_t num_messages, enum GNUNET_GenericReturnValue await_new_connection)
 
enum GNUNET_GenericReturnValue GNUNET_CORE_TESTING_get_trait_connect_peer_state (const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_TESTING_ConnectPeersState **ret)
 
struct GNUNET_TESTING_Trait GNUNET_CORE_TESTING_make_trait_connect_peer_state (const struct GNUNET_TESTING_ConnectPeersState *value)
 
enum GNUNET_GenericReturnValue GNUNET_CORE_TESTING_get_trait_connect (const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_TESTING_CORE_ConnectState **ret)
 
struct GNUNET_TESTING_Trait GNUNET_CORE_TESTING_make_trait_connect (const struct GNUNET_TESTING_CORE_ConnectState *value)
 

Macro Definition Documentation

◆ MTYPE

#define MTYPE   12345

API for cmds working with core sub system provided by libgnunetcoretesting.

Author
t3sserakt

Definition at line 33 of file gnunet_testing_core_lib.h.

◆ NODE_ID_LEN

#define NODE_ID_LEN   16

Definition at line 35 of file gnunet_testing_core_lib.h.

◆ GNUNET_CORE_TESTING_SIMPLE_TRAITS

#define GNUNET_CORE_TESTING_SIMPLE_TRAITS (   op,
  prefix 
)
Value:
op (prefix, connect_peer_state, const struct \
op (prefix, connect, const struct \
static struct GNUNET_ARM_Operation * op
Current operation.
Definition gnunet-arm.c:143
static int prefix
If printing the value of PREFIX has been requested.
Struct to store information needed in callbacks.

Call op on all simple traits.

Definition at line 250 of file gnunet_testing_core_lib.h.

Typedef Documentation

◆ GNUNET_TESTING_CORE_connect_cb

typedef void *(* GNUNET_TESTING_CORE_connect_cb) (void *cls, const struct GNUNET_PeerIdentity *peer_id, struct GNUNET_MQ_Handle *mq)

Definition at line 153 of file gnunet_testing_core_lib.h.

◆ GNUNET_TESTING_CORE_handle_msg

typedef void(* GNUNET_TESTING_CORE_handle_msg) (void *cls, struct GNUNET_TESTING_CORE_Channel *channel, const struct GNUNET_TESTING_CORE_Message *msg)

Definition at line 167 of file gnunet_testing_core_lib.h.

Function Documentation

◆ GNUNET_CORE_cmd_connect_peers()

struct GNUNET_TESTING_Command GNUNET_CORE_cmd_connect_peers ( const char *  label,
const char *  start_peer_label,
const char *  create_label,
uint32_t  num,
struct GNUNET_TESTING_NetjailTopology topology,
unsigned int  additional_connects,
unsigned int  wait_for_connect,
struct GNUNET_MQ_MessageHandler handlers 
)

FIXME: document properly! Create command.

Parameters
labelname for command
start_peer_labelLabel of the cmd to start a peer.
create_labelLabel of the cmd which started the test system.
numNumber globally identifying the node.
topologyThe topology for the test setup.
additional_connectsNumber of additional connects this cmd will wait for not triggered by this cmd.
Returns
command.

Definition at line 212 of file testing_core_cmd_connecting_peers.c.

221{
223 unsigned int node_additional_connects;
224 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
226 unsigned int i;
227
228 node_additional_connects = GNUNET_TESTING_get_additional_connects (num,
229 topology);
230
232 "global: %u and local: %u additional_connects\n",
233 additional_connects,
234 node_additional_connects);
235
236 if (0 != node_additional_connects)
237 additional_connects = node_additional_connects;
238
240 cps->start_peer_label = start_peer_label;
241 cps->num = num;
242 cps->create_label = create_label;
243 cps->topology = topology;
244 cps->additional_connects = additional_connects;
245 cps->wait_for_connect = wait_for_connect;
246 cps->connected_peers_map = connected_peers_map;
247
248 if (NULL != handlers)
249 {
250 for (i = 0; NULL != handlers[i].cb; i++)
251 ;
252 cps->handlers = GNUNET_new_array (i + 1,
255 handlers,
256 i * sizeof(struct GNUNET_MQ_MessageHandler));
257 }
258 // FIXME: wrap with cmd_make_unblocking!
259 if (GNUNET_YES == wait_for_connect)
261 label,
265 &cps->ac);
266 else
267 return GNUNET_TESTING_command_new (cps,
268 label,
272}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition 003.c:1
struct GNUNET_TESTING_Command GNUNET_TESTING_command_new_ac(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 that may be asynchronous.
#define GNUNET_TESTING_command_new(cls, label, run, cleanup, traits)
Create a new 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).
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
Internal representation of the hash map.
Message handler for a specific message type.
uint32_t num
Number globally identifying the node.
unsigned int additional_connects
Number of additional connects this cmd will wait for not triggered by this cmd.
unsigned int wait_for_connect
Flag indicating, whether the command is waiting for peers to connect that are configured to connect.
struct GNUNET_CONTAINER_MultiShortmap * connected_peers_map
A map with struct GNUNET_MQ_Handle values for each peer this peer is connected to.
struct GNUNET_MQ_MessageHandler * handlers
Receive callback.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
const char * start_peer_label
Label of the cmd to start a peer.
struct GNUNET_TESTING_NetjailTopology * topology
The topology of the test setup.
unsigned int GNUNET_TESTING_get_additional_connects(unsigned int num, struct GNUNET_TESTING_NetjailTopology *topology)
Get the number of unintentional additional connections the node waits for.
static void connect_peers_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will connect to peers.
#define LOG(kind,...)
Generic logging shortcut.
static void connect_peers_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.
enum GNUNET_GenericReturnValue connect_peers_traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.

References GNUNET_TESTING_ConnectPeersState::ac, GNUNET_TESTING_ConnectPeersState::additional_connects, connect_peers_cleanup(), connect_peers_run(), connect_peers_traits(), GNUNET_TESTING_ConnectPeersState::connected_peers_map, GNUNET_TESTING_ConnectPeersState::create_label, GNUNET_CONTAINER_multishortmap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcpy, GNUNET_new, GNUNET_new_array, GNUNET_NO, GNUNET_TESTING_command_new, GNUNET_TESTING_command_new_ac(), GNUNET_TESTING_get_additional_connects(), GNUNET_YES, handlers, GNUNET_TESTING_ConnectPeersState::handlers, LOG, GNUNET_TESTING_ConnectPeersState::num, GNUNET_TESTING_ConnectPeersState::start_peer_label, GNUNET_TESTING_ConnectPeersState::topology, and GNUNET_TESTING_ConnectPeersState::wait_for_connect.

Here is the call graph for this function:

◆ GNUNET_TESTING_CORE_cmd_connect()

const struct GNUNET_TESTING_Command GNUNET_TESTING_CORE_cmd_connect ( const char *  label,
const char *  node_id,
char *  arm_service_label 
)

Definition at line 297 of file testing_core_cmd_connect.c.

301{
302 struct GNUNET_TESTING_CORE_ConnectState *connect_state;
303
304 // TODO get handler from caller to call on new connections
305
306 connect_state = GNUNET_new (struct GNUNET_TESTING_CORE_ConnectState);
307 connect_state->node_id = GNUNET_strdup (node_id);
309 connect_state->recv_handlers_len = 0;
310 connect_state->recv_handlers =
311 GNUNET_new_array (connect_state->recv_handlers_len,
313 connect_state->connect_cbs_len = 0;
314 connect_state->connect_cbs =
315 GNUNET_new_array (connect_state->connect_cbs_len,
317 connect_state->finished = GNUNET_NO;
318 LOG (GNUNET_ERROR_TYPE_DEBUG, "(Setting up _cmd_connect)\n");
319 return GNUNET_TESTING_command_new_ac ( // TODO make this sync?
320 connect_state, // state
321 label,
325 &connect_state->ac); // TODO make this sync?
326}
void(* GNUNET_TESTING_CORE_handle_msg)(void *cls, struct GNUNET_TESTING_CORE_Channel *channel, const struct GNUNET_TESTING_CORE_Message *msg)
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_TESTING_CORE_ConnectCb * connect_cbs
Connect callback TODO we probably only need a single one.
GNUNET_TESTING_CORE_handle_msg * recv_handlers
Receive callback.
struct GNUNET_TESTING_AsyncContext ac
enum GNUNET_GenericReturnValue finished
static void exec_connect_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
static void exec_connect_cleanup(void *cls)
static enum GNUNET_GenericReturnValue connect_traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.
#define LOG(kind,...)
Generic logging shortcut.

References GNUNET_TESTING_CORE_ConnectState::ac, GNUNET_TESTING_CORE_ConnectState::arm_service_label, GNUNET_TESTING_CORE_ConnectState::connect_cbs, GNUNET_TESTING_CORE_ConnectState::connect_cbs_len, connect_traits(), exec_connect_cleanup(), exec_connect_run(), GNUNET_TESTING_CORE_ConnectState::finished, GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_new_array, GNUNET_NO, GNUNET_strdup, GNUNET_TESTING_command_new_ac(), LOG, GNUNET_TESTING_CORE_ConnectState::node_id, GNUNET_TESTING_CORE_ConnectState::recv_handlers, and GNUNET_TESTING_CORE_ConnectState::recv_handlers_len.

Here is the call graph for this function:

◆ GNUNET_TESTING_CORE_cmd_recv()

const struct GNUNET_TESTING_Command GNUNET_TESTING_CORE_cmd_recv ( const char *  label,
uint64_t  num_messages 
)

Definition at line 251 of file testing_core_cmd_recv.c.

254{
255 struct RecvState *rs;
256
257 // TODO this could be a static global variable
258 rs = GNUNET_new (struct RecvState);
259 rs->num_channels = 0;
261 rs->num_messages_target = num_messages;
262 LOG (GNUNET_ERROR_TYPE_DEBUG, "(Setting up _cmd_recv)\n");
264 rs, // state
265 label,
268 NULL, // traits
269 &rs->ac); // FIXME
270}
uint64_t num_messages_target
struct ChannelCount * channel_count
struct GNUNET_TESTING_AsyncContext ac
static void exec_recv_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
static void exec_recv_cleanup(void *cls)
#define LOG(kind,...)
Generic logging shortcut.

References RecvState::ac, RecvState::channel_count, exec_recv_cleanup(), exec_recv_run(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_new_array, GNUNET_TESTING_command_new_ac(), LOG, RecvState::num_channels, and RecvState::num_messages_target.

Here is the call graph for this function:

◆ GNUNET_TESTING_CORE_cmd_send()

const struct GNUNET_TESTING_Command GNUNET_TESTING_CORE_cmd_send ( const char *  label,
uint64_t  num_messages,
enum GNUNET_GenericReturnValue  await_new_connection 
)

Definition at line 198 of file testing_core_cmd_send.c.

202{
203 struct SendState *send_state;
204
205 // TODO make struct static global?
206 send_state = GNUNET_new (struct SendState);
207 send_state->num_messages = num_messages;
209 LOG (GNUNET_ERROR_TYPE_DEBUG, "(Setting up _cmd_send)\n");
211 send_state, // state
212 label,
215 NULL);
216}
State for the 'send' command.
enum GNUNET_GenericReturnValue await_new_connection
static void exec_send_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
static void exec_send_cleanup(void *cls)
#define LOG(kind,...)
Generic logging shortcut.

References SendState::await_new_connection, exec_send_cleanup(), exec_send_run(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_TESTING_command_new, LOG, and SendState::num_messages.

Here is the call graph for this function:

◆ GNUNET_CORE_TESTING_get_trait_connect_peer_state()

enum GNUNET_GenericReturnValue GNUNET_CORE_TESTING_get_trait_connect_peer_state ( const struct GNUNET_TESTING_Command cmd,
const struct GNUNET_TESTING_ConnectPeersState **  ret 
)

◆ GNUNET_CORE_TESTING_make_trait_connect_peer_state()

struct GNUNET_TESTING_Trait GNUNET_CORE_TESTING_make_trait_connect_peer_state ( const struct GNUNET_TESTING_ConnectPeersState value)

Referenced by connect_peers_traits().

Here is the caller graph for this function:

◆ GNUNET_CORE_TESTING_get_trait_connect()

enum GNUNET_GenericReturnValue GNUNET_CORE_TESTING_get_trait_connect ( const struct GNUNET_TESTING_Command cmd,
const struct GNUNET_TESTING_CORE_ConnectState **  ret 
)

Referenced by exec_recv_run(), and exec_send_run().

Here is the caller graph for this function:

◆ GNUNET_CORE_TESTING_make_trait_connect()

struct GNUNET_TESTING_Trait GNUNET_CORE_TESTING_make_trait_connect ( const struct GNUNET_TESTING_CORE_ConnectState value)

Referenced by connect_traits().

Here is the caller graph for this function: