Files
ducoterra 9bc8d5213c Initial import: keyrelay, a WiFi-controlled USB HID keyboard
Browser or terminal controller drives an ESP32-S3 that acts as a Logitech
G815 into a target machine running no software. Disarmed by default; arming
requires the passphrase, the board button, or the serial console, and every
fail-safe path cancels in-flight work.

- src/: firmware with pure, host-testable modules (keystate, proto, text,
  ws_codec, sha1), the WebSocket control server, and the served page
- tests/: host suites for the pure modules, relayctl parity, and page JS
- tools/: relayctl terminal controller, serial console, bootloader helper,
  and an evdev target watcher
- platformio.ini: bridge (USB HID) and console (no-HID) environments
- README.md: single source of truth for behaviour, protocol and safety

LLM-Generated: true
2026-11-08 00:20:33 -05:00

50 lines
2.7 KiB
C++

// Minimal assertion harness for the host tests. No dependencies, prints the
// failing expression with file:line, and exits non-zero on any failure so
// tests/run_tests.sh is usable as a gate.
#pragma once
#include <cstdio>
#include <cstring>
static int g_checks = 0;
static int g_failures = 0;
static const char *g_section = "unset";
#define CASE(name) (g_section = (name))
#define CHECK(cond) \
do { \
g_checks++; \
if (!(cond)) { \
g_failures++; \
std::printf(" FAIL %s:%d [%s] %s\n", __FILE__, __LINE__, \
g_section, #cond); \
} \
} while (0)
#define CHECK_EQ(actual, expected) \
do { \
g_checks++; \
const long long _a = (long long)(actual), _e = (long long)(expected); \
if (_a != _e) { \
g_failures++; \
std::printf(" FAIL %s:%d [%s] %s == %s : got %lld, want %lld\n", __FILE__, \
__LINE__, g_section, #actual, #expected, _a, _e); \
} \
} while (0)
#define CHECK_STR(actual, expected) \
do { \
g_checks++; \
if (std::strcmp((actual), (expected)) != 0) { \
g_failures++; \
std::printf(" FAIL %s:%d [%s] %s == %s : got \"%s\", want \"%s\"\n", \
__FILE__, __LINE__, g_section, #actual, #expected, (actual), \
(expected)); \
} \
} while (0)
static int report(const char *suite) {
std::printf("%-24s %3d checks, %d failures\n", suite, g_checks, g_failures);
return g_failures == 0 ? 0 : 1;
}