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 """Base class for running tests on a single device.""" | 5 """Base class for running tests on a single device.""" |
6 | 6 |
7 import contextlib | 7 import contextlib |
8 import httplib | 8 import httplib |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 if self._http_server.StartupHttpServer(): | 117 if self._http_server.StartupHttpServer(): |
118 logging.info('http server started: http://localhost:%s', | 118 logging.info('http server started: http://localhost:%s', |
119 self._http_server.port) | 119 self._http_server.port) |
120 else: | 120 else: |
121 logging.critical('Failed to start http server') | 121 logging.critical('Failed to start http server') |
122 self._ForwardPortsForHttpServer() | 122 self._ForwardPortsForHttpServer() |
123 return (self._forwarder_device_port, self._http_server.port) | 123 return (self._forwarder_device_port, self._http_server.port) |
124 | 124 |
125 def _ForwardPorts(self, port_pairs): | 125 def _ForwardPorts(self, port_pairs): |
126 """Forwards a port.""" | 126 """Forwards a port.""" |
127 Forwarder.Map(port_pairs, self.adb, constants.GetBuildType(), self.tool) | 127 Forwarder.Map(port_pairs, self.adb, self.tool) |
128 | 128 |
129 def _UnmapPorts(self, port_pairs): | 129 def _UnmapPorts(self, port_pairs): |
130 """Unmap previously forwarded ports.""" | 130 """Unmap previously forwarded ports.""" |
131 for (device_port, _) in port_pairs: | 131 for (device_port, _) in port_pairs: |
132 Forwarder.UnmapDevicePort(device_port, self.adb) | 132 Forwarder.UnmapDevicePort(device_port, self.adb) |
133 | 133 |
134 # Deprecated: Use ForwardPorts instead. | 134 # Deprecated: Use ForwardPorts instead. |
135 def StartForwarder(self, port_pairs): | 135 def StartForwarder(self, port_pairs): |
136 """Starts TCP traffic forwarding for the given |port_pairs|. | 136 """Starts TCP traffic forwarding for the given |port_pairs|. |
137 | 137 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 break | 196 break |
197 else: | 197 else: |
198 error_msgs.append(error_msg) | 198 error_msgs.append(error_msg) |
199 self._spawning_server.Stop() | 199 self._spawning_server.Stop() |
200 # Wait for 2 seconds then restart. | 200 # Wait for 2 seconds then restart. |
201 time.sleep(2) | 201 time.sleep(2) |
202 if not server_ready: | 202 if not server_ready: |
203 logging.error(';'.join(error_msgs)) | 203 logging.error(';'.join(error_msgs)) |
204 raise Exception('Can not start the test spawner server.') | 204 raise Exception('Can not start the test spawner server.') |
205 self._PushTestServerPortInfoToDevice() | 205 self._PushTestServerPortInfoToDevice() |
OLD | NEW |