vinix-ports / tests / x11 / graphics.sh
78 lines · 73 sloc · 2.89 KB · 844e1080ffbd12df1fe7409ed7fdb3d64c39f710
Raw
1#!/bin/sh
2set -eu
3export PATH=/bin:/usr/bin:/sbin:/usr/sbin HOME=/tmp
4export DISPLAY=:71 XAUTHORITY=/tmp/vinix-glx.Xauthority LIBGL_ALWAYS_SOFTWARE=1
5server=
6phase=identity
7finish() {
8 status=$?
9 if [ "$status" -ne 0 ]; then
10 echo "Vinix graphics fixture failed at $phase"
11 if [ -f /tmp/xvfb-glx.log ]; then cat /tmp/xvfb-glx.log; fi
12 if [ -f /tmp/xset-glx.log ]; then cat /tmp/xset-glx.log; fi
13 fi
14 if [ -n "$server" ]; then kill "$server" 2>/dev/null || true; fi
15 if [ "$(id -u)" = 0 ]; then /sbin/poweroff -f; fi
16}
17trap finish EXIT
18
19test "$(uname -o)" = Vinix
20if [ "${VINIX_X11_INSTALL_FROM_PKG:-0}" = 1 ]; then
21 phase=package-install
22 test ! -e /usr/bin/Xvfb-glx
23 test "$(vpac o --quiet /usr/bin/pkg)" = vinix-pkg
24 test "$(pkg search --exact x11)" = x11
25 pkg install x11
26 vpac q -F validation local/vinix-release-x11 >/tmp/x11-validation
27 grep -Eq '^validation[[:space:]]+signature$' /tmp/x11-validation
28 test "$(vpac o --quiet /usr/bin/Xvfb-glx)" = xorg-server
29 test "$(vpac o --quiet /usr/lib/libgallium-24.2.8.so)" = mesa
30 echo 'Vinix installed the signed X11 packages'
31fi
32
33if [ -n "${VINIX_X11_SIDECAR_SHA256:-}" ]; then
34 phase=sidecar-extract
35 test ! -e /usr/bin/Xvfb-glx
36 test "$(vpac o --quiet /usr/bin/pkg)" = vinix-pkg
37 pkg_checksum=$(sha256sum /usr/bin/pkg)
38 printf '%s /vinix-x11-sidecar.tar.gz\n' "$VINIX_X11_SIDECAR_SHA256" | sha256sum -c -
39 /bin/busybox tar -k -xzf /vinix-x11-sidecar.tar.gz -C /
40 printf '%s\n' "$pkg_checksum" | sha256sum -c -
41 test "$(vpac o --quiet /usr/bin/pkg)" = vinix-pkg
42 test -x /usr/bin/vinix-wine-host
43 test /usr/lib/xorg/modules/dri/swrast_dri.so -ef /usr/lib/xorg/modules/dri/libgallium_dri.so
44 echo 'Vinix extracted the checked X11 release sidecar'
45fi
46
47phase=egl
48LIBGL_DRIVERS_PATH=/usr/lib/mesa24/dri /vinix-egl-check
49
50phase=glx-authorization
51export LIBGL_DRIVERS_PATH=/usr/lib/xorg/modules/dri
52mkdir -p /tmp
53timeout -k 5 60 xauth -q -f "$XAUTHORITY" add "$DISPLAY" MIT-MAGIC-COOKIE-1 0123456789abcdef0123456789abcdef
54phase=glx-readiness
55Xvfb-glx "$DISPLAY" -auth "$XAUTHORITY" -nolisten tcp -noreset -screen 0 128x128x24 \
56 +extension GLX +iglx >/tmp/xvfb-glx.log 2>&1 &
57server=$!
58attempt=0
59# Loading xset and reading the server settings can take more than 15
60# seconds on an emulated guest even after Xvfb opens its socket.
61until timeout -k 5 90 xset q >/tmp/xset-glx.log 2>&1; do
62 kill -0 "$server"
63 attempt=$((attempt + 1))
64 [ "$attempt" -lt 8 ]
65 sleep 1
66done
67
68phase=glx-client
69client_timeout=${VINIX_GLX_CLIENT_TIMEOUT:-600}
70case "$client_timeout" in
71 *[!0-9]*|0*) echo 'VINIX_GLX_CLIENT_TIMEOUT must be a positive number of seconds' >&2; exit 1 ;;
72esac
73LIBGL_ALWAYS_INDIRECT=1 timeout -k 5 "$client_timeout" /vinix-glx-check || {
74 status=$?
75 echo "GLX client exited with status $status after allowing $client_timeout seconds" >&2
76 exit "$status"
77}
78echo 'VPAC FIXTURE GUEST PASS'
79