From 9d6d126c230f480510622dbb1a0f13cdef640146 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 24 May 2013 11:22:41 +0200 Subject: tests: osmux_test: deadline after 10 seconds If the test takes longer than 10 seconds (it barely takes less than a second according to `time'), bail out and report an error. --- tests/osmux/osmux_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/osmux/osmux_test.c') diff --git a/tests/osmux/osmux_test.c b/tests/osmux/osmux_test.c index 3f01d6e..4036f2d 100644 --- a/tests/osmux/osmux_test.c +++ b/tests/osmux/osmux_test.c @@ -106,6 +106,12 @@ struct osmux_in_handle h_input = { .deliver = osmux_deliver, }; +static void sigalarm_handler(int foo) +{ + printf("FAIL: test did not run successfully\n"); + exit(EXIT_FAILURE); +} + int main(void) { struct msgb *msg; @@ -114,6 +120,11 @@ int main(void) uint16_t seq; int i, j; + if (signal(SIGALRM, sigalarm_handler) == SIG_ERR) { + perror("signal"); + exit(EXIT_FAILURE); + } + /* This test doesn't use it, but osmux requires it internally. */ osmo_init_logging(&osmux_test_log_info); log_set_log_level(osmo_stderr_target, LOGL_DEBUG); @@ -121,6 +132,9 @@ int main(void) osmux_xfrm_input_init(&h_input); osmux_xfrm_output_init(&h_output, 0x7000000); + /* If the test takes longer than 10 seconds, abort it */ + alarm(10); + for (i=1; i<64; i++) { msg = msgb_alloc(1500, "test"); if (!msg) -- cgit v1.2.3