about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFolkert <folkert@folkertdev.nl>2024-07-06 14:06:07 +0200
committerFolkert <folkert@folkertdev.nl>2024-07-06 14:07:18 +0200
commitd65e3688df6a282667aed91cea2c7ecfeb636313 (patch)
tree8697ac5bc8209a871f0108883d9d50a3ff1b45ee
parent46019523e8bc5096ae452a39073aed06a6c45e1f (diff)
downloadrust-d65e3688df6a282667aed91cea2c7ecfeb636313.tar.gz
rust-d65e3688df6a282667aed91cea2c7ecfeb636313.zip
`sched_setaffinity`: adjust test on BE systems
-rw-r--r--src/tools/miri/tests/pass-dep/libc/libc-affinity.rs9
1 files 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 ac3001745db..0e482ab2601 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<cpu_set_t>()` will work
-    for i in 1..24 {
+    // on LE systems, any other number of bytes (at least up to `size_of<cpu_set_t>()`) 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::<std::ffi::c_ulong>() };
+
+    for i in cpu_zero_included_length..24 {
         let err = unsafe { sched_setaffinity(PID, i, &cpuset) };
         assert_eq!(err, 0, "fail for {i}");
     }