OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """A "Test Server Spawner" that handles killing/stopping per-test test servers. | 5 """A "Test Server Spawner" that handles killing/stopping per-test test servers. |
6 | 6 |
7 It's used to accept requests from the device to spawn and kill instances of the | 7 It's used to accept requests from the device to spawn and kill instances of the |
8 chrome test server on the host. | 8 chrome test server on the host. |
9 """ | 9 """ |
10 | 10 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 command = [os.path.join(constants.CHROME_DIR, 'net', 'tools', | 210 command = [os.path.join(constants.CHROME_DIR, 'net', 'tools', |
211 'testserver', 'testserver.py')] + self.command_line | 211 'testserver', 'testserver.py')] + self.command_line |
212 logging.info('Running: %s', command) | 212 logging.info('Running: %s', command) |
213 self.process = subprocess.Popen(command) | 213 self.process = subprocess.Popen(command) |
214 if self.process: | 214 if self.process: |
215 if self.pipe_out: | 215 if self.pipe_out: |
216 self.is_ready = self._WaitToStartAndGetPortFromTestServer() | 216 self.is_ready = self._WaitToStartAndGetPortFromTestServer() |
217 else: | 217 else: |
218 self.is_ready = _CheckPortStatus(self.host_port, True) | 218 self.is_ready = _CheckPortStatus(self.host_port, True) |
219 if self.is_ready: | 219 if self.is_ready: |
220 self._test_server_forwarder = Forwarder( | 220 self._test_server_forwarder = Forwarder(self.adb, self.build_type) |
221 self.adb, [(0, self.host_port)], self.tool, '127.0.0.1', | 221 self._test_server_forwarder.Run( |
222 self.build_type) | 222 [(0, self.host_port)], self.tool, '127.0.0.1') |
223 # Check whether the forwarder is ready on the device. | 223 # Check whether the forwarder is ready on the device. |
224 self.is_ready = False | 224 self.is_ready = False |
225 device_port = self._test_server_forwarder.DevicePortForHostPort( | 225 device_port = self._test_server_forwarder.DevicePortForHostPort( |
226 self.host_port) | 226 self.host_port) |
227 if device_port: | 227 if device_port: |
228 for timeout in range(1, 5): | 228 for timeout in range(1, 5): |
229 if ports.IsDevicePortUsed(self.adb, device_port, 'LISTEN'): | 229 if ports.IsDevicePortUsed(self.adb, device_port, 'LISTEN'): |
230 self.is_ready = True | 230 self.is_ready = True |
231 self.forwarder_device_port = device_port | 231 self.forwarder_device_port = device_port |
232 break | 232 break |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 def Start(self): | 393 def Start(self): |
394 listener_thread = threading.Thread(target=self._Listen) | 394 listener_thread = threading.Thread(target=self._Listen) |
395 listener_thread.setDaemon(True) | 395 listener_thread.setDaemon(True) |
396 listener_thread.start() | 396 listener_thread.start() |
397 time.sleep(1) | 397 time.sleep(1) |
398 | 398 |
399 def Stop(self): | 399 def Stop(self): |
400 if self.server.test_server_instance: | 400 if self.server.test_server_instance: |
401 self.server.test_server_instance.Stop() | 401 self.server.test_server_instance.Stop() |
402 self.server.shutdown() | 402 self.server.shutdown() |
OLD | NEW |