summaryrefslogtreecommitdiff
path: root/test/test_poll.rs
diff options
context:
space:
mode:
authorUtkarsh Kukreti <utkarshkukreti@gmail.com>2015-12-30 20:30:54 +0530
committerKamal Marhubi <kamal@marhubi.com>2016-01-25 17:50:39 -0500
commitcec5c6157b37c924b8a0139d5439fbc87d7becce (patch)
tree9d79663e29c1502ce4d514fa5e44c8c399365bc1 /test/test_poll.rs
parent5700e39180c30ac78598aed4ed94d3111658ec5e (diff)
downloadnix-cec5c6157b37c924b8a0139d5439fbc87d7becce.zip
Add everything from poll.h.
Diffstat (limited to 'test/test_poll.rs')
-rw-r--r--test/test_poll.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/test_poll.rs b/test/test_poll.rs
new file mode 100644
index 00000000..54fd4029
--- /dev/null
+++ b/test/test_poll.rs
@@ -0,0 +1,22 @@
+use nix::poll::*;
+use nix::unistd::{write, pipe};
+
+#[test]
+fn test_poll() {
+ let (r, w) = pipe().unwrap();
+ let mut fds = [PollFd {
+ fd: r,
+ events: POLLIN,
+ revents: EventFlags::empty()
+ }];
+
+ let nfds = poll(&mut fds, 100).unwrap();
+ assert_eq!(nfds, 0);
+ assert!(!fds[0].revents.contains(POLLIN));
+
+ write(w, b".").unwrap();
+
+ let nfds = poll(&mut fds, 100).unwrap();
+ assert_eq!(nfds, 1);
+ assert!(fds[0].revents.contains(POLLIN));
+}