[PATCH wayland] tests: add test for receiving an error on destroyed object

Pekka Paalanen ppaalanen at gmail.com
Fri Feb 26 09:58:23 UTC 2016


On Mon, 22 Feb 2016 13:25:33 -0800
Bryce Harrington <bryce at osg.samsung.com> wrote:

> On Mon, Feb 22, 2016 at 02:37:00PM +0100, Marek Chalupa wrote:
> > test if receiving an error on already destroyed object won't
> > do any harm
> > 
> > Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>  
> 
> Confirmed that this test catches the error that is fixed by
> https://patchwork.freedesktop.org/patch/74577/, and that the test passes
> when that patch is in place.
> 
> Reviewed-by: Bryce Harrington <bryce at osg.samsung.com>
> Tested-by: Bryce Harrington <bryce at osg.samsung.com>

Nice! Pushed:
   cde251a..5646236  master -> master


Thanks,
pq

> > ---
> >  tests/display-test.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 50 insertions(+)
> > 
> > diff --git a/tests/display-test.c b/tests/display-test.c
> > index 1a6c345..f9f8160 100644
> > --- a/tests/display-test.c
> > +++ b/tests/display-test.c
> > @@ -876,3 +876,53 @@ TEST(versions)
> >  
> >  	display_destroy(d);
> >  }
> > +
> > +static void
> > +check_error_on_destroyed_object(void *data)
> > +{
> > +	struct client *c;
> > +	struct wl_seat *seat;
> > +	uint32_t id;
> > +	const struct wl_interface *intf;
> > +
> > +	c = client_connect();
> > +	seat = client_get_seat(c);
> > +
> > +	/* destroy the seat proxy. The display won't know
> > +	 * about it yet, so it will post the error as usual */
> > +	wl_proxy_destroy((struct wl_proxy *) seat);
> > +
> > +	/* let display post the error. The error will
> > +	 * be caught in stop_display while dispatching */
> > +	assert(stop_display(c, 1) == -1);
> > +
> > +	/* check the returned error. Since the object was destroyed,
> > +	 * we don't know the interface and id */
> > +	assert(wl_display_get_error(c->wl_display) == EPROTO);
> > +	assert(wl_display_get_protocol_error(c->wl_display, &intf, &id) == 23);
> > +	assert(intf == NULL);
> > +	assert(id == 0);
> > +
> > +	client_disconnect_nocheck(c);
> > +}
> > +
> > +TEST(error_on_destroyed_object)
> > +{
> > +	struct client_info *cl;
> > +	struct display *d = display_create();
> > +
> > +	wl_global_create(d->wl_display, &wl_seat_interface,
> > +			 1, d, bind_seat);
> > +
> > +	cl = client_create_noarg(d, check_error_on_destroyed_object);
> > +	display_run(d);
> > +
> > +	/* did client bind to the seat? */
> > +	assert(cl->data);
> > +
> > +	/* post error on the destroyed object */
> > +	wl_resource_post_error((struct wl_resource *) cl->data,
> > +			       23, "Dummy error");
> > +	display_resume(d);
> > +	display_destroy(d);
> > +}
> > -- 
> > 2.5.0
> > 
> > _______________________________________________
> > wayland-devel mailing list
> > wayland-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/wayland-devel  
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20160226/e6bd708c/attachment-0001.sig>


More information about the wayland-devel mailing list