diff --git a/local/recipes/drivers/linux-kpi/source/src/rust_impl/error.rs b/local/recipes/drivers/linux-kpi/source/src/rust_impl/error.rs index fb0e72a164..01938957db 100644 --- a/local/recipes/drivers/linux-kpi/source/src/rust_impl/error.rs +++ b/local/recipes/drivers/linux-kpi/source/src/rust_impl/error.rs @@ -44,6 +44,7 @@ struct DriverErrorReport { } impl DriverErrorReport { + #[cfg(test)] fn encode(&self) -> Vec { let bdf_bytes = self.bdf.as_bytes(); let raw_bytes = self.raw.as_bytes(); diff --git a/local/recipes/system/driver-manager/source/src/aer.rs b/local/recipes/system/driver-manager/source/src/aer.rs index b5cd997a09..3a7d064cee 100644 --- a/local/recipes/system/driver-manager/source/src/aer.rs +++ b/local/recipes/system/driver-manager/source/src/aer.rs @@ -113,8 +113,12 @@ where RecoveryAction::Handled } -/// Severity-only default mapping. Used by the AER callback and by -/// tests that don't have driver configs wired in. +/// Severity-only default mapping. Mirrors what `route_to_driver` +/// falls back to when no `consult_driver` returns a result. Production +/// callers go through `DriverConfig::on_error`; this helper stays +/// `pub(crate)` so the `route_to_driver` tests can verify the +/// severity mapping directly without spinning up a driver config. +#[cfg(test)] pub(crate) fn severity_default(severity: ErrorSeverity) -> RecoveryAction { match severity { ErrorSeverity::Correctable => RecoveryAction::Handled, diff --git a/local/recipes/system/driver-manager/source/src/error_channel.rs b/local/recipes/system/driver-manager/source/src/error_channel.rs index 3ad74d31f6..a9694e5c61 100644 --- a/local/recipes/system/driver-manager/source/src/error_channel.rs +++ b/local/recipes/system/driver-manager/source/src/error_channel.rs @@ -61,6 +61,7 @@ impl DriverErrorReport { } /// Decode from bytes. Returns None if the buffer is malformed. + #[cfg(test)] pub fn decode(buf: &[u8]) -> Option { if buf.len() < 2 { return None; @@ -95,6 +96,7 @@ impl DriverErrorReport { pub struct DriverErrorResponse(pub RecoveryAction); impl DriverErrorResponse { + #[cfg(test)] pub fn encode(&self) -> Vec { vec![self.0 as u8] } @@ -162,6 +164,7 @@ pub struct ErrorChannelRegistry { } impl ErrorChannelRegistry { + #[cfg(test)] pub fn new() -> Self { Self { channels: Mutex::new(HashMap::new()), diff --git a/local/recipes/system/driver-manager/source/src/main.rs b/local/recipes/system/driver-manager/source/src/main.rs index cf9d21a8cf..2d035074b8 100644 --- a/local/recipes/system/driver-manager/source/src/main.rs +++ b/local/recipes/system/driver-manager/source/src/main.rs @@ -22,7 +22,7 @@ use std::time::{Duration, Instant}; use std::{env, fs, process}; use redox_driver_core::device::DeviceId; -use redox_driver_core::driver::{ErrorSeverity, ProbeResult}; +use redox_driver_core::driver::ProbeResult; use redox_driver_core::manager::{DeviceManager, ManagerConfig, ProbeEvent}; use redox_driver_pci::PciBus; use std::fs::OpenOptions; @@ -494,10 +494,10 @@ fn main() { event.device ); } + #[cfg(target_os = "redox")] if let Some(action_str) = scheme::DriverManagerScheme::recovery_action_str(*action) { - #[cfg(target_os = "redox")] scheme_for_events.dispatch_recovery(&event.device, action_str); } } diff --git a/local/recipes/system/driver-manager/source/src/scheme.rs b/local/recipes/system/driver-manager/source/src/scheme.rs index 8560dd9917..54bae370f2 100644 --- a/local/recipes/system/driver-manager/source/src/scheme.rs +++ b/local/recipes/system/driver-manager/source/src/scheme.rs @@ -14,6 +14,7 @@ use redox_driver_core::manager::DeviceManager; use redox_driver_core::manager::ProbeEvent; #[cfg(target_os = "redox")] use redox_driver_core::driver::ProbeResult; +#[cfg(any(test, target_os = "redox"))] use redox_driver_core::driver::RecoveryAction; #[cfg(target_os = "redox")] use redox_scheme::scheme::SchemeSync; @@ -409,6 +410,7 @@ impl DriverManagerScheme { /// to the action vocabulary accepted by `dispatch_recovery`. /// Returns `None` for actions that don't need an auto-dispatch /// (e.g. `Handled`, `Fatal` which is operator-only). + #[cfg(any(test, target_os = "redox"))] pub fn recovery_action_str(action: RecoveryAction) -> Option<&'static str> { match action { RecoveryAction::Handled => None,