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:
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @file test_main.cpp
|
||||
* @brief Runner for the fast headless suites: unit + integration.
|
||||
*
|
||||
* The sketch is included as a single translation unit (the same trick the
|
||||
* emulator host uses), which gives the tests direct access to the sketch's
|
||||
* internal statics — no refactor needed to make the game testable.
|
||||
*
|
||||
* Deterministic: no wall-clock waits (tests step the 20 Hz sim tick by tick)
|
||||
* and a fixed RNG seed. Rendering and pixel assertions belong to the E2E
|
||||
* binary (e2e_tests.cpp).
|
||||
*/
|
||||
#include "harness.h"
|
||||
|
||||
// pull in the whole sketch as a single translation unit (-DAPP_INO)
|
||||
#include APP_INO
|
||||
|
||||
#include "unit_tests.h"
|
||||
#include "integration_tests.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// optional filter: ./NetDeck-tests unit | ./NetDeck-tests int
|
||||
const char *filter = argc > 1 ? argv[1] : nullptr;
|
||||
|
||||
test::captureSerial();
|
||||
std::srand(0xC0FFEE);
|
||||
|
||||
int run = 0;
|
||||
for (const auto &c : test::cases()) {
|
||||
if (filter && std::strncmp(c.name, filter, std::strlen(filter)) != 0)
|
||||
continue;
|
||||
test::g_current = c.name;
|
||||
size_t slash = test::g_current.find('/');
|
||||
test::g_group = slash == std::string::npos ? "" : test::g_current.substr(0, slash);
|
||||
std::printf("RUN %s\n", c.name);
|
||||
c.fn();
|
||||
run++;
|
||||
}
|
||||
|
||||
std::printf("\n%s: %d test%s, %d failure%s\n",
|
||||
run ? "DONE" : "NO TESTS MATCHED FILTER",
|
||||
run, run == 1 ? "" : "s",
|
||||
test::g_failures, test::g_failures == 1 ? "" : "s");
|
||||
return (run > 0 && test::g_failures == 0) ? 0 : 1;
|
||||
}
|
||||
Reference in New Issue
Block a user