OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 command = [os.path.join(command, 'net', 'tools', 'testserver', | 233 command = [os.path.join(command, 'net', 'tools', 'testserver', |
234 'testserver.py')] + self.command_line | 234 'testserver.py')] + self.command_line |
235 logging.info('Running: %s', command) | 235 logging.info('Running: %s', command) |
236 self.process = subprocess.Popen(command) | 236 self.process = subprocess.Popen(command) |
237 if self.process: | 237 if self.process: |
238 if self.pipe_out: | 238 if self.pipe_out: |
239 self.is_ready = self._WaitToStartAndGetPortFromTestServer() | 239 self.is_ready = self._WaitToStartAndGetPortFromTestServer() |
240 else: | 240 else: |
241 self.is_ready = _CheckPortStatus(self.host_port, True) | 241 self.is_ready = _CheckPortStatus(self.host_port, True) |
242 if self.is_ready: | 242 if self.is_ready: |
243 self._test_server_forwarder.Run( | 243 self._test_server_forwarder.Run([(0, self.host_port)], self.tool) |
244 [(0, self.host_port)], self.tool, '127.0.0.1') | |
245 # Check whether the forwarder is ready on the device. | 244 # Check whether the forwarder is ready on the device. |
246 self.is_ready = False | 245 self.is_ready = False |
247 device_port = self._test_server_forwarder.DevicePortForHostPort( | 246 device_port = self._test_server_forwarder.DevicePortForHostPort( |
248 self.host_port) | 247 self.host_port) |
249 if device_port and _CheckDevicePortStatus(self.adb, device_port): | 248 if device_port and _CheckDevicePortStatus(self.adb, device_port): |
250 self.is_ready = True | 249 self.is_ready = True |
251 self.forwarder_device_port = device_port | 250 self.forwarder_device_port = device_port |
252 # Wake up the request handler thread. | 251 # Wake up the request handler thread. |
253 self.ready_event.set() | 252 self.ready_event.set() |
254 # Keep thread running until Stop() gets called. | 253 # Keep thread running until Stop() gets called. |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 | 423 |
425 def CleanupState(self): | 424 def CleanupState(self): |
426 """Cleans up the spawning server state. | 425 """Cleans up the spawning server state. |
427 | 426 |
428 This should be called if the test server spawner is reused, | 427 This should be called if the test server spawner is reused, |
429 to avoid sharing the test server instance. | 428 to avoid sharing the test server instance. |
430 """ | 429 """ |
431 if self.server.test_server_instance: | 430 if self.server.test_server_instance: |
432 self.server.test_server_instance.Stop() | 431 self.server.test_server_instance.Stop() |
433 self.server.test_server_instance = None | 432 self.server.test_server_instance = None |
OLD | NEW |