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

Unified 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, 11 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/_linux.py ('k') | third_party/psutil/test/_posix.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/psutil/test/_osx.py
diff --git a/third_party/psutil/test/_osx.py b/third_party/psutil/test/_osx.py
new file mode 100644
index 0000000000000000000000000000000000000000..aaf9215936a56a7c5f389a56200cf5426e5feada
--- /dev/null
+++ b/third_party/psutil/test/_osx.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+#
+# $Id: _osx.py 664 2010-10-09 16:14:34Z g.rodola $
+#
+
+import unittest
+import subprocess
+import time
+import re
+import sys
+
+import psutil
+
+from test_psutil import reap_children, get_test_subprocess
+#from _posix import ps
+
+
+def sysctl(cmdline):
+ """Expects a sysctl command with an argument and parse the result
+ returning only the value of interest.
+ """
+ p = subprocess.Popen(cmdline, shell=1, stdout=subprocess.PIPE)
+ result = p.communicate()[0].strip().split()[1]
+ if sys.version_info >= (3,):
+ result = str(result, sys.stdout.encoding)
+ try:
+ return int(result)
+ except ValueError:
+ return result
+
+
+class OSXSpecificTestCase(unittest.TestCase):
+
+ def setUp(self):
+ self.pid = get_test_subprocess().pid
+
+ def tearDown(self):
+ reap_children()
+
+ def test_TOTAL_PHYMEM(self):
+ sysctl_hwphymem = sysctl('sysctl hw.physmem')
+ self.assertEqual(sysctl_hwphymem, psutil.TOTAL_PHYMEM)
+
+ def test_process_create_time(self):
+ cmdline = "ps -o lstart -p %s" %self.pid
+ p = subprocess.Popen(cmdline, shell=1, stdout=subprocess.PIPE)
+ output = p.communicate()[0]
+ if sys.version_info >= (3,):
+ output = str(output, sys.stdout.encoding)
+ start_ps = output.replace('STARTED', '').strip()
+ start_psutil = psutil.Process(self.pid).create_time
+ start_psutil = time.strftime("%a %b %e %H:%M:%S %Y",
+ time.localtime(start_psutil))
+ self.assertEqual(start_ps, start_psutil)
+
+
+if __name__ == '__main__':
+ test_suite = unittest.TestSuite()
+ test_suite.addTest(unittest.makeSuite(OSXSpecificTestCase))
+ unittest.TextTestRunner(verbosity=2).run(test_suite)
+
+
+
+
« 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