[PATCH v2 3/3] tests: Add free-without-remove test

Derek Foreman derekf at osg.samsung.com
Mon Apr 16 20:01:00 UTC 2018


From: Markus Ongyerth <wl at ongy.net>

[Derek Foreman <derekf at osg.samsung.com> moved this into resources-test]

---

I moved this behind Markus' back, so let's not go landing it if he's
not ok with that change.  I think it's a great illustration of the
problem and would like to see it land though.

 tests/resources-test.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tests/resources-test.c b/tests/resources-test.c
index 76c9eb8..fa6ba2b 100644
--- a/tests/resources-test.c
+++ b/tests/resources-test.c
@@ -182,3 +182,27 @@ TEST(create_resource_with_same_id)
 	wl_display_destroy(display);
 	close(s[1]);
 }
+
+static void
+display_destroy_notify(struct wl_listener *l, void *data)
+{
+	l->link.prev = l->link.next = NULL;
+}
+
+TEST(free_without_remove)
+{
+	struct wl_display *display;
+	struct wl_listener a, b;
+
+	display = wl_display_create();
+	a.notify = display_destroy_notify;
+	b.notify = display_destroy_notify;
+
+	wl_display_add_destroy_listener(display, &a);
+	wl_display_add_destroy_listener(display, &b);
+
+	wl_display_destroy(display);
+
+	assert(a.link.next == a.link.prev && a.link.next == NULL);
+	assert(b.link.next == b.link.prev && b.link.next == NULL);
+}
-- 
2.14.3



More information about the wayland-devel mailing list