Skip to content

Commit

Permalink
#1359: add test case for cpu_count(logical=False) against lscpu utility
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Nov 8, 2018
1 parent a3d6a28 commit fbe821e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions psutil/tests/test_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,16 @@ def test_cpu_count_logical_w_lscpu(self):
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()
Expand Down

0 comments on commit fbe821e

Please sign in to comment.