summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/sys/test_aio.rs4
-rw-r--r--test/sys/test_aio_drop.rs3
-rw-r--r--test/sys/test_lio_listio_resubmit.rs4
-rw-r--r--test/sys/test_ptrace.rs4
-rw-r--r--test/sys/test_select.rs2
-rw-r--r--test/sys/test_signal.rs8
-rw-r--r--test/sys/test_signalfd.rs2
-rw-r--r--test/sys/test_termios.rs8
-rw-r--r--test/sys/test_uio.rs2
-rw-r--r--test/sys/test_wait.rs8
-rw-r--r--test/test.rs11
-rw-r--r--test/test_clearenv.rs2
-rw-r--r--test/test_dir.rs5
-rw-r--r--test/test_kmod/mod.rs30
-rw-r--r--test/test_mount.rs4
-rw-r--r--test/test_pty.rs30
-rw-r--r--test/test_ptymaster_drop.rs2
-rw-r--r--test/test_stat.rs4
-rw-r--r--test/test_unistd.rs88
19 files changed, 97 insertions, 124 deletions
diff --git a/test/sys/test_aio.rs b/test/sys/test_aio.rs
index d03adc5e..6b9bd911 100644
--- a/test/sys/test_aio.rs
+++ b/test/sys/test_aio.rs
@@ -445,7 +445,7 @@ extern fn sigfunc(_: c_int) {
#[test]
#[cfg_attr(any(all(target_env = "musl", target_arch = "x86_64"), target_arch = "mips", target_arch = "mips64"), ignore)]
fn test_write_sigev_signal() {
- let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
let sa = SigAction::new(SigHandler::Handler(sigfunc),
SaFlags::SA_RESETHAND,
SigSet::empty());
@@ -583,7 +583,7 @@ fn test_liocb_listio_nowait() {
#[cfg(not(any(target_os = "ios", target_os = "macos")))]
#[cfg_attr(any(target_arch = "mips", target_arch = "mips64", target_env = "musl"), ignore)]
fn test_liocb_listio_signal() {
- let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
const INITIAL: &[u8] = b"abcdef123456";
const WBUF: &[u8] = b"CDEF";
let mut rbuf = vec![0; 4];
diff --git a/test/sys/test_aio_drop.rs b/test/sys/test_aio_drop.rs
index 492da401..71a2183b 100644
--- a/test/sys/test_aio_drop.rs
+++ b/test/sys/test_aio_drop.rs
@@ -1,6 +1,3 @@
-extern crate nix;
-extern crate tempfile;
-
// Test dropping an AioCb that hasn't yet finished.
// This must happen in its own process, because on OSX this test seems to hose
// the AIO subsystem and causes subsequent tests to fail
diff --git a/test/sys/test_lio_listio_resubmit.rs b/test/sys/test_lio_listio_resubmit.rs
index 19ee3fac..0795370b 100644
--- a/test/sys/test_lio_listio_resubmit.rs
+++ b/test/sys/test_lio_listio_resubmit.rs
@@ -4,10 +4,6 @@
// we must disable the test here rather than in Cargo.toml
#![cfg(target_os = "freebsd")]
-extern crate nix;
-extern crate sysctl;
-extern crate tempfile;
-
use nix::Error;
use nix::errno::*;
use nix::libc::off_t;
diff --git a/test/sys/test_ptrace.rs b/test/sys/test_ptrace.rs
index cb2f04e9..05f407cc 100644
--- a/test/sys/test_ptrace.rs
+++ b/test/sys/test_ptrace.rs
@@ -68,7 +68,7 @@ fn test_ptrace_cont() {
require_capability!(CAP_SYS_PTRACE);
- let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
// FIXME: qemu-user doesn't implement ptrace on all architectures
// and retunrs ENOSYS in this case.
@@ -128,7 +128,7 @@ fn test_ptrace_syscall() {
use nix::unistd::getpid;
use nix::unistd::ForkResult::*;
- let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
match fork().expect("Error: Fork Failed") {
Child => {
diff --git a/test/sys/test_select.rs b/test/sys/test_select.rs
index cf68700c..37951086 100644
--- a/test/sys/test_select.rs
+++ b/test/sys/test_select.rs
@@ -5,7 +5,7 @@ use nix::sys::time::{TimeSpec, TimeValLike};
#[test]
pub fn test_pselect() {
- let _mtx = ::SIGNAL_MTX
+ let _mtx = crate::SIGNAL_MTX
.lock()
.expect("Mutex got poisoned by another test");
diff --git a/test/sys/test_signal.rs b/test/sys/test_signal.rs
index 1c3a25f8..5e0b2762 100644
--- a/test/sys/test_signal.rs
+++ b/test/sys/test_signal.rs
@@ -19,7 +19,7 @@ fn test_killpg_none() {
#[test]
fn test_old_sigaction_flags() {
- let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
extern "C" fn handler(_: ::libc::c_int) {}
let act = SigAction::new(
@@ -41,7 +41,7 @@ fn test_sigprocmask_noop() {
#[test]
fn test_sigprocmask() {
- let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
// This needs to be a signal that rust doesn't use in the test harness.
const SIGNAL: Signal = Signal::SIGCHLD;
@@ -89,7 +89,7 @@ extern fn test_sigaction_action(_: libc::c_int, _: *mut libc::siginfo_t, _: *mut
#[test]
#[cfg(not(target_os = "redox"))]
fn test_signal_sigaction() {
- let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
+ 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);
@@ -97,7 +97,7 @@ fn test_signal_sigaction() {
#[test]
fn test_signal() {
- let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
unsafe { signal(Signal::SIGINT, SigHandler::SigIgn) }.unwrap();
raise(Signal::SIGINT).unwrap();
diff --git a/test/sys/test_signalfd.rs b/test/sys/test_signalfd.rs
index 92759a48..af04c222 100644
--- a/test/sys/test_signalfd.rs
+++ b/test/sys/test_signalfd.rs
@@ -6,7 +6,7 @@ fn test_signalfd() {
use nix::sys::signal::{self, raise, Signal, SigSet};
// Grab the mutex for altering signals so we don't interfere with other tests.
- let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
// Block the SIGUSR1 signal from automatic processing for this thread
let mut mask = SigSet::empty();
diff --git a/test/sys/test_termios.rs b/test/sys/test_termios.rs
index a14b8ce1..40b47af4 100644
--- a/test/sys/test_termios.rs
+++ b/test/sys/test_termios.rs
@@ -19,7 +19,7 @@ fn write_all(f: RawFd, buf: &[u8]) {
#[test]
fn test_tcgetattr_pty() {
// openpty uses ptname(3) internally
- let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
let pty = openpty(None, None).expect("openpty failed");
assert!(termios::tcgetattr(pty.master).is_ok());
@@ -46,7 +46,7 @@ fn test_tcgetattr_ebadf() {
#[test]
fn test_output_flags() {
// openpty uses ptname(3) internally
- let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
// Open one pty to get attributes for the second one
let mut termios = {
@@ -77,7 +77,7 @@ fn test_output_flags() {
// Read from the slave verifying that the output has been properly transformed
let mut buf = [0u8; 10];
- ::read_exact(pty.slave, &mut buf);
+ crate::read_exact(pty.slave, &mut buf);
let transformed_string = "foofoofoo\n";
close(pty.master).unwrap();
close(pty.slave).unwrap();
@@ -88,7 +88,7 @@ fn test_output_flags() {
#[test]
fn test_local_flags() {
// openpty uses ptname(3) internally
- let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
// Open one pty to get attributes for the second one
let mut termios = {
diff --git a/test/sys/test_uio.rs b/test/sys/test_uio.rs
index d0025b87..236560f4 100644
--- a/test/sys/test_uio.rs
+++ b/test/sys/test_uio.rs
@@ -205,7 +205,7 @@ fn test_process_vm_readv() {
use nix::sys::wait::*;
require_capability!(CAP_SYS_PTRACE);
- let _ = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
+ let _ = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
// Pre-allocate memory in the child, since allocation isn't safe
// post-fork (~= async-signal-safe)
diff --git a/test/sys/test_wait.rs b/test/sys/test_wait.rs
index 6b0fb321..53b7c84a 100644
--- a/test/sys/test_wait.rs
+++ b/test/sys/test_wait.rs
@@ -8,7 +8,7 @@ use libc::_exit;
#[test]
#[cfg(not(target_os = "redox"))]
fn test_wait_signal() {
- let _ = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
+ let _ = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
// Safe: The child only calls `pause` and/or `_exit`, which are async-signal-safe.
match fork().expect("Error: Fork Failed") {
@@ -25,7 +25,7 @@ fn test_wait_signal() {
#[test]
fn test_wait_exit() {
- let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
// Safe: Child only calls `_exit`, which is async-signal-safe.
match fork().expect("Error: Fork Failed") {
@@ -46,7 +46,7 @@ fn test_waitstatus_from_raw() {
#[test]
fn test_waitstatus_pid() {
- let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
match fork().unwrap() {
Child => unsafe { _exit(0) },
@@ -96,7 +96,7 @@ mod ptrace {
#[test]
fn test_wait_ptrace() {
require_capability!(CAP_SYS_PTRACE);
- let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
match fork().expect("Error: Fork Failed") {
Child => ptrace_child(),
diff --git a/test/test.rs b/test/test.rs
index 5319c1d8..ac842b11 100644
--- a/test/test.rs
+++ b/test/test.rs
@@ -1,18 +1,9 @@
-extern crate bytes;
-#[cfg(any(target_os = "android", target_os = "linux"))]
-extern crate caps;
#[macro_use]
extern crate cfg_if;
#[cfg_attr(not(target_os = "redox"), macro_use)]
extern crate nix;
#[macro_use]
extern crate lazy_static;
-extern crate libc;
-extern crate rand;
-#[cfg(target_os = "freebsd")]
-extern crate sysctl;
-extern crate tempfile;
-extern crate semver;
cfg_if! {
if #[cfg(any(target_os = "android", target_os = "linux"))] {
@@ -207,7 +198,7 @@ struct DirRestore<'a> {
impl<'a> DirRestore<'a> {
fn new() -> Self {
- let guard = ::CWD_LOCK.write()
+ let guard = crate::CWD_LOCK.write()
.expect("Lock got poisoned by another test");
DirRestore{
_g: guard,
diff --git a/test/test_clearenv.rs b/test/test_clearenv.rs
index f122f7c6..28a77680 100644
--- a/test/test_clearenv.rs
+++ b/test/test_clearenv.rs
@@ -1,5 +1,3 @@
-extern crate nix;
-
use std::env;
#[test]
diff --git a/test/test_dir.rs b/test/test_dir.rs
index c42fbcd1..c5f9c517 100644
--- a/test/test_dir.rs
+++ b/test/test_dir.rs
@@ -1,11 +1,8 @@
-extern crate nix;
-extern crate tempfile;
-
use nix::dir::{Dir, Type};
use nix::fcntl::OFlag;
use nix::sys::stat::Mode;
use std::fs::File;
-use self::tempfile::tempdir;
+use tempfile::tempdir;
#[test]
fn read() {
diff --git a/test/test_kmod/mod.rs b/test/test_kmod/mod.rs
index ad406357..e7472ab8 100644
--- a/test/test_kmod/mod.rs
+++ b/test/test_kmod/mod.rs
@@ -4,7 +4,7 @@ use std::process::Command;
use tempfile::{tempdir, TempDir};
fn compile_kernel_module() -> (PathBuf, String, TempDir) {
- let _m = ::FORK_MTX
+ let _m = crate::FORK_MTX
.lock()
.expect("Mutex got poisoned by another test");
@@ -41,8 +41,8 @@ use std::io::Read;
#[test]
fn test_finit_and_delete_module() {
require_capability!(CAP_SYS_MODULE);
- let _m0 = ::KMOD_MTX.lock().expect("Mutex got poisoned by another test");
- let _m1 = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
+ let _m0 = crate::KMOD_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m1 = crate::CWD_LOCK.read().expect("Mutex got poisoned by another test");
let (kmod_path, kmod_name, _kmod_dir) = compile_kernel_module();
@@ -59,8 +59,8 @@ fn test_finit_and_delete_module() {
#[test]
fn test_finit_and_delete_modul_with_params() {
require_capability!(CAP_SYS_MODULE);
- let _m0 = ::KMOD_MTX.lock().expect("Mutex got poisoned by another test");
- let _m1 = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
+ let _m0 = crate::KMOD_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m1 = crate::CWD_LOCK.read().expect("Mutex got poisoned by another test");
let (kmod_path, kmod_name, _kmod_dir) = compile_kernel_module();
@@ -80,8 +80,8 @@ fn test_finit_and_delete_modul_with_params() {
#[test]
fn test_init_and_delete_module() {
require_capability!(CAP_SYS_MODULE);
- let _m0 = ::KMOD_MTX.lock().expect("Mutex got poisoned by another test");
- let _m1 = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
+ let _m0 = crate::KMOD_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m1 = crate::CWD_LOCK.read().expect("Mutex got poisoned by another test");
let (kmod_path, kmod_name, _kmod_dir) = compile_kernel_module();
@@ -100,8 +100,8 @@ fn test_init_and_delete_module() {
#[test]
fn test_init_and_delete_module_with_params() {
require_capability!(CAP_SYS_MODULE);
- let _m0 = ::KMOD_MTX.lock().expect("Mutex got poisoned by another test");
- let _m1 = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
+ let _m0 = crate::KMOD_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m1 = crate::CWD_LOCK.read().expect("Mutex got poisoned by another test");
let (kmod_path, kmod_name, _kmod_dir) = compile_kernel_module();
@@ -121,8 +121,8 @@ fn test_init_and_delete_module_with_params() {
#[test]
fn test_finit_module_invalid() {
require_capability!(CAP_SYS_MODULE);
- let _m0 = ::KMOD_MTX.lock().expect("Mutex got poisoned by another test");
- let _m1 = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
+ let _m0 = crate::KMOD_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m1 = crate::CWD_LOCK.read().expect("Mutex got poisoned by another test");
let kmod_path = "/dev/zero";
@@ -135,8 +135,8 @@ fn test_finit_module_invalid() {
#[test]
fn test_finit_module_twice_and_delete_module() {
require_capability!(CAP_SYS_MODULE);
- let _m0 = ::KMOD_MTX.lock().expect("Mutex got poisoned by another test");
- let _m1 = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
+ let _m0 = crate::KMOD_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m1 = crate::CWD_LOCK.read().expect("Mutex got poisoned by another test");
let (kmod_path, kmod_name, _kmod_dir) = compile_kernel_module();
@@ -157,8 +157,8 @@ fn test_finit_module_twice_and_delete_module() {
#[test]
fn test_delete_module_not_loaded() {
require_capability!(CAP_SYS_MODULE);
- let _m0 = ::KMOD_MTX.lock().expect("Mutex got poisoned by another test");
- let _m1 = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
+ let _m0 = crate::KMOD_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m1 = crate::CWD_LOCK.read().expect("Mutex got poisoned by another test");
let result = delete_module(&CString::new("hello").unwrap(), DeleteModuleFlags::empty());
diff --git a/test/test_mount.rs b/test/test_mount.rs
index d2e08bc4..605276b5 100644
--- a/test/test_mount.rs
+++ b/test/test_mount.rs
@@ -3,10 +3,6 @@
// namespaces (Linux >= 3.8 compiled with CONFIG_USER_NS), the test should run
// without root.
-extern crate libc;
-extern crate nix;
-extern crate tempfile;
-
#[cfg(target_os = "linux")]
mod test_mount {
use std::fs::{self, File};
diff --git a/test/test_pty.rs b/test/test_pty.rs
index 2608c904..1e085877 100644
--- a/test/test_pty.rs
+++ b/test/test_pty.rs
@@ -29,7 +29,7 @@ fn test_explicit_close() {
#[test]
#[cfg(any(target_os = "android", target_os = "linux"))]
fn test_ptsname_equivalence() {
- let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
// Open a new PTTY master
let master_fd = posix_openpt(OFlag::O_RDWR).unwrap();
@@ -46,7 +46,7 @@ fn test_ptsname_equivalence() {
#[test]
#[cfg(any(target_os = "android", target_os = "linux"))]
fn test_ptsname_copy() {
- let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
// Open a new PTTY master
let master_fd = posix_openpt(OFlag::O_RDWR).unwrap();
@@ -80,7 +80,7 @@ fn test_ptsname_r_copy() {
#[test]
#[cfg(any(target_os = "android", target_os = "linux"))]
fn test_ptsname_unique() {
- let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
// Open a new PTTY master
let master1_fd = posix_openpt(OFlag::O_RDWR).unwrap();
@@ -98,7 +98,7 @@ fn test_ptsname_unique() {
/// Common setup for testing PTTY pairs
fn open_ptty_pair() -> (PtyMaster, File) {
- let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
// Open a new PTTY master
let master = posix_openpt(OFlag::O_RDWR).expect("posix_openpt failed");
@@ -163,7 +163,7 @@ fn test_write_ptty_pair() {
#[test]
fn test_openpty() {
// openpty uses ptname(3) internally
- let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
let pty = openpty(None, None).unwrap();
assert!(pty.master > 0);
@@ -173,21 +173,21 @@ fn test_openpty() {
let string = "foofoofoo\n";
let mut buf = [0u8; 10];
write(pty.master, string.as_bytes()).unwrap();
- ::read_exact(pty.slave, &mut buf);
+ crate::read_exact(pty.slave, &mut buf);
assert_eq!(&buf, string.as_bytes());
// Read the echo as well
let echoed_string = "foofoofoo\r\n";
let mut buf = [0u8; 11];
- ::read_exact(pty.master, &mut buf);
+ crate::read_exact(pty.master, &mut buf);
assert_eq!(&buf, echoed_string.as_bytes());
let string2 = "barbarbarbar\n";
let echoed_string2 = "barbarbarbar\r\n";
let mut buf = [0u8; 14];
write(pty.slave, string2.as_bytes()).unwrap();
- ::read_exact(pty.master, &mut buf);
+ crate::read_exact(pty.master, &mut buf);
assert_eq!(&buf, echoed_string2.as_bytes());
@@ -198,7 +198,7 @@ fn test_openpty() {
#[test]
fn test_openpty_with_termios() {
// openpty uses ptname(3) internally
- let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
// Open one pty to get attributes for the second one
let mut termios = {
@@ -222,20 +222,20 @@ fn test_openpty_with_termios() {
let string = "foofoofoo\n";
let mut buf = [0u8; 10];
write(pty.master, string.as_bytes()).unwrap();
- ::read_exact(pty.slave, &mut buf);
+ crate::read_exact(pty.slave, &mut buf);
assert_eq!(&buf, string.as_bytes());
// read the echo as well
let echoed_string = "foofoofoo\n";
- ::read_exact(pty.master, &mut buf);
+ crate::read_exact(pty.master, &mut buf);
assert_eq!(&buf, echoed_string.as_bytes());
let string2 = "barbarbarbar\n";
let echoed_string2 = "barbarbarbar\n";
let mut buf = [0u8; 13];
write(pty.slave, string2.as_bytes()).unwrap();
- ::read_exact(pty.master, &mut buf);
+ crate::read_exact(pty.master, &mut buf);
assert_eq!(&buf, echoed_string2.as_bytes());
@@ -249,9 +249,9 @@ fn test_forkpty() {
use nix::sys::signal::*;
use nix::sys::wait::wait;
// forkpty calls openpty which uses ptname(3) internally.
- let _m0 = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m0 = crate::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
// forkpty spawns a child process
- let _m1 = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m1 = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
let string = "naninani\n";
let echoed_string = "naninani\r\n";
@@ -265,7 +265,7 @@ fn test_forkpty() {
Parent { child } => {
let mut buf = [0u8; 10];
assert!(child.as_raw() > 0);
- ::read_exact(pty.master, &mut buf);
+ crate::read_exact(pty.master, &mut buf);
kill(child, SIGTERM).unwrap();
wait().unwrap(); // keep other tests using generic wait from getting our child
assert_eq!(&buf, echoed_string.as_bytes());
diff --git a/test/test_ptymaster_drop.rs b/test/test_ptymaster_drop.rs
index 9b59d664..e5da9183 100644
--- a/test/test_ptymaster_drop.rs
+++ b/test/test_ptymaster_drop.rs
@@ -1,5 +1,3 @@
-extern crate nix;
-
use nix::fcntl::OFlag;
use nix::pty::*;
use nix::unistd::close;
diff --git a/test/test_stat.rs b/test/test_stat.rs
index 14a2b06c..0b946668 100644
--- a/test/test_stat.rs
+++ b/test/test_stat.rs
@@ -172,7 +172,7 @@ fn test_fchmod() {
#[test]
#[cfg(not(target_os = "redox"))]
fn test_fchmodat() {
- let _dr = ::DirRestore::new();
+ let _dr = crate::DirRestore::new();
let tempdir = tempfile::tempdir().unwrap();
let filename = "foo.txt";
let fullpath = tempdir.path().join(filename);
@@ -264,7 +264,7 @@ fn test_futimens() {
#[test]
#[cfg(not(target_os = "redox"))]
fn test_utimensat() {
- let _dr = ::DirRestore::new();
+ let _dr = crate::DirRestore::new();
let tempdir = tempfile::tempdir().unwrap();
let filename = "foo.txt";
let fullpath = tempdir.path().join(filename);
diff --git a/test/test_unistd.rs b/test/test_unistd.rs
index 08ea2f68..0a41b65f 100644
--- a/test/test_unistd.rs
+++ b/test/test_unistd.rs
@@ -18,13 +18,13 @@ use std::fs::DirBuilder;
use std::fs::{self, File};
use std::io::Write;
use std::os::unix::prelude::*;
-use tempfile::{self, tempfile};
+use tempfile::{tempdir, tempfile};
use libc::{_exit, off_t};
#[test]
#[cfg(not(any(target_os = "netbsd")))]
fn test_fork_and_waitpid() {
- let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
// Safe: Child only calls `_exit`, which is signal-safe
match fork().expect("Error: Fork Failed") {
@@ -52,7 +52,7 @@ fn test_fork_and_waitpid() {
#[test]
fn test_wait() {
// Grab FORK_MTX so wait doesn't reap a different test's child process
- let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
// Safe: Child only calls `_exit`, which is signal-safe
match fork().expect("Error: Fork Failed") {
@@ -90,7 +90,7 @@ fn test_mkstemp_directory() {
#[test]
#[cfg(not(target_os = "redox"))]
fn test_mkfifo() {
- let tempdir = tempfile::tempdir().unwrap();
+ let tempdir = tempdir().unwrap();
let mkfifo_fifo = tempdir.path().join("mkfifo_fifo");
mkfifo(&mkfifo_fifo, Mode::S_IRUSR).unwrap();
@@ -112,9 +112,9 @@ fn test_mkfifo_directory() {
target_os = "macos", target_os = "ios",
target_os = "android", target_os = "redox")))]
fn test_mkfifoat_none() {
- let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
+ let _m = crate::CWD_LOCK.read().expect("Mutex got poisoned by another test");
- let tempdir = tempfile::tempdir().unwrap();
+ let tempdir = tempdir().unwrap();
let mkfifoat_fifo = tempdir.path().join("mkfifoat_fifo");
mkfifoat(None, &mkfifoat_fifo, Mode::S_IRUSR).unwrap();
@@ -129,7 +129,7 @@ fn test_mkfifoat_none() {
target_os = "macos", target_os = "ios",
target_os = "android", target_os = "redox")))]
fn test_mkfifoat() {
- let tempdir = tempfile::tempdir().unwrap();
+ let tempdir = tempdir().unwrap();
let dirfd = open(tempdir.path(), OFlag::empty(), Mode::empty()).unwrap();
let mkfifoat_name = "mkfifoat_name";
@@ -145,7 +145,7 @@ fn test_mkfifoat() {
target_os = "macos", target_os = "ios",
target_os = "android", target_os = "redox")))]
fn test_mkfifoat_directory_none() {
- let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
+ let _m = crate::CWD_LOCK.read().expect("Mutex got poisoned by another test");
// mkfifoat should fail if a directory is given
assert!(!mkfifoat(None, &env::temp_dir(), Mode::S_IRUSR).is_ok());
@@ -157,7 +157,7 @@ fn test_mkfifoat_directory_none() {
target_os = "android", target_os = "redox")))]
fn test_mkfifoat_directory() {
// mkfifoat should fail if a directory is given
- let tempdir = tempfile::tempdir().unwrap();
+ let tempdir = tempdir().unwrap();
let dirfd = open(tempdir.path(), OFlag::empty(), Mode::empty()).unwrap();
let mkfifoat_dir = "mkfifoat_dir";
stat::mkdirat(dirfd, mkfifoat_dir, Mode::S_IRUSR).unwrap();
@@ -200,7 +200,7 @@ fn test_setgroups() {
// Skip this test when not run as root as `setgroups()` requires root.
skip_if_not_root!("test_setgroups");
- let _m = ::GROUPS_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::GROUPS_MTX.lock().expect("Mutex got poisoned by another test");
// Save the existing groups
let old_groups = getgroups().unwrap();
@@ -224,7 +224,7 @@ fn test_initgroups() {
// require root.
skip_if_not_root!("test_initgroups");
- let _m = ::GROUPS_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::GROUPS_MTX.lock().expect("Mutex got poisoned by another test");
// Save the existing groups
let old_groups = getgroups().unwrap();
@@ -259,7 +259,7 @@ macro_rules! execve_test_factory(
skip_if_seccomp!($test_name);
}
- let m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
+ let m = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
// The `exec`d process will write to `writer`, and we'll read that
// data from `reader`.
let (reader, writer) = pipe().unwrap();
@@ -353,9 +353,9 @@ cfg_if!{
#[test]
fn test_fchdir() {
// fchdir changes the process's cwd
- let _dr = ::DirRestore::new();
+ let _dr = crate::DirRestore::new();
- let tmpdir = tempfile::tempdir().unwrap();
+ let tmpdir = tempdir().unwrap();
let tmpdir_path = tmpdir.path().canonicalize().unwrap();
let tmpdir_fd = File::open(&tmpdir_path).unwrap().into_raw_fd();
@@ -368,9 +368,9 @@ fn test_fchdir() {
#[test]
fn test_getcwd() {
// chdir changes the process's cwd
- let _dr = ::DirRestore::new();
+ let _dr = crate::DirRestore::new();
- let tmpdir = tempfile::tempdir().unwrap();
+ let tmpdir = tempdir().unwrap();
let tmpdir_path = tmpdir.path().canonicalize().unwrap();
assert!(chdir(&tmpdir_path).is_ok());
assert_eq!(getcwd().unwrap(), tmpdir_path);
@@ -395,7 +395,7 @@ fn test_chown() {
let uid = Some(getuid());
let gid = Some(getgid());
- let tempdir = tempfile::tempdir().unwrap();
+ let tempdir = tempdir().unwrap();
let path = tempdir.path().join("file");
{
File::create(&path).unwrap();
@@ -412,12 +412,12 @@ fn test_chown() {
#[test]
#[cfg(not(target_os = "redox"))]
fn test_fchownat() {
- let _dr = ::DirRestore::new();
+ let _dr = crate::DirRestore::new();
// Testing for anything other than our own UID/GID is hard.
let uid = Some(getuid());
let gid = Some(getgid());
- let tempdir = tempfile::tempdir().unwrap();
+ let tempdir = tempdir().unwrap();
let path = tempdir.path().join("file");
{
File::create(&path).unwrap();
@@ -445,7 +445,7 @@ fn test_lseek() {
lseek(tmpfd, offset, Whence::SeekSet).unwrap();
let mut buf = [0u8; 7];
- ::read_exact(tmpfd, &mut buf);
+ crate::read_exact(tmpfd, &mut buf);
assert_eq!(b"f123456", &buf);
close(tmpfd).unwrap();
@@ -462,7 +462,7 @@ fn test_lseek64() {
lseek64(tmpfd, 5, Whence::SeekSet).unwrap();
let mut buf = [0u8; 7];
- ::read_exact(tmpfd, &mut buf);
+ crate::read_exact(tmpfd, &mut buf);
assert_eq!(b"f123456", &buf);
close(tmpfd).unwrap();
@@ -498,7 +498,7 @@ fn test_acct() {
use std::process::Command;
use std::{thread, time};
- let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
require_acct!();
let file = NamedTempFile::new().unwrap();
@@ -573,7 +573,7 @@ fn test_pipe2() {
#[test]
#[cfg(not(target_os = "redox"))]
fn test_truncate() {
- let tempdir = tempfile::tempdir().unwrap();
+ let tempdir = tempdir().unwrap();
let path = tempdir.path().join("file");
{
@@ -590,7 +590,7 @@ fn test_truncate() {
#[test]
fn test_ftruncate() {
- let tempdir = tempfile::tempdir().unwrap();
+ let tempdir = tempdir().unwrap();
let path = tempdir.path().join("file");
let tmpfd = {
@@ -621,7 +621,7 @@ pub extern fn alarm_signal_handler(raw_signal: libc::c_int) {
#[test]
#[cfg(not(target_os = "redox"))]
fn test_alarm() {
- let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
let handler = SigHandler::Handler(alarm_signal_handler);
let signal_action = SigAction::new(handler, SaFlags::SA_RESTART, SigSet::empty());
@@ -651,7 +651,7 @@ fn test_alarm() {
#[test]
#[cfg(not(target_os = "redox"))]
fn test_canceling_alarm() {
- let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
+ let _m = crate::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
assert_eq!(alarm::cancel(), None);
@@ -662,9 +662,9 @@ fn test_canceling_alarm() {
#[test]
#[cfg(not(target_os = "redox"))]
fn test_symlinkat() {
- let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
+ let _m = crate::CWD_LOCK.read().expect("Mutex got poisoned by another test");
- let tempdir = tempfile::tempdir().unwrap();
+ let tempdir = tempdir().unwrap();
let target = tempdir.path().join("a");
let linkpath = tempdir.path().join("b");
@@ -690,7 +690,7 @@ fn test_symlinkat() {
#[test]
#[cfg(not(target_os = "redox"))]
fn test_linkat_file() {
- let tempdir = tempfile::tempdir().unwrap();
+ let tempdir = tempdir().unwrap();
let oldfilename = "foo.txt";
let oldfilepath = tempdir.path().join(oldfilename);
@@ -711,13 +711,13 @@ fn test_linkat_file() {
#[test]
#[cfg(not(target_os = "redox"))]
fn test_linkat_olddirfd_none() {
- let _dr = ::DirRestore::new();
+ let _dr = crate::DirRestore::new();
- let tempdir_oldfile = tempfile::tempdir().unwrap();
+ let tempdir_oldfile = tempdir().unwrap();
let oldfilename = "foo.txt";
let oldfilepath = tempdir_oldfile.path().join(oldfilename);
- let tempdir_newfile = tempfile::tempdir().unwrap();
+ let tempdir_newfile = tempdir().unwrap();
let newfilename = "bar.txt";
let newfilepath = tempdir_newfile.path().join(newfilename);
@@ -736,13 +736,13 @@ fn test_linkat_olddirfd_none() {
#[test]
#[cfg(not(target_os = "redox"))]
fn test_linkat_newdirfd_none() {
- let _dr = ::DirRestore::new();
+ let _dr = crate::DirRestore::new();
- let tempdir_oldfile = tempfile::tempdir().unwrap();
+ let tempdir_oldfile = tempdir().unwrap();
let oldfilename = "foo.txt";
let oldfilepath = tempdir_oldfile.path().join(oldfilename);
- let tempdir_newfile = tempfile::tempdir().unwrap();
+ let tempdir_newfile = tempdir().unwrap();
let newfilename = "bar.txt";
let newfilepath = tempdir_newfile.path().join(newfilename);
@@ -761,9 +761,9 @@ fn test_linkat_newdirfd_none() {
#[test]
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))]
fn test_linkat_no_follow_symlink() {
- let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
+ let _m = crate::CWD_LOCK.read().expect("Mutex got poisoned by another test");
- let tempdir = tempfile::tempdir().unwrap();
+ let tempdir = tempdir().unwrap();
let oldfilename = "foo.txt";
let oldfilepath = tempdir.path().join(oldfilename);
@@ -798,9 +798,9 @@ fn test_linkat_no_follow_symlink() {
#[test]
#[cfg(not(target_os = "redox"))]
fn test_linkat_follow_symlink() {
- let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
+ let _m = crate::CWD_LOCK.read().expect("Mutex got poisoned by another test");
- let tempdir = tempfile::tempdir().unwrap();
+ let tempdir = tempdir().unwrap();
let oldfilename = "foo.txt";
let oldfilepath = tempdir.path().join(oldfilename);
@@ -834,7 +834,7 @@ fn test_linkat_follow_symlink() {
#[test]
#[cfg(not(target_os = "redox"))]
fn test_unlinkat_dir_noremovedir() {
- let tempdir = tempfile::tempdir().unwrap();
+ let tempdir = tempdir().unwrap();
let dirname = "foo_dir";
let dirpath = tempdir.path().join(dirname);
@@ -852,7 +852,7 @@ fn test_unlinkat_dir_noremovedir() {
#[test]
#[cfg(not(target_os = "redox"))]
fn test_unlinkat_dir_removedir() {
- let tempdir = tempfile::tempdir().unwrap();
+ let tempdir = tempdir().unwrap();
let dirname = "foo_dir";
let dirpath = tempdir.path().join(dirname);
@@ -870,7 +870,7 @@ fn test_unlinkat_dir_removedir() {
#[test]
#[cfg(not(target_os = "redox"))]
fn test_unlinkat_file() {
- let tempdir = tempfile::tempdir().unwrap();
+ let tempdir = tempdir().unwrap();
let filename = "foo.txt";
let filepath = tempdir.path().join(filename);
@@ -887,7 +887,7 @@ fn test_unlinkat_file() {
#[test]
fn test_access_not_existing() {
- let tempdir = tempfile::tempdir().unwrap();
+ let tempdir = tempdir().unwrap();
let dir = tempdir.path().join("does_not_exist.txt");
assert_eq!(access(&dir, AccessFlags::F_OK).err().unwrap().as_errno().unwrap(),
Errno::ENOENT);
@@ -895,7 +895,7 @@ fn test_access_not_existing() {
#[test]
fn test_access_file_exists() {
- let tempdir = tempfile::tempdir().unwrap();
+ let tempdir = tempdir().unwrap();
let path = tempdir.path().join("does_exist.txt");
let _file = File::create(path.clone()).unwrap();
assert!(access(&path, AccessFlags::R_OK | AccessFlags::W_OK).is_ok());