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