GNUnet 0.24.1-12-gebf1afa89
plugin_testing_transport_udp_backchannel.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 dependency graph for plugin_testing_transport_udp_backchannel.c:

Go to the source code of this file.

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "udp-backchannel", __VA_ARGS__)
 Generic logging shortcut. More...
 
#define BASE_DIR   "testdir"
 
#define TOPOLOGY_CONFIG   "test_transport_udp_backchannel_topo.conf"
 
#define TIMEOUT   GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600)
 

Functions

static int check_test (void *cls, const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
 Function called to check a message of type GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE being received. More...
 
static void handle_test (void *cls, const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
 Function called to handle 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 * notify_connect (struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_PeerIdentity *peer)
 Callback from start peer cmd for signaling a peer got connected. More...
 
static void all_local_tests_prepared ()
 Callback to set the flag indicating all peers are prepared to finish. More...
 
void * libgnunet_test_transport_plugin_cmd_udp_backchannel_init (void *cls)
 Entry point for the plugin. More...
 
 GNUNET_TESTING_MAKE_PLUGIN (libgnunet, udp_backchannel, GNUNET_TESTING_cmd_system_create("system-create", ts->testdir), GNUNET_TRANSPORT_cmd_start_peer("start-peer", "system-create", num, node_ip, handlers, ts->cfgname, notify_connect, GNUNET_NO), GNUNET_TESTING_cmd_send_peer_ready("send-peer-ready", write_message), block_send, connect_peers, GNUNET_TRANSPORT_cmd_backchannel_check("backchannel-check", "start-peer", "system-create", num, m_int, n_int, topology), local_prepared, GNUNET_TRANSPORT_cmd_stop_peer("stop-peer", "start-peer"), GNUNET_TESTING_cmd_system_destroy("system-destroy", "system-create"))
 
void * libgnunet_test_transport_plugin_cmd_udp_backchannel_done (void *cls)
 Exit point from the plugin. More...
 

Variables

static struct GNUNET_TESTING_Command block_send
 
static struct GNUNET_TESTING_Command connect_peers
 
static struct GNUNET_TESTING_Command local_prepared
 
static struct GNUNET_TESTING_Interpreteris
 

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "udp-backchannel", __VA_ARGS__)

Generic logging shortcut.

Definition at line 38 of file plugin_testing_transport_udp_backchannel.c.

◆ BASE_DIR

#define BASE_DIR   "testdir"

Definition at line 40 of file plugin_testing_transport_udp_backchannel.c.

◆ TOPOLOGY_CONFIG

#define TOPOLOGY_CONFIG   "test_transport_udp_backchannel_topo.conf"

Definition at line 42 of file plugin_testing_transport_udp_backchannel.c.

◆ TIMEOUT

Function Documentation

◆ check_test()

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

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

Definition at line 61 of file plugin_testing_transport_udp_backchannel.c.

63{
64 return GNUNET_OK;
65}
@ GNUNET_OK

References GNUNET_OK.

◆ handle_test()

static void handle_test ( void *  cls,
const struct GNUNET_TRANSPORT_TESTING_TestMessage message 
)
static

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

Definition at line 74 of file plugin_testing_transport_udp_backchannel.c.

76{
77 // struct GNUNET_TESTING_AsyncContext *ac;
78
79 /*GNUNET_TESTING_get_trait_async_context (&block_receive,
80 &ac);
81 if ((NULL == ac) || (NULL == ac->cont))
82 GNUNET_TESTING_async_fail (ac);
83 else
84 GNUNET_TESTING_async_finish (ac);*/
85}

◆ get_waiting_for_barriers()

struct GNUNET_TESTING_BarrierList * get_waiting_for_barriers ( )

Definition at line 89 of file plugin_testing_transport_udp_backchannel.c.

90{
91 // No Barrier
92 return GNUNET_new (struct GNUNET_TESTING_BarrierList);
93}
#define GNUNET_new(type)
Allocate a struct or union of the given type.

References GNUNET_new.

◆ 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 101 of file plugin_testing_transport_udp_backchannel.c.

102{
104
105 GNUNET_TESTING_get_trait_async_context (&block_send,
106 &ac);
107 GNUNET_assert (NULL != ac);
108 if ((NULL == ac->cont))
110 else
112}
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 block_send
State each asynchronous command must have in its closure.

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

Here is the call graph for this function:

◆ 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 122 of file plugin_testing_transport_udp_backchannel.c.

124{
125 struct TestState *ts = cls;
126
128 "Local test exits with status %d\n",
129 rv);
130
131 ts->finished_cb (rv);
132 GNUNET_free (ts->testdir);
133 GNUNET_free (ts->cfgname);
135 GNUNET_free (ts);
136}
#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.

Here is the call graph for this function:

◆ notify_connect()

static void * notify_connect ( struct GNUNET_TESTING_Interpreter is,
const struct GNUNET_PeerIdentity peer 
)
static

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

Definition at line 144 of file plugin_testing_transport_udp_backchannel.c.

146{
147 const struct ConnectPeersState *cps;
148
149 GNUNET_TRANSPORT_TESTING_get_trait_connect_peer_state (&connect_peers,
150 &cps);
151 void *ret = NULL;
152
153 cps->notify_connect (is,
154 peer);
155 return ret;
156}
static int ret
Final status code.
Definition: gnunet-arm.c:93
static struct GNUNET_TESTING_Command connect_peers
static struct GNUNET_TESTING_Interpreter * is
Struct to store information needed in callbacks.
GNUNET_TESTING_notify_connect_cb notify_connect

References connect_peers, is, ConnectPeersState::notify_connect, and ret.

Referenced by libgnunet_test_transport_plugin_cmd_udp_backchannel_init().

Here is the caller graph for this function:

◆ all_local_tests_prepared()

static void all_local_tests_prepared ( )
static

Callback to set the flag indicating all peers are prepared to finish.

Will be called via the plugin api.

Definition at line 163 of file plugin_testing_transport_udp_backchannel.c.

164{
165 const struct GNUNET_TESTING_LocalPreparedState *lfs;
166
167 GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared,
168 &lfs);
169 GNUNET_assert (NULL != &lfs->ac);
170 if (NULL == lfs->ac.cont)
172 else
174 GNUNET_TESTING_AsyncContext *) &lfs->ac);
175}
static struct GNUNET_TESTING_Command local_prepared

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

Here is the call graph for this function:

◆ libgnunet_test_transport_plugin_cmd_udp_backchannel_init()

void * libgnunet_test_transport_plugin_cmd_udp_backchannel_init ( void *  cls)

Entry point for the plugin.

Parameters
clsNULL
Returns
the exported block API

Definition at line 185 of file plugin_testing_transport_udp_backchannel.c.

186{
188
189 unsigned int n_int;
190 unsigned int m_int;
191 unsigned int local_m_int;
192 unsigned int num;
193 struct TestState *ts = GNUNET_new (struct TestState);
194 struct GNUNET_TESTING_NetjailTopology *topology;
195 unsigned int sscanf_ret = 0;
196
197 ts->finished_cb = finished_cb;
199 "n %s m %s\n",
200 n,
201 m);
202
203 if (GNUNET_YES == *read_file)
204 {
206 "read from file\n");
207 topology = GNUNET_TESTING_get_topo_from_file (topology_data);
208 }
209 else
210 topology = GNUNET_TESTING_get_topo_from_string (topology_data);
211
212 ts->topology = topology;
213
214 errno = 0;
215 sscanf_ret = sscanf (m, "%u", &m_int);
216 if (errno != 0)
217 {
219 }
220 GNUNET_assert (0 < sscanf_ret);
221 errno = 0;
222 sscanf_ret = sscanf (n, "%u", &n_int);
223 if (errno != 0)
224 {
226 }
227 GNUNET_assert (0 < sscanf_ret);
228 errno = 0;
229 sscanf_ret = sscanf (local_m, "%u", &local_m_int);
230 if (errno != 0)
231 {
233 }
234 GNUNET_assert (0 < sscanf_ret);
235
236
237 if (0 == n_int)
238 num = m_int;
239 else
240 num = (n_int - 1) * local_m_int + m_int + topology->nodes_x;
241
242 block_send = GNUNET_TESTING_cmd_block_until_external_trigger (
243 "block");
245 "start-peer",
246 "system-create",
247 num,
248 topology,
249 0,
250 GNUNET_YES);
251 local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
252 "local-test-prepared",
254
256 "test_transport_api_tcp_node1.conf");
257
259 "plugin cfgname: %s\n",
260 ts->cfgname);
261
263 "node ip: %s\n",
264 node_ip);
265
267 "%s%s%s",
268 BASE_DIR,
269 m,
270 n);
271
276 NULL),
278 };
279
281 GNUNET_TESTING_cmd_system_create ("system-create",
282 ts->testdir),
284 "system-create",
285 num,
286 node_ip,
287 handlers,
288 ts->cfgname,
290 GNUNET_NO),
291 GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready",
295 GNUNET_TRANSPORT_cmd_backchannel_check ("backchannel-check",
296 "start-peer",
297 "system-create",
298 num,
299 m_int,
300 n_int,
301 topology),
304 "start-peer"),
305 GNUNET_TESTING_cmd_system_destroy ("system-destroy",
306 "system-create"),
308 };
309
311}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
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_Command GNUNET_TESTING_cmd_end(void)
Create command array terminator.
struct GNUNET_TESTING_PluginFunctions * GNUNET_TESTING_make_plugin(const struct GNUNET_TESTING_Command *commands)
@ 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.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
enum GNUNET_GenericReturnValue read_file(char const *const filename, char **buffer)
Definition: pabc_helper.c:71
static void * notify_connect(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_PeerIdentity *peer)
Callback from start peer cmd for signaling a peer got connected.
#define LOG(kind,...)
Generic logging shortcut.
Message handler for a specific message type.
A command to be run by the interpreter.
Topology of our netjail setup.
unsigned int nodes_x
Number of global known nodes.
The plugin API every test case plugin has to implement.
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.
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_backchannel_check(const char *label, const char *start_peer_label, const char *create_label, uint32_t num, unsigned int node_n, unsigned int namespace_n, struct GNUNET_TESTING_NetjailTopology *topology)
Create command.
struct GNUNET_TESTING_Command GNUNET_TRANSPORT_cmd_start_peer(const char *label, const char *system_label, uint32_t no, const char *node_ip, struct GNUNET_MQ_MessageHandler *handlers, const char *cfgname, GNUNET_TRANSPORT_notify_connect_cb notify_connect, unsigned int broadcast)
Create command.
#define GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE
Message type used by GNUNET_TRANSPORT_TESTING_simple_send().

References BASE_DIR, block_send, TestState::cfgname, commands, connect_peers, finished_cb(), GNUNET_asprintf(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log_strerror, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_new, GNUNET_NO, GNUNET_TESTING_cmd_end(), GNUNET_TESTING_make_plugin(), GNUNET_TRANSPORT_cmd_backchannel_check(), GNUNET_TRANSPORT_cmd_connect_peers(), GNUNET_TRANSPORT_cmd_start_peer(), GNUNET_TRANSPORT_cmd_stop_peer(), GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE, GNUNET_YES, handlers, local_prepared, LOG, m, GNUNET_TESTING_NetjailTopology::nodes_x, notify_connect(), read_file(), TestState::testdir, TestState::topology, and write_message().

Here is the call graph for this function:

◆ GNUNET_TESTING_MAKE_PLUGIN()

GNUNET_TESTING_MAKE_PLUGIN ( libgnunet  ,
udp_backchannel  ,
GNUNET_TESTING_cmd_system_create("system-create", ts->testdir)  ,
GNUNET_TRANSPORT_cmd_start_peer("start-peer", "system-create", num, node_ip, handlers, ts->cfgname, notify_connect, GNUNET_NO ,
GNUNET_TESTING_cmd_send_peer_ready("send-peer-ready", write_message)  ,
block_send  ,
connect_peers  ,
GNUNET_TRANSPORT_cmd_backchannel_check("backchannel-check", "start-peer", "system-create", num, m_int, n_int, topology)  ,
local_prepared  ,
GNUNET_TRANSPORT_cmd_stop_peer("stop-peer", "start-peer")  ,
GNUNET_TESTING_cmd_system_destroy("system-destroy", "system-create")   
)

◆ libgnunet_test_transport_plugin_cmd_udp_backchannel_done()

void * libgnunet_test_transport_plugin_cmd_udp_backchannel_done ( void *  cls)

Exit point from the plugin.

Parameters
clsthe return value from #libgnunet_test_transport_plugin_block_test_init
Returns
NULL

Definition at line 355 of file plugin_testing_transport_udp_backchannel.c.

356{
358
359 GNUNET_free (api);
360 return NULL;
361}
void * cls
Closure to pass to start_testcase.

References GNUNET_TESTING_PluginFunctions::cls, and GNUNET_free.

Variable Documentation

◆ block_send

◆ connect_peers

◆ local_prepared

◆ is

struct GNUNET_TESTING_Interpreter* is
static

Definition at line 52 of file plugin_testing_transport_udp_backchannel.c.

Referenced by notify_connect().