change test to use if black_box(false)
This commit is contained in:
parent
d8fb568cf4
commit
409d9946cd
1 changed files with 6 additions and 14 deletions
|
@ -1,23 +1,15 @@
|
||||||
// run-pass
|
// run-pass
|
||||||
// aux-build:weak-lang-items.rs
|
// aux-build:weak-lang-items.rs
|
||||||
|
|
||||||
// ignore-emscripten no threads support
|
|
||||||
// pretty-expanded FIXME #23616
|
// pretty-expanded FIXME #23616
|
||||||
|
|
||||||
extern crate weak_lang_items as other;
|
extern crate weak_lang_items as other;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = std::thread::spawn(move || {
|
// The goal of the test is just to make sure other::foo() is referenced at link time. Since
|
||||||
// The goal of the test is just to make sure other::foo() is called. Since the function
|
// the function panics, to prevent it from running we gate it behind an always-false `if` that
|
||||||
// panics, it's executed in its own thread. That way, the panic is isolated within the
|
// is not going to be optimized away.
|
||||||
// thread and wont't affect the overall exit code.
|
if std::hint::black_box(false) {
|
||||||
//
|
other::foo();
|
||||||
// That causes a spurious failures in panic=abort targets though: if the program exits
|
}
|
||||||
// before the thread is fully initialized the test will pass, but if the thread gets
|
|
||||||
// executed first the whole program will abort. Adding a 60 seconds sleep will (hopefully!)
|
|
||||||
// ensure the program always exits before the thread is executed.
|
|
||||||
std::thread::sleep(std::time::Duration::from_secs(60));
|
|
||||||
|
|
||||||
other::foo()
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue