From dfa31ce3c144c6c296f0ca361c67ba6d691cee6f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 3 Jan 2023 12:44:55 +0000 Subject: [PATCH] d/tests, d/run-tests.sh: Copy run-with-display from gtk4 This should make the build-time tests a bit more robust, by using the -noreset option to avoid a race condition (see #981201). --- debian/README.source | 2 +- debian/copyright | 17 +++++++++ debian/run-tests.sh | 2 +- debian/tests/build | 4 ++- debian/tests/installed-tests | 5 +-- debian/tests/python3-gi | 4 ++- debian/tests/run-with-display | 67 +++++++++++++++++++++++++++++++++++ 7 files changed, 95 insertions(+), 6 deletions(-) create mode 100755 debian/tests/run-with-display diff --git a/debian/README.source b/debian/README.source index 55b9bb910e..45305ce0b8 100644 --- a/debian/README.source +++ b/debian/README.source @@ -12,7 +12,7 @@ srcdir=${srcdir}/testsuite/reftests builddir=${builddir}/testsuite/reftests cd "${builddir}" -xvfb-run -a \ +debian/tests/run-with-display x11 \ dbus-run-session -- \ env \ -u XDG_RUNTIME_DIR \ diff --git a/debian/copyright b/debian/copyright index 2a181c69fa..aad40ca787 100644 --- a/debian/copyright +++ b/debian/copyright @@ -92,6 +92,9 @@ Copyright: Copyright (C) 1986, 1987, 1998 The Open Group Copyright 2012 Intel Corporation License: LGPL-2+ and LGPL-2.1+ and Expat +Files: debian/tests/run-with-display +Copyright: 2021 Marco Trevisan +License: GPL-3+ Files: po/* po-properties/* @@ -973,6 +976,20 @@ License: Expat OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +License: GPL-3+ + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + . + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +Comment: + On Debian systems, a copy of the GNU General Public License version 3 + can be found in /usr/share/common-licenses/GPL-3. + License: LGPL-2+ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/debian/run-tests.sh b/debian/run-tests.sh index f9f7603049..71657adf7d 100755 --- a/debian/run-tests.sh +++ b/debian/run-tests.sh @@ -43,7 +43,7 @@ for BACKEND in x11; do GIO_USE_VFS=local \ GIO_USE_VOLUME_MONITOR=unix \ dbus-run-session -- \ - xvfb-run -a \ + debian/tests/run-with-display x11 \ dh_auto_test --builddirectory="$BUILDDIR" -- \ "$@" \ || touch "$test_data/tests-failed" diff --git a/debian/tests/build b/debian/tests/build index 74076a600a..6160b5e73d 100755 --- a/debian/tests/build +++ b/debian/tests/build @@ -9,6 +9,7 @@ set -u set -x export NO_AT_BRIDGE=1 +srcdir="$(pwd)" # Workaround for #1025312 export LIBGL_ALWAYS_SOFTWARE=1 @@ -58,6 +59,7 @@ EOF "${CROSS_COMPILE}gcc" -o gtktest gtktest.c $("${CROSS_COMPILE}pkg-config" --cflags --libs gtk+-3.0) echo "build: OK" [ -x gtktest ] -xvfb-run -a -s "-screen 0 1024x768x24" \ +"${srcdir}"/debian/tests/run-with-display x11 \ +dbus-run-session -- \ ./gtktest echo "run: OK" diff --git a/debian/tests/installed-tests b/debian/tests/installed-tests index 288774d16f..0bc3d3163f 100755 --- a/debian/tests/installed-tests +++ b/debian/tests/installed-tests @@ -19,8 +19,9 @@ tests=$(gnome-desktop-testing-runner -l gtk+ | grep -v '^gtk./a11ystate.test$' | grep -v '^gtk./reftests') -exec dbus-run-session -- \ -xvfb-run -a -s "-screen 0 1024x768x24" \ +exec \ +debian/tests/run-with-display x11 \ +dbus-run-session -- \ gnome-desktop-testing-runner \ --report-directory="$AUTOPKGTEST_ARTIFACTS" \ --tap \ diff --git a/debian/tests/python3-gi b/debian/tests/python3-gi index 71066d82d1..95888bdeb7 100755 --- a/debian/tests/python3-gi +++ b/debian/tests/python3-gi @@ -5,7 +5,9 @@ export NO_AT_BRIDGE=1 # Workaround for #1025312 export LIBGL_ALWAYS_SOFTWARE=1 -xvfb-run -a -s "-screen 0 1024x768x24" \ +exec \ +debian/tests/run-with-display x11 \ +dbus-run-session -- \ python3 < +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# Assume a Debian Policy ยง10.4-compatible shell like dash or bash (with the +# 'local' builtin) +# shellcheck disable=SC2039 + +set -e + +me="$(basename "$0")" + +usage () { + local status="${1-2}" + + if [ "$status" -ne 0 ]; then + exec >&2 + fi + + echo "Usage: $me [wayland|x11] COMMAND [ARGS...]" + exit "$status" +} + +display="$1" + +case "$display" in + wayland) + shift + if [ -z "$XDG_RUNTIME_DIR" ]; then + our_xrd="$(mktemp -d -t xdg-runtime-XXXXXXXX)" + export XDG_RUNTIME_DIR="$our_xrd" + fi + if ! command -v weston > /dev/null; then + echo "No weston available" + exit 1 + fi + socket="wayland-$(od -vAn -N1 -tu1 < /dev/urandom | tr -d '[:space:]')" + weston --backend=headless-backend.so --socket="$socket" --idle-time=0 2>&1 & + weston_pid=$! + trap 'kill $weston_pid; [ -n $our_xrd ] && rm -rfv $our_xrd' EXIT INT + while [ ! -S "$XDG_RUNTIME_DIR/$socket" ]; do + echo "Waiting for socket..." + sleep 1 + done + env -u DISPLAY WAYLAND_DISPLAY="$XDG_RUNTIME_DIR/$socket" "$@" + exit $? + ;; + x11) + shift + if ! command -v xvfb-run > /dev/null; then + echo "No xvfb-run available" + exit 1 + fi + exec env -u WAYLAND_DISPLAY xvfb-run -a -s "-screen 0 1024x768x24 -noreset" "$@" + ;; + -h|--help|help) + usage 0 + ;; + *) + usage 2 + ;; +esac