Skip to content

Commit d65e368

Browse files
committed
sched_setaffinity: adjust test on BE systems
1 parent 4601952 commit d65e368

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/tools/miri/tests/pass-dep/libc/libc-affinity.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,13 @@ fn set_small_cpu_mask() {
116116
assert_eq!(err, -1);
117117
assert_eq!(std::io::Error::last_os_error().kind(), std::io::ErrorKind::InvalidInput);
118118

119-
// any other number of bytes (at least up to `size_of<cpu_set_t>()` will work
120-
for i in 1..24 {
119+
// on LE systems, any other number of bytes (at least up to `size_of<cpu_set_t>()`) will work.
120+
// on BE systems the CPUs 0..8 are stored in the right-most byte of the first chunk. If that
121+
// byte is not included, no valid CPUs are configured. We skip those cases.
122+
let cpu_zero_included_length =
123+
if cfg!(target_endian = "little") { 1 } else { core::mem::size_of::<std::ffi::c_ulong>() };
124+
125+
for i in cpu_zero_included_length..24 {
121126
let err = unsafe { sched_setaffinity(PID, i, &cpuset) };
122127
assert_eq!(err, 0, "fail for {i}");
123128
}

0 commit comments

Comments
 (0)