diff options
author | qupeng <onlyqupeng@gmail.com> | 2016-12-08 19:50:49 +0800 |
---|---|---|
committer | qupeng <onlyqupeng@gmail.com> | 2016-12-11 17:49:48 +0800 |
commit | bff660f1ed579b39f70f07a228f9135686242c6b (patch) | |
tree | 370b7dd6eba014e31594f694244e06404588ded4 /test/sys | |
parent | 2cfeb5758e1c4957acf4a8108a4c0793ef18a937 (diff) | |
download | nix-bff660f1ed579b39f70f07a228f9135686242c6b.zip |
fix #480 and add simple test cases for that.
r? @fiveop
Diffstat (limited to 'test/sys')
-rw-r--r-- | test/sys/mod.rs | 1 | ||||
-rw-r--r-- | test/sys/test_epoll.rs | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/test/sys/mod.rs b/test/sys/mod.rs index 6176eb32..b073ccf7 100644 --- a/test/sys/mod.rs +++ b/test/sys/mod.rs @@ -6,3 +6,4 @@ mod test_ioctl; mod test_wait; mod test_select; mod test_uio; +mod test_epoll; diff --git a/test/sys/test_epoll.rs b/test/sys/test_epoll.rs new file mode 100644 index 00000000..965c7d06 --- /dev/null +++ b/test/sys/test_epoll.rs @@ -0,0 +1,20 @@ +use nix::sys::epoll::{EpollCreateFlags, EpollFlags, EpollOp, EpollEvent}; +use nix::sys::epoll::{EPOLLIN, EPOLLERR}; +use nix::sys::epoll::{epoll_create1, epoll_ctl}; +use nix::{Error, Errno}; + +#[test] +pub fn test_epoll_errno() { + let efd = epoll_create1(EpollCreateFlags::empty()).unwrap(); + let result = epoll_ctl(efd, EpollOp::EpollCtlDel, 1, None); + assert!(result.is_err()); + assert_eq!(result.unwrap_err(), Error::Sys(Errno::ENOENT)); +} + +#[test] +pub fn test_epoll_ctl() { + let efd = epoll_create1(EpollCreateFlags::empty()).unwrap(); + let mut event = EpollEvent::new(EPOLLIN | EPOLLERR, 1); + epoll_ctl(efd, EpollOp::EpollCtlAdd, 1, &mut event).unwrap(); + epoll_ctl(efd, EpollOp::EpollCtlDel, 1, None).unwrap(); +} |