tests: add a single entry point for the multi-monitor tests
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Failing after 19s
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Failing after 19s
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Failing after 19s
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Failing after 18s
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Failing after 19s
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Failing after 20s
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Failing after 19s
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Failing after 20s
build / module (push) Failing after 17s
build / host-linux (push) Failing after 21s
build / host-windows-cross (push) Failing after 19s
build / docs (push) Failing after 2s
build / obs (clang) (push) Failing after 19s
build / obs (gcc) (push) Failing after 20s
build / idd (push) Canceled after 0s
build / host-windows-native (push) Canceled after 0s

Records the non-obvious build invocations (sanitizers, stub platform
symbols, linking the verifier against the host's built libraries) so the
suite can be run with one command.
This commit is contained in:
donny committed 2026-07-28 07:38:13 +00:00
1 parent 456462f8fb
commit 18c6326e35
1 file changed
+88
+88
View File
@@ -0,0 +1,88 @@
#!/bin/bash
# Builds and runs the multi-monitor tests.
#
# The unit tests are self contained and always run. The live test needs a
# built host and is skipped if one is not present.
#
# Usage: host/tests/run-tests.sh (from the repository root)
set -u
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
OUT="${TMPDIR:-/tmp}/lg-tests"
mkdir -p "$OUT"
cd "$ROOT" || exit 1
RC=0
echo "=============================================="
echo " unit tests: layout packing and pixel repack"
echo "=============================================="
# sanitizers are on because these tests are all about buffer arithmetic
if ! gcc -g -fsanitize=address,undefined -I common/include \
-o "$OUT/test_displays" \
common/tests/test_displays.c common/src/displays.c common/src/debug.c \
common/tests/test_stubs.c; then
echo "FAILED to build the unit tests"
exit 1
fi
"$OUT/test_displays" || RC=1
HOST_BIN="$ROOT/host/build/looking-glass-host"
if [ ! -x "$HOST_BIN" ]; then
echo
echo "skipping the live test: no host built at $HOST_BIN"
exit $RC
fi
echo
echo "=============================================="
echo " live test: capture, pack and publish a frame"
echo "=============================================="
# the verifier links against the host's already built libraries
if ! gcc -O2 -msse4.1 -o "$OUT/lg-verify-atlas" host/tests/lg-verify-atlas.c \
-I common/include -I repos/LGMP/lgmp/include -I host/include -I . \
-Wl,--start-group \
host/build/common/liblg_common.a \
host/build/common/src/platform/linux/liblg_common_platform_code.a \
host/build/lgmp/liblgmp.a \
-Wl,--end-group \
-lpthread -lrt -lbfd 2>"$OUT/verify-build.log"; then
echo "FAILED to build the verifier:"
tail -5 "$OUT/verify-build.log"
exit 1
fi
SHM=/dev/shm/looking-glass-selftest
rm -f "$SHM"
truncate -s 512M "$SHM"
"$HOST_BIN" app:capture=XCB app:shmFile="$SHM" > "$OUT/host.log" 2>&1 &
HOST_PID=$!
sleep 4
if ! kill -0 "$HOST_PID" 2>/dev/null; then
echo "host exited early:"
tail -10 "$OUT/host.log"
rm -f "$SHM"
exit 1
fi
grep -E "Multi-monitor|monitors," "$OUT/host.log" || true
echo
"$OUT/lg-verify-atlas" "$SHM" "$OUT" || RC=1
kill "$HOST_PID" 2>/dev/null
wait "$HOST_PID" 2>/dev/null
rm -f "$SHM"
echo
if [ $RC -eq 0 ]; then
echo "ALL TESTS PASSED"
else
echo "TESTS FAILED"
fi
exit $RC