diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-05-06 22:01:02 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-05-06 22:01:02 +0200 |
commit | ce1dcfe1ed4d3ae8c0a498ebc0bc2f4a357a9c1d (patch) | |
tree | 35c59f62a53b12ed4f4be08ccf55c146d85ecfee | |
parent | 95d338f6ccfe7e7e5da160e1010968a9918c1c23 (diff) | |
download | exchange-ce1dcfe1ed4d3ae8c0a498ebc0bc2f4a357a9c1d.tar.xz |
add timeout logic to aggregator test
-rw-r--r-- | src/exchange/test_taler_exchange_aggregator.c | 29 |
1 files changed, 29 insertions, 0 deletions
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 @@ -194,6 +194,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(). */ static int result; @@ -260,8 +265,29 @@ interpreter (void *cls); * @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. + * + * @param cls closure, NULL if we need to self-restart + */ +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) |