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