[PATCH wayland 4/5] client-test: test posting no-mem error on client destruction
Pekka Paalanen
ppaalanen at gmail.com
Mon May 16 10:52:24 UTC 2016
On Fri, 13 May 2016 15:01:21 +0200
Marek Chalupa <mchqwerty at gmail.com> wrote:
> while client is being destroyed, it destroys all its resources.
> Destroy handlers are called for the resources and if some
> destroy handler post no memory error, we get crash, because
> the display resource is NULL (it is destroyed as a first resource)
>
> Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
> ---
> tests/client-test.c | 37 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 37 insertions(+)
>
> diff --git a/tests/client-test.c b/tests/client-test.c
> index 2e332f8..cb08e39 100644
> --- a/tests/client-test.c
> +++ b/tests/client-test.c
> @@ -89,3 +89,40 @@ TEST(client_destroy_listener)
> wl_display_destroy(display);
> }
>
> +static struct wl_listener seat_destroy_listener;
> +
> +static void
> +seat_destroy_post_no_memory(struct wl_listener *l, void *data)
> +{
> + struct wl_resource *resource = data;
Add an empty line.
> + wl_client_post_no_memory(wl_resource_get_client(resource));
This tests wl_client_post_no_memory(), could it not test
wl_resource_post_no_memory() at the same time?
> +}
> +
> +TEST(client_post_nomem_on_destruction)
> +{
> + struct wl_display *display;
> + struct wl_client *client;
> + struct wl_resource *resource;
> + int s[2];
> +
> + assert(socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, s) == 0);
> + display = wl_display_create();
> + assert(display);
> + client = wl_client_create(display, s[0]);
> + assert(client);
> +
> + resource = wl_resource_create(client, &wl_seat_interface,
> + wl_seat_interface.version, 0);
> + assert(resource);
> +
> + seat_destroy_listener.notify = seat_destroy_post_no_memory;
> + wl_resource_add_destroy_listener(resource, &seat_destroy_listener);
> +
> + wl_client_destroy(client);
> +
> + close(s[0]);
> + close(s[1]);
> +
> + wl_display_destroy(display);
> +}
> +
Anyway
Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Thanks,
pq
-------------- 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/20160516/dda88fd0/attachment.sig>
More information about the wayland-devel
mailing list