convenience API for writing testcases for GNUnet Many testcases need to start and stop a peer/service and this library is supposed to make that easier for TESTCASES. More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_arm_service.h"
#include "gnunet_testing_lib.h"
#include "gnunet_testing_ng_lib.h"
#include "gnunet_testing_plugin.h"
#include "gnunet_testing_barrier.h"
#include "gnunet_testing_netjail_lib.h"
#include "testing_cmds.h"
Go to the source code of this file.
Data Structures | |
struct | SharedServiceInstance |
struct | SharedService |
The structure for identifying a shared service. More... | |
struct | GNUNET_TESTING_System |
Handle for a system on which GNUnet peers are executed; a system is used for reserving unique paths and ports. More... | |
struct | GNUNET_TESTING_Peer |
Handle for a GNUnet peer controlled by testing. More... | |
struct | UpdateContext |
Closure for update_rel_sum() and update_abs_sum(). More... | |
struct | ServiceContext |
Structure for holding service data. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "testing-api", __VA_ARGS__) |
#define | CONNECT_ADDRESS_TEMPLATE "%s-192.168.15.%u" |
#define | ROUTER_CONNECT_ADDRESS_TEMPLATE "%s-92.68.150.%u" |
#define | KNOWN_CONNECT_ADDRESS_TEMPLATE "%s-92.68.151.%u" |
#define | PREFIX_TCP "tcp" |
#define | PREFIX_UDP "udp" |
#define | PREFIX_TCP_NATTED "tcp_natted" |
#define | PREFIX_UDP_NATTED "udp_natted" |
#define | LOW_PORT 12000 |
Lowest port used for GNUnet testing. More... | |
#define | HIGH_PORT 56000 |
Highest port used for GNUnet testing. More... | |
Functions | |
static enum GNUNET_GenericReturnValue | hostkeys_load (struct GNUNET_TESTING_System *system) |
Testing includes a number of pre-created hostkeys for faster peer startup. More... | |
static void | hostkeys_unload (struct GNUNET_TESTING_System *system) |
Function to remove the loaded hostkeys. More... | |
static void | cfg_copy_iterator (void *cls, const char *section, const char *option, const char *value) |
Function to iterate over options. More... | |
struct GNUNET_TESTING_System * | GNUNET_TESTING_system_create_with_portrange (const char *testdir, const char *trusted_ip, const char *hostname, const struct GNUNET_TESTING_SharedService *shared_services, uint16_t lowport, uint16_t highport) |
Create a system handle. More... | |
struct GNUNET_TESTING_System * | GNUNET_TESTING_system_create (const char *testdir, const char *trusted_ip, const char *hostname, const struct GNUNET_TESTING_SharedService *shared_services) |
Create a system handle. More... | |
static void | cleanup_shared_service_instance (struct SharedServiceInstance *i) |
static enum GNUNET_GenericReturnValue | start_shared_service_instance (struct SharedServiceInstance *i) |
static void | stop_shared_service_instance (struct SharedServiceInstance *i) |
void | GNUNET_TESTING_system_destroy (struct GNUNET_TESTING_System *system, int remove_paths) |
Free system resources. More... | |
uint16_t | GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system) |
Reserve a TCP or UDP port for a peer. More... | |
void | GNUNET_TESTING_release_port (struct GNUNET_TESTING_System *system, uint16_t port) |
Release reservation of a TCP or UDP port for a peer (used during GNUNET_TESTING_peer_destroy()). More... | |
struct GNUNET_CRYPTO_EddsaPrivateKey * | GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system, uint32_t key_number, struct GNUNET_PeerIdentity *id) |
Testing includes a number of pre-created hostkeys for faster peer startup. More... | |
static void | update_config (void *cls, const char *section, const char *option, const char *value) |
Function to iterate over options. More... | |
static void | update_config_sections (void *cls, const char *section) |
Section iterator to set ACCEPT_FROM/ACCEPT_FROM6 to include the address of 'trusted_hosts' in all sections. More... | |
static struct SharedServiceInstance * | associate_shared_service (struct GNUNET_TESTING_System *system, struct SharedService *ss, struct GNUNET_CONFIGURATION_Handle *cfg) |
static int | GNUNET_TESTING_configuration_create_ (struct GNUNET_TESTING_System *system, struct GNUNET_CONFIGURATION_Handle *cfg, uint16_t **ports, unsigned int *nports) |
Create a new configuration using the given configuration as a template; ports and paths will be modified to select available ports on the local system. More... | |
int | GNUNET_TESTING_configuration_create (struct GNUNET_TESTING_System *system, struct GNUNET_CONFIGURATION_Handle *cfg) |
Create a new configuration using the given configuration as a template; ports and paths will be modified to select available ports on the local system. More... | |
struct GNUNET_TESTING_Peer * | GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system, struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t key_number, struct GNUNET_PeerIdentity *id, char **emsg) |
Configure a GNUnet peer. More... | |
void | GNUNET_TESTING_peer_get_identity (struct GNUNET_TESTING_Peer *peer, struct GNUNET_PeerIdentity *id) |
Obtain the peer identity from a peer handle. More... | |
int | GNUNET_TESTING_peer_start (struct GNUNET_TESTING_Peer *peer) |
Start the peer. More... | |
int | GNUNET_TESTING_peer_kill (struct GNUNET_TESTING_Peer *peer) |
Sends SIGTERM to the peer's main process. More... | |
int | GNUNET_TESTING_peer_wait (struct GNUNET_TESTING_Peer *peer) |
Waits for a peer to terminate. More... | |
int | GNUNET_TESTING_peer_stop (struct GNUNET_TESTING_Peer *peer) |
Stop the peer. More... | |
static void | disconn_status (void *cls, int connected) |
Function called whenever we connect to or disconnect from ARM. More... | |
int | GNUNET_TESTING_peer_stop_async (struct GNUNET_TESTING_Peer *peer, GNUNET_TESTING_PeerStopCallback cb, void *cb_cls) |
Stop a peer asynchronously using ARM API. More... | |
void | GNUNET_TESTING_peer_stop_async_cancel (struct GNUNET_TESTING_Peer *peer) |
Cancel a previous asynchronous peer stop request. More... | |
void | GNUNET_TESTING_peer_destroy (struct GNUNET_TESTING_Peer *peer) |
Destroy the peer. More... | |
int | GNUNET_TESTING_peer_run (const char *testdir, const char *cfgfilename, GNUNET_TESTING_TestMain tm, void *tm_cls) |
Start a single peer and run a test using the testing library. More... | |
static void | service_run_main (void *cls) |
Callback to be called when SCHEDULER has been started. More... | |
int | GNUNET_TESTING_service_run (const char *testdir, const char *service_name, const char *cfgfilename, GNUNET_TESTING_TestMain tm, void *tm_cls) |
Start a single service (no ARM, except of course if the given service name is 'arm') and run a test using the testing library. More... | |
static unsigned int | get_first_value (const char *line) |
Every line in the topology configuration starts with a string indicating which kind of information will be configured with this line. More... | |
static char * | get_key (const char *line) |
Every line in the topology configuration starts with a string indicating which kind of information will be configured with this line. More... | |
static char * | get_first_string_value (const char *line) |
Every line in the topology configuration starts with a string indicating which kind of information will be configured with this line. More... | |
static unsigned int | get_second_value (const char *line) |
Every line in the topology configuration starts with a string indicating which kind of information will be configured with this line. More... | |
static char * | get_value (const char *key, const char *line) |
Every line in the topology configuration starts with a string indicating which kind of information will be configured with this line. More... | |
static struct GNUNET_TESTING_NodeConnection * | get_connect_value (const char *line, struct GNUNET_TESTING_NetjailNode *node) |
Every line in the topology configuration starts with a string indicating which kind of information will be configured with this line. More... | |
static void | node_connections (const char *line, struct GNUNET_TESTING_NetjailNode *node) |
Every line in the topology configuration starts with a string indicating which kind of information will be configured with this line. More... | |
static int | log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value) |
A helper function to log information about individual nodes. More... | |
static int | log_namespaces (void *cls, const struct GNUNET_ShortHashCode *id, void *value) |
Helper function to log information about namespaces. More... | |
static int | log_topo (const struct GNUNET_TESTING_NetjailTopology *topology) |
Helper function to log the configuration in case of a problem with configuration. More... | |
static void | get_node_info (unsigned int num, const struct GNUNET_TESTING_NetjailTopology *topology, struct GNUNET_TESTING_NetjailNode **node_ex, struct GNUNET_TESTING_NetjailNamespace **namespace_ex, struct GNUNET_TESTING_NodeConnection **node_connections_ex) |
This function extracts information about a specific node from the topology. More... | |
struct GNUNET_TESTING_NetjailNode * | GNUNET_TESTING_get_node (unsigned int num, struct GNUNET_TESTING_NetjailTopology *topology) |
Get a node from the topology. More... | |
struct GNUNET_TESTING_NodeConnection * | GNUNET_TESTING_get_connections (unsigned int num, const struct GNUNET_TESTING_NetjailTopology *topology) |
Get the connections to other nodes for a specific node. More... | |
struct GNUNET_PeerIdentity * | GNUNET_TESTING_get_peer (unsigned int num, const struct GNUNET_TESTING_System *tl_system) |
Retrieve the peer identity from the test system with the unique node id. More... | |
int | free_nodes_cb (void *cls, const struct GNUNET_ShortHashCode *key, void *value) |
int | free_namespaces_cb (void *cls, const struct GNUNET_ShortHashCode *key, void *value) |
void | GNUNET_TESTING_free_topology (struct GNUNET_TESTING_NetjailTopology *topology) |
Deallocate memory of the struct GNUNET_TESTING_NetjailTopology. More... | |
unsigned int | GNUNET_TESTING_calculate_num (struct GNUNET_TESTING_NodeConnection *node_connection, struct GNUNET_TESTING_NetjailTopology *topology) |
Calculate the unique id identifying a node from a given connection. More... | |
char * | GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection, const char *prefix) |
Get the address for a specific communicator from a connection. More... | |
unsigned int | GNUNET_TESTING_get_additional_connects (unsigned int num, struct GNUNET_TESTING_NetjailTopology *topology) |
Get the number of unintentional additional connections the node waits for. More... | |
static void | parse_ac (struct GNUNET_TESTING_NetjailNode *p_node, const char *token) |
struct GNUNET_TESTING_NetjailTopology * | GNUNET_TESTING_get_topo_from_string (const char *input) |
Parse the topology data. More... | |
struct GNUNET_TESTING_NetjailTopology * | GNUNET_TESTING_get_topo_from_file (const char *filename) |
Getting the topology from file. More... | |
convenience API for writing testcases for GNUnet Many testcases need to start and stop a peer/service and this library is supposed to make that easier for TESTCASES.
Normal programs should always use functions from gnunet_{util,arm}_lib.h. This API is ONLY for writing testcases (or internal use of the testbed).
Definition in file testing.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "testing-api", __VA_ARGS__) |
#define LOW_PORT 12000 |
#define HIGH_PORT 56000 |
|
static |
Testing includes a number of pre-created hostkeys for faster peer startup.
This function loads such keys into memory from a file.
system | the testing system handle |
Definition at line 1 of file testing.c.
Referenced by GNUNET_TESTING_system_create_with_portrange().
|
static |
Function to remove the loaded hostkeys.
system | the testing system handle |
Definition at line 339 of file testing.c.
References GNUNET_break, GNUNET_DISK_file_unmap(), GNUNET_TESTING_System::hostkeys_data, GNUNET_TESTING_System::map, and GNUNET_TESTING_System::total_hostkeys.
Referenced by GNUNET_TESTING_service_run(), and GNUNET_TESTING_system_destroy().
|
static |
Function to iterate over options.
cls | closure |
section | name of the section |
option | name of the option |
value | value of the option |
Definition at line 359 of file testing.c.
References GNUNET_CONFIGURATION_set_value_string(), and value.
Referenced by associate_shared_service(), and GNUNET_TESTING_system_create_with_portrange().
|
static |
Definition at line 493 of file testing.c.
References SharedServiceInstance::cfg_fn, GNUNET_break, GNUNET_free, SharedServiceInstance::n_refs, SharedServiceInstance::port_str, SharedServiceInstance::proc, and SharedServiceInstance::unix_sock.
Referenced by associate_shared_service(), and GNUNET_TESTING_system_destroy().
|
static |
Definition at line 493 of file testing.c.
Referenced by GNUNET_TESTING_peer_start().
|
static |
Definition at line 536 of file testing.c.
References GNUNET_break, GNUNET_ERROR_TYPE_WARNING, GNUNET_OS_process_destroy(), GNUNET_OS_process_kill(), GNUNET_OS_process_wait(), GNUNET_TERM_SIG, LOG, SharedServiceInstance::n_refs, SharedServiceInstance::proc, SharedService::sname, and SharedServiceInstance::ss.
Referenced by GNUNET_TESTING_peer_kill(), and GNUNET_TESTING_system_destroy().
|
static |
Function to iterate over options.
Copies the options to the target configuration, updating PORT values as needed.
cls | the UpdateContext |
section | name of the section |
option | name of the option |
value | value of the option |
Definition at line 808 of file testing.c.
References GNUNET_array_append, GNUNET_asprintf(), GNUNET_break, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_free, GNUNET_OK, GNUNET_snprintf(), GNUNET_SYSERR, GNUNET_TESTING_reserve_port(), GNUNET_YES, PATH_MAX, uc, and value.
Referenced by GNUNET_TESTING_configuration_create_().
|
static |
Section iterator to set ACCEPT_FROM/ACCEPT_FROM6 to include the address of 'trusted_hosts' in all sections.
cls | the UpdateContext |
section | name of the section |
Definition at line 905 of file testing.c.
References GNUNET_asprintf(), GNUNET_assert, GNUNET_break, GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_have_value(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_strdup, GNUNET_YES, key, and uc.
Referenced by GNUNET_TESTING_configuration_create_().
|
static |
Definition at line 1011 of file testing.c.
References cfg, SharedService::cfg, cfg_copy_iterator(), SharedServiceInstance::cfg_fn, cleanup_shared_service_instance(), GNUNET_array_append, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_dup(), GNUNET_CONFIGURATION_iterate_section_values(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_CONFIGURATION_write(), GNUNET_free, GNUNET_new, GNUNET_SYSERR, GNUNET_TESTING_reserve_port(), SharedService::instances, SharedService::n_instances, SharedService::n_peers, port, SharedServiceInstance::port_str, SharedService::share, SharedService::sname, SharedServiceInstance::ss, GNUNET_TESTING_System::tmppath, and SharedServiceInstance::unix_sock.
Referenced by GNUNET_TESTING_peer_configure().
|
static |
Create a new configuration using the given configuration as a template; ports and paths will be modified to select available ports on the local system.
The default configuration will be available in PATHS section under the option DEFAULTCONFIG after the call. GNUNET_HOME is also set in PATHS section to the temporary directory specific to this configuration. If we run out of "*port" numbers, return GNUNET_SYSERR.
This is primarily a helper function used internally by 'GNUNET_TESTING_peer_configure'.
system | system to use to coordinate resource usage |
cfg | template configuration to update |
ports | array with port numbers used in the created configuration. Will be updated upon successful return. Can be NULL |
nports | the size of the ‘ports’ array. Will be updated. |
Definition at line 1104 of file testing.c.
References cfg, GNUNET_asprintf(), GNUNET_CONFIGURATION_iterate(), GNUNET_CONFIGURATION_iterate_sections(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_free, GNUNET_OK, UpdateContext::nports, GNUNET_TESTING_System::path_counter, UpdateContext::ports, UpdateContext::system, GNUNET_TESTING_System::tmppath, uc, update_config(), and update_config_sections().
Referenced by GNUNET_TESTING_configuration_create(), and GNUNET_TESTING_peer_configure().
|
static |
Function called whenever we connect to or disconnect from ARM.
cls | closure |
connected | GNUNET_YES if connected, GNUNET_NO if disconnected, GNUNET_SYSERR on error. |
Definition at line 1503 of file testing.c.
References GNUNET_ARM_disconnect(), GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTING_peer_kill(), GNUNET_TESTING_peer_wait(), GNUNET_YES, and peer.
Referenced by GNUNET_TESTING_peer_stop_async().
|
static |
Callback to be called when SCHEDULER has been started.
cls | the ServiceContext |
Definition at line 1634 of file testing.c.
References sc.
Referenced by GNUNET_TESTING_service_run().
|
static |
Every line in the topology configuration starts with a string indicating which kind of information will be configured with this line.
Configuration values following this string are seperated by special sequences of characters. An integer value seperated by ':' is returned by this function.
line | The line of configuration. |
Definition at line 1734 of file testing.c.
References GNUNET_assert, GNUNET_free, GNUNET_malloc, line, and ret.
Referenced by GNUNET_TESTING_get_topo_from_string().
|
static |
Every line in the topology configuration starts with a string indicating which kind of information will be configured with this line.
This string is returned by this function.
line | The line of configuration. |
Definition at line 1761 of file testing.c.
References GNUNET_free, GNUNET_malloc, line, and ret.
Referenced by GNUNET_TESTING_get_topo_from_string(), and reconnect().
|
static |
Every line in the topology configuration starts with a string indicating which kind of information will be configured with this line.
Configuration values following this string are seperated by special sequences of characters. A string value seperated by ':' is returned by this function.
line | The line of configuration. |
Definition at line 1792 of file testing.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_malloc, line, LOG, and ret.
Referenced by GNUNET_TESTING_get_topo_from_string().
|
static |
Every line in the topology configuration starts with a string indicating which kind of information will be configured with this line.
Configuration values following this string are seperated by special sequences of characters. A second integer value seperated by ':' from a first value is returned by this function.
line | The line of configuration. |
Definition at line 1826 of file testing.c.
References GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_strdup, line, LOG, and ret.
Referenced by GNUNET_TESTING_get_topo_from_string().
|
static |
Every line in the topology configuration starts with a string indicating which kind of information will be configured with this line.
Configuration values following this string are seperated by special sequences of characters. A value might be a key value pair. This function returns the value for a specific key in a configuration line.
key | The key of the key value pair. |
Definition at line 1857 of file testing.c.
References GNUNET_strdup, key, and line.
Referenced by GNUNET_TESTING_get_topo_from_string(), and parse_ac().
|
static |
Every line in the topology configuration starts with a string indicating which kind of information will be configured with this line.
Configuration values following this string are seperated by special sequences of characters. A value might be a key value pair. A special key is the 'connect' key which can appear more than once. The value is the information about a connection via some protocol to some other node. This function returns the struct GNUNET_TESTING_NodeConnection which holds the information of the connect value.
value | The value of the connect key value pair. |
Definition at line 1897 of file testing.c.
References GNUNET_TESTING_NodeConnection::address_prefixes_head, GNUNET_TESTING_NodeConnection::address_prefixes_tail, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log_strerror, GNUNET_new, GNUNET_strdup, GNUNET_TESTING_GLOBAL_NODE, GNUNET_TESTING_SUBNET_NODE, line, LOG, GNUNET_TESTING_NodeConnection::namespace_n, GNUNET_TESTING_NetjailNode::namespace_n, GNUNET_TESTING_NodeConnection::node, GNUNET_TESTING_NodeConnection::node_n, GNUNET_TESTING_NetjailNode::node_n, GNUNET_TESTING_NodeConnection::node_type, and prefix.
Referenced by node_connections().
|
static |
Every line in the topology configuration starts with a string indicating which kind of information will be configured with this line.
Configuration values following this string are seperated by special sequences of characters. A value might be a key value pair. A special key is the 'connect' key. The value is the information about a connections via some protocol to other nodes. Each connection itself is a key value pair separated by the character '|' and surrounded by the characters '{' and '}'. The struct GNUNET_TESTING_NodeConnection holds the information of each connection value. This function extracts the values of each connection into a DLL of struct GNUNET_TESTING_NodeConnection which will be added to a node.
line | The line of configuration. |
node | The struct GNUNET_TESTING_NetjailNode to which the DLL of struct GNUNET_TESTING_NodeConnection will be added. |
Definition at line 2006 of file testing.c.
References get_connect_value(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_strdup, line, LOG, GNUNET_TESTING_NodeConnection::node, GNUNET_TESTING_NetjailNode::node_connections_head, GNUNET_TESTING_NetjailNode::node_connections_tail, and value.
Referenced by get_node_info(), GNUNET_TESTING_get_additional_connects(), GNUNET_TESTING_get_connections(), GNUNET_TESTING_get_node(), and GNUNET_TESTING_get_topo_from_string().
|
static |
A helper function to log information about individual nodes.
cls | This is not used actually. |
id | The key of this value in the map. |
value | A struct GNUNET_TESTING_NetjailNode which holds information about a node. return GNUNET_YES to continue with iterating, GNUNET_NO otherwise. |
Definition at line 2059 of file testing.c.
References GNUNET_TESTING_AddressPrefix::address_prefix, GNUNET_TESTING_NodeConnection::address_prefixes_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_YES, GNUNET_TESTING_NetjailNode::is_global, LOG, GNUNET_TESTING_NodeConnection::namespace_n, GNUNET_TESTING_NetjailNode::namespace_n, GNUNET_TESTING_AddressPrefix::next, GNUNET_TESTING_NodeConnection::next, GNUNET_TESTING_NetjailNode::node_connections_head, GNUNET_TESTING_NodeConnection::node_n, GNUNET_TESTING_NetjailNode::node_n, GNUNET_TESTING_NodeConnection::node_type, GNUNET_TESTING_NetjailNode::plugin, and value.
Referenced by log_namespaces(), and log_topo().
|
static |
Helper function to log information about namespaces.
cls | This is not used actually. |
id | The key of this value in the map. |
value | A struct GNUNET_TESTING_NetjailNamespace which holds information about a subnet. return GNUNET_YES to continue with iterating, GNUNET_NO otherwise. |
Definition at line 2104 of file testing.c.
References GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_YES, log_nodes(), and value.
Referenced by log_topo().
|
static |
Helper function to log the configuration in case of a problem with configuration.
topology | The struct GNUNET_TESTING_NetjailTopology holding the configuration information. |
Definition at line 2119 of file testing.c.
References GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_YES, LOG, log_namespaces(), log_nodes(), and topology.
Referenced by get_node_info().
|
static |
This function extracts information about a specific node from the topology.
num | The global index number of the node. | |
[out] | node_ex | A struct GNUNET_TESTING_NetjailNode with information about the node. |
[out] | namespace_ex | A struct GNUNET_TESTING_NetjailNamespace with information about the namespace the node is in or NULL, if the node is a global node. |
[out] | node_connections_ex | A struct GNUNET_TESTING_NodeConnection with information about the connection of this node to other nodes. |
Definition at line 2147 of file testing.c.
References GNUNET_TESTING_NetjailNode::additional_connects, GNUNET_CONTAINER_multishortmap_get(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, consensus-simulation::int, LOG, log_topo(), GNUNET_TESTING_NodeConnection::namespace_n, GNUNET_TESTING_NodeConnection::node, node_connections(), GNUNET_TESTING_NetjailNode::node_connections_head, and topology.
Referenced by GNUNET_TESTING_get_additional_connects(), GNUNET_TESTING_get_connections(), and GNUNET_TESTING_get_node().
struct GNUNET_TESTING_NetjailNode* GNUNET_TESTING_get_node | ( | unsigned int | num, |
struct GNUNET_TESTING_NetjailTopology * | topology | ||
) |
Get a node from the topology.
num | The specific node we want the connections for. |
topology | The topology we get the connections from. |
Definition at line 2229 of file testing.c.
References get_node_info(), GNUNET_TESTING_NodeConnection::node, node_connections(), and topology.
struct GNUNET_TESTING_NodeConnection* GNUNET_TESTING_get_connections | ( | unsigned int | num, |
const struct GNUNET_TESTING_NetjailTopology * | topology | ||
) |
Get the connections to other nodes for a specific node.
num | The specific node we want the connections for. |
topology | The topology we get the connections from. |
Definition at line 2251 of file testing.c.
References get_node_info(), GNUNET_ERROR_TYPE_DEBUG, LOG, GNUNET_TESTING_NodeConnection::node, node_connections(), and topology.
Referenced by backchannel_check_run(), and connect_peers_run().
struct GNUNET_PeerIdentity* GNUNET_TESTING_get_peer | ( | unsigned int | num, |
const struct GNUNET_TESTING_System * | tl_system | ||
) |
Retrieve the peer identity from the test system with the unique node id.
Retrieve peer identity from the test system with the unique node id.
num | The unique node id. |
tl_system | The test system. |
Definition at line 2276 of file testing.c.
References GNUNET_CRYPTO_eddsa_key_get_public(), GNUNET_free, GNUNET_new, GNUNET_TESTING_hostkey_get(), and peer.
Referenced by add_search_string(), connect_peers_run(), and notify_connect().
int free_nodes_cb | ( | void * | cls, |
const struct GNUNET_ShortHashCode * | key, | ||
void * | value | ||
) |
Definition at line 2294 of file testing.c.
References GNUNET_TESTING_AddressPrefix::address_prefix, GNUNET_TESTING_NodeConnection::address_prefixes_head, GNUNET_TESTING_NodeConnection::address_prefixes_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_OK, GNUNET_TESTING_NetjailNode::node_connections_head, GNUNET_TESTING_NetjailNode::node_connections_tail, GNUNET_TESTING_NetjailNode::plugin, and value.
Referenced by free_namespaces_cb(), and GNUNET_TESTING_free_topology().
int free_namespaces_cb | ( | void * | cls, |
const struct GNUNET_ShortHashCode * | key, | ||
void * | value | ||
) |
Definition at line 2326 of file testing.c.
References free_nodes_cb(), GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_free, GNUNET_OK, and value.
Referenced by GNUNET_TESTING_free_topology().
void GNUNET_TESTING_free_topology | ( | struct GNUNET_TESTING_NetjailTopology * | topology | ) |
Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.
topology | The GNUNET_TESTING_NetjailTopology to be deallocated. |
Definition at line 2347 of file testing.c.
References free_namespaces_cb(), free_nodes_cb(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_free, and topology.
unsigned int GNUNET_TESTING_calculate_num | ( | struct GNUNET_TESTING_NodeConnection * | node_connection, |
struct GNUNET_TESTING_NetjailTopology * | topology | ||
) |
Calculate the unique id identifying a node from a given connection.
node_connection | The connection we calculate the id from. |
topology | The topology we get all needed information from. |
Definition at line 2361 of file testing.c.
References m, GNUNET_TESTING_NodeConnection::namespace_n, GNUNET_TESTING_NodeConnection::node_n, and topology.
Referenced by connect_peers_run(), and notify_connect().
char* GNUNET_TESTING_get_address | ( | struct GNUNET_TESTING_NodeConnection * | connection, |
const char * | prefix | ||
) |
Get the address for a specific communicator from a connection.
connection | The connection we like to have the address from. |
prefix | The communicator protocol prefix. |
Definition at line 2387 of file testing.c.
References CONNECT_ADDRESS_TEMPLATE, GNUNET_asprintf(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, KNOWN_CONNECT_ADDRESS_TEMPLATE, LOG, GNUNET_TESTING_NodeConnection::namespace_n, GNUNET_TESTING_NetjailNode::namespace_n, GNUNET_TESTING_NodeConnection::node, GNUNET_TESTING_NodeConnection::node_n, GNUNET_TESTING_NetjailNode::node_n, prefix, PREFIX_TCP, PREFIX_TCP_NATTED, PREFIX_UDP, PREFIX_UDP_NATTED, and ROUTER_CONNECT_ADDRESS_TEMPLATE.
Referenced by connect_peers_run().
unsigned int GNUNET_TESTING_get_additional_connects | ( | unsigned int | num, |
struct GNUNET_TESTING_NetjailTopology * | topology | ||
) |
Get the number of unintentional additional connections the node waits for.
num | The specific node we want the additional connects for. |
Definition at line 2447 of file testing.c.
References GNUNET_TESTING_NetjailNode::additional_connects, get_node_info(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, LOG, node_connections(), and topology.
|
static |
Definition at line 2478 of file testing.c.
References GNUNET_TESTING_NetjailNode::additional_connects, get_value(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log_strerror, LOG, and ret.
Referenced by GNUNET_TESTING_get_topo_from_string().
struct GNUNET_TESTING_NetjailTopology* GNUNET_TESTING_get_topo_from_string | ( | const char * | input | ) |
Parse the topology data.
FIXME: this could use a "to_string".
data | The topology data. |
Definition at line 2515 of file testing.c.
References GNUNET_TESTING_NetjailTopology::additional_connects, data, get_first_string_value(), get_first_value(), get_key(), get_second_value(), get_value(), GNUNET_break, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multishortmap_contains(), GNUNET_CONTAINER_multishortmap_create(), GNUNET_CONTAINER_multishortmap_get(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_new, GNUNET_NO, GNUNET_strdup, GNUNET_YES, GNUNET_TESTING_NetjailNode::is_global, key, LOG, GNUNET_TESTING_NetjailTopology::map_globals, GNUNET_TESTING_NetjailTopology::map_namespaces, GNUNET_TESTING_NetjailNode::namespace_n, GNUNET_TESTING_NetjailTopology::namespaces_n, node_connections(), GNUNET_TESTING_NetjailNode::node_n, GNUNET_TESTING_NetjailTopology::nodes_m, GNUNET_TESTING_NetjailTopology::nodes_x, parse_ac(), GNUNET_TESTING_NetjailNode::plugin, GNUNET_TESTING_NetjailTopology::plugin, ret, GNUNET_TESTING_NetjailRouter::tcp_port, GNUNET_TESTING_NetjailRouter::udp_port, and value.
Referenced by GNUNET_TESTING_get_topo_from_file().
struct GNUNET_TESTING_NetjailTopology* GNUNET_TESTING_get_topo_from_file | ( | const char * | filename | ) |
Getting the topology from file.
filename | The name of the topology file. |
Definition at line 2786 of file testing.c.
References _, data, filename, fs, GNUNET_DISK_file_size(), GNUNET_DISK_file_test(), GNUNET_DISK_fn_read(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_TESTING_get_topo_from_string(), GNUNET_YES, and LOG.