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
153 lines
6.6 KiB
Bash
Executable File
153 lines
6.6 KiB
Bash
Executable File
#!/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 <label> <command...>
|
|
CHECKS=$((CHECKS + 1))
|
|
if "${@:2}"; then echo "[PASS] $1"; else echo "[FAIL] $1"; FAIL=1; fi
|
|
}
|
|
|
|
# shellcheck source=qemu/tests/ui-start.sh disable=SC1091
|
|
. "$HERE/ui-start.sh"
|
|
UI_START_POLL=0.1
|
|
export UI_START_POLL
|
|
|
|
# --- the markers are the ones init prints -----------------------------------
|
|
check "direct-start marker is echoed by sbin/init" \
|
|
grep -qF "echo \"$UI_START_DIRECT" "$INIT"
|
|
check "chain marker is echoed by sbin/init" \
|
|
grep -qF "echo \"$UI_START_CHAIN" "$INIT"
|
|
check "empty-chain marker is echoed by sbin/init" \
|
|
grep -qF "echo \"$UI_FAIL_CHAIN_EMPTY" "$INIT"
|
|
check "the chain marker is printed only on a chain boot" \
|
|
awk -v m="echo \"$UI_START_CHAIN" '
|
|
/^if \[ "\$initchain" = 1 \]; then/ { inchain = 1 }
|
|
inchain && /^fi$/ { inchain = 0 }
|
|
index($0, m) { found = 1; if (!inchain) bad = 1 }
|
|
END { exit !(found && !bad) }' "$INIT"
|
|
check "the direct-start marker is printed only on a direct boot" \
|
|
awk -v m="echo \"$UI_START_DIRECT" '
|
|
/^if \[ "\$initchain" = 0 \]/ { indirect = 1 }
|
|
indirect && /^fi$/ { indirect = 0 }
|
|
index($0, m) { found = 1; if (!indirect) bad = 1 }
|
|
END { exit !(found && !bad) }' "$INIT"
|
|
check "ui_start_marker picks the mode's marker" \
|
|
test "$(ui_start_marker 0)|$(ui_start_marker 1)" = "$UI_START_DIRECT|$UI_START_CHAIN"
|
|
|
|
# The S99lvgl failure line, from the real warden_init_chain with a failing stub.
|
|
D="$WORK/init.d"
|
|
mkdir -p "$D"
|
|
printf '#!/bin/sh\nexit 4\n' > "$D/S99lvgl"
|
|
chmod 0755 "$D/S99lvgl"
|
|
WARDEN_INITD="$D" sh -c '. "$1"; warden_init_chain 10 99' sh "$LIB" > /dev/null 2> "$WORK/lvgl-fail.err"
|
|
check "warden_init_chain prints the S99lvgl failure line ui-start.sh watches for" \
|
|
grep -qF "$UI_FAIL_CHAIN_LVGL rc=4" "$WORK/lvgl-fail.err"
|
|
|
|
# --- console fixtures -------------------------------------------------------
|
|
# Chain boot, as flare-edge job 99350 printed it.
|
|
cat > "$WORK/chain.log" <<'EOF'
|
|
WARDEN-QEMU-ROOTFS-OK slot=_a
|
|
init: shipped init chain (warden.initchain)
|
|
init: chain S03warden-accounts start
|
|
Creating platform accounts: OK
|
|
init: rig bus up on /run/warden/bus/bus.sock (broker pid 253)
|
|
init: starting warden-modbus
|
|
init: starting warden-flared
|
|
init: chain S99lvgl start
|
|
warden-ui: no backlight device
|
|
Starting Warden UI: OK
|
|
init: chain started 2 script(s)
|
|
init: control bridge on /dev/ttyS0
|
|
EOF
|
|
cat > "$WORK/direct.log" <<'EOF'
|
|
WARDEN-QEMU-ROOTFS-OK slot=_a
|
|
init: starting warden-modbus
|
|
init: starting warden-ui (fbdev)
|
|
EOF
|
|
cat > "$WORK/empty-chain.log" <<'EOF'
|
|
init: shipped init chain (warden.initchain)
|
|
init: starting warden-flared
|
|
WARDEN-QEMU-INITCHAIN-EMPTY: warden.initchain but no /etc/init.d/S* script; the UI is not started
|
|
EOF
|
|
{ head -n 8 "$WORK/chain.log"; cat "$WORK/lvgl-fail.err"; } > "$WORK/lvgl-fail.log"
|
|
: > "$WORK/silent.log"
|
|
|
|
sleep 60 &
|
|
VMPID=$!
|
|
|
|
run_wait() { # run_wait <log> <secs> <chain>: rc in $RC, stderr in $WORK/err, seconds in $TOOK
|
|
local t0=$SECONDS
|
|
wait_ui_started "$WORK/$1" "$VMPID" "$2" "$3" 2> "$WORK/err"
|
|
RC=$?
|
|
TOOK=$((SECONDS - t0))
|
|
}
|
|
|
|
run_wait chain.log 5 1
|
|
check "chain console counts as started in chain mode (flare-edge#2295)" test "$RC" = 0
|
|
run_wait chain.log 0 0
|
|
check "the same console is not a direct start (the 99350 failure)" test "$RC" = 1
|
|
check "a direct-mode timeout names the direct start" \
|
|
grep -qF "warden-ui never started" "$WORK/err"
|
|
run_wait direct.log 5 0
|
|
check "direct console counts as started in direct mode" test "$RC" = 0
|
|
run_wait direct.log 0 1
|
|
check "a direct console is not a chain start" test "$RC" = 1
|
|
check "a chain-mode timeout names the chain marker" \
|
|
grep -qF "the shipped init chain never reported its start" "$WORK/err"
|
|
run_wait empty-chain.log 30 1
|
|
check "an empty chain fails" test "$RC" = 1
|
|
check "an empty chain fails at once, not at the deadline" test "$TOOK" -lt 5
|
|
check "an empty chain says why" grep -qF "has no /etc/init.d/S* script" "$WORK/err"
|
|
run_wait lvgl-fail.log 30 1
|
|
check "a failed S99lvgl fails" test "$RC" = 1
|
|
check "a failed S99lvgl fails at once" test "$TOOK" -lt 5
|
|
check "a failed S99lvgl names its status" grep -qF "S99lvgl start FAILED rc=4" "$WORK/err"
|
|
run_wait silent.log 1 1
|
|
check "a silent console times out" test "$RC" = 1
|
|
|
|
kill "$VMPID" 2>/dev/null
|
|
wait "$VMPID" 2>/dev/null
|
|
run_wait silent.log 30 1
|
|
check "a dead VM fails at once with its own message" \
|
|
sh -c 'test "$1" = 1 && test "$2" -lt 5 && grep -qF "VM exited early" "$3"' sh "$RC" "$TOOK" "$WORK/err"
|
|
VMPID=""
|
|
|
|
# --- the drivers use it -----------------------------------------------------
|
|
for s in ui-drive.sh ui-shot.sh; do
|
|
check "$s sources ui-start.sh" grep -qF '. "$HERE/ui-start.sh"' "$HERE/$s"
|
|
check "$s waits through wait_ui_started" grep -q '^wait_ui_started ' "$HERE/$s"
|
|
done
|
|
check "no driver greps a UI start marker of its own" \
|
|
sh -c '! grep -lF "init: starting warden-ui" "$1"/*.sh | grep -v "/ui-start.sh$" | grep -v "/ui-start-test.sh$" | grep -q .' sh "$HERE"
|
|
check "ui-drive.sh waits in chain mode exactly when --init-chain is given" \
|
|
grep -qF 'wait_ui_started "$WORK/console.log" "$QEMU_PID" 180 "$([ -n "$INIT_CHAIN" ] && echo 1 || echo 0)"' "$HERE/ui-drive.sh"
|
|
|
|
echo "ui-start: $CHECKS checks, $([ "$FAIL" = 0 ] && echo OK || echo FAILED)"
|
|
exit "$FAIL"
|