diff options
Diffstat (limited to 'third_party/rust/mio/test/test_fuchsia_handles.rs')
-rw-r--r-- | third_party/rust/mio/test/test_fuchsia_handles.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/third_party/rust/mio/test/test_fuchsia_handles.rs b/third_party/rust/mio/test/test_fuchsia_handles.rs new file mode 100644 index 0000000000..85a14327f9 --- /dev/null +++ b/third_party/rust/mio/test/test_fuchsia_handles.rs @@ -0,0 +1,30 @@ +use mio::*; +use mio::fuchsia::EventedHandle; +use zircon::{self, AsHandleRef}; +use std::time::Duration; + +const MS: u64 = 1_000; + +#[test] +pub fn test_fuchsia_channel() { + let poll = Poll::new().unwrap(); + let mut event_buffer = Events::with_capacity(1); + let event_buffer = &mut event_buffer; + + let (channel0, channel1) = zircon::Channel::create(zircon::ChannelOpts::Normal).unwrap(); + let channel1_evented = unsafe { EventedHandle::new(channel1.raw_handle()) }; + + poll.register(&channel1_evented, Token(1), Ready::readable(), PollOpt::edge()).unwrap(); + + poll.poll(event_buffer, Some(Duration::from_millis(MS))).unwrap(); + assert_eq!(event_buffer.len(), 0); + + channel0.write(&[1, 2, 3], &mut vec![], 0).unwrap(); + + poll.poll(event_buffer, Some(Duration::from_millis(MS))).unwrap(); + let event = event_buffer.get(0).unwrap(); + assert_eq!(event.token(), Token(1)); + assert!(event.readiness().is_readable()); + + poll.deregister(&channel1_evented).unwrap(); +}
\ No newline at end of file |