mirror of
https://github.com/torlando-tech/pyxis.git
synced 2026-05-20 22:35:08 +00:00
14f937cf8a
Standalone C++ tests of pyxis-unique code (BLE fragmenter/reassembler, peer manager, GATT op queue, LXST ring buffers, audio filters, HDLC framing) plus Python tests of the patch_nimble.py build script. Each C++ test is compiled directly by clang++/g++ with shims in tests/native/ (Bytes.h, Log.h, Utilities/OS.h) so pyxis sources can build without microReticulum's full Arduino/MsgPack dep tree. A pytest wrapper per test compiles, runs, and parses the summary line — the whole suite is one command: `pytest tests/build_scripts tests/native -v`. Total: 13 pytest tests, ~72 underlying C++ assertions, 3.4s. Surfaced an HPF-formula bug in lxst_audio (mirrored upstream in LXST-kt/native_audio_filters.cpp) — filed as LXST-kt#13 and tracked in the corresponding test with a TODO link. CI workflow runs the pyxis pytest suite plus the clean-passing microReticulum native17 unit tests (94/114 of the existing fork test/* suites) on push and PR.
44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
// Native-test shim for microReticulum's Utilities/OS.h.
|
|
//
|
|
// BLEReassembler uses RNS::Utilities::OS::time() to get a wall-clock seconds
|
|
// value for reassembly timeout tracking. The real impl pulls in Arduino /
|
|
// FreeRTOS APIs we don't have natively.
|
|
//
|
|
// For tests we expose a controllable clock so timeout behavior can be
|
|
// exercised deterministically without sleep().
|
|
#pragma once
|
|
|
|
#include <chrono>
|
|
|
|
namespace RNS {
|
|
namespace Utilities {
|
|
|
|
class OS {
|
|
public:
|
|
// If a fake clock has been installed via set_fake_time, return that;
|
|
// otherwise return monotonic seconds since the program started.
|
|
static double time() {
|
|
if (_fake_time_set) return _fake_time;
|
|
using clk = std::chrono::steady_clock;
|
|
static const auto t0 = clk::now();
|
|
auto now = clk::now();
|
|
return std::chrono::duration<double>(now - t0).count();
|
|
}
|
|
|
|
static void set_fake_time(double seconds) {
|
|
_fake_time = seconds;
|
|
_fake_time_set = true;
|
|
}
|
|
|
|
static void clear_fake_time() {
|
|
_fake_time_set = false;
|
|
}
|
|
|
|
private:
|
|
inline static double _fake_time = 0.0;
|
|
inline static bool _fake_time_set = false;
|
|
};
|
|
|
|
} // namespace Utilities
|
|
} // namespace RNS
|