ci / test (pull_request) Successful in 24s
ci / mcdc (pull_request) Successful in 17s
ci / badges (push) Skipped
ci / test (push) Successful in 9s
ci / qemu-tools (push) Successful in 1m27s
ci / bench (pull_request) Successful in 5s
ci / mcdc (push) Successful in 12s
ci / bench (push) Successful in 5s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / patches-apply (push) Successful in 43s
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / patches-apply (pull_request) Successful in 24s
ci / quality (pull_request) Successful in 2m35s
ci / kernel-symbols (pull_request) Successful in 5m7s
ci / quality (push) Successful in 1m28s
ci / qemu-tools (pull_request) Successful in 1m36s
ci / badges (pull_request) Skipped
ci / kernel-symbols (push) Successful in 5m2s
ui-drive.sh --init-chain boots with warden.initchain, where sbin/init starts the UI through the panel's S99lvgl and prints "init: chain started N script(s)"; the direct-start line "init: starting warden-ui" is never printed. ui-drive.sh still waited for that line, so the first flare-edge "QEMU UI shipped init chain" run (job 99350) gave "warden-ui never started" after 180 s on a chain that had booted cleanly. The wait moves to qemu/tests/ui-start.sh (sourced by ui-drive.sh and ui-shot.sh): wait_ui_started picks the marker by mode and, on a chain boot, fails at once on WARDEN-QEMU-INITCHAIN-EMPTY or a failed S99lvgl instead of at the deadline. Tests: new qemu/tests/ui-start-test.sh (27 checks, in CI): every marker is the one sbin/init or warden-lib.sh prints in that mode, the job 99350 console counts as started in chain mode, empty and failed chains fail fast, a dead VM and a silent console fail with their own messages, and both drivers wait through the helper. The old ui-drive.sh fails 4 checks. Fixes flare-edge#2295 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG
143 lines
5.0 KiB
Bash
Executable File
143 lines
5.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Display + touch scenario: boot the VM headless with virtio-gpu, wait for the
|
|
# LVGL UI (fbdev build) to render a real frame, then inject an absolute touch
|
|
# tap on the Metrics tab (virtio-tablet) and ASSERT the frame changed: the
|
|
# device-level analogue of flare-edge's Xvfb/xdotool sim-test.sh. Readiness is
|
|
# polled from screendumps on bounded deadlines, never guessed with fixed
|
|
# sleeps: TCG renders CPU-bound and a loaded host can be arbitrarily slow.
|
|
#
|
|
# FAILS CLOSED on missing prerequisites.
|
|
#
|
|
# Usage: ui-shot.sh <zImage-virt> [out-dir]
|
|
set -euo pipefail
|
|
|
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # qemu/tests/
|
|
QDIR="$(cd "$HERE/.." && pwd)" # qemu/
|
|
# shellcheck source=qemu/tests/ui-start.sh disable=SC1091
|
|
. "$HERE/ui-start.sh"
|
|
|
|
ZIMAGE="${1:-}"
|
|
OUTDIR="${2:-$QDIR/out}"
|
|
if [ -z "$ZIMAGE" ] || [ ! -f "$ZIMAGE" ]; then
|
|
echo "FATAL: usage: $0 <zImage> [out-dir]: the virt.fragment kernel variant" >&2
|
|
exit 1
|
|
fi
|
|
[ -x "$QDIR/payload/warden-ui" ] || {
|
|
echo "FATAL: no qemu/payload/warden-ui: build it with flare-edge tools/build-ui-vm.sh" >&2
|
|
exit 1
|
|
}
|
|
command -v qemu-system-arm >/dev/null || {
|
|
echo "FATAL: qemu-system-arm not on PATH: see qemu/README.md" >&2
|
|
exit 1
|
|
}
|
|
|
|
# Short-named scratch: AF_UNIX socket paths are capped at ~108 chars.
|
|
WORK="$(mktemp -d /tmp/wqu.XXXXXX)"
|
|
QEMU_PID=""
|
|
cleanup() {
|
|
if [ -n "$QEMU_PID" ]; then kill "$QEMU_PID" 2>/dev/null || true; fi
|
|
rm -rf "$WORK"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
bash "$QDIR/mkinitramfs.sh"
|
|
bash "$QDIR/mkimage.sh"
|
|
|
|
# Random hostfwd ports can collide. Detect qemu's early bind failure and
|
|
# retry with a fresh base rather than failing spuriously.
|
|
for _attempt in 1 2 3; do
|
|
PORT=$((21000 + RANDOM % 20000))
|
|
: > "$WORK/console.log"
|
|
bash "$QDIR/run.sh" --kernel "$ZIMAGE" --display headless --qmp "$WORK/qmp.sock" \
|
|
--ssh-port "$PORT" --http-port $((PORT + 1)) --api-port $((PORT + 2)) \
|
|
> "$WORK/console.log" 2>&1 &
|
|
QEMU_PID=$!
|
|
sleep 3
|
|
kill -0 "$QEMU_PID" 2>/dev/null && break
|
|
if grep -aq 'Could not set up host forwarding' "$WORK/console.log"; then
|
|
echo "== hostfwd port collision on base $PORT, retrying"
|
|
QEMU_PID=""
|
|
continue
|
|
fi
|
|
echo "FATAL: VM died at launch:" >&2
|
|
tail -20 "$WORK/console.log" >&2
|
|
exit 1
|
|
done
|
|
if [ -z "$QEMU_PID" ] || ! kill -0 "$QEMU_PID" 2>/dev/null; then
|
|
echo "FATAL: could not launch the VM after 3 port attempts" >&2
|
|
exit 1
|
|
fi
|
|
|
|
wait_ui_started "$WORK/console.log" "$QEMU_PID" 120 0 || exit 1
|
|
|
|
qmp() { python3 "$HERE/qmp.py" "$WORK/qmp.sock" "$@"; }
|
|
|
|
# Frame is "real" once it has more than a handful of distinct colors (a blank
|
|
# or console-only frame has very few).
|
|
frame_rendered() { # $1 = ppm path
|
|
python3 - "$1" <<'EOF'
|
|
import sys
|
|
data = open(sys.argv[1], "rb").read()
|
|
parts = data.split(b"\n", 3) # P6 header: magic, dims, maxval, raw RGB
|
|
pixels = parts[3] if len(parts) == 4 else b""
|
|
distinct = len(set(pixels[i:i+3] for i in range(0, min(len(pixels), 3*720*720), 3)))
|
|
print(f"{sys.argv[1]}: {len(pixels)} bytes, {distinct} distinct colors")
|
|
sys.exit(0 if distinct > 16 else 1)
|
|
EOF
|
|
}
|
|
|
|
# The VM can die mid-poll (OOM, crash): check liveness before every QMP
|
|
# call so the failure is OUR message + console evidence, not a python
|
|
# traceback, and preserve the console log before the trap removes $WORK.
|
|
vm_alive_or_die() {
|
|
kill -0 "$QEMU_PID" 2>/dev/null && return 0
|
|
echo "FATAL: VM exited during the screendump poll" >&2
|
|
tail -25 "$WORK/console.log" >&2
|
|
mkdir -p "$OUTDIR"; cp "$WORK/console.log" "$OUTDIR/ui-shot-console.log" || true
|
|
exit 1
|
|
}
|
|
|
|
# Poll for the first rendered frame (bounded, no guessed sleep).
|
|
rendered=0
|
|
deadline=$((SECONDS + 90))
|
|
while [ $SECONDS -lt $deadline ]; do
|
|
vm_alive_or_die
|
|
qmp screendump "$WORK/shot1.ppm"
|
|
if frame_rendered "$WORK/shot1.ppm"; then rendered=1; break; fi
|
|
sleep 3
|
|
done
|
|
[ "$rendered" = 1 ] || {
|
|
echo "FATAL: UI never rendered a non-blank frame within 90s" >&2
|
|
mkdir -p "$OUTDIR"; cp "$WORK/console.log" "$OUTDIR/ui-shot-console.log" || true
|
|
exit 1
|
|
}
|
|
|
|
# Tap the "Metrics" tab: pixel (373,40) of 720x720 scaled to the QMP absolute
|
|
# range 0..32767. Switching tabs must repaint the content area. Poll for the
|
|
# repaint rather than guessing a delay.
|
|
vm_alive_or_die
|
|
qmp tap 16975 1820
|
|
changed=0
|
|
# 90s, matching the first-frame budget: TCG repaints are CPU-bound and a
|
|
# contended CI runner can be arbitrarily slower than this dev box (same
|
|
# margin reasoning as the rs485 test-gap widening).
|
|
deadline=$((SECONDS + 90))
|
|
while [ $SECONDS -lt $deadline ]; do
|
|
sleep 2
|
|
vm_alive_or_die
|
|
qmp screendump "$WORK/shot2.ppm"
|
|
if ! cmp -s "$WORK/shot1.ppm" "$WORK/shot2.ppm"; then changed=1; break; fi
|
|
done
|
|
|
|
mkdir -p "$OUTDIR"
|
|
cp "$WORK/shot1.ppm" "$OUTDIR/ui-shot1.ppm"
|
|
cp "$WORK/shot2.ppm" "$OUTDIR/ui-shot2.ppm" 2>/dev/null || true
|
|
|
|
[ "$changed" = 1 ] || {
|
|
echo "FATAL: tapping the Metrics tab did not change the frame within 90s: touch is not reaching the UI" >&2
|
|
cp "$WORK/console.log" "$OUTDIR/ui-shot-console.log" || true
|
|
exit 1
|
|
}
|
|
echo "tap on the Metrics tab repainted the frame (touch reached the UI)"
|
|
echo "UI-SHOT-PASS (screenshots in $OUTDIR/ui-shot{1,2}.ppm)"
|