aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_testing_ng_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_testing_ng_lib.h')
-rw-r--r--src/include/gnunet_testing_ng_lib.h311
1 files changed, 305 insertions, 6 deletions
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h
index 5c9079fdf..07cdac962 100644
--- a/src/include/gnunet_testing_ng_lib.h
+++ b/src/include/gnunet_testing_ng_lib.h
@@ -31,7 +31,13 @@
31#include "gnunet_util_lib.h" 31#include "gnunet_util_lib.h"
32#include "gnunet_testing_lib.h" 32#include "gnunet_testing_lib.h"
33 33
34 34/**
35 * Stringify operator.
36 *
37 * @param a some expression to stringify. Must NOT be a macro.
38 * @return same expression as a constant string.
39 */
40#define GNUNET_S(a) #a
35 41
36/** 42/**
37 * Maximum length of label in command 43 * Maximum length of label in command
@@ -520,6 +526,20 @@ struct GNUNET_TESTING_Timer
520 unsigned int num_retries; 526 unsigned int num_retries;
521}; 527};
522 528
529/**
530 * Command to execute a script synchronously.
531 *
532 * @param label Label of the command.
533 * @param script The name of the script.
534 * @param script_argv The arguments of the script.
535*/
536const struct GNUNET_TESTING_Command
537GNUNET_TESTING_cmd_exec_bash_script (const char *label,
538 const char *script,
539 char *const script_argv[],
540 int argc,
541 GNUNET_ChildCompletedCallback cb);
542
523 543
524/** 544/**
525 * Retrieve peer identity from the test system with the unique node id. 545 * Retrieve peer identity from the test system with the unique node id.
@@ -530,7 +550,7 @@ struct GNUNET_TESTING_Timer
530 */ 550 */
531struct GNUNET_PeerIdentity * 551struct GNUNET_PeerIdentity *
532GNUNET_TESTING_get_peer (unsigned int num, 552GNUNET_TESTING_get_peer (unsigned int num,
533 const struct GNUNET_TESTING_System *tl_system); 553 const struct GNUNET_TESTING_System *tl_system);
534 554
535 555
536/** 556/**
@@ -546,12 +566,12 @@ GNUNET_TESTING_cmd_stat (struct GNUNET_TESTING_Timer *timers);
546/* *** Generic trait logic for implementing traits ********* */ 566/* *** Generic trait logic for implementing traits ********* */
547 567
548/** 568/**
549 * A struct GNUNET_TESTING_Trait can be used to exchange data between cmds. 569 * A struct GNUNET_TESTING_Trait can be used to exchange data between cmds.
550 * 570 *
551 * Therefor the cmd which like to provide data to other cmds has to implement 571 * Therefor the cmd which like to provide data to other cmds has to implement
552 * the trait function, where an array of traits is defined with the help of the 572 * the trait function, where an array of traits is defined with the help of the
553 * GNUNET_TESTING_make_trait_ macro. The data can be retrieved with the help of the 573 * GNUNET_TESTING_make_trait_ macro. The data can be retrieved with the help of the
554 * GNUNET_TESTING_get_trait_ macro. Traits name and type must be defined to make 574 * GNUNET_TESTING_get_trait_ macro. Traits name and type must be defined to make
555 * use of the macros. 575 * use of the macros.
556 */ 576 */
557struct GNUNET_TESTING_Trait 577struct GNUNET_TESTING_Trait
@@ -604,6 +624,277 @@ GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits,
604/* ****** Specific traits supported by this component ******* */ 624/* ****** Specific traits supported by this component ******* */
605 625
606 626
627typedef void *
628(*GNUNET_TESTING_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is,
629 const struct GNUNET_PeerIdentity *peer);
630
631/**
632 * Struct to store information needed in callbacks.
633 *
634 */
635struct GNUNET_TESTING_ConnectPeersState
636{
637 /**
638 * Receive callback
639 */
640 struct GNUNET_MQ_MessageHandler *handlers;
641
642 /**
643 * A map with struct GNUNET_MQ_Handle values for each peer this peer
644 * is connected to.
645 */
646 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
647
648 /**
649 * Handle for transport.
650 */
651 struct GNUNET_TRANSPORT_ApplicationHandle *ah;
652
653 /**
654 * Core handle.
655 */
656 struct GNUNET_TRANSPORT_CoreHandle *th;
657
658 /**
659 * Context for our asynchronous completion.
660 */
661 struct GNUNET_TESTING_AsyncContext ac;
662
663 /**
664 * The testing system of this node.
665 */
666 const struct GNUNET_TESTING_System *tl_system;
667
668 // Label of the cmd which started the test system.
669 const char *create_label;
670
671 /**
672 * Number globally identifying the node.
673 *
674 */
675 uint32_t num;
676
677 /**
678 * Label of the cmd to start a peer.
679 *
680 */
681 const char *start_peer_label;
682
683 /**
684 * The topology of the test setup.
685 */
686 struct GNUNET_TESTING_NetjailTopology *topology;
687
688 /**
689 * Connections to other peers.
690 */
691 struct GNUNET_TESTING_NodeConnection *node_connections_head;
692
693 struct GNUNET_TESTING_Interpreter *is;
694
695 /**
696 * Number of connections.
697 */
698 unsigned int con_num;
699
700 /**
701 * Number of additional connects this cmd will wait for not triggered by this cmd.
702 */
703 unsigned int additional_connects;
704
705 /**
706 * Number of connections we already have a notification for.
707 */
708 unsigned int con_num_notified;
709
710 /**
711 * Number of additional connects this cmd will wait for not triggered by this cmd we already have a notification for.
712 */
713 unsigned int additional_connects_notified;
714
715 /**
716 * Flag indicating, whether the command is waiting for peers to connect that are configured to connect.
717 */
718 unsigned int wait_for_connect;
719};
720
721/**
722 * Struct to store information needed in callbacks.
723 *
724 */
725struct ConnectPeersState
726{
727 /**
728 * Context for our asynchronous completion.
729 */
730 struct GNUNET_TESTING_AsyncContext ac;
731
732 GNUNET_TESTING_notify_connect_cb notify_connect;
733
734 /**
735 * The testing system of this node.
736 */
737 const struct GNUNET_TESTING_System *tl_system;
738
739 // Label of the cmd which started the test system.
740 const char *create_label;
741
742 /**
743 * Number globally identifying the node.
744 *
745 */
746 uint32_t num;
747
748 /**
749 * Label of the cmd to start a peer.
750 *
751 */
752 const char *start_peer_label;
753
754 /**
755 * The topology of the test setup.
756 */
757 struct GNUNET_TESTING_NetjailTopology *topology;
758
759 /**
760 * Connections to other peers.
761 */
762 struct GNUNET_TESTING_NodeConnection *node_connections_head;
763
764 struct GNUNET_TESTING_Interpreter *is;
765
766 /**
767 * Number of connections.
768 */
769 unsigned int con_num;
770
771 /**
772 * Number of additional connects this cmd will wait for not triggered by this cmd.
773 */
774 unsigned int additional_connects;
775
776 /**
777 * Number of connections we already have a notification for.
778 */
779 unsigned int con_num_notified;
780
781 /**
782 * Number of additional connects this cmd will wait for not triggered by this cmd we already have a notification for.
783 */
784 unsigned int additional_connects_notified;
785
786 /**
787 * Flag indicating, whether the command is waiting for peers to connect that are configured to connect.
788 */
789 unsigned int wait_for_connect;
790};
791
792
793struct GNUNET_TESTING_StartPeerState
794{
795 /**
796 * Context for our asynchronous completion.
797 */
798 struct GNUNET_TESTING_AsyncContext ac;
799
800 /**
801 * The ip of a node.
802 */
803 char *node_ip;
804
805 /**
806 * Receive callback
807 */
808 struct GNUNET_MQ_MessageHandler *handlers;
809
810 /**
811 * GNUnet configuration file used to start a peer.
812 */
813 char *cfgname;
814
815 /**
816 * Peer's configuration
817 */
818 struct GNUNET_CONFIGURATION_Handle *cfg;
819
820 /**
821 * struct GNUNET_TESTING_Peer returned by GNUNET_TESTING_peer_configure.
822 */
823 struct GNUNET_TESTING_Peer *peer;
824
825 /**
826 * Peer identity
827 */
828 struct GNUNET_PeerIdentity id;
829
830 /**
831 * Peer's transport service handle
832 */
833 struct GNUNET_TRANSPORT_CoreHandle *th;
834
835 /**
836 * Application handle
837 */
838 struct GNUNET_TRANSPORT_ApplicationHandle *ah;
839
840 /**
841 * Peer's PEERSTORE Handle
842 */
843 struct GNUNET_PEERSTORE_Handle *ph;
844
845 /**
846 * Hello get task
847 */
848 struct GNUNET_SCHEDULER_Task *rh_task;
849
850 /**
851 * Peer's transport get hello handle to retrieve peer's HELLO message
852 */
853 struct GNUNET_PEERSTORE_IterateContext *pic;
854
855 /**
856 * Hello
857 */
858 char *hello;
859
860 /**
861 * Hello size
862 */
863 size_t hello_size;
864
865 /**
866 * The label of the command which was started by calling GNUNET_TESTING_cmd_system_create.
867 */
868 char *system_label;
869
870 /**
871 * An unique number to identify the peer
872 */
873 unsigned int no;
874
875 /**
876 * A map with struct GNUNET_MQ_Handle values for each peer this peer
877 * is connected to.
878 */
879 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
880
881 /**
882 * Test setup for this peer.
883 */
884 const struct GNUNET_TESTING_System *tl_system;
885
886 /**
887 * Callback which is called on neighbour connect events.
888 */
889 GNUNET_TESTING_notify_connect_cb notify_connect;
890
891 /**
892 * Flag indicating, if udp broadcast should be switched on.
893 */
894 enum GNUNET_GenericReturnValue broadcast;
895};
896
897
607/** 898/**
608 * Create headers for a trait with name @a name for 899 * Create headers for a trait with name @a name for
609 * statically allocated data of type @a type. 900 * statically allocated data of type @a type.
@@ -698,7 +989,15 @@ GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits,
698 */ 989 */
699#define GNUNET_TESTING_SIMPLE_TRAITS(op) \ 990#define GNUNET_TESTING_SIMPLE_TRAITS(op) \
700 op (batch_cmds, struct GNUNET_TESTING_Command *) \ 991 op (batch_cmds, struct GNUNET_TESTING_Command *) \
701 op (process, struct GNUNET_OS_Process *) 992 op (process, struct GNUNET_OS_Process *) \
993 op (peer_id, const struct GNUNET_PeerIdentity) \
994 op (connected_peers_map, const struct GNUNET_CONTAINER_MultiShortmap) \
995 op (hello_size, const size_t) \
996 op (hello, const char) \
997 op (application_handle, const struct GNUNET_TRANSPORT_ApplicationHandle) \
998 op (connect_peer_state, const struct GNUNET_TESTING_ConnectPeersState) \
999 op (state, const struct GNUNET_TESTING_StartPeerState) \
1000 op (broadcast, const enum GNUNET_GenericReturnValue)
702 1001
703 1002
704/** 1003/**