From e94eab9cd53e43a01d6693612c54aa076bce62ff Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 22 Jun 2026 13:34:13 +0200 Subject: [PATCH] .github: use go-x11proto test suite in the CI Signed-off-by: Enrico Weigelt, metux IT consult --- .github/scripts/conf.sh | 1 + .github/scripts/ubuntu/install-pkg.sh | 1 + .github/scripts/ubuntu/install-prereq.sh | 2 + .../ubuntu/run-xserver-build-and-test.sh | 1 + .github/workflows/build-xserver.yml | 3 + test/meson.build | 14 +++ test/scripts/run-xts-go-xephyr.sh | 105 ++++++++++++++++++ test/scripts/run-xts-go.sh | 49 ++++++++ 8 files changed, 176 insertions(+) create mode 100755 test/scripts/run-xts-go-xephyr.sh create mode 100755 test/scripts/run-xts-go.sh diff --git a/.github/scripts/conf.sh b/.github/scripts/conf.sh index 937f709c77..8fa5b27d2b 100644 --- a/.github/scripts/conf.sh +++ b/.github/scripts/conf.sh @@ -13,6 +13,7 @@ export PKG_CONFIG_PATH="$X11_PREFIX/lib/x86_64-linux-gnu/pkgconfig:$X11_PREFIX/l export PKG_PIGLIT_REF=59111996534f875ca88bce51f21fa2e6564895da export PKG_XTS_REF=6cf94400a09abecd6b86e4eb6441741acecd51f6 +export PKG_GOXPROTO_REF="${GOXPROTO_REF:-v0.0.3}" export PKG_RENDERCHECK_REF=rendercheck-1.6 export PKG_LIBDRM_REF=libdrm-2.4.121 export PKG_LIBXCVT_REF=libxcvt-0.1.0 diff --git a/.github/scripts/ubuntu/install-pkg.sh b/.github/scripts/ubuntu/install-pkg.sh index 1ed358e108..abdfe4f76b 100755 --- a/.github/scripts/ubuntu/install-pkg.sh +++ b/.github/scripts/ubuntu/install-pkg.sh @@ -92,4 +92,5 @@ apt-get install -y \ python3-mako \ libxcvt-dev \ git \ + golang-go \ sudo diff --git a/.github/scripts/ubuntu/install-prereq.sh b/.github/scripts/ubuntu/install-prereq.sh index 1d55cb86c1..069ecd60a4 100755 --- a/.github/scripts/ubuntu/install-prereq.sh +++ b/.github/scripts/ubuntu/install-prereq.sh @@ -18,3 +18,5 @@ build_meson xorgproto $(fdo_mirror xorgproto) $PKG_ build_ac_xts xts $(fdo_mirror xts) $PKG_XTS_REF clone_source piglit $(fdo_mirror piglit) $PKG_PIGLIT_REF + +clone_source goxproto $(xl_mirror go-x11proto) $PKG_GOXPROTO_REF diff --git a/.github/scripts/ubuntu/run-xserver-build-and-test.sh b/.github/scripts/ubuntu/run-xserver-build-and-test.sh index 0a8241a7e0..d1536aeff3 100755 --- a/.github/scripts/ubuntu/run-xserver-build-and-test.sh +++ b/.github/scripts/ubuntu/run-xserver-build-and-test.sh @@ -17,6 +17,7 @@ echo "=== MESON_BUILDDIR=$MESON_BUILDDIR" export XTEST_DIR="$X11_BUILD_DIR/xts" export PIGLIT_DIR="$X11_BUILD_DIR/piglit" +export GOXPROTO_DIR="$X11_BUILD_DIR/goxproto" .github/scripts/ubuntu/install-prereq.sh diff --git a/.github/workflows/build-xserver.yml b/.github/workflows/build-xserver.yml index 6afc23e64c..50b17c41d4 100644 --- a/.github/workflows/build-xserver.yml +++ b/.github/workflows/build-xserver.yml @@ -7,6 +7,7 @@ env: MESON_BUILDDIR: "__BUILD" X11_PREFIX: /home/runner/x11 X11_BUILD_DIR: /home/runner/work/xserver/xserver/WORK/sources/3rdparty + GOXPROTO_REF: v0.0.3 on: push: @@ -64,6 +65,7 @@ jobs: ${{ env.X11_PREFIX }} ${{ env.X11_BUILD_DIR }}/xts ${{ env.X11_BUILD_DIR }}/piglit + ${{ env.X11_BUILD_DIR }}/goxproto key: ${{ runner.name }}-x11-deps-${{ hashFiles('.github/scripts/ubuntu/install-prereq.sh') }} restore-keys: ${{ runner.name }}-x11-deps- @@ -105,6 +107,7 @@ jobs: ${{ env.X11_PREFIX }} ${{ env.X11_BUILD_DIR }}/xts ${{ env.X11_BUILD_DIR }}/piglit + ${{ env.X11_BUILD_DIR }}/goxproto key: ${{ runner.name }}-x11-deps-${{ hashFiles('.github/scripts/ubuntu/install-prereq.sh') }} restore-keys: ${{ runner.name }}-x11-deps- diff --git a/test/meson.build b/test/meson.build index f9a3de9c92..1fa8ee23b0 100644 --- a/test/meson.build +++ b/test/meson.build @@ -94,6 +94,13 @@ if get_option('xvfb') suite: 'xvfb' ) + test('go-xts', + find_program('scripts/run-xts-go.sh'), + env: piglit_env, + timeout: 300, + suite: 'xvfb' + ) + if rendercheck.found() foreach rctest: rendercheck_tests test(rctest[0], @@ -127,6 +134,13 @@ if get_option('xvfb') timeout: 1200, suite: 'xephyr-glamor' + testsuite, ) + + test('go-xts', + find_program('scripts/run-xts-go-xephyr.sh'), + env: piglit_env, + timeout: 300, + suite: 'xephyr-glamor' + testsuite, + ) endforeach test_parameters = [ [rendercheck_tests, '', piglit_env, '', false], diff --git a/test/scripts/run-xts-go-xephyr.sh b/test/scripts/run-xts-go-xephyr.sh new file mode 100755 index 0000000000..4f0369281a --- /dev/null +++ b/test/scripts/run-xts-go-xephyr.sh @@ -0,0 +1,105 @@ +#!/bin/sh + +# Run the go-x11proto XTS (wire-protocol round-trip) tests against a freshly +# built Xephyr. Since the test environment is headless, we start an Xvfb first +# to host the Xephyr, then let the go-x11proto test connect to Xephyr via +# $DISPLAY. +# +# The test is skipped (exit 77) when GOXPROTO_DIR is unset or Go isn't found, +# so it's harmless on systems without the go-x11proto tree. +# +# Required environment: +# GOXPROTO_DIR root of the go-x11proto repository +# XSERVER_BUILDDIR build directory root +# +# Optional environment: +# GO go binary (default: go) + +set -e + +# this times out on Travis, because the tests take too long. +if test "x$TRAVIS_BUILD_DIR" != "x"; then + exit 77 +fi + +if [ -z "$GOXPROTO_DIR" ] || [ ! -d "$GOXPROTO_DIR" ]; then + echo "GOXPROTO_DIR not set or not a directory -- skipping go XTS tests" + exit 77 +fi + +if [ -z "$XSERVER_BUILDDIR" ]; then + echo "XSERVER_BUILDDIR must be set" + exit 1 +fi + +XVFB="$XSERVER_BUILDDIR/hw/vfb/Xvfb" +XEPHYR="$XSERVER_BUILDDIR/hw/kdrive/ephyr/Xephyr" + +if [ ! -x "$XVFB" ]; then + echo "Xvfb not found at $XVFB -- skipping go XTS tests" + exit 77 +fi +if [ ! -x "$XEPHYR" ]; then + echo "Xephyr not found at $XEPHYR -- skipping go XTS tests" + exit 77 +fi + +if ! command -v "${GO:-go}" >/dev/null 2>&1; then + echo "Go not found -- skipping go XTS tests" + exit 77 +fi + +# Start Xvfb with -displayfd to get an unused display number. +# Use a single-digit fd (3): POSIX sh (e.g. dash, the default /bin/sh on +# Ubuntu) does not recognize multi-digit fd numbers in redirections, so +# "42>$DSPFIFO" would be parsed as the literal argument "42" plus a stdout +# redirect rather than a redirect of fd 42. +DSPFIFO=$(mktemp /tmp/xts-go-xvfb.XXXXXX) +rm -f "$DSPFIFO" +mkfifo "$DSPFIFO" +"$XVFB" -displayfd 3 3>"$DSPFIFO" -screen scrn 1280x1024x24 -noreset +byteswappedclients +extension GLX +render & +XVFB_PID=$! +read -r XVFB_DISP < "$DSPFIFO" +rm -f "$DSPFIFO" + +CLEANUP() { + kill "$XEPHYR_PID" 2>/dev/null || true + kill "$XVFB_PID" 2>/dev/null || true + wait "$XEPHYR_PID" 2>/dev/null || true + wait "$XVFB_PID" 2>/dev/null || true +} +trap CLEANUP EXIT INT TERM + +# Start Xephyr hosted by Xvfb, letting it pick a free display number itself via +# -displayfd (fd 4) rather than guessing XVFB_DISP+1. meson runs the test suite +# in parallel, so a guessed number races with other tests' servers: Xephyr (no +# -displayfd) would fail to bind ("Cannot establish any listening sockets") while +# the socket of the colliding server still satisfies the old wait-loop, leaving +# $DISPLAY pointed at the wrong server and the go test hanging until timeout. +# As with Xvfb above, a single-digit fd is required for POSIX sh redirections. +EPHFIFO=$(mktemp /tmp/xts-go-xephyr.XXXXXX) +rm -f "$EPHFIFO" +mkfifo "$EPHFIFO" +DISPLAY=:$XVFB_DISP "$XEPHYR" \ + -glamor \ + -glamor-skip-present \ + -schedMax 2000 \ + -screen 1280x1024 \ + +byteswappedclients \ + -displayfd 4 4>"$EPHFIFO" & +XEPHYR_PID=$! +read -r XEPHYR_DISPLAY < "$EPHFIFO" +rm -f "$EPHFIFO" + +if [ -z "$XEPHYR_DISPLAY" ]; then + echo "Xephyr did not start in time" + exit 1 +fi + +# Run the go-xts tests against Xephyr via $DISPLAY. +# Set XTS_XSERVER to a nonexistent path so the test framework falls back to $DISPLAY. +export DISPLAY=:$XEPHYR_DISPLAY +export XTS_XSERVER="/nonexistent" + +cd "$GOXPROTO_DIR" +${GO:-go} test ${GOTESTFLAGS:--count=1 -v} ./xts/... diff --git a/test/scripts/run-xts-go.sh b/test/scripts/run-xts-go.sh new file mode 100755 index 0000000000..af62b000f4 --- /dev/null +++ b/test/scripts/run-xts-go.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +# Run the go-x11proto XTS (wire-protocol round-trip) tests against a freshly +# built Xvfb. These are Go tests in the go-x11proto xts/ package that start +# their own server via -displayfd, so they never touch the host display. +# +# The test is skipped (exit 77) when GOXPROTO_DIR is unset or Go isn't found, +# so it's harmless on systems without the go-x11proto tree. +# +# Required environment: +# GOXPROTO_DIR root of the go-x11proto repository +# XSERVER_BUILDDIR build directory root +# +# Optional environment: +# GO go binary (default: go) +# XTS_XSERVER server binary (default: $XSERVER_BUILDDIR/hw/vfb/Xvfb) +# XTS_XSERVER_ARGS server arguments (see below for default) + +set -e + +if [ -z "$GOXPROTO_DIR" ] || [ ! -d "$GOXPROTO_DIR" ]; then + echo "GOXPROTO_DIR not set or not a directory -- skipping go XTS tests" + exit 77 +fi + +if [ -z "$XSERVER_BUILDDIR" ]; then + echo "XSERVER_BUILDDIR must be set" + exit 1 +fi + +if [ -z "$XTS_XSERVER" ]; then + XTS_XSERVER="$XSERVER_BUILDDIR/hw/vfb/Xvfb" +fi +if [ ! -x "$XTS_XSERVER" ]; then + echo "Server not found at $XTS_XSERVER -- skipping go XTS tests" + exit 77 +fi + +if ! command -v "${GO:-go}" >/dev/null 2>&1; then + echo "Go not found -- skipping go XTS tests" + exit 77 +fi + +export XTS_XSERVER +: "${XTS_XSERVER_ARGS:="-noreset +byteswappedclients -screen scrn 1280x1024x24"}" +export XTS_XSERVER_ARGS + +cd "$GOXPROTO_DIR" +exec ${GO:-go} test ${GOTESTFLAGS:--count=1 -v} ./xts/...