3 use std
::process
::Command
;
4 use std
::sync
::atomic
::{AtomicBool, Ordering::SeqCst}
;
8 const PANICS
: usize = 100;
9 const THREADS
: usize = 8;
10 const VAR
: &str = "__THE_TEST_YOU_ARE_LUKE";
13 // These run in docker containers on CI where they can't re-exec the test,
14 // so just skip these for CI. No other reason this can't run on those
16 // Miri does not have support for re-execing a file
17 if cfg
!(unix
) && (cfg
!(target_arch
= "arm") || cfg
!(target_arch
= "aarch64")) || cfg
!(miri
) {
18 println
!("test result: ok");
22 if env
::var(VAR
).is_err() {
30 let me
= env
::current_exe().unwrap();
31 let result
= Command
::new(&me
)
32 .env("RUST_BACKTRACE", "1")
36 if result
.status
.success() {
37 println
!("test result: ok");
40 println
!("stdout:\n{}", String
::from_utf8_lossy(&result
.stdout
));
41 println
!("stderr:\n{}", String
::from_utf8_lossy(&result
.stderr
));
42 println
!("code: {}", result
.status
);
47 let done
= Arc
::new(AtomicBool
::new(false));
48 let done2
= done
.clone();
49 let a
= thread
::spawn(move || {
50 while !done2
.load(SeqCst
) {
51 format
!("{:?}", backtrace
::Backtrace
::new());
55 let threads
= (0..THREADS
)
59 assert
!(panic
::catch_unwind(|| {
67 for thread
in threads
{
68 thread
.join().unwrap();
71 done
.store(true, SeqCst
);