summaryrefslogtreecommitdiff
path: root/src/testbed/test_testbed_api_statistics.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/test_testbed_api_statistics.c')
-rw-r--r--src/testbed/test_testbed_api_statistics.c108
1 files changed, 54 insertions, 54 deletions
diff --git a/src/testbed/test_testbed_api_statistics.c b/src/testbed/test_testbed_api_statistics.c
index 6d1673cef..26f90cfff 100644
--- a/src/testbed/test_testbed_api_statistics.c
+++ b/src/testbed/test_testbed_api_statistics.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 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/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -46,7 +46,7 @@ static struct GNUNET_TESTBED_Operation *op;
46/** 46/**
47 * dummy pointer 47 * dummy pointer
48 */ 48 */
49static void *dummy_cls = (void *) 0xDEAD0001; 49static void *dummy_cls = (void *)0xDEAD0001;
50 50
51/** 51/**
52 * Abort task identifier 52 * Abort task identifier
@@ -73,13 +73,13 @@ static unsigned int num_seen_peers;
73 * Fail testcase 73 * Fail testcase
74 */ 74 */
75#define FAIL_TEST(cond, ret) do { \ 75#define FAIL_TEST(cond, ret) do { \
76 if (!(cond)) { \ 76 if (!(cond)) { \
77 GNUNET_break(0); \ 77 GNUNET_break(0); \
78 if (NULL != abort_task) \ 78 if (NULL != abort_task) \
79 GNUNET_SCHEDULER_cancel (abort_task); \ 79 GNUNET_SCHEDULER_cancel (abort_task); \
80 abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); \ 80 abort_task = GNUNET_SCHEDULER_add_now(&do_abort, NULL); \
81 ret; \ 81 ret; \
82 } \ 82 } \
83 } while (0) 83 } while (0)
84 84
85 85
@@ -89,15 +89,15 @@ static unsigned int num_seen_peers;
89 * @param cls NULL 89 * @param cls NULL
90 */ 90 */
91static void 91static void
92do_abort (void *cls) 92do_abort(void *cls)
93{ 93{
94 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Test timed out -- Aborting\n"); 94 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Test timed out -- Aborting\n");
95 abort_task = NULL; 95 abort_task = NULL;
96 if (NULL != op) 96 if (NULL != op)
97 { 97 {
98 GNUNET_TESTBED_operation_done (op); 98 GNUNET_TESTBED_operation_done(op);
99 op = NULL; 99 op = NULL;
100 } 100 }
101 result = GNUNET_SYSERR; 101 result = GNUNET_SYSERR;
102} 102}
103 103
@@ -114,20 +114,20 @@ do_abort (void *cls)
114 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration 114 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
115 */ 115 */
116static int 116static int
117stats_iterator (void *cls, 117stats_iterator(void *cls,
118 const struct GNUNET_TESTBED_Peer *peer, 118 const struct GNUNET_TESTBED_Peer *peer,
119 const char *subsystem, const char *name, uint64_t value, 119 const char *subsystem, const char *name, uint64_t value,
120 int is_persistent) 120 int is_persistent)
121{ 121{
122 unsigned int cnt; 122 unsigned int cnt;
123 123
124 FAIL_TEST (cls == dummy_cls, return GNUNET_SYSERR); 124 FAIL_TEST(cls == dummy_cls, return GNUNET_SYSERR);
125 for (cnt = 0; cnt < num_seen_peers; cnt++) 125 for (cnt = 0; cnt < num_seen_peers; cnt++)
126 FAIL_TEST (peer != seen_peers[cnt], return GNUNET_SYSERR); 126 FAIL_TEST(peer != seen_peers[cnt], return GNUNET_SYSERR);
127 FAIL_TEST (NULL != subsystem, return GNUNET_SYSERR); 127 FAIL_TEST(NULL != subsystem, return GNUNET_SYSERR);
128 FAIL_TEST (NULL != name, return GNUNET_SYSERR); 128 FAIL_TEST(NULL != name, return GNUNET_SYSERR);
129 GNUNET_array_append (seen_peers, num_seen_peers, 129 GNUNET_array_append(seen_peers, num_seen_peers,
130 (struct GNUNET_TESTBED_Peer *) peer); 130 (struct GNUNET_TESTBED_Peer *)peer);
131 return GNUNET_SYSERR; 131 return GNUNET_SYSERR;
132} 132}
133 133
@@ -141,16 +141,16 @@ stats_iterator (void *cls,
141 * operation has executed successfully. 141 * operation has executed successfully.
142 */ 142 */
143static void 143static void
144op_comp_cb (void *cls, 144op_comp_cb(void *cls,
145 struct GNUNET_TESTBED_Operation *op, 145 struct GNUNET_TESTBED_Operation *op,
146 const char *emsg) 146 const char *emsg)
147{ 147{
148 FAIL_TEST (cls == dummy_cls, return); 148 FAIL_TEST(cls == dummy_cls, return );
149 result = GNUNET_OK; 149 result = GNUNET_OK;
150 GNUNET_TESTBED_operation_done (op); 150 GNUNET_TESTBED_operation_done(op);
151 op = NULL; 151 op = NULL;
152 GNUNET_SCHEDULER_cancel (abort_task); 152 GNUNET_SCHEDULER_cancel(abort_task);
153 GNUNET_SCHEDULER_shutdown (); 153 GNUNET_SCHEDULER_shutdown();
154} 154}
155 155
156 156
@@ -167,23 +167,23 @@ op_comp_cb (void *cls,
167 * failed 167 * failed
168 */ 168 */
169static void 169static void
170test_master (void *cls, 170test_master(void *cls,
171 struct GNUNET_TESTBED_RunHandle *h, 171 struct GNUNET_TESTBED_RunHandle *h,
172 unsigned int num_peers, 172 unsigned int num_peers,
173 struct GNUNET_TESTBED_Peer **peers_, 173 struct GNUNET_TESTBED_Peer **peers_,
174 unsigned int links_succeeded, 174 unsigned int links_succeeded,
175 unsigned int links_failed) 175 unsigned int links_failed)
176{ 176{
177 FAIL_TEST (NUM_PEERS == num_peers, return); 177 FAIL_TEST(NUM_PEERS == num_peers, return );
178 peers = peers_; 178 peers = peers_;
179 op = GNUNET_TESTBED_get_statistics (num_peers, peers, 179 op = GNUNET_TESTBED_get_statistics(num_peers, peers,
180 NULL, NULL, 180 NULL, NULL,
181 &stats_iterator, 181 &stats_iterator,
182 &op_comp_cb, 182 &op_comp_cb,
183 dummy_cls); 183 dummy_cls);
184 abort_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 184 abort_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply
185 (GNUNET_TIME_UNIT_MINUTES, 1), 185 (GNUNET_TIME_UNIT_MINUTES, 1),
186 &do_abort, NULL); 186 &do_abort, NULL);
187} 187}
188 188
189 189
@@ -191,14 +191,14 @@ test_master (void *cls,
191 * Main function 191 * Main function
192 */ 192 */
193int 193int
194main (int argc, char **argv) 194main(int argc, char **argv)
195{ 195{
196 (void) GNUNET_TESTBED_test_run ("test_testbed_api_statistics", 196 (void)GNUNET_TESTBED_test_run("test_testbed_api_statistics",
197 "test_testbed_api_statistics.conf", 197 "test_testbed_api_statistics.conf",
198 NUM_PEERS, 198 NUM_PEERS,
199 1LL, NULL, NULL, 199 1LL, NULL, NULL,
200 &test_master, NULL); 200 &test_master, NULL);
201 GNUNET_free_non_null (seen_peers); 201 GNUNET_free_non_null(seen_peers);
202 if (GNUNET_OK != result) 202 if (GNUNET_OK != result)
203 return 1; 203 return 1;
204 return 0; 204 return 0;