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:
@@ -232,11 +232,27 @@ inline int xTaskCreatePinnedToCore(void (*fn)(void *), const char *, unsigned, v
|
||||
// ---------------------------------------------------------------------------
|
||||
struct SerialSim {
|
||||
void begin(unsigned long) {}
|
||||
template <typename... A> void printf(const char *fmt, A... a) { std::printf(fmt, a...); }
|
||||
void println() { std::printf("\n"); }
|
||||
void println(const char *s) { std::printf("%s\n", s); }
|
||||
void println(const String &s) { std::printf("%s\n", s.c_str()); }
|
||||
void println(int v) { std::printf("%d\n", v); }
|
||||
// Test support: when sink is non-null, every printed chunk is ALSO
|
||||
// captured there (bounded ring) so headless tests can assert on the
|
||||
// transcript. The interactive emulator leaves it null — zero overhead.
|
||||
std::deque<std::string> *sink = nullptr;
|
||||
void capture(const char *s)
|
||||
{
|
||||
if (!sink) return;
|
||||
sink->push_back(s);
|
||||
while (sink->size() > 512) sink->pop_front();
|
||||
}
|
||||
template <typename... A> void printf(const char *fmt, A... a)
|
||||
{
|
||||
char buf[512];
|
||||
std::snprintf(buf, sizeof(buf), fmt, a...);
|
||||
std::fputs(buf, stdout);
|
||||
capture(buf);
|
||||
}
|
||||
void println() { std::printf("\n"); capture("\n"); }
|
||||
void println(const char *s) { std::printf("%s\n", s); capture(s); capture("\n"); }
|
||||
void println(const String &s) { std::printf("%s\n", s.c_str()); capture(s.c_str()); capture("\n"); }
|
||||
void println(int v) { std::printf("%d\n", v); capture(std::to_string(v).c_str()); capture("\n"); }
|
||||
void setDebugOutput(bool) {}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user