aboutsummaryrefslogtreecommitdiff
path: root/src/service/transport/transport-testing-cmds.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/transport/transport-testing-cmds.h')
-rw-r--r--src/service/transport/transport-testing-cmds.h245
1 files changed, 245 insertions, 0 deletions
diff --git a/src/service/transport/transport-testing-cmds.h b/src/service/transport/transport-testing-cmds.h
new file mode 100644
index 000000000..6b6fcf4f1
--- /dev/null
+++ b/src/service/transport/transport-testing-cmds.h
@@ -0,0 +1,245 @@
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
21/**
22 * @file transport-testing.h
23 * @brief testing lib for transport service
24 * @author Matthias Wachs
25 * @author Christian Grothoff
26 */
27#ifndef TRANSPORT_TESTING_CMDS_H
28#define TRANSPORT_TESTING_CMDS_H
29#include "gnunet_testing_ng_lib.h"
30#include "gnunet_testing_plugin.h"
31
32typedef void *
33(*GNUNET_TRANSPORT_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is,
34 const struct GNUNET_PeerIdentity *peer);
35
36
37
38struct TestState
39{
40 /**
41 * Callback to write messages to the master loop.
42 *
43 */
44 GNUNET_TESTING_cmd_helper_write_cb write_message;
45
46 /**
47 * Callback to notify the helper test case has finished.
48 */
49 GNUNET_TESTING_cmd_helper_finish_cb finished_cb;
50
51 /**
52 * The name for a specific test environment directory.
53 *
54 */
55 char *testdir;
56
57 /**
58 * The name for the configuration file of the specific node.
59 *
60 */
61 char *cfgname;
62
63 /**
64 * The complete topology information.
65 */
66 struct GNUNET_TESTING_NetjailTopology *topology;
67};
68
69
70/**
71 * Create command.
72 *
73 * @param label name for command.
74 * @param system_label Label of the cmd to setup a test environment.
75 * @param no Decimal number representing the last byte of the IP address of this peer.
76 * @param node_ip The IP address of this node.
77 * @param handlers Handler for messages received by this peer.
78 * @param cfgname Configuration file name for this peer.
79 * @param notify_connect Method which will be called, when a peer connects.
80 * @param broadcast Flag indicating, if broadcast should be switched on.
81 * @return command.
82 */
83struct GNUNET_TESTING_Command
84GNUNET_TRANSPORT_cmd_start_peer (const char *label,
85 const char *system_label,
86 uint32_t no,
87 const char *node_ip,
88 struct GNUNET_MQ_MessageHandler *handlers,
89 const char *cfgname,
90 GNUNET_TRANSPORT_notify_connect_cb
91 notify_connect,
92 unsigned int broadcast);
93
94
95struct GNUNET_TESTING_Command
96GNUNET_TRANSPORT_cmd_stop_peer (const char *label,
97 const char *start_label);
98
99
100/**
101 * Create command
102 *
103 * @param label name for command
104 * @param start_peer_label Label of the cmd to start a peer.
105 * @param create_label Label of the cmd which started the test system.
106 * @param num Number globally identifying the node.
107 * @param topology The topology for the test setup.
108 * @param additional_connects Number of additional connects this cmd will wait for not triggered by this cmd.
109 * @return command.
110 */
111struct GNUNET_TESTING_Command
112GNUNET_TRANSPORT_cmd_connect_peers (
113 const char *label,
114 const char *start_peer_label,
115 const char *create_label,
116 uint32_t num,
117 struct GNUNET_TESTING_NetjailTopology *topology,
118 unsigned int additional_connects,
119 unsigned int wait_for_connect);
120
121
122/**
123 * Create command.
124 *
125 * @param label name for command.
126 * @param start_peer_label Label of the cmd to start a peer.
127 * @param create_label Label of the cmd which started the test system.
128 * @param num Number globally identifying the node.
129 * @param topology The topology for the test setup.
130 * @return command.
131 */
132struct GNUNET_TESTING_Command
133GNUNET_TRANSPORT_cmd_send_simple (const char *label,
134 const char *start_peer_label,
135 const char *create_label,
136 uint32_t num,
137 struct GNUNET_TESTING_NetjailTopology *
138 topology);
139
140/**
141 *
142 *
143 * @param label name for command.
144 * @param start_peer_label Label of the cmd to start a peer.
145 * @param create_label Label of the cmd which started the test system.
146 * @param num Number globally identifying the node.
147 * @param size The size of the test message to send.
148 * @param max_send The number of messages to send.
149 * @param topology The topology for the test setup.
150 * @return command.
151 */
152struct GNUNET_TESTING_Command
153GNUNET_TRANSPORT_cmd_send_simple_performance (const char *label,
154 const char *start_peer_label,
155 const char *create_label,
156 uint32_t num,
157 int size,
158 int max_send,
159 struct GNUNET_TESTING_NetjailTopology *
160 topology);
161
162
163/**
164 * Create command.
165 *
166 * @param label name for command.
167 * @param start_peer_label Label of the cmd to start a peer.
168 * @param create_label Label of the cmd to create the testing system.
169 * @param num Number globally identifying the node.
170 * @param node_n The number of the node in a network namespace.
171 * @param namespace_n The number of the network namespace.
172 * @param topology The topology for the test setup.
173 * @return command.
174 */
175struct GNUNET_TESTING_Command
176GNUNET_TRANSPORT_cmd_backchannel_check (const char *label,
177 const char *start_peer_label,
178 const char *create_label,
179 uint32_t num,
180 unsigned int node_n,
181 unsigned int namespace_n,
182 struct GNUNET_TESTING_NetjailTopology *
183 topology);
184
185
186/**
187 * Create headers for a trait with name @a name for
188 * statically allocated data of type @a type.
189 */
190#define GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT(name,type) \
191 enum GNUNET_GenericReturnValue \
192 GNUNET_TRANSPORT_get_trait_ ## name ( \
193 const struct GNUNET_TESTING_Command *cmd, \
194 type **ret); \
195 struct GNUNET_TESTING_Trait \
196 GNUNET_TRANSPORT_make_trait_ ## name ( \
197 type * value);
198
199
200/**
201 * Create C implementation for a trait with name @a name for statically
202 * allocated data of type @a type.
203 */
204#define GNUNET_TRANSPORT_MAKE_IMPL_SIMPLE_TRAIT(name,type) \
205 enum GNUNET_GenericReturnValue \
206 GNUNET_TRANSPORT_get_trait_ ## name ( \
207 const struct GNUNET_TESTING_Command *cmd, \
208 type **ret) \
209 { \
210 if (NULL == cmd->traits) return GNUNET_SYSERR; \
211 return cmd->traits (cmd->cls, \
212 (const void **) ret, \
213 GNUNET_S (name), \
214 0); \
215 } \
216 struct GNUNET_TESTING_Trait \
217 GNUNET_TRANSPORT_make_trait_ ## name ( \
218 type * value) \
219 { \
220 struct GNUNET_TESTING_Trait ret = { \
221 .trait_name = GNUNET_S (name), \
222 .ptr = (const void *) value \
223 }; \
224 return ret; \
225 }
226
227
228/**
229 * Call #op on all simple traits.
230 */
231#define GNUNET_TRANSPORT_SIMPLE_TRAITS(op) \
232 op (peer_id, const struct GNUNET_PeerIdentity) \
233 op (connected_peers_map, const struct GNUNET_CONTAINER_MultiShortmap) \
234 op (hello_size, const size_t) \
235 op (hello, const char) \
236 op (application_handle, const struct GNUNET_TRANSPORT_ApplicationHandle) \
237 op (connect_peer_state, const struct ConnectPeersState) \
238 op (state, const struct GNUNET_TESTING_StartPeerState) \
239 op (broadcast, const enum GNUNET_GenericReturnValue)
240
241GNUNET_TRANSPORT_SIMPLE_TRAITS (GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT)
242
243
244#endif
245/* end of transport_testing.h */