GNUnet  0.20.0
cadet_test_lib.h File Reference

library for writing CADET tests More...

Include dependency graph for cadet_test_lib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


typedef void(* GNUNET_CADET_TEST_AppMain) (void *cls, struct GNUNET_CADET_TEST_Context *ctx, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, struct GNUNET_CADET_Handle **cadets)
 Main function of a CADET test. More...


void GNUNET_CADET_TEST_ruN (const char *testname, const char *cfgfile, unsigned int num_peers, GNUNET_CADET_TEST_AppMain tmain, void *tmain_cls, GNUNET_CADET_ConnectEventHandler connects, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, struct GNUNET_MQ_MessageHandler *handlers, const struct GNUNET_HashCode **ports)
 Run a test using the given name, configuration file and number of peers. More...
void GNUNET_CADET_TEST_cleanup (struct GNUNET_CADET_TEST_Context *ctx)
 Clean up the testbed. More...

Detailed Description

library for writing CADET tests

Bartlomiej Polot

Definition in file cadet_test_lib.h.

Typedef Documentation


typedef void(* GNUNET_CADET_TEST_AppMain) (void *cls, struct GNUNET_CADET_TEST_Context *ctx, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, struct GNUNET_CADET_Handle **cadets)

Main function of a CADET test.

ctxArgument to give to GNUNET_CADET_TEST_cleanup on test end.
num_peersNumber of peers that are running.
peersArray of peers.
cadetsHandle to each of the CADETs of the peers.

Definition at line 54 of file cadet_test_lib.h.

Function Documentation


void GNUNET_CADET_TEST_ruN ( const char *  testname,
const char *  cfgfile,
unsigned int  num_peers,
void *  tmain_cls,
GNUNET_CADET_ConnectEventHandler  connects,
GNUNET_CADET_WindowSizeEventHandler  window_changes,
GNUNET_CADET_DisconnectEventHandler  disconnects,
struct GNUNET_MQ_MessageHandler handlers,
const struct GNUNET_HashCode **  ports 

Run a test using the given name, configuration file and number of peers.

All cadet callbacks will receive the peer number (long) as the closure.

testnameName of the test (for logging).
cfgfileName of the configuration file.
num_peersNumber of peers to start.
tmainMain function to run once the testbed is ready.
tmain_clsClosure for tmain.
connectsHandler for incoming channels.
window_changesHandler for the window size change notification.
disconnectsCleaner for destroyed incoming channels.
handlersMessage handlers.
portsPorts the peers offer, NULL-terminated.

Definition at line 338 of file cadet_test_lib.c.

348 {
352  ctx->num_peers = num_peers;
354  struct GNUNET_TESTBED_Operation *);
355  ctx->cadets = GNUNET_new_array (num_peers,
356  struct GNUNET_CADET_Handle *);
357  ctx->app_main = tmain;
358  ctx->app_main_cls = tmain_cls;
359  ctx->connects = connects;
360  ctx->window_changes = window_changes;
361  ctx->disconnects = disconnects;
362  ctx->handlers = GNUNET_MQ_copy_handlers (handlers);
363  ctx->ports = ports;
364  ctx->port_count = 0;
365  while (NULL != ctx->ports[ctx->port_count])
366  ctx->port_count++;
367  GNUNET_TESTBED_test_run (testname,
368  cfgfile,
369  num_peers,
370  0LL, NULL, NULL,
372  ctx);
373 }
void * connects(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Definition: 010.c:2
void disconnects(void *cls, const struct GNUNET_PeerIdentity *peer)
Definition: 011.c:2
static void cadet_test_run(void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, unsigned int links_succeeded, unsigned int links_failed)
Callback run when the testbed is ready (peers running and connected to each other)
static void tmain(void *cls, struct GNUNET_CADET_TEST_Context *ctx, unsigned int num_peers, struct GNUNET_TESTBED_Peer **testbed_peers, struct GNUNET_CADET_Handle **cadetes)
test main: start test when all peers are connected
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static unsigned int num_peers
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
#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.
struct GNUNET_MQ_MessageHandler * GNUNET_MQ_copy_handlers(const struct GNUNET_MQ_MessageHandler *handlers)
Copy an array of handlers.
Definition: mq.c:957
int GNUNET_TESTBED_test_run(const char *testname, const char *cfg_filename, unsigned int num_peers, uint64_t event_mask, GNUNET_TESTBED_ControllerCallback cc, void *cc_cls, GNUNET_TESTBED_TestMaster test_master, void *test_master_cls)
Convenience method for running a "simple" test on the local system with a single call from 'main'.
Opaque handle to the service.
Definition: cadet_api.c:39
Test context for a CADET Test.
GNUNET_CADET_WindowSizeEventHandler window_changes
Function called when the transmit window size changes.
const struct GNUNET_HashCode ** ports
Application ports.
Opaque handle to an abstract operation to be executed by the testing framework.

References cadet_test_run(), connects(), ctx, disconnects(), GNUNET_MQ_copy_handlers(), GNUNET_new, GNUNET_new_array, GNUNET_TESTBED_test_run(), handlers, num_peers, GNUNET_CADET_TEST_Context::ports, tmain(), and GNUNET_CADET_TEST_Context::window_changes.

Here is the call graph for this function:


void GNUNET_CADET_TEST_cleanup ( struct GNUNET_CADET_TEST_Context ctx)

Clean up the testbed.

ctxhandle for the testbed

Definition at line 238 of file cadet_test_lib.c.

239 {
240  for (unsigned int i = 0; i < ctx->num_peers; i++)
241  {
242  GNUNET_assert (NULL != ctx->ops[i]);
244  ctx->ops[i] = NULL;
245  }
246  GNUNET_free (ctx->ops);
247  GNUNET_free (ctx->cadets);
248  GNUNET_free (ctx->handlers);
249  GNUNET_free (ctx);
251 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:562
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2021

References ctx, GNUNET_assert, GNUNET_free, GNUNET_SCHEDULER_shutdown(), and GNUNET_TESTBED_operation_done().

Referenced by disconnect_cadet_peers(), start_test(), and warmup().

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