Skip to content

Commit 365a8d0

Browse files
committed
Fix iOS, tvOS, watchOS and visionOS tests
1 parent 6bba24e commit 365a8d0

3 files changed

Lines changed: 53 additions & 16 deletions

File tree

ci/run.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ case "$target" in
2626
# FIXME(android): unit tests fail to start on Android
2727
*android*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;;
2828
*s390x*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;;
29+
# ctest's own tests don't work on Apple devices, since these don't have
30+
# host tooling such as `rustc` or a C compiler.
31+
*ios*|*tvos*|*watchos*|*visionos*) cmd="$cmd --workspace --exclude ctest" ;;
2932
# For all other platforms, test everything in the workspace
3033
*) cmd="$cmd --workspace" ;;
3134
esac

libc-test/build.rs

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ fn test_apple(target: &str) {
209209
assert!(target.contains("apple"));
210210
let x86_64 = target.contains("x86_64");
211211
let i686 = target.contains("i686");
212+
let macos = target.contains("darwin") || target.contains("macos");
213+
let tvos = target.contains("tvos");
214+
let watchos = target.contains("watchos");
212215

213216
let mut cfg = ctest_cfg();
214217

@@ -236,27 +239,29 @@ fn test_apple(target: &str) {
236239
"ifaddrs.h",
237240
"langinfo.h",
238241
"libgen.h",
239-
"libproc.h",
242+
(macos, "libproc.h"),
240243
"limits.h",
241244
"locale.h",
245+
"mach/mach.h",
242246
"malloc/malloc.h",
243-
"net/bpf.h",
244-
"net/dlil.h",
247+
(macos, "net/bpf.h"),
248+
(macos, "net/dlil.h"),
245249
"net/if.h",
246-
"net/if_arp.h",
250+
(macos, "net/if_arp.h"),
247251
"net/if_dl.h",
248-
"net/if_mib.h",
249-
"net/if_utun.h",
252+
(macos, "net/if_mib.h"),
253+
(macos, "net/if_utun.h"),
250254
"net/if_var.h",
251-
"net/ndrv.h",
252-
"net/route.h",
255+
(macos, "net/ndrv.h"),
256+
(macos, "net/route.h"),
253257
"netdb.h",
254-
"netinet/if_ether.h",
258+
(macos, "netinet/if_ether.h"),
255259
"netinet/in.h",
256260
"netinet/ip.h",
257261
"netinet/tcp.h",
258262
"netinet/udp.h",
259-
"netinet6/in6_var.h",
263+
"netinet6/scope6_var.h",
264+
(macos, "netinet6/in6_var.h"),
260265
"os/clock.h",
261266
"os/lock.h",
262267
"os/signpost.h",
@@ -287,20 +292,20 @@ fn test_apple(target: &str) {
287292
"sys/file.h",
288293
"sys/ioctl.h",
289294
"sys/ipc.h",
290-
"sys/kern_control.h",
295+
(macos, "sys/kern_control.h"),
291296
"sys/mman.h",
292297
"sys/mount.h",
293-
"sys/proc_info.h",
294-
"sys/ptrace.h",
298+
(macos, "sys/proc_info.h"),
299+
(macos, "sys/ptrace.h"),
295300
"sys/quota.h",
296-
"sys/random.h",
301+
(macos, "sys/random.h"),
297302
"sys/resource.h",
298303
"sys/sem.h",
299304
"sys/shm.h",
300305
"sys/socket.h",
301306
"sys/stat.h",
302307
"sys/statvfs.h",
303-
"sys/sys_domain.h",
308+
(macos, "sys/sys_domain.h"),
304309
"sys/sysctl.h",
305310
"sys/time.h",
306311
"sys/times.h",
@@ -321,7 +326,7 @@ fn test_apple(target: &str) {
321326
"utmpx.h",
322327
"wchar.h",
323328
"xlocale.h",
324-
(x86_64, "crt_externs.h"),
329+
"crt_externs.h",
325330
);
326331

327332
cfg.skip_struct(move |s| {
@@ -377,6 +382,26 @@ fn test_apple(target: &str) {
377382
"close" if x86_64 => true,
378383
// FIXME(1.0): std removed libresolv support: https://github.com/rust-lang/rust/pull/102766
379384
"res_init" => true,
385+
// Marked available everywhere, but the `sys/random.h` header only
386+
// exists on the macOS SDK.
387+
// FIXME(madsmtm): Filed as FB23000895.
388+
"getentropy" => !macos,
389+
// Prohibited on iOS, tvOS, watchOS and visionOS.
390+
// FIXME(madsmtm): Perhaps we should just not expose this symbol?
391+
"system" => !macos,
392+
// Marked unavailable on iOS, tvOS, watchOS and visionOS.
393+
// FIXME(madsmtm): Perhaps we should just not expose these symbols?
394+
"pthread_jit_write_protect_np"
395+
| "pthread_jit_write_protect_supported_np"
396+
| "pthread_jit_write_with_callback_np"
397+
| "pthread_jit_write_freeze_callbacks_np"
398+
| "gethostuuid" => !macos,
399+
// Marked as unavailable on tvOS and watchOS.
400+
// FIXME(madsmtm): Perhaps we should just not expose this symbol?
401+
"execl" | "execle" | "execlp" | "execv" | "execve" | "execvp" | "execvP" | "fork"
402+
| "sigaltstack" | "syscall" | "daemon" | "brk" | "sbrk" | "task_set_info"
403+
| "exchangedata" => tvos || watchos,
404+
ident if ident.starts_with("posix_spawn") => tvos || watchos,
380405
_ => false,
381406
}
382407
});

libc-test/tests/style.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ const SKIP_PREFIXES: &[&str] = &[
2929
];
3030

3131
#[test]
32+
#[cfg_attr(
33+
any(
34+
target_os = "ios",
35+
target_os = "tvos",
36+
target_os = "watchos",
37+
target_os = "visionos",
38+
),
39+
ignore = "source code is not available for cross-compiled tests"
40+
)]
3241
fn check_style() {
3342
let src_root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../src");
3443
walk(&src_root).unwrap();

0 commit comments

Comments
 (0)