Skip to content

Commit c1bbe34

Browse files
authored
Rollup merge of #127594 - c6c7:fuchsia-status-code-match-arm, r=tmandry
Fuchsia status code match arm Adds a match arm for the Fuchsia status code upon a process abort. An additional change moves the Windows status code down into the match arm itself instead of being defined as a constant elsewhere. r​? tmandry
2 parents 7c1bf86 + deb8ebb commit c1bbe34

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

library/test/src/test_result.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@ pub const TR_OK: i32 = 50;
1919
// On Windows we use __fastfail to abort, which is documented to use this
2020
// exception code.
2121
#[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;
2331

2432
#[derive(Debug, Clone, PartialEq)]
2533
pub enum TestResult {
@@ -96,7 +104,7 @@ pub fn get_result_from_exit_code(
96104
let result = match status.code() {
97105
Some(TR_OK) => TestResult::TrOk,
98106
#[cfg(windows)]
99-
Some(STATUS_ABORTED) => TestResult::TrFailed,
107+
Some(STATUS_FAIL_FAST_EXCEPTION) => TestResult::TrFailed,
100108
#[cfg(unix)]
101109
None => match status.signal() {
102110
Some(libc::SIGABRT) => TestResult::TrFailed,
@@ -105,6 +113,9 @@ pub fn get_result_from_exit_code(
105113
}
106114
None => unreachable!("status.code() returned None but status.signal() was None"),
107115
},
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,
108119
#[cfg(not(unix))]
109120
None => TestResult::TrFailedMsg(format!("unknown return code")),
110121
#[cfg(any(windows, unix))]

tests/ui/test-attrs/test-panic-abort-nocapture.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
//@ ignore-wasm no panic or subprocess support
1111
//@ ignore-emscripten no panic or subprocess support
1212
//@ ignore-sgx no subprocess support
13-
//@ ignore-fuchsia code returned as ZX_TASK_RETCODE_EXCEPTION_KILL, FIXME (#127539)
1413

1514
#![cfg(test)]
1615

tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
thread 'main' panicked at $DIR/test-panic-abort-nocapture.rs:35:5:
1+
thread 'main' panicked at $DIR/test-panic-abort-nocapture.rs:34:5:
22
assertion `left == right` failed
33
left: 2
44
right: 4
55
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
6-
thread 'main' panicked at $DIR/test-panic-abort-nocapture.rs:29:5:
6+
thread 'main' panicked at $DIR/test-panic-abort-nocapture.rs:28:5:
77
assertion `left == right` failed
88
left: 2
99
right: 4

tests/ui/test-attrs/test-panic-abort.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
//@ ignore-wasm no panic or subprocess support
1111
//@ ignore-emscripten no panic or subprocess support
1212
//@ ignore-sgx no subprocess support
13-
//@ ignore-fuchsia code returned as ZX_TASK_RETCODE_EXCEPTION_KILL, FIXME (#127539)
1413

1514
#![cfg(test)]
1615
#![feature(test)]

tests/ui/test-attrs/test-panic-abort.run.stdout

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ hello, world
1717
testing123
1818
---- it_fails stderr ----
1919
testing321
20-
thread 'main' panicked at $DIR/test-panic-abort.rs:40:5:
20+
thread 'main' panicked at $DIR/test-panic-abort.rs:39:5:
2121
assertion `left == right` failed
2222
left: 2
2323
right: 5

0 commit comments

Comments
 (0)