From 5cf42d0ca19f11df2829427eb0852199e00668eb Mon Sep 17 00:00:00 2001 From: mikecarper Date: Sat, 17 Oct 2026 14:14:09 -0700 Subject: [PATCH] Update host harnesses for current radio and sleep policy --- test/test_beacon_radio.py | 6 ++++-- test/test_esp32_hwcdc_recipes.py | 11 ++++++++--- test/test_usb_logging_watchdog_roles.py | 3 ++- test/test_wireless_control.py | 3 ++- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/test/test_beacon_radio.py b/test/test_beacon_radio.py index 206c4bf10..bb6f28322 100644 --- a/test/test_beacon_radio.py +++ b/test/test_beacon_radio.py @@ -85,6 +85,7 @@ struct RadioLibWrapper { bool _cw_active = false, pending = false, packet = false, busy = false, calibrating = false; bool _rx_ps_enabled = false, _rx_ps_armed = false, _rx_hold_continuous = false; bool _rx_ps_continuous_fallback = false, _nf_calib_active = false; + bool _nf_refresh_requested = false; bool _rx_boosted_gain_valid = true, _cur_rx_boosted_gain = true; bool _noise_floor_valid = true, _noise_floor_secondary_valid = true; bool _wd_last_busy = false; @@ -162,7 +163,7 @@ struct RadioLibWrapper { } void doResetAGC() { ++resets; } bool isPacketPendingOrReceiving() { return hasPendingRadioInterrupt() || isReceivingPacket(); } - bool resetAGCIfIdle(); + bool resetAGCIfIdle(bool refresh_floor = true); void resetAGC(); void idle() { modem.standby(); state = STATE_IDLE; } uint8_t beginReconfigure(); @@ -209,6 +210,7 @@ int main() { assert(w.beginReconfigure() == 2); w.startRecv(); assert(w.arms == 0); assert(w.recoverRadio(true) == false && w.deep_calls == 0); + assert(!w.resetAGCIfIdle(false) && w.resets == 0 && w.recalibrations == 0); assert(!w.isBeaconChannelBusy() && !w.pending && w.state == STATE_IDLE); assert(w.restoreBeaconReceive() == Result::APPLIED); assert(!w._beacon_owned && w.state == STATE_RX && w._rx_ps_armed == rxps); @@ -342,7 +344,7 @@ class BeaconRadioTest(unittest.TestCase): "uint8_t RadioLibWrapper::beginReconfigure()", "bool RadioLibWrapper::restoreAfterDeepInit()", "bool RadioLibWrapper::recoverRadio(bool hard)", - "bool RadioLibWrapper::resetAGCIfIdle()", + "bool RadioLibWrapper::resetAGCIfIdle(bool refresh_floor)", "void RadioLibWrapper::resetAGC()", "void RadioLibWrapper::startRecv()", "bool RadioLibWrapper::startSendRaw(const uint8_t* bytes, int len)", diff --git a/test/test_esp32_hwcdc_recipes.py b/test/test_esp32_hwcdc_recipes.py index 284536ccd..43686f8bc 100644 --- a/test/test_esp32_hwcdc_recipes.py +++ b/test/test_esp32_hwcdc_recipes.py @@ -368,16 +368,21 @@ class Esp32HwcdcRecipeTests(unittest.TestCase): self.assertEqual(counts, expected) def test_non_esp32_recipes_do_not_acquire_esp32_usb_selectors(self): - count = 0 + checked = set() for name, row in self.rows.items(): if row["esp32"]: continue with self.subTest(environment=name): - count += 1 + checked.add(name) self.assertEqual(row["values"], {USB_MODE: "0", USB_CDC: "0"}) self.assertFalse(self.sdk["hwcdc_primary_enabled"](row["env"])) self.assertFalse(self.sdk["native_primary_enabled"](row["env"])) - self.assertEqual(count, 323) + # Every current non-ESP32 recipe is checked above, including newly + # added boards. Keep representative architecture coverage explicit + # rather than pinning an unrelated, ever-growing environment count. + self.assertTrue({"RAK_3x72_companion_radio_usb", + "Xiao_nrf52_companion_radio_usb", + "PicoW_companion_radio_usb"} <= checked) def test_only_existing_partition_diagnostics_keep_their_cdc_override(self): # These two pre-existing diagnostic recipes intentionally select CDC1 diff --git a/test/test_usb_logging_watchdog_roles.py b/test/test_usb_logging_watchdog_roles.py index bb2817223..0346a93af 100644 --- a/test/test_usb_logging_watchdog_roles.py +++ b/test/test_usb_logging_watchdog_roles.py @@ -289,7 +289,8 @@ class UsbLoggingWatchdogRoleTests(unittest.TestCase): self.assertIn('if (mesh::isUsbLoggingWatchdogArmed()) ' 'return mask(Reason::UsbRecovery);', guard) self.assertIn('const bool can_sleep = sleep_reason == 0;', loop) - self.assertLess(loop.index(guard), loop.index('if (can_sleep)')) + self.assertLess(loop.index(guard), loop.index( + 'if (can_sleep && the_mesh.canIdleDualRadio())')) else: self.assertIn('!mesh::isUsbLoggingWatchdogArmed()', loop) diff --git a/test/test_wireless_control.py b/test/test_wireless_control.py index 3833c0572..a93e6d538 100644 --- a/test/test_wireless_control.py +++ b/test/test_wireless_control.py @@ -307,7 +307,8 @@ int main(){ self.assertIn('if (mesh::wireless::control().pending()) ' 'return mask(Reason::Wireless);', guard) self.assertIn('const bool can_sleep = sleep_reason == 0;', loop) - self.assertLess(loop.index(guard), loop.index('if (can_sleep)')) + self.assertLess(loop.index(guard), loop.index( + 'if (can_sleep && the_mesh.canIdleDualRadio())')) else: self.assertIn('&& sleep_guard(!mesh::wireless::control().pending(), ' 'mesh::powerdiag::Reason::Wireless)', loop)