fix: add boot to login test

This commit is contained in:
2026-07-13 17:38:12 +03:00
parent bf8f012eff
commit 43f53a65be
2 changed files with 110 additions and 0 deletions
@@ -54,6 +54,20 @@ if pipe_line=$(grep -nE '\.unwrap_or_else.*panic.*pipe' "$file_path" | head -1);
exit 1
fi
panic_line=""
if panic_line=$(grep -nE '\bpanic!\s*\(' "$file_path" | head -1); then
line_no="${panic_line%%:*}"
fail "panic! present at line $line_no: ${panic_line#*:}"
exit 1
fi
expect_line=""
if expect_line=$(grep -nE '\.expect\(' "$file_path" | head -1); then
line_no="${expect_line%%:*}"
fail "expect() present at line $line_no: ${expect_line#*:}"
exit 1
fi
panic_count=$(grep -o 'panic!' "$file_path" | wc -l | tr -d ' ')
expect_count=$(grep -o '\.expect(' "$file_path" | wc -l | tr -d ' ')
warn "panic! count: $panic_count"
+96
View File
@@ -0,0 +1,96 @@
#!/usr/bin/env bash
set -euo pipefail
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
project_root="$(git -C "$script_dir" rev-parse --show-toplevel)"
iso_path="$project_root/build/x86_64/redbear-mini.iso"
timeout_secs=60
keep_running=0
if [[ -t 1 ]]; then
c_reset=$'\033[0m'
c_red=$'\033[31m'
c_green=$'\033[32m'
c_yellow=$'\033[33m'
else
c_reset=''
c_red=''
c_green=''
c_yellow=''
fi
ok() { printf '%sOK%s: %s\n' "$c_green" "$c_reset" "$*"; }
warn() { printf '%sWARN%s: %s\n' "$c_yellow" "$c_reset" "$*"; }
fail() { printf '%sFAIL%s: %s\n' "$c_red" "$c_reset" "$*" >&2; }
usage() {
cat <<EOF
Usage: $(basename "$0") [--timeout=N] [--keep-running] [ISO]
Boot a Red Bear ISO in headless QEMU and check for boot/login markers.
Options:
--timeout=N Timeout in seconds (default: 60)
--keep-running Do not kill QEMU after timeout; useful for manual debugging
-h, --help Show this help
Default ISO: build/x86_64/redbear-mini.iso
EOF
}
for arg in "$@"; do
case "$arg" in
--timeout=*) timeout_secs="${arg#*=}" ;;
--keep-running) keep_running=1 ;;
-h|--help) usage; exit 0 ;;
--*) fail "unknown argument: $arg"; usage; exit 2 ;;
*) iso_path="$arg" ;;
esac
done
command -v qemu-system-x86_64 >/dev/null 2>&1 || { fail "qemu-system-x86_64 not found"; exit 1; }
[[ -f "$iso_path" ]] || { fail "ISO not found: $iso_path"; exit 1; }
bootlog="/tmp/bootlog.txt"
: > "$bootlog"
set +e
if (( keep_running )); then
qemu-system-x86_64 -m 2G -nographic -serial mon:stdio -monitor none -cdrom "$iso_path" -boot d 2>&1 | tee "$bootlog"
qemu_status=${PIPESTATUS[0]}
else
timeout "$timeout_secs" qemu-system-x86_64 -m 2G -nographic -serial mon:stdio -monitor none -cdrom "$iso_path" -boot d 2>&1 | tee "$bootlog"
qemu_status=${PIPESTATUS[0]}
if [[ $qemu_status -eq 124 ]]; then
warn "QEMU timed out after ${timeout_secs}s"
fi
fi
set -e
python3 - "$bootlog" "$timeout_secs" <<'PY'
import sys, re
path = sys.argv[1]
text = open(path, 'r', errors='ignore').read().lower()
markers = [
("initfs", "switchroot to /scheme/initfs"),
("logd", "started logger", "[ ok ]"),
("runtime", "00_runtime.target", "runtime target"),
("login", "ion>", "login:", "red bear os login"),
]
results = []
pos = 0
for item in markers:
name, *needles = item
found = -1
for needle in needles:
idx = text.find(needle.lower(), pos)
if idx != -1 and (found == -1 or idx < found):
found = idx
results.append((name, found != -1))
if found != -1:
pos = found
for name, ok in results:
print(f"{name.upper()}: {'OK' if ok else f'not reached in {sys.argv[2]}s'}")
sys.exit(0 if all(ok for _, ok in results) else 1)
PY