1
1
use nix:: sys:: epoll:: { EpollCreateFlags , EpollFlags , EpollOp , EpollEvent } ;
2
2
use nix:: sys:: epoll:: { epoll_create1, epoll_ctl} ;
3
- use nix:: { Error , Errno } ;
3
+ use nix:: { Error , Errno , Result } ;
4
4
5
5
#[ test]
6
6
pub fn test_epoll_errno ( ) {
7
- let efd = epoll_create1 ( EpollCreateFlags :: empty ( ) ) . unwrap ( ) ;
7
+ let efd = epoll_create1 ( EpollCreateFlags :: empty ( ) ) . expect ( "epoll_create1 failed" ) ;
8
8
let result = epoll_ctl ( efd, EpollOp :: EpollCtlDel , 1 , None ) ;
9
9
assert ! ( result. is_err( ) ) ;
10
10
assert_eq ! ( result. unwrap_err( ) , Error :: Sys ( Errno :: ENOENT ) ) ;
@@ -16,8 +16,14 @@ pub fn test_epoll_errno() {
16
16
17
17
#[ test]
18
18
pub fn test_epoll_ctl ( ) {
19
- let efd = epoll_create1 ( EpollCreateFlags :: empty ( ) ) . unwrap ( ) ;
19
+ let ok : Result < ( ) > = Ok ( ( ) ) ;
20
+ let notok: Result < ( ) > = Err ( Error :: Sys ( Errno :: UnknownErrno ) ) ;
21
+ println ! ( "In test_epoll_ctl, ok is {:?}, notok is {:?}" , ok, notok) ;
22
+
23
+ let efd = epoll_create1 ( EpollCreateFlags :: empty ( ) ) . expect ( "epoll_create1 failed" ) ;
20
24
let mut event = EpollEvent :: new ( EpollFlags :: EPOLLIN | EpollFlags :: EPOLLERR , 1 ) ;
21
- epoll_ctl ( efd, EpollOp :: EpollCtlAdd , 1 , & mut event) . unwrap ( ) ;
22
- epoll_ctl ( efd, EpollOp :: EpollCtlDel , 1 , None ) . unwrap ( ) ;
25
+ let epoll_ctl_res = epoll_ctl ( efd, EpollOp :: EpollCtlAdd , 1 , & mut event) ;
26
+ println ! ( "In test_epoll_ctl, result was {:?}" , epoll_ctl_res) ;
27
+ epoll_ctl_res. expect ( "epoll_ctl 1 failed" ) ;
28
+ epoll_ctl ( efd, EpollOp :: EpollCtlDel , 1 , None ) . expect ( "epoll_ctl 2 failed" ) ;
23
29
}
0 commit comments