diff options
author | Al Hoang <3811822-hoanga@users.noreply.gitlab.com> | 2022-04-22 23:56:51 -0500 |
---|---|---|
committer | Al Hoang <3811822-hoanga@users.noreply.gitlab.com> | 2022-05-14 18:45:18 -0500 |
commit | d02e27476cbf23b6818e57e017fd6148a98b7a92 (patch) | |
tree | 2e8bfe3a60c65393dd35224fe20bd3be51a77308 /test | |
parent | 69738c0fd03af19053c5701a984f923ecbbfada6 (diff) | |
download | nix-d02e27476cbf23b6818e57e017fd6148a98b7a92.zip |
add haiku support
* enabled as much functionality and defines that match
updated libc definitions for haiku
Diffstat (limited to 'test')
-rw-r--r-- | test/sys/mod.rs | 8 | ||||
-rw-r--r-- | test/sys/test_uio.rs | 4 | ||||
-rw-r--r-- | test/sys/test_wait.rs | 5 | ||||
-rw-r--r-- | test/test.rs | 4 | ||||
-rw-r--r-- | test/test_dir.rs | 1 | ||||
-rw-r--r-- | test/test_net.rs | 5 | ||||
-rw-r--r-- | test/test_resource.rs | 4 | ||||
-rw-r--r-- | test/test_stat.rs | 36 | ||||
-rw-r--r-- | test/test_unistd.rs | 47 |
9 files changed, 68 insertions, 46 deletions
diff --git a/test/sys/mod.rs b/test/sys/mod.rs index 91c0aae7..768d4d30 100644 --- a/test/sys/mod.rs +++ b/test/sys/mod.rs @@ -15,17 +15,17 @@ mod test_aio; mod test_mman; #[cfg(target_os = "linux")] mod test_signalfd; -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] mod test_socket; -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(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(any(target_os = "redox", target_os = "fuchsia")))] +#[cfg(not(any(target_os = "redox", target_os = "fuchsia", target_os = "haiku")))] mod test_termios; -#[cfg(not(any(target_os = "redox", target_os = "fuchsia")))] +#[cfg(not(any(target_os = "redox", target_os = "fuchsia", target_os = "haiku")))] mod test_ioctl; mod test_wait; mod test_uio; diff --git a/test/sys/test_uio.rs b/test/sys/test_uio.rs index 7dd12a21..847381f1 100644 --- a/test/sys/test_uio.rs +++ b/test/sys/test_uio.rs @@ -145,7 +145,7 @@ fn test_pread() { } #[test] -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] fn test_pwritev() { use std::io::Read; @@ -175,7 +175,7 @@ fn test_pwritev() { } #[test] -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] fn test_preadv() { use std::io::Write; diff --git a/test/sys/test_wait.rs b/test/sys/test_wait.rs index 90d9fcf5..058573a1 100644 --- a/test/sys/test_wait.rs +++ b/test/sys/test_wait.rs @@ -6,7 +6,7 @@ use nix::sys::wait::*; use libc::_exit; #[test] -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] fn test_wait_signal() { let _m = crate::FORK_MTX.lock(); @@ -27,7 +27,7 @@ fn test_wait_signal() { #[cfg(any( target_os = "android", target_os = "freebsd", - target_os = "haiku", + //target_os = "haiku", all(target_os = "linux", not(target_env = "uclibc")), ))] #[cfg(not(any(target_arch = "mips", target_arch = "mips64")))] @@ -63,6 +63,7 @@ fn test_wait_exit() { } } +#[cfg(not(target_os = "haiku"))] #[test] #[cfg(any( target_os = "android", diff --git a/test/test.rs b/test/test.rs index 3cac48f7..240d6e37 100644 --- a/test/test.rs +++ b/test/test.rs @@ -1,6 +1,6 @@ #[macro_use] extern crate cfg_if; -#[cfg_attr(not(target_os = "redox"), macro_use)] +#[cfg_attr(not(any(target_os = "redox", target_os = "haiku")), macro_use)] extern crate nix; #[macro_use] extern crate lazy_static; @@ -26,7 +26,7 @@ mod test_net; mod test_nix_path; mod test_resource; mod test_poll; -#[cfg(not(any(target_os = "redox", target_os = "fuchsia")))] +#[cfg(not(any(target_os = "redox", target_os = "fuchsia", target_os = "haiku")))] mod test_pty; #[cfg(any(target_os = "android", target_os = "dragonfly", diff --git a/test/test_dir.rs b/test/test_dir.rs index 2940b6ea..aaef34e4 100644 --- a/test/test_dir.rs +++ b/test/test_dir.rs @@ -50,6 +50,7 @@ fn rewind() { assert_eq!(entries2, entries3); } +#[cfg(not(target_os = "haiku"))] #[test] fn ebadf() { assert_eq!(Dir::from_fd(-1).unwrap_err(), nix::Error::EBADF); diff --git a/test/test_net.rs b/test/test_net.rs index 40ecd6bb..78a09b6c 100644 --- a/test/test_net.rs +++ b/test/test_net.rs @@ -3,9 +3,12 @@ use nix::net::if_::*; #[cfg(any(target_os = "android", target_os = "linux"))] const LOOPBACK: &[u8] = b"lo"; -#[cfg(not(any(target_os = "android", target_os = "linux")))] +#[cfg(not(any(target_os = "android", target_os = "linux", target_os = "haiku")))] const LOOPBACK: &[u8] = b"lo0"; +#[cfg(target_os = "haiku")] +const LOOPBACK: &[u8] = b"loop"; + #[test] fn test_if_nametoindex() { assert!(if_nametoindex(LOOPBACK).is_ok()); diff --git a/test/test_resource.rs b/test/test_resource.rs index c89d601e..f96bf903 100644 --- a/test/test_resource.rs +++ b/test/test_resource.rs @@ -1,4 +1,4 @@ -#[cfg(not(any(target_os = "redox", target_os = "fuchsia", target_os = "illumos")))] +#[cfg(not(any(target_os = "redox", target_os = "fuchsia", target_os = "illumos", target_os = "haiku")))] use nix::sys::resource::{getrlimit, setrlimit, Resource}; /// Tests the RLIMIT_NOFILE functionality of getrlimit(), where the resource RLIMIT_NOFILE refers @@ -10,7 +10,7 @@ use nix::sys::resource::{getrlimit, setrlimit, Resource}; /// to put the new soft limit in effect, and then getrlimit() once more to ensure the limits have /// been updated. #[test] -#[cfg(not(any(target_os = "redox", target_os = "fuchsia", target_os = "illumos")))] +#[cfg(not(any(target_os = "redox", target_os = "fuchsia", target_os = "illumos", target_os = "haiku")))] pub fn test_resource_limits_nofile() { let (mut soft_limit, hard_limit) = getrlimit(Resource::RLIMIT_NOFILE).unwrap(); diff --git a/test/test_stat.rs b/test/test_stat.rs index 8baa6555..3a09eca5 100644 --- a/test/test_stat.rs +++ b/test/test_stat.rs @@ -1,10 +1,12 @@ -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] use std::fs; use std::fs::File; #[cfg(not(target_os = "redox"))] -use std::os::unix::fs::{symlink, PermissionsExt}; +use std::os::unix::fs::{symlink}; +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] +use std::os::unix::fs::{PermissionsExt}; use std::os::unix::prelude::AsRawFd; -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] use std::time::{Duration, UNIX_EPOCH}; #[cfg(not(target_os = "redox"))] use std::path::Path; @@ -18,25 +20,30 @@ use nix::fcntl; #[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::{self}; +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] +use nix::sys::stat::{futimens, utimes}; use nix::sys::stat::{fchmod, stat}; #[cfg(not(target_os = "redox"))] -use nix::sys::stat::{fchmodat, utimensat, mkdirat}; +use nix::sys::stat::{fchmodat, mkdirat}; +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] +use nix::sys::stat::{utimensat}; #[cfg(any(target_os = "linux", - target_os = "haiku", target_os = "ios", target_os = "macos", target_os = "freebsd", target_os = "netbsd"))] use nix::sys::stat::lutimes; #[cfg(not(target_os = "redox"))] -use nix::sys::stat::{FchmodatFlags, UtimensatFlags}; +use nix::sys::stat::{FchmodatFlags}; +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] +use nix::sys::stat::{UtimensatFlags}; use nix::sys::stat::Mode; #[cfg(not(any(target_os = "netbsd", target_os = "redox")))] use nix::sys::stat::FileStat; -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] use nix::sys::time::{TimeSpec, TimeVal, TimeValLike}; #[cfg(not(target_os = "redox"))] use nix::unistd::chdir; @@ -191,7 +198,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"))] +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] fn assert_times_eq(exp_atime_sec: u64, exp_mtime_sec: u64, attr: &fs::Metadata) { assert_eq!( Duration::new(exp_atime_sec, 0), @@ -202,7 +209,7 @@ fn assert_times_eq(exp_atime_sec: u64, exp_mtime_sec: u64, attr: &fs::Metadata) } #[test] -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] fn test_utimes() { let tempdir = tempfile::tempdir().unwrap(); let fullpath = tempdir.path().join("file"); @@ -214,7 +221,6 @@ fn test_utimes() { #[test] #[cfg(any(target_os = "linux", - target_os = "haiku", target_os = "ios", target_os = "macos", target_os = "freebsd", @@ -238,7 +244,7 @@ fn test_lutimes() { } #[test] -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] fn test_futimens() { let tempdir = tempfile::tempdir().unwrap(); let fullpath = tempdir.path().join("file"); @@ -251,7 +257,7 @@ fn test_futimens() { } #[test] -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] fn test_utimensat() { let _dr = crate::DirRestore::new(); let tempdir = tempfile::tempdir().unwrap(); @@ -283,7 +289,7 @@ fn test_mkdirat_success_path() { } #[test] -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] fn test_mkdirat_success_mode() { let expected_bits = stat::SFlag::S_IFDIR.bits() | stat::Mode::S_IRWXU.bits(); let tempdir = tempfile::tempdir().unwrap(); @@ -312,6 +318,7 @@ fn test_mkdirat_fail() { target_os = "freebsd", target_os = "ios", target_os = "macos", + target_os = "haiku", target_os = "redox")))] fn test_mknod() { use stat::{lstat, mknod, SFlag}; @@ -331,6 +338,7 @@ fn test_mknod() { target_os = "illumos", target_os = "ios", target_os = "macos", + target_os = "haiku", target_os = "redox")))] fn test_mknodat() { use fcntl::{AtFlags, OFlag}; diff --git a/test/test_unistd.rs b/test/test_unistd.rs index 0f56b929..120a9dd3 100644 --- a/test/test_unistd.rs +++ b/test/test_unistd.rs @@ -1,5 +1,7 @@ #[cfg(not(target_os = "redox"))] -use nix::fcntl::{self, open, readlink}; +use nix::fcntl::{self, open}; +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] +use nix::fcntl::{readlink}; use nix::fcntl::OFlag; use nix::unistd::*; use nix::unistd::ForkResult::*; @@ -7,7 +9,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(any(target_os = "redox", target_os = "fuchsia")))] +#[cfg(not(any(target_os = "redox", target_os = "fuchsia", target_os = "haiku")))] use nix::pty::{posix_openpt, grantpt, unlockpt, ptsname}; use nix::errno::Errno; use std::env; @@ -18,7 +20,7 @@ use std::fs::DirBuilder; use std::fs::{self, File}; use std::io::Write; use std::os::unix::prelude::*; -#[cfg(not(any(target_os = "fuchsia", target_os = "redox")))] +#[cfg(not(any(target_os = "fuchsia", target_os = "redox", target_os = "haiku")))] use std::path::Path; use tempfile::{tempdir, tempfile}; use libc::{_exit, mode_t, off_t}; @@ -114,7 +116,7 @@ fn test_mkfifo_directory() { #[test] #[cfg(not(any( target_os = "macos", target_os = "ios", - target_os = "android", target_os = "redox")))] + target_os = "android", target_os = "redox", target_os = "haiku")))] fn test_mkfifoat_none() { let _m = crate::CWD_LOCK.read(); @@ -131,7 +133,7 @@ fn test_mkfifoat_none() { #[test] #[cfg(not(any( target_os = "macos", target_os = "ios", - target_os = "android", target_os = "redox")))] + target_os = "android", target_os = "redox", target_os = "haiku")))] fn test_mkfifoat() { use nix::fcntl; @@ -149,7 +151,7 @@ fn test_mkfifoat() { #[test] #[cfg(not(any( target_os = "macos", target_os = "ios", - target_os = "android", target_os = "redox")))] + target_os = "android", target_os = "redox", target_os = "haiku")))] fn test_mkfifoat_directory_none() { let _m = crate::CWD_LOCK.read(); @@ -160,7 +162,7 @@ fn test_mkfifoat_directory_none() { #[test] #[cfg(not(any( target_os = "macos", target_os = "ios", - target_os = "android", target_os = "redox")))] + target_os = "android", target_os = "redox", target_os = "haiku")))] fn test_mkfifoat_directory() { // mkfifoat should fail if a directory is given let tempdir = tempdir().unwrap(); @@ -201,7 +203,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", target_os = "fuchsia")))] +#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox", target_os = "fuchsia", target_os = "haiku")))] fn test_setgroups() { // Skip this test when not run as root as `setgroups()` requires root. skip_if_not_root!("test_setgroups"); @@ -228,6 +230,7 @@ fn test_setgroups() { target_os = "macos", target_os = "redox", target_os = "fuchsia", + target_os = "haiku", target_os = "illumos")))] fn test_initgroups() { // Skip this test when not run as root as `initgroups()` and `setgroups()` @@ -555,7 +558,7 @@ cfg_if!{ skip_if_jailed!("test_acct"); } } - } else if #[cfg(not(any(target_os = "redox", target_os = "fuchsia")))] { + } else if #[cfg(not(any(target_os = "redox", target_os = "fuchsia", target_os = "haiku")))] { macro_rules! require_acct{ () => { skip_if_not_root!("test_acct"); @@ -565,7 +568,7 @@ cfg_if!{ } #[test] -#[cfg(not(any(target_os = "redox", target_os = "fuchsia")))] +#[cfg(not(any(target_os = "redox", target_os = "fuchsia", target_os = "haiku")))] fn test_acct() { use tempfile::NamedTempFile; use std::process::Command; @@ -786,7 +789,7 @@ fn test_canceling_alarm() { } #[test] -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] fn test_symlinkat() { let _m = crate::CWD_LOCK.read(); @@ -814,7 +817,7 @@ fn test_symlinkat() { } #[test] -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] fn test_linkat_file() { let tempdir = tempdir().unwrap(); let oldfilename = "foo.txt"; @@ -835,7 +838,7 @@ fn test_linkat_file() { } #[test] -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] fn test_linkat_olddirfd_none() { let _dr = crate::DirRestore::new(); @@ -860,7 +863,7 @@ fn test_linkat_olddirfd_none() { } #[test] -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] fn test_linkat_newdirfd_none() { let _dr = crate::DirRestore::new(); @@ -885,7 +888,7 @@ fn test_linkat_newdirfd_none() { } #[test] -#[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 = "haiku")))] fn test_linkat_no_follow_symlink() { let _m = crate::CWD_LOCK.read(); @@ -922,7 +925,7 @@ fn test_linkat_no_follow_symlink() { } #[test] -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "haiku")))] fn test_linkat_follow_symlink() { let _m = crate::CWD_LOCK.read(); @@ -1033,7 +1036,13 @@ fn test_access_file_exists() { #[test] fn test_user_into_passwd() { // get the UID of the "nobody" user - let nobody = User::from_name("nobody").unwrap().unwrap(); + #[cfg(not(target_os = "haiku"))] + let test_username = "nobody"; + // "nobody" unavailable on haiku + #[cfg(target_os = "haiku")] + let test_username = "user"; + + let nobody = User::from_name(test_username).unwrap().unwrap(); let pwd: libc::passwd = nobody.into(); let _: User = (&pwd).into(); } @@ -1078,7 +1087,7 @@ fn test_setfsuid() { } #[test] -#[cfg(not(any(target_os = "redox", target_os = "fuchsia")))] +#[cfg(not(any(target_os = "redox", target_os = "fuchsia", target_os = "haiku")))] fn test_ttyname() { let fd = posix_openpt(OFlag::O_RDWR).expect("posix_openpt failed"); assert!(fd.as_raw_fd() > 0); @@ -1109,7 +1118,7 @@ fn test_ttyname_not_pty() { } #[test] -#[cfg(not(any(target_os = "redox", target_os = "fuchsia")))] +#[cfg(not(any(target_os = "redox", target_os = "fuchsia", target_os = "haiku")))] fn test_ttyname_invalid_fd() { assert_eq!(ttyname(-1), Err(Errno::EBADF)); } |