From 756771d54c28c4543d620891e971bf5a95c3ea3e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 22 Apr 2021 15:06:53 +0100 Subject: [PATCH] panic ui test: Test always_abort on one thread, panic on another This test failed on an earlier version of this branch, where this did not work properly, so I know the test works. Signed-off-by: Ian Jackson --- src/test/ui/panics/abort-on-panic.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/test/ui/panics/abort-on-panic.rs b/src/test/ui/panics/abort-on-panic.rs index c02552be5192..2aea607e9548 100644 --- a/src/test/ui/panics/abort-on-panic.rs +++ b/src/test/ui/panics/abort-on-panic.rs @@ -2,6 +2,7 @@ #![allow(unused_must_use)] #![feature(unwind_attributes)] +#![feature(panic_always_abort)] // Since we mark some ABIs as "nounwind" to LLVM, we must make sure that // we never unwind through them. @@ -11,7 +12,9 @@ use std::{env, panic}; use std::io::prelude::*; use std::io; -use std::process::{Command, Stdio}; +use std::process::{exit, Command, Stdio}; +use std::sync::{Arc, Barrier}; +use std::thread; #[unwind(aborts)] // FIXME(#58794) should work even without the attribute extern "C" fn panic_in_ffi() { @@ -49,11 +52,27 @@ fn test_always_abort() { should_have_aborted(); } +fn test_always_abort_thread() { + let barrier = Arc::new(Barrier::new(2)); + let thr = { + let barrier = barrier.clone(); + thread::spawn(move ||{ + barrier.wait(); + panic!("in thread"); + }) + }; + panic::always_abort(); + barrier.wait(); + let _ = thr.join(); + bomb_out_but_not_abort("joined - but we were supposed to panic!"); +} + fn main() { let tests: &[(_, fn())] = &[ ("test", test), ("testrust", testrust), ("test_always_abort", test_always_abort), + ("test_always_abort_thread", test_always_abort_thread), ]; let args: Vec = env::args().collect();