Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(631)

Unified Diff: third_party/psutil/test/_linux.py

Issue 8159001: Update third_party/psutil and fix the licence issue with it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove the suppression and unnecessary files. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/psutil/test/_bsd.py ('k') | third_party/psutil/test/_osx.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/psutil/test/_linux.py
diff --git a/third_party/psutil/test/_linux.py b/third_party/psutil/test/_linux.py
index 187c058a4843735a7567002e886b8ebf38738f0f..a20d8dc227b4a8e62eff3d4239748964fb2ae76e 100644
--- a/third_party/psutil/test/_linux.py
+++ b/third_party/psutil/test/_linux.py
@@ -1,12 +1,18 @@
#!/usr/bin/env python
#
-# $Id: _linux.py 707 2010-10-19 18:16:08Z g.rodola $
+# $Id: _linux.py 1142 2011-10-05 18:45:49Z g.rodola $
#
+# Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Linux specific tests. These are implicitly run by test_psutil.py."""
import unittest
import subprocess
import sys
+from test_psutil import sh
import psutil
@@ -34,12 +40,33 @@ class LinuxSpecificTestCase(unittest.TestCase):
psutil_cmem = psutil.phymem_buffers() / 1024
self.assertEqual(free_cmem, psutil_cmem)
+ def test_disks(self):
+ # test psutil.disk_usage() and psutil.disk_partitions()
+ # against "df -a"
+ def df(path):
+ out = sh('df -P -B 1 "%s"' % path).strip()
+ lines = out.split('\n')
+ lines.pop(0)
+ line = lines.pop(0)
+ dev, total, used, free = line.split()[:4]
+ if dev == 'none':
+ dev = ''
+ total, used, free = int(total), int(used), int(free)
+ return dev, total, used, free
+
+ for part in psutil.disk_partitions(all=False):
+ usage = psutil.disk_usage(part.mountpoint)
+ dev, total, used, free = df(part.mountpoint)
+ self.assertEqual(part.device, dev)
+ self.assertEqual(usage.total, total)
+ # 10 MB tollerance
+ if abs(usage.free - free) > 10 * 1024 * 1024:
+ self.fail("psutil=%s, df=%s" % usage.free, free)
+ if abs(usage.used - used) > 10 * 1024 * 1024:
+ self.fail("psutil=%s, df=%s" % usage.used, used)
+
if __name__ == '__main__':
test_suite = unittest.TestSuite()
test_suite.addTest(unittest.makeSuite(LinuxSpecificTestCase))
unittest.TextTestRunner(verbosity=2).run(test_suite)
-
-
-
-
« no previous file with comments | « third_party/psutil/test/_bsd.py ('k') | third_party/psutil/test/_osx.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698