Skip to content

Commit c7f01aa

Browse files
committed
invalid_const_promotion: check if we get the right signal
1 parent 6998b36 commit c7f01aa

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/test/run-pass/invalid_const_promotion.rs

+21-2
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,37 @@
1111
// ignore-wasm32
1212
// ignore-emscripten
1313

14-
#![feature(const_fn)]
14+
#![feature(const_fn, libc)]
1515
#![allow(const_err)]
1616

17+
extern crate libc;
18+
1719
use std::env;
1820
use std::process::{Command, Stdio};
1921

22+
// this will panic in debug mode
2023
const fn bar() -> usize { 0 - 1 }
2124

2225
fn foo() {
2326
let _: &'static _ = &bar();
2427
}
2528

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+
2645
fn main() {
2746
let args: Vec<String> = env::args().collect();
2847
if args.len() > 1 && args[1] == "test" {
@@ -34,5 +53,5 @@ fn main() {
3453
.stdout(Stdio::piped())
3554
.stdin(Stdio::piped())
3655
.arg("test").output().unwrap();
37-
assert!(!p.status.success());
56+
check_status(p.status);
3857
}

0 commit comments

Comments
 (0)