-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change test to use
if black_box(false)
- Loading branch information
1 parent
d8fb568
commit 409d994
Showing
1 changed file
with
6 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,15 @@ | ||
// run-pass | ||
// aux-build:weak-lang-items.rs | ||
|
||
// ignore-emscripten no threads support | ||
// pretty-expanded FIXME #23616 | ||
|
||
extern crate weak_lang_items as other; | ||
|
||
fn main() { | ||
let _ = std::thread::spawn(move || { | ||
// The goal of the test is just to make sure other::foo() is called. Since the function | ||
// panics, it's executed in its own thread. That way, the panic is isolated within the | ||
// thread and wont't affect the overall exit code. | ||
// | ||
// 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() | ||
}); | ||
// The goal of the test is just to make sure other::foo() is referenced at link time. Since | ||
// the function panics, to prevent it from running we gate it behind an always-false `if` that | ||
// is not going to be optimized away. | ||
if std::hint::black_box(false) { | ||
other::foo(); | ||
} | ||
} |