mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 10:45:18 +00:00
cf6d6050f7
* The WASI targets deal with the `main` symbol a bit differently than native so some `codegen` and `assembly` tests have been ignored. * All `ignore-emscripten` directives have been updated to `ignore-wasm32` to be more clear that all wasm targets are ignored and it's not just Emscripten. * Most `ignore-wasm32-bare` directives are now gone. * Some ignore directives for wasm were switched to `needs-unwind` instead. * Many `ignore-wasm32*` directives are removed as the tests work with WASI as opposed to `wasm32-unknown-unknown`.
46 lines
1.2 KiB
Rust
46 lines
1.2 KiB
Rust
//@ run-pass
|
|
|
|
#![allow(unused_must_use)]
|
|
#![allow(deprecated)]
|
|
//@ ignore-wasm32 no processes or threads
|
|
//@ ignore-sgx no processes
|
|
|
|
use std::{env, fmt, process, sync, thread};
|
|
|
|
struct SlowFmt(u32);
|
|
impl fmt::Debug for SlowFmt {
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
thread::sleep_ms(3);
|
|
self.0.fmt(f)
|
|
}
|
|
}
|
|
|
|
fn do_print(x: u32) {
|
|
let x = SlowFmt(x);
|
|
println!("{:?}{:?}{:?}{:?}{:?}", x, x, x, x, x);
|
|
}
|
|
|
|
fn main(){
|
|
if env::args().count() == 2 {
|
|
let barrier = sync::Arc::new(sync::Barrier::new(2));
|
|
let tbarrier = barrier.clone();
|
|
let t = thread::spawn(move || {
|
|
tbarrier.wait();
|
|
do_print(1);
|
|
});
|
|
barrier.wait();
|
|
do_print(2);
|
|
t.join();
|
|
} else {
|
|
let this = env::args().next().unwrap();
|
|
let output = process::Command::new(this).arg("-").output().unwrap();
|
|
for line in String::from_utf8(output.stdout).unwrap().lines() {
|
|
match line.chars().next().unwrap() {
|
|
'1' => assert_eq!(line, "11111"),
|
|
'2' => assert_eq!(line, "22222"),
|
|
chr => panic!("unexpected character {:?}", chr)
|
|
}
|
|
}
|
|
}
|
|
}
|