From 039afca9c1067d84a02b25017e81e25d2071bf28 Mon Sep 17 00:00:00 2001 From: diviocity Date: Tue, 1 Dec 2026 03:49:19 +0100 Subject: [PATCH] Test the installed compiler and X11 from an ordinary account --- tests/x11/graphics.sh | 2 +- tests/x11/public-modes.sh | 54 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 tests/x11/public-modes.sh diff --git a/tests/x11/graphics.sh b/tests/x11/graphics.sh index f1bd853..dd18bca 100644 --- a/tests/x11/graphics.sh +++ b/tests/x11/graphics.sh @@ -11,7 +11,7 @@ finish() { if [ -f /tmp/xvfb-glx.log ]; then cat /tmp/xvfb-glx.log; fi fi if [ -n "$server" ]; then kill "$server" 2>/dev/null || true; fi - /sbin/poweroff -f + if [ "$(id -u)" = 0 ]; then /sbin/poweroff -f; fi } trap finish EXIT diff --git a/tests/x11/public-modes.sh b/tests/x11/public-modes.sh new file mode 100644 index 0000000..48ec6f7 --- /dev/null +++ b/tests/x11/public-modes.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# Exercise the installed compiler and graphics paths from an ordinary account. +set -eu +export PATH=/bin:/usr/bin:/sbin:/usr/sbin LC_ALL=C +fixtures=/usr/share/vinix-toolchain-test + +if [ "$(id -u)" = 0 ]; then + trap '/sbin/poweroff -f' EXIT + mkdir -p /tmp/.X11-unix + chmod 1777 /tmp/.X11-unix + /bin/su -s /bin/sh -c "exec /bin/sh $fixtures/public-modes.sh" nobody + echo 'Vinix verified the compiler and X11 paths as an ordinary user' + echo 'VPAC FIXTURE GUEST PASS' + exit 0 +fi + +test "$(id -u)" = 65534 +test "$(id -g)" = 65534 +arch=$(uname -m) +test -x "/usr/$arch-linux-musl/bin/as" +for path in "/usr/$arch-linux-musl/lib/ldscripts/"*.x \ + /usr/lib/bfd-plugins/liblto_plugin.so \ + /usr/lib/xorg/modules/drivers/fbdev_drv.so \ + /usr/lib/xorg/modules/extensions/libglx.so \ + /usr/lib/xorg/modules/input/inputtest_drv.so \ + /usr/lib/cmake/FreeGLUT/FreeGLUTConfig.cmake \ + /etc/X11/xinit/xinitrc +do + test -r "$path" || { echo "ordinary user cannot read $path" >&2; exit 1; } +done + +HOME=$(mktemp -d /tmp/vinix-public-modes.XXXXXX) +export HOME +cd "$HOME" +cat >headers.c <<'VINIX_PUBLIC_HEADERS' +#include +#if defined(__x86_64__) +#include +#elif defined(__aarch64__) +#include +#endif + +int main(void) +{ + return CHAR_BIT != 8; +} +VINIX_PUBLIC_HEADERS +cc -std=c17 -Wall -Wextra -Werror headers.c -o headers +./headers +cp "$fixtures/Makefile" "$fixtures/graphite.c" "$fixtures/optimizers.c" . +make -j1 optimizers +./optimizers +echo 'Vinix compiled with the installed GCC headers and LTO tools as an ordinary user' +/bin/sh "$fixtures/graphics.sh" -- 2.56.1