summaryrefslogtreecommitdiff
path: root/test/test_poll.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2017-12-03 03:52:43 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2017-12-03 03:52:43 +0000
commit86ebf7b0eac4cd0d092b816060042c55ca8871c5 (patch)
tree3e4e6714d843edc493dfc3cf879d659bbd264e65 /test/test_poll.rs
parentd374a1ecd3f69027a2ce28e87806f459ef3f9105 (diff)
parente1baab9dc132f18e13f446df0271a5e46723848d (diff)
downloadnix-86ebf7b0eac4cd0d092b816060042c55ca8871c5.zip
Merge #801
801: Upgrade to Bitflags 1.0 r=asomers a=Susurrus The libc_bitflags! macro was replaced with a non-recursive one supporting only public structs. I could not figure out how to make the old macro work with the upgrade, so I reworked part of the bitflags! macro directly to suit our needs, much as the original recursive macro was made. There are no uses of this macro for non-public structs, so this is not a problem for internal code. Closes #766.
Diffstat (limited to 'test/test_poll.rs')
-rw-r--r--test/test_poll.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/test/test_poll.rs b/test/test_poll.rs
index a48604f9..c28c8fd8 100644
--- a/test/test_poll.rs
+++ b/test/test_poll.rs
@@ -1,4 +1,4 @@
-use nix::poll::*;
+use nix::poll::{EventFlags, poll, PollFd};
use nix::sys::signal::SigSet;
use nix::sys::time::{TimeSpec, TimeValLike};
use nix::unistd::{write, pipe};
@@ -6,19 +6,19 @@ use nix::unistd::{write, pipe};
#[test]
fn test_poll() {
let (r, w) = pipe().unwrap();
- let mut fds = [PollFd::new(r, POLLIN)];
+ let mut fds = [PollFd::new(r, EventFlags::POLLIN)];
// Poll an idle pipe. Should timeout
let nfds = poll(&mut fds, 100).unwrap();
assert_eq!(nfds, 0);
- assert!(!fds[0].revents().unwrap().contains(POLLIN));
+ assert!(!fds[0].revents().unwrap().contains(EventFlags::POLLIN));
write(w, b".").unwrap();
// Poll a readable pipe. Should return an event.
let nfds = poll(&mut fds, 100).unwrap();
assert_eq!(nfds, 1);
- assert!(fds[0].revents().unwrap().contains(POLLIN));
+ assert!(fds[0].revents().unwrap().contains(EventFlags::POLLIN));
}
// ppoll(2) is the same as poll except for how it handles timeouts and signals.
@@ -30,19 +30,20 @@ fn test_poll() {
target_os = "linux"))]
#[test]
fn test_ppoll() {
+ use nix::poll::ppoll;
let timeout = TimeSpec::milliseconds(1);
let (r, w) = pipe().unwrap();
- let mut fds = [PollFd::new(r, POLLIN)];
+ let mut fds = [PollFd::new(r, EventFlags::POLLIN)];
// Poll an idle pipe. Should timeout
let nfds = ppoll(&mut fds, timeout, SigSet::empty()).unwrap();
assert_eq!(nfds, 0);
- assert!(!fds[0].revents().unwrap().contains(POLLIN));
+ assert!(!fds[0].revents().unwrap().contains(EventFlags::POLLIN));
write(w, b".").unwrap();
// Poll a readable pipe. Should return an event.
let nfds = ppoll(&mut fds, timeout, SigSet::empty()).unwrap();
assert_eq!(nfds, 1);
- assert!(fds[0].revents().unwrap().contains(POLLIN));
+ assert!(fds[0].revents().unwrap().contains(EventFlags::POLLIN));
}