- adapt first test to mesh test lib
[oweals/gnunet.git] / src / mesh / mesh_test_lib.h
1 /*
2      This file is part of GNUnet.
3      (C) 2012 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      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      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20 /**
21  * @file mesh/mesh_test_lib.h
22  * @author Bartlomiej Polot
23  * @brief library for writing MESH tests
24  */
25 #ifndef MESH_TEST_LIB_H
26 #define MESH_TEST_LIB_H
27
28 #include "gnunet_testbed_service.h"
29 #include "gnunet_mesh_service.h"
30
31 /**
32  * Test context for a MESH Test.
33  */
34 struct GNUNET_MESH_TEST_Context;
35
36
37 /**
38  * Main function of a MESH test.
39  *
40  * @param cls Closure.
41  * @param ctx Argument to give to GNUNET_MESH_TEST_cleanup on test end.
42  * @param num_peers Number of peers that are running.
43  * @param peers Array of peers.
44  * @param meshes Handle to each of the MESHs of the peers.
45  */
46 typedef void (*GNUNET_MESH_TEST_AppMain) (void *cls,
47                                           struct GNUNET_MESH_TEST_Context *ctx,
48                                           unsigned int num_peers,
49                                           struct GNUNET_TESTBED_Peer **peers,
50                                           struct GNUNET_MESH_Handle **meshes);
51
52
53 /**
54  * Run a test using the given name, configuration file and number of
55  * peers.
56  * All mesh callbacks will receive the peer number as the closure.
57  *
58  * @param testname Name of the test (for logging).
59  * @param cfgname Name of the configuration file.
60  * @param num_peers Number of peers to start.
61  * @param tmain Main function to run once the testbed is ready.
62  * @param tmain_cls Closure for 'tmain'.
63  * @param new_tunnel Handler for incoming tunnels.
64  * @param cleaner Cleaner for destroyed incoming tunnels.
65  * @param handlers Message handlers.
66  * @param stypes Application types.
67  */
68 void 
69 GNUNET_MESH_TEST_run (const char *testname,
70                       const char *cfgname,
71                       unsigned int num_peers,
72                       GNUNET_MESH_TEST_AppMain tmain,
73                       void *tmain_cls,
74                       GNUNET_MESH_InboundTunnelNotificationHandler new_tunnel,
75                       GNUNET_MESH_TunnelEndHandler cleaner,
76                       struct GNUNET_MESH_MessageHandler* handlers,
77                       const GNUNET_MESH_ApplicationType* stypes);
78
79
80 /**
81  * Clean up the testbed.
82  *
83  * @param ctx handle for the testbed
84  */
85 void
86 GNUNET_MESH_TEST_cleanup (struct GNUNET_MESH_TEST_Context *ctx);
87
88
89 #endif