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/test_epoll.rs | |
parent | 2cfeb5758e1c4957acf4a8108a4c0793ef18a937 (diff) | |
download | nix-bff660f1ed579b39f70f07a228f9135686242c6b.zip |
fix #480 and add simple test cases for that.
r? @fiveop
Diffstat (limited to 'test/sys/test_epoll.rs')
-rw-r--r-- | test/sys/test_epoll.rs | 20 |
1 files changed, 20 insertions, 0 deletions
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(); +} |