diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-07-18 23:05:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-18 23:05:21 +0200 |
| commit | c1bbe347c278b7bddb0655b5e7f2a606e32f2ba4 (patch) | |
| tree | a7fa76b383f71c0d14952534a881c8584b56200a /library/test | |
| parent | 7c1bf864174587f5572f1cee9b9ba127dd946dd1 (diff) | |
| parent | deb8ebb39b1fa8ab1436bf224df434273a6c58c6 (diff) | |
| download | rust-c1bbe347c278b7bddb0655b5e7f2a606e32f2ba4.tar.gz rust-c1bbe347c278b7bddb0655b5e7f2a606e32f2ba4.zip | |
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
Diffstat (limited to 'library/test')
| -rw-r--r-- | library/test/src/test_result.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/library/test/src/test_result.rs b/library/test/src/test_result.rs index bb32c70d663..98c54f038da 100644 --- a/library/test/src/test_result.rs +++ b/library/test/src/test_result.rs @@ -19,7 +19,15 @@ pub const TR_OK: i32 = 50; // On Windows we use __fastfail to abort, which is documented to use this // exception code. #[cfg(windows)] -const STATUS_ABORTED: i32 = 0xC0000409u32 as i32; +const STATUS_FAIL_FAST_EXCEPTION: i32 = 0xC0000409u32 as i32; + +// On Zircon (the Fuchsia kernel), an abort from userspace calls the +// LLVM implementation of __builtin_trap(), e.g., ud2 on x86, which +// raises a kernel exception. If a userspace process does not +// otherwise arrange exception handling, the kernel kills the process +// with this return code. +#[cfg(target_os = "fuchsia")] +const ZX_TASK_RETCODE_EXCEPTION_KILL: i32 = -1028; #[derive(Debug, Clone, PartialEq)] pub enum TestResult { @@ -96,7 +104,7 @@ pub fn get_result_from_exit_code( let result = match status.code() { Some(TR_OK) => TestResult::TrOk, #[cfg(windows)] - Some(STATUS_ABORTED) => TestResult::TrFailed, + Some(STATUS_FAIL_FAST_EXCEPTION) => TestResult::TrFailed, #[cfg(unix)] None => match status.signal() { Some(libc::SIGABRT) => TestResult::TrFailed, @@ -105,6 +113,9 @@ pub fn get_result_from_exit_code( } None => unreachable!("status.code() returned None but status.signal() was None"), }, + // Upon an abort, Fuchsia returns the status code ZX_TASK_RETCODE_EXCEPTION_KILL. + #[cfg(target_os = "fuchsia")] + Some(ZX_TASK_RETCODE_EXCEPTION_KILL) => TestResult::TrFailed, #[cfg(not(unix))] None => TestResult::TrFailedMsg(format!("unknown return code")), #[cfg(any(windows, unix))] |
