summaryrefslogtreecommitdiff
path: root/test/sys/test_epoll.rs
blob: f31d874f800e1c54adacffb1c23e7ee4445648e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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();
}