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 ;
@@ -88,12 +90,21 @@ pub fn get_result_from_exit_code(
88
90
time_opts : & Option < time:: TestTimeOptions > ,
89
91
exec_time : & Option < time:: TestExecTime > ,
90
92
) -> TestResult {
91
- let result = match status. code ( ) {
93
+ #[ cfg( target_os = "fuchsia" ) ]
94
+ let result = status. aborted_code ( ) . map ( |_| TestResult :: TrFailed ) ;
95
+ #[ cfg( not( target_os = "fuchsia" ) ) ]
96
+ let result: Option < TestResult > = None ;
97
+
98
+ let result = result. unwrap_or_else ( || match status. code ( ) {
92
99
Some ( TR_OK ) => TestResult :: TrOk ,
93
100
// On Windows we use __fastfail to abort, which is documented to use this
94
101
// exception code.
95
102
#[ cfg( windows) ]
96
103
Some ( const { 0xC0000409u32 as i32 } ) => TestResult :: TrFailed ,
104
+ #[ cfg( any( windows, unix) ) ]
105
+ Some ( code) => TestResult :: TrFailedMsg ( format ! ( "got unexpected return code {code}" ) ) ,
106
+ #[ cfg( not( any( windows, unix) ) ) ]
107
+ Some ( _) => TestResult :: TrFailed ,
97
108
#[ cfg( unix) ]
98
109
None => match status. signal ( ) {
99
110
Some ( libc:: SIGABRT ) => TestResult :: TrFailed ,
@@ -102,16 +113,9 @@ pub fn get_result_from_exit_code(
102
113
}
103
114
None => unreachable ! ( "status.code() returned None but status.signal() was None" ) ,
104
115
} ,
105
- // Upon an abort, Fuchsia returns the status code ZX_TASK_RETCODE_EXCEPTION_KILL.
106
- #[ cfg( target_os = "fuchsia" ) ]
107
- Some ( -1028 ) => TestResult :: TrFailed ,
108
116
#[ cfg( not( unix) ) ]
109
117
None => TestResult :: TrFailedMsg ( format ! ( "unknown return code" ) ) ,
110
- #[ cfg( any( windows, unix) ) ]
111
- Some ( code) => TestResult :: TrFailedMsg ( format ! ( "got unexpected return code {code}" ) ) ,
112
- #[ cfg( not( any( windows, unix) ) ) ]
113
- Some ( _) => TestResult :: TrFailed ,
114
- } ;
118
+ } ) ;
115
119
116
120
// If test is already failed (or allowed to fail), do not change the result.
117
121
if result != TestResult :: TrOk {
0 commit comments