Skip to content

Commit e4ad033

Browse files
committed
Add a test for ppoll
1 parent 9f4db8a commit e4ad033

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/test_poll.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
use nix::poll::*;
2+
use nix::sys::signal::SigSet;
3+
use nix::sys::time::{TimeSpec, TimeValLike};
24
use nix::unistd::{write, pipe};
35

46
#[test]
@@ -16,3 +18,22 @@ fn test_poll() {
1618
assert_eq!(nfds, 1);
1719
assert!(fds[0].revents().unwrap().contains(POLLIN));
1820
}
21+
22+
#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd",
23+
target_os = "linux"))]
24+
#[test]
25+
fn test_ppoll() {
26+
let timeout = TimeSpec::milliseconds(1);
27+
let (r, w) = pipe().unwrap();
28+
let mut fds = [PollFd::new(r, POLLIN)];
29+
30+
let nfds = ppoll(&mut fds, timeout, SigSet::empty()).unwrap();
31+
assert_eq!(nfds, 0);
32+
assert!(!fds[0].revents().unwrap().contains(POLLIN));
33+
34+
write(w, b".").unwrap();
35+
36+
let nfds = ppoll(&mut fds, timeout, SigSet::empty()).unwrap();
37+
assert_eq!(nfds, 1);
38+
assert!(fds[0].revents().unwrap().contains(POLLIN));
39+
}

0 commit comments

Comments
 (0)