Skip to content

Commit cdbfac0

Browse files
roypatShadowCurse
authored andcommitted
fix: suppress dead code warnings in cache_info.rs
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]>
1 parent 73fe828 commit cdbfac0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/vmm/src/arch/aarch64/cache_info.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ pub(crate) struct CacheEntry {
4545
}
4646

4747
#[derive(Debug)]
48+
#[cfg_attr(test, allow(dead_code))]
4849
struct HostCacheStore {
4950
cache_dir: PathBuf,
5051
}
@@ -206,6 +207,7 @@ impl CacheType {
206207
}
207208
}
208209

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

0 commit comments

Comments
 (0)