aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing.h')
-rw-r--r--src/testing/testing.h185
1 files changed, 185 insertions, 0 deletions
diff --git a/src/testing/testing.h b/src/testing/testing.h
index 848533251..382879706 100644
--- a/src/testing/testing.h
+++ b/src/testing/testing.h
@@ -24,7 +24,70 @@
24#ifndef TESTING_H 24#ifndef TESTING_H
25#define TESTING_H 25#define TESTING_H
26#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
27#include "gnunet_testing_plugin.h"
27 28
29GNUNET_NETWORK_STRUCT_BEGIN
30
31/**
32 * Message send to a child loop to inform the child loop about a barrier being advanced.
33 * FIXME: This is not packed and contains a char*... no payload documentation.
34 */
35struct GNUNET_TESTING_CommandBarrierAdvanced
36{
37 /**
38 * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED
39 */
40 struct GNUNET_MessageHeader header;
41
42 /* followed by 0-terminated barrier name */
43};
44
45/**
46 * Message send by a child loop to inform the master loop how much
47 * GNUNET_CMDS_BARRIER_REACHED messages the child will send.
48 * FIXME: Not packed and contains char*; int in NBO? bitlength undefined.
49 */
50struct GNUNET_TESTING_CommandBarrierAttached
51{
52 /**
53 * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED
54 */
55 struct GNUNET_MessageHeader header;
56
57 /**
58 * How often the child loop will reach the barrier.
59 */
60 uint32_t expected_reaches GNUNET_PACKED;
61
62 /**
63 * The number of the node the barrier is running on.
64 */
65 uint32_t node_number GNUNET_PACKED;
66
67 /* followed by 0-terminated barrier name */
68};
69
70struct GNUNET_TESTING_CommandBarrierReached
71{
72 /**
73 * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED
74 */
75 struct GNUNET_MessageHeader header;
76
77 /**
78 * The number of the node the barrier is reached.
79 */
80 uint32_t node_number GNUNET_PACKED;
81
82 /**
83 * The number of reach messages which most likely will send.
84 */
85 uint32_t expected_number_of_reached_messages GNUNET_PACKED;
86
87 /* followed by 0-terminated barrier name */
88};
89
90GNUNET_NETWORK_STRUCT_END
28 91
29/** 92/**
30 * Handle for a plugin. 93 * Handle for a plugin.
@@ -153,6 +216,7 @@ struct GNUNET_TESTING_Barrier
153 unsigned int shadow; 216 unsigned int shadow;
154}; 217};
155 218
219
156/** 220/**
157 * Advance internal pointer to next command. 221 * Advance internal pointer to next command.
158 * 222 *
@@ -196,6 +260,127 @@ GNUNET_TESTING_cmd_batch_set_current_ (const struct GNUNET_TESTING_Command *cmd,
196 unsigned int new_ip); 260 unsigned int new_ip);
197 261
198 262
263// Wait for barrier to be reached by all;
264// async version implies reached but does not
265// wait on other peers to reach it.
266/**
267 * FIXME: Documentation
268 * Create command.
269 *
270 * @param label name for command.
271 * @param barrier_label The name of the barrier we wait for and which will be reached.
272 * @param asynchronous_finish If GNUNET_YES this command will not block. Can be NULL.
273 * @param asynchronous_finish If GNUNET_YES this command will not block. Can be NULL.
274 * @param node_number The global numer of the node the cmd runs on.
275 * @param running_on_master Is this cmd running on the master loop.
276 * @param write_message Callback to write messages to the master loop.
277 * @return command.
278 */
279struct GNUNET_TESTING_Command
280GNUNET_TESTING_cmd_barrier_reached (
281 const char *label,
282 const char *barrier_label,
283 unsigned int asynchronous_finish,
284 unsigned int node_number,
285 unsigned int running_on_master,
286 GNUNET_TESTING_cmd_helper_write_cb write_message);
287
288
289/**
290 * FIXME: Return type
291 * FIXME: Documentation
292 * Can we advance the barrier?
293 *
294 * @param barrier The barrier in question.
295 * @return GNUNET_YES if we can advance the barrier, GNUNET_NO if not.
296 */
297unsigned int
298GNUNET_TESTING_can_barrier_advance (struct GNUNET_TESTING_Barrier *barrier);
299
300
301/**
302 * FIXME: Naming
303 * Send Message to netjail nodes that a barrier can be advanced.
304 *
305 * @param is The interpreter loop.
306 * @param barrier_name The name of the barrier to advance.
307 * @param global_node_number The global number of the node to inform.
308 */
309void
310GNUNET_TESTING_send_barrier_advance (struct GNUNET_TESTING_Interpreter *is,
311 const char *barrier_name,
312 unsigned int global_node_number);
313
314
315/**
316 * Finish all "barrier reached" comands attached to this barrier.
317 *
318 * @param barrier The barrier in question.
319 */
320void
321GNUNET_TESTING_finish_attached_cmds (struct GNUNET_TESTING_Interpreter *is,
322 const char *barrier_name);
323
324
325/**
326 * Send Message to master loop that cmds being attached to a barrier.
327 *
328 * @param is The interpreter loop.
329 * @param barrier_name The name of the barrier to advance.
330 * @param subnet_number The number of the subnet.
331 * @param node_number The node to inform.
332 * @param write_message Callback to write messages to the master loop.
333 */
334void
335GNUNET_TESTING_send_barrier_attach (struct GNUNET_TESTING_Interpreter *is,
336 char *barrier_name,
337 unsigned int global_node_number,
338 unsigned int expected_reaches,
339 GNUNET_TESTING_cmd_helper_write_cb write_message);
340
341
342/**
343 * Getting a node from a map by global node number.
344 *
345 * @param nodes The map.
346 * @param node_number The global node number.
347 * @return The node.
348 */
349struct GNUNET_TESTING_NetjailNode *
350GNUNET_TESTING_barrier_get_node (struct GNUNET_CONTAINER_MultiShortmap *nodes,
351 unsigned int node_number);
352
353
354/**
355 * Deleting all barriers create in the context of this interpreter.
356 *
357 * @param is The interpreter.
358 */
359void
360GNUNET_TESTING_delete_barriers (struct GNUNET_TESTING_Interpreter *is);
361
362
363/**
364 * Getting a barrier from the interpreter.
365 *
366 * @param is The interpreter.
367 * @param barrier_name The name of the barrier.
368 * @return The barrier.
369 */
370struct GNUNET_TESTING_Barrier *
371GNUNET_TESTING_get_barrier (struct GNUNET_TESTING_Interpreter *is,
372 const char *barrier_name);
373
374
375/**
376 * Add a barrier to the loop.
377 *
378 * @param is The interpreter.
379 * @param barrier The barrier to add.
380 */
381void
382GNUNET_TESTING_interpreter_add_barrier (struct GNUNET_TESTING_Interpreter *is,
383 struct GNUNET_TESTING_Barrier *barrier);
199 384
200 385
201#endif 386#endif