blob: 13a95d2cde6687db15d6e7d876e304c1eb3844dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
use nix::poll::*;
use nix::unistd::{write, pipe};
#[test]
fn test_poll() {
let (r, w) = pipe().unwrap();
let mut fds = [PollFd::new(r, POLLIN, EventFlags::empty())];
let nfds = poll(&mut fds, 100).unwrap();
assert_eq!(nfds, 0);
assert!(!fds[0].revents().unwrap().contains(POLLIN));
write(w, b".").unwrap();
let nfds = poll(&mut fds, 100).unwrap();
assert_eq!(nfds, 1);
assert!(fds[0].revents().unwrap().contains(POLLIN));
}
|