GNUnet 0.24.1-14-gdb0ea5ed9
plugin_testing_transport_just_run.c File Reference
#include "platform.h"
#include "gnunet_testing_barrier.h"
#include "gnunet_testing_netjail_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_transport_application_service.h"
#include "transport-testing2.h"
#include "transport-testing-cmds.h"
#include "gnunet_core_service.h"
Include dependency graph for plugin_testing_transport_just_run.c:

Go to the source code of this file.

Data Structures

struct  Sender
 

Macros

#define LOG(kind, ...)   GNUNET_log (kind, __VA_ARGS__)
 Generic logging shortcut. More...
 
#define BASE_DIR   "testdir"
 
#define TOPOLOGY_CONFIG   "test_transport_simple_send_topo.conf"
 
#define TIMEOUT   GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600)
 
#define MAX_RECEIVED   1000
 
#define MESSAGE_SIZE   65000
 

Functions

static int check_test (void *cls, const struct GNUNET_TRANSPORT_TESTING_PerformanceTestMessage *message)
 Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being received. More...
 
struct GNUNET_TESTING_BarrierList * get_waiting_for_barriers ()
 
static void all_peers_started ()
 Callback to set the flag indicating all peers started. More...
 
static void handle_result (void *cls, enum GNUNET_GenericReturnValue rv)
 Function called with the final result of the test. More...
 
static void all_local_tests_prepared ()
 Callback from start peer cmd for signaling a peer got connected. More...
 
static void child_completed_callback (void *cls, enum GNUNET_OS_ProcessStatusType type, long unsigned int exit_code)
 
static int check_encrypted (void *cls, struct GNUNET_MessageHeader *header)
 Function called to check a message being received. More...
 
static void core_receive_continue (struct GNUNET_PeerIdentity *peer)
 
static void handle_encrypted (void *cls, struct GNUNET_MessageHeader *header)
 Function called to handle a message being received. More...
 
static void handle_ephemeral_key (void *cls, struct GNUNET_MessageHeader *header)
 
static void handle_ping (void *cls, struct GNUNET_MessageHeader *header)
 
static void handle_pong (void *cls, struct GNUNET_MessageHeader *header)
 
static struct GNUNET_TESTING_Interpreterstart_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message, const char *router_ip, const char *node_ip, const char *m, const char *n, const char *local_m, const char *topology_data, unsigned int *read_file, GNUNET_TESTING_cmd_helper_finish_cb finished_cb)
 Function to start a local test case. More...
 
void * libgnunet_test_transport_plugin_cmd_just_run_init (void *cls)
 Entry point for the plugin. More...
 
void * libgnunet_test_transport_plugin_cmd_just_run_done (void *cls)
 Exit point from the plugin. More...
 

Variables

static struct GNUNET_TESTING_Command block_script
 
static struct GNUNET_TESTING_Command connect_peers
 
static struct GNUNET_TESTING_Command local_prepared
 
static struct GNUNET_TESTING_Command start_peer
 
static struct GNUNET_TESTING_Interpreteris
 
static struct GNUNET_CONTAINER_MultiPeerMapsenders
 

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log (kind, __VA_ARGS__)

Generic logging shortcut.

Definition at line 39 of file plugin_testing_transport_just_run.c.

◆ BASE_DIR

#define BASE_DIR   "testdir"

Definition at line 41 of file plugin_testing_transport_just_run.c.

◆ TOPOLOGY_CONFIG

#define TOPOLOGY_CONFIG   "test_transport_simple_send_topo.conf"

Definition at line 43 of file plugin_testing_transport_just_run.c.

◆ TIMEOUT

Definition at line 45 of file plugin_testing_transport_just_run.c.

◆ MAX_RECEIVED

#define MAX_RECEIVED   1000

Definition at line 47 of file plugin_testing_transport_just_run.c.

◆ MESSAGE_SIZE

#define MESSAGE_SIZE   65000

Definition at line 49 of file plugin_testing_transport_just_run.c.

Function Documentation

◆ check_test()

static int check_test ( void *  cls,
const struct GNUNET_TRANSPORT_TESTING_PerformanceTestMessage message 
)
static

Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being received.

Definition at line 87 of file plugin_testing_transport_just_run.c.

90{
91 return GNUNET_OK;
92}
@ GNUNET_OK

References GNUNET_OK.

◆ get_waiting_for_barriers()

struct GNUNET_TESTING_BarrierList * get_waiting_for_barriers ( )

Definition at line 96 of file plugin_testing_transport_just_run.c.

97{
98 struct GNUNET_TESTING_BarrierList*barriers;
99 struct GNUNET_TESTING_BarrierListEntry *ble;
100
101 barriers = GNUNET_new (struct GNUNET_TESTING_BarrierList);
102 ble = GNUNET_new (struct GNUNET_TESTING_BarrierListEntry);
103 ble->barrier_name = "ready-to-connect";
104 ble->expected_reaches = 1;
105 GNUNET_CONTAINER_DLL_insert (barriers->head,
106 barriers->tail,
107 ble);
108
109 ble = GNUNET_new (struct GNUNET_TESTING_BarrierListEntry);
110 ble->barrier_name = "test-case-finished";
111 ble->expected_reaches = 1;
112 GNUNET_CONTAINER_DLL_insert (barriers->head,
113 barriers->tail,
114 ble);
115 return barriers;
116}
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.

References GNUNET_CONTAINER_DLL_insert, and GNUNET_new.

Referenced by libgnunet_test_transport_plugin_cmd_just_run_init().

Here is the caller graph for this function:

◆ all_peers_started()

static void all_peers_started ( )
static

Callback to set the flag indicating all peers started.

Will be called via the plugin api.

Definition at line 124 of file plugin_testing_transport_just_run.c.

125{
126}

◆ handle_result()

static void handle_result ( void *  cls,
enum GNUNET_GenericReturnValue  rv 
)
static

Function called with the final result of the test.

Parameters
clsthe struct MainParams
rvGNUNET_OK if the test passed

Definition at line 136 of file plugin_testing_transport_just_run.c.

138{
139 struct TestState *ts = cls;
140
142 "Local test exits with status %d\n",
143 rv);
144
145 ts->finished_cb (rv);
146 GNUNET_free (ts->testdir);
147 GNUNET_free (ts->cfgname);
149 GNUNET_free (ts);
150}
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_free(ptr)
Wrapper around free.
char * cfgname
The name for the configuration file of the specific node.
char * testdir
The name for a specific test environment directory.
struct GNUNET_TESTING_NetjailTopology * topology
The complete topology information.
void GNUNET_TESTING_free_topology(struct GNUNET_TESTING_NetjailTopology *topology)
Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.

References TestState::cfgname, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_TESTING_free_topology(), TestState::testdir, and TestState::topology.

Referenced by start_testcase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ all_local_tests_prepared()

static void all_local_tests_prepared ( )
static

Callback from start peer cmd for signaling a peer got connected.

static void * notify_connect (struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_PeerIdentity *peer) { const struct ConnectPeersState *cps; const struct GNUNET_TESTING_Command *cmd;

cmd = GNUNET_TESTING_interpreter_lookup_command (is, "connect-peers"); GNUNET_TRANSPORT_get_trait_connect_peer_state (cmd, &cps); void *ret = NULL;

cps->notify_connect (is, peer); return ret; } Callback to set the flag indicating all peers are prepared to finish. Will be called via the plugin api.

Definition at line 180 of file plugin_testing_transport_just_run.c.

181{
182 const struct GNUNET_TESTING_LocalPreparedState *lfs;
183
184 GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared,
185 &lfs);
186 GNUNET_assert (NULL != &lfs->ac);
187 if (NULL == lfs->ac.cont)
189 else
191 GNUNET_TESTING_AsyncContext *) &lfs->ac);
192}
void GNUNET_TESTING_async_finish(struct GNUNET_TESTING_AsyncContext *ac)
The asynchronous command of ac has finished.
void GNUNET_TESTING_async_fail(struct GNUNET_TESTING_AsyncContext *ac)
The asynchronous command of ac has failed.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_TESTING_Command local_prepared
State each asynchronous command must have in its closure.

References GNUNET_assert, GNUNET_TESTING_async_fail(), GNUNET_TESTING_async_finish(), and local_prepared.

Here is the call graph for this function:

◆ child_completed_callback()

static void child_completed_callback ( void *  cls,
enum GNUNET_OS_ProcessStatusType  type,
long unsigned int  exit_code 
)
static

Definition at line 196 of file plugin_testing_transport_just_run.c.

199{
200
201}

Referenced by start_testcase().

Here is the caller graph for this function:

◆ check_encrypted()

static int check_encrypted ( void *  cls,
struct GNUNET_MessageHeader header 
)
static

Function called to check a message being received.

Definition at line 210 of file plugin_testing_transport_just_run.c.

211{
212 return GNUNET_OK;
213}

References GNUNET_OK.

◆ core_receive_continue()

static void core_receive_continue ( struct GNUNET_PeerIdentity peer)
static

Definition at line 217 of file plugin_testing_transport_just_run.c.

218{
219 const struct GNUNET_TESTING_StartPeerState *sps;
220
221 GNUNET_TRANSPORT_get_trait_state (&start_peer,
222 &sps);
223
225 "Executing core receive continue\n");
226
227 GNUNET_TRANSPORT_core_receive_continue (sps->th, peer);
228}
static struct GNUNET_TESTING_Command start_peer
#define LOG(kind,...)
Generic logging shortcut.
Handle for a peer controlled via ARM.
struct GNUNET_TESTING_Peer * peer
struct GNUNET_TESTING_Peer returned by GNUNET_TESTING_peer_configure.
struct GNUNET_TRANSPORT_CoreHandle * th
Peer's transport service handle.

References GNUNET_ERROR_TYPE_DEBUG, LOG, GNUNET_TESTING_StartPeerState::peer, start_peer, and GNUNET_TESTING_StartPeerState::th.

Referenced by handle_encrypted(), handle_ephemeral_key(), handle_ping(), and handle_pong().

Here is the caller graph for this function:

◆ handle_encrypted()

static void handle_encrypted ( void *  cls,
struct GNUNET_MessageHeader header 
)
static

Function called to handle a message being received.

Definition at line 245 of file plugin_testing_transport_just_run.c.

246{
247 struct GNUNET_PeerIdentity *peer = cls;
248
250}
static void core_receive_continue(struct GNUNET_PeerIdentity *peer)
The identity of the host (wraps the signing key of the peer).

References core_receive_continue().

Here is the call graph for this function:

◆ handle_ephemeral_key()

static void handle_ephemeral_key ( void *  cls,
struct GNUNET_MessageHeader header 
)
static

Definition at line 254 of file plugin_testing_transport_just_run.c.

255{
256 struct GNUNET_PeerIdentity *peer = cls;
257
259}

References core_receive_continue().

Here is the call graph for this function:

◆ handle_ping()

static void handle_ping ( void *  cls,
struct GNUNET_MessageHeader header 
)
static

Definition at line 263 of file plugin_testing_transport_just_run.c.

264{
265 struct GNUNET_PeerIdentity *peer = cls;
266
268}

References core_receive_continue().

Here is the call graph for this function:

◆ handle_pong()

static void handle_pong ( void *  cls,
struct GNUNET_MessageHeader header 
)
static

Definition at line 272 of file plugin_testing_transport_just_run.c.

273{
274 struct GNUNET_PeerIdentity *peer = cls;
275
277}

References core_receive_continue().

Here is the call graph for this function:

◆ start_testcase()

static struct GNUNET_TESTING_Interpreter * start_testcase ( GNUNET_TESTING_cmd_helper_write_cb  write_message,
const char *  router_ip,
const char *  node_ip,
const char *  m,
const char *  n,
const char *  local_m,
const char *  topology_data,
unsigned int *  read_file,
GNUNET_TESTING_cmd_helper_finish_cb  finished_cb 
)
static

Function to start a local test case.

Parameters
write_messageCallback to send a message to the master loop.
router_ipGlobal address of the network namespace.
node_ipThe IP address of the node.
mThe number of the node in a network namespace.
nThe number of the network namespace.
local_mThe number of nodes in a network namespace.
topology_dataA file name for the file containing the topology configuration, or a string containing the topology configuration.
read_fileIf read_file is GNUNET_YES this string is the filename for the topology configuration, if read_file is GNUNET_NO the string contains the topology configuration.
finish_cbCallback function which writes a message from the helper process running on a netjail node to the master process * signaling that the test case running on the netjail node finished.
Returns
Returns the struct GNUNET_TESTING_Interpreter of the command loop running on this netjail node.

Definition at line 297 of file plugin_testing_transport_just_run.c.

306{
307
308 unsigned int n_int;
309 unsigned int m_int;
310 unsigned int local_m_int;
311 unsigned int num;
312 struct TestState *ts = GNUNET_new (struct TestState);
313 struct GNUNET_TESTING_NetjailTopology *topology;
314 unsigned int sscanf_ret = 0;
315 char **argv = NULL;
316 int argc = 0;
317
318 ts->finished_cb = finished_cb;
320 "n %s m %s\n",
321 n,
322 m);
323
324 if (GNUNET_YES == *read_file)
325 {
327 "read from file\n");
328 topology = GNUNET_TESTING_get_topo_from_file (topology_data);
329 }
330 else
331 topology = GNUNET_TESTING_get_topo_from_string (topology_data);
332
333 ts->topology = topology;
334
335 errno = 0;
336 sscanf_ret = sscanf (m, "%u", &m_int);
337 if (errno != 0)
338 {
340 }
341 GNUNET_assert (0 < sscanf_ret);
342 errno = 0;
343 sscanf_ret = sscanf (n, "%u", &n_int);
344 if (errno != 0)
345 {
347 }
348 GNUNET_assert (0 < sscanf_ret);
349 errno = 0;
350 sscanf_ret = sscanf (local_m, "%u", &local_m_int);
351 if (errno != 0)
352 {
354 }
355 GNUNET_assert (0 < sscanf_ret);
356
357 if (0 == n_int)
358 num = m_int;
359 else
360 num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
361
362 block_script = GNUNET_TESTING_cmd_block_until_external_trigger (
363 "block-script");
365 "start-peer",
366 "system-create",
367 num,
368 topology,
369 0,
370 GNUNET_NO);
371 local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
372 "local-test-prepared",
374
375
377 "test_transport_api_tcp_node1.conf");
378
380 "plugin cfgname: %s\n",
381 ts->cfgname);
382
384 "node ip: %s\n",
385 node_ip);
386
388 "%s%s%s",
389 BASE_DIR,
390 m,
391 n);
392
393 /*struct GNUNET_MQ_MessageHandler handlers[] = {
394 GNUNET_MQ_hd_fixed_size (ephemeral_key,
395 GNUNET_MESSAGE_TYPE_CORE_EPHEMERAL_KEY,
396 struct EphemeralKeyMessage,
397 NULL),
398 GNUNET_MQ_hd_fixed_size (ping,
399 GNUNET_MESSAGE_TYPE_CORE_PING,
400 struct PingMessage,
401 NULL),
402 GNUNET_MQ_hd_fixed_size (pong,
403 GNUNET_MESSAGE_TYPE_CORE_PONG,
404 struct PongMessage,
405 NULL),
406 GNUNET_MQ_handler_end ()
407 };*/
408
410 "system-create",
411 num,
412 node_ip,
413 ts->cfgname,
414 GNUNET_NO);
415
417 GNUNET_TESTING_cmd_system_create ("system-create",
418 ts->testdir),
420 GNUNET_TESTING_cmd_barrier_reached ("ready-to-connect-reached",
421 "ready-to-connect",
422 GNUNET_NO,
423 num,
424 GNUNET_NO,
427 GNUNET_TESTING_cmd_exec_bash_script ("script",
428 "block.sh",
429 argv,
430 argc,
433 GNUNET_TESTING_cmd_barrier_reached ("test-case-finished-reached",
434 "test-case-finished",
435 GNUNET_NO,
436 num,
437 GNUNET_NO,
440 "start-peer"),
441 GNUNET_TESTING_cmd_system_destroy ("system-destroy",
442 "system-create"),
444 };
445
446 ts->write_message = write_message;
447
449 TIMEOUT,
451 ts);
452 return is;
453}
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:103
static void write_message(const struct GNUNET_MessageHeader *message)
Callback to write a message to the parent process.
static void finished_cb(void *cls, enum GNUNET_GenericReturnValue rv)
static struct VoipCommand commands[]
List of supported commands.
struct GNUNET_TESTING_Interpreter * GNUNET_TESTING_run(const struct GNUNET_TESTING_Command *commands, struct GNUNET_TIME_Relative timeout, GNUNET_TESTING_ResultCallback rc, void *rc_cls)
Run the testsuite.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_end(void)
Create command array terminator.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_barrier_reached(const char *label, const char *barrier_label)
If this command is executed the the process is signaling the master process that it reached a barrier...
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_start_peer(const char *label, const char *system_label, uint32_t no, const char *node_ip, const char *cfgname, unsigned int broadcast)
Create command.
@ GNUNET_YES
@ GNUNET_NO
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_ERROR
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
enum GNUNET_GenericReturnValue read_file(char const *const filename, char **buffer)
Definition: pabc_helper.c:71
static struct GNUNET_TESTING_Command block_script
static void child_completed_callback(void *cls, enum GNUNET_OS_ProcessStatusType type, long unsigned int exit_code)
static void handle_result(void *cls, enum GNUNET_GenericReturnValue rv)
Function called with the final result of the test.
static struct GNUNET_TESTING_Command connect_peers
static struct GNUNET_TESTING_Interpreter * is
A command to be run by the interpreter.
Topology of our netjail setup.
unsigned int nodes_x
Number of global known nodes.
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_stop_peer(const char *label, const char *start_label)
Create command.
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_connect_peers(const char *label, const char *start_peer_label, const char *create_label, uint32_t num, struct GNUNET_TESTING_NetjailTopology *topology, unsigned int additional_connects, unsigned int wait_for_connect)
Create command.

References BASE_DIR, block_script, TestState::cfgname, child_completed_callback(), commands, connect_peers, finished_cb(), GNUNET_asprintf(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log_strerror, GNUNET_new, GNUNET_NO, GNUNET_TESTING_cmd_barrier_reached(), GNUNET_TESTING_cmd_end(), GNUNET_TESTING_cmd_start_peer(), GNUNET_TESTING_run(), GNUNET_TRANSPORT_cmd_connect_peers(), GNUNET_TRANSPORT_cmd_stop_peer(), GNUNET_YES, handle_result(), is, local_prepared, LOG, m, GNUNET_TESTING_NetjailTopology::nodes_x, read_file(), start_peer, TestState::testdir, TIMEOUT, TestState::topology, and write_message().

Referenced by libgnunet_test_transport_plugin_cmd_just_run_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ libgnunet_test_transport_plugin_cmd_just_run_init()

void * libgnunet_test_transport_plugin_cmd_just_run_init ( void *  cls)

Entry point for the plugin.

Parameters
clsNULL
Returns
the exported block API

Definition at line 463 of file plugin_testing_transport_just_run.c.

464{
466
467 GNUNET_log_setup ("simple-send",
468 "DEBUG",
469 NULL);
470
473 api->get_waiting_for_barriers = get_waiting_for_barriers;
474 return api;
475}
enum GNUNET_GenericReturnValue GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
struct GNUNET_TESTING_BarrierList * get_waiting_for_barriers()
static struct GNUNET_TESTING_Interpreter * start_testcase(GNUNET_TESTING_cmd_helper_write_cb write_message, const char *router_ip, const char *node_ip, const char *m, const char *n, const char *local_m, const char *topology_data, unsigned int *read_file, GNUNET_TESTING_cmd_helper_finish_cb finished_cb)
Function to start a local test case.
The plugin API every test case plugin has to implement.
struct GNUNET_TESTING_Interpreter *(* start_testcase)(void *cls, const char *topology_data, uint32_t barrier_count, const struct GNUNET_ShortHashCode *barriers, GNUNET_TESTING_cmd_helper_write_cb write_message, GNUNET_TESTING_ResultCallback finish_cb, void *finish_cb_cls)
Function to be implemented for each test case plugin which starts the test case on a netjail node.

References get_waiting_for_barriers(), GNUNET_log_setup(), GNUNET_new, start_testcase(), and GNUNET_TESTING_PluginFunctions::start_testcase.

Here is the call graph for this function:

◆ libgnunet_test_transport_plugin_cmd_just_run_done()

void * libgnunet_test_transport_plugin_cmd_just_run_done ( void *  cls)

Exit point from the plugin.

Parameters
clsthe return value from #libgnunet_test_transport_plugin_just_run_init
Returns
NULL

Definition at line 485 of file plugin_testing_transport_just_run.c.

486{
488
489 GNUNET_free (api);
490 return NULL;
491}
void * cls
Closure to pass to start_testcase.

References GNUNET_TESTING_PluginFunctions::cls, and GNUNET_free.

Variable Documentation

◆ block_script

struct GNUNET_TESTING_Command block_script
static

Definition at line 51 of file plugin_testing_transport_just_run.c.

Referenced by start_testcase().

◆ connect_peers

struct GNUNET_TESTING_Command connect_peers
static

Definition at line 53 of file plugin_testing_transport_just_run.c.

Referenced by start_testcase().

◆ local_prepared

struct GNUNET_TESTING_Command local_prepared
static

Definition at line 55 of file plugin_testing_transport_just_run.c.

Referenced by all_local_tests_prepared(), and start_testcase().

◆ start_peer

struct GNUNET_TESTING_Command start_peer
static

Definition at line 57 of file plugin_testing_transport_just_run.c.

Referenced by core_receive_continue(), and start_testcase().

◆ is

struct GNUNET_TESTING_Interpreter* is
static

Definition at line 59 of file plugin_testing_transport_just_run.c.

Referenced by start_testcase().

◆ senders

struct GNUNET_CONTAINER_MultiPeerMap* senders
static

Definition at line 61 of file plugin_testing_transport_just_run.c.