Files
bfebbx/tests/test_naming.cpp
Kyle Isom b6d3eaad82 Implement bfebbx: Betaflight blackbox extractor
Cross-platform (macOS + Linux) C++17 CLI that extracts a Betaflight FC's
blackbox log in one command: auto-detect the serial port, read craft_name
over the Betaflight CLI, send `msc` to reboot into USB mass storage, wait
for the volume to mount, copy btfl_all.bbl to
<craft_name>_<YYYYMMDD>_<HHMMSS>.bbl, and eject.

Native throughout (termios serial, getmntinfo/proc-mounts mount detection,
DiskArbitration/umount eject); the only subprocess is the Linux udisksctl
eject fallback. Includes CMake/ctest build, unit tests for the pure logic
(naming, craft_name parsing, mount diff, serial via pty, CLI parsing),
README with a manual hardware integration procedure, and design/plan docs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 15:13:17 -07:00

29 lines
791 B
C++

#include "../src/naming.h"
#include <cassert>
#include <ctime>
#include <string>
int main() {
using namespace bfebbx;
// sanitizeCraftName
assert(sanitizeCraftName("My Quad!") == "My_Quad_");
assert(sanitizeCraftName("vroom-5.inch") == "vroom-5.inch");
assert(sanitizeCraftName("a/b\\c:d") == "a_b_c_d");
assert(sanitizeCraftName("") == "");
// buildFilename — construct a known local time and round-trip it
std::tm tm{};
tm.tm_year = 2026 - 1900;
tm.tm_mon = 6; // July (0-based)
tm.tm_mday = 22;
tm.tm_hour = 14;
tm.tm_min = 30;
tm.tm_sec = 5;
tm.tm_isdst = -1;
std::time_t t = std::mktime(&tm); // interprets tm as local time
assert(buildFilename("vroom", t) == "vroom_20260722_143005.bbl");
return 0;
}