From bcc02dc4019b6d4afd744bc06e6764687a7af8b5 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 14 Feb 2016 12:42:14 +0100 Subject: test: use milliseconds for re_main_timeout value --- test/call.c | 6 +++--- test/test.c | 13 ++++++++++--- test/test.h | 2 +- test/ua.c | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/call.c b/test/call.c index 7ca1815..893b25e 100644 --- a/test/call.c +++ b/test/call.c @@ -181,7 +181,7 @@ int test_call_answer(void) TEST_ERR(err); /* run main-loop with timeout, wait for events */ - err = re_main_timeout(5); + err = re_main_timeout(5000); TEST_ERR(err); TEST_ERR(fix.err); @@ -215,7 +215,7 @@ int test_call_reject(void) TEST_ERR(err); /* run main-loop with timeout, wait for events */ - err = re_main_timeout(5); + err = re_main_timeout(5000); TEST_ERR(err); TEST_ERR(fix.err); @@ -248,7 +248,7 @@ int test_call_af_mismatch(void) TEST_ERR(err); /* run main-loop with timeout, wait for events */ - err = re_main_timeout(5); + err = re_main_timeout(5000); TEST_ERR(err); TEST_ERR(fix.err); diff --git a/test/test.c b/test/test.c index ec6f6fb..59e1cd1 100644 --- a/test/test.c +++ b/test/test.c @@ -15,15 +15,22 @@ static void timeout_handler(void *arg) } -int re_main_timeout(uint32_t timeout) +static void signal_handler(int sig) +{ + re_fprintf(stderr, "test interrupted by signal %d\n", sig); + re_cancel(); +} + + +int re_main_timeout(uint32_t timeout_ms) { struct tmr tmr; int err = 0; tmr_init(&tmr); - tmr_start(&tmr, timeout * 1000, timeout_handler, &err); - re_main(NULL); + tmr_start(&tmr, timeout_ms, timeout_handler, &err); + re_main(signal_handler); tmr_cancel(&tmr); return err; diff --git a/test/test.h b/test/test.h index 8aedc00..fc90989 100644 --- a/test/test.h +++ b/test/test.h @@ -46,7 +46,7 @@ /* helpers */ -int re_main_timeout(uint32_t timeout); +int re_main_timeout(uint32_t timeout_ms); #ifdef USE_TLS diff --git a/test/ua.c b/test/ua.c index e5cc382..c039705 100644 --- a/test/ua.c +++ b/test/ua.c @@ -75,7 +75,7 @@ static int reg(enum sip_transp tp) goto out; /* run main-loop with timeout, wait for events */ - err = re_main_timeout(5); + err = re_main_timeout(5000); if (err) goto out; -- cgit v1.2.3