1#![allow(deprecated)]
2
3use nix::errno::Errno;
4use nix::sys::epoll::{epoll_create1, epoll_ctl};
5use nix::sys::epoll::{EpollCreateFlags, EpollEvent, EpollFlags, EpollOp};
6
7#[test]
8pub fn test_epoll_errno() {
9 let efd = epoll_create1(EpollCreateFlags::empty()).unwrap();
10 let result = epoll_ctl(efd, EpollOp::EpollCtlDel, 1, None);
11 result.expect_err("assertion failed");
12 assert_eq!(result.unwrap_err(), Errno::ENOENT);
13
14 let result = epoll_ctl(efd, EpollOp::EpollCtlAdd, 1, None);
15 result.expect_err("assertion failed");
16 assert_eq!(result.unwrap_err(), Errno::EINVAL);
17}
18
19#[test]
20pub fn test_epoll_ctl() {
21 let efd = epoll_create1(EpollCreateFlags::empty()).unwrap();
22 let mut event =
23 EpollEvent::new(EpollFlags::EPOLLIN | EpollFlags::EPOLLERR, 1);
24 epoll_ctl(efd, EpollOp::EpollCtlAdd, 1, &mut event).unwrap();
25 epoll_ctl(efd, EpollOp::EpollCtlDel, 1, None).unwrap();
26}
27