Skip to content

Commit 756771d

Browse files
committed
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 <[email protected]>
1 parent 12fe500 commit 756771d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/test/ui/panics/abort-on-panic.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#![allow(unused_must_use)]
44
#![feature(unwind_attributes)]
5+
#![feature(panic_always_abort)]
56
// Since we mark some ABIs as "nounwind" to LLVM, we must make sure that
67
// we never unwind through them.
78

@@ -11,7 +12,9 @@
1112
use std::{env, panic};
1213
use std::io::prelude::*;
1314
use std::io;
14-
use std::process::{Command, Stdio};
15+
use std::process::{exit, Command, Stdio};
16+
use std::sync::{Arc, Barrier};
17+
use std::thread;
1518

1619
#[unwind(aborts)] // FIXME(#58794) should work even without the attribute
1720
extern "C" fn panic_in_ffi() {
@@ -49,11 +52,27 @@ fn test_always_abort() {
4952
should_have_aborted();
5053
}
5154

55+
fn test_always_abort_thread() {
56+
let barrier = Arc::new(Barrier::new(2));
57+
let thr = {
58+
let barrier = barrier.clone();
59+
thread::spawn(move ||{
60+
barrier.wait();
61+
panic!("in thread");
62+
})
63+
};
64+
panic::always_abort();
65+
barrier.wait();
66+
let _ = thr.join();
67+
bomb_out_but_not_abort("joined - but we were supposed to panic!");
68+
}
69+
5270
fn main() {
5371
let tests: &[(_, fn())] = &[
5472
("test", test),
5573
("testrust", testrust),
5674
("test_always_abort", test_always_abort),
75+
("test_always_abort_thread", test_always_abort_thread),
5776
];
5877

5978
let args: Vec<String> = env::args().collect();

0 commit comments

Comments
 (0)