Skip to content

Commit

Permalink
fix: suppress dead code warnings in cache_info.rs
Browse files Browse the repository at this point in the history
The unittests here rely on the cfg(not(test)) antipattern for mocking,
which new rust compiler interprets as the production version of the
structs being dead-code when running unittests.

Refactoring this to eliminate mocking is difficult, because fdt unit
tests rely on the mocks removing all host-specific information from the
cpu FDT nodes (particularly cache information, which in prod is read
from the host sysfs, but in test mode is some dummy mock values).

Signed-off-by: Patrick Roy <[email protected]>
  • Loading branch information
roypat committed Dec 10, 2024
1 parent 6d145b1 commit 33c0fa0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/vmm/src/arch/aarch64/cache_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ trait CacheStore: std::fmt::Debug {
}

#[derive(Debug)]
#[cfg_attr(test, allow(unused))]
pub(crate) struct CacheEntry {
// Cache Level: 1, 2, 3..
pub level: u8,
Expand Down Expand Up @@ -206,6 +207,7 @@ impl CacheType {
}
}

#[cfg_attr(test, allow(unused))]
fn readln_special<T: AsRef<Path>>(file_path: &T) -> Result<String, CacheInfoError> {
let line = fs::read_to_string(file_path)?;
Ok(line.trim_end().to_string())
Expand Down

0 comments on commit 33c0fa0

Please sign in to comment.