[PATCH] test/event-loop: Check readable state on 0, not 1

Kristian Høgsberg hoegsberg at gmail.com
Mon Jan 7 14:45:05 PST 2013


On Sun, Jan 06, 2013 at 03:58:59PM +0100, Quentin Glidic wrote:
> When redirecting stdout to a non-readable file makes the test fail as a
> false negative

Hi Quentin,

Yes, that's cool.  Normally stdout, stdin and stderr all refer to the
same PTY which is both readable and writable, but when we redirect
output we poll the write end of a pipe for readable.

I'd like a different fix though - as it is here, we might end up with
data on stdin, which means we call fd_dispatch because the fd is
readable, but the test here tests that we call the handler even though
there's no data on the fd (that's what 'checked' refer to).  So
perhaps we could create a pipe instead and poll the read end for
readable (and remember to close both ends of the pipe after the test,
of course).

Kristian

> ---
>  tests/event-loop-test.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/event-loop-test.c b/tests/event-loop-test.c
> index e630cde..6acee65 100644
> --- a/tests/event-loop-test.c
> +++ b/tests/event-loop-test.c
> @@ -44,7 +44,7 @@ TEST(event_loop_post_dispatch_check)
>  	struct wl_event_source *source;
>  	int dispatch_ran = 0;
>  
> -	source = wl_event_loop_add_fd(loop, 1, WL_EVENT_READABLE,
> +	source = wl_event_loop_add_fd(loop, 0, WL_EVENT_READABLE,
>  				      fd_dispatch, &dispatch_ran);
>  	wl_event_source_check(source);
>  
> -- 
> 1.8.0.3
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list