TestCpusetManagerHousekeepingPartitions hardcodes CPUs 0-3 and asserts that the
housekeeping/measurement cpusets become partition=isolated. Some systems hold
CPUs out of the root cgroup's cpuset.cpus.effective -- via isolcpus=, or a
systemd/tuned cpu-partitioning setup (e.g. Fedora CSB reserves CPUs 0-5 with no
isolcpus= boot parameter). Such CPUs cannot form an isolated partition, so the
kernel reports:
isolated invalid (Invalid cpu list in cpuset.cpus.exclusive)
and test_housekeeping_isolated_flag and test_measurement_always_isolated fail
under sudo make test-all. The product code is correct: an isolated partition
built from CPUs that are in cpuset.cpus.effective works.
Skip the two affected tests when the CPUs they use are not in
cpuset.cpus.effective, so the suite is green on such systems while still running
normally elsewhere. A follow-up should pick usable CPUs from
cpuset.cpus.effective instead of hardcoding them.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: John Kacur <jkacur@redhat.com>
---
tests/test_cpusetmanager.py | 39 +++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/tests/test_cpusetmanager.py b/tests/test_cpusetmanager.py
index 3da042dbeaad..50ec478a7427 100644
--- a/tests/test_cpusetmanager.py
+++ b/tests/test_cpusetmanager.py
@@ -23,6 +23,43 @@ from rteval import cpuset
from rteval.Log import Log
+def _expand_cpulist(s):
+ """Expand a cpuset list string like '0-5,8' into a set of ints."""
+ cpus = set()
+ for part in s.split(','):
+ part = part.strip()
+ if not part:
+ continue
+ if '-' in part:
+ start, end = part.split('-')
+ cpus.update(range(int(start), int(end) + 1))
+ else:
+ cpus.add(int(part))
+ return cpus
+
+
+def _skip_if_isolated(test, cpus):
+ """Skip test if any of cpus are not usable by cgroup cpusets.
+
+ Some systems hold CPUs out of the root cgroup's cpuset.cpus.effective
+ (via isolcpus=, or a systemd/tuned cpu-partitioning setup -- e.g. Fedora
+ CSB reserves 0-5 with no isolcpus= boot parameter). Such CPUs cannot form
+ an isolated partition, so a test that hardcodes them would spuriously
+ fail. A later change should pick usable CPUs from cpuset.cpus.effective
+ instead of hardcoding them.
+ """
+ try:
+ with open('/sys/fs/cgroup/cpuset.cpus.effective') as f:
+ usable = _expand_cpulist(f.read().strip())
+ except OSError:
+ return
+ missing = sorted(set(cpus) - usable)
+ if missing:
+ test.skipTest(f"CPUs {missing} are not in cpuset.cpus.effective "
+ "(reserved outside the root cgroup); cannot form an "
+ "isolated partition")
+
+
class TestCpusetManagerBasic(unittest.TestCase):
"""Test basic CpusetManager functionality (non-root tests)"""
@@ -74,6 +111,7 @@ class TestCpusetManagerHousekeepingPartitions(unittest.TestCase):
def test_housekeeping_isolated_flag(self):
"""Test that housekeeping_isolated=True makes partition=isolated"""
+ _skip_if_isolated(self, [0, 1, 2, 3])
with CpusetManager(
housekeeping_cpus=[0, 1],
measurement_cpus=[2, 3],@@ -89,6 +127,7 @@ class TestCpusetManagerHousekeepingPartitions(unittest.TestCase):
def test_measurement_always_isolated(self):
"""Test that measurement cpuset is always partition=isolated"""
+ _skip_if_isolated(self, [0, 1, 2, 3])
# Test with housekeeping_isolated=False
with CpusetManager(
housekeeping_cpus=[0, 1],--
2.56.1