11use  std:: any:: Any ; 
22use  std:: process:: ExitStatus ; 
33
4+ #[ cfg( target_os = "fuchsia" ) ]  
5+ use  std:: os:: fuchsia:: process:: ExitStatusExt  as  _; 
46#[ cfg( unix) ]  
5- use  std:: os:: unix:: process:: ExitStatusExt ; 
7+ use  std:: os:: unix:: process:: ExitStatusExt   as  _ ; 
68
79use  super :: bench:: BenchSamples ; 
810use  super :: options:: ShouldPanic ; 
@@ -88,12 +90,21 @@ pub fn get_result_from_exit_code(
8890    time_opts :  & Option < time:: TestTimeOptions > , 
8991    exec_time :  & Option < time:: TestExecTime > , 
9092)  -> 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 ( )  { 
9299        Some ( TR_OK )  => TestResult :: TrOk , 
93100        // On Windows we use __fastfail to abort, which is documented to use this 
94101        // exception code. 
95102        #[ cfg( windows) ]  
96103        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 , 
97108        #[ cfg( unix) ]  
98109        None  => match  status. signal ( )  { 
99110            Some ( libc:: SIGABRT )  => TestResult :: TrFailed , 
@@ -102,16 +113,9 @@ pub fn get_result_from_exit_code(
102113            } 
103114            None  => unreachable ! ( "status.code() returned None but status.signal() was None" ) , 
104115        } , 
105-         // Upon an abort, Fuchsia returns the status code ZX_TASK_RETCODE_EXCEPTION_KILL. 
106-         #[ cfg( target_os = "fuchsia" ) ]  
107-         Some ( -1028 )  => TestResult :: TrFailed , 
108116        #[ cfg( not( unix) ) ]  
109117        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+     } ) ; 
115119
116120    // If test is already failed (or allowed to fail), do not change the result. 
117121    if  result != TestResult :: TrOk  { 
0 commit comments