2 This file is part of GNUnet.
3 Copyright (C) 2012,2017 GNUnet e.V.
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.
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.
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/>.
19 * @file cadet/cadet_test_lib.h
20 * @author Bartlomiej Polot
21 * @brief library for writing CADET tests
23 #ifndef CADET_TEST_LIB_H
24 #define CADET_TEST_LIB_H
29 #if 0 /* keep Emacsens' auto-indent happy */
34 #include "gnunet_testbed_service.h"
35 #include "gnunet_cadet_service.h"
38 * Test context for a CADET Test.
40 struct GNUNET_CADET_TEST_Context;
44 * Main function of a CADET test.
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.
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);
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.
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.
75 GNUNET_CADET_TEST_ruN (const char *testname,
77 unsigned int num_peers,
78 GNUNET_CADET_TEST_AppMain tmain,
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);
87 * Clean up the testbed.
89 * @param ctx handle for the testbed
92 GNUNET_CADET_TEST_cleanup (struct GNUNET_CADET_TEST_Context *ctx);
95 #if 0 /* keep Emacsens' auto-indent happy */
103 /* ifndef CADET_TEST_LIB_H */