diff options
author | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
commit | d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch) | |
tree | 9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/testbed/test_testbed_api_testbed_run.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/testbed/test_testbed_api_testbed_run.c')
-rw-r--r-- | src/testbed/test_testbed_api_testbed_run.c | 181 |
1 files changed, 91 insertions, 90 deletions
diff --git a/src/testbed/test_testbed_api_testbed_run.c b/src/testbed/test_testbed_api_testbed_run.c index 27f5b13e7..39bc9bfe7 100644 --- a/src/testbed/test_testbed_api_testbed_run.c +++ b/src/testbed/test_testbed_api_testbed_run.c | |||
@@ -1,22 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2008--2013 GNUnet e.V. | 3 | Copyright (C) 2008--2013 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 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, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
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 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file testbed/test_testbed_api_testbed_run.c | 22 | * @file testbed/test_testbed_api_testbed_run.c |
@@ -70,11 +70,11 @@ static int wait_forever; | |||
70 | * @param cls NULL | 70 | * @param cls NULL |
71 | */ | 71 | */ |
72 | static void | 72 | static void |
73 | do_shutdown (void *cls) | 73 | do_shutdown(void *cls) |
74 | { | 74 | { |
75 | if (NULL != abort_task) | 75 | if (NULL != abort_task) |
76 | GNUNET_SCHEDULER_cancel (abort_task); | 76 | GNUNET_SCHEDULER_cancel(abort_task); |
77 | GNUNET_SCHEDULER_shutdown (); /* Stop scheduler to shutdown testbed run */ | 77 | GNUNET_SCHEDULER_shutdown(); /* Stop scheduler to shutdown testbed run */ |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
@@ -84,12 +84,12 @@ do_shutdown (void *cls) | |||
84 | * @param cls NULL | 84 | * @param cls NULL |
85 | */ | 85 | */ |
86 | static void | 86 | static void |
87 | do_abort (void *cls) | 87 | do_abort(void *cls) |
88 | { | 88 | { |
89 | abort_task = NULL; | 89 | abort_task = NULL; |
90 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 90 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
91 | "Test timed out -- Aborting\n"); | 91 | "Test timed out -- Aborting\n"); |
92 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 92 | GNUNET_SCHEDULER_add_now(&do_shutdown, NULL); |
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
@@ -106,26 +106,26 @@ do_abort (void *cls) | |||
106 | * failed | 106 | * failed |
107 | */ | 107 | */ |
108 | static void | 108 | static void |
109 | test_master (void *cls, | 109 | test_master(void *cls, |
110 | struct GNUNET_TESTBED_RunHandle *h, | 110 | struct GNUNET_TESTBED_RunHandle *h, |
111 | unsigned int num_peers, | 111 | unsigned int num_peers, |
112 | struct GNUNET_TESTBED_Peer **peers_, | 112 | struct GNUNET_TESTBED_Peer **peers_, |
113 | unsigned int links_succeeded, | 113 | unsigned int links_succeeded, |
114 | unsigned int links_failed) | 114 | unsigned int links_failed) |
115 | { | 115 | { |
116 | result = GNUNET_OK; | 116 | result = GNUNET_OK; |
117 | if (GNUNET_YES == wait_forever) | 117 | if (GNUNET_YES == wait_forever) |
118 | { | 118 | { |
119 | if (NULL == abort_task) | 119 | if (NULL == abort_task) |
120 | return; /* abort already scheduled */ | 120 | return; /* abort already scheduled */ |
121 | GNUNET_SCHEDULER_cancel (abort_task); | 121 | GNUNET_SCHEDULER_cancel(abort_task); |
122 | abort_task = NULL; | 122 | abort_task = NULL; |
123 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | 123 | GNUNET_SCHEDULER_add_shutdown(&do_shutdown, NULL); |
124 | return; | 124 | return; |
125 | } | 125 | } |
126 | GNUNET_assert (NULL != peers[0]); | 126 | GNUNET_assert(NULL != peers[0]); |
127 | op = GNUNET_TESTBED_peer_stop (NULL, peers[0], NULL, NULL); | 127 | op = GNUNET_TESTBED_peer_stop(NULL, peers[0], NULL, NULL); |
128 | GNUNET_assert (NULL != op); | 128 | GNUNET_assert(NULL != op); |
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
@@ -136,26 +136,27 @@ test_master (void *cls, | |||
136 | * @param event the controller event | 136 | * @param event the controller event |
137 | */ | 137 | */ |
138 | static void | 138 | static void |
139 | controller_event_cb (void *cls, | 139 | controller_event_cb(void *cls, |
140 | const struct GNUNET_TESTBED_EventInformation *event) | 140 | const struct GNUNET_TESTBED_EventInformation *event) |
141 | { | 141 | { |
142 | |||
143 | switch (event->type) | 142 | switch (event->type) |
144 | { | 143 | { |
145 | case GNUNET_TESTBED_ET_PEER_START: | 144 | case GNUNET_TESTBED_ET_PEER_START: |
146 | GNUNET_assert (NULL == peers[peer_id]); | 145 | GNUNET_assert(NULL == peers[peer_id]); |
147 | GNUNET_assert (NULL != event->details.peer_start.peer); | 146 | GNUNET_assert(NULL != event->details.peer_start.peer); |
148 | peers[peer_id++] = event->details.peer_start.peer; | 147 | peers[peer_id++] = event->details.peer_start.peer; |
149 | break; | 148 | break; |
150 | case GNUNET_TESTBED_ET_PEER_STOP: | 149 | |
151 | GNUNET_assert (NULL != op); | 150 | case GNUNET_TESTBED_ET_PEER_STOP: |
152 | GNUNET_TESTBED_operation_done (op); | 151 | GNUNET_assert(NULL != op); |
153 | GNUNET_assert (peers[0] == event->details.peer_stop.peer); | 152 | GNUNET_TESTBED_operation_done(op); |
154 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 153 | GNUNET_assert(peers[0] == event->details.peer_stop.peer); |
155 | break; | 154 | GNUNET_SCHEDULER_add_now(&do_shutdown, NULL); |
156 | default: | 155 | break; |
157 | GNUNET_assert (0); | 156 | |
158 | } | 157 | default: |
158 | GNUNET_assert(0); | ||
159 | } | ||
159 | } | 160 | } |
160 | 161 | ||
161 | 162 | ||
@@ -168,24 +169,24 @@ controller_event_cb (void *cls, | |||
168 | * @param cfg the configuration file handle | 169 | * @param cfg the configuration file handle |
169 | */ | 170 | */ |
170 | static void | 171 | static void |
171 | run (void *cls, | 172 | run(void *cls, |
172 | char *const *args, | 173 | char *const *args, |
173 | const char *cfgfile, | 174 | const char *cfgfile, |
174 | const struct GNUNET_CONFIGURATION_Handle *config) | 175 | const struct GNUNET_CONFIGURATION_Handle *config) |
175 | { | 176 | { |
176 | uint64_t event_mask; | 177 | uint64_t event_mask; |
177 | 178 | ||
178 | event_mask = 0; | 179 | event_mask = 0; |
179 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START); | 180 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START); |
180 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP); | 181 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP); |
181 | GNUNET_TESTBED_run (NULL, config, NUM_PEERS, event_mask, | 182 | GNUNET_TESTBED_run(NULL, config, NUM_PEERS, event_mask, |
182 | &controller_event_cb, NULL, | 183 | &controller_event_cb, NULL, |
183 | &test_master, NULL); | 184 | &test_master, NULL); |
184 | abort_task = | 185 | abort_task = |
185 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 186 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply |
186 | (GNUNET_TIME_UNIT_SECONDS, 300), | 187 | (GNUNET_TIME_UNIT_SECONDS, 300), |
187 | &do_abort, | 188 | &do_abort, |
188 | NULL); | 189 | NULL); |
189 | } | 190 | } |
190 | 191 | ||
191 | 192 | ||
@@ -193,7 +194,7 @@ run (void *cls, | |||
193 | * Main function | 194 | * Main function |
194 | */ | 195 | */ |
195 | int | 196 | int |
196 | main (int argc, char **argv) | 197 | main(int argc, char **argv) |
197 | { | 198 | { |
198 | char *argv2[] = { | 199 | char *argv2[] = { |
199 | "test_testbed_api_testbed_run", | 200 | "test_testbed_api_testbed_run", |
@@ -207,42 +208,42 @@ main (int argc, char **argv) | |||
207 | char *config_filename; | 208 | char *config_filename; |
208 | int ret; | 209 | int ret; |
209 | 210 | ||
210 | if (NULL == (testname = strrchr (argv[0], (int) '_'))) | 211 | if (NULL == (testname = strrchr(argv[0], (int)'_'))) |
211 | { | 212 | { |
212 | GNUNET_break (0); | 213 | GNUNET_break(0); |
213 | return 1; | 214 | return 1; |
214 | } | 215 | } |
215 | testname++; | 216 | testname++; |
216 | testname = GNUNET_strdup (testname); | 217 | testname = GNUNET_strdup(testname); |
217 | #ifdef MINGW | 218 | #ifdef MINGW |
218 | { | 219 | { |
219 | char *period; | 220 | char *period; |
220 | 221 | ||
221 | /* check and remove .exe extension */ | 222 | /* check and remove .exe extension */ |
222 | period = strrchr (testname, (int) '.'); | 223 | period = strrchr(testname, (int)'.'); |
223 | if (NULL != period) | 224 | if (NULL != period) |
224 | *period = '\0'; | 225 | *period = '\0'; |
225 | else | 226 | else |
226 | GNUNET_break (0); /* Windows with no .exe? */ | 227 | GNUNET_break(0); /* Windows with no .exe? */ |
227 | } | 228 | } |
228 | #endif | 229 | #endif |
229 | if (0 == strcmp ("waitforever", testname)) | 230 | if (0 == strcmp("waitforever", testname)) |
230 | wait_forever = GNUNET_YES; | 231 | wait_forever = GNUNET_YES; |
231 | if ( (GNUNET_YES != wait_forever) && (0 != strcmp ("run", testname)) ) | 232 | if ((GNUNET_YES != wait_forever) && (0 != strcmp("run", testname))) |
232 | { | 233 | { |
233 | GNUNET_asprintf (&config_filename, "test_testbed_api_testbed_run_%s.conf", | 234 | GNUNET_asprintf(&config_filename, "test_testbed_api_testbed_run_%s.conf", |
234 | testname); | 235 | testname); |
235 | } | 236 | } |
236 | else | 237 | else |
237 | config_filename = GNUNET_strdup ("test_testbed_api.conf"); | 238 | config_filename = GNUNET_strdup("test_testbed_api.conf"); |
238 | GNUNET_free (testname); | 239 | GNUNET_free(testname); |
239 | argv2[2] = config_filename; | 240 | argv2[2] = config_filename; |
240 | result = GNUNET_SYSERR; | 241 | result = GNUNET_SYSERR; |
241 | ret = | 242 | ret = |
242 | GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, | 243 | GNUNET_PROGRAM_run((sizeof(argv2) / sizeof(char *)) - 1, argv2, |
243 | "test_testbed_api_testbed_run", "nohelp", options, | 244 | "test_testbed_api_testbed_run", "nohelp", options, |
244 | &run, NULL); | 245 | &run, NULL); |
245 | GNUNET_free (config_filename); | 246 | GNUNET_free(config_filename); |
246 | if ((GNUNET_OK != ret) || (GNUNET_OK != result)) | 247 | if ((GNUNET_OK != ret) || (GNUNET_OK != result)) |
247 | return 1; | 248 | return 1; |
248 | return 0; | 249 | return 0; |