Barrier functionality. More...
#include "platform.h"
#include "testing.h"
#include "gnunet_testing_ng_lib.h"
#include "gnunet_testing_plugin.h"
#include "gnunet_testing_netjail_lib.h"
#include "gnunet_testing_barrier.h"
Go to the source code of this file.
Data Structures | |
struct | BarrierState |
Macros | |
#define | LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) |
Generic logging shortcut. More... | |
Functions | |
void | GNUNET_TESTING_send_barrier_attach (struct GNUNET_TESTING_Interpreter *is, char *barrier_name, unsigned int global_node_number, unsigned int expected_reaches, GNUNET_TESTING_cmd_helper_write_cb write_message) |
Send Message to master loop that cmds being attached to a barrier. More... | |
unsigned int | GNUNET_TESTING_barrier_crossable (struct GNUNET_TESTING_Barrier *barrier) |
This function checks, if a barrier can be crossed, which actually means that the cmd representing the barrier is finished. More... | |
static enum GNUNET_GenericReturnValue | barrier_traits (void *cls, const void **ret, const char *trait, unsigned int index) |
Offer internal data from a "barrier" CMD, to other commands. More... | |
static void | barrier_cleanup (void *cls) |
Cleanup the state from a "barrier" CMD, and possibly cancel a pending operation thereof. More... | |
static void | barrier_run (void *cls, struct GNUNET_TESTING_Interpreter *is) |
Run the command. More... | |
struct GNUNET_TESTING_NetjailNode * | GNUNET_TESTING_barrier_get_node (struct GNUNET_TESTING_Barrier *barrier, unsigned int node_number) |
Getting a node from a map by global node number. More... | |
struct GNUNET_TESTING_Command | GNUNET_TESTING_cmd_barrier_create (const char *label, double percentage_to_be_reached, unsigned int number_to_be_reached) |
Command to create a barrier. More... | |
Barrier functionality.
Definition in file testing_api_cmd_barrier.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log (kind, __VA_ARGS__) |
Generic logging shortcut.
Definition at line 36 of file testing_api_cmd_barrier.c.
void GNUNET_TESTING_send_barrier_attach | ( | struct GNUNET_TESTING_Interpreter * | is, |
char * | barrier_name, | ||
unsigned int | global_node_number, | ||
unsigned int | expected_reaches, | ||
GNUNET_TESTING_cmd_helper_write_cb | write_message | ||
) |
Send Message to master loop that cmds being attached to a barrier.
FIXME: Unused function
is | The interpreter loop. |
barrier_name | The name of the barrier to attach to. |
subnet_number | The number of the subnet. |
node_number | The node to inform. |
write_message | Callback to write messages to the master loop. |
Definition at line 53 of file testing_api_cmd_barrier.c.
References CommandBarrierAttached::expected_reaches, GNUNET_free, GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED, GNUNET_new, CommandBarrierAttached::header, CommandBarrierAttached::node_number, GNUNET_MessageHeader::size, GNUNET_MessageHeader::type, and write_message().
unsigned int GNUNET_TESTING_barrier_crossable | ( | struct GNUNET_TESTING_Barrier * | barrier | ) |
This function checks, if a barrier can be crossed, which actually means that the cmd representing the barrier is finished.
barrier | The barrier in question. |
Definition at line 78 of file testing_api_cmd_barrier.c.
Referenced by barrier_reached(), and barrier_reached_run().
|
static |
Offer internal data from a "barrier" CMD, to other commands.
cls | closure. | |
[out] | ret | result. |
trait | name of the trait. | |
index | index number of the object to offer. |
Definition at line 78 of file testing_api_cmd_barrier.c.
References CommandBarrierAttached::expected_reaches, GNUNET_TESTING_Barrier::expected_reaches, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_YES, LOG, GNUNET_TESTING_Barrier::number_to_be_reached, GNUNET_TESTING_Barrier::percentage_to_be_reached, and GNUNET_TESTING_Barrier::reached.
|
static |
Cleanup the state from a "barrier" CMD, and possibly cancel a pending operation thereof.
cls | closure. |
Definition at line 141 of file testing_api_cmd_barrier.c.
References GNUNET_free.
|
static |
Run the command.
cls | closure. |
is | the interpreter state. |
Definition at line 156 of file testing_api_cmd_barrier.c.
References BarrierState::barrier, is, and TST_interpreter_add_barrier().
struct GNUNET_TESTING_NetjailNode* GNUNET_TESTING_barrier_get_node | ( | struct GNUNET_TESTING_Barrier * | barrier, |
unsigned int | node_number | ||
) |
Getting a node from a map by global node number.
FIXME: This is a barrier helper function not related to a command but it is implemented in the *_cmd_barrier.c file. Maybe move into a separate file like testing_barrier.c; see also can barrier advance above
nodes | The map. |
node_number | The global node number. |
Definition at line 166 of file testing_api_cmd_barrier.c.
References GNUNET_CONTAINER_multishortmap_get(), GNUNET_CRYPTO_hash(), key, and GNUNET_TESTING_Barrier::nodes.
Referenced by barrier_attached().
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_barrier_create | ( | const char * | label, |
double | percentage_to_be_reached, | ||
unsigned int | number_to_be_reached | ||
) |
Command to create a barrier.
FIXME: high-level it is baffling how we need both the GNUNET_TESTING_Barrier and the Command that creates barriers. Conceptually this seems to be very much separate. Can we move _Barrier completely into testing as private?
label | The label of this command. |
percentage_to_be_reached | If this percentage of processes reached this barrier, all processes waiting at this barrier can pass it. Must not be used together with number_to_be_reached. |
number_to_be_reached | If this number of processes reached this barrier, all processes waiting at this barrier can pass it. Must not be used together with percentage_to_be_reached. |
Definition at line 166 of file testing_api_cmd_barrier.c.