diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-07-27 01:33:01 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-07-27 18:56:16 +0300 |
| commit | 9be35f82c1abf2ecbab489bca9eca138ea648312 (patch) | |
| tree | 69888506e34af447d9748c0d542de3ba1dd76210 /src/test/ui/panic-runtime | |
| parent | ca9faa52f5ada0054b1fa27d97aedf448afb059b (diff) | |
| download | rust-9be35f82c1abf2ecbab489bca9eca138ea648312.tar.gz rust-9be35f82c1abf2ecbab489bca9eca138ea648312.zip | |
tests: Move run-pass tests without naming conflicts to ui
Diffstat (limited to 'src/test/ui/panic-runtime')
| -rw-r--r-- | src/test/ui/panic-runtime/abort-link-to-unwinding-crates.rs | 41 | ||||
| -rw-r--r-- | src/test/ui/panic-runtime/abort.rs | 44 | ||||
| -rw-r--r-- | src/test/ui/panic-runtime/auxiliary/exit-success-if-unwind.rs | 16 | ||||
| -rw-r--r-- | src/test/ui/panic-runtime/link-to-abort.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/panic-runtime/link-to-unwind.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/panic-runtime/lto-abort.rs | 34 | ||||
| -rw-r--r-- | src/test/ui/panic-runtime/lto-unwind.rs | 37 |
7 files changed, 193 insertions, 0 deletions
diff --git a/src/test/ui/panic-runtime/abort-link-to-unwinding-crates.rs b/src/test/ui/panic-runtime/abort-link-to-unwinding-crates.rs new file mode 100644 index 00000000000..9c099911eab --- /dev/null +++ b/src/test/ui/panic-runtime/abort-link-to-unwinding-crates.rs @@ -0,0 +1,41 @@ +// run-pass +#![allow(unused_variables)] +// compile-flags:-C panic=abort +// aux-build:exit-success-if-unwind.rs +// no-prefer-dynamic +// ignore-cloudabi no processes +// ignore-emscripten no processes +// ignore-sgx no processes +// ignore-macos + +extern crate exit_success_if_unwind; + +use std::process::Command; +use std::env; + +fn main() { + let mut args = env::args_os(); + let me = args.next().unwrap(); + + if let Some(s) = args.next() { + if &*s == "foo" { + exit_success_if_unwind::bar(do_panic); + } + } + + let mut cmd = Command::new(env::args_os().next().unwrap()); + cmd.arg("foo"); + + + // ARMv6 hanges while printing the backtrace, see #41004 + if cfg!(target_arch = "arm") && cfg!(target_env = "gnu") { + cmd.env("RUST_BACKTRACE", "0"); + } + + let s = cmd.status(); + assert!(s.unwrap().code() != Some(0)); +} + +fn do_panic() { + panic!("try to catch me"); +} diff --git a/src/test/ui/panic-runtime/abort.rs b/src/test/ui/panic-runtime/abort.rs new file mode 100644 index 00000000000..f625fe35d72 --- /dev/null +++ b/src/test/ui/panic-runtime/abort.rs @@ -0,0 +1,44 @@ +// run-pass +#![allow(unused_variables)] +// compile-flags:-C panic=abort +// no-prefer-dynamic +// ignore-cloudabi no processes +// ignore-emscripten no processes +// ignore-sgx no processes +// ignore-macos + +use std::process::Command; +use std::env; + +struct Bomb; + +impl Drop for Bomb { + fn drop(&mut self) { + std::process::exit(0); + } +} + +fn main() { + let mut args = env::args_os(); + let me = args.next().unwrap(); + + if let Some(s) = args.next() { + if &*s == "foo" { + + let _bomb = Bomb; + + panic!("try to catch me"); + } + } + + let mut cmd = Command::new(env::args_os().next().unwrap()); + cmd.arg("foo"); + + // ARMv6 hanges while printing the backtrace, see #41004 + if cfg!(target_arch = "arm") && cfg!(target_env = "gnu") { + cmd.env("RUST_BACKTRACE", "0"); + } + + let s = cmd.status(); + assert!(s.unwrap().code() != Some(0)); +} diff --git a/src/test/ui/panic-runtime/auxiliary/exit-success-if-unwind.rs b/src/test/ui/panic-runtime/auxiliary/exit-success-if-unwind.rs new file mode 100644 index 00000000000..c0e05740542 --- /dev/null +++ b/src/test/ui/panic-runtime/auxiliary/exit-success-if-unwind.rs @@ -0,0 +1,16 @@ +// no-prefer-dynamic + +#![crate_type = "rlib"] + +struct Bomb; + +impl Drop for Bomb { + fn drop(&mut self) { + std::process::exit(0); + } +} + +pub fn bar(f: fn()) { + let _bomb = Bomb; + f(); +} diff --git a/src/test/ui/panic-runtime/link-to-abort.rs b/src/test/ui/panic-runtime/link-to-abort.rs new file mode 100644 index 00000000000..422206c574d --- /dev/null +++ b/src/test/ui/panic-runtime/link-to-abort.rs @@ -0,0 +1,11 @@ +// run-pass + +// compile-flags:-C panic=abort +// no-prefer-dynamic +// ignore-macos + +#![feature(panic_abort)] + +extern crate panic_abort; + +fn main() {} diff --git a/src/test/ui/panic-runtime/link-to-unwind.rs b/src/test/ui/panic-runtime/link-to-unwind.rs new file mode 100644 index 00000000000..59036ca99bd --- /dev/null +++ b/src/test/ui/panic-runtime/link-to-unwind.rs @@ -0,0 +1,10 @@ +// run-pass + +// no-prefer-dynamic + +#![feature(panic_unwind)] + +extern crate panic_unwind; + +fn main() { +} diff --git a/src/test/ui/panic-runtime/lto-abort.rs b/src/test/ui/panic-runtime/lto-abort.rs new file mode 100644 index 00000000000..8fff71a629a --- /dev/null +++ b/src/test/ui/panic-runtime/lto-abort.rs @@ -0,0 +1,34 @@ +// run-pass +#![allow(unused_variables)] +// compile-flags:-C lto -C panic=abort +// no-prefer-dynamic +// ignore-cloudabi no processes +// ignore-emscripten no processes +// ignore-sgx no processes + +use std::process::Command; +use std::env; + +struct Bomb; + +impl Drop for Bomb { + fn drop(&mut self) { + std::process::exit(0); + } +} + +fn main() { + let mut args = env::args_os(); + let me = args.next().unwrap(); + + if let Some(s) = args.next() { + if &*s == "foo" { + + let _bomb = Bomb; + + panic!("try to catch me"); + } + } + let s = Command::new(env::args_os().next().unwrap()).arg("foo").status(); + assert!(s.unwrap().code() != Some(0)); +} diff --git a/src/test/ui/panic-runtime/lto-unwind.rs b/src/test/ui/panic-runtime/lto-unwind.rs new file mode 100644 index 00000000000..94a0b596e4a --- /dev/null +++ b/src/test/ui/panic-runtime/lto-unwind.rs @@ -0,0 +1,37 @@ +// run-pass +#![allow(unused_variables)] + +// compile-flags:-C lto -C panic=unwind +// no-prefer-dynamic +// ignore-cloudabi no processes +// ignore-emscripten no processes +// ignore-sgx no processes + +use std::process::Command; +use std::env; + +struct Bomb; + +impl Drop for Bomb { + fn drop(&mut self) { + println!("hurray you ran me"); + } +} + +fn main() { + let mut args = env::args_os(); + let me = args.next().unwrap(); + + if let Some(s) = args.next() { + if &*s == "foo" { + + let _bomb = Bomb; + + panic!("try to catch me"); + } + } + let s = Command::new(env::args_os().next().unwrap()).arg("foo").output(); + let s = s.unwrap(); + assert!(!s.status.success()); + assert!(String::from_utf8_lossy(&s.stdout).contains("hurray you ran me")); +} |
