aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_testing_netjail_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_testing_netjail_lib.h')
-rw-r--r--src/include/gnunet_testing_netjail_lib.h187
1 files changed, 109 insertions, 78 deletions
diff --git a/src/include/gnunet_testing_netjail_lib.h b/src/include/gnunet_testing_netjail_lib.h
index b65ae6537..843fce0d5 100644
--- a/src/include/gnunet_testing_netjail_lib.h
+++ b/src/include/gnunet_testing_netjail_lib.h
@@ -27,9 +27,8 @@
27#ifndef GNUNET_TESTING_NETJAIL_LIB_H 27#ifndef GNUNET_TESTING_NETJAIL_LIB_H
28#define GNUNET_TESTING_NETJAIL_LIB_H 28#define GNUNET_TESTING_NETJAIL_LIB_H
29 29
30#include "gnunet_util_lib.h"
31#include "gnunet_testing_plugin.h"
32#include "gnunet_testing_ng_lib.h" 30#include "gnunet_testing_ng_lib.h"
31#include "gnunet_testing_plugin.h"
33 32
34 33
35/** 34/**
@@ -52,7 +51,7 @@ struct GNUNET_TESTING_NetjailRouter
52/** 51/**
53 * Enum for the different types of nodes. 52 * Enum for the different types of nodes.
54 */ 53 */
55enum GNUNET_TESTING_NODE_TYPE 54enum GNUNET_TESTING_NodeType
56{ 55{
57 /** 56 /**
58 * Node in a subnet. 57 * Node in a subnet.
@@ -121,7 +120,7 @@ struct GNUNET_TESTING_NodeConnection
121 /** 120 /**
122 * The type of the node this connection points to. 121 * The type of the node this connection points to.
123 */ 122 */
124 enum GNUNET_TESTING_NODE_TYPE node_type; 123 enum GNUNET_TESTING_NodeType node_type;
125 124
126 /** 125 /**
127 * The node which establish the connection 126 * The node which establish the connection
@@ -145,6 +144,16 @@ struct GNUNET_TESTING_NodeConnection
145struct GNUNET_TESTING_NetjailNode 144struct GNUNET_TESTING_NetjailNode
146{ 145{
147 /** 146 /**
147 * Head of the DLL with the connections which shall be established to other nodes.
148 */
149 struct GNUNET_TESTING_NodeConnection *node_connections_head;
150
151 /**
152 * Tail of the DLL with the connections which shall be established to other nodes.
153 */
154 struct GNUNET_TESTING_NodeConnection *node_connections_tail;
155
156 /**
148 * Plugin for the test case to be run on this node. 157 * Plugin for the test case to be run on this node.
149 */ 158 */
150 char *plugin; 159 char *plugin;
@@ -165,14 +174,19 @@ struct GNUNET_TESTING_NetjailNode
165 unsigned int node_n; 174 unsigned int node_n;
166 175
167 /** 176 /**
168 * Head of the DLL with the connections which shall be established to other nodes. 177 * The overall number of the node in the whole test system.
169 */ 178 */
170 struct GNUNET_TESTING_NodeConnection *node_connections_head; 179 unsigned int node_number;
171 180
172 /** 181 /**
173 * Tail of the DLL with the connections which shall be established to other nodes. 182 * The number of unintentional additional connections this node waits for. This overwrites the global additional_connects value.
174 */ 183 */
175 struct GNUNET_TESTING_NodeConnection *node_connections_tail; 184 unsigned int additional_connects;
185
186 /**
187 * The number of cmds waiting for a specific barrier.
188 */
189 unsigned int expected_reaches;
176}; 190};
177 191
178 192
@@ -250,13 +264,37 @@ GNUNET_TESTING_get_topo_from_file (const char *filename);
250 264
251 265
252/** 266/**
267 * FIXME: this could use a "to_string".
253 * Parse the topology data. 268 * Parse the topology data.
254 * 269 *
255 * @param data The topology data. 270 * @param data The topology data.
256 * @return The GNUNET_TESTING_NetjailTopology 271 * @return The GNUNET_TESTING_NetjailTopology
257 */ 272 */
258struct GNUNET_TESTING_NetjailTopology * 273struct GNUNET_TESTING_NetjailTopology *
259GNUNET_TESTING_get_topo_from_string (char *data); 274GNUNET_TESTING_get_topo_from_string (const char *data);
275
276
277/**
278 * Get the number of unintentional additional connections the node waits for.
279 *
280 * @param num The specific node we want the additional connects for.
281 * @return The number of additional connects
282 */
283unsigned int
284GNUNET_TESTING_get_additional_connects (unsigned int num,
285 struct GNUNET_TESTING_NetjailTopology *
286 topology);
287
288/**
289 * Get a node from the topology.
290 *
291 * @param num The specific node we want the connections for.
292 * @param topology The topology we get the connections from.
293 * @return The connections of the node.
294 */
295struct GNUNET_TESTING_NetjailNode *
296GNUNET_TESTING_get_node (unsigned int num,
297 struct GNUNET_TESTING_NetjailTopology *topology);
260 298
261 299
262/** 300/**
@@ -267,8 +305,8 @@ GNUNET_TESTING_get_topo_from_string (char *data);
267 * @return The connections of the node. 305 * @return The connections of the node.
268 */ 306 */
269struct GNUNET_TESTING_NodeConnection * 307struct GNUNET_TESTING_NodeConnection *
270GNUNET_TESTING_get_connections (unsigned int num, struct 308GNUNET_TESTING_get_connections (unsigned int num,
271 GNUNET_TESTING_NetjailTopology *topology); 309 const struct GNUNET_TESTING_NetjailTopology *topology);
272 310
273 311
274/** 312/**
@@ -280,7 +318,7 @@ GNUNET_TESTING_get_connections (unsigned int num, struct
280 */ 318 */
281char * 319char *
282GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection, 320GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection,
283 char *prefix); 321 const char *prefix);
284 322
285 323
286/** 324/**
@@ -309,7 +347,7 @@ GNUNET_TESTING_calculate_num (struct
309 * Struct with information for callbacks. 347 * Struct with information for callbacks.
310 * 348 *
311 */ 349 */
312struct BlockState 350struct GNUNET_TESTING_BlockState
313{ 351{
314 /** 352 /**
315 * Context for our asynchronous completion. 353 * Context for our asynchronous completion.
@@ -331,7 +369,7 @@ struct BlockState
331 * Struct to hold information for callbacks. 369 * Struct to hold information for callbacks.
332 * 370 *
333 */ 371 */
334struct LocalPreparedState 372struct GNUNET_TESTING_LocalPreparedState
335{ 373{
336 /** 374 /**
337 * Context for our asynchronous completion. 375 * Context for our asynchronous completion.
@@ -342,22 +380,35 @@ struct LocalPreparedState
342 * Callback to write messages to the master loop. 380 * Callback to write messages to the master loop.
343 * 381 *
344 */ 382 */
345 TESTING_CMD_HELPER_write_cb write_message; 383 GNUNET_TESTING_cmd_helper_write_cb write_message;
346}; 384};
347 385
348 386/**
387 * This command destroys the ressources allocated for the test system setup.
388 *
389 * @param label Name for command.
390 * @param create_label Label of the cmd which started the test system.
391 * @param write_message Callback to write messages to the master loop.
392 * @return command.
393 */
349struct GNUNET_TESTING_Command 394struct GNUNET_TESTING_Command
350GNUNET_TESTING_cmd_system_destroy (const char *label, 395GNUNET_TESTING_cmd_system_destroy (const char *label,
351 const char *create_label); 396 const char *create_label);
352 397
353 398/**
399 * This command is setting up a test environment for a peer to start.
400 *
401 * @param label Name for command.
402 * @param testdir Only the directory name without any path. Temporary
403 * directory used for all service homes.
404 */
354struct GNUNET_TESTING_Command 405struct GNUNET_TESTING_Command
355GNUNET_TESTING_cmd_system_create (const char *label, 406GNUNET_TESTING_cmd_system_create (const char *label,
356 const char *testdir); 407 const char *testdir);
357 408
358 409
359/** 410/**
360 * Create command. 411 * This command executes a shell script to setup the netjail environment.
361 * 412 *
362 * @param label name for command. 413 * @param label name for command.
363 * @param topology_config Configuration file for the test topology. 414 * @param topology_config Configuration file for the test topology.
@@ -371,7 +422,7 @@ GNUNET_TESTING_cmd_netjail_start (const char *label,
371 422
372 423
373/** 424/**
374 * Create command. 425 * This command executes a shell script to remove the netjail environment.
375 * 426 *
376 * @param label name for command. 427 * @param label name for command.
377 * @param topology_config Configuration file for the test topology. 428 * @param topology_config Configuration file for the test topology.
@@ -385,7 +436,8 @@ GNUNET_TESTING_cmd_netjail_stop (const char *label,
385 436
386 437
387/** 438/**
388 * Create command. 439 * This command executes a shell script which starts a helper process.
440 * This process is running on a netjail node, executing a defined test case.
389 * 441 *
390 * @param label Name for the command. 442 * @param label Name for the command.
391 * @param topology The complete topology information. 443 * @param topology The complete topology information.
@@ -395,7 +447,7 @@ GNUNET_TESTING_cmd_netjail_stop (const char *label,
395 * @return command. 447 * @return command.
396 */ 448 */
397struct GNUNET_TESTING_Command 449struct GNUNET_TESTING_Command
398GNUNET_TESTING_cmd_netjail_start_testing_system ( 450GNUNET_TESTING_cmd_netjail_start_cmds_helper (
399 const char *label, 451 const char *label,
400 struct GNUNET_TESTING_NetjailTopology *topology, 452 struct GNUNET_TESTING_NetjailTopology *topology,
401 unsigned int *read_file, 453 unsigned int *read_file,
@@ -412,89 +464,67 @@ GNUNET_TESTING_cmd_netjail_start_testing_system (
412 * @return command. 464 * @return command.
413 */ 465 */
414struct GNUNET_TESTING_Command 466struct GNUNET_TESTING_Command
415GNUNET_TESTING_cmd_stop_testing_system ( 467GNUNET_TESTING_cmd_stop_cmds_helper (
416 const char *label, 468 const char *label,
417 const char *helper_start_label, 469 const char *helper_start_label,
418 struct GNUNET_TESTING_NetjailTopology *topology); 470 struct GNUNET_TESTING_NetjailTopology *topology);
419 471
420 472
421/** 473/**
422 * Create a GNUNET_CMDS_LOCAL_FINISHED message. 474 * This command is used to block the loop, until the command is finished by other commands,
475 * using a trait to get this commands struct GNUNET_TESTING_AsyncContext.
423 * 476 *
424 * @param rv The result of the local test as GNUNET_GenericReturnValue. 477 * @param label name for command.
425 * @return The GNUNET_CMDS_LOCAL_FINISHED message. 478 * @return command.
426*/ 479 */
427struct GNUNET_MessageHeader *
428GNUNET_TESTING_send_local_test_finished_msg (enum GNUNET_GenericReturnValue rv);
429
430
431struct GNUNET_TESTING_Command
432GNUNET_TESTING_cmd_barrier_create (
433 const char *label);
434
435
436struct GNUNET_TESTING_Command 480struct GNUNET_TESTING_Command
437GNUNET_TESTING_cmd_barrier_setup_finished ( 481GNUNET_TESTING_cmd_block_until_external_trigger (
438 const char *label); 482 const char *label);
439 483
440
441// Wait for barrier to be reached by all;
442// async version implies reached but does not
443// wait on other peers to reach it.
444struct GNUNET_TESTING_Command
445GNUNET_TESTING_cmd_barrier_reached (
446 const char *label,
447 const char *barrier_label);
448
449
450struct GNUNET_TESTING_Command
451GNUNET_TESTING_cmd_block_until_all_peers_started (
452 const char *label,
453 unsigned int *all_peers_started);
454
455
456/** 484/**
457 * Create command. 485 * DEPRECATED
486 * This command sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED message to the master loop.
458 * 487 *
459 * @param label name for command. 488 * @param label name for command.
460 * @param all_peers_started Flag which will be set from outside. 489 * @param write_message Callback to write messages to the master loop.
461 * @param asynchronous_finish If GNUNET_YES this command will not block.
462 * @return command. 490 * @return command.
463 */ 491 */
464struct GNUNET_TESTING_Command 492struct GNUNET_TESTING_Command
465GNUNET_TESTING_cmd_block_until_external_trigger (
466 const char *label);
467
468
469struct GNUNET_TESTING_Command
470GNUNET_TESTING_cmd_send_peer_ready (const char *label, 493GNUNET_TESTING_cmd_send_peer_ready (const char *label,
471 TESTING_CMD_HELPER_write_cb write_message); 494 GNUNET_TESTING_cmd_helper_write_cb write_message);
472 495
473 496
474/** 497/**
475 * Create command. 498 * This command sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TESTS_PREPARED message to the master loop.
476 * 499 *
477 * @param label name for command. 500 * @param label name for command.
478 * @param write_message Callback to write messages to the master loop. 501 * @param write_message Callback to write messages to the master loop.
479 * @return command. 502 * @return command.
480 */ 503 */
481struct GNUNET_TESTING_Command 504struct GNUNET_TESTING_Command
482GNUNET_TESTING_cmd_local_test_finished ( 505GNUNET_TESTING_cmd_local_test_prepared (const char *label,
483 const char *label, 506 GNUNET_TESTING_cmd_helper_write_cb
484 TESTING_CMD_HELPER_write_cb write_message); 507 write_message);
508
485 509
486/** 510/**
487 * Create command. 511 * Create command.
488 * 512 *
489 * @param label name for command. 513 * @param label name for command.
490 * @param write_message Callback to write messages to the master loop. 514 * @param system_label Label of the cmd to setup a test environment.
491 * @param all_local_tests_prepared Flag which will be set from outside. 515 * @param no Decimal number representing the last byte of the IP address of this peer.
516 * @param node_ip The IP address of this node.
517 * @param cfgname Configuration file name for this peer.
518 * @param broadcast Flag indicating, if broadcast should be switched on.
492 * @return command. 519 * @return command.
493 */ 520 */
494struct GNUNET_TESTING_Command 521struct GNUNET_TESTING_Command
495GNUNET_TESTING_cmd_local_test_prepared (const char *label, 522GNUNET_TESTING_cmd_start_peer (const char *label,
496 TESTING_CMD_HELPER_write_cb 523 const char *system_label,
497 write_message); 524 uint32_t no,
525 const char *node_ip,
526 const char *cfgname,
527 unsigned int broadcast);
498 528
499 529
500/* ***** Netjail trait support ***** */ 530/* ***** Netjail trait support ***** */
@@ -503,13 +533,14 @@ GNUNET_TESTING_cmd_local_test_prepared (const char *label,
503/** 533/**
504 * Call #op on all simple traits. 534 * Call #op on all simple traits.
505 */ 535 */
506#define GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS(op) \ 536#define GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS(op, prefix) \
507 op (test_system, const struct GNUNET_TESTING_System) \ 537 op (prefix, test_system, const struct GNUNET_TESTING_System) \
508 op (async_context, const struct GNUNET_TESTING_AsyncContext) \ 538 op (prefix, async_context, struct GNUNET_TESTING_AsyncContext) \
509 op (helper_handles, const struct GNUNET_HELPER_Handle *) \ 539 op (prefix, helper_handles, const struct GNUNET_HELPER_Handle *) \
510 op (local_prepared_state, const struct LocalPreparedState) \ 540 op (prefix, local_prepared_state, const struct GNUNET_TESTING_LocalPreparedState) \
511 op (block_state, const struct BlockState) 541 op (prefix, block_state, struct GNUNET_TESTING_BlockState)
512 542
513GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT) 543GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT, GNUNET_TESTING)
544
514 545
515#endif 546#endif