diff options
| author | Mohsen Zohrevandi <mohsen.zohrevandi@fortanix.com> | 2020-03-25 19:28:14 -0700 |
|---|---|---|
| committer | Mohsen Zohrevandi <mohsen.zohrevandi@fortanix.com> | 2020-04-22 14:24:20 -0700 |
| commit | db1fbd4a11db579436f68be3a8f5fe03484aa45d (patch) | |
| tree | 30691fce892ffd193a96d294b3749c0dc304ea81 | |
| parent | 82e90d64266b8a4b53935d629786e69610b33f25 (diff) | |
| download | rust-db1fbd4a11db579436f68be3a8f5fe03484aa45d.tar.gz rust-db1fbd4a11db579436f68be3a8f5fe03484aa45d.zip | |
Process termination tests
Related issues: - https://github.com/fortanix/rust-sgx/issues/109
| -rw-r--r-- | src/test/ui/process-termination/process-termination-blocking-io.rs | 18 | ||||
| -rw-r--r-- | src/test/ui/process-termination/process-termination-simple.rs | 12 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/test/ui/process-termination/process-termination-blocking-io.rs b/src/test/ui/process-termination/process-termination-blocking-io.rs new file mode 100644 index 00000000000..d9027fc89e2 --- /dev/null +++ b/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"); +} diff --git a/src/test/ui/process-termination/process-termination-simple.rs b/src/test/ui/process-termination/process-termination-simple.rs new file mode 100644 index 00000000000..7098a34512e --- /dev/null +++ b/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(); +} |
