diff --git a/local/scripts/check-pipe2-init-invariant.sh b/local/scripts/check-pipe2-init-invariant.sh index b18c7f4ac1..f01cc5ca45 100755 --- a/local/scripts/check-pipe2-init-invariant.sh +++ b/local/scripts/check-pipe2-init-invariant.sh @@ -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" diff --git a/local/scripts/test-boot-to-login.sh b/local/scripts/test-boot-to-login.sh new file mode 100755 index 0000000000..def920a31b --- /dev/null +++ b/local/scripts/test-boot-to-login.sh @@ -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 </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