| 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 # TODO(jbudorick) Deprecate and remove this class and all subclasses after | 7 # TODO(jbudorick) Deprecate and remove this class and all subclasses after |
| 8 # any relevant parts have been ported to the new environment + test instance | 8 # any relevant parts have been ported to the new environment + test instance |
| 9 # model. | 9 # model. |
| 10 | 10 |
| 11 import logging | 11 import logging |
| 12 | 12 |
| 13 from devil.android import device_utils | 13 from devil.android import device_utils |
| 14 from devil.android import forwarder | 14 from devil.android import forwarder |
| 15 from devil.android import ports | 15 from devil.android import ports |
| 16 from pylib.valgrind_tools import CreateTool | 16 from pylib.valgrind_tools import CreateTool |
| 17 # TODO(frankf): Move this to pylib/utils | 17 # TODO(frankf): Move this to pylib/utils |
| 18 import lighttpd_server | |
| 19 | 18 |
| 20 | 19 |
| 21 # A file on device to store ports of net test server. The format of the file is | 20 # A file on device to store ports of net test server. The format of the file is |
| 22 # test-spawner-server-port:test-server-port | 21 # test-spawner-server-port:test-server-port |
| 23 NET_TEST_SERVER_PORT_INFO_FILE = 'net-test-server-ports' | 22 NET_TEST_SERVER_PORT_INFO_FILE = 'net-test-server-ports' |
| 24 | 23 |
| 25 | 24 |
| 26 class BaseTestRunner(object): | 25 class BaseTestRunner(object): |
| 27 """Base class for running tests on a single device.""" | 26 """Base class for running tests on a single device.""" |
| 28 | 27 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 78 |
| 80 def LaunchTestHttpServer(self, document_root, port=None, | 79 def LaunchTestHttpServer(self, document_root, port=None, |
| 81 extra_config_contents=None): | 80 extra_config_contents=None): |
| 82 """Launches an HTTP server to serve HTTP tests. | 81 """Launches an HTTP server to serve HTTP tests. |
| 83 | 82 |
| 84 Args: | 83 Args: |
| 85 document_root: Document root of the HTTP server. | 84 document_root: Document root of the HTTP server. |
| 86 port: port on which we want to the http server bind. | 85 port: port on which we want to the http server bind. |
| 87 extra_config_contents: Extra config contents for the HTTP server. | 86 extra_config_contents: Extra config contents for the HTTP server. |
| 88 """ | 87 """ |
| 88 import lighttpd_server |
| 89 self._http_server = lighttpd_server.LighttpdServer( | 89 self._http_server = lighttpd_server.LighttpdServer( |
| 90 document_root, port=port, extra_config_contents=extra_config_contents) | 90 document_root, port=port, extra_config_contents=extra_config_contents) |
| 91 if self._http_server.StartupHttpServer(): | 91 if self._http_server.StartupHttpServer(): |
| 92 logging.info('http server started: http://localhost:%s', | 92 logging.info('http server started: http://localhost:%s', |
| 93 self._http_server.port) | 93 self._http_server.port) |
| 94 else: | 94 else: |
| 95 logging.critical('Failed to start http server') | 95 logging.critical('Failed to start http server') |
| 96 self._ForwardPortsForHttpServer() | 96 self._ForwardPortsForHttpServer() |
| 97 return (self._forwarder_device_port, self._http_server.port) | 97 return (self._forwarder_device_port, self._http_server.port) |
| 98 | 98 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 129 # will be left open even after the forwarder has been killed. | 129 # will be left open even after the forwarder has been killed. |
| 130 if not ports.IsDevicePortUsed(self.device, self._forwarder_device_port): | 130 if not ports.IsDevicePortUsed(self.device, self._forwarder_device_port): |
| 131 self._ForwardPortsForHttpServer() | 131 self._ForwardPortsForHttpServer() |
| 132 | 132 |
| 133 def ShutdownHelperToolsForTestSuite(self): | 133 def ShutdownHelperToolsForTestSuite(self): |
| 134 """Shuts down the server and the forwarder.""" | 134 """Shuts down the server and the forwarder.""" |
| 135 if self._http_server: | 135 if self._http_server: |
| 136 self._UnmapPorts([(self._forwarder_device_port, self._http_server.port)]) | 136 self._UnmapPorts([(self._forwarder_device_port, self._http_server.port)]) |
| 137 self._http_server.ShutdownHttpServer() | 137 self._http_server.ShutdownHttpServer() |
| 138 | 138 |
| OLD | NEW |