library for writing CADET tests More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "cadet_test_lib.h"
#include "gnunet_cadet_service.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_CADET_TEST_Context |
Test context for a CADET Test. More... | |
struct | GNUNET_CADET_TEST_AdapterContext |
Context for a cadet adapter callback. More... | |
Functions | |
static void * | cadet_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) |
Adapter function called to establish a connection to the CADET service. More... | |
static void | cadet_disconnect_adapter (void *cls, void *op_result) |
Adapter function called to destroy a connection to the CADET service. More... | |
static void | cadet_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg) |
Callback to be called when a service connect operation is completed. More... | |
void | GNUNET_CADET_TEST_cleanup (struct GNUNET_CADET_TEST_Context *ctx) |
Clean up the testbed. More... | |
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) 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... | |
library for writing CADET tests
Definition in file cadet_test_lib.c.
|
static |
Adapter function called to establish a connection to the CADET service.
cls | closure |
cfg | configuration of the peer to connect to; will be available until GNUNET_TESTBED_operation_done() is called on the operation returned from GNUNET_TESTBED_service_connect() |
Definition at line 131 of file cadet_test_lib.c.
References cfg, GNUNET_CADET_TEST_AdapterContext::ctx, ctx, GNUNET_break, GNUNET_CADET_connect(), GNUNET_CADET_open_port(), GNUNET_new_array, h, GNUNET_CADET_TEST_AdapterContext::peer, and GNUNET_CADET_TEST_AdapterContext::ports.
Referenced by cadet_test_run().
|
static |
Adapter function called to destroy a connection to the CADET service.
cls | closure |
op_result | service handle returned from the connect adapter |
Definition at line 170 of file cadet_test_lib.c.
References cadet, GNUNET_CADET_TEST_AdapterContext::ctx, GNUNET_CADET_close_port(), GNUNET_CADET_disconnect(), GNUNET_free, op_result(), GNUNET_CADET_TEST_Context::port_count, and GNUNET_CADET_TEST_AdapterContext::ports.
Referenced by cadet_test_run().
|
static |
Callback to be called when a service connect operation is completed.
cls | The callback closure from functions generating an operation. |
op | The operation that has been finished. |
ca_result | The service handle returned from GNUNET_TESTBED_ConnectAdapter() (cadet handle). |
emsg | Error message in case the operation has failed. NULL if operation has executed successfully. |
Definition at line 201 of file cadet_test_lib.c.
References ctx, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_shutdown(), and op.
Referenced by cadet_test_run().
void GNUNET_CADET_TEST_cleanup | ( | struct GNUNET_CADET_TEST_Context * | ctx | ) |
Clean up the testbed.
ctx | handle for the testbed |
Definition at line 238 of file cadet_test_lib.c.
References ctx, GNUNET_assert, GNUNET_free, GNUNET_SCHEDULER_shutdown(), and GNUNET_TESTBED_operation_done().
Referenced by disconnect_cadet_peers(), start_test(), and warmup().
|
static |
Callback run when the testbed is ready (peers running and connected to each other)
cls | Closure (context). |
h | the run handle |
num_peers | Number of peers that are running. |
peers | Handles to each one of the num_peers peers. |
links_succeeded | the number of overlay link connection attempts that succeeded |
links_failed | the number of overlay link connection attempts that failed |
Definition at line 268 of file cadet_test_lib.c.
References cadet_connect_adapter(), cadet_connect_cb(), cadet_disconnect_adapter(), GNUNET_CADET_TEST_AdapterContext::ctx, ctx, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_new, GNUNET_TESTBED_service_connect(), num_peers, GNUNET_CADET_TEST_AdapterContext::peer, and peers.
Referenced by 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.
testname | Name of the test (for logging). |
cfgfile | Name of the configuration file. |
num_peers | Number of peers to start. |
tmain | Main function to run once the testbed is ready. |
tmain_cls | Closure for tmain. |
connects | Handler for incoming channels. |
window_changes | Handler for the window size change notification. |
disconnects | Cleaner for destroyed incoming channels. |
handlers | Message handlers. |
ports | Ports the peers offer, NULL-terminated. |
Definition at line 338 of file cadet_test_lib.c.
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.