| 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 'testserver.py')] + self.command_line | 242 'testserver.py')] + self.command_line |
| 243 logging.info('Running: %s', command) | 243 logging.info('Running: %s', command) |
| 244 self.process = subprocess.Popen( | 244 self.process = subprocess.Popen( |
| 245 command, preexec_fn=self._CloseUnnecessaryFDsForTestServerProcess) | 245 command, preexec_fn=self._CloseUnnecessaryFDsForTestServerProcess) |
| 246 if self.process: | 246 if self.process: |
| 247 if self.pipe_out: | 247 if self.pipe_out: |
| 248 self.is_ready = self._WaitToStartAndGetPortFromTestServer() | 248 self.is_ready = self._WaitToStartAndGetPortFromTestServer() |
| 249 else: | 249 else: |
| 250 self.is_ready = _CheckPortStatus(self.host_port, True) | 250 self.is_ready = _CheckPortStatus(self.host_port, True) |
| 251 if self.is_ready: | 251 if self.is_ready: |
| 252 Forwarder.Map([(0, self.host_port)], self.adb, self.tool) | 252 Forwarder.Map([(0, self.host_port)], self.adb, constants.GetBuildType(), |
| 253 self.tool) |
| 253 # Check whether the forwarder is ready on the device. | 254 # Check whether the forwarder is ready on the device. |
| 254 self.is_ready = False | 255 self.is_ready = False |
| 255 device_port = Forwarder.DevicePortForHostPort(self.host_port) | 256 device_port = Forwarder.DevicePortForHostPort(self.host_port) |
| 256 if device_port and _CheckDevicePortStatus(self.adb, device_port): | 257 if device_port and _CheckDevicePortStatus(self.adb, device_port): |
| 257 self.is_ready = True | 258 self.is_ready = True |
| 258 self.forwarder_device_port = device_port | 259 self.forwarder_device_port = device_port |
| 259 # Wake up the request handler thread. | 260 # Wake up the request handler thread. |
| 260 self.ready_event.set() | 261 self.ready_event.set() |
| 261 # Keep thread running until Stop() gets called. | 262 # Keep thread running until Stop() gets called. |
| 262 _WaitUntil(lambda: self.stop_flag, max_attempts=sys.maxint) | 263 _WaitUntil(lambda: self.stop_flag, max_attempts=sys.maxint) |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 | 428 |
| 428 def CleanupState(self): | 429 def CleanupState(self): |
| 429 """Cleans up the spawning server state. | 430 """Cleans up the spawning server state. |
| 430 | 431 |
| 431 This should be called if the test server spawner is reused, | 432 This should be called if the test server spawner is reused, |
| 432 to avoid sharing the test server instance. | 433 to avoid sharing the test server instance. |
| 433 """ | 434 """ |
| 434 if self.server.test_server_instance: | 435 if self.server.test_server_instance: |
| 435 self.server.test_server_instance.Stop() | 436 self.server.test_server_instance.Stop() |
| 436 self.server.test_server_instance = None | 437 self.server.test_server_instance = None |
| OLD | NEW |