NetDeck: headless test runner — unit + integration suites, E2E as separate build

- emulator/tests/: harness.h (TEST/EXPECT framework, input + serial +
  framebuffer helpers), shim_globals.cpp (shim externs for test binaries,
  replacing main.cpp ownership)
- unit_tests.h (14): map/door/LOS/BFS/cover/link state machine/trace/
  spike/reinforcement/win/loss/reset — deterministic fixed-seed, sim
  stepped tick by tick
- integration_tests.h (7): keyboard->pollKeyboard->handleKey pipeline,
  beacon clicks -> squad movement, full network journey via clicks,
  hover-sever (incl. safe sever during trace), daemon gating
- e2e_tests.cpp (separate NetDeck-e2e build): real setup()/loop() journeys
  with device-pipeline input injection (boot grace, 0x55 keyboard, GT911
  tap, trackball ISRs), transcript + pixel assertions (HUD, freeze tint)
- shim SerialSim: opt-in transcript ring for test assertions (off by
  default, interactive emulator unchanged)
- make netdeck-test / -unit / -e2e (root) and make test / test-unit /
  test-e2e (emulator/); tests/README.md documents the structure
- STATUS.md: test-structure note

Verified: make netdeck-test -> 14 unit + 7 integration + 3 E2E, 0 failures
This commit is contained in:
Dejvino
2026-11-14 13:02:41 +01:00
parent 383bffc85a
commit a1d0730124
13 changed files with 894 additions and 9 deletions
+31 -2
View File
@@ -45,10 +45,17 @@ LIBS := -lSDL2 -lSDL2_ttf
DEFS += -DAPP_INO='"$(APP).ino"' -DAPP_NAME='"$(APP_TITLE)"'
SHIMS := $(wildcard src/shim/*.h) $(wildcard src/shim/driver/*.h)
SKETCH_SRCS := $(APP_DIR)/$(APP).ino $(wildcard $(APP_DIR)/*.h)
SOUND_SRC := $(wildcard $(APP_DIR)/sound_engine.cpp)
EMU := $(APP)-emu
.PHONY: all run smoke clean
# Headless test binaries (tests/): same single-TU sketch inclusion as
# main.cpp, no window. Unit+integration share one fast binary; E2E is a
# separate build driving the real loop() through the device input pipeline.
TESTS := $(wildcard tests/*.h tests/*.cpp tests/e2e/*.cpp)
TESTS_INC := $(INC) -Itests
.PHONY: all run smoke test test-unit test-e2e clean
all: $(EMU)
@@ -64,5 +71,27 @@ run: $(EMU)
smoke: $(EMU)
./$(EMU) --frames 240 --dump smoke_frame.bmp
# --- tests -----------------------------------------------------------------
# fast layer: unit + integration (deterministic, sim stepped directly)
$(APP)-tests: tests/test_main.cpp tests/shim_globals.cpp tests/harness.h \
tests/sim_helpers.h tests/unit_tests.h tests/integration_tests.h \
$(SHIMS) $(SKETCH_SRCS)
$(CXX) $(CXXFLAGS) $(SDLFLAGS) $(TESTS_INC) $(DEFS) \
tests/shim_globals.cpp tests/test_main.cpp -o $@ $(LIBS)
# slow layer: E2E journeys through the real loop() + input pipeline (own build)
$(APP)-e2e: tests/e2e_tests.cpp tests/shim_globals.cpp tests/harness.h \
tests/sim_helpers.h $(SHIMS) $(SKETCH_SRCS)
$(CXX) $(CXXFLAGS) $(SDLFLAGS) $(TESTS_INC) $(DEFS) \
tests/shim_globals.cpp tests/e2e_tests.cpp -o $@ $(LIBS)
test-unit: $(APP)-tests
./$(APP)-tests unit
test: test-unit
./$(APP)-tests integration
test-e2e: $(APP)-e2e
SDL_VIDEODRIVER=dummy ./$(APP)-e2e
clean:
rm -f $(EMU) smoke_frame.bmp
rm -f $(EMU) $(APP)-tests $(APP)-e2e smoke_frame.bmp