From a9f2b9b26a6ff6211746aa69c1a53a36701e9a62 Mon Sep 17 00:00:00 2001 From: BFE Engineering Date: Wed, 28 Oct 2026 17:17:14 -0600 Subject: [PATCH] qemu: ui-drive waits for the chain start on an init-chain boot (flare-edge#2295) 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 Claude-Session: https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG --- .github/workflows/ci.yml | 5 ++ qemu/tests/ui-drive.sh | 16 ++-- qemu/tests/ui-shot.sh | 14 +--- qemu/tests/ui-start-test.sh | 152 ++++++++++++++++++++++++++++++++++++ qemu/tests/ui-start.sh | 61 +++++++++++++++ 5 files changed, 226 insertions(+), 22 deletions(-) create mode 100755 qemu/tests/ui-start-test.sh create mode 100644 qemu/tests/ui-start.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 935a84f..2003ea4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -178,6 +178,11 @@ jobs: if command -v busybox >/dev/null; then WARDEN_TEST_SH="busybox sh" bash qemu/tests/init-chain-test.sh fi + - name: ui-drive.sh / ui-shot.sh UI start wait regression test (flare-edge#2295) + # The console line that means "UI started" differs between a direct + # start and a shipped init chain boot; every marker is checked + # against sbin/init, and a chain failure fails at once. + run: bash qemu/tests/ui-start-test.sh - name: mkimage.sh ROOTFS_OVERLAY regression test (flare-edge#2210) # The panel's scripts land in both slots with their modes; an overlay # reaching outside etc/ and usr/, or holding a symlink, writes no image. diff --git a/qemu/tests/ui-drive.sh b/qemu/tests/ui-drive.sh index c7e619d..d7dcd30 100755 --- a/qemu/tests/ui-drive.sh +++ b/qemu/tests/ui-drive.sh @@ -36,6 +36,8 @@ 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" SEED_FILE="" REFS_FILE="" @@ -252,17 +254,9 @@ if [ -n "$RS485_DEVICES" ]; then fi echo "== waiting for warden-ui" -deadline=$((SECONDS + 180)) -while [ $SECONDS -lt $deadline ]; do - grep -aq 'init: starting warden-ui' "$WORK/console.log" && break - kill -0 "$QEMU_PID" 2>/dev/null || { echo "FATAL: VM exited early" >&2; tail -25 "$WORK/console.log" >&2; exit 1; } - sleep 2 -done -grep -aq 'init: starting warden-ui' "$WORK/console.log" || { - echo "FATAL: warden-ui never started (no fb0? wrong kernel?)" >&2 - tail -25 "$WORK/console.log" >&2 - exit 1 -} +# A chain boot reports the start through the chain, not the direct-start line +# (ui-start.sh, flare-edge#2295). +wait_ui_started "$WORK/console.log" "$QEMU_PID" 180 "$([ -n "$INIT_CHAIN" ] && echo 1 || echo 0)" || exit 1 # A started process is not a rendered frame. Poll screendumps until the panel # stops being a single flat colour, on a bounded deadline: TCG renders CPU-bound diff --git a/qemu/tests/ui-shot.sh b/qemu/tests/ui-shot.sh index 0389209..451d53d 100755 --- a/qemu/tests/ui-shot.sh +++ b/qemu/tests/ui-shot.sh @@ -13,6 +13,8 @@ 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}" @@ -66,17 +68,7 @@ if [ -z "$QEMU_PID" ] || ! kill -0 "$QEMU_PID" 2>/dev/null; then exit 1 fi -deadline=$((SECONDS + 120)) -while [ $SECONDS -lt $deadline ]; do - grep -aq 'init: starting warden-ui' "$WORK/console.log" && break - kill -0 "$QEMU_PID" 2>/dev/null || { echo "FATAL: VM exited early" >&2; tail -25 "$WORK/console.log" >&2; exit 1; } - sleep 2 -done -grep -aq 'init: starting warden-ui' "$WORK/console.log" || { - echo "FATAL: warden-ui never started (no fb0? wrong kernel?)" >&2 - tail -25 "$WORK/console.log" >&2 - exit 1 -} +wait_ui_started "$WORK/console.log" "$QEMU_PID" 120 0 || exit 1 qmp() { python3 "$HERE/qmp.py" "$WORK/qmp.sock" "$@"; } diff --git a/qemu/tests/ui-start-test.sh b/qemu/tests/ui-start-test.sh new file mode 100755 index 0000000..fa53235 --- /dev/null +++ b/qemu/tests/ui-start-test.sh @@ -0,0 +1,152 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2016 # the single-quoted $ strings are literal patterns and child-shell args +# Host test for qemu/tests/ui-start.sh (flare-edge#2295): the console line +# ui-drive.sh and ui-shot.sh wait for before driving the UI. Offline, no VM. +# +# flare-edge job 99350 (the first "QEMU UI shipped init chain" run) booted +# the chain cleanly but ui-drive.sh waited 180 s for the direct-start line, +# which a warden.initchain boot never prints. This test pins: +# - every marker ui-start.sh waits for is printed by rootfs/sbin/init or +# rootfs/etc/warden-lib.sh, in the mode it is used for; +# - a chain-boot console (the 99350 lines) counts as started in chain +# mode, and a direct-start console in direct mode; +# - an empty chain and a failed S99lvgl fail at once, not at the deadline; +# - a dead VM and a silent console fail with their own messages; +# - ui-drive.sh and ui-shot.sh wait through ui-start.sh only, and +# ui-drive.sh passes chain mode exactly when --init-chain is given. +# +# bash ui-start-test.sh +set -uo pipefail + +HERE="$(cd "$(dirname "$0")" && pwd)" +INIT="$HERE/../rootfs/sbin/init" +LIB="$HERE/../rootfs/etc/warden-lib.sh" +WORK="$(mktemp -d "${TMPDIR:-/tmp}/warden-ui-start.XXXXXX")" || exit 1 +VMPID="" +# shellcheck disable=SC2317 # called from the EXIT trap +cleanup() { [ -n "$VMPID" ] && kill "$VMPID" 2>/dev/null; rm -rf "$WORK"; } +trap cleanup EXIT +FAIL=0 +CHECKS=0 +check() { # check