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

Unified Diff: third_party/psutil/test/_posix.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/_osx.py ('k') | third_party/psutil/test/_windows.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/psutil/test/_posix.py
diff --git a/third_party/psutil/test/_posix.py b/third_party/psutil/test/_posix.py
old mode 100644
new mode 100755
index 1879dc7294f2c9131226952198fe6757f5b22798..ad0db64a003f8d621f0043f845257744f50e588f
--- a/third_party/psutil/test/_posix.py
+++ b/third_party/psutil/test/_posix.py
@@ -1,7 +1,12 @@
#!/usr/bin/env python
#
-# $Id: _posix.py 744 2010-10-27 22:42:42Z jloden $
+# $Id: _posix.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.
+
+"""POSIX specific tests. These are implicitly run by test_psutil.py."""
import unittest
import subprocess
@@ -11,7 +16,8 @@ import os
import psutil
-from test_psutil import kill, get_test_subprocess, PYTHON, LINUX, OSX
+from test_psutil import (get_test_subprocess, reap_children, PYTHON, LINUX, OSX,
+ ignore_access_denied, sh)
def ps(cmd):
@@ -41,7 +47,7 @@ class PosixSpecificTestCase(unittest.TestCase):
self.pid = get_test_subprocess([PYTHON, "-E", "-O"]).pid
def tearDown(self):
- kill(self.pid)
+ reap_children()
def test_process_parent_pid(self):
ppid_ps = ps("ps --no-headers -o ppid -p %s" %self.pid)
@@ -50,12 +56,12 @@ class PosixSpecificTestCase(unittest.TestCase):
def test_process_uid(self):
uid_ps = ps("ps --no-headers -o uid -p %s" %self.pid)
- uid_psutil = psutil.Process(self.pid).uid
+ uid_psutil = psutil.Process(self.pid).uids.real
self.assertEqual(uid_ps, uid_psutil)
def test_process_gid(self):
gid_ps = ps("ps --no-headers -o rgid -p %s" %self.pid)
- gid_psutil = psutil.Process(self.pid).gid
+ gid_psutil = psutil.Process(self.pid).gids.real
self.assertEqual(gid_ps, gid_psutil)
def test_process_username(self):
@@ -63,6 +69,7 @@ class PosixSpecificTestCase(unittest.TestCase):
username_psutil = psutil.Process(self.pid).username
self.assertEqual(username_ps, username_psutil)
+ @ignore_access_denied
def test_process_rss_memory(self):
# give python interpreter some time to properly initialize
# so that the results are the same
@@ -71,6 +78,7 @@ class PosixSpecificTestCase(unittest.TestCase):
rss_psutil = psutil.Process(self.pid).get_memory_info()[0] / 1024
self.assertEqual(rss_ps, rss_psutil)
+ @ignore_access_denied
def test_process_vsz_memory(self):
# give python interpreter some time to properly initialize
# so that the results are the same
@@ -83,18 +91,24 @@ class PosixSpecificTestCase(unittest.TestCase):
# use command + arg since "comm" keyword not supported on all platforms
name_ps = ps("ps --no-headers -o command -p %s" %self.pid).split(' ')[0]
# remove path if there is any, from the command
- name_ps = os.path.basename(name_ps)
- name_psutil = psutil.Process(self.pid).name
- if OSX:
- self.assertEqual(name_psutil, "Python")
- else:
- self.assertEqual(name_ps, name_psutil)
-
+ name_ps = os.path.basename(name_ps).lower()
+ name_psutil = psutil.Process(self.pid).name.lower()
+ self.assertEqual(name_ps, name_psutil)
def test_process_exe(self):
ps_pathname = ps("ps --no-headers -o command -p %s" %self.pid).split(' ')[0]
psutil_pathname = psutil.Process(self.pid).exe
- self.assertEqual(ps_pathname, psutil_pathname)
+ try:
+ self.assertEqual(ps_pathname, psutil_pathname)
+ except AssertionError:
+ # certain platforms such as BSD are more accurate returning:
+ # "/usr/local/bin/python2.7"
+ # ...instead of:
+ # "/usr/local/bin/python"
+ # We do not want to consider this difference in accuracy
+ # an error.
+ adjusted_ps_pathname = ps_pathname[:len(ps_pathname)]
+ self.assertEqual(ps_pathname, adjusted_ps_pathname)
def test_process_cmdline(self):
ps_cmdline = ps("ps --no-headers -o command -p %s" %self.pid)
@@ -116,18 +130,13 @@ class PosixSpecificTestCase(unittest.TestCase):
pids_ps.append(int(pid.strip()))
# remove ps subprocess pid which is supposed to be dead in meantime
pids_ps.remove(p.pid)
- # not all systems include pid 0 in their list but psutil does so
- # we force it
- if 0 not in pids_ps:
- pids_ps.append(0)
-
pids_psutil = psutil.get_pid_list()
pids_ps.sort()
pids_psutil.sort()
if pids_ps != pids_psutil:
- difference = filter(lambda x:x not in pids_ps, pids_psutil) + \
- filter(lambda x:x not in pids_psutil, pids_ps)
+ difference = [x for x in pids_psutil if x not in pids_ps] + \
+ [x for x in pids_ps if x not in pids_psutil]
self.fail("difference: " + str(difference))
« no previous file with comments | « third_party/psutil/test/_osx.py ('k') | third_party/psutil/test/_windows.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698