78 "Testcase shutting down\n");
101 if (NULL !=
ccc->
p[i])
122 "Testcase timed out\n");
183 "Peers connected: %u (%s) <-> %u (%s)\n",
194 "All connections UP, launching custom test logic.\n");
214 for (
unsigned int i = 0; i < ccc->
num_peers; i++)
215 if ((NULL != ccc->
p[i]) &&
305 if (NULL != ccc->
rec)
342 if (NULL != ccc->
rec)
361 for (
unsigned int i = 0; i < ccc->
num_peers; i++)
380 "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
411 "Peer %u (`%s') started\n",
458 for (
unsigned int i = 0; i < ccc->
num_peers; i++)
480 if (NULL == ccc->
p[i])
486 "Fail! Could not start peers!\n");
511 const char *test_plugin_,
512 const char *test_name_,
537 for (
unsigned int i = 0; i <
num_peers; i++)
587 for (
unsigned int i = 0; i <
num_peers; i++)
597 ret = check (check_cls,
605 for (
unsigned int i = 0; i <
num_peers; i++)
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MQ_MessageHandlers handlers[]
struct GNUNET_MQ_Handle * mq
static int ret
Final status code.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static struct GNUNET_OS_Process * p
Helper process we started.
static unsigned int num_peers
Number of peers.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_log(kind,...)
void * cls
Closure for mv and cb.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
enum GNUNET_GenericReturnValue GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
#define GNUNET_TIME_UNIT_SECONDS
One second.
Information tracked per connected peer.
const struct GNUNET_PeerIdentity * sender
Peer this is about.
struct GNUNET_TRANSPORT_TESTING_InternalPeerContext * ipi
Information about the receiving peer.
Definition of a command line option.
Handle to a message queue.
Message handler for a specific message type.
The identity of the host (wraps the signing key of the peer).
Closure that must be passed to GNUNET_TRANSPORT_TESTING_connect_check.
GNUNET_TRANSPORT_TESTING_NotifyConnect nc
Notify connect argument to give for peers we start.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration object for the testcase.
unsigned int num_peers
Number of peers involved in the test.
void * shutdown_task_cls
Closure for shutdown_task.
struct GNUNET_SCHEDULER_Task * timeout_task
Task run on timeout.
int global_ret
Result from the main function, set to GNUNET_OK on success.
GNUNET_SCHEDULER_TaskCallback shutdown_task
Custom task to run on shutdown.
void * pre_connect_task_cls
Closure for shutdown_task.
GNUNET_TRANSPORT_TESTING_ReceiveCallback rec
Receiver argument to give for peers we start.
GNUNET_SCHEDULER_TaskCallback connect_continuation
How should we continue after the connect?
const char * config_file
Which configuration file should we pass to the GNUNET_PROGRAM_run() of the testcase?
struct GNUNET_TRANSPORT_TESTING_InternalPeerContext * ip
Array with num_peers entries.
GNUNET_TRANSPORT_TESTING_NotifyDisconnect nd
Notify disconnect argument to give for peers we start.
char ** cfg_files
Configuration files we have, array with num_peers entries.
const char * test_name
Name of the testcase.
GNUNET_SCHEDULER_TaskCallback pre_connect_task
Custom task to run after peers were started but before we try to connect them.
void * connect_continuation_cls
Closure for connect_continuation.
void * cls
Closure for rec, nc and nd.
struct GNUNET_SCHEDULER_Task * connect_task
Task run to connect peers.
struct GNUNET_TRANSPORT_TESTING_ConnectRequestList * crl_head
DLL of active connect requests.
int bi_directional
Should we try to create connections in both directions?
unsigned int started
Number of peers that have been started.
struct GNUNET_TRANSPORT_TESTING_Handle * tth
Main testing handle.
struct GNUNET_TRANSPORT_TESTING_PeerContext ** p
Array with num_peers entries.
struct GNUNET_TIME_Relative timeout
When should the testcase time out?
const char * test_plugin
Name of the plugin.
struct GNUNET_TRANSPORT_TESTING_ConnectRequestList * crl_tail
DLL of active connect requests.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p1
Peer being connected.
struct GNUNET_TRANSPORT_TESTING_ConnectRequestList * next
Stored in a DLL.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cr
Connect request this is about.
struct GNUNET_TRANSPORT_TESTING_ConnectRequestList * prev
Stored in a DLL.
struct GNUNET_TRANSPORT_TESTING_PeerContext * p2
Peer being connected.
struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext * ccc
Overall context we are in.
Handle for a request to connect two peers.
unsigned int off
Offset of the peer this is about.
struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext * ccc
Overall context of the callback.
Context for a single peer.
struct GNUNET_TESTING_Peer * peer
Peer's testing handle.
unsigned int no
An unique number to identify the peer.
struct GNUNET_PeerIdentity id
Peer identity.
char * GNUNET_TRANSPORT_TESTING_get_test_plugin_name(const char *file, const char *test)
Extracts the plugin name from an absolute file name and the test name.
char * GNUNET_TRANSPORT_TESTING_get_test_source_name(const char *file)
Extracts the filename from an absolute file name and removes the extension.
char * GNUNET_TRANSPORT_TESTING_get_config_name(const char *file, int count)
This function takes the filename (e.g.
char * GNUNET_TRANSPORT_TESTING_get_test_name(const char *file)
Extracts the test filename from an absolute file name and removes the extension.
static void connect_check_run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Function run from GNUNET_TRANSPORT_TESTING_connect_check once the scheduler is up.
static int check_test2(void *cls, const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
Wrapper around receiving data.
static void connect_cb(void *cls)
Function called when we connected two peers.
struct GNUNET_TRANSPORT_TESTING_PeerContext * GNUNET_TRANSPORT_TESTING_find_peer(struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc, const struct GNUNET_PeerIdentity *peer)
Find peer by peer ID.
static void start_cb(void *cls)
Function called once we have successfully launched a peer.
static void do_timeout(void *cls)
Testcase hit timeout, shut it down with error.
static void * my_nc(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Wrapper around peers connecting.
static void do_connect(void *cls)
Connect the peers as a clique.
static void do_shutdown(void *cls)
Shutdown function for the test.
int GNUNET_TRANSPORT_TESTING_connect_check(void *cls, struct GNUNET_TRANSPORT_TESTING_Handle *tth_, const char *test_plugin_, const char *test_name_, unsigned int num_peers, char *cfg_files[])
Common implementation of the GNUNET_TRANSPORT_TESTING_CheckCallback.
static int check_test(void *cls, const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
Wrapper around receiving data.
static void my_nd(void *cls, const struct GNUNET_PeerIdentity *peer, void *custom_cls)
Wrapper around peers disconnecting.
static void handle_test(void *cls, const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
Wrapper around receiving data.
int GNUNET_TRANSPORT_TESTING_main_(const char *argv0, const char *filename, unsigned int num_peers, GNUNET_TRANSPORT_TESTING_CheckCallback check, void *check_cls)
Setup testcase.
static void handle_test2(void *cls, const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
Wrapper around receiving data.
struct GNUNET_TRANSPORT_TESTING_PeerContext * GNUNET_TRANSPORT_TESTING_start_peer(struct GNUNET_TRANSPORT_TESTING_Handle *tth, const char *cfgname, int peer_id, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_TRANSPORT_NotifyConnect nc, GNUNET_TRANSPORT_NotifyDisconnect nd, void *cb_cls, GNUNET_SCHEDULER_TaskCallback start_cb, void *start_cb_cls)
Start a peer with the given configuration.
void GNUNET_TRANSPORT_TESTING_stop_peer(struct GNUNET_TRANSPORT_TESTING_PeerContext *p)
Shutdown the given peer.
struct GNUNET_TRANSPORT_TESTING_Handle * GNUNET_TRANSPORT_TESTING_init()
Initialize the transport testing.
struct GNUNET_TRANSPORT_TESTING_ConnectRequest * GNUNET_TRANSPORT_TESTING_connect_peers(struct GNUNET_TRANSPORT_TESTING_PeerContext *p1, struct GNUNET_TRANSPORT_TESTING_PeerContext *p2, GNUNET_SCHEDULER_TaskCallback cb, void *cls)
Function called after the HELLO was passed to the transport service.
void GNUNET_TRANSPORT_TESTING_done(struct GNUNET_TRANSPORT_TESTING_Handle *tth)
Clean up the transport testing.
void GNUNET_TRANSPORT_TESTING_connect_peers_cancel(struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc)
Cancel the request to connect two peers.
int(* GNUNET_TRANSPORT_TESTING_CheckCallback)(void *cls, struct GNUNET_TRANSPORT_TESTING_Handle *tth_, const char *test_plugin_, const char *test_name_, unsigned int num_peers, char *cfg_files[])
Main function of a testcase.
#define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE
Message type used by GNUNET_TRANSPORT_TESTING_simple_send().
#define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2
Alternative message type for tests.