diff --git a/test/fixtures/companion_delayed_reply_delivery/test.cpp b/test/fixtures/companion_delayed_reply_delivery/test.cpp index 1e7b1ff48..bd8b10820 100644 --- a/test/fixtures/companion_delayed_reply_delivery/test.cpp +++ b/test/fixtures/companion_delayed_reply_delivery/test.cpp @@ -17,6 +17,9 @@ #include #include +// This fixture models correlated RF replies. Direct USB OTA administration +// has a separate fixture and is disabled for every consumer of this harness. +#define COMPANION_FEATURE_DIRECT_OTA_ADMIN 0 #define MESH_DEBUG_PRINTLN(...) ((void)0) #include "production_constants.inc" #include "production_stream.inc" diff --git a/test/fixtures/morse_main_loop.cpp b/test/fixtures/morse_main_loop.cpp index d26ff575e..da6f1fb93 100644 --- a/test/fixtures/morse_main_loop.cpp +++ b/test/fixtures/morse_main_loop.cpp @@ -109,6 +109,7 @@ bool profileIdleSleepAllowed() { && (!the_mesh.isDualRadioActive() || (profileIdleQueryAllowed() && the_mesh.profile_idle_allowed)); } void serviceCommandInterfaces() { ++command_services; } +bool serviceCompanionHostKissUsb() { return false; } void serviceUsbLoggingOnlySession() { ++usb_services; } void serviceUsbTerminalHostSessionReset() { ++usb_services; } void serviceUsbAsciiSessionDefault() { ++usb_services; } diff --git a/test/test_carrier_wave.py b/test/test_carrier_wave.py index 2d95018bc..6da7c13a0 100644 --- a/test/test_carrier_wave.py +++ b/test/test_carrier_wave.py @@ -141,6 +141,7 @@ struct RadioLibWrapper : mesh::Radio { uint32_t rssi_latency=0; unsigned rssi_reads=0; bool _params_valid=true, _rx_ps_armed=true, _rx_hold_continuous=false; + bool _primary_receive_preempt=false; bool _rx_boosted_gain_valid=false, _cur_rx_boosted_gain=false, _rx_boosted_gain_applied=false; bool rx_gain_apply_ok=true, physical_rx_gain=false; unsigned rx_gain_applies=0,rx_gain_order=0; @@ -212,6 +213,7 @@ struct RadioLibWrapper : mesh::Radio { #endif virtual bool supportsRadioDeepInit() const { return deep_supported; } uint8_t beginReconfigure(); + void noteReconfigureAdmission(const char*, int16_t) {} void endReconfigure(bool resume) { if (resume) startRecv(); } bool isChipBusy() { return busy; } bool isReceivingPacket() { return packet; } diff --git a/test/test_cli_settings_contract.py b/test/test_cli_settings_contract.py index 6dfe8c0c1..d660eed2c 100644 --- a/test/test_cli_settings_contract.py +++ b/test/test_cli_settings_contract.py @@ -269,9 +269,11 @@ namespace mesh { struct Utils { 'flash.health', # Read-only flash health diagnostics 'key.backup.transport', # Identity-backup transport capability 'mqtt', 'mqtt.running', # MQTT connection status + 'ota.direct', # Direct USB OTA session diagnostics 'password', 'prv.key', # Local secret/identity reads 'public.key', # Read-only public identity 'pwrmgt.bootreason', 'role', # Boot/build facts + 'radio.apply', # Pending/applied radio diagnostics 'radio.rxps.config', # Detail view of radio.rxps 'tx.status', # HIL-only applied-power verification 'wifi.status', 'wifi.ip', # Live WiFi link state diff --git a/test/test_companion_ota_includes.py b/test/test_companion_ota_includes.py index 9a01bc510..8d2039ebc 100644 --- a/test/test_companion_ota_includes.py +++ b/test/test_companion_ota_includes.py @@ -54,6 +54,14 @@ class CompanionOtaIncludeTest(unittest.TestCase): (directory / "MyMesh.h").write_text( '#pragma once\n#include "CompanionFeatures.h"\n' ) + # Host KISS declares its filesystem boundary in Full images. Keep + # that SDK type visible without pulling a board filesystem into + # this include-only test of the real OTA headers. + identity = directory / "helpers/IdentityStore.h" + identity.write_text( + "#pragma once\nclass IncludeTestFilesystem;\n" + "#define FILESYSTEM IncludeTestFilesystem\n" + ) if not (usb or ble): # Prove that small/non-OTA images do not gain these dependencies. for header in ("MotaSourceSerial.h", "OtaContext.h"): diff --git a/test/test_companion_usb_default.py b/test/test_companion_usb_default.py index 43eeba0c8..555d3bcc2 100644 --- a/test/test_companion_usb_default.py +++ b/test/test_companion_usb_default.py @@ -68,6 +68,7 @@ static constexpr unsigned USB_HOST_LOSS_EDGE_MS = 100, USB_HOST_LOSS_GRACE_MS = struct Stream { int pending = 0; int available() const { return pending; } + int peek() const { return pending > 0 ? 'x' : -1; } int read() { return pending-- > 0 ? 'x' : -1; } void print(const char*) {} } usb_stream; diff --git a/test/test_ota_folder_ready.py b/test/test_ota_folder_ready.py index eaac88266..f36f63409 100644 --- a/test/test_ota_folder_ready.py +++ b/test/test_ota_folder_ready.py @@ -21,6 +21,9 @@ class OtaFolderReadyTest(unittest.TestCase): self.assertIsNotNone(match) defines.append("#define " + name + " " + match[1]) source = (ROOT / "test/fixtures/ota_folder_ready.cpp").read_text(encoding="ascii") + # This folder-readiness fixture has no competing raw USB host session. + # Keep the real Arduino declaration visible to MotaSourceSerial.cpp. + source += "\nnamespace mesh { bool isUsbBinaryStreamOwned() { return false; } }\n" source = source.replace("// @PRODUCTION_DEFINES@", "\n".join(defines)) ready = extract_braced(production, "if (ota::ota_ctx().manager.takeSourceReadyAnnouncement())") source = source.replace("// @PRODUCTION_READY@", "" if missing_ready_trigger else ready) @@ -38,7 +41,8 @@ class OtaFolderReadyTest(unittest.TestCase): with self.subTest(definitions=definitions): sources = ("OtaManager.cpp", "OtaProtocol.cpp", "MotaContainer.cpp", "MerkleTree.cpp", "MotaSourceSerial.cpp") result = subprocess.run([compiler, "-std=c++17", "-O1", *sanitizers, - "-DENABLE_OTA=1", "-DOTA_SEEDER_ONLY=1", *["-D" + value for value in definitions], + "-DARDUINO=10819", "-DENABLE_OTA=1", "-DOTA_SEEDER_ONLY=1", + *["-D" + value for value in definitions], "-I", str(ROOT / "src"), "-I", str(ROOT / "test/mocks"), str(cpp), *[str(ROOT / "src/helpers/ota" / name) for name in sources], str(ROOT / "src/Utils.cpp"), "-o", str(executable)], capture_output=True, text=True, timeout=90) diff --git a/test/test_ota_source_proofs.py b/test/test_ota_source_proofs.py index 42cca597f..526fc5012 100644 --- a/test/test_ota_source_proofs.py +++ b/test/test_ota_source_proofs.py @@ -73,6 +73,8 @@ static_assert(OTA_PROOFGEN_SCRATCH / 4 == 4095, "odd byte limit lost usable leaf #include #include using namespace mesh::ota; +// This serial-source capacity test has no competing USB stream owner. +namespace mesh { bool isUsbBinaryStreamOwned() { return false; } } @FAKE@ class MtuSource : public SerialMotaSource { public: @@ -110,7 +112,7 @@ int main() { built = subprocess.run([ os.environ.get("CXX", "g++"), "-std=c++17", "-fsanitize=address,undefined", "-fno-sanitize-recover=all", "-fno-pie", "-no-pie", - "-DESP32_PLATFORM=1", "-DCOMPANION_RADIO_FULL=1", + "-DARDUINO=10819", "-DESP32_PLATFORM=1", "-DCOMPANION_RADIO_FULL=1", "-I", str(ROOT / "src"), "-I", str(ROOT / "test/mocks"), str(source), str(ROOT / "src/helpers/ota/MotaSourceSerial.cpp"), "-o", str(binary), ], capture_output=True, text=True, timeout=60) diff --git a/test/test_rp2040_application_capabilities.py b/test/test_rp2040_application_capabilities.py index 7eb16fb48..50218305f 100644 --- a/test/test_rp2040_application_capabilities.py +++ b/test/test_rp2040_application_capabilities.py @@ -171,6 +171,7 @@ class RP2040ApplicationCapabilityTests(unittest.TestCase): set -euo pipefail source build.sh pio() { echo 'PlatformIO must not run' >&2; return 99; } +PIO_CONFIG_JSON='[]' PIO_BUILD_DIR_OVERRIDE=@BUILD@ OUTPUT_DIR=@OUTPUT@ BUILD_PROFILE_FOR_TARGET=auto diff --git a/test/test_t096_message_footer_profile.py b/test/test_t096_message_footer_profile.py index af2ce85e0..43640586b 100644 --- a/test/test_t096_message_footer_profile.py +++ b/test/test_t096_message_footer_profile.py @@ -54,6 +54,7 @@ class T096MessageFooterProfileTest(unittest.TestCase): for display_class in ( "SH1106Display", "SSD1306Display", + "HeltecV4Display", "ST7735Display", "U8g2Display", ): @@ -103,6 +104,7 @@ class T096MessageFooterProfileTest(unittest.TestCase): for display_class in ( "SH1106Display", "SSD1306Display", + "HeltecV4Display", "ST7735Display", "U8g2Display", ): @@ -127,7 +129,7 @@ class T096MessageFooterProfileTest(unittest.TestCase): self.assertNotIn("MESHCORE_HAS_REAL_DISPLAY", null_macros) self.assertNotIn("MESHCORE_HAS_SMALL_DISPLAY", null_macros) - def test_v4_oled_is_compact_but_v4_tft_is_not(self): + def test_v4_display_aliases_share_the_unified_compact_driver(self): profile = V4_PROFILE.read_text(encoding="utf-8") usb = profile.split( "[env:heltec_v4_companion_radio_usb_femon]", 1 @@ -136,9 +138,9 @@ class T096MessageFooterProfileTest(unittest.TestCase): "[env:heltec_v4_tft_companion_radio_usb_femon]", 1 )[1].split("[", 1)[0] self.assertIn("extends = heltec_v4_oled", usb) - self.assertIn("DISPLAY_CLASS=SSD1306Display", usb) + self.assertIn("DISPLAY_CLASS=HeltecV4Display", usb) self.assertIn("extends = heltec_v4_tft", tft_usb) - self.assertIn("DISPLAY_CLASS=ST7789LCDDisplay", tft_usb) + self.assertIn("DISPLAY_CLASS=HeltecV4Display", tft_usb) if __name__ == "__main__": diff --git a/test/test_usb_logging_hwcdc_watchdog.py b/test/test_usb_logging_hwcdc_watchdog.py index 03cea3705..7fbf1414f 100644 --- a/test/test_usb_logging_hwcdc_watchdog.py +++ b/test/test_usb_logging_hwcdc_watchdog.py @@ -43,13 +43,24 @@ class HwcdcLoggingWatchdogTests(unittest.TestCase): cls.companion_methods = "\n".join(body(companion, signature) for signature in ( "static void clearUsbTerminalLine()", "static void cancelUsbSerialOperations()", "static void resetUsbTerminalHostSession()", "static void serviceUsbTerminalHostSessionReset()")) - cls.ordinary_methods = "" + # There is no functional text backlog in the peripheral fake. Keep + # the actual role calls and subsequent session-completion gate below. + cls.ordinary_methods = "namespace mesh { void serviceUsbTerminalPort() {} }\n" for role in ("simple_repeater", "simple_room_server", "simple_sensor"): text = (ROOT / "examples" / role / "main.cpp").read_text() - start = text.index(" if (mesh::takeUsbTerminalSessionReset())") + # The reset body now contains nested feature guards. Extract the + # complete compound statement, preserving every guarded operation. + reset = body(text, " if (mesh::takeUsbTerminalSessionReset())") + start = text.index(" if (usb_ready) mesh::serviceUsbTerminalPort();") stop = text.index("\n#endif", start) + completion = text[start:stop] + # This separate block follows optional KISS admission in the real + # loop. Do not silently truncate it if nested guards are added. + assert "#if" not in completion + assert "mesh::tryCompleteUsbTerminalSessionReset()" in completion cls.ordinary_methods += ("static void service_" + role + "() {\n" - " bool usb_ready = true;\n" + text[start:stop] + "\n (void)usb_ready;\n}\n") + " bool usb_ready = true;\n" + reset + "\n" + completion + + "\n (void)usb_ready;\n}\n") cls.binaries = {(backport, ota): cls.compile_backend(backport, ota) for backport in (0, 1) for ota in (False, True)} diff --git a/test/test_usb_logging_watchdog_roles.py b/test/test_usb_logging_watchdog_roles.py index 8b29ead50..84f3d5d4a 100644 --- a/test/test_usb_logging_watchdog_roles.py +++ b/test/test_usb_logging_watchdog_roles.py @@ -30,6 +30,10 @@ namespace mesh { struct Status {bool reader_connected=true, stalled=false;}; static Status status; Status usbLoggingStatus(){return status;} + namespace hostkiss { + static bool usb_active=false; + bool usbActive(){return usb_active;} + } } struct Store { bool dirty=false; @@ -91,6 +95,7 @@ bool isUsbTerminalDataConnected(){return usb_connected;} void reset(){ board=Board{};radio_driver=RadioDriver{};mesh::status=mesh::Status{}; + mesh::hostkiss::usb_active=false; the_mesh=RoleMesh{}; // Assignment copies the fixture's dependency pointers; point them back at // the live fixture objects, not the temporary used to reset scalar state. @@ -243,6 +248,13 @@ class UsbLoggingWatchdogRoleTests(unittest.TestCase): the_mesh._serial=&the_mesh.serial; ''' companion_checks = r''' + // A host KISS session owns the same physical USB transport regardless of + // the logging reader, terminal feature or ordinary Companion USB mode. + for(unsigned state=0;state<3;++state){ + reset();mesh::status.reader_connected=state!=1;mesh::status.stalled=state==2; + mesh::hostkiss::usb_active=true;assert(!usbLoggingRecoverySafe(nullptr)); + mesh::hostkiss::usb_active=false;assert(usbLoggingRecoverySafe(nullptr)); + } #if defined(ENABLE_USB_INTERFACE) // A live binary client or buffered protocol transaction is always protected, // even if the dedicated logging CDC is disconnected or its output is stuck.