File tree 1 file changed +21
-2
lines changed
1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change 11
11
// ignore-wasm32
12
12
// ignore-emscripten
13
13
14
- #![ feature( const_fn) ]
14
+ #![ feature( const_fn, libc ) ]
15
15
#![ allow( const_err) ]
16
16
17
+ extern crate libc;
18
+
17
19
use std:: env;
18
20
use std:: process:: { Command , Stdio } ;
19
21
22
+ // this will panic in debug mode
20
23
const fn bar ( ) -> usize { 0 - 1 }
21
24
22
25
fn foo ( ) {
23
26
let _: & ' static _ = & bar ( ) ;
24
27
}
25
28
29
+ #[ cfg( unix) ]
30
+ fn check_status ( status : std:: process:: ExitStatus )
31
+ {
32
+ use libc;
33
+ use std:: os:: unix:: process:: ExitStatusExt ;
34
+
35
+ assert ! ( status. signal( ) == Some ( libc:: SIGILL )
36
+ || status. signal( ) == Some ( libc:: SIGABRT ) ) ;
37
+ }
38
+
39
+ #[ cfg( not( unix) ) ]
40
+ fn check_status ( status : std:: process:: ExitStatus )
41
+ {
42
+ assert ! ( !status. success( ) ) ;
43
+ }
44
+
26
45
fn main ( ) {
27
46
let args: Vec < String > = env:: args ( ) . collect ( ) ;
28
47
if args. len ( ) > 1 && args[ 1 ] == "test" {
@@ -34,5 +53,5 @@ fn main() {
34
53
. stdout ( Stdio :: piped ( ) )
35
54
. stdin ( Stdio :: piped ( ) )
36
55
. arg ( "test" ) . output ( ) . unwrap ( ) ;
37
- assert ! ( ! p. status. success ( ) ) ;
56
+ check_status ( p. status ) ;
38
57
}
You can’t perform that action at this time.
0 commit comments