Files
tokio/tokio-sync/tests/fuzz_mpsc.rs
T

43 lines
805 B
Rust
Raw Normal View History

2019-05-14 10:27:36 -07:00
#![deny(warnings, rust_2018_idioms)]
#![feature(async_await)]
2019-05-14 10:27:36 -07:00
2019-02-20 10:05:56 -08:00
#[macro_use]
extern crate loom;
macro_rules! if_fuzz {
($($t:tt)*) => {
$($t)*
}
}
#[path = "../src/mpsc/mod.rs"]
#[allow(warnings)]
mod mpsc;
#[path = "../src/semaphore.rs"]
#[allow(warnings)]
mod semaphore;
2019-06-24 12:34:30 -07:00
// use futures::{future::poll_fn, Stream};
use async_util::future::poll_fn;
2019-02-20 10:05:56 -08:00
use loom::futures::block_on;
use loom::thread;
#[test]
fn closing_tx() {
loom::fuzz(|| {
let (mut tx, mut rx) = mpsc::channel(16);
thread::spawn(move || {
tx.try_send(()).unwrap();
drop(tx);
});
let v = block_on(poll_fn(|cx| rx.poll_recv(cx)));
2019-02-20 10:05:56 -08:00
assert!(v.is_some());
let v = block_on(poll_fn(|cx| rx.poll_recv(cx)));
2019-02-20 10:05:56 -08:00
assert!(v.is_none());
});
}