diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/sys/mod.rs | 3 | ||||
-rw-r--r-- | test/sys/test_epoll.rs | 20 |
2 files changed, 23 insertions, 0 deletions
diff --git a/test/sys/mod.rs b/test/sys/mod.rs index 6176eb32..d2c38c3e 100644 --- a/test/sys/mod.rs +++ b/test/sys/mod.rs @@ -6,3 +6,6 @@ mod test_ioctl; mod test_wait; mod test_select; mod test_uio; + +#[cfg(target_os = "linux")] +mod test_epoll; diff --git a/test/sys/test_epoll.rs b/test/sys/test_epoll.rs new file mode 100644 index 00000000..f31d874f --- /dev/null +++ b/test/sys/test_epoll.rs @@ -0,0 +1,20 @@ +use nix::sys::epoll::{EpollCreateFlags, 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(); +} |