| 100 | /// the pair. |
| 101 | #[cfg(all(test, target_os = "linux"))] |
| 102 | pub(crate) fn setup_debuglink_tmpdir( |
| 103 | binary: &Path, |
| 104 | debug_file: &Path, |
| 105 | ) -> (tempfile::TempDir, PathBuf, PathBuf) { |
| 106 | let src = std::fs::read(binary).unwrap(); |
| 107 | let object = object::File::parse(&*src).unwrap(); |
| 108 | let (debuglink, _crc) = object |
| 109 | .gnu_debuglink() |
| 110 | .unwrap() |
| 111 | .expect("binary has no .gnu_debuglink"); |
| 112 | let debuglink = std::str::from_utf8(debuglink).unwrap(); |
| 113 | |
| 114 | let dir = tempfile::tempdir().unwrap(); |
| 115 | let staged_binary = dir.path().join("binary"); |
| 116 | let staged_debug = dir.path().join(debuglink); |
| 117 | std::fs::copy(binary, &staged_binary).unwrap(); |
| 118 | std::fs::copy(debug_file, &staged_debug).unwrap(); |
| 119 | |
| 120 | (dir, staged_binary, staged_debug) |
| 121 | } |
| 122 | |
| 123 | #[cfg(all(test, target_os = "linux"))] |
| 124 | mod tests { |