aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-compositor.c
diff options
context:
space:
mode:
authorAlexandros Frantzis <alexandros.frantzis@collabora.com>2022-11-15 11:21:37 +0200
committerSimon Ser <contact@emersion.fr>2023-02-28 11:22:04 +0000
commite09010f470b28353e29a673ad76e813a92e61a1f (patch)
tree7c1140cb21823eea6b0b64b791146b4ac54f1b87 /tests/test-compositor.c
parentclient: Warn when a queue is destroyed with attached proxies (diff)
downloadwayland-e09010f470b28353e29a673ad76e813a92e61a1f.tar
wayland-e09010f470b28353e29a673ad76e813a92e61a1f.tar.gz
wayland-e09010f470b28353e29a673ad76e813a92e61a1f.tar.bz2
wayland-e09010f470b28353e29a673ad76e813a92e61a1f.tar.lz
wayland-e09010f470b28353e29a673ad76e813a92e61a1f.tar.xz
wayland-e09010f470b28353e29a673ad76e813a92e61a1f.tar.zst
wayland-e09010f470b28353e29a673ad76e813a92e61a1f.zip
tests: Support tests that check for client failure
Add the display_destroy_expect_signal() function to check that test clients exit due to a particular signal. This is useful for checking that clients fail in an expected way. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Diffstat (limited to 'tests/test-compositor.c')
-rw-r--r--tests/test-compositor.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/tests/test-compositor.c b/tests/test-compositor.c
index 587bc2b..49d76d6 100644
--- a/tests/test-compositor.c
+++ b/tests/test-compositor.c
@@ -114,7 +114,7 @@ handle_client_destroy(void *data)
case CLD_DUMPED:
fprintf(stderr, "Client '%s' was killed by signal %d\n",
ci->name, status.si_status);
- ci->exit_code = status.si_status;
+ ci->kill_code = status.si_status;
break;
case CLD_EXITED:
if (status.si_status != EXIT_SUCCESS)
@@ -425,8 +425,10 @@ display_resume(struct display *d)
wl_display_run(d->wl_display);
}
+/* If signum is 0, expect a successful client exit, otherwise
+ * expect the client to have been killed by that signal. */
void
-display_destroy(struct display *d)
+display_destroy_expect_signal(struct display *d, int signum)
{
struct client_info *cl, *next;
int failed = 0;
@@ -437,7 +439,15 @@ display_destroy(struct display *d)
wl_list_for_each_safe(cl, next, &d->clients, link) {
assert(cl->wl_client == NULL);
- if (cl->exit_code != 0) {
+ if (signum != 0 && cl->kill_code != signum) {
+ ++failed;
+ fprintf(stderr,
+ "Client '%s' failed, expecting signal %d, "
+ "got %d\n",
+ cl->name, signum, cl->kill_code);
+ }
+ else if (signum == 0 &&
+ (cl->kill_code != 0 || cl->exit_code != 0)) {
++failed;
fprintf(stderr, "Client '%s' failed\n", cl->name);
}
@@ -457,6 +467,12 @@ display_destroy(struct display *d)
}
}
+void
+display_destroy(struct display *d)
+{
+ display_destroy_expect_signal(d, 0);
+}
+
/*
* --- Client helper functions ---
*/