[Debian unstable] 3 tests failing on several "uncommon" architectures
Summary
- OS: debian unstable
- Architecture: several, see below
- Psutil version: 7.0.0
- Python version: 3.13
- Type: tests
Description
In debian we try to support several architectures, some less common than others; on several of them, 3 tests fail (the full logs link and failure snippets are listed below).
During package build, we run tests, and since they fail the build is considered failed, and that in turns prevent to upgrade psutil to staging area we will be cutting our upcoming stable release.
- arch=armel, full log
=================================== FAILURES ===================================
_______________ TestSystemCPUFrequency.test_emulate_use_cpuinfo ________________
self = <psutil.tests.test_linux.TestSystemCPUFrequency testMethod=test_emulate_use_cpuinfo>
@pytest.mark.skipif(not HAS_CPU_FREQ, reason="not supported")
@pytest.mark.skipif(
AARCH64, reason="aarch64 does not report mhz in /proc/cpuinfo"
)
def test_emulate_use_cpuinfo(self):
# Emulate a case where /sys/devices/system/cpu/cpufreq* does not
# exist and /proc/cpuinfo is used instead.
def path_exists_mock(path):
if path.startswith('/sys/devices/system/cpu/'):
return False
else:
return os_path_exists(path)
os_path_exists = os.path.exists
try:
with mock.patch("os.path.exists", side_effect=path_exists_mock):
reload_module(psutil._pslinux)
ret = psutil.cpu_freq()
> assert ret, ret
E AssertionError: None
E assert None
psutil/tests/test_linux.py:795: AssertionError
_____________ TestSystemCPUFrequency.test_emulate_use_second_file ______________
self = <psutil.tests.test_linux.TestSystemCPUFrequency testMethod=test_emulate_use_second_file>
@pytest.mark.skipif(not HAS_CPU_FREQ, reason="not supported")
@pytest.mark.skipif(
AARCH64, reason="aarch64 does not always expose frequency"
)
def test_emulate_use_second_file(self):
# https://github.com/giampaolo/psutil/issues/981
def path_exists_mock(path):
if path.startswith("/sys/devices/system/cpu/cpufreq/policy"):
return False
else:
return orig_exists(path)
orig_exists = os.path.exists
with mock.patch(
"os.path.exists", side_effect=path_exists_mock, create=True
):
> assert psutil.cpu_freq()
E assert None
E + where None = <function cpu_freq at 0xf625ab18>()
E + where <function cpu_freq at 0xf625ab18> = psutil.cpu_freq
psutil/tests/test_linux.py:775: AssertionError
__________________________ TestCpuAPIs.test_cpu_freq ___________________________
self = <psutil.tests.test_system.TestCpuAPIs testMethod=test_cpu_freq>
@pytest.mark.skipif(
MACOS and platform.machine() == 'arm64', reason="skipped due to #1892"
)
@pytest.mark.skipif(not HAS_CPU_FREQ, reason="not supported")
def test_cpu_freq(self):
def check_ls(ls):
for nt in ls:
assert nt._fields == ('current', 'min', 'max')
if nt.max != 0.0:
assert nt.current <= nt.max
for name in nt._fields:
value = getattr(nt, name)
assert isinstance(value, (int, float))
assert value >= 0
ls = psutil.cpu_freq(percpu=True)
if (FREEBSD or AARCH64) and not ls:
raise pytest.skip(
"returns empty list on FreeBSD and Linux aarch64"
)
> assert ls, ls
E AssertionError: []
E assert []
psutil/tests/test_system.py:606: AssertionError
=========================== short test summary info ============================
FAILED psutil/tests/test_linux.py::TestSystemCPUFrequency::test_emulate_use_cpuinfo
FAILED psutil/tests/test_linux.py::TestSystemCPUFrequency::test_emulate_use_second_file
FAILED psutil/tests/test_system.py::TestCpuAPIs::test_cpu_freq - AssertionErr...
========== 3 failed, 495 passed, 167 skipped, 18 deselected in 9.96s ===========
- arch=armhf, full log
=================================== FAILURES ===================================
_______________ TestSystemCPUFrequency.test_emulate_use_cpuinfo ________________
self = <psutil.tests.test_linux.TestSystemCPUFrequency testMethod=test_emulate_use_cpuinfo>
@pytest.mark.skipif(not HAS_CPU_FREQ, reason="not supported")
@pytest.mark.skipif(
AARCH64, reason="aarch64 does not report mhz in /proc/cpuinfo"
)
def test_emulate_use_cpuinfo(self):
# Emulate a case where /sys/devices/system/cpu/cpufreq* does not
# exist and /proc/cpuinfo is used instead.
def path_exists_mock(path):
if path.startswith('/sys/devices/system/cpu/'):
return False
else:
return os_path_exists(path)
os_path_exists = os.path.exists
try:
with mock.patch("os.path.exists", side_effect=path_exists_mock):
reload_module(psutil._pslinux)
ret = psutil.cpu_freq()
> assert ret, ret
E AssertionError: None
E assert None
psutil/tests/test_linux.py:795: AssertionError
_____________ TestSystemCPUFrequency.test_emulate_use_second_file ______________
self = <psutil.tests.test_linux.TestSystemCPUFrequency testMethod=test_emulate_use_second_file>
@pytest.mark.skipif(not HAS_CPU_FREQ, reason="not supported")
@pytest.mark.skipif(
AARCH64, reason="aarch64 does not always expose frequency"
)
def test_emulate_use_second_file(self):
# https://github.com/giampaolo/psutil/issues/981
def path_exists_mock(path):
if path.startswith("/sys/devices/system/cpu/cpufreq/policy"):
return False
else:
return orig_exists(path)
orig_exists = os.path.exists
with mock.patch(
"os.path.exists", side_effect=path_exists_mock, create=True
):
> assert psutil.cpu_freq()
E assert None
E + where None = <function cpu_freq at 0xf67f7b68>()
E + where <function cpu_freq at 0xf67f7b68> = psutil.cpu_freq
psutil/tests/test_linux.py:775: AssertionError
__________________________ TestCpuAPIs.test_cpu_freq ___________________________
self = <psutil.tests.test_system.TestCpuAPIs testMethod=test_cpu_freq>
@pytest.mark.skipif(
MACOS and platform.machine() == 'arm64', reason="skipped due to #1892"
)
@pytest.mark.skipif(not HAS_CPU_FREQ, reason="not supported")
def test_cpu_freq(self):
def check_ls(ls):
for nt in ls:
assert nt._fields == ('current', 'min', 'max')
if nt.max != 0.0:
assert nt.current <= nt.max
for name in nt._fields:
value = getattr(nt, name)
assert isinstance(value, (int, float))
assert value >= 0
ls = psutil.cpu_freq(percpu=True)
if (FREEBSD or AARCH64) and not ls:
raise pytest.skip(
"returns empty list on FreeBSD and Linux aarch64"
)
> assert ls, ls
E AssertionError: []
E assert []
psutil/tests/test_system.py:606: AssertionError
=========================== short test summary info ============================
FAILED psutil/tests/test_linux.py::TestSystemCPUFrequency::test_emulate_use_cpuinfo
FAILED psutil/tests/test_linux.py::TestSystemCPUFrequency::test_emulate_use_second_file
FAILED psutil/tests/test_system.py::TestCpuAPIs::test_cpu_freq - AssertionErr...
========== 3 failed, 495 passed, 167 skipped, 18 deselected in 9.43s ===========
- arch=mips64el, full log
=================================== FAILURES ===================================
_______________ TestSystemCPUFrequency.test_emulate_use_cpuinfo ________________
self = <psutil.tests.test_linux.TestSystemCPUFrequency testMethod=test_emulate_use_cpuinfo>
@pytest.mark.skipif(not HAS_CPU_FREQ, reason="not supported")
@pytest.mark.skipif(
AARCH64, reason="aarch64 does not report mhz in /proc/cpuinfo"
)
def test_emulate_use_cpuinfo(self):
# Emulate a case where /sys/devices/system/cpu/cpufreq* does not
# exist and /proc/cpuinfo is used instead.
def path_exists_mock(path):
if path.startswith('/sys/devices/system/cpu/'):
return False
else:
return os_path_exists(path)
os_path_exists = os.path.exists
try:
with mock.patch("os.path.exists", side_effect=path_exists_mock):
reload_module(psutil._pslinux)
ret = psutil.cpu_freq()
> assert ret, ret
E AssertionError: None
E assert None
psutil/tests/test_linux.py:795: AssertionError
_____________ TestSystemCPUFrequency.test_emulate_use_second_file ______________
self = <psutil.tests.test_linux.TestSystemCPUFrequency testMethod=test_emulate_use_second_file>
@pytest.mark.skipif(not HAS_CPU_FREQ, reason="not supported")
@pytest.mark.skipif(
AARCH64, reason="aarch64 does not always expose frequency"
)
def test_emulate_use_second_file(self):
# https://github.com/giampaolo/psutil/issues/981
def path_exists_mock(path):
if path.startswith("/sys/devices/system/cpu/cpufreq/policy"):
return False
else:
return orig_exists(path)
orig_exists = os.path.exists
with mock.patch(
"os.path.exists", side_effect=path_exists_mock, create=True
):
> assert psutil.cpu_freq()
E assert None
E + where None = <function cpu_freq at 0xffee9631a0>()
E + where <function cpu_freq at 0xffee9631a0> = psutil.cpu_freq
psutil/tests/test_linux.py:775: AssertionError
__________________________ TestCpuAPIs.test_cpu_freq ___________________________
self = <psutil.tests.test_system.TestCpuAPIs testMethod=test_cpu_freq>
@pytest.mark.skipif(
MACOS and platform.machine() == 'arm64', reason="skipped due to #1892"
)
@pytest.mark.skipif(not HAS_CPU_FREQ, reason="not supported")
def test_cpu_freq(self):
def check_ls(ls):
for nt in ls:
assert nt._fields == ('current', 'min', 'max')
if nt.max != 0.0:
assert nt.current <= nt.max
for name in nt._fields:
value = getattr(nt, name)
assert isinstance(value, (int, float))
assert value >= 0
ls = psutil.cpu_freq(percpu=True)
if (FREEBSD or AARCH64) and not ls:
raise pytest.skip(
"returns empty list on FreeBSD and Linux aarch64"
)
> assert ls, ls
E AssertionError: []
E assert []
psutil/tests/test_system.py:606: AssertionError
=========================== short test summary info ============================
FAILED psutil/tests/test_linux.py::TestSystemCPUFrequency::test_emulate_use_cpuinfo
FAILED psutil/tests/test_linux.py::TestSystemCPUFrequency::test_emulate_use_second_file
FAILED psutil/tests/test_system.py::TestCpuAPIs::test_cpu_freq - AssertionErr...
========== 3 failed, 496 passed, 166 skipped, 18 deselected in 15.34s ==========
- arch=ppc64el, full log
=================================== FAILURES ===================================
_______________ TestSystemCPUFrequency.test_emulate_use_cpuinfo ________________
self = <psutil.tests.test_linux.TestSystemCPUFrequency testMethod=test_emulate_use_cpuinfo>
@pytest.mark.skipif(not HAS_CPU_FREQ, reason="not supported")
@pytest.mark.skipif(
AARCH64, reason="aarch64 does not report mhz in /proc/cpuinfo"
)
def test_emulate_use_cpuinfo(self):
# Emulate a case where /sys/devices/system/cpu/cpufreq* does not
# exist and /proc/cpuinfo is used instead.
def path_exists_mock(path):
if path.startswith('/sys/devices/system/cpu/'):
return False
else:
return os_path_exists(path)
os_path_exists = os.path.exists
try:
with mock.patch("os.path.exists", side_effect=path_exists_mock):
reload_module(psutil._pslinux)
ret = psutil.cpu_freq()
> assert ret, ret
E AssertionError: None
E assert None
psutil/tests/test_linux.py:795: AssertionError
_____________ TestSystemCPUFrequency.test_emulate_use_second_file ______________
self = <psutil.tests.test_linux.TestSystemCPUFrequency testMethod=test_emulate_use_second_file>
@pytest.mark.skipif(not HAS_CPU_FREQ, reason="not supported")
@pytest.mark.skipif(
AARCH64, reason="aarch64 does not always expose frequency"
)
def test_emulate_use_second_file(self):
# https://github.com/giampaolo/psutil/issues/981
def path_exists_mock(path):
if path.startswith("/sys/devices/system/cpu/cpufreq/policy"):
return False
else:
return orig_exists(path)
orig_exists = os.path.exists
with mock.patch(
"os.path.exists", side_effect=path_exists_mock, create=True
):
> assert psutil.cpu_freq()
E assert None
E + where None = <function cpu_freq at 0x7fffaa84f1a0>()
E + where <function cpu_freq at 0x7fffaa84f1a0> = psutil.cpu_freq
psutil/tests/test_linux.py:775: AssertionError
__________________________ TestCpuAPIs.test_cpu_freq ___________________________
self = <psutil.tests.test_system.TestCpuAPIs testMethod=test_cpu_freq>
@pytest.mark.skipif(
MACOS and platform.machine() == 'arm64', reason="skipped due to #1892"
)
@pytest.mark.skipif(not HAS_CPU_FREQ, reason="not supported")
def test_cpu_freq(self):
def check_ls(ls):
for nt in ls:
assert nt._fields == ('current', 'min', 'max')
if nt.max != 0.0:
assert nt.current <= nt.max
for name in nt._fields:
value = getattr(nt, name)
assert isinstance(value, (int, float))
assert value >= 0
ls = psutil.cpu_freq(percpu=True)
if (FREEBSD or AARCH64) and not ls:
raise pytest.skip(
"returns empty list on FreeBSD and Linux aarch64"
)
> assert ls, ls
E AssertionError: []
E assert []
psutil/tests/test_system.py:606: AssertionError
=========================== short test summary info ============================
FAILED psutil/tests/test_linux.py::TestSystemCPUFrequency::test_emulate_use_cpuinfo
FAILED psutil/tests/test_linux.py::TestSystemCPUFrequency::test_emulate_use_second_file
FAILED psutil/tests/test_system.py::TestCpuAPIs::test_cpu_freq - AssertionErr...
========== 3 failed, 495 passed, 167 skipped, 18 deselected in 8.32s ===========
- arch=riscv64, full log
=================================== FAILURES ===================================
_______________ TestSystemCPUFrequency.test_emulate_use_cpuinfo ________________
self = <psutil.tests.test_linux.TestSystemCPUFrequency testMethod=test_emulate_use_cpuinfo>
@pytest.mark.skipif(not HAS_CPU_FREQ, reason="not supported")
@pytest.mark.skipif(
AARCH64, reason="aarch64 does not report mhz in /proc/cpuinfo"
)
def test_emulate_use_cpuinfo(self):
# Emulate a case where /sys/devices/system/cpu/cpufreq* does not
# exist and /proc/cpuinfo is used instead.
def path_exists_mock(path):
if path.startswith('/sys/devices/system/cpu/'):
return False
else:
return os_path_exists(path)
os_path_exists = os.path.exists
try:
with mock.patch("os.path.exists", side_effect=path_exists_mock):
reload_module(psutil._pslinux)
ret = psutil.cpu_freq()
> assert ret, ret
E AssertionError: None
E assert None
psutil/tests/test_linux.py:795: AssertionError
_____________ TestSystemCPUFrequency.test_emulate_use_second_file ______________
self = <psutil.tests.test_linux.TestSystemCPUFrequency testMethod=test_emulate_use_second_file>
@pytest.mark.skipif(not HAS_CPU_FREQ, reason="not supported")
@pytest.mark.skipif(
AARCH64, reason="aarch64 does not always expose frequency"
)
def test_emulate_use_second_file(self):
# https://github.com/giampaolo/psutil/issues/981
def path_exists_mock(path):
if path.startswith("/sys/devices/system/cpu/cpufreq/policy"):
return False
else:
return orig_exists(path)
orig_exists = os.path.exists
with mock.patch(
"os.path.exists", side_effect=path_exists_mock, create=True
):
> assert psutil.cpu_freq()
E assert None
E + where None = <function cpu_freq at 0x3fb9f5b1a0>()
E + where <function cpu_freq at 0x3fb9f5b1a0> = psutil.cpu_freq
psutil/tests/test_linux.py:775: AssertionError
__________________________ TestCpuAPIs.test_cpu_freq ___________________________
self = <psutil.tests.test_system.TestCpuAPIs testMethod=test_cpu_freq>
@pytest.mark.skipif(
MACOS and platform.machine() == 'arm64', reason="skipped due to #1892"
)
@pytest.mark.skipif(not HAS_CPU_FREQ, reason="not supported")
def test_cpu_freq(self):
def check_ls(ls):
for nt in ls:
assert nt._fields == ('current', 'min', 'max')
if nt.max != 0.0:
assert nt.current <= nt.max
for name in nt._fields:
value = getattr(nt, name)
assert isinstance(value, (int, float))
assert value >= 0
ls = psutil.cpu_freq(percpu=True)
if (FREEBSD or AARCH64) and not ls:
raise pytest.skip(
"returns empty list on FreeBSD and Linux aarch64"
)
> assert ls, ls
E AssertionError: []
E assert []
psutil/tests/test_system.py:606: AssertionError
=========================== short test summary info ============================
FAILED psutil/tests/test_linux.py::TestSystemCPUFrequency::test_emulate_use_cpuinfo
FAILED psutil/tests/test_linux.py::TestSystemCPUFrequency::test_emulate_use_second_file
FAILED psutil/tests/test_system.py::TestCpuAPIs::test_cpu_freq - AssertionErr...
===== 3 failed, 496 passed, 166 skipped, 18 deselected in 68.18s (0:01:08) =====
- arch=s390x, full log
=================================== FAILURES ===================================
_________________ TestSystemCPUCountLogical.test_against_nproc _________________
self = <psutil.tests.test_linux.TestSystemCPUCountLogical testMethod=test_against_nproc>
@pytest.mark.skipif(
not shutil.which("nproc"), reason="nproc utility not available"
)
def test_against_nproc(self):
num = int(sh("nproc --all"))
> assert psutil.cpu_count(logical=True) == num
E assert 2 == 64
E + where 2 = <function cpu_count at 0x3ffbc366ac0>(logical=True)
E + where <function cpu_count at 0x3ffbc366ac0> = psutil.cpu_count
psutil/tests/test_linux.py:677: AssertionError
__________________ TestProcessAgainstStatus.test_cpu_affinity __________________
self = <psutil.tests.test_linux.TestProcessAgainstStatus testMethod=test_cpu_affinity>
def test_cpu_affinity(self):
value = self.read_status_file("Cpus_allowed_list:")
if '-' in str(value):
min_, max_ = map(int, value.split('-'))
> assert self.proc.cpu_affinity() == list(range(min_, max_ + 1))
E AssertionError: assert [0, 1] == [0, 1, 2, 3, 4, 5, ...]
E
E Right contains 62 more items, first extra item: 2
E
E Full diff:
E [
E 0,
E 1,...
E
E ...Full output truncated (63 lines hidden), use '-vv' to show
psutil/tests/test_linux.py:2270: AssertionError
__________________________ TestCpuAPIs.test_cpu_freq ___________________________
self = <psutil.tests.test_system.TestCpuAPIs testMethod=test_cpu_freq>
@pytest.mark.skipif(
MACOS and platform.machine() == 'arm64', reason="skipped due to #1892"
)
@pytest.mark.skipif(not HAS_CPU_FREQ, reason="not supported")
def test_cpu_freq(self):
def check_ls(ls):
for nt in ls:
assert nt._fields == ('current', 'min', 'max')
if nt.max != 0.0:
assert nt.current <= nt.max
for name in nt._fields:
value = getattr(nt, name)
assert isinstance(value, (int, float))
assert value >= 0
ls = psutil.cpu_freq(percpu=True)
if (FREEBSD or AARCH64) and not ls:
raise pytest.skip(
"returns empty list on FreeBSD and Linux aarch64"
)
assert ls, ls
check_ls([psutil.cpu_freq(percpu=False)])
if LINUX:
> assert len(ls) == psutil.cpu_count()
E assert 4 == 2
E + where 4 = len([scpufreq(current=5200.0, min=0.0, max=0.0), scpufreq(current=5200.0, min=0.0, max=0.0), scpufreq(current=5200.0, min=0.0, max=0.0), scpufreq(current=5200.0, min=0.0, max=0.0)])
E + and 2 = <function cpu_count at 0x3ffbc3668e0>()
E + where <function cpu_count at 0x3ffbc3668e0> = psutil.cpu_count
psutil/tests/test_system.py:610: AssertionError
=========================== short test summary info ============================
FAILED psutil/tests/test_linux.py::TestSystemCPUCountLogical::test_against_nproc
FAILED psutil/tests/test_linux.py::TestProcessAgainstStatus::test_cpu_affinity
FAILED psutil/tests/test_system.py::TestCpuAPIs::test_cpu_freq - assert 4 == 2
========== 3 failed, 497 passed, 165 skipped, 18 deselected in 6.21s ===========
Hi @sandrotosi and @giampaolo
I just notice also 3 errors when trying to build and test psutil 7.0.0 on riscv64. But funnily I don't have exactly the same error as @sandrotosi :
=================================== FAILURES ===================================
________________ TestSystemCPUFrequency.test_emulate_multi_cpu _________________
/tmp/tmp.QdG0UwYZMg/venv/lib/python3.10/site-packages/psutil/tests/test_linux.py:882: in test_emulate_multi_cpu
assert freq[1].current == 400.0
E IndexError: list index out of range
_______________ TestSystemCPUFrequency.test_emulate_use_cpuinfo ________________
/tmp/tmp.QdG0UwYZMg/venv/lib/python3.10/site-packages/psutil/tests/test_linux.py:795: in test_emulate_use_cpuinfo
assert ret, ret
E AssertionError: None
E assert None
__________________________ TestCpuAPIs.test_cpu_freq ___________________________
/tmp/tmp.QdG0UwYZMg/venv/lib/python3.10/site-packages/psutil/tests/test_system.py:610: in test_cpu_freq
assert len(ls) == psutil.cpu_count()
E assert 1 == 4
E + where 1 = len([scpufreq(current=1848.0, min=300.0, max=1848.0)])
E + and 4 = <function cpu_count at 0x3fe6a9e7a0>()
E + where <function cpu_count at 0x3fe6a9e7a0> = psutil.cpu_count
The test_emulate_use_cpuinfo looks the same as @sandrotosi and seems to be that /proc/cpunfo does not report mhz.
I send a fix for that https://github.com/giampaolo/psutil/pull/2561. It's only for riscv64, maybe @sandrotosi can confirm that it's the same issue for the other architecture and I can add them into the patch?
The test_cpu_freq also fails but with a different error compared to @sandrotosi . Didn't investigate this one yet.
On my end, test_emulate_use_second_file PASS but test_emulate_multi_cpu fails (didn't investigate yet).
Here is the full log
@giampaolo I am not sure we should close this issue (I guess it was automatically closed when merging https://github.com/giampaolo/psutil/pull/2561).
The fix I made in https://github.com/giampaolo/psutil/pull/2561 was only for riscv64 and only for one of the tests (test_emulate_use_cpuinfo). I think we can apply the same kind of patch for other architecture for this specific test if @sandrotosi confirm they are all failing for the same reason.
Anyway, we should still fix the other tests. I don't have rights to reopen this bug. can you do it @giampaolo ?
Sure thing.
I opened a PR for test_cpu_freq (see https://github.com/giampaolo/psutil/pull/2562)
About test_emulate_multi_cpu I investigated and here is my findings:
- even with fix https://github.com/giampaolo/psutil/pull/2562 it's broken on my system. The new error is now:
________________ TestSystemCPUFrequency.test_emulate_multi_cpu _________________
/tmp/tmp.focd9ggkTH/venv/lib/python3.10/site-packages/psutil/tests/test_linux.py:885: in test_emulate_multi_cpu
assert freq[1].min == 500.0
E assert 200.0 == 500.0
E + where 200.0 = scpufreq(current=400.0, min=200.0, max=300.0).min
=============================== warnings summary ===============================
because /sys/devices/system/cpu/cpufreq/policy1 does not exist on the system, so we will never return different value for the second cpu
- I am even wondering if this test can work on a single core cpu?
I think this test should be mocked in a different way.
what do you think @giampaolo ? If you have some idea, I can try to modify the test
Hi @giampaolo any thoughts about this issue? I can help debug it further if needed
The cpu_count() problem occurs on sparc64 as well. The underlying problem is that psutil apparently doesn't understand the different between available CPUs and online CPUs which is not the same. I'll file a separate bug report for that.