paragraph for gnunet devs that don't know how to use the web
[oweals/gnunet.git] / src / cadet / cadet_test_lib.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2012,2017 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 /**
19  * @file cadet/cadet_test_lib.h
20  * @author Bartlomiej Polot
21  * @brief library for writing CADET tests
22  */
23 #ifndef CADET_TEST_LIB_H
24 #define CADET_TEST_LIB_H
25
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #if 0                           /* keep Emacsens' auto-indent happy */
30 }
31 #endif
32 #endif
33
34 #include "gnunet_testbed_service.h"
35 #include "gnunet_cadet_service.h"
36
37 /**
38  * Test context for a CADET Test.
39  */
40 struct GNUNET_CADET_TEST_Context;
41
42
43 /**
44  * Main function of a CADET test.
45  *
46  * @param cls Closure.
47  * @param ctx Argument to give to GNUNET_CADET_TEST_cleanup on test end.
48  * @param num_peers Number of peers that are running.
49  * @param peers Array of peers.
50  * @param cadets Handle to each of the CADETs of the peers.
51  */
52 typedef void (*GNUNET_CADET_TEST_AppMain) (void *cls,
53                                           struct GNUNET_CADET_TEST_Context *ctx,
54                                           unsigned int num_peers,
55                                           struct GNUNET_TESTBED_Peer **peers,
56                                           struct GNUNET_CADET_Handle **cadets);
57
58
59 /**
60  * Run a test using the given name, configuration file and number of peers.
61  * All cadet callbacks will receive the peer number (long) as the closure.
62  *
63  * @param testname Name of the test (for logging).
64  * @param cfgfile Name of the configuration file.
65  * @param num_peers Number of peers to start.
66  * @param tmain Main function to run once the testbed is ready.
67  * @param tmain_cls Closure for @a tmain.
68  * @param connects Handler for incoming channels.
69  * @param window_changes Handler for the window size change notification.
70  * @param disconnects Cleaner for destroyed incoming channels.
71  * @param handlers Message handlers.
72  * @param ports Ports the peers offer, NULL-terminated.
73  */
74 void
75 GNUNET_CADET_TEST_ruN (const char *testname,
76                        const char *cfgfile,
77                        unsigned int num_peers,
78                        GNUNET_CADET_TEST_AppMain tmain,
79                        void *tmain_cls,
80                        GNUNET_CADET_ConnectEventHandler connects,
81                        GNUNET_CADET_WindowSizeEventHandler window_changes,
82                        GNUNET_CADET_DisconnectEventHandler disconnects,
83                        struct GNUNET_MQ_MessageHandler *handlers,
84                        const struct GNUNET_HashCode **ports);
85
86 /**
87  * Clean up the testbed.
88  *
89  * @param ctx handle for the testbed
90  */
91 void
92 GNUNET_CADET_TEST_cleanup (struct GNUNET_CADET_TEST_Context *ctx);
93
94
95 #if 0                           /* keep Emacsens' auto-indent happy */
96 {
97 #endif
98 #ifdef __cplusplus
99 }
100 #endif
101
102
103 /* ifndef CADET_TEST_LIB_H */
104 #endif