test:@test 闭环迁移 PowerShell→Python(run_boot_test/verify_log 纯标准库,文档同步)

This commit is contained in:
2026-09-20 03:07:42 +08:00
parent 2375569f96
commit 8ae7a12016
18 changed files with 395 additions and 323 deletions
+9 -9
View File
@@ -34,20 +34,20 @@ Interpretation (per AGENTS.md): exit code 0 = PASS (0 errors, 0 warnings). 1/2+
### Step 2 — Flash + capture boot log (one orchestrated call)
Use `test/run_boot_test.ps1` which opens the port + clears the log (arming),
Use `test/run_boot_test.py` (pure-stdlib Python, 2026-09-20 起替代 PowerShell 版) which opens the port + clears the log (arming),
flashes, waits for RX silence, extracts the boot log and verifies — all in one
call. The serial daemon buffers the full stream in `tools/serial_tool/state/serial.log`,
so nothing can be lost between steps:
```powershell
powershell -ExecutionPolicy Bypass -File "test\run_boot_test.ps1" `
-SettleMs 8000 -MaxWaitMs 30000 `
-FlashCmd "MDK-ARM\download.bat" `
-Required "App init OK;Network Init;net init: OK" `
-Forbidden "FAIL;ERROR;HardFault"
& '.venv\Scripts\python.exe' test/run_boot_test.py `
--settle-ms 8000 --max-wait-ms 30000 `
--flash-cmd "MDK-ARM\download.bat" `
--required "App init OK;Network Init;net init: OK" `
--forbidden "FAIL;ERROR;HardFault"
```
`-Port` defaults to `.opencode/serial_config.json`; override only if needed.
`--port` defaults to `.opencode/serial_config.json`; override only if needed.
Exit codes: **0 = PASS**, 1 = FAIL (marker miss / forbidden hit), 2 = capture/flash error, 3 = preflight/usage error.
### Step 3 — Iterate
@@ -68,7 +68,7 @@ For interactive command/response (not boot-log capture), drive the serial assist
- **串口端口**:以 `.opencode/serial_config.json` 为准(本机为 COM6)。每次连接前先读它。
- **全量历史 = 日志文件**:daemon 把 RX/TX/SYS 持续写入 `tools/serial_tool/state/serial.log`,直接 Read/Grep 即可,无需采集窗口仪式。
- **⚠️ 静默判据**:boot 任务间有 ~3-4s 自然静默间隙,`-SettleMs` 必须 ≥ 8000(默认已如此),否则日志截断。
- **⚠️ 静默判据**:boot 任务间有 ~3-4s 自然静默间隙,`--settle-ms` 必须 ≥ 8000(默认已如此),否则日志截断。
- **daemon 生命周期**:任何命令自动拉起 daemon(无需显式 start);`restart` 保证加载最新代码;强杀 daemon 后下条命令自动恢复(串口需重新 `open`)。
- UI (LVGL) task `ui_task` 已有 `UI port init: OK` / `UI menu init: OK` 打印,可用 `-Required "UI port init: OK;UI menu init: OK"` 自动回归 UI 初始化。
- UI (LVGL) task `ui_task` 已有 `UI port init: OK` / `UI menu init: OK` 打印,可用 `--required "UI port init: OK;UI menu init: OK"` 自动回归 UI 初始化。
- Full command contract / daemon behavior / known traps: `docs/测试说明/串口助手设计说明.md` and `docs/测试说明/自动化测试流程.md`.