37 #define TEST_ROOM "test"
38 #define TEST_NAME "tester"
83 for (
unsigned int i = 0; i < properties->
num_peer; i++)
140 for (
unsigned int i = 0; i < properties->
num_peer; i++)
150 if (
peer->props->num_peer != (
unsigned int) members)
152 fprintf (stderr,
"Testcase failed (members: %d/%u).\n", members,
peer->props->num_peer);
170 fprintf (stderr,
"Testcase failed (timeout).\n");
184 peer->op_task = NULL;
186 fprintf (stderr,
"Testcase failed (operation: '%s').\n",
peer->message);
198 peer->op_task = NULL;
200 fprintf (stderr,
"Testcase failed (error: '%s').\n",
peer->message);
215 if (
peer->wait == waiting)
228 if (
peer->wait == waiting)
231 if (0 != (
peer->props->cfg->stages[
peer->num - 1] & 0x02))
233 unsigned int door =
peer->props->cfg->doors[
peer->num - 1];
277 fprintf (stderr,
"Peer: %s; [%s] Message: %s (%s)\n",
284 peer->peer_messages++;
286 if (
peer->props->num_hosts ==
peer->peer_messages)
288 else if (
peer->props->num_hosts <
peer->peer_messages)
298 peer->message =
"peer";
310 peer->op_task = NULL;
315 if (0 != (
peer->props->cfg->stages[
peer->num - 1] & 0x10))
328 if (0 != (
peer->props->cfg->stages[
peer->num - 1] & 0x20))
330 unsigned int door =
peer->props->cfg->doors[
peer->num - 1];
368 peer->message =
"info";
375 peer->message =
"config";
386 if (0 != (
peer->props->cfg->stages[
peer->num - 1] & 0x01))
417 fprintf (stderr,
"Testcase failed (operation: 'start').\n");
425 peer->props = properties;
428 peer->peer =
event->details.peer_start.peer;
446 fprintf (stderr,
"Testcase failed (operation: 'barrier2').\n");
479 fprintf (stderr,
"Testcase failed (operation: 'process').\n");
487 fprintf (stderr,
"Testcase failed (operation: 'barrier').\n");
496 for (
unsigned int i = 0; i < properties->
num_peer; i++)
506 unsigned int links_succeeded,
507 unsigned int links_failed)
525 memset(&properties, 0,
sizeof(properties));
530 for (
unsigned int i = 0; i <
cfg->count; i++)
531 if (0 != (
cfg->stages[i] & 0x11))
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static struct GNUNET_ARM_Operation * op
Current operation.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static struct CadetPeer * peers
Operation to get peer ids.
static unsigned int num_peers
uint16_t status
See PRISM_STATUS_*-constants.
API for submitting data to the testbed logger service.
API for writing tests and creating large-scale emulation testbeds for GNUnet.
Convenience API for writing testcases for GNUnet.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_get_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *dst)
Retrieve the identity of the host's peer.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_MESSENGER_Room * GNUNET_MESSENGER_enter_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key)
Enter a room to send and receive messages through a door opened using GNUNET_MESSENGER_open_room.
int GNUNET_MESSENGER_iterate_members(struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback, void *cls)
Iterates through all members of a given room and calls a selected callback for each of them with a pr...
struct GNUNET_MESSENGER_Room * GNUNET_MESSENGER_open_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Open a room to send and receive messages.
GNUNET_MESSENGER_MessageFlags
Enum for the different supported flags used by message handling Compatible flags can be OR'ed togethe...
struct GNUNET_MESSENGER_Handle * GNUNET_MESSENGER_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name, GNUNET_MESSENGER_IdentityCallback identity_callback, void *identity_cls, GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls)
Set up a handle for the messenger related functions and connects to all necessary services.
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
void GNUNET_MESSENGER_disconnect(struct GNUNET_MESSENGER_Handle *handle)
Disconnect all of the messengers used services and clears up its used memory.
void GNUNET_MESSENGER_close_room(struct GNUNET_MESSENGER_Room *room)
Close a room which was entered, opened or both in various order and variety.
@ GNUNET_MESSENGER_KIND_PEER
The peer kind.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
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_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_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
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...
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_get_information(struct GNUNET_TESTBED_Peer *peer, enum GNUNET_TESTBED_PeerInformationType pit, GNUNET_TESTBED_PeerInfoCallback cb, void *cb_cls)
Request information about a peer.
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'.
@ GNUNET_TESTBED_PIT_CONFIGURATION
What configuration is the peer using? Returns a 'const struct GNUNET_CONFIGURATION_Handle *'.
@ GNUNET_TESTBED_ET_PEER_START
A peer has been started.
#define GNUNET_TIME_UNIT_SECONDS
One second.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Opaque handle to an abstract operation to be executed by the testing framework.
A peer controlled by the testing framework.
struct GNUNET_SCHEDULER_Task * op_task
struct GNUNET_TESTBED_Operation * op
unsigned int peer_messages
struct test_properties * props
struct GNUNET_BarrierWaitHandle * wait
struct GNUNET_TESTBED_Peer * peer
struct GNUNET_PeerIdentity peer_id
struct GNUNET_MESSENGER_Handle * handle
struct GNUNET_MESSENGER_Room * room
const struct test_configuration * cfg
struct GNUNET_SCHEDULER_Task * end_task
struct GNUNET_SCHEDULER_Task * die_task
struct GNUNET_BarrierHandle * barrier
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
void GNUNET_cancel_barrier(struct GNUNET_BarrierHandle *barrier)
Cancel a pseudo-barrier.
void GNUNET_cancel_wait_barrier(struct GNUNET_BarrierWaitHandle *waiting)
Cancel a pseudo-barrier wait handle.
struct GNUNET_BarrierHandle * GNUNET_init_barrier(unsigned int requirement, GNUNET_BarrierStatusCallback cb, void *cb_cls)
Initialise a pseudo-barrier and call the given callback when the required amount of peers (requiremen...
struct GNUNET_BarrierWaitHandle * GNUNET_wait_barrier(struct GNUNET_BarrierHandle *barrier, GNUNET_BarrierWaitStatusCallback cb, void *cb_cls)
Wait for a pseudo-barrier to be crossed.
Pseudo-barriers for simple event handling.
static void barrier_cb(void *cls, struct GNUNET_BarrierHandle *barrier, int status)
static void on_message(void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_MessageFlags flags)
Function called whenever a message is received or sent.
static void barrier_wait_cb(void *cls, struct GNUNET_BarrierWaitHandle *waiting, int status)
static void on_peer(void *cb_cls, struct GNUNET_TESTBED_Operation *op, const struct GNUNET_TESTBED_PeerInformation *pinfo, const char *emsg)
static void barrier2_wait_cb(void *cls, struct GNUNET_BarrierWaitHandle *waiting, int status)
static void end_error_cb(void *cls)
static void shutdown_cb(void *cls)
static void barrier2_cb(void *cls, struct GNUNET_BarrierHandle *barrier, int status)
static void end_cb(void *cls)
static void run(void *cls, const struct GNUNET_TESTBED_EventInformation *event)
Main function for a peer of the testcase.
static void second_stage(void *cls)
static void init(void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, unsigned int links_succeeded, unsigned int links_failed)
static void end_badly_cb(void *cls)
static void end_operation_cb(void *cls)
int GNUNET_run_messenger_setup(const char *test_name, const struct test_configuration *cfg)
A simple test-case setup for the messenger service.