aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/gnunet-testbed-profiler.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
commitc4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch)
treecac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/testbed/gnunet-testbed-profiler.c
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
downloadgnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz
gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/testbed/gnunet-testbed-profiler.c')
-rw-r--r--src/testbed/gnunet-testbed-profiler.c215
1 files changed, 109 insertions, 106 deletions
diff --git a/src/testbed/gnunet-testbed-profiler.c b/src/testbed/gnunet-testbed-profiler.c
index e65ae6202..cfc6367fe 100644
--- a/src/testbed/gnunet-testbed-profiler.c
+++ b/src/testbed/gnunet-testbed-profiler.c
@@ -33,7 +33,7 @@
33 * Generic loggins shorthand 33 * Generic loggins shorthand
34 */ 34 */
35#define LOG(kind, ...) \ 35#define LOG(kind, ...) \
36 GNUNET_log(kind, __VA_ARGS__) 36 GNUNET_log (kind, __VA_ARGS__)
37 37
38 38
39/** 39/**
@@ -104,18 +104,18 @@ static int noninteractive;
104 * @param cls NULL 104 * @param cls NULL
105 */ 105 */
106static void 106static void
107do_shutdown(void *cls) 107do_shutdown (void *cls)
108{ 108{
109 if (NULL != abort_task) 109 if (NULL != abort_task)
110 { 110 {
111 GNUNET_SCHEDULER_cancel(abort_task); 111 GNUNET_SCHEDULER_cancel (abort_task);
112 abort_task = NULL; 112 abort_task = NULL;
113 } 113 }
114 if (NULL != cfg) 114 if (NULL != cfg)
115 { 115 {
116 GNUNET_CONFIGURATION_destroy(cfg); 116 GNUNET_CONFIGURATION_destroy (cfg);
117 cfg = NULL; 117 cfg = NULL;
118 } 118 }
119} 119}
120 120
121 121
@@ -125,13 +125,13 @@ do_shutdown(void *cls)
125 * @param cls NULL 125 * @param cls NULL
126 */ 126 */
127static void 127static void
128do_abort(void *cls) 128do_abort (void *cls)
129{ 129{
130 abort_task = NULL; 130 abort_task = NULL;
131 LOG(GNUNET_ERROR_TYPE_WARNING, 131 LOG (GNUNET_ERROR_TYPE_WARNING,
132 "Aborting\n"); 132 "Aborting\n");
133 result = GNUNET_SYSERR; 133 result = GNUNET_SYSERR;
134 GNUNET_SCHEDULER_shutdown(); 134 GNUNET_SCHEDULER_shutdown ();
135} 135}
136 136
137 137
@@ -140,15 +140,15 @@ do_abort(void *cls)
140 * many failed 140 * many failed
141 */ 141 */
142static void 142static void
143print_overlay_links_summary() 143print_overlay_links_summary ()
144{ 144{
145 static int printed_already; 145 static int printed_already;
146 146
147 if (GNUNET_YES == printed_already) 147 if (GNUNET_YES == printed_already)
148 return; 148 return;
149 printed_already = GNUNET_YES; 149 printed_already = GNUNET_YES;
150 printf("%u links succeeded\n", established_links); 150 printf ("%u links succeeded\n", established_links);
151 printf("%u links failed due to timeouts\n", failed_links); 151 printf ("%u links failed due to timeouts\n", failed_links);
152} 152}
153 153
154 154
@@ -159,43 +159,43 @@ print_overlay_links_summary()
159 * @param event the controller event 159 * @param event the controller event
160 */ 160 */
161static void 161static void
162controller_event_cb(void *cls, 162controller_event_cb (void *cls,
163 const struct GNUNET_TESTBED_EventInformation *event) 163 const struct GNUNET_TESTBED_EventInformation *event)
164{ 164{
165 switch (event->type) 165 switch (event->type)
166 {
167 case GNUNET_TESTBED_ET_OPERATION_FINISHED:
168 /* Control reaches here when a peer linking operation fails */
169 if (NULL != event->details.operation_finished.emsg)
166 { 170 {
167 case GNUNET_TESTBED_ET_OPERATION_FINISHED: 171 printf ("F");
168 /* Control reaches here when a peer linking operation fails */ 172 fflush (stdout);
169 if (NULL != event->details.operation_finished.emsg) 173 failed_links++;
170 { 174 if (++cont_fails > num_cont_fails)
171 printf("F"); 175 {
172 fflush(stdout); 176 printf ("\nAborting due to very high failure rate\n");
173 failed_links++; 177 print_overlay_links_summary ();
174 if (++cont_fails > num_cont_fails) 178 GNUNET_SCHEDULER_shutdown ();
175 { 179 return;
176 printf("\nAborting due to very high failure rate\n"); 180 }
177 print_overlay_links_summary(); 181 }
178 GNUNET_SCHEDULER_shutdown(); 182 break;
179 return; 183
180 } 184 case GNUNET_TESTBED_ET_CONNECT:
181 }
182 break;
183
184 case GNUNET_TESTBED_ET_CONNECT:
185 { 185 {
186 if (0 != cont_fails) 186 if (0 != cont_fails)
187 cont_fails--; 187 cont_fails--;
188 if (0 == established_links) 188 if (0 == established_links)
189 printf("Establishing links. Please wait\n"); 189 printf ("Establishing links. Please wait\n");
190 printf("."); 190 printf (".");
191 fflush(stdout); 191 fflush (stdout);
192 established_links++; 192 established_links++;
193 } 193 }
194 break; 194 break;
195 195
196 default: 196 default:
197 GNUNET_break(0); 197 GNUNET_break (0);
198 } 198 }
199} 199}
200 200
201 201
@@ -211,30 +211,30 @@ controller_event_cb(void *cls,
211 * @param links_failed the number of overlay link 211 * @param links_failed the number of overlay link
212 */ 212 */
213static void 213static void
214test_run(void *cls, 214test_run (void *cls,
215 struct GNUNET_TESTBED_RunHandle *h, 215 struct GNUNET_TESTBED_RunHandle *h,
216 unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, 216 unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers,
217 unsigned int links_succeeded, 217 unsigned int links_succeeded,
218 unsigned int links_failed) 218 unsigned int links_failed)
219{ 219{
220 result = GNUNET_OK; 220 result = GNUNET_OK;
221 fprintf(stdout, "\n"); 221 fprintf (stdout, "\n");
222 print_overlay_links_summary(); 222 print_overlay_links_summary ();
223 GNUNET_SCHEDULER_add_shutdown(&do_shutdown, NULL); 223 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
224 if (noninteractive) 224 if (noninteractive)
225 { 225 {
226 GNUNET_SCHEDULER_cancel(abort_task); 226 GNUNET_SCHEDULER_cancel (abort_task);
227 abort_task = NULL; 227 abort_task = NULL;
228 return; 228 return;
229 } 229 }
230#if (!ENABLE_SUPERMUC) 230#if (! ENABLE_SUPERMUC)
231 fprintf(stdout, "Testbed running, waiting for keystroke to shut down\n"); 231 fprintf (stdout, "Testbed running, waiting for keystroke to shut down\n");
232 fflush(stdout); 232 fflush (stdout);
233 (void)getc(stdin); 233 (void) getc (stdin);
234#endif 234#endif
235 fprintf(stdout, "Shutting down. Please wait\n"); 235 fprintf (stdout, "Shutting down. Please wait\n");
236 fflush(stdout); 236 fflush (stdout);
237 GNUNET_SCHEDULER_shutdown(); 237 GNUNET_SCHEDULER_shutdown ();
238} 238}
239 239
240 240
@@ -247,25 +247,25 @@ test_run(void *cls,
247 * @param config configuration 247 * @param config configuration
248 */ 248 */
249static void 249static void
250run(void *cls, char *const *args, const char *cfgfile, 250run (void *cls, char *const *args, const char *cfgfile,
251 const struct GNUNET_CONFIGURATION_Handle *config) 251 const struct GNUNET_CONFIGURATION_Handle *config)
252{ 252{
253 if (0 == num_peers) 253 if (0 == num_peers)
254 { 254 {
255 LOG(GNUNET_ERROR_TYPE_ERROR, _("Exiting as the number of peers is %u\n"), 255 LOG (GNUNET_ERROR_TYPE_ERROR, _ ("Exiting as the number of peers is %u\n"),
256 num_peers); 256 num_peers);
257 return; 257 return;
258 } 258 }
259 cfg = GNUNET_CONFIGURATION_dup(config); 259 cfg = GNUNET_CONFIGURATION_dup (config);
260 event_mask = 0; 260 event_mask = 0;
261 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); 261 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
262 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); 262 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
263 GNUNET_TESTBED_run(hosts_file, cfg, num_peers, event_mask, 263 GNUNET_TESTBED_run (hosts_file, cfg, num_peers, event_mask,
264 &controller_event_cb, NULL, 264 &controller_event_cb, NULL,
265 &test_run, NULL); 265 &test_run, NULL);
266 abort_task = 266 abort_task =
267 GNUNET_SCHEDULER_add_shutdown(&do_abort, 267 GNUNET_SCHEDULER_add_shutdown (&do_abort,
268 NULL); 268 NULL);
269} 269}
270 270
271 271
@@ -275,47 +275,50 @@ run(void *cls, char *const *args, const char *cfgfile,
275 * @return 0 on success 275 * @return 0 on success
276 */ 276 */
277int 277int
278main(int argc, char *const *argv) 278main (int argc, char *const *argv)
279{ 279{
280 struct GNUNET_GETOPT_CommandLineOption options[] = { 280 struct GNUNET_GETOPT_CommandLineOption options[] = {
281 GNUNET_GETOPT_option_uint('p', 281 GNUNET_GETOPT_option_uint ('p',
282 "num-peers", 282 "num-peers",
283 "COUNT", 283 "COUNT",
284 gettext_noop("create COUNT number of peers"), 284 gettext_noop ("create COUNT number of peers"),
285 &num_peers), 285 &num_peers),
286 GNUNET_GETOPT_option_uint('e', 286 GNUNET_GETOPT_option_uint ('e',
287 "num-errors", 287 "num-errors",
288 "COUNT", 288 "COUNT",
289 gettext_noop("tolerate COUNT number of continious timeout failures"), 289 gettext_noop (
290 &num_cont_fails), 290 "tolerate COUNT number of continious timeout failures"),
291 GNUNET_GETOPT_option_flag('n', 291 &num_cont_fails),
292 "non-interactive", 292 GNUNET_GETOPT_option_flag ('n',
293 gettext_noop("run profiler in non-interactive mode where upon " 293 "non-interactive",
294 "testbed setup the profiler does not wait for a " 294 gettext_noop (
295 "keystroke but continues to run until a termination " 295 "run profiler in non-interactive mode where upon "
296 "signal is received"), 296 "testbed setup the profiler does not wait for a "
297 &noninteractive), 297 "keystroke but continues to run until a termination "
298#if !ENABLE_SUPERMUC 298 "signal is received"),
299 GNUNET_GETOPT_option_string('H', 299 &noninteractive),
300 "hosts", 300#if ! ENABLE_SUPERMUC
301 "FILENAME", 301 GNUNET_GETOPT_option_string ('H',
302 gettext_noop("name of the file with the login information for the testbed"), 302 "hosts",
303 &hosts_file), 303 "FILENAME",
304 gettext_noop (
305 "name of the file with the login information for the testbed"),
306 &hosts_file),
304#endif 307#endif
305 GNUNET_GETOPT_OPTION_END 308 GNUNET_GETOPT_OPTION_END
306 }; 309 };
307 const char *binaryHelp = "gnunet-testbed-profiler [OPTIONS]"; 310 const char *binaryHelp = "gnunet-testbed-profiler [OPTIONS]";
308 int ret; 311 int ret;
309 312
310 unsetenv("XDG_DATA_HOME"); 313 unsetenv ("XDG_DATA_HOME");
311 unsetenv("XDG_CONFIG_HOME"); 314 unsetenv ("XDG_CONFIG_HOME");
312 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv)) 315 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
313 return 2; 316 return 2;
314 result = GNUNET_SYSERR; 317 result = GNUNET_SYSERR;
315 ret = 318 ret =
316 GNUNET_PROGRAM_run(argc, argv, "gnunet-testbed-profiler", binaryHelp, 319 GNUNET_PROGRAM_run (argc, argv, "gnunet-testbed-profiler", binaryHelp,
317 options, &run, NULL); 320 options, &run, NULL);
318 GNUNET_free((void *)argv); 321 GNUNET_free ((void *) argv);
319 if (GNUNET_OK != ret) 322 if (GNUNET_OK != ret)
320 return ret; 323 return ret;
321 if (GNUNET_OK != result) 324 if (GNUNET_OK != result)