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

Unified Diff: build/android/pylib/chrome_test_server_spawner.py

Issue 15151003: Use a single Python Forwarder instance for each base test runner instance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Craig + Frank comments Created 7 years, 7 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/base/base_test_runner.py ('k') | build/android/pylib/forwarder.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/chrome_test_server_spawner.py
diff --git a/build/android/pylib/chrome_test_server_spawner.py b/build/android/pylib/chrome_test_server_spawner.py
index 2a0fa4641ceaeed81f081196f35a53c7e11f5eff..ec101803ccef57a4b5c7a4acd27ea839a145ba5a 100644
--- a/build/android/pylib/chrome_test_server_spawner.py
+++ b/build/android/pylib/chrome_test_server_spawner.py
@@ -21,7 +21,6 @@ import time
import urlparse
import constants
-from forwarder import Forwarder
import ports
@@ -99,7 +98,7 @@ def _GetServerTypeCommandLine(server_type):
class TestServerThread(threading.Thread):
"""A thread to run the test server in a separate process."""
- def __init__(self, ready_event, arguments, adb, tool, build_type):
+ def __init__(self, ready_event, arguments, adb, tool, forwarder, build_type):
"""Initialize TestServerThread with the following argument.
Args:
@@ -107,6 +106,7 @@ class TestServerThread(threading.Thread):
arguments: dictionary of arguments to run the test server.
adb: instance of AndroidCommands.
tool: instance of runtime error detection tool.
+ forwarder: instance of Forwarder.
build_type: 'Release' or 'Debug'.
"""
threading.Thread.__init__(self)
@@ -121,7 +121,7 @@ class TestServerThread(threading.Thread):
self.is_ready = False
self.host_port = self.arguments['port']
assert isinstance(self.host_port, int)
- self._test_server_forwarder = None
+ self._test_server_forwarder = forwarder
# The forwarder device port now is dynamically allocated.
self.forwarder_device_port = 0
# Anonymous pipe in order to get port info from test server.
@@ -239,7 +239,6 @@ class TestServerThread(threading.Thread):
else:
self.is_ready = _CheckPortStatus(self.host_port, True)
if self.is_ready:
- self._test_server_forwarder = Forwarder(self.adb, self.build_type)
self._test_server_forwarder.Run(
[(0, self.host_port)], self.tool, '127.0.0.1')
# Check whether the forwarder is ready on the device.
@@ -255,8 +254,7 @@ class TestServerThread(threading.Thread):
_WaitUntil(lambda: self.stop_flag, max_attempts=sys.maxint)
if self.process.poll() is None:
self.process.kill()
- if self._test_server_forwarder:
- self._test_server_forwarder.UnmapDevicePort(self.forwarder_device_port)
+ self._test_server_forwarder.UnmapDevicePort(self.forwarder_device_port)
self.process = None
self.is_ready = False
if self.pipe_out:
@@ -326,6 +324,7 @@ class SpawningServerRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
json.loads(test_server_argument_json),
self.server.adb,
self.server.tool,
+ self.server.forwarder,
self.server.build_type)
self.server.test_server_instance.setDaemon(True)
self.server.test_server_instance.start()
@@ -393,13 +392,14 @@ class SpawningServerRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
class SpawningServer(object):
"""The class used to start/stop a http server."""
- def __init__(self, test_server_spawner_port, adb, tool, build_type):
+ def __init__(self, test_server_spawner_port, adb, tool, forwarder,
+ build_type):
logging.info('Creating new spawner on port: %d.', test_server_spawner_port)
self.server = BaseHTTPServer.HTTPServer(('', test_server_spawner_port),
SpawningServerRequestHandler)
- self.port = test_server_spawner_port
self.server.adb = adb
self.server.tool = tool
+ self.server.forwarder = forwarder
self.server.test_server_instance = None
self.server.build_type = build_type
« no previous file with comments | « build/android/pylib/base/base_test_runner.py ('k') | build/android/pylib/forwarder.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698