From cbaa83173496243dc743b2e5b76757f974fc0ae2 Mon Sep 17 00:00:00 2001 From: Charles Celerier Date: Wed, 10 Jul 2024 03:22:44 +0000 Subject: [PATCH 1/2] Add match arm for Fuchsia status code upon an abort in a test This change adds ZX_TASK_RETCODE_EXCEPTION_KILL as an expected status code upon an abort in a test on Fuchsia. Tests fixes #127539 --- test/src/test_result.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/src/test_result.rs b/test/src/test_result.rs index bb32c70d6631..cecf747f5311 100644 --- a/test/src/test_result.rs +++ b/test/src/test_result.rs @@ -21,6 +21,14 @@ pub const TR_OK: i32 = 50; #[cfg(windows)] const STATUS_ABORTED: 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 { TrOk, @@ -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))] From d50143fddb910ec7a75293b5131eaa78b922e9da Mon Sep 17 00:00:00 2001 From: Charles Celerier Date: Wed, 10 Jul 2024 03:43:15 +0000 Subject: [PATCH 2/2] Update name of Windows abort constant to match platform documentation --- test/src/test_result.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/src/test_result.rs b/test/src/test_result.rs index cecf747f5311..98c54f038da6 100644 --- a/test/src/test_result.rs +++ b/test/src/test_result.rs @@ -19,7 +19,7 @@ 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 @@ -104,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,