test(firmware): broaden native-test coverage + gcov instrumentation

Extract the pre-first-image retry from normal_operation() into a
templated bootstrap_loop() helper in operation.h so the loop body
becomes unit-testable. Add four tests against it: two that verify the
X-Panel-Id header is sent on every poll and matches the compile-time
PANEL_ID (a silent server-side mis-routing risk if dropped), and two
that exercise the loop's exit-on-deep-sleep vs. iterate-while-204
behaviour.

Wire --coverage into env:native-test (compile + link via a post-script)
so `gcovr -r . --filter src/` produces a real number, and ignore the
stray *.gcov files gcovr drops at the repo root.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-14 16:25:00 -04:00
parent 013e49d859
commit e9f2ec0629
7 changed files with 118 additions and 5 deletions
+8 -1
View File
@@ -150,9 +150,16 @@ build_flags =
-DBOARD_HAS_PSRAM
; ── Native unit tests — no hardware, uses test/mocks/ ──
; --coverage instruments gcov on both compile and link. After a test run,
; .gcda files land in .pio/build/native-test/test/... — gcovr aggregates
; them against src/. To regenerate the number:
; pio test -e native-test
; gcovr -r . --filter src/ --print-summary
[env:native-test]
platform = native
lib_deps =
throwtheswitch/Unity@^2.6
build_flags = -DUNIT_TEST -std=c++17 -iquote test/mocks -iquote test -Itest/mocks -Itest
build_flags = -DUNIT_TEST -std=c++17 -iquote test/mocks -iquote test -Itest/mocks -Itest --coverage -O0 -g
build_unflags = -O2
test_build_src = no
extra_scripts = post:scripts/native_coverage_link.py