diff options
author | t3sserakt <t3ss@posteo.de> | 2023-01-06 21:02:55 +0100 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2023-01-06 21:02:55 +0100 |
commit | 2c2b2911e1585dc378dbb88d4dd6aaec37b00316 (patch) | |
tree | 701cd3a2304a7e1fb74553c78d8a3d2a1cbcc6c2 /src | |
parent | d9f74f1751f0c4e08ddb2ce5f81a8cf8e4dcf1a2 (diff) | |
download | gnunet-2c2b2911e1585dc378dbb88d4dd6aaec37b00316.tar.gz gnunet-2c2b2911e1585dc378dbb88d4dd6aaec37b00316.zip |
- relsoved an coverity issue, worked on fixmes, code documentation and cleaned up up the barrier API
Diffstat (limited to 'src')
32 files changed, 572 insertions, 461 deletions
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 8f857e86c..e78738d7b 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -3605,7 +3605,7 @@ extern "C" { | |||
3605 | 3605 | ||
3606 | #define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACH 1708 | 3606 | #define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACH 1708 |
3607 | 3607 | ||
3608 | #define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED 1709 | 3608 | #define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE 1709 |
3609 | 3609 | ||
3610 | #define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED 1710 | 3610 | #define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED 1710 |
3611 | 3611 | ||
diff --git a/src/include/gnunet_testing_barrier.h b/src/include/gnunet_testing_barrier.h index 3eb61c7ec..4384dd055 100644 --- a/src/include/gnunet_testing_barrier.h +++ b/src/include/gnunet_testing_barrier.h | |||
@@ -27,6 +27,8 @@ | |||
27 | #ifndef GNUNET_TESTING_BARRIER_LIB_H | 27 | #ifndef GNUNET_TESTING_BARRIER_LIB_H |
28 | #define GNUNET_TESTING_BARRIER_LIB_H | 28 | #define GNUNET_TESTING_BARRIER_LIB_H |
29 | 29 | ||
30 | #include "gnunet_testing_plugin.h" | ||
31 | |||
30 | #define GNUNET_TESTING_BARRIER_MAX 32 | 32 | #define GNUNET_TESTING_BARRIER_MAX 32 |
31 | 33 | ||
32 | /** | 34 | /** |
@@ -47,7 +49,7 @@ struct GNUNET_TESTING_BarrierListEntry | |||
47 | * Number of commands attached to the barrier. | 49 | * Number of commands attached to the barrier. |
48 | */ | 50 | */ |
49 | unsigned int expected_reaches; | 51 | unsigned int expected_reaches; |
50 | }; | 52 | }; |
51 | 53 | ||
52 | /** | 54 | /** |
53 | * A list to hold barriers provided by plugins | 55 | * A list to hold barriers provided by plugins |
@@ -63,10 +65,21 @@ struct GNUNET_TESTING_BarrierList | |||
63 | 65 | ||
64 | 66 | ||
65 | /** | 67 | /** |
66 | * FIXME: documentation | 68 | * Command to create a barrier. |
69 | * | ||
67 | * FIXME: high-level it is baffling how we need both the GNUNET_TESTING_Barrier | 70 | * FIXME: high-level it is baffling how we need both the GNUNET_TESTING_Barrier |
68 | * and the Command that creates barriers. Conceptually this seems to be | 71 | * and the Command that creates barriers. Conceptually this seems to be |
69 | * very much separate. Can we move _Barrier completely into testing as private? | 72 | * very much separate. Can we move _Barrier completely into testing as private? |
73 | * | ||
74 | * @param label The label of this command. | ||
75 | * @param percentage_to_be_reached If this percentage of processes reached | ||
76 | * this barrier, all processes waiting at | ||
77 | * this barrier can pass it. Must not be | ||
78 | * used together with number_to_be_reached. | ||
79 | * @param number_to_be_reached If this number of processes reached | ||
80 | * this barrier, all processes waiting at | ||
81 | * this barrier can pass it. Must not be | ||
82 | * used together with percentage_to_be_reached. | ||
70 | */ | 83 | */ |
71 | struct GNUNET_TESTING_Command | 84 | struct GNUNET_TESTING_Command |
72 | GNUNET_TESTING_cmd_barrier_create ( | 85 | GNUNET_TESTING_cmd_barrier_create ( |
@@ -74,5 +87,29 @@ GNUNET_TESTING_cmd_barrier_create ( | |||
74 | double percentage_to_be_reached, | 87 | double percentage_to_be_reached, |
75 | unsigned int number_to_be_reached); | 88 | unsigned int number_to_be_reached); |
76 | 89 | ||
90 | /** | ||
91 | * If this command is executed the the process is signaling the master process | ||
92 | * that it reached a barrier. If this command is synchronous it will block. | ||
93 | * | ||
94 | * FIXME: Now this, as it returns a Command, seems to me like it should be | ||
95 | * part of the public API? | ||
96 | * | ||
97 | * @param label name for command. | ||
98 | * @param barrier_label The name of the barrier we waited for and which was reached. | ||
99 | * @param asynchronous_finish If GNUNET_YES this command will not block. | ||
100 | * @param node_number The global number of the node the cmd runs on. | ||
101 | * @param running_on_master Is this cmd running on the master loop? | ||
102 | * @param write_message Callback to write messages to the master loop. | ||
103 | * @return command. | ||
104 | */ | ||
105 | struct GNUNET_TESTING_Command | ||
106 | GNUNET_TESTING_cmd_barrier_reached ( | ||
107 | const char *label, | ||
108 | const char *barrier_label, | ||
109 | unsigned int asynchronous_finish, | ||
110 | unsigned int node_number, | ||
111 | unsigned int running_on_master, | ||
112 | GNUNET_TESTING_cmd_helper_write_cb write_message); | ||
113 | |||
77 | #endif | 114 | #endif |
78 | /* end of testing_barrier.h */ | 115 | /* end of testing_barrier.h */ |
diff --git a/src/include/gnunet_testing_netjail_lib.h b/src/include/gnunet_testing_netjail_lib.h index a2f2e056a..106d7cdae 100644 --- a/src/include/gnunet_testing_netjail_lib.h +++ b/src/include/gnunet_testing_netjail_lib.h | |||
@@ -50,10 +50,9 @@ struct GNUNET_TESTING_NetjailRouter | |||
50 | 50 | ||
51 | 51 | ||
52 | /** | 52 | /** |
53 | * FIXME: Naming | ||
54 | * Enum for the different types of nodes. | 53 | * Enum for the different types of nodes. |
55 | */ | 54 | */ |
56 | enum GNUNET_TESTING_NODE_TYPE | 55 | enum GNUNET_TESTING_NodeType |
57 | { | 56 | { |
58 | /** | 57 | /** |
59 | * Node in a subnet. | 58 | * Node in a subnet. |
@@ -122,7 +121,7 @@ struct GNUNET_TESTING_NodeConnection | |||
122 | /** | 121 | /** |
123 | * The type of the node this connection points to. | 122 | * The type of the node this connection points to. |
124 | */ | 123 | */ |
125 | enum GNUNET_TESTING_NODE_TYPE node_type; | 124 | enum GNUNET_TESTING_NodeType node_type; |
126 | 125 | ||
127 | /** | 126 | /** |
128 | * The node which establish the connection | 127 | * The node which establish the connection |
@@ -345,7 +344,6 @@ GNUNET_TESTING_calculate_num (struct | |||
345 | struct GNUNET_TESTING_NetjailTopology *topology); | 344 | struct GNUNET_TESTING_NetjailTopology *topology); |
346 | 345 | ||
347 | /** | 346 | /** |
348 | * FIXME: This was also not namespaces. | ||
349 | * Struct with information for callbacks. | 347 | * Struct with information for callbacks. |
350 | * | 348 | * |
351 | */ | 349 | */ |
@@ -368,7 +366,6 @@ struct GNUNET_TESTING_BlockState | |||
368 | }; | 366 | }; |
369 | 367 | ||
370 | /** | 368 | /** |
371 | * FIXME: This was also not namespaced | ||
372 | * Struct to hold information for callbacks. | 369 | * Struct to hold information for callbacks. |
373 | * | 370 | * |
374 | */ | 371 | */ |
@@ -387,9 +384,9 @@ struct GNUNET_TESTING_LocalPreparedState | |||
387 | }; | 384 | }; |
388 | 385 | ||
389 | /** | 386 | /** |
390 | * Create command. FIXME: What? | 387 | * This command destroys the ressources allocated for the test system setup. |
391 | * | 388 | * |
392 | * @param label name for command. | 389 | * @param label Name for command. |
393 | * @param create_label Label of the cmd which started the test system. | 390 | * @param create_label Label of the cmd which started the test system. |
394 | * @param write_message Callback to write messages to the master loop. | 391 | * @param write_message Callback to write messages to the master loop. |
395 | * @return command. | 392 | * @return command. |
@@ -398,15 +395,20 @@ struct GNUNET_TESTING_Command | |||
398 | GNUNET_TESTING_cmd_system_destroy (const char *label, | 395 | GNUNET_TESTING_cmd_system_destroy (const char *label, |
399 | const char *create_label); | 396 | const char *create_label); |
400 | 397 | ||
401 | //FIXME | 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 | */ | ||
402 | struct GNUNET_TESTING_Command | 405 | struct GNUNET_TESTING_Command |
403 | GNUNET_TESTING_cmd_system_create (const char *label, | 406 | GNUNET_TESTING_cmd_system_create (const char *label, |
404 | const char *testdir); | 407 | const char *testdir); |
405 | 408 | ||
406 | 409 | ||
407 | /** | 410 | /** |
408 | * FIXME | 411 | * This command executes a shell script to setup the netjail environment. |
409 | * Create command. | ||
410 | * | 412 | * |
411 | * @param label name for command. | 413 | * @param label name for command. |
412 | * @param topology_config Configuration file for the test topology. | 414 | * @param topology_config Configuration file for the test topology. |
@@ -420,8 +422,7 @@ GNUNET_TESTING_cmd_netjail_start (const char *label, | |||
420 | 422 | ||
421 | 423 | ||
422 | /** | 424 | /** |
423 | * FIXME | 425 | * This command executes a shell script to remove the netjail environment. |
424 | * Create command. | ||
425 | * | 426 | * |
426 | * @param label name for command. | 427 | * @param label name for command. |
427 | * @param topology_config Configuration file for the test topology. | 428 | * @param topology_config Configuration file for the test topology. |
@@ -435,9 +436,8 @@ GNUNET_TESTING_cmd_netjail_stop (const char *label, | |||
435 | 436 | ||
436 | 437 | ||
437 | /** | 438 | /** |
438 | * FIXME | 439 | * This command executes a shell script which starts a helper process. |
439 | * FIXME Naming? | 440 | * This process is running on a netjail node, executing a defined test case. |
440 | * Create command. | ||
441 | * | 441 | * |
442 | * @param label Name for the command. | 442 | * @param label Name for the command. |
443 | * @param topology The complete topology information. | 443 | * @param topology The complete topology information. |
@@ -447,7 +447,7 @@ GNUNET_TESTING_cmd_netjail_stop (const char *label, | |||
447 | * @return command. | 447 | * @return command. |
448 | */ | 448 | */ |
449 | struct GNUNET_TESTING_Command | 449 | struct GNUNET_TESTING_Command |
450 | GNUNET_TESTING_cmd_netjail_start_testing_system ( | 450 | GNUNET_TESTING_cmd_netjail_start_cmds_helper ( |
451 | const char *label, | 451 | const char *label, |
452 | struct GNUNET_TESTING_NetjailTopology *topology, | 452 | struct GNUNET_TESTING_NetjailTopology *topology, |
453 | unsigned int *read_file, | 453 | unsigned int *read_file, |
@@ -464,36 +464,17 @@ GNUNET_TESTING_cmd_netjail_start_testing_system ( | |||
464 | * @return command. | 464 | * @return command. |
465 | */ | 465 | */ |
466 | struct GNUNET_TESTING_Command | 466 | struct GNUNET_TESTING_Command |
467 | GNUNET_TESTING_cmd_stop_testing_system ( | 467 | GNUNET_TESTING_cmd_stop_cmds_helper ( |
468 | const char *label, | 468 | const char *label, |
469 | const char *helper_start_label, | 469 | const char *helper_start_label, |
470 | struct GNUNET_TESTING_NetjailTopology *topology); | 470 | struct GNUNET_TESTING_NetjailTopology *topology); |
471 | 471 | ||
472 | /** | ||
473 | * Create a GNUNET_CMDS_LOCAL_FINISHED message. | ||
474 | * FIXME: This is strange as messages are not really used | ||
475 | * like this. Consider removing. | ||
476 | * | ||
477 | * @return The GNUNET_CMDS_LOCAL_FINISHED message. | ||
478 | */ | ||
479 | struct GNUNET_MessageHeader * | ||
480 | GNUNET_TESTING_send_local_test_finished_msg (); | ||
481 | |||
482 | |||
483 | //FIXME | ||
484 | struct GNUNET_TESTING_Command | ||
485 | GNUNET_TESTING_cmd_block_until_all_peers_started ( | ||
486 | const char *label, | ||
487 | unsigned int *all_peers_started); | ||
488 | |||
489 | 472 | ||
490 | /** | 473 | /** |
491 | * FIXME | 474 | * This command is used to block the loop, until the command is finished by other commands, |
492 | * Create command. | 475 | * using a trait to get this commands struct GNUNET_TESTING_AsyncContext. |
493 | * | 476 | * |
494 | * @param label name for command. | 477 | * @param label name for command. |
495 | * @param all_peers_started Flag which will be set from outside. | ||
496 | * @param asynchronous_finish If GNUNET_YES this command will not block. | ||
497 | * @return command. | 478 | * @return command. |
498 | */ | 479 | */ |
499 | struct GNUNET_TESTING_Command | 480 | struct GNUNET_TESTING_Command |
@@ -501,8 +482,8 @@ GNUNET_TESTING_cmd_block_until_external_trigger ( | |||
501 | const char *label); | 482 | const char *label); |
502 | 483 | ||
503 | /** | 484 | /** |
504 | * FIXME | 485 | * DEPRECATED |
505 | * Create command. | 486 | * This command sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED message to the master loop. |
506 | * | 487 | * |
507 | * @param label name for command. | 488 | * @param label name for command. |
508 | * @param write_message Callback to write messages to the master loop. | 489 | * @param write_message Callback to write messages to the master loop. |
@@ -514,21 +495,7 @@ GNUNET_TESTING_cmd_send_peer_ready (const char *label, | |||
514 | 495 | ||
515 | 496 | ||
516 | /** | 497 | /** |
517 | * FIXME | 498 | * This command sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TESTS_PREPARED message to the master loop. |
518 | * Create command. | ||
519 | * | ||
520 | * @param label name for command. | ||
521 | * @param write_message Callback to write messages to the master loop. | ||
522 | * @return command. | ||
523 | */ | ||
524 | struct GNUNET_TESTING_Command | ||
525 | GNUNET_TESTING_cmd_local_test_finished ( | ||
526 | const char *label, | ||
527 | GNUNET_TESTING_cmd_helper_write_cb write_message); | ||
528 | |||
529 | /** | ||
530 | * FIXME | ||
531 | * Create command. | ||
532 | * | 499 | * |
533 | * @param label name for command. | 500 | * @param label name for command. |
534 | * @param write_message Callback to write messages to the master loop. | 501 | * @param write_message Callback to write messages to the master loop. |
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h index f0e2e3250..aae918ff3 100644 --- a/src/include/gnunet_testing_ng_lib.h +++ b/src/include/gnunet_testing_ng_lib.h | |||
@@ -422,46 +422,6 @@ GNUNET_TESTING_main (struct GNUNET_TESTING_Command *commands, | |||
422 | 422 | ||
423 | 423 | ||
424 | /** | 424 | /** |
425 | * Adding a helper handle to the interpreter. | ||
426 | * | ||
427 | * @param is The interpreter. | ||
428 | * @param helper The helper handle. | ||
429 | */ | ||
430 | void | ||
431 | GNUNET_TESTING_add_netjail_helper (struct GNUNET_TESTING_Interpreter *is, | ||
432 | const struct GNUNET_HELPER_Handle *helper); | ||
433 | |||
434 | |||
435 | /** | ||
436 | * Send Message to netjail nodes that a barrier can be advanced. | ||
437 | * FIXME: Naming. No "netjail" in argument. Or is there a | ||
438 | * GNUNET_TESTING_send_message without "to_netjail"?? | ||
439 | * | ||
440 | * @param is The interpreter. | ||
441 | * @param global_node_number The node to inform. | ||
442 | * @param header The message to send. | ||
443 | */ | ||
444 | void | ||
445 | GNUNET_TESTING_send_message_to_netjail (struct GNUNET_TESTING_Interpreter *is, | ||
446 | unsigned int global_node_number, | ||
447 | struct GNUNET_MessageHeader *header); | ||
448 | |||
449 | |||
450 | /** | ||
451 | * Returns the actual running command. | ||
452 | * FIXME: Is Command allocated? Is it constant? Should this be a private | ||
453 | * function? => not used outside of testing | ||
454 | * | ||
455 | * @param is Global state of the interpreter, used by a command | ||
456 | * to access information about other commands. | ||
457 | * @return The actual running command. | ||
458 | */ | ||
459 | struct GNUNET_TESTING_Command * | ||
460 | GNUNET_TESTING_interpreter_get_current_command ( | ||
461 | struct GNUNET_TESTING_Interpreter *is); | ||
462 | |||
463 | |||
464 | /** | ||
465 | * Check if the command is running. | 425 | * Check if the command is running. |
466 | * FIXME: Unused function. | 426 | * FIXME: Unused function. |
467 | * | 427 | * |
@@ -561,15 +521,14 @@ struct GNUNET_TESTING_Timer | |||
561 | 521 | ||
562 | 522 | ||
563 | /** | 523 | /** |
564 | * Retrieve the public key from the test system with the unique node id. | 524 | * Retrieve peer identity from the test system with the unique node id. |
565 | * FIXME: Naming. => get_peer? This returns a PeerIdentity not a PublicKey | ||
566 | * | 525 | * |
567 | * @param num The unique node id. | 526 | * @param num The unique node id. |
568 | * @param tl_system The test system. | 527 | * @param tl_system The test system. |
569 | * @return The peer identity wrapping the public key. | 528 | * @return The peer identity wrapping the public key. |
570 | */ | 529 | */ |
571 | struct GNUNET_PeerIdentity * | 530 | struct GNUNET_PeerIdentity * |
572 | GNUNET_TESTING_get_pub_key (unsigned int num, | 531 | GNUNET_TESTING_get_peer (unsigned int num, |
573 | const struct GNUNET_TESTING_System *tl_system); | 532 | const struct GNUNET_TESTING_System *tl_system); |
574 | 533 | ||
575 | 534 | ||
@@ -586,8 +545,13 @@ GNUNET_TESTING_cmd_stat (struct GNUNET_TESTING_Timer *timers); | |||
586 | /* *** Generic trait logic for implementing traits ********* */ | 545 | /* *** Generic trait logic for implementing traits ********* */ |
587 | 546 | ||
588 | /** | 547 | /** |
589 | * FIXME: Documentation | 548 | * A struct GNUNET_TESTING_Trait can be used to exchange data between cmds. |
590 | * A trait. | 549 | * |
550 | * Therefor the cmd which like to provide data to other cmds has to implement | ||
551 | * the trait function, where an array of traits is defined with the help of the | ||
552 | * GNUNET_TESTING_make_trait_ macro. The data can be retrieved with the help of the | ||
553 | * GNUNET_TESTING_get_trait_ macro. Traits name and type must be defined to make | ||
554 | * use of the macros. | ||
591 | */ | 555 | */ |
592 | struct GNUNET_TESTING_Trait | 556 | struct GNUNET_TESTING_Trait |
593 | { | 557 | { |
diff --git a/src/include/gnunet_testing_plugin.h b/src/include/gnunet_testing_plugin.h index 5f7570680..12fbd7b75 100644 --- a/src/include/gnunet_testing_plugin.h +++ b/src/include/gnunet_testing_plugin.h | |||
@@ -40,17 +40,40 @@ extern "C" | |||
40 | 40 | ||
41 | struct GNUNET_TESTING_Barrier; | 41 | struct GNUNET_TESTING_Barrier; |
42 | 42 | ||
43 | //FIXME documentation for both functions | 43 | /** |
44 | * Callback function to write messages from the helper process running on a netjail node to the master process. | ||
45 | * | ||
46 | * @param message The message to write. | ||
47 | * @param msg_length The length of the message. | ||
48 | */ | ||
44 | typedef void | 49 | typedef void |
45 | (*GNUNET_TESTING_cmd_helper_write_cb) (struct GNUNET_MessageHeader *message, | 50 | (*GNUNET_TESTING_cmd_helper_write_cb) (struct GNUNET_MessageHeader *message, |
46 | size_t msg_length); | 51 | size_t msg_length); |
47 | 52 | ||
53 | /** | ||
54 | * Callback function which writes a message from the helper process running on a netjail node to the master process * signaling that the test case running on the netjail node finished. | ||
55 | */ | ||
48 | typedef void | 56 | typedef void |
49 | (*GNUNET_TESTING_cmd_helper_finish_cb) (); | 57 | (*GNUNET_TESTING_cmd_helper_finish_cb) (); |
50 | 58 | ||
51 | // FIXME documentation | 59 | /** |
52 | // FIXME: Why are n, m, local_m strings? | 60 | * Function to be implemented for each test case plugin which starts the test case on a netjail node. |
53 | // FIXME: Why is topology_data a string and not a GNUNET_TESTING_NetworkTopology?? | 61 | * |
62 | * @param write_message Callback function to write messages from the helper process running on a | ||
63 | * netjail node to the master process. | ||
64 | * @param router_ip Global address of the network namespace, if the helper process is for a node in a subnet. | ||
65 | * @param node_ip The IP address of the node. | ||
66 | * @param m The number of the node in a network namespace. | ||
67 | * @param n The number of the network namespace. | ||
68 | * @param local_m The number of nodes in a network namespace. | ||
69 | * @param topology_data A file name for the file containing the topology configuration, or a string containing | ||
70 | * the topology configuration. | ||
71 | * @param read_file If read_file is GNUNET_YES this string is the filename for the topology configuration, | ||
72 | * if read_file is GNUNET_NO the string contains the topology configuration. | ||
73 | * @param finish_cb Callback function which writes a message from the helper process running on a netjail | ||
74 | * node to the master process * signaling that the test case running on the netjail node finished. | ||
75 | * @return Returns The struct GNUNET_TESTING_Interpreter of the command loop running on this netjail node. | ||
76 | */ | ||
54 | typedef struct GNUNET_TESTING_Interpreter * | 77 | typedef struct GNUNET_TESTING_Interpreter * |
55 | (*GNUNET_TESTING_PLUGIN_StartTestCase) (GNUNET_TESTING_cmd_helper_write_cb | 78 | (*GNUNET_TESTING_PLUGIN_StartTestCase) (GNUNET_TESTING_cmd_helper_write_cb |
56 | write_message, | 79 | write_message, |
@@ -63,30 +86,41 @@ typedef struct GNUNET_TESTING_Interpreter * | |||
63 | unsigned int *read_file, | 86 | unsigned int *read_file, |
64 | GNUNET_TESTING_cmd_helper_finish_cb finish_cb); | 87 | GNUNET_TESTING_cmd_helper_finish_cb finish_cb); |
65 | 88 | ||
66 | 89 | /** | |
90 | * DEPRECATED | ||
91 | * The helper process received a message of type | ||
92 | * GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED. This will finish the blocking command | ||
93 | * GNUNET_TESTING_cmd_block_until_external_trigger which was execute right after the command | ||
94 | * GNUNET_TESTING_cmd_send_peer_ready. | ||
95 | */ | ||
67 | typedef void | 96 | typedef void |
68 | (*GNUNET_TESTING_PLUGIN_ALL_PEERS_STARTED) (); | 97 | (*GNUNET_TESTING_PLUGIN_ALL_PEERS_STARTED) (); |
69 | 98 | ||
70 | 99 | /** | |
100 | * DEPRECATED | ||
101 | * The helper process received a message of type | ||
102 | * GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED. This will finish the blocking command | ||
103 | * GNUNET_TESTING_cmd_local_test_prepared which was execute right after the command | ||
104 | * GNUNET_TRANSPORT_cmd_connect_peers. | ||
105 | */ | ||
71 | typedef void | 106 | typedef void |
72 | (*GNUNET_TESTING_PLUGIN_ALL_LOCAL_TESTS_PREPARED) (); | 107 | (*GNUNET_TESTING_PLUGIN_ALL_LOCAL_TESTS_PREPARED) (); |
73 | 108 | ||
74 | typedef void | 109 | /** |
75 | (*GNUNET_TESTING_PLUGIN_BARRIER_ADVANCED) (const char *barrier_name); | 110 | * This function returns a struct GNUNET_TESTING_BarrierList, which is a list of all barriers |
76 | 111 | * this test case will wait for. | |
112 | * | ||
113 | * @return A struct GNUNET_TESTING_BarrierList. | ||
114 | */ | ||
77 | typedef struct GNUNET_TESTING_BarrierList* | 115 | typedef struct GNUNET_TESTING_BarrierList* |
78 | (*GNUNET_TESTING_PLUGIN_GET_WAITING_FOR_BARRIERS) (void); | 116 | (*GNUNET_TESTING_PLUGIN_GET_WAITING_FOR_BARRIERS) (void); |
79 | 117 | ||
80 | 118 | ||
81 | // FIXME documentation | 119 | /** |
120 | * The plugin API every test case plugin has to implement. | ||
121 | */ | ||
82 | struct GNUNET_TESTING_PluginFunctions | 122 | struct GNUNET_TESTING_PluginFunctions |
83 | { | 123 | { |
84 | /** | ||
85 | * Closure for all of the callbacks. | ||
86 | */ | ||
87 | void *cls; | ||
88 | |||
89 | GNUNET_TESTING_PLUGIN_BARRIER_ADVANCED barrier_advanced; | ||
90 | 124 | ||
91 | GNUNET_TESTING_PLUGIN_StartTestCase start_testcase; | 125 | GNUNET_TESTING_PLUGIN_StartTestCase start_testcase; |
92 | 126 | ||
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am index 3a4990db4..1f6ccc15b 100644 --- a/src/testing/Makefile.am +++ b/src/testing/Makefile.am | |||
@@ -33,13 +33,12 @@ libgnunettesting_la_SOURCES = \ | |||
33 | testing_api_cmd_barrier_reached.c \ | 33 | testing_api_cmd_barrier_reached.c \ |
34 | testing_api_cmd_end.c \ | 34 | testing_api_cmd_end.c \ |
35 | testing_api_cmd_finish.c \ | 35 | testing_api_cmd_finish.c \ |
36 | testing_api_cmd_local_test_finished.c \ | ||
37 | testing_api_cmd_local_test_prepared.c \ | 36 | testing_api_cmd_local_test_prepared.c \ |
38 | testing_api_cmd_send_peer_ready.c \ | 37 | testing_api_cmd_send_peer_ready.c \ |
39 | testing_api_cmd_block_until_external_trigger.c \ | 38 | testing_api_cmd_block_until_external_trigger.c \ |
40 | testing_api_cmd_netjail_start.c \ | 39 | testing_api_cmd_netjail_start.c \ |
41 | testing_api_cmd_netjail_start_testsystem.c \ | 40 | testing_api_cmd_netjail_start_cmds_helper.c \ |
42 | testing_api_cmd_netjail_stop_testsystem.c \ | 41 | testing_api_cmd_netjail_stop_cmds_helper.c \ |
43 | testing_api_cmd_netjail_stop.c \ | 42 | testing_api_cmd_netjail_stop.c \ |
44 | testing.c testing.h \ | 43 | testing.c testing.h \ |
45 | testing_api_cmd_system_create.c \ | 44 | testing_api_cmd_system_create.c \ |
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c index 4d3da6260..90b686891 100644 --- a/src/testing/gnunet-cmds-helper.c +++ b/src/testing/gnunet-cmds-helper.c | |||
@@ -61,7 +61,7 @@ | |||
61 | 61 | ||
62 | #define NODE_BASE_IP "192.168.15." | 62 | #define NODE_BASE_IP "192.168.15." |
63 | 63 | ||
64 | #define KNOWN_BASE_IP "172.168.151." | 64 | #define KNOWN_BASE_IP "172.16.151." |
65 | 65 | ||
66 | #define ROUTER_BASE_IP "172.16.150." | 66 | #define ROUTER_BASE_IP "172.16.150." |
67 | 67 | ||
@@ -213,6 +213,9 @@ do_shutdown (void *cls) | |||
213 | (void) GNUNET_DISK_file_close (stdout_fd); | 213 | (void) GNUNET_DISK_file_close (stdout_fd); |
214 | GNUNET_MST_destroy (tokenizer); | 214 | GNUNET_MST_destroy (tokenizer); |
215 | tokenizer = NULL; | 215 | tokenizer = NULL; |
216 | GNUNET_PLUGIN_unload (plugin->library_name, | ||
217 | NULL); | ||
218 | GNUNET_free (plugin); | ||
216 | } | 219 | } |
217 | 220 | ||
218 | 221 | ||
@@ -286,16 +289,36 @@ delay_shutdown_cb () | |||
286 | } | 289 | } |
287 | 290 | ||
288 | 291 | ||
292 | struct GNUNET_MessageHeader * | ||
293 | GNUNET_TESTING_send_local_test_finished_msg () | ||
294 | { | ||
295 | struct GNUNET_TESTING_CommandLocalFinished *reply; | ||
296 | size_t msg_length; | ||
297 | |||
298 | msg_length = sizeof(struct GNUNET_TESTING_CommandLocalFinished); | ||
299 | reply = GNUNET_new (struct GNUNET_TESTING_CommandLocalFinished); | ||
300 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED); | ||
301 | reply->header.size = htons ((uint16_t) msg_length); | ||
302 | |||
303 | return (struct GNUNET_MessageHeader *) reply; | ||
304 | } | ||
305 | |||
306 | |||
289 | static void | 307 | static void |
290 | finished_cb () | 308 | finished_cb (enum GNUNET_GenericReturnValue rv) |
291 | { | 309 | { |
292 | struct GNUNET_MessageHeader *reply; | 310 | struct GNUNET_TESTING_CommandLocalFinished *reply; |
311 | size_t msg_length; | ||
293 | 312 | ||
294 | reply = GNUNET_TESTING_send_local_test_finished_msg (); | 313 | msg_length = sizeof(struct GNUNET_TESTING_CommandLocalFinished); |
314 | reply = GNUNET_new (struct GNUNET_TESTING_CommandLocalFinished); | ||
315 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED); | ||
316 | reply->header.size = htons ((uint16_t) msg_length); | ||
317 | reply->rv = rv; | ||
295 | 318 | ||
296 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 319 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
297 | "message prepared\n"); | 320 | "message prepared\n"); |
298 | write_message (reply, ntohs (reply->size)); | 321 | write_message ((struct GNUNET_MessageHeader *) reply, msg_length); |
299 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 322 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
300 | "message send\n"); | 323 | "message send\n"); |
301 | 324 | ||
@@ -337,10 +360,11 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message) | |||
337 | unsigned int namespace_n; | 360 | unsigned int namespace_n; |
338 | 361 | ||
339 | type = ntohs (message->type); | 362 | type = ntohs (message->type); |
340 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
341 | "Received message type %u\n", | ||
342 | type); | ||
343 | msize = ntohs (message->size); | 363 | msize = ntohs (message->size); |
364 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
365 | "Received message type %u and size %u\n", | ||
366 | type, | ||
367 | msize); | ||
344 | if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT == ntohs (message->type)) | 368 | if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT == ntohs (message->type)) |
345 | { | 369 | { |
346 | msg = (const struct GNUNET_TESTING_CommandHelperInit *) message; | 370 | msg = (const struct GNUNET_TESTING_CommandHelperInit *) message; |
@@ -412,13 +436,16 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message) | |||
412 | 436 | ||
413 | return GNUNET_OK; | 437 | return GNUNET_OK; |
414 | } | 438 | } |
415 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED == ntohs ( | 439 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE == ntohs ( |
416 | message->type)) | 440 | message->type)) |
417 | { | 441 | { |
418 | const char *barrier_name; | 442 | const char *barrier_name; |
419 | struct CommandBarrierAdvanced *adm = (struct CommandBarrierAdvanced *) message; | 443 | struct CommandBarrierCrossable *adm = (struct CommandBarrierCrossable *) message; |
420 | 444 | ||
421 | barrier_name = (const char *) &adm[1]; | 445 | barrier_name = (const char *) &adm[1]; |
446 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
447 | "cross barrier %s\n", | ||
448 | barrier_name); | ||
422 | TST_interpreter_finish_attached_cmds (is, barrier_name); | 449 | TST_interpreter_finish_attached_cmds (is, barrier_name); |
423 | return GNUNET_OK; | 450 | return GNUNET_OK; |
424 | } | 451 | } |
diff --git a/src/testing/testing.c b/src/testing/testing.c index b45270d57..f2bf68c08 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -1739,8 +1739,13 @@ GNUNET_TESTING_get_testname_from_underscore (const char *argv0) | |||
1739 | 1739 | ||
1740 | 1740 | ||
1741 | /** | 1741 | /** |
1742 | * FIXME: I'm just janitoring around here. I have no idea what this function | 1742 | * Every line in the topology configuration starts with a string indicating which |
1743 | * is supposed todo. Needs documentation. | 1743 | * kind of information will be configured with this line. Configuration values following |
1744 | * this string are seperated by special sequences of characters. An integer value seperated | ||
1745 | * by ':' is returned by this function. | ||
1746 | * | ||
1747 | * @param line The line of configuration. | ||
1748 | * @return An integer value. | ||
1744 | */ | 1749 | */ |
1745 | static unsigned int | 1750 | static unsigned int |
1746 | get_first_value (const char *line) | 1751 | get_first_value (const char *line) |
@@ -1763,8 +1768,11 @@ get_first_value (const char *line) | |||
1763 | 1768 | ||
1764 | 1769 | ||
1765 | /** | 1770 | /** |
1766 | * FIXME: I'm just janitoring around here. I have no idea what this function | 1771 | * Every line in the topology configuration starts with a string indicating which |
1767 | * is supposed todo. Needs documentation. | 1772 | * kind of information will be configured with this line. This string is returned by this function. |
1773 | * | ||
1774 | * @param line The line of configuration. | ||
1775 | * @return The leading string of this configuration line. | ||
1768 | */ | 1776 | */ |
1769 | static char * | 1777 | static char * |
1770 | get_key (const char *line) | 1778 | get_key (const char *line) |
@@ -1789,8 +1797,13 @@ get_key (const char *line) | |||
1789 | 1797 | ||
1790 | 1798 | ||
1791 | /** | 1799 | /** |
1792 | * FIXME: I'm just janitoring around here. I have no idea what this function | 1800 | * Every line in the topology configuration starts with a string indicating which |
1793 | * is supposed todo. Needs documentation. | 1801 | * kind of information will be configured with this line. Configuration values following |
1802 | * this string are seperated by special sequences of characters. A string value seperated | ||
1803 | * by ':' is returned by this function. | ||
1804 | * | ||
1805 | * @param line The line of configuration. | ||
1806 | * @return A string value. | ||
1794 | */ | 1807 | */ |
1795 | static char * | 1808 | static char * |
1796 | get_first_string_value (const char *line) | 1809 | get_first_string_value (const char *line) |
@@ -1818,8 +1831,13 @@ get_first_string_value (const char *line) | |||
1818 | 1831 | ||
1819 | 1832 | ||
1820 | /** | 1833 | /** |
1821 | * FIXME: I'm just janitoring around here. I have no idea what this function | 1834 | * Every line in the topology configuration starts with a string indicating which |
1822 | * is supposed todo. Needs documentation. | 1835 | * kind of information will be configured with this line. Configuration values following |
1836 | * this string are seperated by special sequences of characters. A second integer value | ||
1837 | * seperated by ':' from a first value is returned by this function. | ||
1838 | * | ||
1839 | * @param line The line of configuration. | ||
1840 | * @return An integer value. | ||
1823 | */ | 1841 | */ |
1824 | static unsigned int | 1842 | static unsigned int |
1825 | get_second_value (const char *line) | 1843 | get_second_value (const char *line) |
@@ -1833,7 +1851,9 @@ get_second_value (const char *line) | |||
1833 | token = strtok_r (copy, ":", &rest); | 1851 | token = strtok_r (copy, ":", &rest); |
1834 | token = strtok_r (NULL, ":", &rest); | 1852 | token = strtok_r (NULL, ":", &rest); |
1835 | token = strtok_r (NULL, ":", &rest); | 1853 | token = strtok_r (NULL, ":", &rest); |
1836 | /* FIXME: ASSERT??? Are we not parsing "user" input here? */ | 1854 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1855 | "Format error in configuration line: %s\n", | ||
1856 | line); | ||
1837 | GNUNET_assert (1 == sscanf (token, "%u", &ret)); | 1857 | GNUNET_assert (1 == sscanf (token, "%u", &ret)); |
1838 | GNUNET_free (copy); | 1858 | GNUNET_free (copy); |
1839 | return ret; | 1859 | return ret; |
@@ -1841,8 +1861,14 @@ get_second_value (const char *line) | |||
1841 | 1861 | ||
1842 | 1862 | ||
1843 | /** | 1863 | /** |
1844 | * FIXME: I'm just janitoring around here. I have no idea what this function | 1864 | * Every line in the topology configuration starts with a string indicating which |
1845 | * is supposed todo. Needs documentation. | 1865 | * kind of information will be configured with this line. Configuration values following |
1866 | * this string are seperated by special sequences of characters. A value might be | ||
1867 | * a key value pair. | ||
1868 | * This function returns the value for a specific key in a configuration line. | ||
1869 | * | ||
1870 | * @param key The key of the key value pair. | ||
1871 | * @return The value of the key value pair. | ||
1846 | */ | 1872 | */ |
1847 | static char * | 1873 | static char * |
1848 | get_value (const char *key, const char *line) | 1874 | get_value (const char *key, const char *line) |
@@ -1873,8 +1899,16 @@ get_value (const char *key, const char *line) | |||
1873 | 1899 | ||
1874 | 1900 | ||
1875 | /** | 1901 | /** |
1876 | * FIXME: I'm just janitoring around here. I have no idea what this function | 1902 | * Every line in the topology configuration starts with a string indicating which |
1877 | * is supposed todo. Needs documentation. | 1903 | * kind of information will be configured with this line. Configuration values following |
1904 | * this string are seperated by special sequences of characters. A value might be | ||
1905 | * a key value pair. A special key is the 'connect' which can appear more than once. | ||
1906 | * The value is the information about a connection via some protocol to some other node. | ||
1907 | * This function returns the struct GNUNET_TESTING_NodeConnection which holds the information | ||
1908 | * of the connect value. | ||
1909 | * | ||
1910 | * @param value The value of the connect key value pair. | ||
1911 | * @return The struct GNUNET_TESTING_NodeConnection. | ||
1878 | */ | 1912 | */ |
1879 | static struct GNUNET_TESTING_NodeConnection * | 1913 | static struct GNUNET_TESTING_NodeConnection * |
1880 | get_connect_value (const char *line, | 1914 | get_connect_value (const char *line, |
@@ -1970,8 +2004,20 @@ get_connect_value (const char *line, | |||
1970 | 2004 | ||
1971 | 2005 | ||
1972 | /** | 2006 | /** |
1973 | * FIXME: I'm just janitoring around here. I have no idea what this function | 2007 | * Every line in the topology configuration starts with a string indicating which |
1974 | * is supposed todo. Needs documentation. | 2008 | * kind of information will be configured with this line. Configuration values following |
2009 | * this string are seperated by special sequences of characters. A value might be | ||
2010 | * a key value pair. A special key is the 'connect' key. | ||
2011 | * The value is the information about a connections via some protocol to other nodes. | ||
2012 | * Each connection itself is a key value pair separated by the character '|' and | ||
2013 | * surrounded by the characters '{' and '}'. | ||
2014 | * The struct GNUNET_TESTING_NodeConnection holds the information of each connection value. | ||
2015 | * This function extracts the values of each connection into a DLL of | ||
2016 | * struct GNUNET_TESTING_NodeConnection which will be added to a node. | ||
2017 | * | ||
2018 | * @param line The line of configuration. | ||
2019 | * @param node The struct GNUNET_TESTING_NetjailNode to which the DLL of | ||
2020 | * struct GNUNET_TESTING_NodeConnection will be added. | ||
1975 | */ | 2021 | */ |
1976 | static void | 2022 | static void |
1977 | node_connections (const char *line, struct GNUNET_TESTING_NetjailNode *node) | 2023 | node_connections (const char *line, struct GNUNET_TESTING_NetjailNode *node) |
@@ -1998,7 +2044,12 @@ node_connections (const char *line, struct GNUNET_TESTING_NetjailNode *node) | |||
1998 | value); | 2044 | value); |
1999 | node_connection = get_connect_value (value, node); | 2045 | node_connection = get_connect_value (value, node); |
2000 | if (NULL == node_connection) | 2046 | if (NULL == node_connection) |
2001 | break; /* FIXME: continue? */ | 2047 | { |
2048 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
2049 | "connect key was not expected in this configuration line: %s\n", | ||
2050 | line); | ||
2051 | break; | ||
2052 | } | ||
2002 | GNUNET_CONTAINER_DLL_insert (node->node_connections_head, | 2053 | GNUNET_CONTAINER_DLL_insert (node->node_connections_head, |
2003 | node->node_connections_tail, | 2054 | node->node_connections_tail, |
2004 | node_connection); | 2055 | node_connection); |
@@ -2014,8 +2065,12 @@ node_connections (const char *line, struct GNUNET_TESTING_NetjailNode *node) | |||
2014 | 2065 | ||
2015 | 2066 | ||
2016 | /** | 2067 | /** |
2017 | * FIXME: I'm just janitoring around here. I have no idea what this function | 2068 | * A helper function to log information about individual nodes. |
2018 | * is supposed todo. Needs documentation. | 2069 | * |
2070 | * @param cls This is not used actually. | ||
2071 | * @param id The key of this value in the map. | ||
2072 | * @param value A struct GNUNET_TESTING_NetjailNode which holds information about a node. | ||
2073 | * return GNUNET_YES to continue with iterating, GNUNET_NO otherwise. | ||
2019 | */ | 2074 | */ |
2020 | static int | 2075 | static int |
2021 | log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value) | 2076 | log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value) |
@@ -2054,6 +2109,14 @@ log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value) | |||
2054 | } | 2109 | } |
2055 | 2110 | ||
2056 | 2111 | ||
2112 | /** | ||
2113 | * Helper function to log information about namespaces. | ||
2114 | * | ||
2115 | * @param cls This is not used actually. | ||
2116 | * @param id The key of this value in the map. | ||
2117 | * @param value A struct GNUNET_TESTING_NetjailNamespace which holds information about a subnet. | ||
2118 | * return GNUNET_YES to continue with iterating, GNUNET_NO otherwise. | ||
2119 | */ | ||
2057 | static int | 2120 | static int |
2058 | log_namespaces (void *cls, const struct GNUNET_ShortHashCode *id, void *value) | 2121 | log_namespaces (void *cls, const struct GNUNET_ShortHashCode *id, void *value) |
2059 | { | 2122 | { |
@@ -2064,6 +2127,11 @@ log_namespaces (void *cls, const struct GNUNET_ShortHashCode *id, void *value) | |||
2064 | } | 2127 | } |
2065 | 2128 | ||
2066 | 2129 | ||
2130 | /** | ||
2131 | * Helper function to log the configuration in case of a problem with configuration. | ||
2132 | * | ||
2133 | * @param topology The struct GNUNET_TESTING_NetjailTopology holding the configuration information. | ||
2134 | */ | ||
2067 | static int | 2135 | static int |
2068 | log_topo (const struct GNUNET_TESTING_NetjailTopology *topology) | 2136 | log_topo (const struct GNUNET_TESTING_NetjailTopology *topology) |
2069 | { | 2137 | { |
@@ -2082,9 +2150,15 @@ log_topo (const struct GNUNET_TESTING_NetjailTopology *topology) | |||
2082 | } | 2150 | } |
2083 | 2151 | ||
2084 | /** | 2152 | /** |
2085 | * FIXME: I'm just janitoring around here. I have no idea what this function | 2153 | * This function extracts information about a specific node from the topology. |
2086 | * is supposed todo. Needs documentation. | 2154 | * |
2087 | */ | 2155 | * @param num The global index number of the node. |
2156 | * @param[out] node_ex A struct GNUNET_TESTING_NetjailNode with information about the node. | ||
2157 | * @param[out] namespace_ex A struct GNUNET_TESTING_NetjailNamespace with information about the namespace | ||
2158 | the node is in or NULL, if the node is a global node. | ||
2159 | * @param[out] node_connections_ex A struct GNUNET_TESTING_NodeConnection with information about the connection | ||
2160 | of this node to other nodes. | ||
2161 | */ | ||
2088 | static void | 2162 | static void |
2089 | get_node_info (unsigned int num, | 2163 | get_node_info (unsigned int num, |
2090 | const struct GNUNET_TESTING_NetjailTopology *topology, | 2164 | const struct GNUNET_TESTING_NetjailTopology *topology, |
@@ -2206,10 +2280,14 @@ GNUNET_TESTING_get_connections (unsigned int num, | |||
2206 | 2280 | ||
2207 | 2281 | ||
2208 | /** | 2282 | /** |
2209 | * FIXME: Function named incorrectly IMO | 2283 | * Retrieve the peer identity from the test system with the unique node id. |
2284 | * | ||
2285 | * @param num The unique node id. | ||
2286 | * @param tl_system The test system. | ||
2287 | * @return The peer identity wrapping the public key. | ||
2210 | */ | 2288 | */ |
2211 | struct GNUNET_PeerIdentity * | 2289 | struct GNUNET_PeerIdentity * |
2212 | GNUNET_TESTING_get_pub_key (unsigned int num, | 2290 | GNUNET_TESTING_get_peer (unsigned int num, |
2213 | const struct GNUNET_TESTING_System *tl_system) | 2291 | const struct GNUNET_TESTING_System *tl_system) |
2214 | { | 2292 | { |
2215 | struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity); | 2293 | struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity); |
@@ -2412,22 +2490,6 @@ GNUNET_TESTING_get_additional_connects (unsigned int num, | |||
2412 | return node->additional_connects; | 2490 | return node->additional_connects; |
2413 | } | 2491 | } |
2414 | 2492 | ||
2415 | |||
2416 | struct GNUNET_MessageHeader * | ||
2417 | GNUNET_TESTING_send_local_test_finished_msg () | ||
2418 | { | ||
2419 | struct GNUNET_CMDS_LOCAL_FINISHED *reply; | ||
2420 | size_t msg_length; | ||
2421 | |||
2422 | msg_length = sizeof(struct GNUNET_CMDS_LOCAL_FINISHED); | ||
2423 | reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_FINISHED); | ||
2424 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED); | ||
2425 | reply->header.size = htons ((uint16_t) msg_length); | ||
2426 | |||
2427 | return (struct GNUNET_MessageHeader *) reply; | ||
2428 | } | ||
2429 | |||
2430 | |||
2431 | static void | 2493 | static void |
2432 | parse_ac (struct GNUNET_TESTING_NetjailNode *p_node, const char *token) | 2494 | parse_ac (struct GNUNET_TESTING_NetjailNode *p_node, const char *token) |
2433 | { | 2495 | { |
diff --git a/src/testing/testing.h b/src/testing/testing.h index debcec39a..adcb50a13 100644 --- a/src/testing/testing.h +++ b/src/testing/testing.h | |||
@@ -30,12 +30,11 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
30 | 30 | ||
31 | /** | 31 | /** |
32 | * Message send to a child loop to inform the child loop about a barrier being advanced. | 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 | */ | 33 | */ |
35 | struct CommandBarrierAdvanced | 34 | struct CommandBarrierCrossable |
36 | { | 35 | { |
37 | /** | 36 | /** |
38 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED | 37 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE |
39 | */ | 38 | */ |
40 | struct GNUNET_MessageHeader header; | 39 | struct GNUNET_MessageHeader header; |
41 | 40 | ||
@@ -45,7 +44,6 @@ struct CommandBarrierAdvanced | |||
45 | /** | 44 | /** |
46 | * Message send by a child loop to inform the master loop how much | 45 | * Message send by a child loop to inform the master loop how much |
47 | * GNUNET_CMDS_BARRIER_REACHED messages the child will send. | 46 | * GNUNET_CMDS_BARRIER_REACHED messages the child will send. |
48 | * FIXME: Not packed and contains char*; int in NBO? bitlength undefined. | ||
49 | */ | 47 | */ |
50 | struct CommandBarrierAttached | 48 | struct CommandBarrierAttached |
51 | { | 49 | { |
@@ -260,60 +258,26 @@ GNUNET_TESTING_cmd_batch_set_current_ (const struct GNUNET_TESTING_Command *cmd, | |||
260 | unsigned int new_ip); | 258 | unsigned int new_ip); |
261 | 259 | ||
262 | 260 | ||
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 | /** | 261 | /** |
267 | * FIXME: Documentation | 262 | * This function checks, if a barrier can be crossed, which actually means that |
268 | * FIXME: Now this, as it returns a Command, seems to me like it should be | 263 | * the cmd representing the barrier is finished. |
269 | * part of the public API? | ||
270 | * Create command. | ||
271 | * | ||
272 | * @param label name for command. | ||
273 | * @param barrier_label The name of the barrier we wait for and which will be reached. | ||
274 | * @param asynchronous_finish If GNUNET_YES this command will not block. Can be NULL. | ||
275 | * @param asynchronous_finish If GNUNET_YES this command will not block. Can be NULL. | ||
276 | * @param node_number The global numer of the node the cmd runs on. | ||
277 | * @param running_on_master Is this cmd running on the master loop. | ||
278 | * @param write_message Callback to write messages to the master loop. | ||
279 | * @return command. | ||
280 | */ | ||
281 | struct GNUNET_TESTING_Command | ||
282 | GNUNET_TESTING_cmd_barrier_reached ( | ||
283 | const char *label, | ||
284 | const char *barrier_label, | ||
285 | unsigned int asynchronous_finish, | ||
286 | unsigned int node_number, | ||
287 | unsigned int running_on_master, | ||
288 | GNUNET_TESTING_cmd_helper_write_cb write_message); | ||
289 | |||
290 | |||
291 | /** | ||
292 | * Can we advance the barrier? | ||
293 | * FIXME: As this is not in testing.h it should be in another namespace. | ||
294 | * Possibly BARRIER_can_advance. However, as this is also used in a netjail cmd, | ||
295 | * I am not sure if this needs to be public? Maybe there should be a barrier | ||
296 | * trait that returns a barrier where this helper function can be called on? | ||
297 | * Barriers are usually also not "advanced" but "crossed" or "passed" | ||
298 | * but it seems to me that the word here should correctly be "reached"? | ||
299 | * | 264 | * |
300 | * @param barrier The barrier in question. | 265 | * @param barrier The barrier in question. |
301 | * @return GNUNET_YES if we can advance the barrier, GNUNET_NO if not. | 266 | * @return GNUNET_YES if we can cross the barrier, GNUNET_NO if not. |
302 | */ | 267 | */ |
303 | unsigned int | 268 | unsigned int |
304 | GNUNET_TESTING_can_barrier_advance (struct GNUNET_TESTING_Barrier *barrier); | 269 | GNUNET_TESTING_barrier_crossable (struct GNUNET_TESTING_Barrier *barrier); |
305 | 270 | ||
306 | 271 | ||
307 | /** | 272 | /** |
308 | * FIXME: Naming | 273 | * Send Message to a netjail node that a barrier can be crossed. |
309 | * Send Message to netjail nodes that a barrier can be advanced. | ||
310 | * | 274 | * |
311 | * @param is The interpreter loop. | 275 | * @param is The interpreter loop. |
312 | * @param barrier_name The name of the barrier to advance. | 276 | * @param barrier_name The name of the barrier to cross. |
313 | * @param global_node_number The global number of the node to inform. | 277 | * @param global_node_number The global number of the node to inform. |
314 | */ | 278 | */ |
315 | void | 279 | void |
316 | TST_interpreter_send_barrier_advance (struct GNUNET_TESTING_Interpreter *is, | 280 | TST_interpreter_send_barrier_crossable (struct GNUNET_TESTING_Interpreter *is, |
317 | const char *barrier_name, | 281 | const char *barrier_name, |
318 | unsigned int global_node_number); | 282 | unsigned int global_node_number); |
319 | 283 | ||
@@ -333,7 +297,7 @@ TST_interpreter_finish_attached_cmds (struct GNUNET_TESTING_Interpreter *is, | |||
333 | * FIXME: Unused function | 297 | * FIXME: Unused function |
334 | * | 298 | * |
335 | * @param is The interpreter loop. | 299 | * @param is The interpreter loop. |
336 | * @param barrier_name The name of the barrier to advance. | 300 | * @param barrier_name The name of the barrier to attach to. |
337 | * @param subnet_number The number of the subnet. | 301 | * @param subnet_number The number of the subnet. |
338 | * @param node_number The node to inform. | 302 | * @param node_number The node to inform. |
339 | * @param write_message Callback to write messages to the master loop. | 303 | * @param write_message Callback to write messages to the master loop. |
diff --git a/src/testing/testing_api_cmd_barrier.c b/src/testing/testing_api_cmd_barrier.c index bc4f79eb6..118918bc4 100644 --- a/src/testing/testing_api_cmd_barrier.c +++ b/src/testing/testing_api_cmd_barrier.c | |||
@@ -30,6 +30,11 @@ | |||
30 | #include "gnunet_testing_netjail_lib.h" | 30 | #include "gnunet_testing_netjail_lib.h" |
31 | #include "gnunet_testing_barrier.h" | 31 | #include "gnunet_testing_barrier.h" |
32 | 32 | ||
33 | /** | ||
34 | * Generic logging shortcut | ||
35 | */ | ||
36 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
37 | |||
33 | struct BarrierState | 38 | struct BarrierState |
34 | { | 39 | { |
35 | /* | 40 | /* |
@@ -70,13 +75,22 @@ GNUNET_TESTING_send_barrier_attach (struct GNUNET_TESTING_Interpreter *is, | |||
70 | 75 | ||
71 | 76 | ||
72 | unsigned int | 77 | unsigned int |
73 | GNUNET_TESTING_can_barrier_advance (struct GNUNET_TESTING_Barrier *barrier) | 78 | GNUNET_TESTING_barrier_crossable (struct GNUNET_TESTING_Barrier *barrier) |
74 | { | 79 | { |
75 | unsigned int expected_reaches = barrier->expected_reaches; | 80 | unsigned int expected_reaches = barrier->expected_reaches; |
76 | unsigned int reached = barrier->reached; | 81 | unsigned int reached = barrier->reached; |
77 | double percentage_to_be_reached = barrier->percentage_to_be_reached; | 82 | double percentage_to_be_reached = barrier->percentage_to_be_reached; |
78 | unsigned int number_to_be_reached = barrier->number_to_be_reached; | 83 | unsigned int number_to_be_reached = barrier->number_to_be_reached; |
79 | double percentage_reached = (double) expected_reaches / reached * 100; | 84 | double percentage_reached = (double) reached / expected_reaches * 100; |
85 | |||
86 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
87 | "%u %f %f %u %u\n", | ||
88 | expected_reaches, | ||
89 | percentage_to_be_reached, | ||
90 | percentage_reached, | ||
91 | number_to_be_reached, | ||
92 | reached); | ||
93 | |||
80 | if (((0 < percentage_to_be_reached) && | 94 | if (((0 < percentage_to_be_reached) && |
81 | (percentage_reached >= percentage_to_be_reached)) || | 95 | (percentage_reached >= percentage_to_be_reached)) || |
82 | ((0 < number_to_be_reached) && (reached >= number_to_be_reached))) | 96 | ((0 < number_to_be_reached) && (reached >= number_to_be_reached))) |
@@ -173,6 +187,8 @@ GNUNET_TESTING_cmd_barrier_create (const char *label, | |||
173 | bs->label = label; | 187 | bs->label = label; |
174 | barrier = GNUNET_new (struct GNUNET_TESTING_Barrier); | 188 | barrier = GNUNET_new (struct GNUNET_TESTING_Barrier); |
175 | barrier->name = label; | 189 | barrier->name = label; |
190 | barrier->percentage_to_be_reached = percentage_to_be_reached; | ||
191 | barrier->number_to_be_reached = number_to_be_reached; | ||
176 | GNUNET_assert ((0 < percentage_to_be_reached && 0 == number_to_be_reached) || | 192 | GNUNET_assert ((0 < percentage_to_be_reached && 0 == number_to_be_reached) || |
177 | (0 == percentage_to_be_reached && 0 < number_to_be_reached)); | 193 | (0 == percentage_to_be_reached && 0 < number_to_be_reached)); |
178 | bs->barrier = barrier; | 194 | bs->barrier = barrier; |
diff --git a/src/testing/testing_api_cmd_barrier_reached.c b/src/testing/testing_api_cmd_barrier_reached.c index 8d52310c9..3c2ba3a1d 100644 --- a/src/testing/testing_api_cmd_barrier_reached.c +++ b/src/testing/testing_api_cmd_barrier_reached.c | |||
@@ -25,13 +25,18 @@ | |||
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_testing_lib.h" | 27 | #include "gnunet_testing_lib.h" |
28 | #include "gnunet_testing_ng_lib.h" | 28 | #include "testing_cmds.h" |
29 | #include "gnunet_testing_plugin.h" | 29 | #include "gnunet_testing_plugin.h" |
30 | #include "gnunet_testing_barrier.h" | 30 | #include "gnunet_testing_barrier.h" |
31 | #include "gnunet_testing_netjail_lib.h" | 31 | #include "gnunet_testing_netjail_lib.h" |
32 | #include "testing.h" | 32 | #include "testing.h" |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * Generic logging shortcut | ||
36 | */ | ||
37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
38 | |||
39 | /** | ||
35 | * Struct with information for callbacks. | 40 | * Struct with information for callbacks. |
36 | * | 41 | * |
37 | */ | 42 | */ |
@@ -87,7 +92,7 @@ barrier_reached_run (void *cls, | |||
87 | { | 92 | { |
88 | struct BarrierReachedState *brs = cls; | 93 | struct BarrierReachedState *brs = cls; |
89 | struct GNUNET_TESTING_Barrier *barrier; | 94 | struct GNUNET_TESTING_Barrier *barrier; |
90 | struct GNUNET_TESTING_Command *cmd = NULL; | 95 | struct GNUNET_TESTING_Command *cmd = GNUNET_TESTING_interpreter_get_current_command (is); |
91 | struct CommandListEntry *cle; | 96 | struct CommandListEntry *cle; |
92 | size_t msg_length; | 97 | size_t msg_length; |
93 | struct GNUNET_TESTING_CommandBarrierReached *msg; | 98 | struct GNUNET_TESTING_CommandBarrierReached *msg; |
@@ -97,43 +102,44 @@ barrier_reached_run (void *cls, | |||
97 | if (NULL == barrier) | 102 | if (NULL == barrier) |
98 | { | 103 | { |
99 | barrier = GNUNET_new (struct GNUNET_TESTING_Barrier); | 104 | barrier = GNUNET_new (struct GNUNET_TESTING_Barrier); |
100 | barrier->shadow = GNUNET_YES; | 105 | barrier->name = brs->barrier_name; |
101 | barrier->name = brs->label; | ||
102 | TST_interpreter_add_barrier (is, barrier); | 106 | TST_interpreter_add_barrier (is, barrier); |
107 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
108 | "barrier %s added locally\n", | ||
109 | brs->barrier_name); | ||
103 | } | 110 | } |
104 | barrier->reached++; | 111 | barrier->reached++; |
105 | if (GNUNET_TESTING_can_barrier_advance (barrier)) | 112 | if (GNUNET_TESTING_barrier_crossable (barrier)) |
106 | { | 113 | { |
107 | //FIXME cmd uninitialized | ||
108 | GNUNET_assert (NULL != cmd); | 114 | GNUNET_assert (NULL != cmd); |
109 | cmd->asynchronous_finish = GNUNET_YES; | 115 | cmd->asynchronous_finish = GNUNET_YES; |
110 | TST_interpreter_finish_attached_cmds (is, barrier->name); | 116 | TST_interpreter_finish_attached_cmds (is, barrier->name); |
111 | } | 117 | } |
112 | else if (GNUNET_NO == brs->asynchronous_finish) | 118 | else if (GNUNET_NO == brs->asynchronous_finish) |
113 | { | 119 | { |
114 | /** FIXME: This is already fishy as commands in is are an array | ||
115 | * It is unclear how this does not end up with a DLL issue. | ||
116 | * We should create a dedicated struct to hold this list. | ||
117 | */ | ||
118 | cle = GNUNET_new (struct CommandListEntry); | 120 | cle = GNUNET_new (struct CommandListEntry); |
119 | cle->command = GNUNET_TESTING_interpreter_get_current_command (is); | 121 | cle->command = cmd; |
120 | GNUNET_CONTAINER_DLL_insert (barrier->cmds_head, | 122 | GNUNET_CONTAINER_DLL_insert (barrier->cmds_head, |
121 | barrier->cmds_tail, | 123 | barrier->cmds_tail, |
122 | cle); | 124 | cle); |
125 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
126 | "added cle for %p %s\n", | ||
127 | barrier, | ||
128 | barrier->name); | ||
123 | } | 129 | } |
124 | else | 130 | |
125 | { | ||
126 | cmd->asynchronous_finish = GNUNET_YES; | ||
127 | } | ||
128 | if (GNUNET_NO == brs->running_on_master) | 131 | if (GNUNET_NO == brs->running_on_master) |
129 | { | 132 | { |
130 | name_len = strlen (barrier->name) + 1; | 133 | char *terminator = "\0"; |
131 | msg_length = sizeof(struct GNUNET_TESTING_CommandBarrierReached); | 134 | |
132 | msg = GNUNET_new (struct GNUNET_TESTING_CommandBarrierReached); | 135 | name_len = strlen (barrier->name); |
136 | msg_length = sizeof(struct GNUNET_TESTING_CommandBarrierReached) + name_len + 1; | ||
137 | msg = GNUNET_malloc (msg_length); | ||
133 | msg->header.size = htons ((uint16_t) msg_length); | 138 | msg->header.size = htons ((uint16_t) msg_length); |
134 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED); | 139 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED); |
135 | memcpy (&msg[1], barrier->name, name_len); | ||
136 | msg->node_number = brs->node_number; | 140 | msg->node_number = brs->node_number; |
141 | memcpy (&msg[1], barrier->name, name_len + 1); | ||
142 | memcpy(&msg[name_len + 1],terminator,1); | ||
137 | brs->write_message ((struct GNUNET_MessageHeader *) msg, msg_length); | 143 | brs->write_message ((struct GNUNET_MessageHeader *) msg, msg_length); |
138 | } | 144 | } |
139 | } | 145 | } |
@@ -189,7 +195,7 @@ barrier_reached_traits (void *cls, | |||
189 | * | 195 | * |
190 | * @param label name for command. | 196 | * @param label name for command. |
191 | * @param barrier_label The name of the barrier we wait for (if finishing asynchronous) and which will be reached. | 197 | * @param barrier_label The name of the barrier we wait for (if finishing asynchronous) and which will be reached. |
192 | * @param asynchronous_finish If GNUNET_YES this command will not block. Can be NULL. | 198 | * @param asynchronous_finish If GNUNET_YES this command will not block. |
193 | * @param node_number The global numer of the node the cmd runs on. | 199 | * @param node_number The global numer of the node the cmd runs on. |
194 | * @param running_on_master Is this cmd running on the master loop. | 200 | * @param running_on_master Is this cmd running on the master loop. |
195 | * @param write_message Callback to write messages to the master loop. | 201 | * @param write_message Callback to write messages to the master loop. |
diff --git a/src/testing/testing_api_cmd_block_until_external_trigger.c b/src/testing/testing_api_cmd_block_until_external_trigger.c index 2219ec246..81a43a3ac 100644 --- a/src/testing/testing_api_cmd_block_until_external_trigger.c +++ b/src/testing/testing_api_cmd_block_until_external_trigger.c | |||
@@ -25,7 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_testing_ng_lib.h" | 28 | #include "testing_cmds.h" |
29 | #include "gnunet_testing_plugin.h" | 29 | #include "gnunet_testing_plugin.h" |
30 | #include "gnunet_testing_barrier.h" | 30 | #include "gnunet_testing_barrier.h" |
31 | #include "gnunet_testing_netjail_lib.h" | 31 | #include "gnunet_testing_netjail_lib.h" |
diff --git a/src/testing/testing_api_cmd_local_test_finished.c b/src/testing/testing_api_cmd_local_test_finished.c deleted file mode 100644 index f54b67acf..000000000 --- a/src/testing/testing_api_cmd_local_test_finished.c +++ /dev/null | |||
@@ -1,116 +0,0 @@ | |||
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 testing_api_cmd_local_test_finished.c | ||
23 | * @brief cmd to block the interpreter loop until all peers started. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testing_ng_lib.h" | ||
29 | #include "gnunet_testing_plugin.h" | ||
30 | #include "gnunet_testing_barrier.h" | ||
31 | #include "gnunet_testing_netjail_lib.h" | ||
32 | #include "testing_cmds.h" | ||
33 | |||
34 | /** | ||
35 | * Generic logging shortcut | ||
36 | */ | ||
37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
38 | |||
39 | |||
40 | /** | ||
41 | * Struct to hold information for callbacks. | ||
42 | * | ||
43 | */ | ||
44 | struct LocalFinishedState | ||
45 | { | ||
46 | |||
47 | /** | ||
48 | * Callback to write messages to the master loop. | ||
49 | * | ||
50 | */ | ||
51 | GNUNET_TESTING_cmd_helper_write_cb write_message; | ||
52 | |||
53 | /** | ||
54 | * The message send back to the master loop. | ||
55 | * | ||
56 | */ | ||
57 | struct GNUNET_CMDS_LOCAL_FINISHED *reply; | ||
58 | }; | ||
59 | |||
60 | |||
61 | /** | ||
62 | * The cleanup function of this cmd frees resources the cmd allocated. | ||
63 | * | ||
64 | */ | ||
65 | static void | ||
66 | local_test_finished_cleanup (void *cls) | ||
67 | { | ||
68 | struct LocalFinishedState *lfs = cls; | ||
69 | |||
70 | GNUNET_free (lfs); | ||
71 | } | ||
72 | |||
73 | |||
74 | /** | ||
75 | * This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED message to the master loop. | ||
76 | * | ||
77 | */ | ||
78 | static void | ||
79 | local_test_finished_run (void *cls, | ||
80 | struct GNUNET_TESTING_Interpreter *is) | ||
81 | { | ||
82 | struct LocalFinishedState *lfs = cls; | ||
83 | struct GNUNET_CMDS_LOCAL_FINISHED *reply; | ||
84 | size_t msg_length; | ||
85 | |||
86 | msg_length = sizeof(struct GNUNET_CMDS_LOCAL_FINISHED); | ||
87 | reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_FINISHED); | ||
88 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED); | ||
89 | reply->header.size = htons ((uint16_t) msg_length); | ||
90 | lfs->reply = reply; | ||
91 | lfs->write_message ((struct GNUNET_MessageHeader *) reply, | ||
92 | msg_length); | ||
93 | } | ||
94 | |||
95 | |||
96 | /** | ||
97 | * Create command. | ||
98 | * | ||
99 | * @param label name for command. | ||
100 | * @param write_message Callback to write messages to the master loop. | ||
101 | * @return command. | ||
102 | */ | ||
103 | struct GNUNET_TESTING_Command | ||
104 | GNUNET_TESTING_cmd_local_test_finished ( | ||
105 | const char *label, | ||
106 | GNUNET_TESTING_cmd_helper_write_cb write_message) | ||
107 | { | ||
108 | struct LocalFinishedState *lfs; | ||
109 | |||
110 | lfs = GNUNET_new (struct LocalFinishedState); | ||
111 | lfs->write_message = write_message; | ||
112 | return GNUNET_TESTING_command_new (lfs, label, | ||
113 | &local_test_finished_run, | ||
114 | &local_test_finished_cleanup, | ||
115 | NULL, NULL); | ||
116 | } | ||
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem.c b/src/testing/testing_api_cmd_netjail_start_cmds_helper.c index 40a23c67c..c0f238530 100644 --- a/src/testing/testing_api_cmd_netjail_start_testsystem.c +++ b/src/testing/testing_api_cmd_netjail_start_cmds_helper.c | |||
@@ -356,7 +356,7 @@ barrier_attached (struct NetJailState *ns, const struct | |||
356 | am = (struct CommandBarrierAttached *) message; | 356 | am = (struct CommandBarrierAttached *) message; |
357 | barrier_name = (const char *) &am[1]; | 357 | barrier_name = (const char *) &am[1]; |
358 | barrier = TST_interpreter_get_barrier (ns->is, barrier_name); | 358 | barrier = TST_interpreter_get_barrier (ns->is, barrier_name); |
359 | GNUNET_assert (NULL != barrier && GNUNET_NO == barrier->shadow); | 359 | GNUNET_assert (NULL != barrier); |
360 | node = GNUNET_TESTING_barrier_get_node (barrier, am->node_number); | 360 | node = GNUNET_TESTING_barrier_get_node (barrier, am->node_number); |
361 | if (NULL == node) | 361 | if (NULL == node) |
362 | { | 362 | { |
@@ -386,13 +386,29 @@ barrier_reached (struct NetJailState *ns, const struct | |||
386 | *) message; | 386 | *) message; |
387 | 387 | ||
388 | barrier_name = (const char *) &rm[1]; | 388 | barrier_name = (const char *) &rm[1]; |
389 | |||
389 | barrier = TST_interpreter_get_barrier (ns->is, barrier_name); | 390 | barrier = TST_interpreter_get_barrier (ns->is, barrier_name); |
390 | GNUNET_assert (NULL != barrier && GNUNET_NO == barrier->shadow); | 391 | GNUNET_assert (NULL != barrier); |
392 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
393 | "barrier %s reached %p %u\n", | ||
394 | barrier_name, | ||
395 | barrier, | ||
396 | barrier->reached); | ||
391 | barrier->reached++; | 397 | barrier->reached++; |
392 | if (GNUNET_TESTING_can_barrier_advance (barrier)) | 398 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
399 | "%u %p\n", | ||
400 | barrier->reached, | ||
401 | barrier); | ||
402 | if (GNUNET_TESTING_barrier_crossable (barrier)) | ||
393 | { | 403 | { |
404 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
405 | "%s can be crossed\n", | ||
406 | barrier_name); | ||
394 | TST_interpreter_finish_attached_cmds (ns->is, barrier->name); | 407 | TST_interpreter_finish_attached_cmds (ns->is, barrier->name); |
395 | } | 408 | } |
409 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
410 | "barrier %s reached finished\n", | ||
411 | barrier_name); | ||
396 | } | 412 | } |
397 | 413 | ||
398 | 414 | ||
@@ -414,6 +430,7 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | |||
414 | struct NetJailState *ns = cls; | 430 | struct NetJailState *ns = cls; |
415 | unsigned int total_number = ns->local_m * ns->global_n + ns->known; | 431 | unsigned int total_number = ns->local_m * ns->global_n + ns->known; |
416 | uint16_t message_type = ntohs (message->type); | 432 | uint16_t message_type = ntohs (message->type); |
433 | struct GNUNET_TESTING_CommandLocalFinished *lf; | ||
417 | 434 | ||
418 | switch (message_type) | 435 | switch (message_type) |
419 | { | 436 | { |
@@ -463,8 +480,13 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | |||
463 | } | 480 | } |
464 | break; | 481 | break; |
465 | case GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED: | 482 | case GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED: |
483 | lf = (struct GNUNET_TESTING_CommandLocalFinished *) message; | ||
484 | |||
466 | ns->number_of_local_tests_finished++; | 485 | ns->number_of_local_tests_finished++; |
467 | if (ns->number_of_local_tests_finished == total_number) | 486 | if (GNUNET_OK != lf->rv) |
487 | { | ||
488 | GNUNET_TESTING_async_fail (&(ns->ac)); | ||
489 | } else if (ns->number_of_local_tests_finished == total_number) | ||
468 | { | 490 | { |
469 | GNUNET_SCHEDULER_cancel (ns->timeout_task); | 491 | GNUNET_SCHEDULER_cancel (ns->timeout_task); |
470 | GNUNET_TESTING_async_finish (&ns->ac); | 492 | GNUNET_TESTING_async_finish (&ns->ac); |
@@ -570,11 +592,19 @@ start_helper (struct NetJailState *ns, | |||
570 | struct GNUNET_TESTING_BarrierListEntry *pos; | 592 | struct GNUNET_TESTING_BarrierListEntry *pos; |
571 | struct GNUNET_TESTING_Barrier *barrier; | 593 | struct GNUNET_TESTING_Barrier *barrier; |
572 | struct GNUNET_TESTING_BarrierList *barriers; | 594 | struct GNUNET_TESTING_BarrierList *barriers; |
595 | unsigned int node_num; | ||
596 | char *binary_path; | ||
573 | 597 | ||
574 | if (0 == n) | 598 | if (0 == n) |
599 | { | ||
600 | node_num = m; | ||
575 | script_num = m - 1; | 601 | script_num = m - 1; |
602 | } | ||
576 | else | 603 | else |
604 | { | ||
605 | node_num = (n - 1) * ns->local_m + m + ns->known; | ||
577 | script_num = n - 1 + (n - 1) * ns->local_m + m + ns->known; | 606 | script_num = n - 1 + (n - 1) * ns->local_m + m + ns->known; |
607 | } | ||
578 | pid = getpid (); | 608 | pid = getpid (); |
579 | 609 | ||
580 | GNUNET_asprintf (&m_char, "%u", m); | 610 | GNUNET_asprintf (&m_char, "%u", m); |
@@ -613,6 +643,8 @@ start_helper (struct NetJailState *ns, | |||
613 | GNUNET_TESTING_interpreter_fail (ns->is); | 643 | GNUNET_TESTING_interpreter_fail (ns->is); |
614 | } | 644 | } |
615 | 645 | ||
646 | binary_path = GNUNET_OS_get_libexec_binary_path (HELPER_CMDS_BINARY); | ||
647 | |||
616 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 648 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
617 | "sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n", | 649 | "sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n", |
618 | ns->number_of_testsystems_started, | 650 | ns->number_of_testsystems_started, |
@@ -626,8 +658,7 @@ start_helper (struct NetJailState *ns, | |||
626 | char *const script_argv[] = {script_name, | 658 | char *const script_argv[] = {script_name, |
627 | m_char, | 659 | m_char, |
628 | n_char, | 660 | n_char, |
629 | GNUNET_OS_get_libexec_binary_path ( | 661 | binary_path, |
630 | HELPER_CMDS_BINARY), | ||
631 | global_n_char, | 662 | global_n_char, |
632 | local_m_char, | 663 | local_m_char, |
633 | node_id, | 664 | node_id, |
@@ -643,17 +674,14 @@ start_helper (struct NetJailState *ns, | |||
643 | ns); | 674 | ns); |
644 | GNUNET_array_append (ns->helper, ns->n_helper, helper); | 675 | GNUNET_array_append (ns->helper, ns->n_helper, helper); |
645 | } | 676 | } |
646 | |||
647 | GNUNET_TESTING_add_netjail_helper (ns->is, | 677 | GNUNET_TESTING_add_netjail_helper (ns->is, |
648 | helper); | 678 | helper); |
649 | |||
650 | plugin_name = topology->plugin; | 679 | plugin_name = topology->plugin; |
651 | 680 | ||
652 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | 681 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); |
653 | if (0 == m) | 682 | if (0 == n) |
654 | { | 683 | { |
655 | 684 | GNUNET_CRYPTO_hash (&m, sizeof(m), &hc); | |
656 | GNUNET_CRYPTO_hash (&n, sizeof(n), &hc); | ||
657 | memcpy (hkey, | 685 | memcpy (hkey, |
658 | &hc, | 686 | &hc, |
659 | sizeof (*hkey)); | 687 | sizeof (*hkey)); |
@@ -665,11 +693,10 @@ start_helper (struct NetJailState *ns, | |||
665 | if (NULL != node->plugin) | 693 | if (NULL != node->plugin) |
666 | plugin_name = node->plugin; | 694 | plugin_name = node->plugin; |
667 | } | 695 | } |
668 | |||
669 | } | 696 | } |
670 | else | 697 | else |
671 | { | 698 | { |
672 | GNUNET_CRYPTO_hash (&m, sizeof(m), &hc); | 699 | GNUNET_CRYPTO_hash (&n, sizeof(n), &hc); |
673 | memcpy (hkey, | 700 | memcpy (hkey, |
674 | &hc, | 701 | &hc, |
675 | sizeof (*hkey)); | 702 | sizeof (*hkey)); |
@@ -678,7 +705,7 @@ start_helper (struct NetJailState *ns, | |||
678 | { | 705 | { |
679 | namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces, | 706 | namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces, |
680 | hkey); | 707 | hkey); |
681 | GNUNET_CRYPTO_hash (&n, sizeof(n), &hc); | 708 | GNUNET_CRYPTO_hash (&m, sizeof(m), &hc); |
682 | memcpy (hkey, | 709 | memcpy (hkey, |
683 | &hc, | 710 | &hc, |
684 | sizeof (*hkey)); | 711 | sizeof (*hkey)); |
@@ -694,7 +721,8 @@ start_helper (struct NetJailState *ns, | |||
694 | 721 | ||
695 | 722 | ||
696 | } | 723 | } |
697 | 724 | GNUNET_assert (NULL != node); | |
725 | node->node_number = node_num; | ||
698 | plugin = GNUNET_new (struct TestcasePlugin); | 726 | plugin = GNUNET_new (struct TestcasePlugin); |
699 | plugin->api = GNUNET_PLUGIN_load (plugin_name, | 727 | plugin->api = GNUNET_PLUGIN_load (plugin_name, |
700 | NULL); | 728 | NULL); |
@@ -704,28 +732,49 @@ start_helper (struct NetJailState *ns, | |||
704 | for (pos = barriers->head; NULL != pos; pos = pos->next) | 732 | for (pos = barriers->head; NULL != pos; pos = pos->next) |
705 | { | 733 | { |
706 | barrier = TST_interpreter_get_barrier (ns->is, pos->barrier_name); | 734 | barrier = TST_interpreter_get_barrier (ns->is, pos->barrier_name); |
707 | if (NULL == barrier || GNUNET_YES == barrier->shadow) | 735 | if (NULL == barrier) |
708 | { | 736 | { |
737 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
738 | "barrier %s added\n", | ||
739 | pos->barrier_name); | ||
709 | barrier = GNUNET_new (struct GNUNET_TESTING_Barrier); | 740 | barrier = GNUNET_new (struct GNUNET_TESTING_Barrier); |
710 | barrier->name = pos->barrier_name; | 741 | barrier->name = pos->barrier_name; |
742 | barrier->shadow = GNUNET_YES; | ||
711 | TST_interpreter_add_barrier (ns->is, barrier); | 743 | TST_interpreter_add_barrier (ns->is, barrier); |
712 | 744 | ||
745 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
746 | "%u %p\n", | ||
747 | barrier->reached, | ||
748 | barrier); | ||
749 | |||
713 | barrier->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO); | 750 | barrier->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO); |
714 | } | 751 | } |
715 | GNUNET_assert (NULL != node); | 752 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
753 | "barrier %p %s node %u added \n", | ||
754 | barrier, | ||
755 | pos->barrier_name, | ||
756 | node->node_number); | ||
716 | barrier_node = GNUNET_new (struct GNUNET_TESTING_NetjailNode); | 757 | barrier_node = GNUNET_new (struct GNUNET_TESTING_NetjailNode); |
717 | barrier_node->node_number = node->node_number; | 758 | barrier_node->node_number = node->node_number; |
718 | barrier_node->expected_reaches = pos->expected_reaches; | 759 | barrier_node->expected_reaches = pos->expected_reaches; |
719 | barrier->expected_reaches = barrier->expected_reaches | 760 | barrier->expected_reaches = barrier->expected_reaches |
720 | + pos->expected_reaches; | 761 | + pos->expected_reaches; |
762 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
763 | "number_to_be_reached %u\n", | ||
764 | barrier->number_to_be_reached); | ||
765 | if (GNUNET_YES == barrier->shadow) | ||
766 | barrier->number_to_be_reached++; | ||
767 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
768 | "number_to_be_reached %u\n", | ||
769 | barrier->number_to_be_reached); | ||
721 | GNUNET_CRYPTO_hash (&(node->node_number), sizeof(node->node_number), &hc); | 770 | GNUNET_CRYPTO_hash (&(node->node_number), sizeof(node->node_number), &hc); |
722 | memcpy (&key, &hc, sizeof (key)); | 771 | memcpy (&key, &hc, sizeof (key)); |
723 | GNUNET_CONTAINER_multishortmap_put (barrier->nodes, | 772 | GNUNET_CONTAINER_multishortmap_put (barrier->nodes, |
724 | &key, | 773 | &key, |
725 | node, | 774 | barrier_node, |
726 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 775 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
727 | } | 776 | } |
728 | // FIXME Free barriers?? | 777 | |
729 | tbc->plugin = plugin; | 778 | tbc->plugin = plugin; |
730 | 779 | ||
731 | msg = create_helper_init_msg_ (plugin_name); | 780 | msg = create_helper_init_msg_ (plugin_name); |
@@ -743,8 +792,20 @@ start_helper (struct NetJailState *ns, | |||
743 | "Send handle is NULL!\n"); | 792 | "Send handle is NULL!\n"); |
744 | GNUNET_TESTING_interpreter_fail (ns->is); | 793 | GNUNET_TESTING_interpreter_fail (ns->is); |
745 | } | 794 | } |
795 | GNUNET_free (pos); | ||
796 | GNUNET_free (binary_path); | ||
746 | GNUNET_free (hkey); | 797 | GNUNET_free (hkey); |
747 | GNUNET_free (msg); | 798 | GNUNET_free (msg); |
799 | GNUNET_free (m_char); | ||
800 | GNUNET_free (n_char); | ||
801 | GNUNET_free (local_m_char); | ||
802 | GNUNET_free (global_n_char); | ||
803 | GNUNET_free (known_char); | ||
804 | GNUNET_free (node_id); | ||
805 | GNUNET_free (read_file); | ||
806 | GNUNET_free (data_dir); | ||
807 | GNUNET_free (script_name); | ||
808 | GNUNET_free (barriers); | ||
748 | } | 809 | } |
749 | 810 | ||
750 | 811 | ||
@@ -783,6 +844,9 @@ netjail_exec_run (void *cls, | |||
783 | ns->is = is; | 844 | ns->is = is; |
784 | for (int i = 1; i <= ns->known; i++) | 845 | for (int i = 1; i <= ns->known; i++) |
785 | { | 846 | { |
847 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
848 | "i %u\n", | ||
849 | i); | ||
786 | start_helper (ns, | 850 | start_helper (ns, |
787 | i, | 851 | i, |
788 | 0); | 852 | 0); |
@@ -792,6 +856,10 @@ netjail_exec_run (void *cls, | |||
792 | { | 856 | { |
793 | for (int j = 1; j <= ns->local_m; j++) | 857 | for (int j = 1; j <= ns->local_m; j++) |
794 | { | 858 | { |
859 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
860 | "i %u j %u\n", | ||
861 | i, | ||
862 | j); | ||
795 | start_helper (ns, | 863 | start_helper (ns, |
796 | j, | 864 | j, |
797 | i); | 865 | i); |
@@ -818,7 +886,7 @@ netjail_exec_run (void *cls, | |||
818 | * @return command. | 886 | * @return command. |
819 | */ | 887 | */ |
820 | struct GNUNET_TESTING_Command | 888 | struct GNUNET_TESTING_Command |
821 | GNUNET_TESTING_cmd_netjail_start_testing_system ( | 889 | GNUNET_TESTING_cmd_netjail_start_cmds_helper ( |
822 | const char *label, | 890 | const char *label, |
823 | struct GNUNET_TESTING_NetjailTopology *topology, | 891 | struct GNUNET_TESTING_NetjailTopology *topology, |
824 | unsigned int *read_file, | 892 | unsigned int *read_file, |
diff --git a/src/testing/testing_api_cmd_netjail_stop.c b/src/testing/testing_api_cmd_netjail_stop.c index c13d177fb..cc05617f7 100644 --- a/src/testing/testing_api_cmd_netjail_stop.c +++ b/src/testing/testing_api_cmd_netjail_stop.c | |||
@@ -178,6 +178,8 @@ netjail_stop_run (void *cls, | |||
178 | &child_completed_callback, | 178 | &child_completed_callback, |
179 | ns); | 179 | ns); |
180 | GNUNET_break (NULL != ns->cwh); | 180 | GNUNET_break (NULL != ns->cwh); |
181 | GNUNET_free (read_file); | ||
182 | GNUNET_free (pid); | ||
181 | } | 183 | } |
182 | 184 | ||
183 | 185 | ||
diff --git a/src/testing/testing_api_cmd_netjail_stop_testsystem.c b/src/testing/testing_api_cmd_netjail_stop_cmds_helper.c index 8f63216ef..c6bb0ab52 100644 --- a/src/testing/testing_api_cmd_netjail_stop_testsystem.c +++ b/src/testing/testing_api_cmd_netjail_stop_cmds_helper.c | |||
@@ -123,6 +123,7 @@ stop_testing_system_run (void *cls, | |||
123 | GNUNET_YES); | 123 | GNUNET_YES); |
124 | } | 124 | } |
125 | } | 125 | } |
126 | GNUNET_free (helper); | ||
126 | } | 127 | } |
127 | 128 | ||
128 | 129 | ||
@@ -135,7 +136,7 @@ stop_testing_system_run (void *cls, | |||
135 | * @return command. | 136 | * @return command. |
136 | */ | 137 | */ |
137 | struct GNUNET_TESTING_Command | 138 | struct GNUNET_TESTING_Command |
138 | GNUNET_TESTING_cmd_stop_testing_system ( | 139 | GNUNET_TESTING_cmd_stop_cmds_helper ( |
139 | const char *label, | 140 | const char *label, |
140 | const char *helper_start_label, | 141 | const char *helper_start_label, |
141 | struct GNUNET_TESTING_NetjailTopology *topology) | 142 | struct GNUNET_TESTING_NetjailTopology *topology) |
diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c index 7d76979dc..5385a53d7 100644 --- a/src/testing/testing_api_loop.c +++ b/src/testing/testing_api_loop.c | |||
@@ -41,11 +41,6 @@ | |||
41 | struct GNUNET_TESTING_Interpreter | 41 | struct GNUNET_TESTING_Interpreter |
42 | { | 42 | { |
43 | /** | 43 | /** |
44 | * Send handle for sending messages to netjail nodes. | ||
45 | */ | ||
46 | struct GNUNET_HELPER_SendHandle *sh; | ||
47 | |||
48 | /** | ||
49 | * Array with handles of helper processes for communication with netjails. | 44 | * Array with handles of helper processes for communication with netjails. |
50 | */ | 45 | */ |
51 | const struct GNUNET_HELPER_Handle **helper; | 46 | const struct GNUNET_HELPER_Handle **helper; |
@@ -291,6 +286,7 @@ finish_test (void *cls) | |||
291 | GNUNET_free (is->commands); | 286 | GNUNET_free (is->commands); |
292 | is->rc (is->rc_cls, | 287 | is->rc (is->rc_cls, |
293 | is->result); | 288 | is->result); |
289 | GNUNET_free (is->helper); | ||
294 | GNUNET_free (is); | 290 | GNUNET_free (is); |
295 | } | 291 | } |
296 | 292 | ||
@@ -618,11 +614,7 @@ loop_run (void *cls) | |||
618 | static void | 614 | static void |
619 | clear_msg (void *cls, int result) | 615 | clear_msg (void *cls, int result) |
620 | { | 616 | { |
621 | struct GNUNET_TESTING_Interpreter *is = cls; | 617 | GNUNET_assert (GNUNET_YES == result); |
622 | |||
623 | GNUNET_assert (NULL != is->sh); | ||
624 | GNUNET_free (is->sh); | ||
625 | is->sh = NULL; | ||
626 | } | 618 | } |
627 | 619 | ||
628 | /** | 620 | /** |
@@ -640,14 +632,14 @@ GNUNET_TESTING_add_netjail_helper (struct GNUNET_TESTING_Interpreter *is, | |||
640 | 632 | ||
641 | 633 | ||
642 | /** | 634 | /** |
643 | * Send Message to netjail nodes that a barrier can be advanced. | 635 | * Send Message to netjail nodes. |
644 | * | 636 | * |
645 | * @param is The interpreter. | 637 | * @param is The interpreter. |
646 | * @param global_node_number The node to inform. | 638 | * @param global_node_number The netjail node to inform. |
647 | * @param header The message to send. | 639 | * @param header The message to send. |
648 | */ | 640 | */ |
649 | void | 641 | void |
650 | GNUNET_TESTING_send_message_to_netjail (struct GNUNET_TESTING_Interpreter *is, | 642 | send_message_to_netjail (struct GNUNET_TESTING_Interpreter *is, |
651 | unsigned int global_node_number, | 643 | unsigned int global_node_number, |
652 | struct GNUNET_MessageHeader *header) | 644 | struct GNUNET_MessageHeader *header) |
653 | { | 645 | { |
@@ -655,31 +647,36 @@ GNUNET_TESTING_send_message_to_netjail (struct GNUNET_TESTING_Interpreter *is, | |||
655 | 647 | ||
656 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 648 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
657 | "send message of type %u to locals\n", | 649 | "send message of type %u to locals\n", |
658 | header->type); | 650 | ntohs (header->type)); |
659 | helper = is->helper[global_node_number - 1]; | 651 | helper = is->helper[global_node_number - 1]; |
660 | struct GNUNET_HELPER_SendHandle *sh = GNUNET_HELPER_send ( | 652 | struct GNUNET_HELPER_SendHandle *sh = GNUNET_HELPER_send ( |
661 | (struct GNUNET_HELPER_Handle *) helper, | 653 | (struct GNUNET_HELPER_Handle *) helper, |
662 | header, | 654 | header, |
663 | GNUNET_NO, | 655 | GNUNET_NO, |
664 | &clear_msg, | 656 | &clear_msg, |
665 | is); | 657 | NULL); |
666 | } | 658 | } |
667 | 659 | ||
668 | void | 660 | void |
669 | TST_interpreter_send_barrier_advance (struct GNUNET_TESTING_Interpreter *is, | 661 | TST_interpreter_send_barrier_crossable (struct GNUNET_TESTING_Interpreter *is, |
670 | const char *barrier_name, | 662 | const char *barrier_name, |
671 | unsigned int global_node_number) | 663 | unsigned int global_node_number) |
672 | { | 664 | { |
673 | struct CommandBarrierAdvanced *adm = GNUNET_new (struct | 665 | struct CommandBarrierCrossable *adm; |
674 | CommandBarrierAdvanced); | 666 | size_t msg_length; |
675 | size_t msg_length = sizeof(struct CommandBarrierAdvanced); | ||
676 | size_t name_len; | 667 | size_t name_len; |
668 | char *terminator = "\0"; | ||
677 | 669 | ||
678 | name_len = strlen (barrier_name) + 1; | 670 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
679 | adm->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED); | 671 | "send barrier name %s barrier_name\n", |
672 | barrier_name); | ||
673 | name_len = strlen (barrier_name); | ||
674 | msg_length = sizeof(struct CommandBarrierCrossable) + name_len + 1; | ||
675 | adm = GNUNET_malloc (msg_length); | ||
676 | adm->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE); | ||
680 | adm->header.size = htons ((uint16_t) msg_length); | 677 | adm->header.size = htons ((uint16_t) msg_length); |
681 | memcpy (&adm[1], barrier_name, name_len); | 678 | memcpy (&adm[1], barrier_name, name_len); |
682 | GNUNET_TESTING_send_message_to_netjail (is, | 679 | send_message_to_netjail (is, |
683 | global_node_number, | 680 | global_node_number, |
684 | &adm->header); | 681 | &adm->header); |
685 | GNUNET_free (adm); | 682 | GNUNET_free (adm); |
@@ -697,13 +694,17 @@ free_barrier_node_cb (void *cls, | |||
697 | struct GNUNET_TESTING_Barrier *barrier = free_barrier_node_cb_cls->barrier; | 694 | struct GNUNET_TESTING_Barrier *barrier = free_barrier_node_cb_cls->barrier; |
698 | struct GNUNET_TESTING_Interpreter *is = free_barrier_node_cb_cls->is; | 695 | struct GNUNET_TESTING_Interpreter *is = free_barrier_node_cb_cls->is; |
699 | 696 | ||
697 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
698 | "free_barrier_node_cb\n"); | ||
700 | if (GNUNET_NO == is->finishing) | 699 | if (GNUNET_NO == is->finishing) |
701 | { | 700 | { |
702 | TST_interpreter_send_barrier_advance (is, | 701 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
702 | "TST_interpreter_send_barrier_crossable\n"); | ||
703 | TST_interpreter_send_barrier_crossable (is, | ||
703 | barrier->name, | 704 | barrier->name, |
704 | node->node_number); | 705 | node->node_number); |
705 | } | 706 | } |
706 | GNUNET_CONTAINER_multishortmap_remove (barrier->nodes, key, node); | 707 | GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multishortmap_remove (barrier->nodes, key, node)); |
707 | return GNUNET_YES; | 708 | return GNUNET_YES; |
708 | } | 709 | } |
709 | 710 | ||
@@ -728,7 +729,6 @@ TST_interpreter_get_barrier (struct GNUNET_TESTING_Interpreter *is, | |||
728 | &hc, | 729 | &hc, |
729 | sizeof (create_key)); | 730 | sizeof (create_key)); |
730 | barrier = GNUNET_CONTAINER_multishortmap_get (is->barriers, &create_key); | 731 | barrier = GNUNET_CONTAINER_multishortmap_get (is->barriers, &create_key); |
731 | // GNUNET_free (create_key); | ||
732 | return barrier; | 732 | return barrier; |
733 | } | 733 | } |
734 | 734 | ||
@@ -747,11 +747,17 @@ TST_interpreter_finish_attached_cmds (struct GNUNET_TESTING_Interpreter *is, | |||
747 | struct GNUNET_TESTING_Barrier *barrier = TST_interpreter_get_barrier (is, | 747 | struct GNUNET_TESTING_Barrier *barrier = TST_interpreter_get_barrier (is, |
748 | barrier_name); | 748 | barrier_name); |
749 | 749 | ||
750 | while (NULL != (pos = barrier->cmds_head)) | 750 | while (NULL != barrier && NULL != (pos = barrier->cmds_head)) |
751 | { | 751 | { |
752 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
753 | "command label %s\n", | ||
754 | pos->command->label); | ||
752 | if (GNUNET_NO == pos->command->ac->finished && | 755 | if (GNUNET_NO == pos->command->ac->finished && |
753 | GNUNET_NO == pos->command->asynchronous_finish) | 756 | GNUNET_NO == pos->command->asynchronous_finish) |
754 | { | 757 | { |
758 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
759 | "command label %s finish\n", | ||
760 | pos->command->label); | ||
755 | GNUNET_TESTING_async_finish (pos->command->ac); | 761 | GNUNET_TESTING_async_finish (pos->command->ac); |
756 | } | 762 | } |
757 | else if (GNUNET_NO == pos->command->ac->finished) | 763 | else if (GNUNET_NO == pos->command->ac->finished) |
@@ -761,18 +767,28 @@ TST_interpreter_finish_attached_cmds (struct GNUNET_TESTING_Interpreter *is, | |||
761 | GNUNET_CONTAINER_DLL_remove (barrier->cmds_head, | 767 | GNUNET_CONTAINER_DLL_remove (barrier->cmds_head, |
762 | barrier->cmds_tail, | 768 | barrier->cmds_tail, |
763 | pos); | 769 | pos); |
764 | // FIXME: DANGER DANGER! "pos" is a pointer to the array(!) element in an | 770 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
765 | // IS. This WILL crash and burn | 771 | "command entry label %s removed\n", |
766 | GNUNET_break (0); | 772 | pos->command->label); |
767 | GNUNET_free (pos); | 773 | GNUNET_free (pos); |
774 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
775 | "command entry freed\n"); | ||
776 | } | ||
777 | if (NULL != barrier->nodes) | ||
778 | { | ||
779 | free_barrier_node_cb_cls = GNUNET_new (struct FreeBarrierNodeCbCls); | ||
780 | free_barrier_node_cb_cls->barrier = barrier; | ||
781 | free_barrier_node_cb_cls->is = is; | ||
782 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
783 | "freeing nodes\n"); | ||
784 | GNUNET_CONTAINER_multishortmap_iterate (barrier->nodes, free_barrier_node_cb, | ||
785 | free_barrier_node_cb_cls); | ||
786 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
787 | "nodes freed\n"); | ||
788 | GNUNET_free (free_barrier_node_cb_cls); | ||
789 | GNUNET_CONTAINER_multishortmap_destroy (barrier->nodes); | ||
790 | barrier->nodes = NULL; | ||
768 | } | 791 | } |
769 | free_barrier_node_cb_cls = GNUNET_new (struct FreeBarrierNodeCbCls); | ||
770 | free_barrier_node_cb_cls->barrier = barrier; | ||
771 | free_barrier_node_cb_cls->is = is; | ||
772 | GNUNET_CONTAINER_multishortmap_iterate (barrier->nodes, free_barrier_node_cb, | ||
773 | free_barrier_node_cb_cls); | ||
774 | GNUNET_CONTAINER_multishortmap_destroy (barrier->nodes); | ||
775 | GNUNET_free (free_barrier_node_cb_cls); | ||
776 | } | 792 | } |
777 | 793 | ||
778 | 794 | ||
@@ -786,12 +802,16 @@ free_barriers_cb (void *cls, | |||
786 | struct CommandListEntry *pos; | 802 | struct CommandListEntry *pos; |
787 | struct FreeBarrierNodeCbCls *free_barrier_node_cb_cls; | 803 | struct FreeBarrierNodeCbCls *free_barrier_node_cb_cls; |
788 | 804 | ||
789 | free_barrier_node_cb_cls = GNUNET_new (struct FreeBarrierNodeCbCls); | 805 | if (NULL != barrier->nodes) |
790 | free_barrier_node_cb_cls->barrier = barrier; | 806 | { |
791 | free_barrier_node_cb_cls->is = is; | 807 | free_barrier_node_cb_cls = GNUNET_new (struct FreeBarrierNodeCbCls); |
792 | GNUNET_CONTAINER_multishortmap_iterate (barrier->nodes, free_barrier_node_cb, | 808 | free_barrier_node_cb_cls->barrier = barrier; |
793 | free_barrier_node_cb_cls); | 809 | free_barrier_node_cb_cls->is = is; |
794 | GNUNET_CONTAINER_multishortmap_destroy (barrier->nodes); | 810 | GNUNET_CONTAINER_multishortmap_iterate (barrier->nodes, free_barrier_node_cb, |
811 | free_barrier_node_cb_cls); | ||
812 | GNUNET_CONTAINER_multishortmap_destroy (barrier->nodes); | ||
813 | barrier->nodes = NULL; | ||
814 | } | ||
795 | 815 | ||
796 | while (NULL != (pos = barrier->cmds_head)) | 816 | while (NULL != (pos = barrier->cmds_head)) |
797 | { | 817 | { |
diff --git a/src/testing/testing_cmds.h b/src/testing/testing_cmds.h index a5ea59a3a..9c261aab5 100644 --- a/src/testing/testing_cmds.h +++ b/src/testing/testing_cmds.h | |||
@@ -78,12 +78,17 @@ struct GNUNET_TESTING_CommandAllPeersStarted | |||
78 | struct GNUNET_MessageHeader header; | 78 | struct GNUNET_MessageHeader header; |
79 | }; | 79 | }; |
80 | 80 | ||
81 | struct GNUNET_CMDS_LOCAL_FINISHED | 81 | struct GNUNET_TESTING_CommandLocalFinished |
82 | { | 82 | { |
83 | /** | 83 | /** |
84 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED | 84 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED |
85 | */ | 85 | */ |
86 | struct GNUNET_MessageHeader header; | 86 | struct GNUNET_MessageHeader header; |
87 | |||
88 | /** | ||
89 | * The exit status local test return with. | ||
90 | */ | ||
91 | enum GNUNET_GenericReturnValue rv; | ||
87 | }; | 92 | }; |
88 | 93 | ||
89 | 94 | ||
@@ -105,5 +110,34 @@ struct GNUNET_TESTING_CommandAllLocalTestsPrepared | |||
105 | 110 | ||
106 | GNUNET_NETWORK_STRUCT_END | 111 | GNUNET_NETWORK_STRUCT_END |
107 | 112 | ||
113 | /** | ||
114 | * Global state of the interpreter, used by a command | ||
115 | * to access information about other commands. | ||
116 | */ | ||
117 | struct GNUNET_TESTING_Interpreter; | ||
118 | |||
119 | |||
120 | /** | ||
121 | * Returns the actual running command. | ||
122 | * | ||
123 | * @param is Global state of the interpreter, used by a command | ||
124 | * to access information about other commands. | ||
125 | * @return The actual running command. | ||
126 | */ | ||
127 | struct GNUNET_TESTING_Command * | ||
128 | GNUNET_TESTING_interpreter_get_current_command ( | ||
129 | struct GNUNET_TESTING_Interpreter *is); | ||
130 | |||
131 | |||
132 | /** | ||
133 | * Adding a helper handle to the interpreter. | ||
134 | * | ||
135 | * @param is The interpreter. | ||
136 | * @param helper The helper handle. | ||
137 | */ | ||
138 | void | ||
139 | GNUNET_TESTING_add_netjail_helper (struct GNUNET_TESTING_Interpreter *is, | ||
140 | const struct GNUNET_HELPER_Handle *helper); | ||
141 | |||
108 | #endif | 142 | #endif |
109 | /* end of testing_cmds.h */ | 143 | /* end of testing_cmds.h */ |
diff --git a/src/transport/test_transport_api2_tcp_node1.conf b/src/transport/test_transport_api2_tcp_node1.conf index d396f43d7..37b6f08d1 100644 --- a/src/transport/test_transport_api2_tcp_node1.conf +++ b/src/transport/test_transport_api2_tcp_node1.conf | |||
@@ -8,6 +8,9 @@ PLUGINS = tcp | |||
8 | #PREFIX = valgrind --leak-check=full --track-origins=yes --trace-children=yes --log-file=$GNUNET_TEST_HOME/vg_peer1-%p | 8 | #PREFIX = valgrind --leak-check=full --track-origins=yes --trace-children=yes --log-file=$GNUNET_TEST_HOME/vg_peer1-%p |
9 | UNIXPATH = $GNUNET_RUNTIME_DIR/tng-p1.sock | 9 | UNIXPATH = $GNUNET_RUNTIME_DIR/tng-p1.sock |
10 | 10 | ||
11 | [PEER] | ||
12 | PRIVATE_KEY = $GNUNET_RUNTIME_DIR/private.key | ||
13 | |||
11 | [communicator-tcp] | 14 | [communicator-tcp] |
12 | BINARY = gnunet-communicator-tcp | 15 | BINARY = gnunet-communicator-tcp |
13 | BINDTO = 192.168.15.1:60002 | 16 | BINDTO = 192.168.15.1:60002 |
diff --git a/src/transport/test_transport_nat_upnp.sh b/src/transport/test_transport_nat_upnp.sh index f9dfca71f..df43ef320 100755 --- a/src/transport/test_transport_nat_upnp.sh +++ b/src/transport/test_transport_nat_upnp.sh | |||
@@ -9,3 +9,4 @@ if [ -f /proc/sys/kernel/unprivileged_userns_clone ]; then | |||
9 | fi | 9 | fi |
10 | fi | 10 | fi |
11 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_nat_upnp_topo.conf" | 11 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_nat_upnp_topo.conf" |
12 | #sudo valgrind --vgdb=yes --leak-check=full --track-origins=yes --trace-children=yes --trace-children-skip=/usr/bin/awk,/usr/bin/cut,/usr/bin/seq,/sbin/ip/sed/bash ./test_transport_start_with_config test_transport_nat_upnp_topo.conf | ||
diff --git a/src/transport/test_transport_plugin_cmd_nat_upnp.c b/src/transport/test_transport_plugin_cmd_nat_upnp.c index 91255a9fe..1b02fbfc2 100644 --- a/src/transport/test_transport_plugin_cmd_nat_upnp.c +++ b/src/transport/test_transport_plugin_cmd_nat_upnp.c | |||
@@ -146,7 +146,7 @@ handle_result (void *cls, | |||
146 | "Local test exits with status %d\n", | 146 | "Local test exits with status %d\n", |
147 | rv); | 147 | rv); |
148 | 148 | ||
149 | ts->finished_cb (); | 149 | ts->finished_cb (rv); |
150 | GNUNET_free (ts->testdir); | 150 | GNUNET_free (ts->testdir); |
151 | GNUNET_free (ts->cfgname); | 151 | GNUNET_free (ts->cfgname); |
152 | GNUNET_TESTING_free_topology (ts->topology); | 152 | GNUNET_TESTING_free_topology (ts->topology); |
@@ -201,10 +201,17 @@ all_local_tests_prepared () | |||
201 | * | 201 | * |
202 | * @param write_message Callback to send a message to the master loop. | 202 | * @param write_message Callback to send a message to the master loop. |
203 | * @param router_ip Global address of the network namespace. | 203 | * @param router_ip Global address of the network namespace. |
204 | * @param node_ip Local address of a node i a network namespace. | 204 | * @param node_ip The IP address of the node. |
205 | * @param m The number of the node in a network namespace. | 205 | * @param m The number of the node in a network namespace. |
206 | * @param n The number of the network namespace. | 206 | * @param n The number of the network namespace. |
207 | * @param local_m The number of nodes in a network namespace. | 207 | * @param local_m The number of nodes in a network namespace. |
208 | * @param topology_data A file name for the file containing the topology configuration, or a string containing | ||
209 | * the topology configuration. | ||
210 | * @param read_file If read_file is GNUNET_YES this string is the filename for the topology configuration, | ||
211 | * if read_file is GNUNET_NO the string contains the topology configuration. | ||
212 | * @param finish_cb Callback function which writes a message from the helper process running on a netjail | ||
213 | * node to the master process * signaling that the test case running on the netjail node finished. | ||
214 | * @return Returns the struct GNUNET_TESTING_Interpreter of the command loop running on this netjail node. | ||
208 | */ | 215 | */ |
209 | static struct GNUNET_TESTING_Interpreter * | 216 | static struct GNUNET_TESTING_Interpreter * |
210 | start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message, | 217 | start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message, |
@@ -321,9 +328,12 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message, | |||
321 | ts->cfgname, | 328 | ts->cfgname, |
322 | notify_connect, | 329 | notify_connect, |
323 | GNUNET_NO), | 330 | GNUNET_NO), |
324 | GNUNET_TESTING_cmd_barrier_create ("ready-to-connect", | 331 | GNUNET_TESTING_cmd_barrier_reached ("ready-to-connect-reached", |
325 | 0.0, | 332 | "ready-to-connect", |
326 | 2), | 333 | GNUNET_NO, |
334 | num, | ||
335 | GNUNET_NO, | ||
336 | write_message), | ||
327 | connect_peers, | 337 | connect_peers, |
328 | GNUNET_TRANSPORT_cmd_send_simple ("send-simple", | 338 | GNUNET_TRANSPORT_cmd_send_simple ("send-simple", |
329 | "start-peer", | 339 | "start-peer", |
@@ -331,9 +341,12 @@ start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message, | |||
331 | num, | 341 | num, |
332 | topology), | 342 | topology), |
333 | block_receive, | 343 | block_receive, |
334 | GNUNET_TESTING_cmd_barrier_create ("test-case-finished", | 344 | GNUNET_TESTING_cmd_barrier_reached ("test-case-finished-reached", |
335 | 0.0, | 345 | "test-case-finished", |
336 | 2), | 346 | GNUNET_NO, |
347 | num, | ||
348 | GNUNET_NO, | ||
349 | write_message), | ||
337 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", | 350 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", |
338 | "start-peer"), | 351 | "start-peer"), |
339 | GNUNET_TESTING_cmd_system_destroy ("system-destroy", | 352 | GNUNET_TESTING_cmd_system_destroy ("system-destroy", |
@@ -368,8 +381,6 @@ libgnunet_test_transport_plugin_cmd_nat_upnp_init (void *cls) | |||
368 | 381 | ||
369 | api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions); | 382 | api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions); |
370 | api->start_testcase = &start_testcase; | 383 | api->start_testcase = &start_testcase; |
371 | api->all_peers_started = &all_peers_started; | ||
372 | api->all_local_tests_prepared = all_local_tests_prepared; | ||
373 | api->get_waiting_for_barriers = get_waiting_for_barriers; | 384 | api->get_waiting_for_barriers = get_waiting_for_barriers; |
374 | return api; | 385 | return api; |
375 | } | 386 | } |
@@ -378,11 +389,11 @@ libgnunet_test_transport_plugin_cmd_nat_upnp_init (void *cls) | |||
378 | /** | 389 | /** |
379 | * Exit point from the plugin. | 390 | * Exit point from the plugin. |
380 | * | 391 | * |
381 | * @param cls the return value from #libgnunet_test_transport_plugin_block_test_init | 392 | * @param cls the return value from #libgnunet_test_transport_plugin_nat_upnp_init |
382 | * @return NULL | 393 | * @return NULL |
383 | */ | 394 | */ |
384 | void * | 395 | void * |
385 | libgnunet_test_transport_plugin_cmd_simple_send_done (void *cls) | 396 | libgnunet_test_transport_plugin_cmd_nat_upnp_done (void *cls) |
386 | { | 397 | { |
387 | struct GNUNET_TESTING_PluginFunctions *api = cls; | 398 | struct GNUNET_TESTING_PluginFunctions *api = cls; |
388 | 399 | ||
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c index 632c522c9..375796dff 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send.c +++ b/src/transport/test_transport_plugin_cmd_simple_send.c | |||
@@ -130,7 +130,7 @@ handle_result (void *cls, | |||
130 | "Local test exits with status %d\n", | 130 | "Local test exits with status %d\n", |
131 | rv); | 131 | rv); |
132 | 132 | ||
133 | ts->finished_cb (); | 133 | ts->finished_cb (rv); |
134 | GNUNET_free (ts->testdir); | 134 | GNUNET_free (ts->testdir); |
135 | GNUNET_free (ts->cfgname); | 135 | GNUNET_free (ts->cfgname); |
136 | GNUNET_TESTING_free_topology (ts->topology); | 136 | GNUNET_TESTING_free_topology (ts->topology); |
@@ -185,7 +185,7 @@ all_local_tests_prepared () | |||
185 | * | 185 | * |
186 | * @param write_message Callback to send a message to the master loop. | 186 | * @param write_message Callback to send a message to the master loop. |
187 | * @param router_ip Global address of the network namespace. | 187 | * @param router_ip Global address of the network namespace. |
188 | * @param node_ip Local address of a node i a network namespace. | 188 | * @param node_ip The IP address of the node. |
189 | * @param m The number of the node in a network namespace. | 189 | * @param m The number of the node in a network namespace. |
190 | * @param n The number of the network namespace. | 190 | * @param n The number of the network namespace. |
191 | * @param local_m The number of nodes in a network namespace. | 191 | * @param local_m The number of nodes in a network namespace. |
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c index 2f84b8213..7381b1d7e 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c +++ b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c | |||
@@ -131,7 +131,7 @@ handle_result (void *cls, | |||
131 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 131 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
132 | "Local test exits with status %d\n", | 132 | "Local test exits with status %d\n", |
133 | rv); | 133 | rv); |
134 | ts->finished_cb (); | 134 | ts->finished_cb (rv); |
135 | GNUNET_free (ts->testdir); | 135 | GNUNET_free (ts->testdir); |
136 | GNUNET_free (ts->cfgname); | 136 | GNUNET_free (ts->cfgname); |
137 | GNUNET_TESTING_free_topology (ts->topology); | 137 | GNUNET_TESTING_free_topology (ts->topology); |
@@ -218,7 +218,7 @@ all_local_tests_prepared () | |||
218 | * | 218 | * |
219 | * @param write_message Callback to send a message to the master loop. | 219 | * @param write_message Callback to send a message to the master loop. |
220 | * @param router_ip Global address of the network namespace. | 220 | * @param router_ip Global address of the network namespace. |
221 | * @param node_ip Local address of a node i a network namespace. | 221 | * @param node_ip The IP address of the node. |
222 | * @param m The number of the node in a network namespace. | 222 | * @param m The number of the node in a network namespace. |
223 | * @param n The number of the network namespace. | 223 | * @param n The number of the network namespace. |
224 | * @param local_m The number of nodes in a network namespace. | 224 | * @param local_m The number of nodes in a network namespace. |
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_dv.c b/src/transport/test_transport_plugin_cmd_simple_send_dv.c index 4da03d155..55ab4a48f 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send_dv.c +++ b/src/transport/test_transport_plugin_cmd_simple_send_dv.c | |||
@@ -183,7 +183,7 @@ handle_result (void *cls, | |||
183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
184 | "Local test exits with status %d\n", | 184 | "Local test exits with status %d\n", |
185 | rv); | 185 | rv); |
186 | ts->finished_cb (); | 186 | ts->finished_cb (rv); |
187 | GNUNET_free (ts->testdir); | 187 | GNUNET_free (ts->testdir); |
188 | GNUNET_free (ts->cfgname); | 188 | GNUNET_free (ts->cfgname); |
189 | GNUNET_TESTING_free_topology (ts->topology); | 189 | GNUNET_TESTING_free_topology (ts->topology); |
@@ -241,7 +241,7 @@ all_local_tests_prepared () | |||
241 | * | 241 | * |
242 | * @param write_message Callback to send a message to the master loop. | 242 | * @param write_message Callback to send a message to the master loop. |
243 | * @param router_ip Global address of the network namespace. | 243 | * @param router_ip Global address of the network namespace. |
244 | * @param node_ip Local address of a node i a network namespace. | 244 | * @param node_ip The IP address of the node. |
245 | * @param m The number of the node in a network namespace. | 245 | * @param m The number of the node in a network namespace. |
246 | * @param n The number of the network namespace. | 246 | * @param n The number of the network namespace. |
247 | * @param local_m The number of nodes in a network namespace. | 247 | * @param local_m The number of nodes in a network namespace. |
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c index 7a26a89d8..5e931fbe3 100644 --- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c +++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c | |||
@@ -128,7 +128,7 @@ handle_result (void *cls, | |||
128 | "Local test exits with status %d\n", | 128 | "Local test exits with status %d\n", |
129 | rv); | 129 | rv); |
130 | 130 | ||
131 | ts->finished_cb (); | 131 | ts->finished_cb (rv); |
132 | GNUNET_free (ts->testdir); | 132 | GNUNET_free (ts->testdir); |
133 | GNUNET_free (ts->cfgname); | 133 | GNUNET_free (ts->cfgname); |
134 | GNUNET_TESTING_free_topology (ts->topology); | 134 | GNUNET_TESTING_free_topology (ts->topology); |
@@ -178,7 +178,7 @@ all_local_tests_prepared () | |||
178 | * | 178 | * |
179 | * @param write_message Callback to send a message to the master loop. | 179 | * @param write_message Callback to send a message to the master loop. |
180 | * @param router_ip Global address of the network namespace. | 180 | * @param router_ip Global address of the network namespace. |
181 | * @param node_ip Local address of a node i a network namespace. | 181 | * @param node_ip The IP address of the node. |
182 | * @param m The number of the node in a network namespace. | 182 | * @param m The number of the node in a network namespace. |
183 | * @param n The number of the network namespace. | 183 | * @param n The number of the network namespace. |
184 | * @param local_m The number of nodes in a network namespace. | 184 | * @param local_m The number of nodes in a network namespace. |
diff --git a/src/transport/test_transport_simple_send_dv_circle.sh b/src/transport/test_transport_simple_send_dv_circle.sh index 353d14f65..bd5f00abe 100755 --- a/src/transport/test_transport_simple_send_dv_circle.sh +++ b/src/transport/test_transport_simple_send_dv_circle.sh | |||
@@ -9,4 +9,3 @@ if [ -f /proc/sys/kernel/unprivileged_userns_clone ]; then | |||
9 | fi | 9 | fi |
10 | fi | 10 | fi |
11 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_distance_vector_circle_topo.conf" | 11 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_distance_vector_circle_topo.conf" |
12 | # sudo valgrind --leak-check=full --track-origins=yes --trace-children=yes --trace-children-skip=/usr/bin/awk,/usr/bin/cut,/usr/bin/seq,/sbin/ip/sed/bash ./test_transport_start_with_config test_transport_distance_vector_circle_topo.conf | ||
diff --git a/src/transport/test_transport_start_with_config.c b/src/transport/test_transport_start_with_config.c index 0c3271436..c4b6c55ad 100644 --- a/src/transport/test_transport_start_with_config.c +++ b/src/transport/test_transport_start_with_config.c | |||
@@ -94,12 +94,12 @@ main (int argc, | |||
94 | GNUNET_TESTING_cmd_netjail_start ("netjail-start", | 94 | GNUNET_TESTING_cmd_netjail_start ("netjail-start", |
95 | topology_data_script, | 95 | topology_data_script, |
96 | &read_file), | 96 | &read_file), |
97 | GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed", | 97 | GNUNET_TESTING_cmd_netjail_start_cmds_helper ("netjail-start-testbed", |
98 | topology, | 98 | topology, |
99 | &read_file, | 99 | &read_file, |
100 | topology_data_script, | 100 | topology_data_script, |
101 | TIMEOUT), | 101 | TIMEOUT), |
102 | GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed", | 102 | GNUNET_TESTING_cmd_stop_cmds_helper ("stop-testbed", |
103 | "netjail-start-testbed", | 103 | "netjail-start-testbed", |
104 | topology), | 104 | topology), |
105 | GNUNET_TESTING_cmd_netjail_stop ("netjail-stop", | 105 | GNUNET_TESTING_cmd_netjail_stop ("netjail-stop", |
diff --git a/src/transport/transport-testing-cmds.h b/src/transport/transport-testing-cmds.h index 1088f2e5b..46f6045dc 100644 --- a/src/transport/transport-testing-cmds.h +++ b/src/transport/transport-testing-cmds.h | |||
@@ -116,7 +116,9 @@ struct StartPeerState | |||
116 | */ | 116 | */ |
117 | struct GNUNET_MQ_MessageHandler *handlers; | 117 | struct GNUNET_MQ_MessageHandler *handlers; |
118 | 118 | ||
119 | //FIXME documentation | 119 | /** |
120 | * GNUnet configuration file used to start a peer. | ||
121 | */ | ||
120 | char *cfgname; | 122 | char *cfgname; |
121 | 123 | ||
122 | /** | 124 | /** |
@@ -124,7 +126,9 @@ struct StartPeerState | |||
124 | */ | 126 | */ |
125 | struct GNUNET_CONFIGURATION_Handle *cfg; | 127 | struct GNUNET_CONFIGURATION_Handle *cfg; |
126 | 128 | ||
127 | //FIXME documentation | 129 | /** |
130 | * struct GNUNET_TESTING_Peer returned by GNUNET_TESTING_peer_configure. | ||
131 | */ | ||
128 | struct GNUNET_TESTING_Peer *peer; | 132 | struct GNUNET_TESTING_Peer *peer; |
129 | 133 | ||
130 | /** | 134 | /** |
@@ -167,13 +171,9 @@ struct StartPeerState | |||
167 | */ | 171 | */ |
168 | size_t hello_size; | 172 | size_t hello_size; |
169 | 173 | ||
170 | /** All of the below: FIXME documentation */ | 174 | /** |
171 | char *m; | 175 | * The label of the command which was started by calling GNUNET_TESTING_cmd_system_create. |
172 | 176 | */ | |
173 | char *n; | ||
174 | |||
175 | char *local_m; | ||
176 | |||
177 | char *system_label; | 177 | char *system_label; |
178 | 178 | ||
179 | /** | 179 | /** |
@@ -181,10 +181,20 @@ struct StartPeerState | |||
181 | */ | 181 | */ |
182 | unsigned int no; | 182 | unsigned int no; |
183 | 183 | ||
184 | /** | ||
185 | * A map with struct GNUNET_MQ_Handle values for each peer this peer | ||
186 | * is connected to. | ||
187 | */ | ||
184 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; | 188 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; |
185 | 189 | ||
190 | /** | ||
191 | * Test setup for this peer. | ||
192 | */ | ||
186 | const struct GNUNET_TESTING_System *tl_system; | 193 | const struct GNUNET_TESTING_System *tl_system; |
187 | 194 | ||
195 | /** | ||
196 | * Callback which is called on neighbour connect events. | ||
197 | */ | ||
188 | GNUNET_TRANSPORT_notify_connect_cb notify_connect; | 198 | GNUNET_TRANSPORT_notify_connect_cb notify_connect; |
189 | 199 | ||
190 | /** | 200 | /** |
@@ -227,14 +237,11 @@ struct TestState | |||
227 | 237 | ||
228 | /** | 238 | /** |
229 | * Create command. | 239 | * Create command. |
230 | * FIXME: Parameter list does not match documentation. | ||
231 | * FIXME: m and n parameters need a rename. | ||
232 | * | 240 | * |
233 | * @param label name for command. | 241 | * @param label name for command. |
234 | * @param system_label Label of the cmd to setup a test environment. | 242 | * @param system_label Label of the cmd to setup a test environment. |
235 | * @param m The number of the local node of the actual network namespace. | 243 | * @param no Decimal number representing the last byte of the IP address of this peer. |
236 | * @param n The number of the actual namespace. | 244 | * @param node_ip The IP address of this node. |
237 | * @param local_m Number of local nodes in each namespace. | ||
238 | * @param handlers Handler for messages received by this peer. | 245 | * @param handlers Handler for messages received by this peer. |
239 | * @param cfgname Configuration file name for this peer. | 246 | * @param cfgname Configuration file name for this peer. |
240 | * @param notify_connect Method which will be called, when a peer connects. | 247 | * @param notify_connect Method which will be called, when a peer connects. |
diff --git a/src/transport/transport_api_cmd_backchannel_check.c b/src/transport/transport_api_cmd_backchannel_check.c index 9f62281a4..d672e3ae8 100644 --- a/src/transport/transport_api_cmd_backchannel_check.c +++ b/src/transport/transport_api_cmd_backchannel_check.c | |||
@@ -351,12 +351,12 @@ add_search_string (struct CheckState *cs, const struct | |||
351 | + cs->topology->nodes_x; | 351 | + cs->topology->nodes_x; |
352 | 352 | ||
353 | // num = GNUNET_TESTING_calculate_num (pos_connection, cs->topology); | 353 | // num = GNUNET_TESTING_calculate_num (pos_connection, cs->topology); |
354 | peer = GNUNET_TESTING_get_pub_key (num, cs->tl_system); | 354 | peer = GNUNET_TESTING_get_peer (num, cs->tl_system); |
355 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 355 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
356 | "peer: %s num %u\n", | 356 | "peer: %s num %u\n", |
357 | GNUNET_i2s (peer), | 357 | GNUNET_i2s (peer), |
358 | num); | 358 | num); |
359 | us = GNUNET_TESTING_get_pub_key (cs->num, cs->tl_system); | 359 | us = GNUNET_TESTING_get_peer (cs->num, cs->tl_system); |
360 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 360 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
361 | "us: %s cs->num %d\n", | 361 | "us: %s cs->num %d\n", |
362 | GNUNET_i2s (us), | 362 | GNUNET_i2s (us), |
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c index 528e05b5f..d399e9d0a 100644 --- a/src/transport/transport_api_cmd_connecting_peers.c +++ b/src/transport/transport_api_cmd_connecting_peers.c | |||
@@ -112,7 +112,7 @@ connect_peers_run (void *cls, | |||
112 | GNUNET_asprintf (&addr_and_port, | 112 | GNUNET_asprintf (&addr_and_port, |
113 | "%s:60002", | 113 | "%s:60002", |
114 | addr); | 114 | addr); |
115 | peer = GNUNET_TESTING_get_pub_key (num, tl_system); | 115 | peer = GNUNET_TESTING_get_peer (num, tl_system); |
116 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 116 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
117 | "validating peer number %u with identity %s and address %s %u %s\n", | 117 | "validating peer number %u with identity %s and address %s %u %s\n", |
118 | num, | 118 | num, |
@@ -160,7 +160,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is, | |||
160 | pos_connection = pos_connection->next) | 160 | pos_connection = pos_connection->next) |
161 | { | 161 | { |
162 | num = GNUNET_TESTING_calculate_num (pos_connection, cps->topology); | 162 | num = GNUNET_TESTING_calculate_num (pos_connection, cps->topology); |
163 | peer_connection = GNUNET_TESTING_get_pub_key (num, cps->tl_system); | 163 | peer_connection = GNUNET_TESTING_get_peer (num, cps->tl_system); |
164 | if (0 == GNUNET_memcmp (peer, | 164 | if (0 == GNUNET_memcmp (peer, |
165 | peer_connection)) | 165 | peer_connection)) |
166 | cps->con_num_notified++; | 166 | cps->con_num_notified++; |
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c index 0677b6227..516f8d0aa 100644 --- a/src/transport/transport_api_cmd_start_peer.c +++ b/src/transport/transport_api_cmd_start_peer.c | |||
@@ -64,6 +64,9 @@ hello_iter_cb (void *cb_cls, | |||
64 | memcpy (sps->hello, record->value, sps->hello_size); | 64 | memcpy (sps->hello, record->value, sps->hello_size); |
65 | sps->hello[sps->hello_size - 1] = '\0'; | 65 | sps->hello[sps->hello_size - 1] = '\0'; |
66 | 66 | ||
67 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
68 | "Our hello %s\n", | ||
69 | sps->hello); | ||
67 | GNUNET_PEERSTORE_iterate_cancel (sps->pic); | 70 | GNUNET_PEERSTORE_iterate_cancel (sps->pic); |
68 | sps->pic = NULL; | 71 | sps->pic = NULL; |
69 | GNUNET_TESTING_async_finish (&sps->ac); | 72 | GNUNET_TESTING_async_finish (&sps->ac); |
diff --git a/src/transport/transport_api_cmd_stop_peer.c b/src/transport/transport_api_cmd_stop_peer.c index 1fdd48fa6..a80742b5f 100644 --- a/src/transport/transport_api_cmd_stop_peer.c +++ b/src/transport/transport_api_cmd_stop_peer.c | |||
@@ -72,6 +72,8 @@ stop_peer_run (void *cls, | |||
72 | } | 72 | } |
73 | if (NULL != sps->th) | 73 | if (NULL != sps->th) |
74 | { | 74 | { |
75 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
76 | "Disconnecting from TRANSPORT service\n"); | ||
75 | GNUNET_TRANSPORT_core_disconnect (sps->th); | 77 | GNUNET_TRANSPORT_core_disconnect (sps->th); |
76 | } | 78 | } |
77 | if (NULL != sps->ah) | 79 | if (NULL != sps->ah) |