mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-04 02:48:13 +10:00
test: containerize portal hardware contract
This commit is contained in:
+71
-20
@@ -1,45 +1,96 @@
|
||||
# Testing
|
||||
|
||||
The clean-consumer check builds a project that declares only WiFiManager. It proves the package manifest resolves DFTE, ESPAsyncWebServer, and the correct ESP8266 or ESP32 TCP dependency without a sibling checkout or attached board. The runner removes a previous local package link before each
|
||||
check, so dependency resolution uses the current manifest rather than a stale
|
||||
`.pio` copy.
|
||||
WiFiManager separates repeatable package checks from opt-in tests that flash a
|
||||
real board or join a captive portal. The normal commands never need a board,
|
||||
local Wi-Fi credentials, browser binary, or sibling checkout.
|
||||
|
||||
## Clean consumer and example builds
|
||||
|
||||
The clean-consumer check builds a project that declares only WiFiManager. It
|
||||
proves the package manifest resolves DFTE, ESPAsyncWebServer, and the correct
|
||||
ESP8266 or ESP32 TCP dependency without a sibling checkout. The runner removes
|
||||
a prior local package link before each check, so dependency resolution uses the
|
||||
current manifest rather than a stale `.pio` copy.
|
||||
|
||||
```bash
|
||||
./scripts/test.sh compile --platform esp8266
|
||||
./scripts/test.sh compile --platform esp32
|
||||
```
|
||||
|
||||
## Example builds
|
||||
|
||||
```bash
|
||||
./scripts/test.sh examples --platform esp8266
|
||||
./scripts/test.sh examples --platform esp32
|
||||
```
|
||||
|
||||
CI runs the clean-consumer and example checks for pushes to the maintained branch and pull requests. It intentionally compiles only: attached boards, local network state, and browser installation are not CI requirements.
|
||||
CI runs these board-free checks for pull requests and pushes to the maintained
|
||||
branch. It intentionally does not require attached hardware, a local network,
|
||||
or Docker.
|
||||
|
||||
## Local hardware lifecycle tests
|
||||
|
||||
The existing Unity suite runs on a board without Wi-Fi credentials, MQTT, a DeviceFramework checkout, or a local profile. It verifies portal start and stop lifecycle recovery, scan-cache release, and a real asynchronous Wi-Fi scan.
|
||||
The Unity suite runs on a board without Wi-Fi credentials, MQTT, DeviceFramework,
|
||||
or a local profile. It verifies portal start/stop recovery, scan-cache release,
|
||||
and a real asynchronous Wi-Fi scan.
|
||||
|
||||
Use a stable serial-by-id path rather than a changing /dev/ttyUSB number:
|
||||
Use a stable serial-by-id path rather than a changing `/dev/ttyUSB` number:
|
||||
|
||||
~~~bash
|
||||
```bash
|
||||
pio device list
|
||||
./scripts/test.sh hardware --platform esp8266 --port /dev/serial/by-id/usb-...
|
||||
./scripts/test.sh hardware --platform esp32 --port /dev/serial/by-id/usb-...
|
||||
~~~
|
||||
```
|
||||
|
||||
The runner uploads the test image, captures its normal-boot serial output with the repository Bash helper, requires Unity's Tests 0 Failures and OK summary, and prints WM_METRIC lifecycle measurements. It does not need or read an environment file. A failed capture is preserved under /tmp for inspection; a successful one is removed.
|
||||
The runner flashes the selected board, captures normal-boot serial output with
|
||||
the repository Bash helper, requires Unity's `Tests 0 Failures` and `OK`
|
||||
summary, and prints lifecycle metrics. Hardware work shares a lock with the
|
||||
portal contract, so two invocations cannot flash or use the same board at once.
|
||||
|
||||
## Optional portal browser test
|
||||
## Docker portal contract
|
||||
|
||||
test/portal-harness is a deliberately tiny portal-only firmware. It is not an example or a consuming application. The browser runner flashes it to the selected board, joins the portal with an explicitly named secondary Wi-Fi adapter, checks root HTML and bootstrap JSON, exercises concurrent root/bootstrap responses, and verifies an asynchronous scan. When a compatible local Chromium binary is available, it also captures the portal and records browser-console output.
|
||||
`test/portal-harness` is deliberately tiny portal-only firmware, not an example
|
||||
or consuming application. `tools/portal-hardware` flashes it to one explicitly
|
||||
selected board, joins its AP through one explicitly selected **secondary**
|
||||
Wi-Fi adapter, then runs its HTTP and browser contract in a pinned Playwright
|
||||
Docker image. Docker uses host networking only to reach the already-routed
|
||||
portal; it never runs NetworkManager or changes host adapters.
|
||||
|
||||
~~~bash
|
||||
./tools/test-portal-browser.sh --platform esp8266 --port /dev/serial/by-id/usb-... --wifi-interface wlx74da385d4165 --output /tmp/wifimanager-browser-results
|
||||
~~~
|
||||
```bash
|
||||
./tools/portal-hardware doctor --client-interface wlx74da385d4165
|
||||
./tools/portal-hardware run \
|
||||
--platform esp8266 \
|
||||
--port /dev/serial/by-id/usb-... \
|
||||
--client-interface wlx74da385d4165
|
||||
```
|
||||
|
||||
The runner refuses an interface that owns the host's default route. It creates a temporary NetworkManager connection with never-default before bringing it up, so portal traffic stays on the specified adapter and does not replace the host Internet route. The temporary connection is removed on exit. Use a non-default secondary adapter only.
|
||||
The command refuses the host default-route adapter. If the chosen secondary
|
||||
adapter is already connected, require an explicit acknowledgement before it is
|
||||
replaced:
|
||||
|
||||
```bash
|
||||
./tools/portal-hardware run ... --take-over-client-adapter
|
||||
```
|
||||
|
||||
The fixture opens a 15-minute portal session, includes one harmless custom
|
||||
parameter, and verifies root/bootstrap/info/status API responses, concurrent
|
||||
low-priority requests, parameter persistence, timeout reset, an actual async
|
||||
scan, a missing-route response, and desktop/mobile portal rendering with no
|
||||
browser page errors. Screenshots, traces on failure, JSON results, and the HTML
|
||||
report are saved under the printed XDG state-directory artifact path.
|
||||
|
||||
For interactive diagnosis, leave the temporary client connection up and remove
|
||||
only that managed connection when finished:
|
||||
|
||||
```bash
|
||||
./tools/portal-hardware up --platform esp32 --port /dev/serial/by-id/usb-... \
|
||||
--client-interface wlx74da385d4165
|
||||
./tools/portal-hardware down
|
||||
```
|
||||
|
||||
An optional station handoff test is deliberately separate because it connects
|
||||
the fixture to a real LAN. Copy the ignored template below, add local
|
||||
credentials, and pass it explicitly; it is mounted read-only into the test
|
||||
container and is never logged by the runner.
|
||||
|
||||
```bash
|
||||
cp test/portal-station.env.example test/portal-station.env
|
||||
./tools/portal-hardware run ... --station-env test/portal-station.env
|
||||
```
|
||||
|
||||
Back to [documentation](README.md) · [project overview](../README.md).
|
||||
|
||||
Reference in New Issue
Block a user