summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2018-11-08 18:35:59 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2018-11-08 18:35:59 +0100
commitfbe821ebccb61def22cea953f1df83134fa01d0e (patch)
tree6beb754aa046a8d3a172bc1bf9772ddf58b30f7c
parenta3d6a28be2631cae7f78287b0742bba36338a745 (diff)
downloadpsutil-fbe821ebccb61def22cea953f1df83134fa01d0e.tar.gz
#1359: add test case for cpu_count(logical=False) against lscpu utility
-rwxr-xr-xpsutil/tests/test_linux.py10
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()