From ce1dcfe1ed4d3ae8c0a498ebc0bc2f4a357a9c1d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 6 May 2016 22:01:02 +0200 Subject: add timeout logic to aggregator test --- src/exchange/test_taler_exchange_aggregator.c | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src') diff --git a/src/exchange/test_taler_exchange_aggregator.c b/src/exchange/test_taler_exchange_aggregator.c index d38d07906..5df34a9c2 100644 --- a/src/exchange/test_taler_exchange_aggregator.c +++ b/src/exchange/test_taler_exchange_aggregator.c @@ -193,6 +193,11 @@ static struct GNUNET_DISK_PipeHandle *sigpipe; */ static struct GNUNET_SCHEDULER_Task *child_death_task; +/** + * ID of task called whenever we time out. + */ +static struct GNUNET_SCHEDULER_Task *timeout_task; + /** * Return value from main(). */ @@ -254,6 +259,22 @@ static void interpreter (void *cls); +/** + * Task triggered whenever we are to shutdown. + * + * @param cls closure, NULL if we need to self-restart + */ +static void +timeout_action (void *cls) +{ + timeout_task = NULL; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Test failed: timeout\n"); + result = 2; + GNUNET_SCHEDULER_shutdown (); +} + + /** * Task triggered whenever we are to shutdown. * @@ -262,6 +283,11 @@ interpreter (void *cls); static void shutdown_action (void *cls) { + if (NULL != timeout_task) + { + GNUNET_SCHEDULER_cancel (timeout_task); + timeout_task = NULL; + } if (NULL != int_task) { GNUNET_SCHEDULER_cancel (int_task); @@ -1143,6 +1169,9 @@ run (void *cls) &maint_child_death, NULL); GNUNET_SCHEDULER_add_shutdown (&shutdown_action, NULL); + timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, + &timeout_action, + NULL); result = 1; /* test failed for undefined reason */ fb = FAKEBANK_start (8082); if (NULL == fb) -- cgit v1.2.3