about summary refs log tree commit diff
path: root/library/test
diff options
context:
space:
mode:
authorCharles Celerier <chcl@google.com>2024-07-10 03:22:44 +0000
committerCharles Celerier <chcl@google.com>2024-07-15 22:21:41 +0000
commit1aad89d11ca9e52fa0442c75bb3d9dee9635cbb7 (patch)
tree6e8641fcada7754c3b2ca0cde2bf67ab8638d126 /library/test
parent24d2ac0b56fcbde13d827745f66e73efb1e17156 (diff)
downloadrust-1aad89d11ca9e52fa0442c75bb3d9dee9635cbb7.tar.gz
rust-1aad89d11ca9e52fa0442c75bb3d9dee9635cbb7.zip
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
Diffstat (limited to 'library/test')
-rw-r--r--library/test/src/test_result.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/library/test/src/test_result.rs b/library/test/src/test_result.rs
index bb32c70d663..cecf747f531 100644
--- a/library/test/src/test_result.rs
+++ b/library/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))]