[PATCH 3/3] tests: add one more test for event-loop signal source
Marek Chalupa
mchqwerty at gmail.com
Tue Aug 12 02:35:07 PDT 2014
Test if when we get a signal, all signal sources for that signal
get dispatched.
Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
---
tests/event-loop-test.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/tests/event-loop-test.c b/tests/event-loop-test.c
index e327a66..1709a1a 100644
--- a/tests/event-loop-test.c
+++ b/tests/event-loop-test.c
@@ -173,6 +173,44 @@ TEST(event_loop_signal)
wl_event_loop_destroy(loop);
}
+TEST(event_loop_multiple_same_signals)
+{
+ struct wl_event_loop *loop = wl_event_loop_create();
+ struct wl_event_source *s1, *s2;
+ int calls_no = 0;
+ int i;
+
+ s1 = wl_event_loop_add_signal(loop, SIGUSR1,
+ signal_callback, &calls_no);
+ assert(s1);
+
+ s2 = wl_event_loop_add_signal(loop, SIGUSR1,
+ signal_callback, &calls_no);
+ assert(s2);
+
+ assert(wl_event_loop_dispatch(loop, 0) == 0);
+ assert(!calls_no);
+
+ /* Try it more times */
+ for (i = 0; i < 5; ++i) {
+ calls_no = 0;
+ kill(getpid(), SIGUSR1);
+ assert(wl_event_loop_dispatch(loop, 0) == 0);
+ assert(calls_no == 2);
+ }
+
+ wl_event_source_remove(s1);
+
+ /* Try it again with one source */
+ calls_no = 0;
+ kill(getpid(), SIGUSR1);
+ assert(wl_event_loop_dispatch(loop, 0) == 0);
+ assert(calls_no == 1);
+
+ wl_event_source_remove(s2);
+
+ wl_event_loop_destroy(loop);
+}
static int
timer_callback(void *data)
--
2.0.4
More information about the wayland-devel
mailing list