Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: build/android/pylib/base/base_test_runner.py

Issue 1050883002: [Android] Reland cleanup of old_interface in build/android/pylib. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build/android/pylib/device/device_utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 pylib import ports 13 from pylib import ports
14 from pylib.device import device_utils 14 from pylib.device import device_utils
15 from pylib.forwarder import Forwarder 15 from pylib.forwarder import Forwarder
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 18 import lighttpd_server
19 19
20 20
21 # A file on device to store ports of net test server. The format of the file is 21 # 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 22 # test-spawner-server-port:test-server-port
23 NET_TEST_SERVER_PORT_INFO_FILE = 'net-test-server-ports' 23 NET_TEST_SERVER_PORT_INFO_FILE = 'net-test-server-ports'
24 24
25 25
26 class BaseTestRunner(object): 26 class BaseTestRunner(object):
27 """Base class for running tests on a single device.""" 27 """Base class for running tests on a single device."""
28 28
29 def __init__(self, device_serial, tool, cleanup_test_files=False): 29 def __init__(self, device_serial, tool):
30 """ 30 """
31 Args: 31 Args:
32 device: Tests will run on the device of this ID. 32 device: Tests will run on the device of this ID.
33 tool: Name of the Valgrind tool. 33 tool: Name of the Valgrind tool.
34 cleanup_test_files: Whether or not to cleanup test files on device.
35 """ 34 """
36 self.device_serial = device_serial 35 self.device_serial = device_serial
37 self.device = device_utils.DeviceUtils(device_serial) 36 self.device = device_utils.DeviceUtils(device_serial)
38 self.tool = CreateTool(tool, self.device) 37 self.tool = CreateTool(tool, self.device)
39 self._http_server = None 38 self._http_server = None
40 self._forwarder_device_port = 8000 39 self._forwarder_device_port = 8000
41 self.forwarder_base_url = ('http://localhost:%d' % 40 self.forwarder_base_url = ('http://localhost:%d' %
42 self._forwarder_device_port) 41 self._forwarder_device_port)
43 # We will allocate port for test server spawner when calling method 42 # We will allocate port for test server spawner when calling method
44 # LaunchChromeTestServerSpawner and allocate port for test server when 43 # LaunchChromeTestServerSpawner and allocate port for test server when
45 # starting it in TestServerThread. 44 # starting it in TestServerThread.
46 self.test_server_spawner_port = 0 45 self.test_server_spawner_port = 0
47 self.test_server_port = 0 46 self.test_server_port = 0
48 self._cleanup_test_files = cleanup_test_files
49 47
50 def _PushTestServerPortInfoToDevice(self): 48 def _PushTestServerPortInfoToDevice(self):
51 """Pushes the latest port information to device.""" 49 """Pushes the latest port information to device."""
52 self.device.WriteFile( 50 self.device.WriteFile(
53 self.device.GetExternalStoragePath() + '/' + 51 self.device.GetExternalStoragePath() + '/' +
54 NET_TEST_SERVER_PORT_INFO_FILE, 52 NET_TEST_SERVER_PORT_INFO_FILE,
55 '%d:%d' % (self.test_server_spawner_port, self.test_server_port)) 53 '%d:%d' % (self.test_server_spawner_port, self.test_server_port))
56 54
57 def RunTest(self, test): 55 def RunTest(self, test):
58 """Runs a test. Needs to be overridden. 56 """Runs a test. Needs to be overridden.
(...skipping 11 matching lines...) Expand all
70 """Installs the test package once before all tests are run.""" 68 """Installs the test package once before all tests are run."""
71 pass 69 pass
72 70
73 def SetUp(self): 71 def SetUp(self):
74 """Run once before all tests are run.""" 72 """Run once before all tests are run."""
75 self.InstallTestPackage() 73 self.InstallTestPackage()
76 74
77 def TearDown(self): 75 def TearDown(self):
78 """Run once after all tests are run.""" 76 """Run once after all tests are run."""
79 self.ShutdownHelperToolsForTestSuite() 77 self.ShutdownHelperToolsForTestSuite()
80 if self._cleanup_test_files:
81 self.device.old_interface.RemovePushedFiles()
82 78
83 def LaunchTestHttpServer(self, document_root, port=None, 79 def LaunchTestHttpServer(self, document_root, port=None,
84 extra_config_contents=None): 80 extra_config_contents=None):
85 """Launches an HTTP server to serve HTTP tests. 81 """Launches an HTTP server to serve HTTP tests.
86 82
87 Args: 83 Args:
88 document_root: Document root of the HTTP server. 84 document_root: Document root of the HTTP server.
89 port: port on which we want to the http server bind. 85 port: port on which we want to the http server bind.
90 extra_config_contents: Extra config contents for the HTTP server. 86 extra_config_contents: Extra config contents for the HTTP server.
91 """ 87 """
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 # will be left open even after the forwarder has been killed. 128 # will be left open even after the forwarder has been killed.
133 if not ports.IsDevicePortUsed(self.device, self._forwarder_device_port): 129 if not ports.IsDevicePortUsed(self.device, self._forwarder_device_port):
134 self._ForwardPortsForHttpServer() 130 self._ForwardPortsForHttpServer()
135 131
136 def ShutdownHelperToolsForTestSuite(self): 132 def ShutdownHelperToolsForTestSuite(self):
137 """Shuts down the server and the forwarder.""" 133 """Shuts down the server and the forwarder."""
138 if self._http_server: 134 if self._http_server:
139 self._UnmapPorts([(self._forwarder_device_port, self._http_server.port)]) 135 self._UnmapPorts([(self._forwarder_device_port, self._http_server.port)])
140 self._http_server.ShutdownHttpServer() 136 self._http_server.ShutdownHttpServer()
141 137
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/device/device_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698