Rollup merge of #127594 - c6c7:fuchsia-status-code-match-arm, r=tmandry · model-checking/verify-rust-std@c99ebd4 (original) (raw)
`@@ -19,7 +19,15 @@ pub const TR_OK: i32 = 50;
`
19
19
`// On Windows we use __fastfail to abort, which is documented to use this
`
20
20
`// exception code.
`
21
21
`#[cfg(windows)]
`
22
``
`-
const STATUS_ABORTED: i32 = 0xC0000409u32 as i32;
`
``
22
`+
const STATUS_FAIL_FAST_EXCEPTION: i32 = 0xC0000409u32 as i32;
`
``
23
+
``
24
`+
// On Zircon (the Fuchsia kernel), an abort from userspace calls the
`
``
25
`+
// LLVM implementation of __builtin_trap(), e.g., ud2 on x86, which
`
``
26
`+
// raises a kernel exception. If a userspace process does not
`
``
27
`+
// otherwise arrange exception handling, the kernel kills the process
`
``
28
`+
// with this return code.
`
``
29
`+
#[cfg(target_os = "fuchsia")]
`
``
30
`+
const ZX_TASK_RETCODE_EXCEPTION_KILL: i32 = -1028;
`
23
31
``
24
32
`#[derive(Debug, Clone, PartialEq)]
`
25
33
`pub enum TestResult {
`
`@@ -96,7 +104,7 @@ pub fn get_result_from_exit_code(
`
96
104
`let result = match status.code() {
`
97
105
`Some(TR_OK) => TestResult::TrOk,
`
98
106
`#[cfg(windows)]
`
99
``
`-
Some(STATUS_ABORTED) => TestResult::TrFailed,
`
``
107
`+
Some(STATUS_FAIL_FAST_EXCEPTION) => TestResult::TrFailed,
`
100
108
`#[cfg(unix)]
`
101
109
`None => match status.signal() {
`
102
110
`Some(libc::SIGABRT) => TestResult::TrFailed,
`
`@@ -105,6 +113,9 @@ pub fn get_result_from_exit_code(
`
105
113
`}
`
106
114
`None => unreachable!("status.code() returned None but status.signal() was None"),
`
107
115
`},
`
``
116
`+
// Upon an abort, Fuchsia returns the status code ZX_TASK_RETCODE_EXCEPTION_KILL.
`
``
117
`+
#[cfg(target_os = "fuchsia")]
`
``
118
`+
Some(ZX_TASK_RETCODE_EXCEPTION_KILL) => TestResult::TrFailed,
`
108
119
`#[cfg(not(unix))]
`
109
120
`None => TestResult::TrFailedMsg(format!("unknown return code")),
`
110
121
`#[cfg(any(windows, unix))]
`