1
1
use std:: any:: Any ;
2
2
use std:: process:: ExitStatus ;
3
3
4
+ #[ cfg( target_os = "fuchsia" ) ]
5
+ use std:: os:: fuchsia:: process:: ExitStatusExt as _;
4
6
#[ cfg( unix) ]
5
- use std:: os:: unix:: process:: ExitStatusExt ;
7
+ use std:: os:: unix:: process:: ExitStatusExt as _ ;
6
8
7
9
use super :: bench:: BenchSamples ;
8
10
use super :: options:: ShouldPanic ;
@@ -21,14 +23,6 @@ pub const TR_OK: i32 = 50;
21
23
#[ cfg( windows) ]
22
24
const STATUS_FAIL_FAST_EXCEPTION : i32 = 0xC0000409u32 as i32 ;
23
25
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 ;
31
-
32
26
#[ derive( Debug , Clone , PartialEq ) ]
33
27
pub enum TestResult {
34
28
TrOk ,
@@ -101,10 +95,19 @@ pub fn get_result_from_exit_code(
101
95
time_opts : & Option < time:: TestTimeOptions > ,
102
96
exec_time : & Option < time:: TestExecTime > ,
103
97
) -> TestResult {
104
- let result = match status. code ( ) {
98
+ #[ cfg( target_os = "fuchsia" ) ]
99
+ let result = status. aborted_code ( ) . map ( |_| TestResult :: TrFailed ) ;
100
+ #[ cfg( not( target_os = "fuchsia" ) ) ]
101
+ let result: Option < TestResult > = None ;
102
+
103
+ let result = result. unwrap_or_else ( || match status. code ( ) {
105
104
Some ( TR_OK ) => TestResult :: TrOk ,
106
105
#[ cfg( windows) ]
107
106
Some ( STATUS_FAIL_FAST_EXCEPTION ) => TestResult :: TrFailed ,
107
+ #[ cfg( any( windows, unix) ) ]
108
+ Some ( code) => TestResult :: TrFailedMsg ( format ! ( "got unexpected return code {code}" ) ) ,
109
+ #[ cfg( not( any( windows, unix) ) ) ]
110
+ Some ( _) => TestResult :: TrFailed ,
108
111
#[ cfg( unix) ]
109
112
None => match status. signal ( ) {
110
113
Some ( libc:: SIGABRT ) => TestResult :: TrFailed ,
@@ -113,16 +116,9 @@ pub fn get_result_from_exit_code(
113
116
}
114
117
None => unreachable ! ( "status.code() returned None but status.signal() was None" ) ,
115
118
} ,
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 ,
119
119
#[ cfg( not( unix) ) ]
120
120
None => TestResult :: TrFailedMsg ( format ! ( "unknown return code" ) ) ,
121
- #[ cfg( any( windows, unix) ) ]
122
- Some ( code) => TestResult :: TrFailedMsg ( format ! ( "got unexpected return code {code}" ) ) ,
123
- #[ cfg( not( any( windows, unix) ) ) ]
124
- Some ( _) => TestResult :: TrFailed ,
125
- } ;
121
+ } ) ;
126
122
127
123
// If test is already failed (or allowed to fail), do not change the result.
128
124
if result != TestResult :: TrOk {
0 commit comments