summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2016-09-10 18:37:12 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2016-09-10 18:37:12 +0200
commite313a8271e1c4e3011168d5a63ded696a291281f (patch)
treebd127d77908c53107e0fb8402fd7687ba5e3b423
parent7c237754753a63f7e167698937049d7f9dd6add7 (diff)
downloadpsutil-e313a8271e1c4e3011168d5a63ded696a291281f.tar.gz
add more linux tests
-rw-r--r--psutil/tests/test_linux.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py
index a4abd685..f39b088d 100644
--- a/psutil/tests/test_linux.py
+++ b/psutil/tests/test_linux.py
@@ -120,6 +120,15 @@ def free_physmem():
"can't find 'Mem' in 'free' output:\n%s" % '\n'.join(lines))
+def vmstat(stat):
+ out = sh("vmstat -s")
+ for line in out.split("\n"):
+ line = line.strip()
+ if stat in line:
+ return int(line.split(' ')[0])
+ raise ValueError("can't find %r in 'vmstat' output" % stat)
+
+
# =====================================================================
# system virtual memory
# =====================================================================
@@ -337,6 +346,25 @@ class TestSystemCPU(unittest.TestCase):
# =====================================================================
+# system CPU stats
+# =====================================================================
+
+
+@unittest.skipUnless(LINUX, "not a Linux system")
+class TestSystemCPUStats(unittest.TestCase):
+
+ def test_ctx_switches(self):
+ vmstat_value = vmstat("context switches")
+ psutil_value = psutil.cpu_stats().ctx_switches
+ self.assertAlmostEqual(vmstat_value, psutil_value, delta=50)
+
+ def test_interrupts(self):
+ vmstat_value = vmstat("interrupts")
+ psutil_value = psutil.cpu_stats().interrupts
+ self.assertAlmostEqual(vmstat_value, psutil_value, delta=20)
+
+
+# =====================================================================
# system network
# =====================================================================