mirror of
https://github.com/mikecarper/MeshCore.git
synced 2026-09-16 07:42:37 +00:00
Skip redundant modulation writes during owned fast RX retunes when the last acknowledged SF/BW/CR/LDRO tuple matches. Invalidate that cache after ordinary setters, failed writes, and lifecycle changes. Include the remaining scan, preamble, settling, and memory-soak experiments, their collectors, validation notes, and original capture records. Preserve capture bytes across checkouts and keep private soak credentials local. Run lab collector and compiled contract tests in CI. Update the expectation, profile mapping, and result-buffer tests for the extended lab tools, and make the private WiFi override header optional for ordinary soak diagnostics. Validation: 145 host tests passed from the staged source snapshot. Clean heltec_v4_repeater and Xiao_S3_WIO_companion_radio_usb builds passed their RAM/flash gates. All 229 staged capture files retain their original bytes; all 75 local documentation links resolve in the clean snapshot.
48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
"""Check firmware-side USB results are immutable, bounded and sequence-scoped."""
|
|
from pathlib import Path
|
|
import unittest
|
|
import test_sx1262_batched_modulation as compiler
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
class UsbResultCacheTests(unittest.TestCase):
|
|
compile_run = compiler.BatchedModulationTests.compile_run
|
|
|
|
def test_cache_replay_never_executes_an_operation(self):
|
|
source = (ROOT / "tools/hil/ProfileSwitchUsb.h").read_text().replace("#pragma once", "")
|
|
harness = r'''
|
|
#include <cassert>
|
|
#include <cstdint>
|
|
#include <cstdio>
|
|
#include <cstring>
|
|
#include <string>
|
|
struct {
|
|
std::string output;unsigned flushes=0;
|
|
void print(const char* text) { output+=text; }
|
|
void println(const char* text) { output+=text;output+='\n'; }
|
|
void flush() { ++flushes; }
|
|
} Serial;
|
|
@SOURCE@
|
|
int main() {
|
|
recordBenchResult(lastTxResult,42,"{\"sent\":%u,\"rc\":0}\n",42u);
|
|
const auto expected=Serial.output;assert(lastTxResult.sequence==42);
|
|
Serial.output.clear();replayBenchResult("sent",42);assert(Serial.output==expected);
|
|
Serial.output.clear();replayBenchResult("sent",43);
|
|
assert(Serial.output.find("unavailable")!=std::string::npos);
|
|
Serial.output.clear();replayBenchResult("listening",42);
|
|
assert(Serial.output.find("unavailable")!=std::string::npos);
|
|
Serial.output.clear();
|
|
recordBenchResult(lastTxResult,43,"%0*d",int(sizeof(lastTxResult.text)),1);
|
|
assert(lastTxResult.sequence==0 && Serial.output.find("overflow")!=std::string::npos);
|
|
Serial.output.clear();replayBenchResult("sent",42);
|
|
assert(Serial.output.find("unavailable")!=std::string::npos);
|
|
assert(Serial.flushes==2);
|
|
}
|
|
'''
|
|
self.compile_run(harness.replace("@SOURCE@", source))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|