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

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

Issue 10836323: Change Android build configurations (step 2). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unnecessary changes Created 8 years, 4 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 | « build/android/gdb_content_shell ('k') | build/android/pylib/device_stats_monitor.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 import contextlib 5 import contextlib
6 import httplib 6 import httplib
7 import logging 7 import logging
8 import os 8 import os
9 import tempfile 9 import tempfile
10 import time 10 import time
(...skipping 13 matching lines...) Expand all
24 NET_TEST_SERVER_PORT_INFO_FILE = '/data/local/tmp/net-test-server-ports' 24 NET_TEST_SERVER_PORT_INFO_FILE = '/data/local/tmp/net-test-server-ports'
25 25
26 26
27 class BaseTestRunner(object): 27 class BaseTestRunner(object):
28 """Base class for running tests on a single device. 28 """Base class for running tests on a single device.
29 29
30 A subclass should implement RunTests() with no parameter, so that calling 30 A subclass should implement RunTests() with no parameter, so that calling
31 the Run() method will set up tests, run them and tear them down. 31 the Run() method will set up tests, run them and tear them down.
32 """ 32 """
33 33
34 def __init__(self, device, tool, shard_index): 34 def __init__(self, device, tool, shard_index, build_type):
35 """ 35 """
36 Args: 36 Args:
37 device: Tests will run on the device of this ID. 37 device: Tests will run on the device of this ID.
38 shard_index: Index number of the shard on which the test suite will run. 38 shard_index: Index number of the shard on which the test suite will run.
39 build_type: 'Release' or 'Debug'.
39 """ 40 """
40 self.device = device 41 self.device = device
41 self.adb = android_commands.AndroidCommands(device=device) 42 self.adb = android_commands.AndroidCommands(device=device)
42 self.tool = CreateTool(tool, self.adb) 43 self.tool = CreateTool(tool, self.adb)
43 # Synchronize date/time between host and device. Otherwise same file on 44 # Synchronize date/time between host and device. Otherwise same file on
44 # host and device may have different timestamp which may cause 45 # host and device may have different timestamp which may cause
45 # AndroidCommands.PushIfNeeded failed, or a test which may compare timestamp 46 # AndroidCommands.PushIfNeeded failed, or a test which may compare timestamp
46 # got from http head and local time could be failed. 47 # got from http head and local time could be failed.
47 self.adb.SynchronizeDateTime() 48 self.adb.SynchronizeDateTime()
48 self._http_server = None 49 self._http_server = None
49 self._forwarder = None 50 self._forwarder = None
50 self._forwarder_device_port = 8000 51 self._forwarder_device_port = 8000
51 self.forwarder_base_url = ('http://localhost:%d' % 52 self.forwarder_base_url = ('http://localhost:%d' %
52 self._forwarder_device_port) 53 self._forwarder_device_port)
53 self.flags = FlagChanger(self.adb) 54 self.flags = FlagChanger(self.adb)
54 self.shard_index = shard_index 55 self.shard_index = shard_index
55 self.flags.AddFlags(['--disable-fre']) 56 self.flags.AddFlags(['--disable-fre'])
56 self._spawning_server = None 57 self._spawning_server = None
57 self._spawner_forwarder = None 58 self._spawner_forwarder = None
58 # We will allocate port for test server spawner when calling method 59 # We will allocate port for test server spawner when calling method
59 # LaunchChromeTestServerSpawner and allocate port for test server when 60 # LaunchChromeTestServerSpawner and allocate port for test server when
60 # starting it in TestServerThread. 61 # starting it in TestServerThread.
61 self.test_server_spawner_port = 0 62 self.test_server_spawner_port = 0
62 self.test_server_port = 0 63 self.test_server_port = 0
64 self.build_type = build_type
63 65
64 def _PushTestServerPortInfoToDevice(self): 66 def _PushTestServerPortInfoToDevice(self):
65 """Pushes the latest port information to device.""" 67 """Pushes the latest port information to device."""
66 self.adb.SetFileContents(NET_TEST_SERVER_PORT_INFO_FILE, 68 self.adb.SetFileContents(NET_TEST_SERVER_PORT_INFO_FILE,
67 '%d:%d' % (self.test_server_spawner_port, 69 '%d:%d' % (self.test_server_spawner_port,
68 self.test_server_port)) 70 self.test_server_port))
69 71
70 def Run(self): 72 def Run(self):
71 """Calls subclass functions to set up tests, run them and tear them down. 73 """Calls subclass functions to set up tests, run them and tear them down.
72 74
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 Args: 160 Args:
159 host_port_pairs: A list of (device_port, local_port) tuples to forward. 161 host_port_pairs: A list of (device_port, local_port) tuples to forward.
160 """ 162 """
161 # Sometimes the forwarder device port may be already used. We have to kill 163 # Sometimes the forwarder device port may be already used. We have to kill
162 # all forwarder processes to ensure that the forwarder can be started since 164 # all forwarder processes to ensure that the forwarder can be started since
163 # currently we can not associate the specified port to related pid. 165 # currently we can not associate the specified port to related pid.
164 self.adb.KillAll('forwarder') 166 self.adb.KillAll('forwarder')
165 if self._forwarder: 167 if self._forwarder:
166 self._forwarder.Close() 168 self._forwarder.Close()
167 self._forwarder = Forwarder( 169 self._forwarder = Forwarder(
168 self.adb, port_pairs, self.tool, '127.0.0.1') 170 self.adb, port_pairs, self.tool, '127.0.0.1', self.build_type)
169 171
170 def StartForwarderForHttpServer(self): 172 def StartForwarderForHttpServer(self):
171 """Starts a forwarder for the HTTP server. 173 """Starts a forwarder for the HTTP server.
172 174
173 The forwarder forwards HTTP requests and responses between host and device. 175 The forwarder forwards HTTP requests and responses between host and device.
174 """ 176 """
175 self.StartForwarder([(self._forwarder_device_port, self._http_server.port)]) 177 self.StartForwarder([(self._forwarder_device_port, self._http_server.port)])
176 178
177 def RestartHttpServerForwarderIfNecessary(self): 179 def RestartHttpServerForwarderIfNecessary(self):
178 """Restarts the forwarder if it's not open.""" 180 """Restarts the forwarder if it's not open."""
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 self._spawning_server.Stop() 227 self._spawning_server.Stop()
226 # Wait for 2 seconds then restart. 228 # Wait for 2 seconds then restart.
227 time.sleep(2) 229 time.sleep(2)
228 if not server_ready: 230 if not server_ready:
229 logging.error(';'.join(error_msgs)) 231 logging.error(';'.join(error_msgs))
230 raise Exception('Can not start the test spawner server.') 232 raise Exception('Can not start the test spawner server.')
231 self._PushTestServerPortInfoToDevice() 233 self._PushTestServerPortInfoToDevice()
232 self._spawner_forwarder = Forwarder( 234 self._spawner_forwarder = Forwarder(
233 self.adb, 235 self.adb,
234 [(self.test_server_spawner_port, self.test_server_spawner_port)], 236 [(self.test_server_spawner_port, self.test_server_spawner_port)],
235 self.tool, '127.0.0.1') 237 self.tool, '127.0.0.1', self.build_type)
OLDNEW
« no previous file with comments | « build/android/gdb_content_shell ('k') | build/android/pylib/device_stats_monitor.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698