Files
HaloKeymind/test/test_profile_rollback.py
T
mikecarper 091c8d8324 Preserve radio lab experiments and reuse unchanged SX1262 modulation
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.
2026-09-14 22:34:17 -07:00

41 lines
1.8 KiB
Python

"""HIL rollback preserves production ownership and ordinary standby semantics."""
from pathlib import Path
import unittest
from test_radio_receive_contract import method
import test_sx1262_batched_modulation as compiler
ROOT=Path(__file__).resolve().parents[1]
class RollbackTests(unittest.TestCase):
compile_run=compiler.BatchedModulationTests.compile_run
def test_warm_rollback_only_suppresses_request(self):
source=(ROOT/'tools/hil/profile_switch.cpp').read_text()
body=method(source,'void setProfileStandbyWarm(')
self.compile_run(r'''
#include <cassert>
struct CustomSX1262Wrapper { bool requested=false;virtual void setProfileStandbyWarm(bool v){requested=v;} };
struct Bench:CustomSX1262Wrapper { bool warmStandby=true; @METHOD@ };
int main(){for(bool policy:{false,true})for(bool request:{false,true}){
Bench b;b.warmStandby=policy;b.setProfileStandbyWarm(request);assert(b.requested==(policy&&request));
}}
'''.replace('#include <cassert>','#include <cassert>\n#include <initializer_list>').replace('@METHOD@',body))
def test_rollback_never_bypasses_hop_ownership_or_busy_checks(self):
source=(ROOT/'tools/hil/profile_switch_channels.h').read_text()
start=method(source,'void startChannelSweep(')
for control in ('(channelRollback & 9)==0','(channelRollback & 4)==0',
'(channelRollback & 2)==0','(channelRollback & 8)==0'):
self.assertIn(control,start)
service=method(source,'void serviceChannelSweep(')
self.assertIn('driver.hop(slot)',service)
self.assertIn('rc==mesh::RadioParamApplyResult::BUSY',service)
self.assertIn('!waitBusy()',service)
self.assertIn('rfWordAtRead=channelTrace.rfWord',service)
self.assertIn('payloadValid && bytes[8]==channelSweep.current',service)
if __name__=='__main__':
unittest.main()