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

Side by Side Diff: third_party/psutil/test/_osx.py

Issue 6246123: Moving psutil to third_party. This is first step for Media Performance test project. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: modification based on code review's comments Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/psutil/test/_linux.py ('k') | third_party/psutil/test/_posix.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # $Id: _osx.py 664 2010-10-09 16:14:34Z g.rodola $
4 #
5
6 import unittest
7 import subprocess
8 import time
9 import re
10 import sys
11
12 import psutil
13
14 from test_psutil import reap_children, get_test_subprocess
15 #from _posix import ps
16
17
18 def sysctl(cmdline):
19 """Expects a sysctl command with an argument and parse the result
20 returning only the value of interest.
21 """
22 p = subprocess.Popen(cmdline, shell=1, stdout=subprocess.PIPE)
23 result = p.communicate()[0].strip().split()[1]
24 if sys.version_info >= (3,):
25 result = str(result, sys.stdout.encoding)
26 try:
27 return int(result)
28 except ValueError:
29 return result
30
31
32 class OSXSpecificTestCase(unittest.TestCase):
33
34 def setUp(self):
35 self.pid = get_test_subprocess().pid
36
37 def tearDown(self):
38 reap_children()
39
40 def test_TOTAL_PHYMEM(self):
41 sysctl_hwphymem = sysctl('sysctl hw.physmem')
42 self.assertEqual(sysctl_hwphymem, psutil.TOTAL_PHYMEM)
43
44 def test_process_create_time(self):
45 cmdline = "ps -o lstart -p %s" %self.pid
46 p = subprocess.Popen(cmdline, shell=1, stdout=subprocess.PIPE)
47 output = p.communicate()[0]
48 if sys.version_info >= (3,):
49 output = str(output, sys.stdout.encoding)
50 start_ps = output.replace('STARTED', '').strip()
51 start_psutil = psutil.Process(self.pid).create_time
52 start_psutil = time.strftime("%a %b %e %H:%M:%S %Y",
53 time.localtime(start_psutil))
54 self.assertEqual(start_ps, start_psutil)
55
56
57 if __name__ == '__main__':
58 test_suite = unittest.TestSuite()
59 test_suite.addTest(unittest.makeSuite(OSXSpecificTestCase))
60 unittest.TextTestRunner(verbosity=2).run(test_suite)
61
62
63
64
OLDNEW
« no previous file with comments | « third_party/psutil/test/_linux.py ('k') | third_party/psutil/test/_posix.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698