Skip to content

Commit

Permalink
Use named temporary file for perf map tests
Browse files Browse the repository at this point in the history
It's not at all clear why, but our perf map tests fail when run in a
vmtest VM that has the hosts /tmp/ mounted inside. The issue seems fixed
once we switch to using named temporary files ¯\_(°ペ)_/¯
Switch over to using them, which makes a lot more sense anyway, because
we are currently making up a path that does not represent reality.

Signed-off-by: Daniel Müller <[email protected]>
  • Loading branch information
d-e-s-o committed Aug 20, 2024
1 parent 4e63427 commit c33d706
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/symbolize/perf_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ mod tests {

use scopeguard::defer;

use tempfile::tempfile;
use tempfile::NamedTempFile;

use crate::symbolize::Input;
use crate::symbolize::Process;
Expand Down Expand Up @@ -257,9 +257,9 @@ mod tests {
};
assert_ne!(format!("{func:?}"), "");

let mut file = tempfile().unwrap();
let mut file = NamedTempFile::new().unwrap();
let () = file.write_all(SAMPLE_PERF_MAP).unwrap();
let perf_map = PerfMap::from_file(Path::new("SAMPLE_PERF_MAP"), &file).unwrap();
let perf_map = PerfMap::from_file(Path::new("SAMPLE_PERF_MAP"), file.as_file()).unwrap();
assert_ne!(format!("{perf_map:?}"), "");
}

Expand Down Expand Up @@ -295,9 +295,9 @@ mod tests {
/// Check that we can load a perf map and use it to symbolize an address.
#[test]
fn perf_map_symbolization() {
let mut file = tempfile().unwrap();
let mut file = NamedTempFile::new().unwrap();
let () = file.write_all(SAMPLE_PERF_MAP).unwrap();
let perf_map = PerfMap::from_file(Path::new("SAMPLE_PERF_MAP"), &file).unwrap();
let perf_map = PerfMap::from_file(file.path(), file.as_file()).unwrap();

for offset in 0..0xb {
let sym = perf_map
Expand Down

0 comments on commit c33d706

Please sign in to comment.