From 3623a28f5433cf75b3b1590597e7266a0fd244ee Mon Sep 17 00:00:00 2001 From: Vasilito Date: Wed, 29 Apr 2026 12:08:09 +0100 Subject: [PATCH] milestone: Wi-Fi + Bluetooth unified runtime harnesses test-wifi-runtime.sh: runs redbear-phase5-wifi-check + wifi-link-check in guest/QEMU modes, exit-code-based, following Phase 1-5 pattern test-bt-runtime.sh: runs redbear-bluetooth-battery-check in guest/QEMU modes, following same pattern Hardware validation requires real BT controller + USB passthrough. --- local/scripts/test-bt-runtime.sh | 79 +++++++++++++++++++++++++++++ local/scripts/test-wifi-runtime.sh | 81 ++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 local/scripts/test-bt-runtime.sh create mode 100644 local/scripts/test-wifi-runtime.sh diff --git a/local/scripts/test-bt-runtime.sh b/local/scripts/test-bt-runtime.sh new file mode 100644 index 00000000..fe8b6fb8 --- /dev/null +++ b/local/scripts/test-bt-runtime.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash +# Bluetooth runtime validation harness — runs BT check binaries. +# Follows Phase 1-5 pattern: guest + QEMU, exit-code-based. +# Hardware validation requires real BT controller + USB passthrough. + +set -euo pipefail +PROG="$(basename "$0")" + +usage() { + cat <<'EOF' +Usage: test-bt-runtime.sh [--guest|--qemu CONFIG] +Modes: + --guest Run inside already-booted Red Bear OS + --qemu CONFIG Launch QEMU with CONFIG and run checks +Exit: 0 if all pass, 1 otherwise. +EOF + exit 1 +} + +MODE=""; CONFIG="" +while [[ $# -gt 0 ]]; do + case "$1" in + --guest) MODE="guest"; shift ;; + --qemu) MODE="qemu"; CONFIG="$2"; shift 2 ;; + -h|--help) usage ;; + *) echo "$PROG: unknown: $1"; usage ;; + esac +done +[[ -z "$MODE" ]] && usage + +run_guest_checks() { + local failures=0 + run_check() { + local name="$1" cmd="$2" desc="$3" + if ! command -v "$cmd" >/dev/null 2>&1; then + echo " FAIL $name: $cmd not found ($desc)" + failures=$((failures + 1)); return 0 + fi + echo " Running $name..." + if "$cmd" --json >/dev/null 2>&1; then + echo " PASS $name: $desc" + else + echo " FAIL $name: $desc (exit non-zero)" + failures=$((failures + 1)) + fi + } + echo "=== Bluetooth Runtime Validation ==="; echo + run_check "BT battery" "redbear-bluetooth-battery-check" "BLE battery level service" + echo + echo "=== Bluetooth Summary ===" + if [[ $failures -eq 0 ]]; then echo "ALL BT CHECKS PASSED"; else echo "FAILURES: $failures"; exit 1; fi + exit 0 +} + +run_qemu_checks() { + local arch="${ARCH:-x86_64}" + local image="build/${arch}/${CONFIG}/harddrive.img" + local firmware="${FIRMWARE_PATH:-/usr/share/ovmf/x64/OVMF.fd}" + if [[ ! -f "$image" ]]; then echo "$PROG: image not found: $image"; exit 1; fi + if [[ ! -f "$firmware" ]]; then echo "$PROG: firmware not found: $firmware"; exit 1; fi + expect </dev/null 2>&1 && echo __BT_OK__ || echo __BT_FAIL__\r" +expect { "__BT_OK__" { } "__BT_FAIL__" { puts "FAIL: bt check"; exit 1 } timeout { puts "FAIL: timeout"; exit 1 } eof { puts "FAIL: eof"; exit 1 } } +puts "ALL BT CHECKS PASSED" +EXPECT_SCRIPT + exit $? +} + +case "$MODE" in + guest) run_guest_checks ;; + qemu) export FIRMWARE_PATH="${FIRMWARE_PATH:-/usr/share/ovmf/x64/OVMF.fd}"; run_qemu_checks ;; + *) usage ;; +esac diff --git a/local/scripts/test-wifi-runtime.sh b/local/scripts/test-wifi-runtime.sh new file mode 100644 index 00000000..5f9b2220 --- /dev/null +++ b/local/scripts/test-wifi-runtime.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +# Wi-Fi runtime validation harness — runs all Phase 5 Wi-Fi check binaries. +# Follows Phase 1-5 test harness pattern: guest + QEMU modes, exit-code-based. + +set -euo pipefail +PROG="$(basename "$0")" + +usage() { + cat <<'EOF' +Usage: test-wifi-runtime.sh [--guest|--qemu CONFIG] +Modes: + --guest Run inside already-booted Red Bear OS + --qemu CONFIG Launch QEMU with CONFIG and run checks +Exit: 0 if all pass, 1 otherwise. +EOF + exit 1 +} + +MODE=""; CONFIG="" +while [[ $# -gt 0 ]]; do + case "$1" in + --guest) MODE="guest"; shift ;; + --qemu) MODE="qemu"; CONFIG="$2"; shift 2 ;; + -h|--help) usage ;; + *) echo "$PROG: unknown: $1"; usage ;; + esac +done +[[ -z "$MODE" ]] && usage + +run_guest_checks() { + local failures=0 + run_check() { + local name="$1" cmd="$2" desc="$3" + if ! command -v "$cmd" >/dev/null 2>&1; then + echo " FAIL $name: $cmd not found ($desc)" + failures=$((failures + 1)); return 0 + fi + echo " Running $name..." + if "$cmd" --json >/dev/null 2>&1; then + echo " PASS $name: $desc" + else + echo " FAIL $name: $desc (exit non-zero)" + failures=$((failures + 1)) + fi + } + echo "=== Wi-Fi Runtime Validation ==="; echo + run_check "Wi-Fi check" "redbear-phase5-wifi-check" "driver + interface presence" + run_check "Wi-Fi link" "redbear-phase5-wifi-link-check" "link-layer readiness" + echo + echo "=== Wi-Fi Summary ===" + if [[ $failures -eq 0 ]]; then echo "ALL WI-FI CHECKS PASSED"; else echo "FAILURES: $failures"; exit 1; fi + exit 0 +} + +run_qemu_checks() { + local arch="${ARCH:-x86_64}" + local image="build/${arch}/${CONFIG}/harddrive.img" + local firmware="${FIRMWARE_PATH:-/usr/share/ovmf/x64/OVMF.fd}" + if [[ ! -f "$image" ]]; then echo "$PROG: image not found: $image"; exit 1; fi + if [[ ! -f "$firmware" ]]; then echo "$PROG: firmware not found: $firmware"; exit 1; fi + expect </dev/null 2>&1 && echo __WF_OK__ || echo __WF_FAIL__\r" +expect { "__WF_OK__" { } "__WF_FAIL__" { puts "FAIL: wifi check"; exit 1 } timeout { puts "FAIL: timeout"; exit 1 } eof { puts "FAIL: eof"; exit 1 } } +send "redbear-phase5-wifi-link-check --json >/dev/null 2>&1 && echo __WL_OK__ || echo __WL_FAIL__\r" +expect { "__WL_OK__" { } "__WL_FAIL__" { puts "FAIL: wifi link"; exit 1 } timeout { puts "FAIL: timeout"; exit 1 } eof { puts "FAIL: eof"; exit 1 } } +puts "ALL WI-FI CHECKS PASSED" +EXPECT_SCRIPT + exit $? +} + +case "$MODE" in + guest) run_guest_checks ;; + qemu) export FIRMWARE_PATH="${FIRMWARE_PATH:-/usr/share/ovmf/x64/OVMF.fd}"; run_qemu_checks ;; + *) usage ;; +esac