test/event-loop: Check readable state on a pipe
authorQuentin Glidic <sardemff7+git@sardemff7.net>
Sun, 6 Jan 2013 14:46:00 +0000 (15:46 +0100)
committerKristian Høgsberg <krh@bitplanet.net>
Fri, 11 Jan 2013 20:12:45 +0000 (15:12 -0500)
When redirecting stdout to a non-readable file makes the test fail as a
false negative

tests/event-loop-test.c

index e630cde..2f3dcd4 100644 (file)
@@ -43,14 +43,19 @@ TEST(event_loop_post_dispatch_check)
        struct wl_event_loop *loop = wl_event_loop_create();
        struct wl_event_source *source;
        int dispatch_ran = 0;
+       int p[2];
 
-       source = wl_event_loop_add_fd(loop, 1, WL_EVENT_READABLE,
+       assert(pipe(p) == 0);
+
+       source = wl_event_loop_add_fd(loop, p[0], WL_EVENT_READABLE,
                                      fd_dispatch, &dispatch_ran);
        wl_event_source_check(source);
 
        wl_event_loop_dispatch(loop, 0);
        assert(dispatch_ran);
 
+       assert(close(p[0]) == 0);
+       assert(close(p[1]) == 0);
        wl_event_source_remove(source);
        wl_event_loop_destroy(loop);
 }