diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-05-16 15:43:30 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-05-16 15:43:30 +0000 |
commit | d4c278025719fc145516e98a6619b6136b768c23 (patch) | |
tree | af4c20adfdbe924c1e6bc954d62848c83158abac /src/core/test_core_api_reliability.c | |
parent | 1b0756f382f3e7d71bd31a808143f9b2ec48376c (diff) | |
download | gnunet-d4c278025719fc145516e98a6619b6136b768c23.tar.gz gnunet-d4c278025719fc145516e98a6619b6136b768c23.zip |
-do switch statement cases in order of enum
Diffstat (limited to 'src/core/test_core_api_reliability.c')
-rw-r--r-- | src/core/test_core_api_reliability.c | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index 0c6a39ffb..e18d8c4fd 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c | |||
@@ -33,8 +33,6 @@ | |||
33 | #include "gnunet_transport_service.h" | 33 | #include "gnunet_transport_service.h" |
34 | #include <gauger.h> | 34 | #include <gauger.h> |
35 | 35 | ||
36 | #define VERBOSE GNUNET_NO | ||
37 | |||
38 | #define START_ARM GNUNET_YES | 36 | #define START_ARM GNUNET_YES |
39 | 37 | ||
40 | /** | 38 | /** |
@@ -89,11 +87,7 @@ static int ok; | |||
89 | static int32_t tr_n; | 87 | static int32_t tr_n; |
90 | 88 | ||
91 | 89 | ||
92 | #if VERBOSE | ||
93 | #define OKPP do { ok++; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) | 90 | #define OKPP do { ok++; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) |
94 | #else | ||
95 | #define OKPP do { ok++; } while (0) | ||
96 | #endif | ||
97 | 91 | ||
98 | struct TestMessage | 92 | struct TestMessage |
99 | { | 93 | { |
@@ -113,9 +107,11 @@ get_size (unsigned int iter) | |||
113 | return sizeof (struct TestMessage) + (ret % 60000); | 107 | return sizeof (struct TestMessage) + (ret % 60000); |
114 | } | 108 | } |
115 | 109 | ||
110 | |||
116 | static void | 111 | static void |
117 | process_hello (void *cls, const struct GNUNET_MessageHeader *message); | 112 | process_hello (void *cls, const struct GNUNET_MessageHeader *message); |
118 | 113 | ||
114 | |||
119 | static void | 115 | static void |
120 | terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 116 | terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
121 | { | 117 | { |
@@ -183,6 +179,7 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
183 | GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); | 179 | GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); |
184 | } | 180 | } |
185 | 181 | ||
182 | |||
186 | static size_t | 183 | static size_t |
187 | transmit_ready (void *cls, size_t size, void *buf) | 184 | transmit_ready (void *cls, size_t size, void *buf) |
188 | { | 185 | { |
@@ -210,10 +207,8 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
210 | cbuf = buf; | 207 | cbuf = buf; |
211 | do | 208 | do |
212 | { | 209 | { |
213 | #if VERBOSE | ||
214 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 210 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
215 | "Sending message %u of size %u at offset %u\n", tr_n, s, ret); | 211 | "Sending message %u of size %u at offset %u\n", tr_n, s, ret); |
216 | #endif | ||
217 | hdr.header.size = htons (s); | 212 | hdr.header.size = htons (s); |
218 | hdr.header.type = htons (MTYPE); | 213 | hdr.header.type = htons (MTYPE); |
219 | hdr.num = htonl (tr_n); | 214 | hdr.num = htonl (tr_n); |
@@ -237,7 +232,6 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
237 | } | 232 | } |
238 | 233 | ||
239 | 234 | ||
240 | |||
241 | static void | 235 | static void |
242 | connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer, | 236 | connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer, |
243 | const struct GNUNET_ATS_Information *atsi, | 237 | const struct GNUNET_ATS_Information *atsi, |
@@ -289,10 +283,8 @@ inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, | |||
289 | const struct GNUNET_ATS_Information *atsi, | 283 | const struct GNUNET_ATS_Information *atsi, |
290 | unsigned int atsi_count) | 284 | unsigned int atsi_count) |
291 | { | 285 | { |
292 | #if VERBOSE | ||
293 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 286 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
294 | "Core provides inbound data from `%4s'.\n", GNUNET_i2s (other)); | 287 | "Core provides inbound data from `%4s'.\n", GNUNET_i2s (other)); |
295 | #endif | ||
296 | return GNUNET_OK; | 288 | return GNUNET_OK; |
297 | } | 289 | } |
298 | 290 | ||
@@ -303,11 +295,9 @@ outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, | |||
303 | const struct GNUNET_ATS_Information *atsi, | 295 | const struct GNUNET_ATS_Information *atsi, |
304 | unsigned int atsi_count) | 296 | unsigned int atsi_count) |
305 | { | 297 | { |
306 | #if VERBOSE | ||
307 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 298 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
308 | "Core notifies about outbound data for `%4s'.\n", | 299 | "Core notifies about outbound data for `%4s'.\n", |
309 | GNUNET_i2s (other)); | 300 | GNUNET_i2s (other)); |
310 | #endif | ||
311 | return GNUNET_OK; | 301 | return GNUNET_OK; |
312 | } | 302 | } |
313 | 303 | ||
@@ -315,6 +305,7 @@ outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, | |||
315 | static size_t | 305 | static size_t |
316 | transmit_ready (void *cls, size_t size, void *buf); | 306 | transmit_ready (void *cls, size_t size, void *buf); |
317 | 307 | ||
308 | |||
318 | static int | 309 | static int |
319 | process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, | 310 | process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, |
320 | const struct GNUNET_MessageHeader *message, | 311 | const struct GNUNET_MessageHeader *message, |
@@ -347,10 +338,8 @@ process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
347 | err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error, NULL); | 338 | err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error, NULL); |
348 | return GNUNET_SYSERR; | 339 | return GNUNET_SYSERR; |
349 | } | 340 | } |
350 | #if VERBOSE | ||
351 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n", | 341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n", |
352 | ntohl (hdr->num), ntohs (message->size)); | 342 | ntohl (hdr->num), ntohs (message->size)); |
353 | #endif | ||
354 | n++; | 343 | n++; |
355 | if (0 == (n % (TOTAL_MSGS / 100))) | 344 | if (0 == (n % (TOTAL_MSGS / 100))) |
356 | FPRINTF (stderr, "%s", "."); | 345 | FPRINTF (stderr, "%s", "."); |
@@ -378,7 +367,6 @@ static struct GNUNET_CORE_MessageHandler handlers[] = { | |||
378 | }; | 367 | }; |
379 | 368 | ||
380 | 369 | ||
381 | |||
382 | static void | 370 | static void |
383 | init_notify (void *cls, struct GNUNET_CORE_Handle *server, | 371 | init_notify (void *cls, struct GNUNET_CORE_Handle *server, |
384 | const struct GNUNET_PeerIdentity *my_identity) | 372 | const struct GNUNET_PeerIdentity *my_identity) |
@@ -435,7 +423,6 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) | |||
435 | } | 423 | } |
436 | 424 | ||
437 | 425 | ||
438 | |||
439 | static void | 426 | static void |
440 | setup_peer (struct PeerContext *p, const char *cfgname) | 427 | setup_peer (struct PeerContext *p, const char *cfgname) |
441 | { | 428 | { |
@@ -444,9 +431,6 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
444 | p->arm_proc = | 431 | p->arm_proc = |
445 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | 432 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", |
446 | "gnunet-service-arm", | 433 | "gnunet-service-arm", |
447 | #if VERBOSE | ||
448 | "-L", "DEBUG", | ||
449 | #endif | ||
450 | "-c", cfgname, NULL); | 434 | "-c", cfgname, NULL); |
451 | #endif | 435 | #endif |
452 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 436 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
@@ -494,9 +478,6 @@ check () | |||
494 | char *const argv[] = { "test-core-api-reliability", | 478 | char *const argv[] = { "test-core-api-reliability", |
495 | "-c", | 479 | "-c", |
496 | "test_core_api_data.conf", | 480 | "test_core_api_data.conf", |
497 | #if VERBOSE | ||
498 | "-L", "DEBUG", | ||
499 | #endif | ||
500 | NULL | 481 | NULL |
501 | }; | 482 | }; |
502 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 483 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
@@ -511,17 +492,14 @@ check () | |||
511 | return ok; | 492 | return ok; |
512 | } | 493 | } |
513 | 494 | ||
495 | |||
514 | int | 496 | int |
515 | main (int argc, char *argv[]) | 497 | main (int argc, char *argv[]) |
516 | { | 498 | { |
517 | int ret; | 499 | int ret; |
518 | 500 | ||
519 | GNUNET_log_setup ("test-core-api", | 501 | GNUNET_log_setup ("test-core-api", |
520 | #if VERBOSE | ||
521 | "DEBUG", | ||
522 | #else | ||
523 | "WARNING", | 502 | "WARNING", |
524 | #endif | ||
525 | NULL); | 503 | NULL); |
526 | ret = check (); | 504 | ret = check (); |
527 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); | 505 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); |