diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /third_party/rust/mio/test/test_fuchsia_handles.rs | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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 |