aboutsummaryrefslogtreecommitdiff
path: root/test/test_sched.rs
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_sched.rs')
-rw-r--r--test/test_sched.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/test/test_sched.rs b/test/test_sched.rs
index 922196a..c52616b 100644
--- a/test/test_sched.rs
+++ b/test/test_sched.rs
@@ -1,4 +1,4 @@
-use nix::sched::{sched_getaffinity, sched_setaffinity, CpuSet};
+use nix::sched::{sched_getaffinity, sched_getcpu, sched_setaffinity, CpuSet};
use nix::unistd::Pid;
#[test]
@@ -24,9 +24,16 @@ fn test_sched_affinity() {
let updated_affinity = sched_getaffinity(Pid::from_raw(0)).unwrap();
for field in 0..CpuSet::count() {
// Should be set only for the CPU we set previously
- assert_eq!(updated_affinity.is_set(field).unwrap(), field==last_valid_cpu)
+ assert_eq!(
+ updated_affinity.is_set(field).unwrap(),
+ field == last_valid_cpu
+ )
}
+ // Now check that we're also currently running on the CPU in question.
+ let cur_cpu = sched_getcpu().unwrap();
+ assert_eq!(cur_cpu, last_valid_cpu);
+
// Finally, reset the initial CPU set
sched_setaffinity(Pid::from_raw(0), &initial_affinity).unwrap();
}