link against libz explicitly, as we use it directly
[oweals/gnunet.git] / src / testbed / test_testbed_api_test_timeout.c
1 /*
2   This file is part of GNUnet
3   Copyright (C) 2008--2013 GNUnet e.V.
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., 51 Franklin Street, Fifth Floor,
18   Boston, MA 02110-1301, USA.
19 */
20
21 /**
22  * @file src/testbed/test_testbed_api_test.c
23  * @brief testing cases for testing notications via test master callback upon
24  *          timeout while setting up testbed using functions
25  *          GNUNET_TESTBED_test_run()
26  * @author Sree Harsha Totakura <sreeharsha@totakura.in>
27  */
28
29 #include "platform.h"
30 #include "gnunet_util_lib.h"
31 #include "gnunet_testbed_service.h"
32
33
34 /**
35  * Generic logging shortcut
36  */
37 #define LOG(kind,...)                           \
38   GNUNET_log (kind, __VA_ARGS__)
39
40 /**
41  * Number of peers we want to start
42  */
43 #define NUM_PEERS 25
44
45 /**
46  * Testing result
47  */
48 static int result;
49
50
51 /**
52  * shortcut to exit during failure
53  */
54 #define FAIL_TEST(cond) do {                                            \
55     if (!(cond)) {                                                      \
56       GNUNET_break(0);                                                  \
57       GNUNET_SCHEDULER_shutdown ();                                     \
58       return;                                                           \
59     }                                                                   \
60   } while (0)
61
62
63 /**
64  * Controller event callback
65  *
66  * @param cls NULL
67  * @param event the controller event
68  */
69 static void
70 controller_event_cb (void *cls,
71                      const struct GNUNET_TESTBED_EventInformation *event)
72 {
73   FAIL_TEST (0);
74 }
75
76
77 /**
78  * Signature of a main function for a testcase.
79  *
80  * @param cls closure
81  * @param h the run handle
82  * @param num_peers number of peers in 'peers'
83  * @param peers- handle to peers run in the testbed
84  * @param links_succeeded the number of overlay link connection attempts that
85  *          succeeded
86  * @param links_failed the number of overlay link connection attempts that
87  *          failed
88  */
89 static void
90 test_master (void *cls,
91              struct GNUNET_TESTBED_RunHandle *h,
92              unsigned int num_peers,
93              struct GNUNET_TESTBED_Peer **peers_,
94              unsigned int links_succeeded,
95              unsigned int links_failed)
96 {
97   FAIL_TEST (NULL == cls);
98   FAIL_TEST (0 == num_peers);
99   FAIL_TEST (NULL == peers_);
100   result = GNUNET_OK;
101   GNUNET_SCHEDULER_shutdown ();
102 }
103
104
105 /**
106  * Main function
107  */
108 int
109 main (int argc, char **argv)
110 {
111   uint64_t event_mask;
112
113   result = GNUNET_SYSERR;
114   event_mask = 0;
115   (void) GNUNET_TESTBED_test_run ("test_testbed_api_test",
116                                   "test_testbed_api_test_timeout.conf", NUM_PEERS,
117                                   event_mask, &controller_event_cb, NULL,
118                                   &test_master, NULL);
119   if (GNUNET_OK != result)
120     return 1;
121   return 0;
122 }
123
124 /* end of test_testbed_api_test.c */