[PATCH wayland 4/5] client-test: test posting no-mem error on client destruction
Marek Chalupa
mchqwerty at gmail.com
Fri May 13 13:01:21 UTC 2016
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;
+ wl_client_post_no_memory(wl_resource_get_client(resource));
+}
+
+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);
+}
+
--
2.5.5
More information about the wayland-devel
mailing list