Remove more unsupported functions and make it possible to run tests

This commit is contained in:
Xavier L'Heureux 2019-07-16 15:02:54 -04:00 committed by Xavier L'Heureux
parent 0259f9d517
commit e94c139a47
No known key found for this signature in database
GPG Key ID: A06A06A3924D1F17
14 changed files with 178 additions and 93 deletions

View File

@ -57,6 +57,6 @@ name = "test-mount"
path = "test/test_mount.rs"
harness = false
[[test]]
[[target.'cfg(not(target_os = "redox"))'.test]]
name = "test-ptymaster-drop"
path = "test/test_ptymaster_drop.rs"

View File

@ -1,17 +1,25 @@
#[cfg(not(target_os = "redox"))]
use {Error, NixPath, Result};
#[cfg(not(target_os = "redox"))]
use errno::Errno;
#[cfg(not(target_os = "redox"))]
use fcntl::{self, OFlag};
use libc;
use std::os::unix::io::{IntoRawFd, RawFd};
#[cfg(not(target_os = "redox"))]
use std::os::unix::io::AsRawFd;
use std::{ffi, ptr};
use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd};
#[cfg(not(target_os = "redox"))]
use std::ptr;
use std::ffi;
#[cfg(not(target_os = "redox"))]
use sys;
#[cfg(target_os = "linux")]
use libc::{dirent64 as dirent, readdir64_r as readdir_r};
#[cfg(not(target_os = "linux"))]
#[cfg(target_os = "redox")]
use libc::dirent;
#[cfg(not(any(target_os = "linux", target_os = "redox")))]
use libc::{dirent, readdir_r};
/// An open directory.
@ -28,10 +36,12 @@ use libc::{dirent, readdir_r};
/// * returns entries' names as a `CStr` (no allocation or conversion beyond whatever libc
/// does).
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
#[cfg(not(target_os = "redox"))]
pub struct Dir(
ptr::NonNull<libc::DIR>
);
#[cfg(not(target_os = "redox"))]
impl Dir {
/// Opens the given path as with `fcntl::open`.
pub fn open<P: ?Sized + NixPath>(path: &P, oflag: OFlag,
@ -77,6 +87,7 @@ impl Dir {
// call `readdir` simultaneously from multiple threads.
//
// `Dir` is safe to pass from one thread to another, as it's not reference-counted.
#[cfg(not(target_os = "redox"))]
unsafe impl Send for Dir {}
#[cfg(not(target_os = "redox"))]
@ -86,6 +97,7 @@ impl AsRawFd for Dir {
}
}
#[cfg(not(target_os = "redox"))]
impl Drop for Dir {
fn drop(&mut self) {
unsafe { libc::closedir(self.0.as_ptr()) };
@ -93,8 +105,10 @@ impl Drop for Dir {
}
#[derive(Debug, Eq, Hash, PartialEq)]
#[cfg(not(target_os = "redox"))]
pub struct Iter<'d>(&'d mut Dir);
#[cfg(not(target_os = "redox"))]
impl<'d> Iterator for Iter<'d> {
type Item = Result<Entry>;
@ -121,6 +135,7 @@ impl<'d> Iterator for Iter<'d> {
}
}
#[cfg(not(target_os = "redox"))]
impl<'d> Drop for Iter<'d> {
fn drop(&mut self) {
unsafe { libc::rewinddir((self.0).0.as_ptr()) }

View File

@ -1,29 +1,31 @@
use {Result, NixPath};
use errno::Errno;
use libc::{self, c_int, c_uint, c_char, size_t, ssize_t};
use sys::stat::Mode;
use libc::{self, c_char, c_int, c_uint, size_t, ssize_t};
use std::ffi::OsString;
#[cfg(not(target_os = "redox"))]
use std::os::raw;
use std::os::unix::io::RawFd;
use std::ffi::OsString;
use std::os::unix::ffi::OsStringExt;
use std::os::unix::io::RawFd;
use sys::stat::Mode;
use {NixPath, Result};
#[cfg(any(target_os = "android", target_os = "linux"))]
use std::ptr; // For splice and copy_file_range
#[cfg(any(target_os = "android", target_os = "linux"))]
use sys::uio::IoVec; // For vmsplice
use sys::uio::IoVec; // For vmsplice
#[cfg(any(target_os = "linux",
target_os = "android",
target_os = "emscripten",
target_os = "fuchsia",
any(target_os = "wasi", target_env = "wasi"),
target_env = "uclibc",
target_env = "freebsd"))]
#[cfg(any(
target_os = "linux",
target_os = "android",
target_os = "emscripten",
target_os = "fuchsia",
any(target_os = "wasi", target_env = "wasi"),
target_env = "uclibc",
target_env = "freebsd"
))]
pub use self::posix_fadvise::*;
#[cfg(not(target_os = "redox"))]
libc_bitflags!{
libc_bitflags! {
pub struct AtFlags: c_int {
AT_REMOVEDIR;
AT_SYMLINK_FOLLOW;
@ -168,7 +170,13 @@ pub fn open<P: ?Sized + NixPath>(path: &P, oflag: OFlag, mode: Mode) -> Result<R
Errno::result(fd)
}
pub fn openat<P: ?Sized + NixPath>(dirfd: RawFd, path: &P, oflag: OFlag, mode: Mode) -> Result<RawFd> {
#[cfg(not(target_os = "redox"))]
pub fn openat<P: ?Sized + NixPath>(
dirfd: RawFd,
path: &P,
oflag: OFlag,
mode: Mode,
) -> Result<RawFd> {
let fd = path.with_nix_path(|cstr| {
let modebits = c_uint::from(mode.bits());
unsafe { libc::openat(dirfd, cstr.as_ptr(), oflag.bits(), modebits) }
@ -176,13 +184,21 @@ pub fn openat<P: ?Sized + NixPath>(dirfd: RawFd, path: &P, oflag: OFlag, mode: M
Errno::result(fd)
}
pub fn renameat<P1: ?Sized + NixPath, P2: ?Sized + NixPath>(old_dirfd: Option<RawFd>, old_path: &P1,
new_dirfd: Option<RawFd>, new_path: &P2)
-> Result<()> {
#[cfg(not(target_os = "redox"))]
pub fn renameat<P1: ?Sized + NixPath, P2: ?Sized + NixPath>(
old_dirfd: Option<RawFd>,
old_path: &P1,
new_dirfd: Option<RawFd>,
new_path: &P2,
) -> Result<()> {
let res = old_path.with_nix_path(|old_cstr| {
new_path.with_nix_path(|new_cstr| unsafe {
libc::renameat(at_rawfd(old_dirfd), old_cstr.as_ptr(),
at_rawfd(new_dirfd), new_cstr.as_ptr())
libc::renameat(
at_rawfd(old_dirfd),
old_cstr.as_ptr(),
at_rawfd(new_dirfd),
new_cstr.as_ptr(),
)
})
})??;
Errno::result(res).map(drop)
@ -194,25 +210,32 @@ fn wrap_readlink_result(mut v: Vec<u8>, len: ssize_t) -> Result<OsString> {
Ok(OsString::from_vec(v.to_vec()))
}
fn readlink_maybe_at<P: ?Sized + NixPath>(dirfd: Option<RawFd>, path: &P,
v: &mut Vec<u8>)
-> Result<libc::ssize_t> {
path.with_nix_path(|cstr| {
unsafe {
match dirfd {
Some(dirfd) => libc::readlinkat(dirfd, cstr.as_ptr(),
v.as_mut_ptr() as *mut c_char,
v.capacity() as size_t),
None => libc::readlink(cstr.as_ptr(),
v.as_mut_ptr() as *mut c_char,
v.capacity() as size_t),
}
fn readlink_maybe_at<P: ?Sized + NixPath>(
dirfd: Option<RawFd>,
path: &P,
v: &mut Vec<u8>,
) -> Result<libc::ssize_t> {
path.with_nix_path(|cstr| unsafe {
match dirfd {
#[cfg(target_os = "redox")]
Some(_) => unreachable!(),
#[cfg(not(target_os = "redox"))]
Some(dirfd) => libc::readlinkat(
dirfd,
cstr.as_ptr(),
v.as_mut_ptr() as *mut c_char,
v.capacity() as size_t,
),
None => libc::readlink(
cstr.as_ptr(),
v.as_mut_ptr() as *mut c_char,
v.capacity() as size_t,
),
}
})
}
fn inner_readlink<P: ?Sized + NixPath>(dirfd: Option<RawFd>, path: &P)
-> Result<OsString> {
fn inner_readlink<P: ?Sized + NixPath>(dirfd: Option<RawFd>, path: &P) -> Result<OsString> {
let mut v = Vec::with_capacity(libc::PATH_MAX as usize);
// simple case: result is strictly less than `PATH_MAX`
let res = readlink_maybe_at(dirfd, path, &mut v)?;
@ -224,7 +247,8 @@ fn inner_readlink<P: ?Sized + NixPath>(dirfd: Option<RawFd>, path: &P)
// Uh oh, the result is too long...
// Let's try to ask lstat how many bytes to allocate.
let reported_size = super::sys::stat::lstat(path)
.and_then(|x| Ok(x.st_size)).unwrap_or(0);
.and_then(|x| Ok(x.st_size))
.unwrap_or(0);
let mut try_size = if reported_size > 0 {
// Note: even if `lstat`'s apparently valid answer turns out to be
// wrong, we will still read the full symlink no matter what.
@ -241,14 +265,13 @@ fn inner_readlink<P: ?Sized + NixPath>(dirfd: Option<RawFd>, path: &P)
debug_assert!(len >= 0);
if (len as usize) < v.capacity() {
break wrap_readlink_result(v, res);
}
else {
} else {
// Ugh! Still not big enough!
match try_size.checked_shl(1) {
Some(next_size) => try_size = next_size,
// It's absurd that this would happen, but handle it sanely
// anyway.
None => break Err(super::Error::Sys(Errno::ENAMETOOLONG))
None => break Err(super::Error::Sys(Errno::ENAMETOOLONG)),
}
}
}
@ -258,9 +281,8 @@ pub fn readlink<P: ?Sized + NixPath>(path: &P) -> Result<OsString> {
inner_readlink(None, path)
}
pub fn readlinkat<P: ?Sized + NixPath>(dirfd: RawFd, path: &P)
-> Result<OsString> {
#[cfg(not(target_os = "redox"))]
pub fn readlinkat<P: ?Sized + NixPath>(dirfd: RawFd, path: &P) -> Result<OsString> {
inner_readlink(Some(dirfd), path)
}
@ -324,7 +346,6 @@ pub enum FcntlArg<'a> {
F_GETPIPE_SZ,
#[cfg(any(target_os = "linux", target_os = "android"))]
F_SETPIPE_SZ(c_int),
// TODO: Rest of flags
}
@ -488,9 +509,7 @@ pub fn splice(
.map(|offset| offset as *mut libc::loff_t)
.unwrap_or(ptr::null_mut());
let ret = unsafe {
libc::splice(fd_in, off_in, fd_out, off_out, len, flags.bits())
};
let ret = unsafe { libc::splice(fd_in, off_in, fd_out, off_out, len, flags.bits()) };
Errno::result(ret).map(|r| r as usize)
}
@ -503,7 +522,12 @@ pub fn tee(fd_in: RawFd, fd_out: RawFd, len: usize, flags: SpliceFFlags) -> Resu
#[cfg(any(target_os = "linux", target_os = "android"))]
pub fn vmsplice(fd: RawFd, iov: &[IoVec<&[u8]>], flags: SpliceFFlags) -> Result<usize> {
let ret = unsafe {
libc::vmsplice(fd, iov.as_ptr() as *const libc::iovec, iov.len(), flags.bits())
libc::vmsplice(
fd,
iov.as_ptr() as *const libc::iovec,
iov.len(),
flags.bits(),
)
};
Errno::result(ret).map(|r| r as usize)
}
@ -544,23 +568,30 @@ libc_bitflags!(
/// Allows the caller to directly manipulate the allocated disk space for the
/// file referred to by fd.
#[cfg(any(target_os = "linux"))]
pub fn fallocate(fd: RawFd, mode: FallocateFlags, offset: libc::off_t, len: libc::off_t) -> Result<()> {
pub fn fallocate(
fd: RawFd,
mode: FallocateFlags,
offset: libc::off_t,
len: libc::off_t,
) -> Result<()> {
let res = unsafe { libc::fallocate(fd, mode.bits(), offset, len) };
Errno::result(res).map(drop)
}
#[cfg(any(target_os = "linux",
target_os = "android",
target_os = "emscripten",
target_os = "fuchsia",
any(target_os = "wasi", target_env = "wasi"),
target_env = "uclibc",
target_env = "freebsd"))]
#[cfg(any(
target_os = "linux",
target_os = "android",
target_os = "emscripten",
target_os = "fuchsia",
any(target_os = "wasi", target_env = "wasi"),
target_env = "uclibc",
target_env = "freebsd"
))]
mod posix_fadvise {
use Result;
use libc;
use errno::Errno;
use libc;
use std::os::unix::io::RawFd;
use Result;
libc_enum! {
#[repr(i32)]
@ -574,10 +605,12 @@ mod posix_fadvise {
}
}
pub fn posix_fadvise(fd: RawFd,
offset: libc::off_t,
len: libc::off_t,
advice: PosixFadviseAdvice) -> Result<libc::c_int> {
pub fn posix_fadvise(
fd: RawFd,
offset: libc::off_t,
len: libc::off_t,
advice: PosixFadviseAdvice,
) -> Result<libc::c_int> {
let res = unsafe { libc::posix_fadvise(fd, offset, len, advice as libc::c_int) };
Errno::result(res)
}
@ -591,11 +624,7 @@ mod posix_fadvise {
any(target_os = "wasi", target_env = "wasi"),
target_os = "freebsd"
))]
pub fn posix_fallocate(
fd: RawFd,
offset: libc::off_t,
len: libc::off_t
) -> Result<()> {
pub fn posix_fallocate(fd: RawFd, offset: libc::off_t, len: libc::off_t) -> Result<()> {
let res = unsafe { libc::posix_fallocate(fd, offset, len) };
match Errno::result(res) {
Err(err) => Err(err),

View File

@ -464,6 +464,7 @@ impl SigSet {
/// Suspends execution of the calling thread until one of the signals in the
/// signal mask becomes pending, and returns the accepted signal.
#[cfg(not(target_os = "redox"))]
pub fn wait(&self) -> Result<Signal> {
let mut signum = mem::MaybeUninit::uninit();
let res = unsafe { libc::sigwait(&self.sigset as *const libc::sigset_t, signum.as_mut_ptr()) };
@ -890,6 +891,7 @@ mod sigevent {
#[cfg(test)]
mod tests {
#[cfg(not(target_os = "redox"))]
use std::thread;
use super::*;
@ -945,6 +947,7 @@ mod tests {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_thread_signal_set_mask() {
thread::spawn(|| {
let prev_mask = SigSet::thread_get_mask()
@ -965,6 +968,7 @@ mod tests {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_thread_signal_block() {
thread::spawn(|| {
let mut mask = SigSet::empty();
@ -977,6 +981,7 @@ mod tests {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_thread_signal_unblock() {
thread::spawn(|| {
let mut mask = SigSet::empty();
@ -989,6 +994,7 @@ mod tests {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_thread_signal_swap() {
thread::spawn(|| {
let mut mask = SigSet::empty();
@ -1011,23 +1017,14 @@ mod tests {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_sigaction() {
use libc;
thread::spawn(|| {
extern fn test_sigaction_handler(_: libc::c_int) {}
#[cfg(not(target_os = "redox"))]
extern fn test_sigaction_action(_: libc::c_int,
_: *mut libc::siginfo_t, _: *mut libc::c_void) {}
#[cfg(not(target_os = "redox"))]
fn test_sigaction_sigaction(flags: SaFlags, mask: SigSet) {
let handler_act = SigHandler::SigAction(test_sigaction_action);
let action_act = SigAction::new(handler_act, flags, mask);
assert_eq!(action_act.handler(), handler_act);
}
#[cfg(target_os = "redox")]
fn test_sigaction_sigaction() {}
let handler_sig = SigHandler::Handler(test_sigaction_handler);
let flags = SaFlags::SA_ONSTACK | SaFlags::SA_RESTART |
@ -1046,7 +1043,9 @@ mod tests {
assert!(mask.contains(SIGUSR1));
assert!(!mask.contains(SIGUSR2));
test_sigaction_sigaction(flags, mask);
let handler_act = SigHandler::SigAction(test_sigaction_action);
let action_act = SigAction::new(handler_act, flags, mask);
assert_eq!(action_act.handler(), handler_act);
let action_dfl = SigAction::new(SigHandler::SigDfl, flags, mask);
assert_eq!(action_dfl.handler(), SigHandler::SigDfl);
@ -1057,6 +1056,7 @@ mod tests {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_sigwait() {
thread::spawn(|| {
let mut mask = SigSet::empty();

View File

@ -289,6 +289,7 @@ pub fn utimensat<P: ?Sized + NixPath>(
Errno::result(res).map(drop)
}
#[cfg(not(target_os = "redox"))]
pub fn mkdirat<P: ?Sized + NixPath>(fd: RawFd, path: &P, mode: Mode) -> Result<()> {
let res = path.with_nix_path(|cstr| {
unsafe { libc::mkdirat(fd, cstr.as_ptr(), mode.bits() as mode_t) }

View File

@ -291,6 +291,7 @@ pub fn setsid() -> Result<Pid> {
/// Obtain the process group ID of the process that is the session leader of the process specified
/// by pid. If pid is zero, it specifies the calling process.
#[inline]
#[cfg(not(target_os = "redox"))]
pub fn getsid(pid: Option<Pid>) -> Result<Pid> {
let res = unsafe { libc::getsid(pid.unwrap_or(Pid(0)).into()) };
Errno::result(res).map(Pid)
@ -1149,6 +1150,7 @@ fn pipe2_setflags(fd1: RawFd, fd2: RawFd, flags: OFlag) -> Result<()> {
///
/// See also
/// [truncate(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html)
#[cfg(not(target_os = "redox"))]
pub fn truncate<P: ?Sized + NixPath>(path: &P, len: off_t) -> Result<()> {
let res = path.with_nix_path(|cstr| {
unsafe {
@ -1263,6 +1265,7 @@ pub enum UnlinkatFlags {
///
/// # References
/// See also [unlinkat(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/unlinkat.html)
#[cfg(not(target_os = "redox"))]
pub fn unlinkat<P: ?Sized + NixPath>(
dirfd: Option<RawFd>,
path: &P,
@ -1657,6 +1660,7 @@ pub fn initgroups(user: &CStr, group: Gid) -> Result<()> {
///
/// See also [pause(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/pause.html).
#[inline]
#[cfg(not(target_os = "redox"))]
pub fn pause() {
unsafe { libc::pause() };
}

View File

@ -13,12 +13,17 @@ mod test_signal;
mod test_aio;
#[cfg(target_os = "linux")]
mod test_signalfd;
#[cfg(not(target_os = "redox"))]
mod test_socket;
#[cfg(not(target_os = "redox"))]
mod test_sockopt;
#[cfg(not(target_os = "redox"))]
mod test_select;
#[cfg(any(target_os = "android", target_os = "linux"))]
mod test_sysinfo;
#[cfg(not(target_os = "redox"))]
mod test_termios;
#[cfg(not(target_os = "redox"))]
mod test_ioctl;
mod test_wait;
mod test_uio;

View File

@ -1,13 +1,13 @@
use nix::sys::pthread::*;
#[cfg(target_env = "musl")]
#[cfg(any(target_env = "musl", target_os = "redox"))]
#[test]
fn test_pthread_self() {
let tid = pthread_self();
assert!(tid != ::std::ptr::null_mut());
}
#[cfg(not(target_env = "musl"))]
#[cfg(not(any(target_env = "musl", target_os = "redox")))]
#[test]
fn test_pthread_self() {
let tid = pthread_self();

View File

@ -82,7 +82,16 @@ extern fn test_sigaction_handler(signal: libc::c_int) {
SIGNALED.store(signal == Signal::SIGINT, Ordering::Relaxed);
}
extern fn test_sigaction_action(_: libc::c_int, _: *mut libc::siginfo_t, _: *mut libc::c_void) {
#[cfg(not(target_os = "redox"))]
extern fn test_sigaction_action(_: libc::c_int, _: *mut libc::siginfo_t, _: *mut libc::c_void) {}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_signal_sigaction() {
let _m = ::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);
}
#[test]
@ -99,9 +108,6 @@ fn test_signal() {
assert!(SIGNALED.load(Ordering::Relaxed));
assert_eq!(unsafe { signal(Signal::SIGINT, SigHandler::SigDfl) }.unwrap(), handler);
let action_handler = SigHandler::SigAction(test_sigaction_action);
assert_eq!(unsafe { signal(Signal::SIGINT, action_handler) }.unwrap_err(), Error::UnsupportedOperation);
// Restore default signal handler
unsafe { signal(Signal::SIGINT, SigHandler::SigDfl) }.unwrap();
}

View File

@ -6,6 +6,7 @@ use nix::sys::wait::*;
use libc::_exit;
#[test]
#[cfg(not(target_os = "redox"))]
fn test_wait_signal() {
let _ = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");

View File

@ -134,6 +134,7 @@ cfg_if! {
}
mod sys;
#[cfg(not(target_os = "redox"))]
mod test_dir;
mod test_fcntl;
#[cfg(any(target_os = "android",
@ -145,9 +146,12 @@ mod test_kmod;
target_os = "linux",
target_os = "netbsd"))]
mod test_mq;
#[cfg(not(target_os = "redox"))]
mod test_net;
mod test_nix_path;
#[cfg(not(target_os = "redox"))]
mod test_poll;
#[cfg(not(target_os = "redox"))]
mod test_pty;
#[cfg(any(target_os = "android",
target_os = "linux"))]

View File

@ -1,6 +1,8 @@
use nix::Error;
use nix::errno::*;
use nix::fcntl::{openat, open, OFlag, readlink, readlinkat, renameat};
use nix::fcntl::{open, OFlag, readlink};
#[cfg(not(target_os = "redox"))]
use nix::fcntl::{openat, readlinkat, renameat};
use nix::sys::stat::Mode;
use nix::unistd::{close, read};
use tempfile::{self, NamedTempFile};
@ -9,6 +11,7 @@ use std::io::prelude::*;
use std::os::unix::fs;
#[test]
#[cfg(not(target_os = "redox"))]
fn test_openat() {
const CONTENTS: &[u8] = b"abcd";
let mut tmp = NamedTempFile::new().unwrap();
@ -31,6 +34,7 @@ fn test_openat() {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_renameat() {
let old_dir = tempfile::tempdir().unwrap();
let old_dirfd = open(old_dir.path(), OFlag::empty(), Mode::empty()).unwrap();
@ -47,6 +51,7 @@ fn test_renameat() {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_readlink() {
let tempdir = tempfile::tempdir().unwrap();
let src = tempdir.path().join("a");

View File

@ -9,7 +9,9 @@ use libc::{S_IFMT, S_IFLNK, mode_t};
use nix::{fcntl, Error};
use nix::errno::{Errno};
use nix::sys::stat::{self, fchmod, fchmodat, futimens, stat, utimes, utimensat, mkdirat};
use nix::sys::stat::{self, fchmod, futimens, stat, utimes};
#[cfg(not(target_os = "redox"))]
use nix::sys::stat::{fchmodat, utimensat, mkdirat};
#[cfg(any(target_os = "linux",
target_os = "haiku",
target_os = "ios",
@ -92,7 +94,7 @@ fn test_stat_and_fstat() {
}
#[test]
#[cfg(not(any(target_os = "netbsd")))]
#[cfg(not(any(target_os = "netbsd", target_os = "redox")))]
fn test_fstatat() {
let tempdir = tempfile::tempdir().unwrap();
let filename = tempdir.path().join("foo.txt");
@ -155,6 +157,7 @@ fn test_fchmod() {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_fchmodat() {
let _dr = ::DirRestore::new();
let tempdir = tempfile::tempdir().unwrap();
@ -243,6 +246,7 @@ fn test_futimens() {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_utimensat() {
let _dr = ::DirRestore::new();
let tempdir = tempfile::tempdir().unwrap();
@ -264,6 +268,7 @@ fn test_utimensat() {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_mkdirat_success_path() {
let tempdir = tempfile::tempdir().unwrap();
let filename = "example_subdir";
@ -273,6 +278,7 @@ fn test_mkdirat_success_path() {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_mkdirat_success_mode() {
let expected_bits = stat::SFlag::S_IFDIR.bits() | stat::Mode::S_IRWXU.bits();
let tempdir = tempfile::tempdir().unwrap();
@ -285,6 +291,7 @@ fn test_mkdirat_success_mode() {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_mkdirat_fail() {
let tempdir = tempfile::tempdir().unwrap();
let not_dir_filename= "example_not_dir";

View File

@ -157,6 +157,7 @@ fn test_getpid() {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_getsid() {
let none_sid: ::libc::pid_t = getsid(None).unwrap().into();
let pid_sid: ::libc::pid_t = getsid(Some(getpid())).unwrap().into();
@ -177,7 +178,7 @@ mod linux_android {
#[test]
// `getgroups()` and `setgroups()` do not behave as expected on Apple platforms
#[cfg(not(any(target_os = "ios", target_os = "macos")))]
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))]
fn test_setgroups() {
// Skip this test when not run as root as `setgroups()` requires root.
skip_if_not_root!("test_setgroups");
@ -200,7 +201,7 @@ fn test_setgroups() {
#[test]
// `getgroups()` and `setgroups()` do not behave as expected on Apple platforms
#[cfg(not(any(target_os = "ios", target_os = "macos")))]
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))]
fn test_initgroups() {
// Skip this test when not run as root as `initgroups()` and `setgroups()`
// require root.
@ -391,6 +392,7 @@ fn test_chown() {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_fchownat() {
let _dr = ::DirRestore::new();
// Testing for anything other than our own UID/GID is hard.
@ -472,6 +474,7 @@ cfg_if!{
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_acct() {
use tempfile::NamedTempFile;
use std::process::Command;
@ -550,6 +553,7 @@ fn test_pipe2() {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_truncate() {
let tempdir = tempfile::tempdir().unwrap();
let path = tempdir.path().join("file");
@ -634,6 +638,7 @@ 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");
@ -801,6 +806,7 @@ fn test_linkat_follow_symlink() {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_unlinkat_dir_noremovedir() {
let tempdir = tempfile::tempdir().unwrap();
let dirname = "foo_dir";
@ -818,6 +824,7 @@ fn test_unlinkat_dir_noremovedir() {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_unlinkat_dir_removedir() {
let tempdir = tempfile::tempdir().unwrap();
let dirname = "foo_dir";
@ -835,6 +842,7 @@ fn test_unlinkat_dir_removedir() {
}
#[test]
#[cfg(not(target_os = "redox"))]
fn test_unlinkat_file() {
let tempdir = tempfile::tempdir().unwrap();
let filename = "foo.txt";