GNUnet 0.29.1-12-g57a93edc3
 
Loading...
Searching...
No Matches
plugin_testing_transport_just_run.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
26#include "platform.h"
27#include "gnunet_testing_barrier.h"
28#include "gnunet_testing_netjail_lib.h"
29#include "gnunet_util_lib.h"
31#include "transport-testing2.h"
33#include "gnunet_testing_barrier.h"
34#include "gnunet_core_service.h"
35
39#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
40
41#define BASE_DIR "testdir"
42
43#define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf"
44
45#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600)
46
47#define MAX_RECEIVED 1000
48
49#define MESSAGE_SIZE 65000
50
52
54
56
58
60
61static struct GNUNET_CONTAINER_MultiPeerMap *senders;
62
63struct Sender
64{
68 unsigned long long num_received;
69
74
79};
80
86static int
87check_test (void *cls,
88 const struct
90{
91 return GNUNET_OK;
92}
93
94
95struct GNUNET_TESTING_BarrierList*
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}
117
118
123static void
125{
126}
127
128
135static void
136handle_result (void *cls,
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}
151
152
179static void
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}
193
194
195static void
198 long unsigned int exit_code)
199{
200
201}
202
203
209static int
210check_encrypted (void *cls, struct GNUNET_MessageHeader *header)
211{
212 return GNUNET_OK;
213}
214
215
216static void
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}
229
230
231/*static void
232handle_core (void *cls, struct GNUNET_MessageHeader *header)
233{
234 struct GNUNET_PeerIdentity *peer = cls;
235
236 core_receive_continue (peer);
237 }*/
238
239
244static void
245handle_encrypted (void *cls, struct GNUNET_MessageHeader *header)
246{
247 struct GNUNET_PeerIdentity *peer = cls;
248
250}
251
252
253static void
255{
256 struct GNUNET_PeerIdentity *peer = cls;
257
259}
260
261
262static void
263handle_ping (void *cls, struct GNUNET_MessageHeader *header)
264{
265 struct GNUNET_PeerIdentity *peer = cls;
266
268}
269
270
271static void
272handle_pong (void *cls, struct GNUNET_MessageHeader *header)
273{
274 struct GNUNET_PeerIdentity *peer = cls;
275
277}
278
296static struct GNUNET_TESTING_Interpreter *
298 const char *router_ip,
299 const char *node_ip,
300 const char *m,
301 const char *n,
302 const char *local_m,
303 const char *topology_data,
304 unsigned int *read_file,
305 GNUNET_TESTING_cmd_helper_finish_cb finished_cb)
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}
454
455
462void *
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}
476
477
484void *
486{
488
489 GNUNET_free (api);
490 return NULL;
491}
492
493
494/* end of plugin_cmd_simple_send.c */
static enum GNUNET_GenericReturnValue read_file(const char *filename, char **contents, size_t *size)
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.
static uint32_t type
Type string converted to DNS type value.
static int exit_code
Global exit code.
Definition gnunet-qr.c:43
Core service; the main API for encrypted P2P communications.
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.
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.
Bandwidth allocation API for applications to interact with.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_log(kind,...)
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
enum GNUNET_GenericReturnValue GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
#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
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_OS_ProcessStatusType
Process status types.
static struct GNUNET_TESTING_Command block_script
void * libgnunet_test_transport_plugin_cmd_just_run_init(void *cls)
Entry point for the plugin.
static void child_completed_callback(void *cls, enum GNUNET_OS_ProcessStatusType type, long unsigned int exit_code)
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.
static void core_receive_continue(struct GNUNET_PeerIdentity *peer)
static void handle_result(void *cls, enum GNUNET_GenericReturnValue rv)
Function called with the final result of the test.
static struct GNUNET_TESTING_Command local_prepared
static struct GNUNET_TESTING_Command connect_peers
static void handle_encrypted(void *cls, struct GNUNET_MessageHeader *header)
Function called to handle a message being received.
static void all_local_tests_prepared()
Callback from start peer cmd for signaling a peer got connected.
struct GNUNET_TESTING_BarrierList * get_waiting_for_barriers()
static struct GNUNET_TESTING_Command start_peer
void * libgnunet_test_transport_plugin_cmd_just_run_done(void *cls)
Exit point from the plugin.
static int check_encrypted(void *cls, struct GNUNET_MessageHeader *header)
Function called to check a message being received.
static struct GNUNET_TESTING_Interpreter * is
static void handle_ephemeral_key(void *cls, struct GNUNET_MessageHeader *header)
static struct GNUNET_CONTAINER_MultiPeerMap * senders
#define LOG(kind,...)
Generic logging shortcut.
static void handle_pong(void *cls, struct GNUNET_MessageHeader *header)
static void all_peers_started()
Callback to set the flag indicating all peers started.
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.
static void handle_ping(void *cls, struct GNUNET_MessageHeader *header)
Header for all communications.
The identity of the host (wraps the signing key of the peer).
State each asynchronous command must have in its closure.
A command to be run by the interpreter.
void * cls
Closure for all commands with command-specific context information.
Global state of the interpreter, used by a command to access information about other commands.
Topology of our netjail setup.
unsigned int nodes_x
Number of global known nodes.
The plugin API every test case plugin has to implement.
void * cls
Closure to pass to start_testcase.
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.
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.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
unsigned long long num_received
Number of received messages from sender.
struct GNUNET_TIME_Absolute time_first
Time the first message was send.
struct GNUNET_TIME_Relative mean_time
Sample mean time the message traveled.
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_cmd_helper_write_cb)(const struct GNUNET_MessageHeader *message)
Callback function to write messages from the helper process running on a netjail node to the master p...
void GNUNET_TESTING_free_topology(struct GNUNET_TESTING_NetjailTopology *topology)
Deallocate memory of the struct GNUNET_TESTING_NetjailTopology.
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.