From: Pádraig Brady Date: Sun, 14 Jun 2026 02:39:37 +0000 (+0900) Subject: tests: nproc: ensure affinity mask is independent of scheduler X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=144287129eb94ff7cf7471152be25bf09a8c1324;p=thirdparty%2Fcoreutils.git tests: nproc: ensure affinity mask is independent of scheduler * tests/nproc/nproc-quota-systemd.sh: Check affinity mask with various schedulers. https://github.com/coreutils/coreutils/pull/291 --- diff --git a/tests/nproc/nproc-quota-systemd.sh b/tests/nproc/nproc-quota-systemd.sh index 7b95dea55..d6782917f 100755 --- a/tests/nproc/nproc-quota-systemd.sh +++ b/tests/nproc/nproc-quota-systemd.sh @@ -28,10 +28,10 @@ test ${all} != 1 || skip_ 'Single CPU detected' check_sched_quota() { cpu=$1; shift - pct=$1; shift + sysd_limit=$1; shift - if systemd-run --scope -q -p CPUQuota=$pct chrt $* true; then - test $(systemd-run --scope -q -p CPUQuota=$pct \ + if systemd-run --scope -q -p $sysd_limit chrt $* true; then + test $(systemd-run --scope -q -p $sysd_limit \ chrt $* \ env OMP_NUM_THREADS=0 \ nproc) = $cpu || @@ -40,19 +40,24 @@ check_sched_quota() return 0 } -check_sched_quota 1 100% --other 0 || fail=1 -check_sched_quota 1 149% --other 0 || fail=1 -check_sched_quota 2 150% --other 0 || fail=1 -check_sched_quota 2 249% --other 0 || fail=1 +check_sched_quota 1 CPUQuota=100% --other 0 || fail=1 +check_sched_quota 1 CPUQuota=149% --other 0 || fail=1 +check_sched_quota 2 CPUQuota=150% --other 0 || fail=1 +check_sched_quota 2 CPUQuota=249% --other 0 || fail=1 -check_sched_quota 1 100% --idle 0 || fail=1 -check_sched_quota 1 100% --batch 0 || fail=1 +check_sched_quota 1 CPUQuota=100% --idle 0 || fail=1 +check_sched_quota 1 CPUQuota=100% --batch 0 || fail=1 # some schedulers should use all threads -check_sched_quota $all 100% --fifo 1 || fail=1 -check_sched_quota $all 100% --rr 1 || fail=1 -check_sched_quota $all 100% --deadline \ +check_sched_quota $all CPUQuota=100% --fifo 1 || fail=1 +check_sched_quota $all CPUQuota=100% --rr 1 || fail=1 +check_sched_quota $all CPUQuota=100% --deadline \ --sched-runtime 100000000 --sched-deadline 1000000000 \ --sched-period 1000000000 0 || fail=1 +# Ensure affinity mask is applied +check_sched_quota 1 AllowedCPUs=0 --other 0 || fail=1 +check_sched_quota 1 AllowedCPUs=0 --fifo 1 || fail=1 +check_sched_quota 1 AllowedCPUs=0 --rr 1 || fail=1 + Exit $fail