v4.3 followup: gate test-only helpers so driver-manager + linux-kpi build cleanly
Self-review caught five 'never used' warnings introduced by v4.3:
src/aer.rs:118 severity_default (only tests use it)
src/error_channel.rs:64 DriverErrorReport::decode (only tests)
src/error_channel.rs:98 DriverErrorResponse::encode (only tests)
src/error_channel.rs:165 ErrorChannelRegistry::new (only tests)
src/scheme.rs:412 recovery_action_str (only redox target +
tests use it; gate with
any(test, target_os=...))
src/scheme.rs:17 RecoveryAction import (gated to match)
src/rust_impl/error.rs:47 DriverErrorReport::encode (linux-kpi tests
only)
Gate all with #[cfg(test)] (or #[cfg(any(test, target_os = "redox"))]
for recovery_action_str which main.rs uses on Redox target).
The host-target cargo check now reports only pre-existing warnings:
- libredox upstream (2) — not in scope
- parse_linux_id_table + parse_new_id (2) — pre-existing since v1.9/v2.2
cargo test --bin driver-manager: 70 passed
cargo test --lib (redox-driver-core): 32 passed
linux-kpi cargo check: clean
linux-kpi cargo build: clean (host test link fails on
redox_strerror_v1, pre-existing)
This commit is contained in:
@@ -44,6 +44,7 @@ struct DriverErrorReport {
|
||||
}
|
||||
|
||||
impl DriverErrorReport {
|
||||
#[cfg(test)]
|
||||
fn encode(&self) -> Vec<u8> {
|
||||
let bdf_bytes = self.bdf.as_bytes();
|
||||
let raw_bytes = self.raw.as_bytes();
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -61,6 +61,7 @@ impl DriverErrorReport {
|
||||
}
|
||||
|
||||
/// Decode from bytes. Returns None if the buffer is malformed.
|
||||
#[cfg(test)]
|
||||
pub fn decode(buf: &[u8]) -> Option<Self> {
|
||||
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<u8> {
|
||||
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()),
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user