GNUnet  0.20.0
dht_test_lib.h File Reference

library for writing DHT tests More...

Include dependency graph for dht_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_DHT_TEST_AppMain) (void *cls, struct GNUNET_DHT_TEST_Context *ctx, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, struct GNUNET_DHT_Handle **dhts)
 Main function of a DHT test. More...
 

Functions

void GNUNET_DHT_TEST_run (const char *testname, const char *cfgname, unsigned int num_peers, GNUNET_DHT_TEST_AppMain tmain, void *tmain_cls)
 Run a test using the given name, configuration file and number of peers. More...
 
void GNUNET_DHT_TEST_cleanup (struct GNUNET_DHT_TEST_Context *ctx)
 Clean up the testbed. More...
 

Detailed Description

library for writing DHT tests

Author
Christian Grothoff

Definition in file dht_test_lib.h.

Typedef Documentation

◆ GNUNET_DHT_TEST_AppMain

typedef void(* GNUNET_DHT_TEST_AppMain) (void *cls, struct GNUNET_DHT_TEST_Context *ctx, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, struct GNUNET_DHT_Handle **dhts)

Main function of a DHT test.

Parameters
clsclosure
ctxargument to give to GNUNET_DHT_TEST_cleanup on test end
num_peersnumber of peers that are running
peersarray of peers
dhtshandle to each of the DHTs of the peers

Definition at line 54 of file dht_test_lib.h.

Function Documentation

◆ GNUNET_DHT_TEST_run()

void GNUNET_DHT_TEST_run ( const char *  testname,
const char *  cfgname,
unsigned int  num_peers,
GNUNET_DHT_TEST_AppMain  tmain,
void *  tmain_cls 
)

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

Parameters
testnamename of the test (for logging)
cfgnamename of the configuration file
num_peersnumber of peers to start
tmainmain function to run once the testbed is ready
tmain_clsclosure for 'tmain'

Definition at line 178 of file dht_test_lib.c.

183 {
185 
187  ctx->num_peers = num_peers;
189  struct GNUNET_TESTBED_Operation *);
190  ctx->dhts = GNUNET_new_array (num_peers,
191  struct GNUNET_DHT_Handle *);
192  ctx->app_main = tmain;
193  ctx->app_main_cls = tmain_cls;
194  (void) GNUNET_TESTBED_test_run (testname,
195  cfgname,
196  num_peers,
197  0LL, NULL, NULL,
198  &dht_test_run, ctx);
199 }
static void dht_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)
Definition: dht_test_lib.c:154
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 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.
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'.
Connection to the DHT service.
Definition: dht_api.c:237
Test context for a DHT Test.
Definition: dht_test_lib.c:32
Opaque handle to an abstract operation to be executed by the testing framework.

References ctx, dht_test_run(), GNUNET_new, GNUNET_new_array, GNUNET_TESTBED_test_run(), num_peers, and tmain().

Here is the call graph for this function:

◆ GNUNET_DHT_TEST_cleanup()

void GNUNET_DHT_TEST_cleanup ( struct GNUNET_DHT_TEST_Context ctx)

Clean up the testbed.

Parameters
ctxhandle for the testbed

Definition at line 142 of file dht_test_lib.c.

143 {
144  for (unsigned int i = 0; i < ctx->num_peers; i++)
146  GNUNET_free (ctx->ops);
147  GNUNET_free (ctx->dhts);
148  GNUNET_free (ctx);
150 }
#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_free, GNUNET_SCHEDULER_shutdown(), and GNUNET_TESTBED_operation_done().

Here is the call graph for this function: