From 550e8f3861b70bd9bb4e4b29fd7247627b5476f3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 8 May 2012 09:55:55 -0400 Subject: [PATCH] tests: Add timerfd test --- tests/event-loop-test.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/event-loop-test.c b/tests/event-loop-test.c index 6923721..b1479f2 100644 --- a/tests/event-loop-test.c +++ b/tests/event-loop-test.c @@ -139,7 +139,7 @@ signal_callback(int signal_number, void *data) return 1; } -TEST(signal_test) +TEST(event_loop_signal) { struct wl_event_loop *loop = wl_event_loop_create(); struct wl_event_source *source; @@ -147,6 +147,8 @@ TEST(signal_test) source = wl_event_loop_add_signal(loop, SIGUSR1, signal_callback, &got_it); + wl_event_loop_dispatch(loop, 0); + assert(!got_it); kill(getpid(), SIGUSR1); wl_event_loop_dispatch(loop, 0); assert(got_it); @@ -154,3 +156,31 @@ TEST(signal_test) wl_event_source_remove(source); wl_event_loop_destroy(loop); } + + +static int +timer_callback(void *data) +{ + int *got_it = data; + + *got_it = 1; + + return 1; +} + +TEST(event_loop_timer) +{ + struct wl_event_loop *loop = wl_event_loop_create(); + struct wl_event_source *source; + int got_it = 0; + + source = wl_event_loop_add_timer(loop, timer_callback, &got_it); + wl_event_source_timer_update(source, 10); + wl_event_loop_dispatch(loop, 0); + assert(!got_it); + wl_event_loop_dispatch(loop, 20); + assert(got_it); + + wl_event_source_remove(source); + wl_event_loop_destroy(loop); +} -- 2.7.4