]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/panics/abort-on-panic.rs
3 #![allow(unused_must_use)]
4 #![feature(unwind_attributes)]
5 // Since we mark some ABIs as "nounwind" to LLVM, we must make sure that
6 // we never unwind through them.
8 // ignore-emscripten no processes
9 // ignore-sgx no processes
11 use std
::{env, panic}
;
12 use std
::io
::prelude
::*;
14 use std
::process
::{Command, Stdio}
;
16 #[unwind(aborts)] // FIXME(#58794) should work even without the attribute
17 extern "C" fn panic_in_ffi() {
22 extern "Rust" fn panic_in_rust_abi() {
27 let _
= panic
::catch_unwind(|| { panic_in_ffi(); }
);
28 // The process should have aborted by now.
29 io
::stdout().write(b
"This should never be printed.\n");
30 let _
= io
::stdout().flush();
34 let _
= panic
::catch_unwind(|| { panic_in_rust_abi(); }
);
35 // The process should have aborted by now.
36 io
::stdout().write(b
"This should never be printed.\n");
37 let _
= io
::stdout().flush();
41 let args
: Vec
<String
> = env
::args().collect();
43 // This is inside the self-executed command.
45 "test" => return test(),
46 "testrust" => return testrust(),
47 _
=> panic
!("bad test"),
51 // These end up calling the self-execution branches above.
52 let mut p
= Command
::new(&args
[0])
53 .stdout(Stdio
::piped())
54 .stdin(Stdio
::piped())
55 .arg("test").spawn().unwrap();
56 assert
!(!p
.wait().unwrap().success());
58 let mut p
= Command
::new(&args
[0])
59 .stdout(Stdio
::piped())
60 .stdin(Stdio
::piped())
61 .arg("testrust").spawn().unwrap();
62 assert
!(!p
.wait().unwrap().success());