diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2012-05-08 09:37:34 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-05-08 09:41:37 -0400 |
commit | d56af2787efd05e6f8fe06cc8ad9bad433097213 (patch) | |
tree | d10a61665227fdfec90b5f2641157b3416e586ab /tests | |
parent | 3e7bd7362b6841d1862de5af7b71f138b6d70a5d (diff) |
tests: Add signal test case
Doesn't necessarily catch the signalfd bug just fixed, since that only
triggers when an uninitialized int is negative.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/event-loop-test.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/event-loop-test.c b/tests/event-loop-test.c index 70818b2..6923721 100644 --- a/tests/event-loop-test.c +++ b/tests/event-loop-test.c @@ -23,6 +23,7 @@ #include <stdlib.h> #include <assert.h> #include <unistd.h> +#include <signal.h> #include "../src/wayland-server.h" #include "test-runner.h" @@ -126,3 +127,30 @@ TEST(free_source_with_data) assert(close(context.p2[0]) == 0); assert(close(context.p2[1]) == 0); } + +static int +signal_callback(int signal_number, void *data) +{ + int *got_it = data; + + assert(signal_number == SIGUSR1); + *got_it = 1; + + return 1; +} + +TEST(signal_test) +{ + struct wl_event_loop *loop = wl_event_loop_create(); + struct wl_event_source *source; + int got_it = 0; + + source = wl_event_loop_add_signal(loop, SIGUSR1, + signal_callback, &got_it); + kill(getpid(), SIGUSR1); + wl_event_loop_dispatch(loop, 0); + assert(got_it); + + wl_event_source_remove(source); + wl_event_loop_destroy(loop); +} |