diff options
author | Xavier L'Heureux <xavier.lheureux@icloud.com> | 2019-09-17 13:39:34 -0400 |
---|---|---|
committer | Xavier L'Heureux <dev.xlheureux@gmail.com> | 2020-05-17 21:05:46 -0400 |
commit | 92e63f61cd5046547c30a812cda98d8a2c3b3361 (patch) | |
tree | 8274596822cad094600cdaddaa50a0a93a822956 | |
parent | f0912911a9843dea2f3f0755451346c9cea16f9b (diff) | |
download | nix-92e63f61cd5046547c30a812cda98d8a2c3b3361.zip |
Remove warnings when compiling for Redox
-rw-r--r-- | test/sys/test_signal.rs | 1 | ||||
-rw-r--r-- | test/sys/test_uio.rs | 4 | ||||
-rw-r--r-- | test/test.rs | 3 | ||||
-rw-r--r-- | test/test_fcntl.rs | 9 | ||||
-rw-r--r-- | test/test_stat.rs | 34 | ||||
-rw-r--r-- | test/test_unistd.rs | 18 |
6 files changed, 53 insertions, 16 deletions
diff --git a/test/sys/test_signal.rs b/test/sys/test_signal.rs index 8c1ced3c..1c3a25f8 100644 --- a/test/sys/test_signal.rs +++ b/test/sys/test_signal.rs @@ -1,4 +1,5 @@ use libc; +#[cfg(not(target_os = "redox"))] use nix::Error; use nix::sys::signal::*; use nix::unistd::*; diff --git a/test/sys/test_uio.rs b/test/sys/test_uio.rs index 7601e02f..d0025b87 100644 --- a/test/sys/test_uio.rs +++ b/test/sys/test_uio.rs @@ -6,7 +6,9 @@ use std::{cmp, iter}; use std::fs::{OpenOptions}; use std::os::unix::io::AsRawFd; -use tempfile::{tempfile, tempdir}; +#[cfg(not(target_os = "redox"))] +use tempfile::tempfile; +use tempfile::tempdir; #[test] fn test_writev() { diff --git a/test/test.rs b/test/test.rs index d48874fc..0bc8341d 100644 --- a/test/test.rs +++ b/test/test.rs @@ -3,7 +3,7 @@ extern crate bytes; extern crate caps; #[macro_use] extern crate cfg_if; -#[macro_use] +#[cfg_attr(not(target_os = "redox"), macro_use)] extern crate nix; #[macro_use] extern crate lazy_static; @@ -58,6 +58,7 @@ macro_rules! skip_if_jailed { } } +#[cfg(not(target_os = "redox"))] macro_rules! skip_if_not_root { ($name:expr) => { use nix::unistd::Uid; diff --git a/test/test_fcntl.rs b/test/test_fcntl.rs index 2848cfac..c9f382bc 100644 --- a/test/test_fcntl.rs +++ b/test/test_fcntl.rs @@ -1,13 +1,22 @@ +#[cfg(not(target_os = "redox"))] use nix::Error; +#[cfg(not(target_os = "redox"))] use nix::errno::*; +#[cfg(not(target_os = "redox"))] use nix::fcntl::{open, OFlag, readlink}; #[cfg(not(target_os = "redox"))] use nix::fcntl::{openat, readlinkat, renameat}; +#[cfg(not(target_os = "redox"))] use nix::sys::stat::Mode; +#[cfg(not(target_os = "redox"))] use nix::unistd::{close, read}; +#[cfg(not(target_os = "redox"))] use tempfile::{self, NamedTempFile}; +#[cfg(not(target_os = "redox"))] use std::fs::File; +#[cfg(not(target_os = "redox"))] use std::io::prelude::*; +#[cfg(not(target_os = "redox"))] use std::os::unix::fs; #[test] diff --git a/test/test_stat.rs b/test/test_stat.rs index b003ed09..14a2b06c 100644 --- a/test/test_stat.rs +++ b/test/test_stat.rs @@ -1,15 +1,24 @@ -use std::fs::{self, File}; +#[cfg(not(target_os = "redox"))] +use std::fs; +use std::fs::File; +#[cfg(not(target_os = "redox"))] use std::os::unix::fs::{symlink, PermissionsExt}; use std::os::unix::prelude::AsRawFd; +#[cfg(not(target_os = "redox"))] use std::time::{Duration, UNIX_EPOCH}; +#[cfg(not(target_os = "redox"))] use std::path::Path; -#[cfg(not(any(target_os = "netbsd")))] +#[cfg(not(any(target_os = "netbsd", target_os = "redox")))] use libc::{S_IFMT, S_IFLNK, mode_t}; +#[cfg(not(target_os = "redox"))] use nix::{fcntl, Error}; -use nix::errno::{Errno}; -use nix::sys::stat::{self, fchmod, futimens, stat, utimes}; +#[cfg(not(target_os = "redox"))] +use nix::errno::Errno; +#[cfg(not(target_os = "redox"))] +use nix::sys::stat::{self, futimens, utimes}; +use nix::sys::stat::{fchmod, stat}; #[cfg(not(target_os = "redox"))] use nix::sys::stat::{fchmodat, utimensat, mkdirat}; #[cfg(any(target_os = "linux", @@ -19,15 +28,19 @@ use nix::sys::stat::{fchmodat, utimensat, mkdirat}; target_os = "freebsd", target_os = "netbsd"))] use nix::sys::stat::lutimes; -use nix::sys::stat::{Mode, FchmodatFlags, UtimensatFlags}; +#[cfg(not(target_os = "redox"))] +use nix::sys::stat::{FchmodatFlags, UtimensatFlags}; +use nix::sys::stat::Mode; -#[cfg(not(any(target_os = "netbsd")))] +#[cfg(not(any(target_os = "netbsd", target_os = "redox")))] use nix::sys::stat::FileStat; +#[cfg(not(target_os = "redox"))] use nix::sys::time::{TimeSpec, TimeVal, TimeValLike}; +#[cfg(not(target_os = "redox"))] use nix::unistd::chdir; -#[cfg(not(any(target_os = "netbsd")))] +#[cfg(not(any(target_os = "netbsd", target_os = "redox")))] use nix::Result; use tempfile; @@ -35,14 +48,14 @@ use tempfile; // uid and gid are signed on Windows, but not on other platforms. This function // allows warning free compiles on all platforms, and can be removed when // expression-level #[allow] is available. -#[cfg(not(any(target_os = "netbsd")))] +#[cfg(not(any(target_os = "netbsd", target_os = "redox")))] fn valid_uid_gid(stat: FileStat) -> bool { // uid could be 0 for the `root` user. This quite possible when // the tests are being run on a rooted Android device. stat.st_uid >= 0 && stat.st_gid >= 0 } -#[cfg(not(any(target_os = "netbsd")))] +#[cfg(not(any(target_os = "netbsd", target_os = "redox")))] fn assert_stat_results(stat_result: Result<FileStat>) { let stats = stat_result.expect("stat call failed"); assert!(stats.st_dev > 0); // must be positive integer, exact number machine dependent @@ -55,7 +68,7 @@ fn assert_stat_results(stat_result: Result<FileStat>) { assert!(stats.st_blocks <= 16); // Up to 16 blocks can be allocated for a blank file } -#[cfg(not(any(target_os = "netbsd")))] +#[cfg(not(any(target_os = "netbsd", target_os = "redox")))] fn assert_lstat_results(stat_result: Result<FileStat>) { let stats = stat_result.expect("stat call failed"); assert!(stats.st_dev > 0); // must be positive integer, exact number machine dependent @@ -189,6 +202,7 @@ fn test_fchmodat() { /// /// The atime and mtime are expressed with a resolution of seconds because some file systems /// (like macOS's HFS+) do not have higher granularity. +#[cfg(not(target_os = "redox"))] fn assert_times_eq(exp_atime_sec: u64, exp_mtime_sec: u64, attr: &fs::Metadata) { assert_eq!( Duration::new(exp_atime_sec, 0), diff --git a/test/test_unistd.rs b/test/test_unistd.rs index cc64a285..b9ec0718 100644 --- a/test/test_unistd.rs +++ b/test/test_unistd.rs @@ -1,18 +1,25 @@ -use nix::fcntl::{self, fcntl, FcntlArg, FdFlag, open, OFlag, readlink}; +#[cfg(not(target_os = "redox"))] +use nix::fcntl::{self, open, readlink}; +use nix::fcntl::{fcntl, FcntlArg, FdFlag, OFlag}; use nix::unistd::*; use nix::unistd::ForkResult::*; +#[cfg(not(target_os = "redox"))] use nix::sys::signal::{SaFlags, SigAction, SigHandler, SigSet, Signal, sigaction}; use nix::sys::wait::*; use nix::sys::stat::{self, Mode, SFlag}; use nix::errno::Errno; +#[cfg(not(target_os = "redox"))] use nix::Error; use std::{env, iter}; +#[cfg(not(target_os = "redox"))] use std::ffi::CString; -use std::fs::{self, DirBuilder, File}; +#[cfg(not(target_os = "redox"))] +use std::fs::DirBuilder; +use std::fs::{self, File}; use std::io::Write; use std::os::unix::prelude::*; use tempfile::{self, tempfile}; -use libc::{self, _exit, off_t}; +use libc::{_exit, off_t}; #[test] #[cfg(not(any(target_os = "netbsd")))] @@ -233,6 +240,7 @@ fn test_initgroups() { setgroups(&old_groups).unwrap(); } +#[cfg(not(target_os = "redox"))] macro_rules! execve_test_factory( ($test_name:ident, $syscall:ident, $exe: expr $(, $pathname:expr, $flags:expr)*) => ( #[test] @@ -466,7 +474,7 @@ cfg_if!{ skip_if_jailed!("test_acct"); } } - } else { + } else if #[cfg(not(target_os = "redox"))] { macro_rules! require_acct{ () => { skip_if_not_root!("test_acct"); @@ -592,9 +600,11 @@ fn test_ftruncate() { } // Used in `test_alarm`. +#[cfg(not(target_os = "redox"))] static mut ALARM_CALLED: bool = false; // Used in `test_alarm`. +#[cfg(not(target_os = "redox"))] pub extern fn alarm_signal_handler(raw_signal: libc::c_int) { assert_eq!(raw_signal, libc::SIGALRM, "unexpected signal: {}", raw_signal); unsafe { ALARM_CALLED = true }; |