GNUnet  0.10.x
Typedefs | Functions
cadet_test_lib.h File Reference

library for writing CADET tests More...

#include "gnunet_testbed_service.h"
#include "gnunet_cadet_service.h"
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.

Typedefs

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

Functions

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

Author
Bartlomiej Polot

Definition in file cadet_test_lib.h.

Typedef Documentation

◆ GNUNET_CADET_TEST_AppMain

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.

Parameters
clsClosure.
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

◆ GNUNET_CADET_TEST_ruN()

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.

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

Parameters
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 336 of file cadet_test_lib.c.

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

346 {
348 
350  ctx->num_peers = num_peers;
352  struct GNUNET_TESTBED_Operation *);
354  struct GNUNET_CADET_Handle *);
355  ctx->app_main = tmain;
356  ctx->app_main_cls = tmain_cls;
357  ctx->connects = connects;
359  ctx->disconnects = disconnects;
360  ctx->handlers = GNUNET_MQ_copy_handlers(handlers);
361  ctx->ports = ports;
362  ctx->port_count = 0;
363  while (NULL != ctx->ports[ctx->port_count])
364  ctx->port_count++;
365  GNUNET_TESTBED_test_run(testname,
366  cfgfile,
367  num_peers,
368  0LL, NULL, NULL,
370  ctx);
371 }
struct GNUNET_TESTBED_Operation ** ops
Operation associated with the connection to the CADET.
Opaque handle to the service.
Definition: cadet_api.c:38
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'...
struct GNUNET_MQ_MessageHandler * GNUNET_MQ_copy_handlers(const struct GNUNET_MQ_MessageHandler *handlers)
Copy an array of handlers.
Definition: mq.c:1211
struct GNUNET_CADET_Handle ** cadets
Array of handles to the CADET for each peer.
GNUNET_CADET_ConnectEventHandler connects
Handler for incoming tunnels.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Test context for a CADET Test.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
Opaque handle to an abstract operation to be executed by the testing framework.
GNUNET_CADET_DisconnectEventHandler disconnects
Cleaner for destroyed incoming tunnels.
struct GNUNET_MQ_MessageHandler * handlers
Message handlers.
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
GNUNET_CADET_WindowSizeEventHandler window_changes
Function called when the transmit window size changes.
unsigned int num_peers
Number of peers running, size of the arrays above.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
const struct GNUNET_HashCode ** ports
Application ports.
unsigned int port_count
Number of ports in ports.
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 unsigned int num_peers
void * app_main_cls
Closure for 'app_main'.
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) ...
GNUNET_CADET_TEST_AppMain app_main
Main function of the test to run once all CADETs are available.
Here is the call graph for this function:

◆ GNUNET_CADET_TEST_cleanup()

void GNUNET_CADET_TEST_cleanup ( struct GNUNET_CADET_TEST_Context ctx)

Clean up the testbed.

Parameters
ctxhandle for the testbed

Definition at line 236 of file cadet_test_lib.c.

References GNUNET_CADET_TEST_Context::cadets, GNUNET_assert, GNUNET_free, GNUNET_SCHEDULER_shutdown(), GNUNET_TESTBED_operation_done(), GNUNET_CADET_TEST_Context::handlers, GNUNET_CADET_TEST_Context::num_peers, and GNUNET_CADET_TEST_Context::ops.

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

237 {
238  for (unsigned int i = 0; i < ctx->num_peers; i++)
239  {
240  GNUNET_assert(NULL != ctx->ops[i]);
242  ctx->ops[i] = NULL;
243  }
244  GNUNET_free(ctx->ops);
245  GNUNET_free(ctx->cadets);
246  GNUNET_free(ctx->handlers);
247  GNUNET_free(ctx);
249 }
struct GNUNET_TESTBED_Operation ** ops
Operation associated with the connection to the CADET.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_CADET_Handle ** cadets
Array of handles to the CADET for each peer.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
struct GNUNET_MQ_MessageHandler * handlers
Message handlers.
unsigned int num_peers
Number of peers running, size of the arrays above.
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:2037
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function: