Skip to content

Commit

Permalink
Rollup merge of rust-lang#70416 - mzohreva:mz/sgx-test, r=nikomatsakis
Browse files Browse the repository at this point in the history
Process termination test for SGX

The issue is described in fortanix/rust-sgx#109

cc @jethrogb
  • Loading branch information
Dylan-DPC committed Apr 28, 2020
2 parents 6470169 + db1fbd4 commit 5f49ff7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/test/ui/process-termination/process-termination-blocking-io.rs
@@ -0,0 +1,18 @@
// program should terminate even if a thread is blocked on I/O.
// https://github.com/fortanix/rust-sgx/issues/109

// run-pass

use std::{net::TcpListener, sync::mpsc, thread};

fn main() {
let (tx, rx) = mpsc::channel();
thread::spawn(move || {
let listen = TcpListener::bind("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");
}
12 changes: 12 additions & 0 deletions src/test/ui/process-termination/process-termination-simple.rs
@@ -0,0 +1,12 @@
// program should terminate when std::process::exit is called from any thread

// run-pass

use std::{process, thread};

fn main() {
let h = thread::spawn(|| {
process::exit(0);
});
let _ = h.join();
}

0 comments on commit 5f49ff7

Please sign in to comment.