Update tvOS support elsewhere in the stdlib

This commit is contained in:
Thom Chiovoloni 2023-06-04 09:46:43 -07:00
parent 49da0acb71
commit 37854aab76
No known key found for this signature in database
4 changed files with 36 additions and 7 deletions

View File

@ -1640,6 +1640,10 @@ fn test_file_times() {
use crate::os::ios::fs::FileTimesExt;
#[cfg(target_os = "macos")]
use crate::os::macos::fs::FileTimesExt;
#[cfg(target_os = "tvos")]
use crate::os::tvos::fs::FileTimesExt;
#[cfg(target_os = "tvos")]
use crate::os::tvos::fs::FileTimesExt;
#[cfg(target_os = "watchos")]
use crate::os::watchos::fs::FileTimesExt;
#[cfg(windows)]
@ -1651,9 +1655,21 @@ fn test_file_times() {
let accessed = SystemTime::UNIX_EPOCH + Duration::from_secs(12345);
let modified = SystemTime::UNIX_EPOCH + Duration::from_secs(54321);
times = times.set_accessed(accessed).set_modified(modified);
#[cfg(any(windows, target_os = "macos", target_os = "ios", target_os = "watchos"))]
#[cfg(any(
windows,
target_os = "macos",
target_os = "ios",
target_os = "watchos",
target_os = "tvos",
))]
let created = SystemTime::UNIX_EPOCH + Duration::from_secs(32123);
#[cfg(any(windows, target_os = "macos", target_os = "ios", target_os = "watchos"))]
#[cfg(any(
windows,
target_os = "macos",
target_os = "ios",
target_os = "watchos",
target_os = "tvos",
))]
{
times = times.set_created(created);
}
@ -1678,7 +1694,13 @@ fn test_file_times() {
let metadata = file.metadata().unwrap();
assert_eq!(metadata.accessed().unwrap(), accessed);
assert_eq!(metadata.modified().unwrap(), modified);
#[cfg(any(windows, target_os = "macos", target_os = "ios", target_os = "watchos"))]
#[cfg(any(
windows,
target_os = "macos",
target_os = "ios",
target_os = "watchos",
target_os = "tvos",
))]
{
assert_eq!(metadata.created().unwrap(), created);
}

View File

@ -27,7 +27,13 @@ fn test_socket_pair() {
}
#[test]
#[cfg(any(target_os = "linux", target_os = "ios", target_os = "macos", target_os = "watchos"))]
#[cfg(any(
target_os = "linux",
target_os = "ios",
target_os = "macos",
target_os = "watchos",
target_os = "tvos",
))]
fn test_socket_pair_pids(arg: Type) -> RetType {
// Create two connected sockets and get their peer credentials.
let (sock_a, sock_b) = UnixStream::pair().unwrap();

View File

@ -362,7 +362,7 @@ pub struct FilePermissions {
pub struct FileTimes {
accessed: Option<SystemTime>,
modified: Option<SystemTime>,
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos"))]
created: Option<SystemTime>,
}
@ -615,7 +615,7 @@ impl FileTimes {
self.modified = Some(t);
}
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos"))]
pub fn set_created(&mut self, t: SystemTime) {
self.created = Some(t);
}
@ -1272,7 +1272,7 @@ impl File {
io::ErrorKind::Unsupported,
"setting file times not supported",
))
} else if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))] {
} else if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))] {
let mut buf = [mem::MaybeUninit::<libc::timespec>::uninit(); 3];
let mut num_times = 0;
let mut attrlist: libc::attrlist = unsafe { mem::zeroed() };

View File

@ -42,6 +42,7 @@ fn test_named_thread() {
all(target_os = "linux", target_env = "gnu"),
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "watchos"
))]
#[test]