|
1 | 1 | use std::any::Any; |
2 | 2 | use std::process::ExitStatus; |
3 | 3 |
|
| 4 | +#[cfg(target_os = "fuchsia")] |
| 5 | +use std::os::fuchsia::process::ExitStatusExt as _; |
4 | 6 | #[cfg(unix)] |
5 | | -use std::os::unix::process::ExitStatusExt; |
| 7 | +use std::os::unix::process::ExitStatusExt as _; |
6 | 8 |
|
7 | 9 | use super::bench::BenchSamples; |
8 | 10 | use super::options::ShouldPanic; |
@@ -88,30 +90,30 @@ pub fn get_result_from_exit_code( |
88 | 90 | time_opts: &Option<time::TestTimeOptions>, |
89 | 91 | exec_time: &Option<time::TestExecTime>, |
90 | 92 | ) -> TestResult { |
91 | | - let result = match status.code() { |
| 93 | + #[cfg(target_os = "fuchsia")] |
| 94 | + let result = status.aborted_code().map(|_| TestResult::TrFailed); |
| 95 | + #[cfg(not(target_os = "fuchsia"))] |
| 96 | + let result: Option<TestResult> = None; |
| 97 | + |
| 98 | + let result = result.unwrap_or_else(|| match status.code() { |
92 | 99 | Some(TR_OK) => TestResult::TrOk, |
93 | 100 | // On Windows we use __fastfail to abort, which is documented to use this |
94 | 101 | // exception code. |
95 | 102 | #[cfg(windows)] |
96 | 103 | Some(0xC0000409u32 as i32) => TestResult::TrFailed, |
97 | | - #[cfg(unix)] |
| 104 | + #[cfg(any(windows, unix))] |
| 105 | + Some(code) => TestResult::TrFailedMsg(format!("got unexpected return code {code}")), |
| 106 | + #[cfg(not(any(windows, unix)))] |
| 107 | + Some(_) => TestResult::TrFailed, |
98 | 108 | None => match status.signal() { |
| 109 | + #[cfg(unix)] |
99 | 110 | Some(libc::SIGABRT) => TestResult::TrFailed, |
100 | 111 | Some(signal) => { |
101 | 112 | TestResult::TrFailedMsg(format!("child process exited with signal {signal}")) |
102 | 113 | } |
103 | 114 | None => unreachable!("status.code() returned None but status.signal() was None"), |
104 | 115 | }, |
105 | | - // Upon an abort, Fuchsia returns the status code ZX_TASK_RETCODE_EXCEPTION_KILL. |
106 | | - #[cfg(target_os = "fuchsia")] |
107 | | - Some(-1028) => TestResult::TrFailed, |
108 | | - #[cfg(not(unix))] |
109 | | - None => TestResult::TrFailedMsg(format!("unknown return code")), |
110 | | - #[cfg(any(windows, unix))] |
111 | | - Some(code) => TestResult::TrFailedMsg(format!("got unexpected return code {code}")), |
112 | | - #[cfg(not(any(windows, unix)))] |
113 | | - Some(_) => TestResult::TrFailed, |
114 | | - }; |
| 116 | + }); |
115 | 117 |
|
116 | 118 | // If test is already failed (or allowed to fail), do not change the result. |
117 | 119 | if result != TestResult::TrOk { |
|
0 commit comments