Whether `path` is an executable file. Used to detect machine hooks.
(path: &str)
| 108 | |
| 109 | /// Whether `path` is an executable file. Used to detect machine hooks. |
| 110 | fn hook_is_executable(path: &str) -> bool { |
| 111 | #[cfg(target_os = "linux")] |
| 112 | { |
| 113 | use std::os::unix::fs::PermissionsExt; |
| 114 | std::fs::metadata(path) |
| 115 | .map(|m| m.is_file() && m.permissions().mode() & 0o111 != 0) |
| 116 | .unwrap_or(false) |
| 117 | } |
| 118 | #[cfg(not(target_os = "linux"))] |
| 119 | { |
| 120 | let _ = path; |
| 121 | false |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | /// Run a machine hook, logging (never failing the run) on error. Isolation is |
| 126 | /// best-effort: a missing or failing hook leaves the benchmark less isolated, but |