Skip to content

TestSystemCPUCountLogical fails on sparc64 due to wrong data sources #2683

@glaubitz

Description

@glaubitz

On sparc64, the test TestSystemCPUCountLogical fails with the following error message:

____________ TestSystemCPUCountLogical.test_against_sysdev_cpu_num _____________
psutil/tests/test_linux.py:664: in test_against_sysdev_cpu_num
    assert psutil.cpu_count() == count
E   assert 48 == 64
E    +  where 48 = <function cpu_count at 0xfff80001058cb240>()
E    +    where <function cpu_count at 0xfff80001058cb240> = psutil.cpu_count

psutil/tests/test_linux.py::TestSystemCPUCountLogical::test_against_sysdev_cpu_online PASSED
psutil/tests/test_linux.py::TestSystemCPUCountLogical::test_emulate_fallbacks FAILED

Full build log available at: https://buildd.debian.org/status/fetch.php?pkg=python-psutil&arch=sparc64&ver=7.1.0-1&stamp=1762556398&raw=0

The reason why the assert in this case fails is because the number of CPUs reported as 48 here is the number of online CPUs while the number 64 is the number of configured CPUs. Apparently, the code in psutil does not differentiate both and hence the assert fails.

From the manpage of sysconf():

        - _SC_NPROCESSORS_CONF
              The number of processors configured.  See also get_nprocs_conf(3).

        - _SC_NPROCESSORS_ONLN
              The number of processors currently online (available).  See also get_nprocs_conf(3).

I assume that psutil is somehow querying sysconf() and asking for configured processors (_SC_NPROCESSORS_CONF) when it should be querying for online processors (_SC_NPROCESSORS_ONLN).

Access to a SPARC machine running both Solaris and Linux can be obtained through the GCC Compile Farm: https://gcc.gnu.org/wiki/CompileFarm

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions