From d65e3688df6a282667aed91cea2c7ecfeb636313 Mon Sep 17 00:00:00 2001 From: Folkert Date: Sat, 6 Jul 2024 14:06:07 +0200 Subject: [PATCH] `sched_setaffinity`: adjust test on BE systems --- src/tools/miri/tests/pass-dep/libc/libc-affinity.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tools/miri/tests/pass-dep/libc/libc-affinity.rs b/src/tools/miri/tests/pass-dep/libc/libc-affinity.rs index ac3001745db8..0e482ab26010 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-affinity.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-affinity.rs @@ -116,8 +116,13 @@ fn set_small_cpu_mask() { assert_eq!(err, -1); assert_eq!(std::io::Error::last_os_error().kind(), std::io::ErrorKind::InvalidInput); - // any other number of bytes (at least up to `size_of()` will work - for i in 1..24 { + // on LE systems, any other number of bytes (at least up to `size_of()`) will work. + // on BE systems the CPUs 0..8 are stored in the right-most byte of the first chunk. If that + // byte is not included, no valid CPUs are configured. We skip those cases. + let cpu_zero_included_length = + if cfg!(target_endian = "little") { 1 } else { core::mem::size_of::() }; + + for i in cpu_zero_included_length..24 { let err = unsafe { sched_setaffinity(PID, i, &cpuset) }; assert_eq!(err, 0, "fail for {i}"); }