From f973e4a952e85cfd614013ab60f4cb3f1e8f129b Mon Sep 17 00:00:00 2001 From: mikecarper Date: Wed, 28 Oct 2026 04:26:03 -0700 Subject: [PATCH] Keep native Companion fixtures aligned with shared control dispatch --- test/test_companion_fleet_control.py | 18 +++++++++++++++--- test/test_companion_tx_raw_alias.py | 3 +++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/test/test_companion_fleet_control.py b/test/test_companion_fleet_control.py index be9748435..e83a02fea 100644 --- a/test/test_companion_fleet_control.py +++ b/test/test_companion_fleet_control.py @@ -27,6 +27,7 @@ HARNESS = r''' #include #include #include +#include #include #include "regulator_cli_stub.h" #include "usb_mode_console.h" @@ -230,6 +231,7 @@ class MyMesh : public mesh::Mesh { bool sendFleetCommandData(GroupChannel&, const uint8_t*, size_t); void onRadioProfileCopyQueued(mesh::Packet*, const mesh::Packet*, uint8_t); bool handleCommand(const char* command, uint32_t sender_timestamp, char* reply); + bool handleLocalControlCommand(const char*, char*, size_t); void checkCLIRescueCmd(); void enterCLIRescue(); void resetUsbHostSessionInput(); @@ -1299,7 +1301,16 @@ class CompanionFleetControlTests(unittest.TestCase): fleet_end = function.index(" if (mesh::handleMorseReplyCommand", fleet_start) # Keep the actual compile guard as well as its complete branch so # compact profiles prove that none of the fleet dependencies survive. - cls.production = prefix + function[fleet_start:fleet_end] + "\n return false;\n}\n" + # The local-control route follows the fleet/radio branches. Retain + # its real dispatcher and USB-mode prefix without the other local + # command families' unrelated board/filesystem dependencies. + local_dispatch = " if (handleLocalControlCommand(command, reply, reply_capacity)) return true;" + assert function.count(local_dispatch) == 1 + local = body(source, "bool MyMesh::handleLocalControlCommand(") + cls.local_control = local[:local.index("#if defined(ESP32_PLATFORM) && defined(WIFI_SSID)")] + cls.local_control += "\n return false;\n}\n" + cls.production = (prefix + function[fleet_start:fleet_end] + local_dispatch + + "\n return false;\n}\n") cls.work = tempfile.TemporaryDirectory(prefix="meshcore-fleet-companion-") work = Path(cls.work.name) cls.binary = work / "companion-fleet" @@ -1334,7 +1345,7 @@ class CompanionFleetControlTests(unittest.TestCase): assert enter.count(banner) == 1 enter = enter.replace(banner, 'mesh::usbTerminalPort().print("========= CLI Rescue =========\\n");') cls.fixture = fixture - fixture.write_text(HARNESS.replace("@METHOD@", cls.production) + fixture.write_text(HARNESS.replace("@METHOD@", cls.production + cls.local_control) .replace("@USB_INPUT_RESERVED@", body( (ROOT / "src/helpers/HostKiss.cpp").read_text(), "bool usbInputReserved(")) @@ -1524,6 +1535,7 @@ static_assert(MESH_ENABLE_FLEET_CONTROL == 0, "compact profile must disable flee class MyMesh { public: bool handleCommand(const char*, uint32_t, char*); + bool handleLocalControlCommand(const char*, char*, size_t); }; @METHOD@ int main() { @@ -1536,7 +1548,7 @@ int main() { ''' work = Path(self.work.name) source = work / "disabled.cpp" - source.write_text(harness.replace("@METHOD@", self.production)) + source.write_text(harness.replace("@METHOD@", self.production + self.local_control)) for profile, flags in (("stm32-default", ["-DSTM32_PLATFORM=1"]), ("explicit-disable", ["-DMESH_ENABLE_FLEET_CONTROL=0"])): with self.subTest(profile=profile): diff --git a/test/test_companion_tx_raw_alias.py b/test/test_companion_tx_raw_alias.py index b1342b6be..3753fed41 100644 --- a/test/test_companion_tx_raw_alias.py +++ b/test/test_companion_tx_raw_alias.py @@ -63,6 +63,9 @@ public: bool setChannel(int, const ChannelDetails&); }; class MyMesh : public BaseChatMesh, public DataStoreHost {""") + # The publication-only fixture aliases its simplified channel owner. This + # fixture supplies the real base accessors and must retain that base name. + code = replace_once(code, " using BaseChatMesh = MyMesh;\n", "") code = replace_once(code, " bool writable=true, writes_ok=true; unsigned writes=0;", """ struct { bool enabled = false; } _ethernet_settings; bool writable=true, writes_ok=true; unsigned writes=0;""")