-
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.
Auto merge of #70416 - mzohreva:mz/sgx-test, r=nikomatsakis
Process termination test for SGX The issue is described in fortanix/rust-sgx#109 cc @jethrogb
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/test/ui/process-termination/process-termination-blocking-io.rs
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// program should terminate even if a thread is blocked on I/O. | ||
// https://github.com/fortanix/rust-sgx/issues/109 | ||
|
||
// run-pass | ||
// ignore-emscripten no threads support | ||
|
||
use std::{net::TcpListener, sync::mpsc, thread}; | ||
|
||
fn main() { | ||
let (tx, rx) = mpsc::channel(); | ||
thread::spawn(move || { | ||
let listen = TcpListener::bind("0.0.0.0:0").unwrap(); | ||
tx.send(()).unwrap(); | ||
while let Ok(_) = listen.accept() {} | ||
}); | ||
rx.recv().unwrap(); | ||
for _ in 0..3 { thread::yield_now(); } | ||
println!("Exiting main thread"); | ||
} |
13 changes: 13 additions & 0 deletions
13
src/test/ui/process-termination/process-termination-simple.rs
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// program should terminate when std::process::exit is called from any thread | ||
|
||
// run-pass | ||
// ignore-emscripten no threads support | ||
|
||
use std::{process, thread}; | ||
|
||
fn main() { | ||
let h = thread::spawn(|| { | ||
process::exit(0); | ||
}); | ||
let _ = h.join(); | ||
} |