aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2013-05-24 11:22:41 +0200
committerPablo Neira Ayuso <pablo@gnumonks.org>2013-05-24 11:22:41 +0200
commit9d6d126c230f480510622dbb1a0f13cdef640146 (patch)
treed285b6997e145fff51d8143c0fc2c64e9bb1d429 /tests
parentb1f92341c359fb173dc2d28a66ae3a86a7a94a99 (diff)
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/osmux/osmux_test.c14
1 files changed, 14 insertions, 0 deletions
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)