diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs index bb315a1bc2..ec7670bd87 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -830,6 +830,8 @@ impl UnixAddr { } /// Create a new `sockaddr_un` representing an "unnamed" unix socket address. + #[cfg(any(target_os = "android", target_os = "linux"))] + #[cfg_attr(docsrs, doc(cfg(all())))] pub fn new_unnamed() -> UnixAddr { #[allow(unused)] let mut ret = libc::sockaddr_un { @@ -906,6 +908,8 @@ impl UnixAddr { } /// Check if this address is an "unnamed" unix socket address. + #[cfg(any(target_os = "android", target_os = "linux"))] + #[cfg_attr(docsrs, doc(cfg(all())))] #[inline] pub fn is_unnamed(&self) -> bool { matches!(self.kind(), UnixAddrKind::Unnamed) diff --git a/test/sys/test_socket.rs b/test/sys/test_socket.rs index 26ba9b2d0f..07ca4d3420 100644 --- a/test/sys/test_socket.rs +++ b/test/sys/test_socket.rs @@ -223,7 +223,7 @@ pub fn test_addr_equality_abstract() { } // Test getting/setting abstract addresses (without unix socket creation) -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "android", target_os = "linux"))] #[test] pub fn test_abstract_uds_addr() { let empty = String::new(); @@ -245,6 +245,7 @@ pub fn test_abstract_uds_addr() { } // Test getting an unnamed address (without unix socket creation) +#[cfg(any(target_os = "android", target_os = "linux"))] #[test] pub fn test_unnamed_uds_addr() { use crate::nix::sys::socket::SockaddrLike; @@ -256,7 +257,6 @@ pub fn test_unnamed_uds_addr() { assert!(addr.path().is_none()); assert_eq!(addr.path_len(), 0); - #[cfg(target_os = "linux")] assert!(addr.as_abstract().is_none()); } @@ -1544,6 +1544,7 @@ pub fn test_named_unixdomain() { } // Test using unnamed unix domain addresses +#[cfg(any(target_os = "android", target_os = "linux"))] #[test] pub fn test_unnamed_unixdomain() { use nix::sys::socket::{getsockname, socketpair};