From 2103082d617592fe6069384b73069adef3a11bb5 Mon Sep 17 00:00:00 2001 From: Billy Price Date: Tue, 27 Jan 2026 14:52:48 -0800 Subject: [PATCH] fix tests on windows --- debug-service/src/lib.rs | 21 +++++++++++++++++++ espi-service/src/espi_service.rs | 11 +++------- espi-service/src/lib.rs | 21 +++++++++++++++++++ .../partition-manager/Cargo.toml | 2 +- 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/debug-service/src/lib.rs b/debug-service/src/lib.rs index 827847212..48db64975 100644 --- a/debug-service/src/lib.rs +++ b/debug-service/src/lib.rs @@ -3,8 +3,29 @@ #![allow(clippy::indexing_slicing)] #![allow(clippy::unwrap_used)] +// This module has a hard dependency on defmt, which doesn't work on desktop. +// This means that the entire workspace's tests won't compile if this module is enabled. +// +// On Linux, we sort-of get away with it - as far as I can tell, the linker on Linux is more aggressive +// with pruning unused code, so as long as there's no test that calls into anything that eventually calls +// into defmt, we at least compile on Linux. +// +// However, on Windows, it looks like the linker is erroring out because it can't find defmt-related symbols before +// it does the analysis to determine that those symbols aren't reachable anyway, so we have to disable this module +// entirely to be able to compile the workspace's tests at all on Windows. +// +// If we ever want to run tests for this module on Windows, we'll need some way to either break the dependency +// on defmt or provide dummy implementations of the defmt symbols for test builds on Windows. Until then, +// we need to gate everything on #[cfg(not(test))]. + +#[cfg(not(test))] mod debug_service; + +#[cfg(not(test))] mod defmt_ring_logger; + +#[cfg(not(test))] pub mod task; +#[cfg(not(test))] pub use debug_service::*; diff --git a/espi-service/src/espi_service.rs b/espi-service/src/espi_service.rs index 55dcd55e7..74fd55826 100644 --- a/espi-service/src/espi_service.rs +++ b/espi-service/src/espi_service.rs @@ -114,7 +114,6 @@ impl Service<'_> { })?; // Last byte is PEC, ignore for now let packet = &packet[..packet.len() - 1]; - #[cfg(feature = "defmt")] trace!("Sending MCTP response: {:?}", packet); self.write_to_hw(espi, packet).map_err(|e| { @@ -228,7 +227,7 @@ pub(crate) async fn process_controller_event( with_pec[src_slice.len()] = 0; let with_pec = &with_pec[..=src_slice.len()]; - #[cfg(feature = "defmt")] + #[cfg(feature = "defmt")] // Required because without defmt, there is no implementation of UpperHex for [u8] debug!("OOB message: {:02X}", &src_slice[0..]); let mut assembly_access = espi_service @@ -240,13 +239,11 @@ pub(crate) async fn process_controller_event( match mctp_ctx.deserialize_packet(with_pec) { Ok(Some(message)) => { - #[cfg(feature = "defmt")] trace!("MCTP packet successfully deserialized"); match message.parse_as::() { Ok((header, body)) => { let target_endpoint = header.service.get_endpoint_id(); - #[cfg(feature = "defmt")] trace!( "Host Request: Service {:?}, Command {:?}", target_endpoint, header.message_id, @@ -261,9 +258,8 @@ pub(crate) async fn process_controller_event( .expect("result error type is infallible"); info!("MCTP packet forwarded to service: {:?}", target_endpoint); } - Err(_e) => { - #[cfg(feature = "defmt")] - error!("MCTP ODP type malformed: {}", _e); + Err(e) => { + error!("MCTP ODP type malformed: {:?}", e); espi.complete_port(port_event.port); @@ -282,7 +278,6 @@ pub(crate) async fn process_controller_event( // Handle protocol or medium error error!("MCTP packet malformed"); - #[cfg(feature = "defmt")] error!("error code: {:?}", _e); espi.complete_port(OOB_PORT_ID); diff --git a/espi-service/src/lib.rs b/espi-service/src/lib.rs index 88a69717e..e8233bc93 100644 --- a/espi-service/src/lib.rs +++ b/espi-service/src/lib.rs @@ -4,8 +4,29 @@ #![allow(clippy::panic)] #![allow(clippy::unwrap_used)] +// This module has a hard dependency on embassy-imxrt, which doesn't work on desktop. +// This means that the entire workspace's tests won't compile if this module is enabled. +// +// On Linux, we sort-of get away with it - as far as I can tell, the linker on Linux is more aggressive +// with pruning unused code, so as long as there's no test that calls into anything that eventually calls +// into embassy-imxrt, we at least compile on Linux. +// +// However, on Windows, it looks like the linker is erroring out because it can't find embassy-imxrt-related +// symbols before it does the analysis to determine that those symbols aren't reachable anyway, so we have to +// disable this module entirely to be able to compile the workspace's tests at all on Windows. +// +// If we ever want to run tests for this module on Windows, we'll need some way to break the dependency +// on embassy-imxrt - probably by switching to some sort of trait-based interface with eSPI. Until then, +// we need to gate everything on #[cfg(not(test))]. + +#[cfg(not(test))] mod espi_service; + +#[cfg(not(test))] mod mctp; + +#[cfg(not(test))] pub mod task; +#[cfg(not(test))] pub use espi_service::*; diff --git a/partition-manager/partition-manager/Cargo.toml b/partition-manager/partition-manager/Cargo.toml index fae91142d..5958dcb42 100644 --- a/partition-manager/partition-manager/Cargo.toml +++ b/partition-manager/partition-manager/Cargo.toml @@ -26,7 +26,7 @@ partition-manager-macros = { path = "../macros", features = [ defmt = { workspace = true, optional = true } [features] -default = ["esa", "bdd", "macros", "defmt"] +default = ["esa", "bdd", "macros"] macros = ["dep:partition-manager-macros"]