From e58203c1e2c00184cb2ba265e6d19bde84918c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Tue, 26 Sep 2023 16:39:27 +0200 Subject: [PATCH] test: Kill weston whenever shell exits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This script runs with -e, so if the timeout command returns a non-0 exit status (meaning the while loop timed out), the script exits immediately as well. This would leave weston running in the background, which resulted in meson waiting for weston to terminate until hitting meson's own timeout. Instead, explicitly kill weston whenever the shell exits. This results in meson recording the test as failed immediately. As a bonus, we can drop the special handling around run-piglit.sh. v2: * Use trap (José Expósito) v3: * Explicitly use bash, and document a bashism we rely on (Olivier Fourdan) --- test/scripts/xwayland-piglit.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/scripts/xwayland-piglit.sh b/test/scripts/xwayland-piglit.sh index 16cf7e2a0..42209e8ab 100755 --- a/test/scripts/xwayland-piglit.sh +++ b/test/scripts/xwayland-piglit.sh @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/bash -e # this times out on Travis, because the tests take too long. if test "x$TRAVIS_BUILD_DIR" != "x"; then @@ -17,6 +17,11 @@ weston --no-config --backend=headless-backend.so --socket=wayland-$$ & WESTON_PID=$! export WAYLAND_DISPLAY=wayland-$$ +# Need to kill weston before exiting, or meson will time out waiting for it to terminate +# We rely on bash's behaviour, which executes the EXIT trap handler even if the shell is +# terminated due to receiving a signal +trap 'kill $WESTON_PID' EXIT + # Wait for weston to initialize before starting Xwayland timeout --preserve-status 5s bash -c "while ! $XSERVER_BUILDDIR/hw/xwayland/Xwayland -pogo -displayfd 1 &>/dev/null; do sleep 1; done" @@ -38,10 +43,4 @@ PIGLIT_ARGS="$PIGLIT_ARGS -x xsetfontpath@2" export PIGLIT_ARGS -# Do not let run-piglit.sh exit status terminate this script prematurely -set +e $XSERVER_DIR/test/scripts/run-piglit.sh -PIGLIT_STATUS=$? - -kill $WESTON_PID -exit $PIGLIT_STATUS