From c7f01aa175c97c1103f45f73aad8b679edc3d045 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 29 Jul 2018 13:11:01 +0200 Subject: [PATCH] invalid_const_promotion: check if we get the right signal --- src/test/run-pass/invalid_const_promotion.rs | 23 ++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/test/run-pass/invalid_const_promotion.rs b/src/test/run-pass/invalid_const_promotion.rs index 29a4b921992..53cb4c4b009 100644 --- a/src/test/run-pass/invalid_const_promotion.rs +++ b/src/test/run-pass/invalid_const_promotion.rs @@ -11,18 +11,37 @@ // ignore-wasm32 // ignore-emscripten -#![feature(const_fn)] +#![feature(const_fn, libc)] #![allow(const_err)] +extern crate libc; + use std::env; use std::process::{Command, Stdio}; +// this will panic in debug mode const fn bar() -> usize { 0 - 1 } fn foo() { let _: &'static _ = &bar(); } +#[cfg(unix)] +fn check_status(status: std::process::ExitStatus) +{ + use libc; + use std::os::unix::process::ExitStatusExt; + + assert!(status.signal() == Some(libc::SIGILL) + || status.signal() == Some(libc::SIGABRT)); +} + +#[cfg(not(unix))] +fn check_status(status: std::process::ExitStatus) +{ + assert!(!status.success()); +} + fn main() { let args: Vec = env::args().collect(); if args.len() > 1 && args[1] == "test" { @@ -34,5 +53,5 @@ fn main() { .stdout(Stdio::piped()) .stdin(Stdio::piped()) .arg("test").output().unwrap(); - assert!(!p.status.success()); + check_status(p.status); }