Index: trunk/src/build/android/pylib/chrome_test_server_spawner.py |
=================================================================== |
--- trunk/src/build/android/pylib/chrome_test_server_spawner.py (revision 212053) |
+++ trunk/src/build/android/pylib/chrome_test_server_spawner.py (working copy) |
@@ -23,7 +23,6 @@ |
import constants |
import ports |
-from pylib.forwarder import Forwarder |
# Path that are needed to import necessary modules when launching a testserver. |
os.environ['PYTHONPATH'] = os.environ.get('PYTHONPATH', '') + (':%s:%s:%s:%s:%s' |
@@ -100,7 +99,7 @@ |
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: |
@@ -108,6 +107,7 @@ |
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) |
@@ -122,6 +122,7 @@ |
self.is_ready = False |
self.host_port = self.arguments['port'] |
assert isinstance(self.host_port, int) |
+ 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,10 +240,11 @@ |
else: |
self.is_ready = _CheckPortStatus(self.host_port, True) |
if self.is_ready: |
- Forwarder.Map([(0, self.host_port)], self.adb, self.build_type, self.tool) |
+ self._test_server_forwarder.Run([(0, self.host_port)], self.tool) |
# Check whether the forwarder is ready on the device. |
self.is_ready = False |
- device_port = Forwarder.DevicePortForHostPort(self.host_port) |
+ device_port = self._test_server_forwarder.DevicePortForHostPort( |
+ self.host_port) |
if device_port and _CheckDevicePortStatus(self.adb, device_port): |
self.is_ready = True |
self.forwarder_device_port = device_port |
@@ -252,7 +254,7 @@ |
_WaitUntil(lambda: self.stop_flag, max_attempts=sys.maxint) |
if self.process.poll() is None: |
self.process.kill() |
- Forwarder.UnmapDevicePort(self.forwarder_device_port, self.adb) |
+ self._test_server_forwarder.UnmapDevicePort(self.forwarder_device_port) |
self.process = None |
self.is_ready = False |
if self.pipe_out: |
@@ -322,6 +324,7 @@ |
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() |
@@ -389,12 +392,14 @@ |
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.server.adb = adb |
self.server.tool = tool |
+ self.server.forwarder = forwarder |
self.server.test_server_instance = None |
self.server.build_type = build_type |