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, constants.GetBuildType(), | 252 Forwarder.Map([(0, self.host_port)], self.adb, self.tool) |
253 self.tool) | |
254 # Check whether the forwarder is ready on the device. | 253 # Check whether the forwarder is ready on the device. |
255 self.is_ready = False | 254 self.is_ready = False |
256 device_port = Forwarder.DevicePortForHostPort(self.host_port) | 255 device_port = Forwarder.DevicePortForHostPort(self.host_port) |
257 if device_port and _CheckDevicePortStatus(self.adb, device_port): | 256 if device_port and _CheckDevicePortStatus(self.adb, device_port): |
258 self.is_ready = True | 257 self.is_ready = True |
259 self.forwarder_device_port = device_port | 258 self.forwarder_device_port = device_port |
260 # Wake up the request handler thread. | 259 # Wake up the request handler thread. |
261 self.ready_event.set() | 260 self.ready_event.set() |
262 # Keep thread running until Stop() gets called. | 261 # Keep thread running until Stop() gets called. |
263 _WaitUntil(lambda: self.stop_flag, max_attempts=sys.maxint) | 262 _WaitUntil(lambda: self.stop_flag, max_attempts=sys.maxint) |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 427 |
429 def CleanupState(self): | 428 def CleanupState(self): |
430 """Cleans up the spawning server state. | 429 """Cleans up the spawning server state. |
431 | 430 |
432 This should be called if the test server spawner is reused, | 431 This should be called if the test server spawner is reused, |
433 to avoid sharing the test server instance. | 432 to avoid sharing the test server instance. |
434 """ | 433 """ |
435 if self.server.test_server_instance: | 434 if self.server.test_server_instance: |
436 self.server.test_server_instance.Stop() | 435 self.server.test_server_instance.Stop() |
437 self.server.test_server_instance = None | 436 self.server.test_server_instance = None |
OLD | NEW |