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

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

Issue 23467004: [android] Update FlagChanger to work with additional apks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | build/android/pylib/constants.py » ('j') | build/android/pylib/flag_changer.py » ('J')
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 import contextlib 7 import contextlib
8 import httplib 8 import httplib
9 import logging 9 import logging
10 import os 10 import os
11 import tempfile 11 import tempfile
12 import time 12 import time
13 13
14 from pylib import android_commands 14 from pylib import android_commands
15 from pylib import constants 15 from pylib import constants
16 from pylib import ports 16 from pylib import ports
17 from pylib.chrome_test_server_spawner import SpawningServer 17 from pylib.chrome_test_server_spawner import SpawningServer
18 from pylib.flag_changer import FlagChanger
19 from pylib.forwarder import Forwarder 18 from pylib.forwarder import Forwarder
20 from pylib.valgrind_tools import CreateTool 19 from pylib.valgrind_tools import CreateTool
21 # TODO(frankf): Move this to pylib/utils 20 # TODO(frankf): Move this to pylib/utils
22 import lighttpd_server 21 import lighttpd_server
23 22
24 23
25 # A file on device to store ports of net test server. The format of the file is 24 # A file on device to store ports of net test server. The format of the file is
26 # test-spawner-server-port:test-server-port 25 # test-spawner-server-port:test-server-port
27 NET_TEST_SERVER_PORT_INFO_FILE = 'net-test-server-ports' 26 NET_TEST_SERVER_PORT_INFO_FILE = 'net-test-server-ports'
28 27
29 28
30 class BaseTestRunner(object): 29 class BaseTestRunner(object):
31 """Base class for running tests on a single device.""" 30 """Base class for running tests on a single device."""
32 31
33 def __init__(self, device, tool, push_deps=True, cleanup_test_files=False): 32 def __init__(self, device, tool, push_deps=True, cleanup_test_files=False):
34 """ 33 """
35 Args: 34 Args:
36 device: Tests will run on the device of this ID. 35 device: Tests will run on the device of this ID.
37 tool: Name of the Valgrind tool. 36 tool: Name of the Valgrind tool.
38 push_deps: If True, push all dependencies to the device. 37 push_deps: If True, push all dependencies to the device.
39 cleanup_test_files: Whether or not to cleanup test files on device. 38 cleanup_test_files: Whether or not to cleanup test files on device.
40 """ 39 """
41 self.device = device 40 self.device = device
42 self.adb = android_commands.AndroidCommands(device=device) 41 self.adb = android_commands.AndroidCommands(device=device)
43 self.tool = CreateTool(tool, self.adb) 42 self.tool = CreateTool(tool, self.adb)
44 self._http_server = None 43 self._http_server = None
45 self._forwarder_device_port = 8000 44 self._forwarder_device_port = 8000
46 self.forwarder_base_url = ('http://localhost:%d' % 45 self.forwarder_base_url = ('http://localhost:%d' %
47 self._forwarder_device_port) 46 self._forwarder_device_port)
48 self.flags = FlagChanger(self.adb)
49 self.flags.AddFlags(['--disable-fre'])
50 self._spawning_server = None 47 self._spawning_server = None
51 # We will allocate port for test server spawner when calling method 48 # We will allocate port for test server spawner when calling method
52 # LaunchChromeTestServerSpawner and allocate port for test server when 49 # LaunchChromeTestServerSpawner and allocate port for test server when
53 # starting it in TestServerThread. 50 # starting it in TestServerThread.
54 self.test_server_spawner_port = 0 51 self.test_server_spawner_port = 0
55 self.test_server_port = 0 52 self.test_server_port = 0
56 self._push_deps = push_deps 53 self._push_deps = push_deps
57 self._cleanup_test_files = cleanup_test_files 54 self._cleanup_test_files = cleanup_test_files
58 55
59 def _PushTestServerPortInfoToDevice(self): 56 def _PushTestServerPortInfoToDevice(self):
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 if not ports.IsDevicePortUsed(self.adb, self._forwarder_device_port): 156 if not ports.IsDevicePortUsed(self.adb, self._forwarder_device_port):
160 self._ForwardPortsForHttpServer() 157 self._ForwardPortsForHttpServer()
161 158
162 def ShutdownHelperToolsForTestSuite(self): 159 def ShutdownHelperToolsForTestSuite(self):
163 """Shuts down the server and the forwarder.""" 160 """Shuts down the server and the forwarder."""
164 if self._http_server: 161 if self._http_server:
165 self._UnmapPorts([(self._forwarder_device_port, self._http_server.port)]) 162 self._UnmapPorts([(self._forwarder_device_port, self._http_server.port)])
166 self._http_server.ShutdownHttpServer() 163 self._http_server.ShutdownHttpServer()
167 if self._spawning_server: 164 if self._spawning_server:
168 self._spawning_server.Stop() 165 self._spawning_server.Stop()
169 self.flags.Restore()
170 166
171 def CleanupSpawningServerState(self): 167 def CleanupSpawningServerState(self):
172 """Tells the spawning server to clean up any state. 168 """Tells the spawning server to clean up any state.
173 169
174 If the spawning server is reused for multiple tests, this should be called 170 If the spawning server is reused for multiple tests, this should be called
175 after each test to prevent tests affecting each other. 171 after each test to prevent tests affecting each other.
176 """ 172 """
177 if self._spawning_server: 173 if self._spawning_server:
178 self._spawning_server.CleanupState() 174 self._spawning_server.CleanupState()
179 175
(...skipping 20 matching lines...) Expand all
200 break 196 break
201 else: 197 else:
202 error_msgs.append(error_msg) 198 error_msgs.append(error_msg)
203 self._spawning_server.Stop() 199 self._spawning_server.Stop()
204 # Wait for 2 seconds then restart. 200 # Wait for 2 seconds then restart.
205 time.sleep(2) 201 time.sleep(2)
206 if not server_ready: 202 if not server_ready:
207 logging.error(';'.join(error_msgs)) 203 logging.error(';'.join(error_msgs))
208 raise Exception('Can not start the test spawner server.') 204 raise Exception('Can not start the test spawner server.')
209 self._PushTestServerPortInfoToDevice() 205 self._PushTestServerPortInfoToDevice()
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/constants.py » ('j') | build/android/pylib/flag_changer.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698