aboutsummaryrefslogtreecommitdiff
path: root/src/core/test_core_api_reliability.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-26 10:16:55 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-26 10:16:55 +0000
commitbbcfaabced541509ee15cadffa018105d4410ae8 (patch)
tree0728a702aa993dde0e5dc5a85b9692f830a1de00 /src/core/test_core_api_reliability.c
parent3ace86cc6a790b8a58554cfdc1c1a9077517224e (diff)
downloadgnunet-bbcfaabced541509ee15cadffa018105d4410ae8.tar.gz
gnunet-bbcfaabced541509ee15cadffa018105d4410ae8.zip
fix testcase shutdown
Diffstat (limited to 'src/core/test_core_api_reliability.c')
-rw-r--r--src/core/test_core_api_reliability.c58
1 files changed, 41 insertions, 17 deletions
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c
index 99eb7ea21..9924bef97 100644
--- a/src/core/test_core_api_reliability.c
+++ b/src/core/test_core_api_reliability.c
@@ -84,7 +84,7 @@ static int32_t tr_n;
84struct TestMessage 84struct TestMessage
85{ 85{
86 struct GNUNET_MessageHeader header; 86 struct GNUNET_MessageHeader header;
87 uint32_t num; 87 uint32_t num GNUNET_PACKED;
88}; 88};
89 89
90 90
@@ -136,8 +136,6 @@ terminate_task (void *cls)
136{ 136{
137 unsigned long long delta; 137 unsigned long long delta;
138 138
139 terminate_peer (&p1);
140 terminate_peer (&p2);
141 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; 139 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us;
142 FPRINTF (stderr, 140 FPRINTF (stderr,
143 "\nThroughput was %llu kb/s\n", 141 "\nThroughput was %llu kb/s\n",
@@ -146,6 +144,7 @@ terminate_task (void *cls)
146 "Core throughput/s", 144 "Core throughput/s",
147 total_bytes * 1000000LL / 1024 / delta, 145 total_bytes * 1000000LL / 1024 / delta,
148 "kb/s"); 146 "kb/s");
147 GNUNET_SCHEDULER_shutdown ();
149 ok = 0; 148 ok = 0;
150} 149}
151 150
@@ -153,10 +152,23 @@ terminate_task (void *cls)
153static void 152static void
154terminate_task_error (void *cls) 153terminate_task_error (void *cls)
155{ 154{
155 err_task = NULL;
156 GNUNET_break (0); 156 GNUNET_break (0);
157 GNUNET_SCHEDULER_shutdown ();
158 ok = 42;
159}
160
161
162static void
163do_shutdown (void *cls)
164{
165 if (NULL != err_task)
166 {
167 GNUNET_SCHEDULER_cancel (err_task);
168 err_task = NULL;
169 }
157 terminate_peer (&p1); 170 terminate_peer (&p1);
158 terminate_peer (&p2); 171 terminate_peer (&p2);
159 ok = 42;
160} 172}
161 173
162 174
@@ -462,7 +474,9 @@ setup_peer (struct PeerContext *p,
462 binary, 474 binary,
463 "gnunet-service-arm", 475 "gnunet-service-arm",
464 "-c", cfgname, NULL); 476 "-c", cfgname, NULL);
465 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 477 GNUNET_assert (GNUNET_OK ==
478 GNUNET_CONFIGURATION_load (p->cfg,
479 cfgname));
466 p->ats = GNUNET_ATS_connectivity_init (p->cfg); 480 p->ats = GNUNET_ATS_connectivity_init (p->cfg);
467 GNUNET_assert (NULL != p->ats); 481 GNUNET_assert (NULL != p->ats);
468 p->ghh = GNUNET_TRANSPORT_get_hello (p->cfg, 482 p->ghh = GNUNET_TRANSPORT_get_hello (p->cfg,
@@ -486,24 +500,30 @@ run (void *cls,
486 GNUNET_SCHEDULER_add_delayed (TIMEOUT, 500 GNUNET_SCHEDULER_add_delayed (TIMEOUT,
487 &terminate_task_error, 501 &terminate_task_error,
488 NULL); 502 NULL);
489 503 GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
490 GNUNET_assert (NULL != (p1.ch = GNUNET_CORE_connect (p1.cfg, &p1, 504 NULL);
491 &init_notify, 505
492 &connect_notify, 506 GNUNET_assert (NULL !=
493 &disconnect_notify, 507 (p1.ch = GNUNET_CORE_connect (p1.cfg, &p1,
494 &inbound_notify, GNUNET_YES, 508 &init_notify,
495 &outbound_notify, GNUNET_YES, 509 &connect_notify,
496 handlers))); 510 &disconnect_notify,
511 &inbound_notify,
512 GNUNET_YES,
513 &outbound_notify,
514 GNUNET_YES,
515 handlers)));
497} 516}
498 517
499 518
500static void 519static void
501stop_arm (struct PeerContext *p) 520stop_arm (struct PeerContext *p)
502{ 521{
503 if (0 != GNUNET_OS_process_kill (p->arm_proc, GNUNET_TERM_SIG)) 522 if (0 != GNUNET_OS_process_kill (p->arm_proc,
523 GNUNET_TERM_SIG))
504 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, 524 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
505 "kill"); 525 "kill");
506 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) 526 if (GNUNET_OK != GNUNET_OS_process_wait (p->arm_proc))
507 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, 527 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
508 "waitpid"); 528 "waitpid");
509 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 529 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -531,8 +551,12 @@ main (int argc, char *argv1[])
531 GNUNET_log_setup ("test-core-api-reliability", 551 GNUNET_log_setup ("test-core-api-reliability",
532 "WARNING", 552 "WARNING",
533 NULL); 553 NULL);
534 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, 554 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
535 "test-core-api-reliability", "nohelp", options, &run, 555 argv,
556 "test-core-api-reliability",
557 "nohelp",
558 options,
559 &run,
536 &ok); 560 &ok);
537 stop_arm (&p1); 561 stop_arm (&p1);
538 stop_arm (&p2); 562 stop_arm (&p2);