Bug 908296 - Upgrade psutil to version 1.0.1; rs=glandium
Archive obtained from https://psutil.googlecode.com/files/psutil-1.0.1.tar.gz and extracted over existing source code without modifications.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.
|
||||
# Copyright (c) 2009, 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.
|
||||
|
||||
@@ -16,11 +16,10 @@ import re
|
||||
import psutil
|
||||
|
||||
from psutil._compat import PY3
|
||||
from test_psutil import reap_children, get_test_subprocess, sh
|
||||
from test_psutil import *
|
||||
|
||||
|
||||
PAGESIZE = os.sysconf("SC_PAGE_SIZE")
|
||||
TOLERANCE = 500 * 1024 # 500 KB
|
||||
|
||||
|
||||
def sysctl(cmdline):
|
||||
@@ -55,14 +54,6 @@ class OSXSpecificTestCase(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
reap_children()
|
||||
|
||||
def assert_eq_w_tol(self, first, second, tolerance):
|
||||
difference = abs(first - second)
|
||||
if difference <= tolerance:
|
||||
return
|
||||
msg = '%r != %r (tolerance=%r, difference=%s)' \
|
||||
% (first, second, tolerance, difference)
|
||||
raise AssertionError(msg)
|
||||
|
||||
def test_process_create_time(self):
|
||||
cmdline = "ps -o lstart -p %s" %self.pid
|
||||
p = subprocess.Popen(cmdline, shell=1, stdout=subprocess.PIPE)
|
||||
@@ -108,21 +99,29 @@ class OSXSpecificTestCase(unittest.TestCase):
|
||||
sysctl_hwphymem = sysctl('sysctl hw.memsize')
|
||||
self.assertEqual(sysctl_hwphymem, psutil.TOTAL_PHYMEM)
|
||||
|
||||
@retry_before_failing()
|
||||
def test_vmem_free(self):
|
||||
num = vm_stat("free")
|
||||
self.assert_eq_w_tol(psutil.virtual_memory().free, num, TOLERANCE)
|
||||
self.assertAlmostEqual(psutil.virtual_memory().free, num,
|
||||
delta=TOLERANCE)
|
||||
|
||||
@retry_before_failing()
|
||||
def test_vmem_active(self):
|
||||
num = vm_stat("active")
|
||||
self.assert_eq_w_tol(psutil.virtual_memory().active, num, TOLERANCE)
|
||||
self.assertAlmostEqual(psutil.virtual_memory().active, num,
|
||||
delta=TOLERANCE)
|
||||
|
||||
@retry_before_failing()
|
||||
def test_vmem_inactive(self):
|
||||
num = vm_stat("inactive")
|
||||
self.assert_eq_w_tol(psutil.virtual_memory().inactive, num, TOLERANCE)
|
||||
self.assertAlmostEqual(psutil.virtual_memory().inactive, num,
|
||||
delta=TOLERANCE)
|
||||
|
||||
@retry_before_failing()
|
||||
def test_vmem_wired(self):
|
||||
num = vm_stat("wired")
|
||||
self.assert_eq_w_tol(psutil.virtual_memory().wired, num, TOLERANCE)
|
||||
self.assertAlmostEqual(psutil.virtual_memory().wired, num,
|
||||
delta=TOLERANCE)
|
||||
|
||||
# --- swap mem
|
||||
|
||||
@@ -146,7 +145,12 @@ class OSXSpecificTestCase(unittest.TestCase):
|
||||
self.assertEqual(tot1, tot2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
def test_main():
|
||||
test_suite = unittest.TestSuite()
|
||||
test_suite.addTest(unittest.makeSuite(OSXSpecificTestCase))
|
||||
unittest.TextTestRunner(verbosity=2).run(test_suite)
|
||||
result = unittest.TextTestRunner(verbosity=2).run(test_suite)
|
||||
return result.wasSuccessful()
|
||||
|
||||
if __name__ == '__main__':
|
||||
if not test_main():
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user