simon 95d5a9747a Extend autotest to cover all UART commands except OTA upload.
Add led_ring, find_me, restart, and ota_progress steps plus uart_cmds scenario.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-19 22:41:23 +02:00

88 lines
3.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# goTool autotest fixtures
## Bench config (`configs/*.json`)
Describes your hardware bench: network, MACs, and serial ports.
| Field | Meaning |
|-------|---------|
| `id` | Config name; referenced by scenarios |
| `network` | ESP-NOW network **18** (DIP / IO expander on all nodes) |
| `master_mac` | Master WiFi STA MAC (reference) |
| `uart.baud` | Command UART baud (default **921600**) |
| `uart.master` | **gotool** port — external UART adapter on master GPIO2/3 (e.g. `/dev/ttyUSB0`) |
| `uart.master_console` | Master USB-JTAG/console for **reset** via esptool (e.g. `/dev/ttyACM0`) |
| `slaves[].id` | Short name for scenarios (`input.slave`, `expect.slave`) |
| `slaves[].mac` | Slave STA MAC (must match `gotool clients`) |
| `slaves[].client_id` | Optional; default = last MAC byte |
| `slaves[].console` | Slave USB console for **reset** (optional, e.g. `/dev/ttyACM1`) |
Copy `example-lab.json``my-lab.json` and set real paths (`ls /dev/ttyUSB* /dev/ttyACM*`).
`gotool test` uses `uart.master` when `-port` is omitted. Override with `-port /dev/…`.
## Scenario (`scenarios/*.json`)
Ordered steps: UART commands, delays, or esptool reset.
| Step field | Meaning |
|------------|---------|
| `delay_ms` | Sleep only (no command) |
| `command` | See below |
| `input` | Command arguments |
| `expect` | Assertions (UART commands only) |
### Commands
**version**`expect`: `version`, `version_min`, `git_hash`
**clients**`expect`: `min_clients`, `max_clients`, `client_count`, `slave` / `slaves`, `available`
**deadzone**`input`: `write`, `value`/`deadzone`, `slave` or `client`/`client_id`, `all_clients`
`expect`: `deadzone`, `success`, `slaves_updated`, `slaves_updated_min`
**unicast_test**`input`: `slave` or `client_id`, `seq`
`expect`: `success`, `seq`
**led_ring**`input`: `mode` (`clear`, `progress`, `digit`, `blink`, `find_me`), `progress`, `digit`, `r`/`g`/`b`, `intensity`, `blink_ms`, `blink_count`
`expect`: `success`, `mode`, `progress`, `digit`
**find_me**`input`: `client` / `client_id` or `slave` (`0` = master ring)
`expect`: `success`
**restart**`input`: `client` / `client_id` or `slave` (prefer slave in tests so UART stays up)
`expect`: `success`
**ota_progress** — query `OTA_SLAVE_PROGRESS` (no firmware upload)
`input`: optional `client_id` / `slave`
`expect`: `active` (typically `false` when idle)
**reset** — esptool hard-reset via console port from bench config (no `expect`).
`input`: `target` (`master`) or `slave` (`pod-1`), or `all: true`; optional `wait_ms` after each reset (default 2000).
Example reset steps:
```json
{ "name": "reset master", "command": "reset", "input": { "target": "master", "wait_ms": 3000 } },
{ "name": "reset all", "command": "reset", "input": { "all": true, "wait_ms": 2500 } }
```
Requires `python -m esptool` or `esptool.py` on PATH (ESP-IDF).
The `smoke` scenario resets every node with a configured `console` port, waits **10 s** for boot and ESP-NOW join, then runs a short UART smoke test.
The **`uart_cmds`** scenario covers all implemented UART commands **except OTA upload** (`OTA_START` / `OTA_PAYLOAD` / `OTA_END` / `OTA_START_ESPNOW`). It ends with a slave **restart** (master UART stays connected).
`CLIENT_INPUT` is not tested (not implemented in firmware).
### Example
```bash
cd goTool
go run . test -config example-lab -scenario smoke
go run . test -config example-lab -scenario uart_cmds
go run . test -config my-lab -scenario smoke -port /dev/ttyUSB1
go run . test -list-configs
go run . test -list-scenarios
```