Files
MicrOBU/obu-firmware/test/bench/run_host_tests_overnight.ps1
T
Ashin Walpola 462e1898ff Run the overnight bench test on the spare board, and document it
Track the bench scripts (run_overnight.py and its stages, the link and ITS
client libraries, the phone-vs-node comparison) with the first reports.

Changes for the spare XIAO (no cell):
- run_overnight.py picks the single Espressif board by default and refuses to
  test a build that is not this checkout's HEAD.
- The unsigned soak stops as "transmit path wedged" after 40 resource_limit
  refusals in a row and tries whether a repeated STATION_CONFIGURE clears it.
- "Refused requests put nothing on the radio" counts only own transmissions;
  frames heard from other stations are copied by RAW_CAPTURE too.
- start_overnight.ps1: optional build and flash, host C tests in the
  background, Windows kept awake. setup_workstation.ps1 checks and installs
  git, Python 3.11, pyserial, asn1tools, MSYS2 gcc and make, ESP-IDF 6.0.2.
- obu-firmware/docs/overnight-bench-test.tex (and PDF) describe the test, the
  workstation set-up and the findings of the 2026-11-25 runs.
2026-11-25 14:43:34 +01:00

56 lines
2.7 KiB
PowerShell

# Overnight run of the PC-side firmware tests (obu-firmware/test/host): the whole suite once, then the mutation fuzzer of
# gn_unwrap_its with a new seed and a long iteration count until the time is up. Needs MSYS2 UCRT64 (gcc, make) and Python
# 3.11 with asn1tools, as obu-firmware/test/host/README.md describes. It needs no board.
#
# powershell -ExecutionPolicy Bypass -File obu-firmware\test\bench\run_host_tests_overnight.ps1 -Hours 8
#
# Output: obu-firmware\test\results\host-<time>\ (suite.log, fuzz-<seed>.log, summary.txt). Exit code 1 if anything failed.
param(
[double]$Hours = 8,
[int]$FuzzIterations = 200000000,
[string]$Msys = "C:\msys64"
)
$ErrorActionPreference = "Continue"
$root = Resolve-Path (Join-Path $PSScriptRoot "..\..") # obu-firmware
$hostDir = Join-Path $root "test\host"
$out = Join-Path $root ("test\results\host-" + (Get-Date -Format "yyyyMMdd-HHmmss"))
New-Item -ItemType Directory -Force $out | Out-Null
$summary = Join-Path $out "summary.txt"
function Log($m) { $line = "{0} {1}" -f (Get-Date -Format "HH:mm:ss"), $m; Write-Host $line; Add-Content -Path $summary -Value $line }
$bin = Join-Path $Msys "ucrt64\bin"
if (-not (Test-Path (Join-Path $bin "gcc.exe"))) {
Log "gcc not found in $bin. Install MSYS2 UCRT64 (obu-firmware/test/host/README.md, Option B) or pass -Msys."
exit 2
}
$env:PATH = "$bin;" + (Join-Path $Msys "usr\bin") + ";$env:PATH"
$pyLocal = Join-Path $env:LOCALAPPDATA "Programs\Python\Python311\python.exe"
$pyArg = if (Get-Command py -ErrorAction SilentlyContinue) { "py -3.11" } elseif (Test-Path $pyLocal) { "`"$pyLocal`"" } else { "python" }
Set-Location $hostDir
$failed = 0
Log "make clean; make check (chain, replay with asn1tools, fuzz, battery, firmware unit tests, fragments)"
& make clean *> $null
& make check "PYTHON_ASN1=$pyArg" *> (Join-Path $out "suite.log")
if ($LASTEXITCODE -ne 0) { $failed++; Log "make check FAILED (exit $LASTEXITCODE): see suite.log" } else { Log "make check passed" }
Select-String -Path (Join-Path $out "suite.log") -Pattern "RESULT:|FAIL|CRASH" | Select-Object -First 20 | ForEach-Object { Log (" " + $_.Line.Trim()) }
$end = (Get-Date).AddHours($Hours)
$seed = 100
$runs = 0
while ((Get-Date) -lt $end) {
$seed++
$log = Join-Path $out ("fuzz-{0}.log" -f $seed)
Log "fuzz seed $seed, $FuzzIterations iterations"
& make fuzz "FUZZ_ITER=$FuzzIterations" "FUZZ_SEED=$seed" *> $log
$runs++
if ($LASTEXITCODE -ne 0 -or (Select-String -Path $log -Pattern "CRASH" -Quiet)) {
$failed++
Log " FUZZ FAILURE with seed $seed (exit $LASTEXITCODE): see fuzz-$seed.log, which lists the input as hex"
}
}
Log "finished: $runs fuzz runs after the suite, $failed failure(s)"
exit ([int]($failed -gt 0))