diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2012-05-08 09:55:55 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-05-08 09:55:55 -0400 |
commit | 550e8f3861b70bd9bb4e4b29fd7247627b5476f3 (patch) | |
tree | 73d880b5a143ab5143e185c821278f371f8a8dbb /tests | |
parent | d56af2787efd05e6f8fe06cc8ad9bad433097213 (diff) |
tests: Add timerfd test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/event-loop-test.c | 32 |
1 files changed, 31 insertions, 1 deletions
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); +} |