diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2018-11-08 18:35:59 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2018-11-08 18:35:59 +0100 |
commit | fbe821ebccb61def22cea953f1df83134fa01d0e (patch) | |
tree | 6beb754aa046a8d3a172bc1bf9772ddf58b30f7c | |
parent | a3d6a28be2631cae7f78287b0742bba36338a745 (diff) | |
download | psutil-fbe821ebccb61def22cea953f1df83134fa01d0e.tar.gz |
#1359: add test case for cpu_count(logical=False) against lscpu utility
-rwxr-xr-x | psutil/tests/test_linux.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index 4b72f725..0f981b6b 100755 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -639,6 +639,16 @@ class TestSystemCPU(unittest.TestCase): num = len([x for x in out.split('\n') if not x.startswith('#')]) self.assertEqual(psutil.cpu_count(logical=True), num) + @unittest.skipIf(not which("lscpu"), "lscpu utility not available") + def test_cpu_count_physical_w_lscpu(self): + out = sh("lscpu -p") + core_ids = set() + for line in out.split('\n'): + if not line.startswith('#'): + fields = line.split(',') + core_ids.add(fields[1]) + self.assertEqual(psutil.cpu_count(logical=False), len(core_ids)) + def test_cpu_count_logical_mocked(self): import psutil._pslinux original = psutil._pslinux.cpu_count_logical() |