Call TestMaster callback upon timeout set through configuration
[oweals/gnunet.git] / src / testbed / test_testbed_api_test_timeout.c
1 /*
2   This file is part of GNUnet
3   (C) 2008--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 /**
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_common.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 num_peers number of peers in 'peers'
82  * @param peers handle to peers run in the testbed
83  */
84 static void
85 test_master (void *cls, unsigned int num_peers,
86              struct GNUNET_TESTBED_Peer **peers_)
87 {
88   FAIL_TEST (NULL == cls);
89   FAIL_TEST (0 == num_peers);
90   FAIL_TEST (NULL == peers_);
91   result = GNUNET_OK;
92   GNUNET_SCHEDULER_shutdown ();
93 }
94
95
96 /**
97  * Main function
98  */
99 int
100 main (int argc, char **argv)
101 {
102   uint64_t event_mask;
103
104   result = GNUNET_SYSERR;
105   event_mask = 0;
106   (void) GNUNET_TESTBED_test_run ("test_testbed_api_test",
107                                   "test_testbed_api_test_timeout.conf", NUM_PEERS,
108                                   event_mask, &controller_event_cb, NULL,
109                                   &test_master, NULL);
110   if (GNUNET_OK != result)
111     return 1;
112   return 0;
113 }
114
115 /* end of test_testbed_api_test.c */