GNUnet  0.20.0
testing.h
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 
24 #ifndef TESTING_H
25 #define TESTING_H
26 #include "gnunet_util_lib.h"
27 #include "gnunet_testing_plugin.h"
28 
30 
35 {
40 
41  /* followed by 0-terminated barrier name */
42 };
43 
49 {
54 
59 
64 
65  /* followed by 0-terminated barrier name */
66 };
67 
69 {
74 
79 
84 
85  /* followed by 0-terminated barrier name */
86 };
87 
89 
94 {
98  char *library_name;
99 
104 
109  char *node_ip;
110 
115  char *plugin_name;
116 
121  char *global_n;
122 
127  char *local_m;
128 
133  char *n;
134 
139  char *m;
140 };
141 
143 {
145 
147 
149 };
150 
151 
153 {
158 
163 
168 
173 
178 
182  const char *name;
183 
187  unsigned int running_on_master;
188 
192  unsigned int expected_reaches;
193 
197  unsigned int reached;
198 
204 
209  unsigned int number_to_be_reached;
210 
211  /*
212  * No barrier locally. Shadow created. Real barrier created elsewhere.
213  */
214  unsigned int shadow;
215 };
216 
217 
225 bool
227 
228 
234 bool
236 
237 
243 struct GNUNET_TESTING_Command *
245 
246 
256 void
258  unsigned int new_ip);
259 
260 
268 unsigned int
270 
271 
279 void
281  const char *barrier_name,
282  unsigned int global_node_number);
283 
284 
290 void
292  const char *barrier_name);
293 
294 
305 void
307  char *barrier_name,
308  unsigned int global_node_number,
309  unsigned int expected_reaches,
311 
312 
326  unsigned int node_number);
327 
328 
336 struct GNUNET_TESTING_Barrier *
338  const char *barrier_name);
339 
340 
347 void
349  struct GNUNET_TESTING_Barrier *barrier);
350 
351 
352 #endif
struct GNUNET_TESTING_Interpreter * is
static int write_message(uint16_t message_type, const char *data, size_t data_length)
Write message to the master process.
void(* GNUNET_TESTING_cmd_helper_write_cb)(struct GNUNET_MessageHeader *message, size_t msg_length)
Callback function to write messages from the helper process running on a netjail node to the master p...
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
#define GNUNET_PACKED
gcc-ism to get packed structs.
Message send by a child loop to inform the master loop how much GNUNET_CMDS_BARRIER_REACHED messages ...
Definition: testing.h:49
uint32_t expected_reaches
How often the child loop will reach the barrier.
Definition: testing.h:58
uint32_t node_number
The number of the node the barrier is running on.
Definition: testing.h:63
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED.
Definition: testing.h:53
Message send to a child loop to inform the child loop about a barrier being advanced.
Definition: testing.h:35
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE.
Definition: testing.h:39
struct CommandListEntry * prev
Definition: testing.h:146
struct CommandListEntry * next
Definition: testing.h:144
struct GNUNET_TESTING_Command * command
Definition: testing.h:148
Internal representation of the hash map.
Header for all communications.
const char * name
Name of the barrier.
Definition: testing.h:182
unsigned int shadow
Definition: testing.h:214
struct GNUNET_TESTING_Barrier * next
Pointer to the next prefix in the DLL.
Definition: testing.h:162
unsigned int number_to_be_reached
Number of commands which need to reach the barrier to change state.
Definition: testing.h:209
struct GNUNET_CONTAINER_MultiShortmap * nodes
Hash map containing the global known nodes which are not natted.
Definition: testing.h:177
struct CommandListEntry * cmds_tail
Tail of the DLL with local commands the barrier is attached too.
Definition: testing.h:172
struct CommandListEntry * cmds_head
Head of the DLL with local commands the barrier is attached too.
Definition: testing.h:167
unsigned int running_on_master
Is this barrier running on the master.
Definition: testing.h:187
double percentage_to_be_reached
Percentage of of commands which need to reach the barrier to change state.
Definition: testing.h:203
struct GNUNET_TESTING_Barrier * prev
Pointer to the previous prefix in the DLL.
Definition: testing.h:157
unsigned int reached
Number of commands which reached this barrier.
Definition: testing.h:197
unsigned int expected_reaches
Number of commands attached to this barrier.
Definition: testing.h:192
uint32_t expected_number_of_reached_messages
The number of reach messages which most likely will send.
Definition: testing.h:83
uint32_t node_number
The number of the node the barrier is reached.
Definition: testing.h:78
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED.
Definition: testing.h:73
A command to be run by the interpreter.
Global state of the interpreter, used by a command to access information about other commands.
Node in the netjail topology.
unsigned int node_number
The overall number of the node in the whole test system.
The plugin API every test case plugin has to implement.
Handle for a plugin.
Definition: testing.h:94
char * global_n
The number of namespaces.
Definition: testing.h:121
char * node_ip
IP address of the specific node the helper is running for.
Definition: testing.h:109
char * local_m
The number of local nodes per namespace.
Definition: testing.h:127
char * plugin_name
Name of the test case plugin.
Definition: testing.h:115
char * n
The number of the namespace this node is in.
Definition: testing.h:133
char * m
The number of the node in the namespace.
Definition: testing.h:139
char * library_name
Name of the shared library.
Definition: testing.h:98
struct GNUNET_TESTING_PluginFunctions * api
Plugin API.
Definition: testing.h:103
void GNUNET_TESTING_cmd_batch_set_current_(const struct GNUNET_TESTING_Command *cmd, unsigned int new_ip)
Set what command the batch should be at.
struct GNUNET_TESTING_Command * GNUNET_TESTING_cmd_batch_get_current_(const struct GNUNET_TESTING_Command *cmd)
Obtain what command the batch is at.
void TST_interpreter_send_barrier_crossable(struct GNUNET_TESTING_Interpreter *is, const char *barrier_name, unsigned int global_node_number)
Send Message to a netjail node that a barrier can be crossed.
void GNUNET_TESTING_send_barrier_attach(struct GNUNET_TESTING_Interpreter *is, char *barrier_name, unsigned int global_node_number, unsigned int expected_reaches, GNUNET_TESTING_cmd_helper_write_cb write_message)
Send Message to master loop that cmds being attached to a barrier.
struct GNUNET_TESTING_NetjailNode * GNUNET_TESTING_barrier_get_node(struct GNUNET_TESTING_Barrier *barrier, unsigned int node_number)
Getting a node from a map by global node number.
bool GNUNET_TESTING_cmd_batch_next_(void *cls)
Advance internal pointer to next command.
bool GNUNET_TESTING_cmd_is_batch_(const struct GNUNET_TESTING_Command *cmd)
Test if this command is a batch command.
void TST_interpreter_add_barrier(struct GNUNET_TESTING_Interpreter *is, struct GNUNET_TESTING_Barrier *barrier)
Add a barrier to the loop.
struct GNUNET_TESTING_Barrier * TST_interpreter_get_barrier(struct GNUNET_TESTING_Interpreter *is, const char *barrier_name)
Getting a barrier from the interpreter.
void TST_interpreter_finish_attached_cmds(struct GNUNET_TESTING_Interpreter *is, const char *barrier_name)
Finish all "barrier reached" comands attached to this barrier.
unsigned int GNUNET_TESTING_barrier_crossable(struct GNUNET_TESTING_Barrier *barrier)
This function checks, if a barrier can be crossed, which actually means that the cmd representing the...