diff options
Diffstat (limited to 'test/sys')
-rw-r--r-- | test/sys/test_aio.rs | 2 | ||||
-rw-r--r-- | test/sys/test_epoll.rs | 4 | ||||
-rw-r--r-- | test/sys/test_inotify.rs | 4 | ||||
-rw-r--r-- | test/sys/test_ioctl.rs | 34 | ||||
-rw-r--r-- | test/sys/test_lio_listio_resubmit.rs | 8 | ||||
-rw-r--r-- | test/sys/test_ptrace.rs | 18 | ||||
-rw-r--r-- | test/sys/test_signal.rs | 4 | ||||
-rw-r--r-- | test/sys/test_socket.rs | 8 | ||||
-rw-r--r-- | test/sys/test_termios.rs | 6 | ||||
-rw-r--r-- | test/sys/test_wait.rs | 3 |
10 files changed, 46 insertions, 45 deletions
diff --git a/test/sys/test_aio.rs b/test/sys/test_aio.rs index 254d771b..f1d9a3b1 100644 --- a/test/sys/test_aio.rs +++ b/test/sys/test_aio.rs @@ -177,7 +177,7 @@ fn test_aio_suspend() { let cbbuf = [wcb.as_ref(), rcb.as_ref()]; let r = aio_suspend(&cbbuf[..], Some(timeout)); match r { - Err(Error::Sys(Errno::EINTR)) => continue, + Err(Error(Errno::EINTR)) => continue, Err(e) => panic!("aio_suspend returned {:?}", e), Ok(_) => () }; diff --git a/test/sys/test_epoll.rs b/test/sys/test_epoll.rs index e0dc5131..57bc4844 100644 --- a/test/sys/test_epoll.rs +++ b/test/sys/test_epoll.rs @@ -8,11 +8,11 @@ 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)); + assert_eq!(result.unwrap_err(), Error::from(Errno::ENOENT)); let result = epoll_ctl(efd, EpollOp::EpollCtlAdd, 1, None); assert!(result.is_err()); - assert_eq!(result.unwrap_err(), Error::Sys(Errno::EINVAL)); + assert_eq!(result.unwrap_err(), Error::from(Errno::EINVAL)); } #[test] diff --git a/test/sys/test_inotify.rs b/test/sys/test_inotify.rs index a8ead46d..121b726c 100644 --- a/test/sys/test_inotify.rs +++ b/test/sys/test_inotify.rs @@ -14,7 +14,7 @@ pub fn test_inotify() { instance.add_watch(tempdir.path(), AddWatchFlags::IN_ALL_EVENTS).unwrap(); let events = instance.read_events(); - assert_eq!(events.unwrap_err(), Error::Sys(Errno::EAGAIN)); + assert_eq!(events.unwrap_err(), Error::from(Errno::EAGAIN)); File::create(tempdir.path().join("test")).unwrap(); @@ -31,7 +31,7 @@ pub fn test_inotify_multi_events() { instance.add_watch(tempdir.path(), AddWatchFlags::IN_ALL_EVENTS).unwrap(); let events = instance.read_events(); - assert_eq!(events.unwrap_err(), Error::Sys(Errno::EAGAIN)); + assert_eq!(events.unwrap_err(), Error::from(Errno::EAGAIN)); File::create(tempdir.path().join("test")).unwrap(); rename(tempdir.path().join("test"), tempdir.path().join("test2")).unwrap(); diff --git a/test/sys/test_ioctl.rs b/test/sys/test_ioctl.rs index ddb86968..d65e43ac 100644 --- a/test/sys/test_ioctl.rs +++ b/test/sys/test_ioctl.rs @@ -167,15 +167,15 @@ mod linux_ioctls { use tempfile::tempfile; use libc::{TCGETS, TCSBRK, TCSETS, TIOCNXCL, termios}; - use nix::Error::Sys; - use nix::errno::Errno::{ENOTTY, ENOSYS}; + use nix::Error; + use nix::errno::Errno; ioctl_none_bad!(tiocnxcl, TIOCNXCL); #[test] fn test_ioctl_none_bad() { let file = tempfile().unwrap(); let res = unsafe { tiocnxcl(file.as_raw_fd()) }; - assert_eq!(res, Err(Sys(ENOTTY))); + assert_eq!(res, Err(Error(Errno::ENOTTY))); } ioctl_read_bad!(tcgets, TCGETS, termios); @@ -184,7 +184,7 @@ mod linux_ioctls { let file = tempfile().unwrap(); let mut termios = unsafe { mem::zeroed() }; let res = unsafe { tcgets(file.as_raw_fd(), &mut termios) }; - assert_eq!(res, Err(Sys(ENOTTY))); + assert_eq!(res, Err(Error(Errno::ENOTTY))); } ioctl_write_int_bad!(tcsbrk, TCSBRK); @@ -192,7 +192,7 @@ mod linux_ioctls { fn test_ioctl_write_int_bad() { let file = tempfile().unwrap(); let res = unsafe { tcsbrk(file.as_raw_fd(), 0) }; - assert_eq!(res, Err(Sys(ENOTTY))); + assert_eq!(res, Err(Error(Errno::ENOTTY))); } ioctl_write_ptr_bad!(tcsets, TCSETS, termios); @@ -201,7 +201,7 @@ mod linux_ioctls { let file = tempfile().unwrap(); let termios: termios = unsafe { mem::zeroed() }; let res = unsafe { tcsets(file.as_raw_fd(), &termios) }; - assert_eq!(res, Err(Sys(ENOTTY))); + assert_eq!(res, Err(Error(Errno::ENOTTY))); } // FIXME: Find a suitable example for `ioctl_readwrite_bad` @@ -212,7 +212,7 @@ mod linux_ioctls { fn test_ioctl_none() { let file = tempfile().unwrap(); let res = unsafe { log_status(file.as_raw_fd()) }; - assert!(res == Err(Sys(ENOTTY)) || res == Err(Sys(ENOSYS))); + assert!(res == Err(Error(Errno::ENOTTY)) || res == Err(Error(Errno::ENOSYS))); } #[repr(C)] @@ -231,7 +231,7 @@ mod linux_ioctls { let file = tempfile().unwrap(); let data: v4l2_audio = unsafe { mem::zeroed() }; let res = unsafe { s_audio(file.as_raw_fd(), &data) }; - assert!(res == Err(Sys(ENOTTY)) || res == Err(Sys(ENOSYS))); + assert!(res == Err(Error(Errno::ENOTTY)) || res == Err(Error(Errno::ENOSYS))); } // From linux/net/bluetooth/hci_sock.h @@ -242,7 +242,7 @@ mod linux_ioctls { fn test_ioctl_write_int() { let file = tempfile().unwrap(); let res = unsafe { hcidevup(file.as_raw_fd(), 0) }; - assert!(res == Err(Sys(ENOTTY)) || res == Err(Sys(ENOSYS))); + assert!(res == Err(Error(Errno::ENOTTY)) || res == Err(Error(Errno::ENOSYS))); } // From linux/videodev2.h @@ -252,7 +252,7 @@ mod linux_ioctls { let file = tempfile().unwrap(); let mut data: v4l2_audio = unsafe { mem::zeroed() }; let res = unsafe { g_audio(file.as_raw_fd(), &mut data) }; - assert!(res == Err(Sys(ENOTTY)) || res == Err(Sys(ENOSYS))); + assert!(res == Err(Error(Errno::ENOTTY)) || res == Err(Error(Errno::ENOSYS))); } // From linux/videodev2.h @@ -262,7 +262,7 @@ mod linux_ioctls { let file = tempfile().unwrap(); let mut data: v4l2_audio = unsafe { mem::zeroed() }; let res = unsafe { enum_audio(file.as_raw_fd(), &mut data) }; - assert!(res == Err(Sys(ENOTTY)) || res == Err(Sys(ENOSYS))); + assert!(res == Err(Error(Errno::ENOTTY)) || res == Err(Error(Errno::ENOSYS))); } // FIXME: Find a suitable example for `ioctl_read_buf`. @@ -288,7 +288,7 @@ mod linux_ioctls { let file = tempfile().unwrap(); let data: [spi_ioc_transfer; 4] = unsafe { mem::zeroed() }; let res = unsafe { spi_ioc_message(file.as_raw_fd(), &data[..]) }; - assert!(res == Err(Sys(ENOTTY)) || res == Err(Sys(ENOSYS))); + assert!(res == Err(Error(Errno::ENOTTY)) || res == Err(Error(Errno::ENOSYS))); } // FIXME: Find a suitable example for `ioctl_readwrite_buf`. @@ -302,8 +302,8 @@ mod freebsd_ioctls { use tempfile::tempfile; use libc::termios; - use nix::Error::Sys; - use nix::errno::Errno::ENOTTY; + use nix::Error; + use nix::errno::Errno; // From sys/sys/ttycom.h const TTY_IOC_MAGIC: u8 = b't'; @@ -316,7 +316,7 @@ mod freebsd_ioctls { fn test_ioctl_none() { let file = tempfile().unwrap(); let res = unsafe { tiocnxcl(file.as_raw_fd()) }; - assert_eq!(res, Err(Sys(ENOTTY))); + assert_eq!(res, Err(Error(Errno::ENOTTY))); } ioctl_read!(tiocgeta, TTY_IOC_MAGIC, TTY_IOC_TYPE_GETA, termios); @@ -325,7 +325,7 @@ mod freebsd_ioctls { let file = tempfile().unwrap(); let mut termios = unsafe { mem::zeroed() }; let res = unsafe { tiocgeta(file.as_raw_fd(), &mut termios) }; - assert_eq!(res, Err(Sys(ENOTTY))); + assert_eq!(res, Err(Error(Errno::ENOTTY))); } ioctl_write_ptr!(tiocseta, TTY_IOC_MAGIC, TTY_IOC_TYPE_SETA, termios); @@ -334,6 +334,6 @@ mod freebsd_ioctls { let file = tempfile().unwrap(); let termios: termios = unsafe { mem::zeroed() }; let res = unsafe { tiocseta(file.as_raw_fd(), &termios) }; - assert_eq!(res, Err(Sys(ENOTTY))); + assert_eq!(res, Err(Error(Errno::ENOTTY))); } } diff --git a/test/sys/test_lio_listio_resubmit.rs b/test/sys/test_lio_listio_resubmit.rs index 6b33aa4f..1c1941fb 100644 --- a/test/sys/test_lio_listio_resubmit.rs +++ b/test/sys/test_lio_listio_resubmit.rs @@ -25,7 +25,7 @@ fn finish_liocb(liocb: &mut LioCb) { let e = liocb.error(j); match e { Ok(()) => break, - Err(Error::Sys(Errno::EINPROGRESS)) => + Err(Error(Errno::EINPROGRESS)) => thread::sleep(time::Duration::from_millis(10)), Err(x) => panic!("aio_error({:?})", x) } @@ -82,9 +82,9 @@ fn test_lio_listio_resubmit() { } let mut liocb = builder.finish(); let mut err = liocb.listio(LioMode::LIO_NOWAIT, SigevNotify::SigevNone); - while err == Err(Error::Sys(Errno::EIO)) || - err == Err(Error::Sys(Errno::EAGAIN)) || - err == Err(Error::Sys(Errno::EINTR)) { + while err == Err(Error(Errno::EIO)) || + err == Err(Error(Errno::EAGAIN)) || + err == Err(Error(Errno::EINTR)) { // thread::sleep(time::Duration::from_millis(10)); resubmit_count += 1; diff --git a/test/sys/test_ptrace.rs b/test/sys/test_ptrace.rs index b9793b39..b8309a74 100644 --- a/test/sys/test_ptrace.rs +++ b/test/sys/test_ptrace.rs @@ -16,8 +16,8 @@ fn test_ptrace() { // FIXME: qemu-user doesn't implement ptrace on all arches, so permit ENOSYS require_capability!(CAP_SYS_PTRACE); let err = ptrace::attach(getpid()).unwrap_err(); - assert!(err == Error::Sys(Errno::EPERM) || err == Error::Sys(Errno::EINVAL) || - err == Error::Sys(Errno::ENOSYS)); + assert!(err == Error(Errno::EPERM) || err == Error(Errno::EINVAL) || + err == Error(Errno::ENOSYS)); } // Just make sure ptrace_setoptions can be called at all, for now. @@ -26,7 +26,7 @@ fn test_ptrace() { fn test_ptrace_setoptions() { require_capability!(CAP_SYS_PTRACE); let err = ptrace::setoptions(getpid(), Options::PTRACE_O_TRACESYSGOOD).unwrap_err(); - assert!(err != Error::UnsupportedOperation); + assert!(err != Error(Errno::EOPNOTSUPP)); } // Just make sure ptrace_getevent can be called at all, for now. @@ -35,7 +35,7 @@ fn test_ptrace_setoptions() { fn test_ptrace_getevent() { require_capability!(CAP_SYS_PTRACE); let err = ptrace::getevent(getpid()).unwrap_err(); - assert!(err != Error::UnsupportedOperation); + assert!(err != Error(Errno::EOPNOTSUPP)); } // Just make sure ptrace_getsiginfo can be called at all, for now. @@ -43,8 +43,8 @@ fn test_ptrace_getevent() { #[cfg(any(target_os = "android", target_os = "linux"))] fn test_ptrace_getsiginfo() { require_capability!(CAP_SYS_PTRACE); - if let Err(Error::UnsupportedOperation) = ptrace::getsiginfo(getpid()) { - panic!("ptrace_getsiginfo returns Error::UnsupportedOperation!"); + if let Err(Error(Errno::EOPNOTSUPP)) = ptrace::getsiginfo(getpid()) { + panic!("ptrace_getsiginfo returns Error(Errno::EOPNOTSUPP)!"); } } @@ -54,8 +54,8 @@ fn test_ptrace_getsiginfo() { fn test_ptrace_setsiginfo() { require_capability!(CAP_SYS_PTRACE); let siginfo = unsafe { mem::zeroed() }; - if let Err(Error::UnsupportedOperation) = ptrace::setsiginfo(getpid(), &siginfo) { - panic!("ptrace_setsiginfo returns Error::UnsupportedOperation!"); + if let Err(Error(Errno::EOPNOTSUPP)) = ptrace::setsiginfo(getpid(), &siginfo) { + panic!("ptrace_setsiginfo returns Error(Errno::EOPNOTSUPP)!"); } } @@ -79,7 +79,7 @@ fn test_ptrace_cont() { // On valid platforms the ptrace call should return Errno::EPERM, this // is already tested by `test_ptrace`. let err = ptrace::attach(getpid()).unwrap_err(); - if err == Error::Sys(Errno::ENOSYS) { + if err == Error(Errno::ENOSYS) { return; } diff --git a/test/sys/test_signal.rs b/test/sys/test_signal.rs index c8c13e52..741d97b9 100644 --- a/test/sys/test_signal.rs +++ b/test/sys/test_signal.rs @@ -1,5 +1,5 @@ #[cfg(not(target_os = "redox"))] -use nix::Error; +use nix::{errno::Errno, Error}; use nix::sys::signal::*; use nix::unistd::*; use std::convert::TryFrom; @@ -92,7 +92,7 @@ fn test_signal_sigaction() { let _m = crate::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test"); let action_handler = SigHandler::SigAction(test_sigaction_action); - assert_eq!(unsafe { signal(Signal::SIGINT, action_handler) }.unwrap_err(), Error::UnsupportedOperation); + assert_eq!(unsafe { signal(Signal::SIGINT, action_handler) }.unwrap_err(), Error(Errno::ENOTSUP)); } #[test] diff --git a/test/sys/test_socket.rs b/test/sys/test_socket.rs index c22eaeb1..c833aa7c 100644 --- a/test/sys/test_socket.rs +++ b/test/sys/test_socket.rs @@ -528,7 +528,7 @@ pub fn test_recvmsg_ebadf() { let iov = [IoVec::from_mut_slice(&mut buf[..])]; let fd = -1; // Bad file descriptor let r = recvmsg(fd, &iov, None, MsgFlags::empty()); - assert_eq!(r.err().unwrap(), Error::Sys(Errno::EBADF)); + assert_eq!(r.err().unwrap(), Error(Errno::EBADF)); } // Disable the test on emulated platforms due to a bug in QEMU versions < @@ -835,7 +835,7 @@ pub fn test_sendmsg_ipv6packetinfo() { let inet_addr = InetAddr::from_std(&std_sa); let sock_addr = SockAddr::new_inet(inet_addr); - if let Err(Error::Sys(Errno::EADDRNOTAVAIL)) = bind(sock, &sock_addr) { + if let Err(Error(Errno::EADDRNOTAVAIL)) = bind(sock, &sock_addr) { println!("IPv6 not available, skipping test."); return; } @@ -1153,7 +1153,7 @@ pub fn test_syscontrol() { SockFlag::empty(), SockProtocol::KextControl) .expect("socket failed"); let _sockaddr = SockAddr::new_sys_control(fd, "com.apple.net.utun_control", 0).expect("resolving sys_control name failed"); - assert_eq!(SockAddr::new_sys_control(fd, "foo.bar.lol", 0).err(), Some(Error::Sys(Errno::ENOENT))); + assert_eq!(SockAddr::new_sys_control(fd, "foo.bar.lol", 0).err(), Some(Error(Errno::ENOENT))); // requires root privileges // connect(fd, &sockaddr).expect("connect failed"); @@ -1516,7 +1516,7 @@ pub fn test_vsock() { // VMADDR_CID_HYPERVISOR is reserved, so we expect an EADDRNOTAVAIL error. let sockaddr = SockAddr::new_vsock(libc::VMADDR_CID_HYPERVISOR, port); assert_eq!(bind(s1, &sockaddr).err(), - Some(Error::Sys(Errno::EADDRNOTAVAIL))); + Some(Error(Errno::EADDRNOTAVAIL))); let sockaddr = SockAddr::new_vsock(libc::VMADDR_CID_ANY, port); assert_eq!(bind(s1, &sockaddr), Ok(())); diff --git a/test/sys/test_termios.rs b/test/sys/test_termios.rs index 00aeb2fc..ce436a13 100644 --- a/test/sys/test_termios.rs +++ b/test/sys/test_termios.rs @@ -32,14 +32,14 @@ fn test_tcgetattr_pty() { fn test_tcgetattr_enotty() { let file = tempfile().unwrap(); assert_eq!(termios::tcgetattr(file.as_raw_fd()).err(), - Some(Error::Sys(Errno::ENOTTY))); + Some(Error(Errno::ENOTTY))); } // Test tcgetattr on an invalid file descriptor #[test] fn test_tcgetattr_ebadf() { assert_eq!(termios::tcgetattr(-1).err(), - Some(Error::Sys(Errno::EBADF))); + Some(Error(Errno::EBADF))); } // Test modifying output flags @@ -126,5 +126,5 @@ fn test_local_flags() { let read = read(pty.master, &mut buf).unwrap_err(); close(pty.master).unwrap(); close(pty.slave).unwrap(); - assert_eq!(read, Error::Sys(Errno::EAGAIN)); + assert_eq!(read, Error(Errno::EAGAIN)); } diff --git a/test/sys/test_wait.rs b/test/sys/test_wait.rs index f68b8b08..65220474 100644 --- a/test/sys/test_wait.rs +++ b/test/sys/test_wait.rs @@ -1,3 +1,4 @@ +use nix::errno::Errno; use nix::Error; use nix::unistd::*; use nix::unistd::ForkResult::*; @@ -41,7 +42,7 @@ fn test_waitstatus_from_raw() { let pid = Pid::from_raw(1); assert_eq!(WaitStatus::from_raw(pid, 0x0002), Ok(WaitStatus::Signaled(pid, Signal::SIGINT, false))); assert_eq!(WaitStatus::from_raw(pid, 0x0200), Ok(WaitStatus::Exited(pid, 2))); - assert_eq!(WaitStatus::from_raw(pid, 0x7f7f), Err(Error::invalid_argument())); + assert_eq!(WaitStatus::from_raw(pid, 0x7f7f), Err(Error(Errno::EINVAL))); } #[test] |