From 5846ae2afd76ba1ffaddb9d08f91dfbed30243c4 Mon Sep 17 00:00:00 2001 From: Amanda Tait Date: Wed, 5 Aug 2020 13:25:03 -0400 Subject: Add fuchsia support Allow nix to compile on Fuchsia by conditionally avoiding libc functionality that does not exist for Fuchsia. --- test/test_unistd.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'test/test_unistd.rs') diff --git a/test/test_unistd.rs b/test/test_unistd.rs index d169d6e0..0f6cf7d3 100644 --- a/test/test_unistd.rs +++ b/test/test_unistd.rs @@ -7,7 +7,7 @@ use nix::unistd::ForkResult::*; use nix::sys::signal::{SaFlags, SigAction, SigHandler, SigSet, Signal, sigaction}; use nix::sys::wait::*; use nix::sys::stat::{self, Mode, SFlag}; -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "fuchsia")))] use nix::pty::{posix_openpt, grantpt, unlockpt, ptsname}; use nix::errno::Errno; #[cfg(not(target_os = "redox"))] @@ -201,7 +201,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", target_os = "redox")))] +#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox", target_os = "fuchsia")))] fn test_setgroups() { // Skip this test when not run as root as `setgroups()` requires root. skip_if_not_root!("test_setgroups"); @@ -224,7 +224,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", target_os = "redox")))] +#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox", target_os = "fuchsia")))] fn test_initgroups() { // Skip this test when not run as root as `initgroups()` and `setgroups()` // require root. @@ -406,6 +406,7 @@ cfg_if!{ } #[test] +#[cfg(not(target_os = "fuchsia"))] fn test_fchdir() { // fchdir changes the process's cwd let _dr = crate::DirRestore::new(); @@ -552,7 +553,7 @@ cfg_if!{ skip_if_jailed!("test_acct"); } } - } else if #[cfg(not(target_os = "redox"))] { + } else if #[cfg(not(any(target_os = "redox", target_os = "fuchsia")))] { macro_rules! require_acct{ () => { skip_if_not_root!("test_acct"); @@ -562,7 +563,7 @@ cfg_if!{ } #[test] -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "fuchsia")))] fn test_acct() { use tempfile::NamedTempFile; use std::process::Command; @@ -649,7 +650,7 @@ fn test_pipe2() { } #[test] -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "fuchsia")))] fn test_truncate() { let tempdir = tempdir().unwrap(); let path = tempdir.path().join("file"); @@ -1033,7 +1034,7 @@ fn test_setfsuid() { } #[test] -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "fuchsia")))] fn test_ttyname() { let fd = posix_openpt(OFlag::O_RDWR).expect("posix_openpt failed"); assert!(fd.as_raw_fd() > 0); @@ -1056,7 +1057,7 @@ fn test_ttyname() { } #[test] -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "fuchsia")))] fn test_ttyname_not_pty() { let fd = File::open("/dev/zero").unwrap(); assert!(fd.as_raw_fd() > 0); @@ -1064,7 +1065,7 @@ fn test_ttyname_not_pty() { } #[test] -#[cfg(all(not(target_os = "redox")))] +#[cfg(not(any(target_os = "redox", target_os = "fuchsia")))] fn test_ttyname_invalid_fd() { assert_eq!(ttyname(-1), Err(Error::Sys(Errno::EBADF))); } -- cgit v1.2.3