The unit test of this_thread.rs started its second thread with std::thread::spawn inside the
module's own #[cfg(test)] block, under src/. exit_guard's
threads_and_the_program_s_code_go_through_the_guard reads every runtime source under src/ but
src/tests/ for thread starts outside exit_guard.rs, so it failed on that test's spawn (reported
by the halfnative worker's translator-suite run on msi at b8bb54e69f).
The test moves, unchanged, to src/tests/this_thread.rs, beside the runtime's other tests, which
that check leaves out by their directory; this_thread.rs keeps only id and runs. No allowlist.
Verified: the fail-first run at f3c9f748ce and the run at this commit follow (runtime crate,
threads_and_the_program_s_code_go_through_the_guard and a_thread_tells_itself_from_another).
26 lines
835 B
Rust
26 lines
835 B
Rust
//! The calling thread's identity (`this_thread.rs`), on threads the test starts. No device is
|
|
//! opened.
|
|
|
|
use crate::this_thread::{id, runs};
|
|
use std::sync::mpsc;
|
|
use std::thread::JoinHandle;
|
|
|
|
/// A thread reads the same identity each time, another live thread another one, and a thread's
|
|
/// handle runs on that thread alone.
|
|
#[test]
|
|
fn a_thread_tells_itself_from_another() {
|
|
let here = id();
|
|
assert_eq!(id(), here);
|
|
let (give, take) = mpsc::channel::<JoinHandle<()>>();
|
|
let (tell, told) = mpsc::channel();
|
|
let handle = std::thread::spawn(move || {
|
|
let own = take.recv().unwrap();
|
|
tell.send((id(), runs(&own))).unwrap();
|
|
});
|
|
assert!(!runs(&handle));
|
|
give.send(handle).unwrap();
|
|
let (there, ran_there) = told.recv().unwrap();
|
|
assert_ne!(there, here);
|
|
assert!(ran_there);
|
|
}
|