aboutsummaryrefslogtreecommitdiffstats
path: root/tests/display-test.c
diff options
context:
space:
mode:
authorChristopher James Halse Rogers <christopher.halse.rogers@canonical.com>2018-11-20 18:02:50 +1100
committerPekka Paalanen <pekka.paalanen@collabora.com>2019-01-29 15:58:19 +0200
commitd325140289d5767cdef5fc31f7d89b451c1066aa (patch)
treeef2bf07585035be33022425087cd6d265d25c959 /tests/display-test.c
parentserver: Split out varargs version of wl_resource_post_error. (diff)
downloadwayland-d325140289d5767cdef5fc31f7d89b451c1066aa.tar
wayland-d325140289d5767cdef5fc31f7d89b451c1066aa.tar.gz
wayland-d325140289d5767cdef5fc31f7d89b451c1066aa.tar.bz2
wayland-d325140289d5767cdef5fc31f7d89b451c1066aa.tar.lz
wayland-d325140289d5767cdef5fc31f7d89b451c1066aa.tar.xz
wayland-d325140289d5767cdef5fc31f7d89b451c1066aa.tar.zst
wayland-d325140289d5767cdef5fc31f7d89b451c1066aa.zip
proto, server: Add internal server error message. (v2)
Many languages such as C++ or Rust have an unwinding error-reporting mechanism. Code in these languages can (and must!) wrap request handling callbacks in unwind guards to avoid undefined behaviour. As a consequence such code will detect internal server errors, but have no way to communicate such failures to the client. This adds a WL_DISPLAY_ERROR_IMPLEMENTATION error to wl_display so that such code can notify (and disconnect) clients which hit internal bugs. While servers can currently abuse other wl_display errors for the same effect, adding an explicit error code allows clients to tell the difference between errors which are their fault and errors which are the server's fault. This is particularly interesting for automated bug reporting. v2: Rename error from "internal" to "implementation", in sympathy with X11's BadImplementation error. Add more justification in the commit message. Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Diffstat (limited to 'tests/display-test.c')
-rw-r--r--tests/display-test.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/display-test.c b/tests/display-test.c
index 9b49a0e..6d98cc7 100644
--- a/tests/display-test.c
+++ b/tests/display-test.c
@@ -420,6 +420,46 @@ TEST(post_nomem_tst)
}
static void
+post_implementation_error_main(void)
+{
+ struct client *c = client_connect();
+ struct wl_seat *seat = client_get_seat(c);
+ uint32_t object_id, protocol_error;
+ const struct wl_interface *interface;
+
+ assert(stop_display(c, 1) == -1);
+ int err = wl_display_get_error(c->wl_display);
+ fprintf(stderr, "Err is %i\n", err);
+ assert(err == EPROTO);
+ protocol_error = wl_display_get_protocol_error(c->wl_display,
+ &interface,
+ &object_id);
+ assert(protocol_error == WL_DISPLAY_ERROR_IMPLEMENTATION);
+ assert(interface == &wl_display_interface);
+
+ wl_proxy_destroy((struct wl_proxy *) seat);
+ client_disconnect_nocheck(c);
+}
+
+TEST(post_internal_error_tst)
+{
+ struct display *d = display_create();
+ struct client_info *cl;
+
+ wl_global_create(d->wl_display, &wl_seat_interface,
+ 1, d, bind_seat);
+
+ cl = client_create_noarg(d, post_implementation_error_main);
+ display_run(d);
+
+ wl_client_post_implementation_error(cl->wl_client, "Error %i", 20);
+
+ display_resume(d);
+
+ display_destroy(d);
+}
+
+static void
register_reading(struct wl_display *display)
{
while(wl_display_prepare_read(display) != 0 && errno == EAGAIN)