From c33d706e3edc0c08c57bc9df9915590e67cd460b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Tue, 20 Aug 2024 13:57:28 -0700 Subject: [PATCH] Use named temporary file for perf map tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/symbolize/perf_map.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/symbolize/perf_map.rs b/src/symbolize/perf_map.rs index 99a2cfbc3..8681039c3 100644 --- a/src/symbolize/perf_map.rs +++ b/src/symbolize/perf_map.rs @@ -206,7 +206,7 @@ mod tests { use scopeguard::defer; - use tempfile::tempfile; + use tempfile::NamedTempFile; use crate::symbolize::Input; use crate::symbolize::Process; @@ -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:?}"), ""); } @@ -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