mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge pull request #1836 from aspenluxxxy/ios-compat
Change target_os = "macos" to target_vendor = "apple"
This commit is contained in:
commit
a482e28798
17 changed files with 54 additions and 64 deletions
|
@ -164,7 +164,7 @@ fn set_main_group(group: &str) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
|
#[cfg(any(target_vendor = "apple", target_os = "freebsd"))]
|
||||||
fn set_groups(groups: Vec<libc::gid_t>) -> libc::c_int {
|
fn set_groups(groups: Vec<libc::gid_t>) -> libc::c_int {
|
||||||
unsafe { setgroups(groups.len() as libc::c_int, groups.as_ptr()) }
|
unsafe { setgroups(groups.len() as libc::c_int, groups.as_ptr()) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,15 +32,15 @@ use std::ffi::CString;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
|
#[cfg(any(target_vendor = "apple", target_os = "freebsd"))]
|
||||||
use libc::c_int;
|
use libc::c_int;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_vendor = "apple")]
|
||||||
use libc::statfs;
|
use libc::statfs;
|
||||||
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
|
#[cfg(any(target_vendor = "apple", target_os = "freebsd"))]
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "windows"))]
|
#[cfg(any(target_vendor = "apple", target_os = "freebsd", target_os = "windows"))]
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
|
#[cfg(any(target_vendor = "apple", target_os = "freebsd"))]
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
#[cfg(target_os = "freebsd")]
|
#[cfg(target_os = "freebsd")]
|
||||||
|
@ -137,7 +137,7 @@ struct MountInfo {
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
target_os = "freebsd",
|
target_os = "freebsd",
|
||||||
not(all(target_os = "macos", target_arch = "x86_64"))
|
not(all(target_vendor = "apple", target_arch = "x86_64"))
|
||||||
))]
|
))]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
|
@ -209,20 +209,20 @@ fn get_usage() -> String {
|
||||||
format!("{0} [OPTION]... [FILE]...", executable!())
|
format!("{0} [OPTION]... [FILE]...", executable!())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
|
#[cfg(any(target_os = "freebsd", target_vendor = "apple"))]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
|
#[cfg(all(target_vendor = "apple", target_arch = "x86_64"))]
|
||||||
#[link_name = "getmntinfo$INODE64"]
|
#[link_name = "getmntinfo$INODE64"]
|
||||||
fn getmntinfo(mntbufp: *mut *mut statfs, flags: c_int) -> c_int;
|
fn getmntinfo(mntbufp: *mut *mut statfs, flags: c_int) -> c_int;
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
all(target_os = "freebsd"),
|
all(target_os = "freebsd"),
|
||||||
all(target_os = "macos", target_arch = "aarch64")
|
all(target_vendor = "apple", target_arch = "aarch64")
|
||||||
))]
|
))]
|
||||||
fn getmntinfo(mntbufp: *mut *mut statfs, flags: c_int) -> c_int;
|
fn getmntinfo(mntbufp: *mut *mut statfs, flags: c_int) -> c_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
|
#[cfg(any(target_os = "freebsd", target_vendor = "apple"))]
|
||||||
impl From<statfs> for MountInfo {
|
impl From<statfs> for MountInfo {
|
||||||
fn from(statfs: statfs) -> Self {
|
fn from(statfs: statfs) -> Self {
|
||||||
let mut info = MountInfo {
|
let mut info = MountInfo {
|
||||||
|
@ -585,7 +585,7 @@ fn read_fs_list() -> Vec<MountInfo> {
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
}
|
}
|
||||||
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
|
#[cfg(any(target_os = "freebsd", target_vendor = "apple"))]
|
||||||
{
|
{
|
||||||
let mut mptr: *mut statfs = ptr::null_mut();
|
let mut mptr: *mut statfs = ptr::null_mut();
|
||||||
let len = unsafe { getmntinfo(&mut mptr, 1 as c_int) };
|
let len = unsafe { getmntinfo(&mut mptr, 1 as c_int) };
|
||||||
|
|
|
@ -291,7 +291,7 @@ fn pretty(possible_pw: Option<Passwd>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
|
#[cfg(any(target_vendor = "apple", target_os = "freebsd"))]
|
||||||
fn pline(possible_uid: Option<uid_t>) {
|
fn pline(possible_uid: Option<uid_t>) {
|
||||||
let uid = possible_uid.unwrap_or_else(getuid);
|
let uid = possible_uid.unwrap_or_else(getuid);
|
||||||
let pw = Passwd::locate(uid).unwrap();
|
let pw = Passwd::locate(uid).unwrap();
|
||||||
|
|
|
@ -23,7 +23,7 @@ use uucore::fs::{is_stderr_interactive, is_stdin_interactive, is_stdout_interact
|
||||||
static NAME: &str = "nohup";
|
static NAME: &str = "nohup";
|
||||||
static VERSION: &str = env!("CARGO_PKG_VERSION");
|
static VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_vendor = "apple")]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn _vprocmgr_detach_from_console(flags: u32) -> *const libc::c_int;
|
fn _vprocmgr_detach_from_console(flags: u32) -> *const libc::c_int;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ use std::env;
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub const _SC_NPROCESSORS_CONF: libc::c_int = 83;
|
pub const _SC_NPROCESSORS_CONF: libc::c_int = 83;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_vendor = "apple")]
|
||||||
pub const _SC_NPROCESSORS_CONF: libc::c_int = libc::_SC_NPROCESSORS_CONF;
|
pub const _SC_NPROCESSORS_CONF: libc::c_int = libc::_SC_NPROCESSORS_CONF;
|
||||||
#[cfg(target_os = "freebsd")]
|
#[cfg(target_os = "freebsd")]
|
||||||
pub const _SC_NPROCESSORS_CONF: libc::c_int = 57;
|
pub const _SC_NPROCESSORS_CONF: libc::c_int = 57;
|
||||||
|
@ -89,7 +89,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
target_os = "macos",
|
target_vendor = "apple",
|
||||||
target_os = "freebsd",
|
target_os = "freebsd",
|
||||||
target_os = "netbsd"
|
target_os = "netbsd"
|
||||||
))]
|
))]
|
||||||
|
@ -109,7 +109,7 @@ fn num_cpus_all() -> usize {
|
||||||
// Other platforms (e.g., windows), num_cpus::get() directly.
|
// Other platforms (e.g., windows), num_cpus::get() directly.
|
||||||
#[cfg(not(any(
|
#[cfg(not(any(
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
target_os = "macos",
|
target_vendor = "apple",
|
||||||
target_os = "freebsd",
|
target_os = "freebsd",
|
||||||
target_os = "netbsd"
|
target_os = "netbsd"
|
||||||
)))]
|
)))]
|
||||||
|
|
|
@ -149,7 +149,7 @@ use std::path::Path;
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
target_os = "macos",
|
target_vendor = "apple",
|
||||||
target_os = "android",
|
target_os = "android",
|
||||||
target_os = "freebsd"
|
target_os = "freebsd"
|
||||||
))]
|
))]
|
||||||
|
@ -165,7 +165,7 @@ use uucore::libc::statvfs as Sstatfs;
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
target_os = "macos",
|
target_vendor = "apple",
|
||||||
target_os = "android",
|
target_os = "android",
|
||||||
target_os = "freebsd"
|
target_os = "freebsd"
|
||||||
))]
|
))]
|
||||||
|
@ -211,11 +211,11 @@ impl FsMeta for Sstatfs {
|
||||||
fn free_fnodes(&self) -> u64 {
|
fn free_fnodes(&self) -> u64 {
|
||||||
self.f_ffree as u64
|
self.f_ffree as u64
|
||||||
}
|
}
|
||||||
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))]
|
#[cfg(any(target_os = "linux", target_vendor = "apple", target_os = "freebsd"))]
|
||||||
fn fs_type(&self) -> i64 {
|
fn fs_type(&self) -> i64 {
|
||||||
self.f_type as i64
|
self.f_type as i64
|
||||||
}
|
}
|
||||||
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "freebsd")))]
|
#[cfg(not(any(target_os = "linux", target_vendor = "apple", target_os = "freebsd")))]
|
||||||
fn fs_type(&self) -> i64 {
|
fn fs_type(&self) -> i64 {
|
||||||
// FIXME: statvfs doesn't have an equivalent, so we need to do something else
|
// FIXME: statvfs doesn't have an equivalent, so we need to do something else
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
|
@ -225,12 +225,12 @@ impl FsMeta for Sstatfs {
|
||||||
fn iosize(&self) -> u64 {
|
fn iosize(&self) -> u64 {
|
||||||
self.f_frsize as u64
|
self.f_frsize as u64
|
||||||
}
|
}
|
||||||
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
|
#[cfg(any(target_vendor = "apple", target_os = "freebsd"))]
|
||||||
fn iosize(&self) -> u64 {
|
fn iosize(&self) -> u64 {
|
||||||
self.f_iosize as u64
|
self.f_iosize as u64
|
||||||
}
|
}
|
||||||
// XXX: dunno if this is right
|
// XXX: dunno if this is right
|
||||||
#[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "linux")))]
|
#[cfg(not(any(target_vendor = "apple", target_os = "freebsd", target_os = "linux")))]
|
||||||
fn iosize(&self) -> u64 {
|
fn iosize(&self) -> u64 {
|
||||||
self.f_bsize as u64
|
self.f_bsize as u64
|
||||||
}
|
}
|
||||||
|
@ -241,13 +241,13 @@ impl FsMeta for Sstatfs {
|
||||||
//
|
//
|
||||||
// Solaris, Irix and POSIX have a system call statvfs(2) that returns a
|
// Solaris, Irix and POSIX have a system call statvfs(2) that returns a
|
||||||
// struct statvfs, containing an unsigned long f_fsid
|
// struct statvfs, containing an unsigned long f_fsid
|
||||||
#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "linux"))]
|
#[cfg(any(target_vendor = "apple", target_os = "freebsd", target_os = "linux"))]
|
||||||
fn fsid(&self) -> u64 {
|
fn fsid(&self) -> u64 {
|
||||||
let f_fsid: &[u32; 2] =
|
let f_fsid: &[u32; 2] =
|
||||||
unsafe { &*(&self.f_fsid as *const uucore::libc::fsid_t as *const [u32; 2]) };
|
unsafe { &*(&self.f_fsid as *const uucore::libc::fsid_t as *const [u32; 2]) };
|
||||||
(u64::from(f_fsid[0])) << 32 | u64::from(f_fsid[1])
|
(u64::from(f_fsid[0])) << 32 | u64::from(f_fsid[1])
|
||||||
}
|
}
|
||||||
#[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "linux")))]
|
#[cfg(not(any(target_vendor = "apple", target_os = "freebsd", target_os = "linux")))]
|
||||||
fn fsid(&self) -> u64 {
|
fn fsid(&self) -> u64 {
|
||||||
self.f_fsid as u64
|
self.f_fsid as u64
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ impl FsMeta for Sstatfs {
|
||||||
fn namelen(&self) -> u64 {
|
fn namelen(&self) -> u64 {
|
||||||
self.f_namelen as u64
|
self.f_namelen as u64
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_vendor = "apple")]
|
||||||
fn namelen(&self) -> u64 {
|
fn namelen(&self) -> u64 {
|
||||||
1024
|
1024
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ impl FsMeta for Sstatfs {
|
||||||
self.f_namemax as u64
|
self.f_namemax as u64
|
||||||
}
|
}
|
||||||
// XXX: should everything just use statvfs?
|
// XXX: should everything just use statvfs?
|
||||||
#[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "linux")))]
|
#[cfg(not(any(target_vendor = "apple", target_os = "freebsd", target_os = "linux")))]
|
||||||
fn namelen(&self) -> u64 {
|
fn namelen(&self) -> u64 {
|
||||||
self.f_namemax as u64
|
self.f_namemax as u64
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,12 @@ use std::env;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "windows")))]
|
#[cfg(not(any(target_vendor = "apple", target_os = "windows")))]
|
||||||
mod platform {
|
mod platform {
|
||||||
pub const DYLIB_EXT: &str = ".so";
|
pub const DYLIB_EXT: &str = ".so";
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
#[cfg(any(target_vendor = "apple"))]
|
||||||
mod platform {
|
mod platform {
|
||||||
pub const DYLIB_EXT: &str = ".dylib";
|
pub const DYLIB_EXT: &str = ".dylib";
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ fn preload_strings() -> (&'static str, &'static str) {
|
||||||
("LD_PRELOAD", "so")
|
("LD_PRELOAD", "so")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_vendor = "apple")]
|
||||||
fn preload_strings() -> (&'static str, &'static str) {
|
fn preload_strings() -> (&'static str, &'static str) {
|
||||||
("DYLD_LIBRARY_PATH", "dylib")
|
("DYLD_LIBRARY_PATH", "dylib")
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ fn preload_strings() -> (&'static str, &'static str) {
|
||||||
target_os = "freebsd",
|
target_os = "freebsd",
|
||||||
target_os = "netbsd",
|
target_os = "netbsd",
|
||||||
target_os = "dragonflybsd",
|
target_os = "dragonflybsd",
|
||||||
target_os = "macos"
|
target_vendor = "apple"
|
||||||
)))]
|
)))]
|
||||||
fn preload_strings() -> (&'static str, &'static str) {
|
fn preload_strings() -> (&'static str, &'static str) {
|
||||||
crash!(1, "Command not supported for this operating system!")
|
crash!(1, "Command not supported for this operating system!")
|
||||||
|
|
|
@ -39,7 +39,7 @@ const HOST_OS: &str = "Windows NT";
|
||||||
const HOST_OS: &str = "FreeBSD";
|
const HOST_OS: &str = "FreeBSD";
|
||||||
#[cfg(target_os = "openbsd")]
|
#[cfg(target_os = "openbsd")]
|
||||||
const HOST_OS: &str = "OpenBSD";
|
const HOST_OS: &str = "OpenBSD";
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_vendor = "apple")]
|
||||||
const HOST_OS: &str = "Darwin";
|
const HOST_OS: &str = "Darwin";
|
||||||
#[cfg(target_os = "fuchsia")]
|
#[cfg(target_os = "fuchsia")]
|
||||||
const HOST_OS: &str = "Fuchsia";
|
const HOST_OS: &str = "Fuchsia";
|
||||||
|
|
|
@ -60,12 +60,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
"count",
|
"count",
|
||||||
"all login names and number of users logged on",
|
"all login names and number of users logged on",
|
||||||
);
|
);
|
||||||
#[cfg(any(
|
#[cfg(any(target_vendor = "apple", target_os = "linux", target_os = "android"))]
|
||||||
target_os = "macos",
|
|
||||||
target_os = "ios",
|
|
||||||
target_os = "linux",
|
|
||||||
target_os = "android"
|
|
||||||
))]
|
|
||||||
opts.optflag("r", "runlevel", "print current runlevel");
|
opts.optflag("r", "runlevel", "print current runlevel");
|
||||||
opts.optflag("s", "short", "print only name, line, and time (default)");
|
opts.optflag("s", "short", "print only name, line, and time (default)");
|
||||||
opts.optflag("t", "time", "print last system clock change");
|
opts.optflag("t", "time", "print last system clock change");
|
||||||
|
@ -305,12 +300,7 @@ impl Who {
|
||||||
#[allow(unused_assignments)]
|
#[allow(unused_assignments)]
|
||||||
let mut res = false;
|
let mut res = false;
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(target_vendor = "apple", target_os = "linux", target_os = "android"))]
|
||||||
target_os = "macos",
|
|
||||||
target_os = "ios",
|
|
||||||
target_os = "linux",
|
|
||||||
target_os = "android"
|
|
||||||
))]
|
|
||||||
{
|
{
|
||||||
res = record == utmpx::RUN_LVL;
|
res = record == utmpx::RUN_LVL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
//! assert!(entries::Group::locate(root_group).is_ok());
|
//! assert!(entries::Group::locate(root_group).is_ok());
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
|
#[cfg(any(target_os = "freebsd", target_vendor = "apple"))]
|
||||||
use libc::time_t;
|
use libc::time_t;
|
||||||
use libc::{c_char, c_int, gid_t, uid_t};
|
use libc::{c_char, c_int, gid_t, uid_t};
|
||||||
use libc::{getgrgid, getgrnam, getgroups, getpwnam, getpwuid, group, passwd};
|
use libc::{getgrgid, getgrnam, getgroups, getpwnam, getpwuid, group, passwd};
|
||||||
|
@ -119,19 +119,19 @@ impl Passwd {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// AKA passwd.pw_class
|
/// AKA passwd.pw_class
|
||||||
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
|
#[cfg(any(target_os = "freebsd", target_vendor = "apple"))]
|
||||||
pub fn user_access_class(&self) -> Cow<str> {
|
pub fn user_access_class(&self) -> Cow<str> {
|
||||||
cstr2cow!(self.inner.pw_class)
|
cstr2cow!(self.inner.pw_class)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// AKA passwd.pw_change
|
/// AKA passwd.pw_change
|
||||||
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
|
#[cfg(any(target_os = "freebsd", target_vendor = "apple"))]
|
||||||
pub fn passwd_change_time(&self) -> time_t {
|
pub fn passwd_change_time(&self) -> time_t {
|
||||||
self.inner.pw_change
|
self.inner.pw_change
|
||||||
}
|
}
|
||||||
|
|
||||||
/// AKA passwd.pw_expire
|
/// AKA passwd.pw_expire
|
||||||
#[cfg(any(target_os = "freebsd", target_os = "macos"))]
|
#[cfg(any(target_os = "freebsd", target_vendor = "apple"))]
|
||||||
pub fn expiration(&self) -> time_t {
|
pub fn expiration(&self) -> time_t {
|
||||||
self.inner.pw_expire
|
self.inner.pw_expire
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,7 +197,7 @@ No Name Default Action Description
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
|
#[cfg(any(target_vendor = "apple", target_os = "freebsd"))]
|
||||||
pub static ALL_SIGNALS: [Signal<'static>; 31] = [
|
pub static ALL_SIGNALS: [Signal<'static>; 31] = [
|
||||||
Signal {
|
Signal {
|
||||||
name: "HUP",
|
name: "HUP",
|
||||||
|
|
|
@ -47,7 +47,7 @@ use libc::utmpx;
|
||||||
pub use libc::endutxent;
|
pub use libc::endutxent;
|
||||||
pub use libc::getutxent;
|
pub use libc::getutxent;
|
||||||
pub use libc::setutxent;
|
pub use libc::setutxent;
|
||||||
#[cfg(any(target_os = "macos", target_os = "linux"))]
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
||||||
pub use libc::utmpxname;
|
pub use libc::utmpxname;
|
||||||
#[cfg(target_os = "freebsd")]
|
#[cfg(target_os = "freebsd")]
|
||||||
pub unsafe extern "C" fn utmpxname(_file: *const libc::c_char) -> libc::c_int {
|
pub unsafe extern "C" fn utmpxname(_file: *const libc::c_char) -> libc::c_int {
|
||||||
|
@ -85,7 +85,7 @@ mod ut {
|
||||||
pub use libc::USER_PROCESS;
|
pub use libc::USER_PROCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_vendor = "apple")]
|
||||||
mod ut {
|
mod ut {
|
||||||
pub static DEFAULT_FILE: &str = "/var/run/utmpx";
|
pub static DEFAULT_FILE: &str = "/var/run/utmpx";
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ fn test_reference() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_vendor = "apple")]
|
||||||
fn test_reference() {
|
fn test_reference() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("-v")
|
.arg("-v")
|
||||||
|
|
|
@ -12,7 +12,7 @@ fn test_du_basics() {
|
||||||
assert!(result.success);
|
assert!(result.success);
|
||||||
assert_eq!(result.stderr, "");
|
assert_eq!(result.stderr, "");
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_vendor = "apple")]
|
||||||
fn _du_basics(s: String) {
|
fn _du_basics(s: String) {
|
||||||
let answer = "32\t./subdir
|
let answer = "32\t./subdir
|
||||||
8\t./subdir/deeper
|
8\t./subdir/deeper
|
||||||
|
@ -21,7 +21,7 @@ fn _du_basics(s: String) {
|
||||||
";
|
";
|
||||||
assert_eq!(s, answer);
|
assert_eq!(s, answer);
|
||||||
}
|
}
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_vendor = "apple"))]
|
||||||
fn _du_basics(s: String) {
|
fn _du_basics(s: String) {
|
||||||
let answer = "28\t./subdir
|
let answer = "28\t./subdir
|
||||||
8\t./subdir/deeper
|
8\t./subdir/deeper
|
||||||
|
@ -41,11 +41,11 @@ fn test_du_basics_subdir() {
|
||||||
_du_basics_subdir(result.stdout);
|
_du_basics_subdir(result.stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_vendor = "apple")]
|
||||||
fn _du_basics_subdir(s: String) {
|
fn _du_basics_subdir(s: String) {
|
||||||
assert_eq!(s, "4\tsubdir/deeper\n");
|
assert_eq!(s, "4\tsubdir/deeper\n");
|
||||||
}
|
}
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_vendor = "apple"))]
|
||||||
fn _du_basics_subdir(s: String) {
|
fn _du_basics_subdir(s: String) {
|
||||||
// MS-WSL linux has altered expected output
|
// MS-WSL linux has altered expected output
|
||||||
if !is_wsl() {
|
if !is_wsl() {
|
||||||
|
@ -80,12 +80,12 @@ fn test_du_soft_link() {
|
||||||
_du_soft_link(result.stdout);
|
_du_soft_link(result.stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_vendor = "apple")]
|
||||||
fn _du_soft_link(s: String) {
|
fn _du_soft_link(s: String) {
|
||||||
// 'macos' host variants may have `du` output variation for soft links
|
// 'macos' host variants may have `du` output variation for soft links
|
||||||
assert!((s == "12\tsubdir/links\n") || (s == "16\tsubdir/links\n"));
|
assert!((s == "12\tsubdir/links\n") || (s == "16\tsubdir/links\n"));
|
||||||
}
|
}
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_vendor = "apple"))]
|
||||||
fn _du_soft_link(s: String) {
|
fn _du_soft_link(s: String) {
|
||||||
// MS-WSL linux has altered expected output
|
// MS-WSL linux has altered expected output
|
||||||
if !is_wsl() {
|
if !is_wsl() {
|
||||||
|
@ -109,11 +109,11 @@ fn test_du_hard_link() {
|
||||||
_du_hard_link(result.stdout);
|
_du_hard_link(result.stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_vendor = "apple")]
|
||||||
fn _du_hard_link(s: String) {
|
fn _du_hard_link(s: String) {
|
||||||
assert_eq!(s, "12\tsubdir/links\n")
|
assert_eq!(s, "12\tsubdir/links\n")
|
||||||
}
|
}
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_vendor = "apple"))]
|
||||||
fn _du_hard_link(s: String) {
|
fn _du_hard_link(s: String) {
|
||||||
// MS-WSL linux has altered expected output
|
// MS-WSL linux has altered expected output
|
||||||
if !is_wsl() {
|
if !is_wsl() {
|
||||||
|
@ -133,11 +133,11 @@ fn test_du_d_flag() {
|
||||||
_du_d_flag(result.stdout);
|
_du_d_flag(result.stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_vendor = "apple")]
|
||||||
fn _du_d_flag(s: String) {
|
fn _du_d_flag(s: String) {
|
||||||
assert_eq!(s, "16\t./subdir\n20\t./\n");
|
assert_eq!(s, "16\t./subdir\n20\t./\n");
|
||||||
}
|
}
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_vendor = "apple"))]
|
||||||
fn _du_d_flag(s: String) {
|
fn _du_d_flag(s: String) {
|
||||||
// MS-WSL linux has altered expected output
|
// MS-WSL linux has altered expected output
|
||||||
if !is_wsl() {
|
if !is_wsl() {
|
||||||
|
|
|
@ -11,7 +11,7 @@ fn test_hostname() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FixME: fails for "MacOS"
|
// FixME: fails for "MacOS"
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_vendor = "apple"))]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_hostname_ip() {
|
fn test_hostname_ip() {
|
||||||
let result = new_ucmd!().arg("-i").run();
|
let result = new_ucmd!().arg("-i").run();
|
||||||
|
|
|
@ -285,7 +285,7 @@ fn test_ls_ls_color() {
|
||||||
scene.ucmd().arg("--color=never").arg("z").succeeds();
|
scene.ucmd().arg("--color=never").arg("z").succeeds();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "macos", target_os = "windows")))] // Truncate not available on mac or win
|
#[cfg(not(any(target_vendor = "apple", target_os = "windows")))] // Truncate not available on mac or win
|
||||||
#[test]
|
#[test]
|
||||||
fn test_ls_human() {
|
fn test_ls_human() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue