diff options
author | wiggin15 <arnony@infinidat.com> | 2019-05-08 11:20:49 +0300 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2019-05-08 16:20:49 +0800 |
commit | 43a22b81832f7ba546636c26006190bc2bb8dfc2 (patch) | |
tree | 2bd8f5e4725be70b515bfc86b10f5aa2d79b9326 | |
parent | 904f5ec2b416620302df78de1ef8d73c00401a32 (diff) | |
download | psutil-43a22b81832f7ba546636c26006190bc2bb8dfc2.tar.gz |
Fix some tests on AIX (#1507)
-rwxr-xr-x | psutil/tests/test_posix.py | 20 | ||||
-rwxr-xr-x | scripts/ps.py | 4 |
2 files changed, 20 insertions, 4 deletions
diff --git a/psutil/tests/test_posix.py b/psutil/tests/test_posix.py index d24abad3..348366ad 100755 --- a/psutil/tests/test_posix.py +++ b/psutil/tests/test_posix.py @@ -52,7 +52,7 @@ def ps(fmt, pid=None): if pid is not None: cmd.extend(['-p', str(pid)]) else: - if SUNOS: + if SUNOS or AIX: cmd.append('-A') else: cmd.append('ax') @@ -113,6 +113,20 @@ def ps_args(pid): return ps(field, pid) +def ps_rss(pid): + field = "rss" + if AIX: + field = "rssize" + return ps(field, pid) + + +def ps_vsz(pid): + field = "vsz" + if AIX: + field = "vsize" + return ps(field, pid) + + @unittest.skipIf(not POSIX, "POSIX only") class TestProcess(unittest.TestCase): """Compare psutil results against 'ps' command line utility (mainly).""" @@ -162,7 +176,7 @@ class TestProcess(unittest.TestCase): # give python interpreter some time to properly initialize # so that the results are the same time.sleep(0.1) - rss_ps = ps('rss', self.pid) + rss_ps = ps_rss(self.pid) rss_psutil = psutil.Process(self.pid).memory_info()[0] / 1024 self.assertEqual(rss_ps, rss_psutil) @@ -172,7 +186,7 @@ class TestProcess(unittest.TestCase): # give python interpreter some time to properly initialize # so that the results are the same time.sleep(0.1) - vsz_ps = ps('vsz', self.pid) + vsz_ps = ps_vsz(self.pid) vsz_psutil = psutil.Process(self.pid).memory_info()[1] / 1024 self.assertEqual(vsz_ps, vsz_psutil) diff --git a/scripts/ps.py b/scripts/ps.py index 40dcce20..8467cca6 100755 --- a/scripts/ps.py +++ b/scripts/ps.py @@ -70,6 +70,8 @@ def main(): pass if user and psutil.WINDOWS and '\\' in user: user = user.split('\\')[1] + if not user: + user = '' user = user[:9] vms = bytes2human(p.info['memory_info'].vms) if \ p.info['memory_info'] is not None else '' @@ -85,7 +87,7 @@ def main(): status = p.info['status'][:5] if p.info['status'] else '' line = templ % ( - user[:10], + user, p.info['pid'], memp, vms, |