diff --git a/src/sys/epoll.rs b/src/sys/epoll.rs index 5ab766dcb9..3fae2f2df4 100644 --- a/src/sys/epoll.rs +++ b/src/sys/epoll.rs @@ -98,7 +98,10 @@ pub fn epoll_ctl<'a, T>(epfd: RawFd, op: EpollOp, fd: RawFd, event: T) -> Result Err(Error::Sys(Errno::EINVAL)) } else { let res = unsafe { libc::epoll_ctl(epfd, op as c_int, fd, &mut event.event) }; - Errno::result(res).map(drop) + println!("libc::epoll_ctl returned {:?}", res); + let retval = Errno::result(res).map(drop); + println!("in epoll_ctl, retval is {:?}", retval); + retval } } diff --git a/test/sys/test_epoll.rs b/test/sys/test_epoll.rs index a73fea6d80..11ce875a48 100644 --- a/test/sys/test_epoll.rs +++ b/test/sys/test_epoll.rs @@ -1,11 +1,11 @@ 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}; +use nix::{Error, Errno, Result}; #[test] pub fn test_epoll_errno() { - let efd = epoll_create1(EpollCreateFlags::empty()).unwrap(); + let efd = epoll_create1(EpollCreateFlags::empty()).expect("epoll_create1 failed"); let result = epoll_ctl(efd, EpollOp::EpollCtlDel, 1, None); assert!(result.is_err()); assert_eq!(result.unwrap_err(), Error::Sys(Errno::ENOENT)); @@ -17,8 +17,14 @@ pub fn test_epoll_errno() { #[test] pub fn test_epoll_ctl() { - let efd = epoll_create1(EpollCreateFlags::empty()).unwrap(); + let ok : Result<()> = Ok(()); + let notok: Result<()> = Err(Error::Sys(Errno::UnknownErrno)); + println!("In test_epoll_ctl, ok is {:?}, notok is {:?}", ok, notok); + + let efd = epoll_create1(EpollCreateFlags::empty()).expect("epoll_create1 failed"); 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(); + let epoll_ctl_res = epoll_ctl(efd, EpollOp::EpollCtlAdd, 1, &mut event); + println!("In test_epoll_ctl, result was {:?}", epoll_ctl_res); + epoll_ctl_res.expect("epoll_ctl 1 failed"); + epoll_ctl(efd, EpollOp::EpollCtlDel, 1, None).expect("epoll_ctl 2 failed"); }