- 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
97 lines
3.4 KiB
Makefile
97 lines
3.4 KiB
Makefile
# SDL2 emulator for T-Deck example sketches (run the app on your PC)
|
|
#
|
|
# make build the MissileCommand emulator (default)
|
|
# make APP=CrtTerminal build the CRT terminal emulator
|
|
# make run [APP=...] build + launch the window
|
|
# make smoke [APP=...] headless test: N frames, dump the last frame
|
|
# make clean [APP=...] remove the binary + smoke frame
|
|
#
|
|
# The sketch is included by src/main.cpp as a single translation unit:
|
|
# -DAPP_INO='"<App>.ino"'. Apps with a sound_engine.cpp get it linked
|
|
# automatically (wildcard).
|
|
|
|
APP ?= MissileCommand
|
|
APP_DIR := ../examples/$(APP)
|
|
|
|
ifeq ($(APP),MissileCommand)
|
|
APP_TITLE := Missile Command
|
|
DEFS += -DEMU_APP_MISSILECOMMAND
|
|
endif
|
|
ifeq ($(APP),CrtTerminal)
|
|
APP_TITLE := CRT Terminal
|
|
endif
|
|
ifeq ($(APP),NetDeck)
|
|
APP_TITLE := NetDeck // Breach & Board
|
|
# the sketch moved to src/netdeck (next to nd_layout.h); its hardware
|
|
# shim header utilities.h stays with the pio project in examples/NetDeck
|
|
APP_DIR := ../src/netdeck
|
|
APP_EXTRA_INC := ../examples/NetDeck
|
|
endif
|
|
ifeq ($(APP),Lotus3)
|
|
APP_TITLE := Lotus 3
|
|
DEFS += -DEMU_APP_LOTUS3
|
|
ifdef AUTOPLAY
|
|
DEFS += -DAUTOPLAY
|
|
endif
|
|
endif
|
|
APP_TITLE ?= $(APP)
|
|
|
|
CXX ?= g++
|
|
CXXFLAGS ?= -std=gnu++17 -O2 -Wall -Wextra
|
|
SDLFLAGS := -I/usr/include/SDL2
|
|
INC := -Isrc/shim -I$(APP_DIR) $(if $(APP_EXTRA_INC),-I$(APP_EXTRA_INC))
|
|
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
|
|
|
|
# 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)
|
|
|
|
$(EMU): src/main.cpp $(SOUND_SRC) $(APP_DIR)/$(APP).ino $(SHIMS)
|
|
$(CXX) $(CXXFLAGS) $(SDLFLAGS) $(INC) $(DEFS) \
|
|
src/main.cpp $(SOUND_SRC) -o $@ $(LIBS)
|
|
|
|
run: $(EMU)
|
|
./$(EMU)
|
|
|
|
# Headless smoke test: dummy video/audio, run N frames, save the last frame.
|
|
# Feed keys via --type "text" (queued a few chars per frame).
|
|
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) $(APP)-tests $(APP)-e2e smoke_frame.bmp
|