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

Unified Diff: build/android/run_tests.py

Issue 11734008: [Android] Move Xvfb and TimeProfile from run_tests.py into individual files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 12 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 | « build/android/pylib/utils/xvfb.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/run_tests.py
diff --git a/build/android/run_tests.py b/build/android/run_tests.py
index 1a628d1528e1d6c00276dc3ca57d1bd4e4efbfc9..aa4e7dc482e73ae73da6febe95dc3f4f32f758c7 100755
--- a/build/android/run_tests.py
+++ b/build/android/run_tests.py
@@ -55,6 +55,8 @@ from pylib import run_tests_helper
from pylib import test_options_parser
from pylib.base_test_sharder import BaseTestSharder
from pylib.single_test_runner import SingleTestRunner
+from pylib.utils import time_profile
+from pylib.utils import xvfb
_TEST_SUITES = ['base_unittests',
@@ -105,71 +107,6 @@ def FullyQualifiedTestSuites(exe, option_test_suite, build_type):
return qualified_test_suites
-class TimeProfile(object):
- """Class for simple profiling of action, with logging of cost."""
-
- def __init__(self, description):
- self._description = description
- self.Start()
-
- def Start(self):
- self._starttime = time.time()
-
- def Stop(self):
- """Stop profiling and dump a log."""
- if self._starttime:
- stoptime = time.time()
- logging.info('%fsec to perform %s',
- stoptime - self._starttime, self._description)
- self._starttime = None
-
-
-class Xvfb(object):
- """Class to start and stop Xvfb if relevant. Nop if not Linux."""
-
- def __init__(self):
- self._pid = 0
-
- def _IsLinux(self):
- """Return True if on Linux; else False."""
- return sys.platform.startswith('linux')
-
- def Start(self):
- """Start Xvfb and set an appropriate DISPLAY environment. Linux only.
-
- Copied from tools/code_coverage/coverage_posix.py
- """
- if not self._IsLinux():
- return
- proc = subprocess.Popen(['Xvfb', ':9', '-screen', '0', '1024x768x24',
- '-ac'],
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- self._pid = proc.pid
- if not self._pid:
- raise Exception('Could not start Xvfb')
- os.environ['DISPLAY'] = ':9'
-
- # Now confirm, giving a chance for it to start if needed.
- for _ in range(10):
- proc = subprocess.Popen('xdpyinfo >/dev/null', shell=True)
- _, retcode = os.waitpid(proc.pid, 0)
- if retcode == 0:
- break
- time.sleep(0.25)
- if retcode != 0:
- raise Exception('Could not confirm Xvfb happiness')
-
- def Stop(self):
- """Stop Xvfb if needed. Linux only."""
- if self._pid:
- try:
- os.kill(self._pid, signal.SIGKILL)
- except:
- pass
- del os.environ['DISPLAY']
- self._pid = 0
-
-
class TestSharder(BaseTestSharder):
"""Responsible for sharding the tests on the connected devices."""
@@ -311,7 +248,7 @@ def _RunATestSuite(options):
if options.use_emulator:
for n in range(options.emulator_count):
- t = TimeProfile('Emulator launch %d' % n)
+ t = time_profile.TimeProfile('Emulator launch %d' % n)
avd_name = None
if n > 0:
# Creates a temporary AVD for the extra emulators.
@@ -381,8 +318,8 @@ def Dispatch(options):
return 0
if options.use_xvfb:
- xvfb = Xvfb()
- xvfb.Start()
+ framebuffer = xvfb.Xvfb()
+ framebuffer.Start()
all_test_suites = FullyQualifiedTestSuites(options.exe, options.test_suite,
options.build_type)
@@ -394,7 +331,7 @@ def Dispatch(options):
failures += _RunATestSuite(test_options)
if options.use_xvfb:
- xvfb.Stop()
+ framebuffer.Stop()
return failures
« no previous file with comments | « build/android/pylib/utils/xvfb.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698