These tests run on a normal PC — no ESP32, no flashing. They exercise the fallback / restore / reconnect logic on the host, in seconds, so regressions are caught before anything reaches hardware.
Three suites:
nm_harness.cpp— drivesNetworkManagerCore(the pure decision logic) through a set of scenarios and asserts the exact event sequence each produces.test_glue.cpp— instantiates the realNetworkManagerClasssingleton with a mock adapter and runs a full CONNECTED → FALLBACK → RESTORED → DISCONNECTED → CONNECTED path. This also compile-checks the shipping headers.test_start_retry.cpp— the same, with an adapter whosestart()fails (an Ethernet chip that does not answer): the next adapter must start at once, and the failing one be retried after 15, 30, 60 ... 300 s.
Arduino.h and NetworkProfile.h here are tiny host stubs — just enough for
the glue to compile and run on a PC. They are not used on the device.
A C++17 compiler on your PATH: g++ / clang++ on Linux/macOS, or g++ from
MSYS2 on Windows. Nothing else.
-
Download and install MSYS2 from https://www.msys2.org (default path:
C:\msys64). -
Open the MSYS2 UCRT64 shell and run:
pacman -S mingw-w64-ucrt-x86_64-gcc
-
Add the compiler to your PATH so
cmd.exeand VSCode can find it. Choose one of:Permanently (recommended): Add
C:\msys64\ucrt64\binto your user PATH via System Properties → Environment Variables.For the VSCode task only: The supplied
.vscode/tasks.jsonalready adds the MSYS2 paths automatically for the build task, so Ctrl+Shift+B works without touching the system PATH. If you installed MSYS2 somewhere other thanC:\msys64, update the two paths in theoptions.env.PATHentry of.vscode/tasks.json.For
run_tests.bat(double-click / cmd): Either the permanent option above, or prepend the path in the same cmd window before running:set PATH=C:\msys64\ucrt64\bin;C:\msys64\usr\bin;%PATH% run_tests.bat
Pick whichever fits your setup — they all do the same thing:
| Environment | Command |
|---|---|
| Linux / macOS / WSL / Git-Bash | ./run_tests.sh |
| Windows (cmd / double-click) | run_tests.bat |
Anywhere with make |
make |
| VSCode | Ctrl+Shift+B |
On Linux/macOS you may first need chmod +x run_tests.sh. The VSCode task is in
.vscode/tasks.json; it assumes the project root is your workspace folder.
A passing run ends with 11/11 passed for the Core suite and [PASS] for the
glue smoke test.
The build commands look for the library headers one level up (..) and in
../src, so this works whether your headers sit in the project root or under
src/. If your layout differs, adjust the include paths in Makefile /
run_tests.sh / run_tests.bat.