[PATCH wayland v2 8/8] tests: Test that one can fetch the protocol error after EPIPE

Jonas Ådahl jadahl at gmail.com
Tue Dec 29 06:28:36 PST 2015


On Tue, Dec 29, 2015 at 11:15:38AM +0000, Daniel Stone wrote:
> Hi Jonas,
> 
> On 29 December 2015 at 02:10, Jonas Ådahl <jadahl at gmail.com> wrote:
> > +       /* The server will not actually destroy the client until it receives
> > +        * input, so send something to trigger the client destruction. */
> > +       callback = wl_display_sync(client->wl_display);
> > +       wl_callback_destroy(callback);
> > +
> > +       /* Sleep some to give the server a chance to react and destroy the
> > +        * client. */
> > +       test_usleep(200000);
> 
> I don't really love the forced 200ms wait here; I'd prefer to do a
> kernel-style early exit from time-bounded wait, e.g.:
> timeout = now() + MS(200);
> while (now() < timeout)
>     check_for_error_using_*(); /* will block until error arrives */
> while (now() < timeout) {
>     if (wl_display_dispatch() == 0) {
>         msleep(10);
>         continue; /* fd still alive; give server time to kill it */
>     }
>     assert(errno == EPIPE);
> }

With the bugs unfixed, this would cause the test case to mostly pass
anyway, since the client will often have passed the flush state before
the server reached the close state. There needs to either be some
out-of-band synchronization mechanism making the client always wait
until the server has closed the socket, or a dumb sleep, which seemed
much easier.


Jonas

> 
> Aside from this and my comment on the roundtrip rewrite, for the series:
> Reviewed-by: Daniel Stone <daniels at collabora.com>
> 
> Cheers,
> Daniel


More information about the wayland-devel mailing list