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

Side by Side Diff: build/android/pylib/local/device/local_device_gtest_run.py

Issue 1854233002: Reland 2 of GN: Make breakpad_unittests & sandbox_linux_unittests use test() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@test-minor-renames
Patch Set: Fix PIE errors, fix component mode. Created 4 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 | « build/android/pylib/gtest/gtest_test_instance.py ('k') | build/android/test_runner.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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 collections 5 import collections
6 import itertools 6 import itertools
7 import os 7 import os
8 import posixpath 8 import posixpath
9 9
10 from devil.android import device_errors 10 from devil.android import device_errors
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 raise 154 raise
155 155
156 def PullAppFiles(self, device, files, directory): 156 def PullAppFiles(self, device, files, directory):
157 PullAppFilesImpl(device, self._package, files, directory) 157 PullAppFilesImpl(device, self._package, files, directory)
158 158
159 def Clear(self, device): 159 def Clear(self, device):
160 device.ClearApplicationState(self._package, permissions=self._permissions) 160 device.ClearApplicationState(self._package, permissions=self._permissions)
161 161
162 162
163 class _ExeDelegate(object): 163 class _ExeDelegate(object):
164 def __init__(self, tr, exe): 164 def __init__(self, tr, dist_dir):
165 self._exe_host_path = exe 165 self._host_dist_dir = dist_dir
166 self._exe_file_name = os.path.split(exe)[-1] 166 self._exe_file_name = os.path.basename(dist_dir)[:-len('__dist')]
167 self._exe_device_path = '%s/%s' % ( 167 self._device_dist_dir = posixpath.join(
168 constants.TEST_EXECUTABLE_DIR, self._exe_file_name) 168 constants.TEST_EXECUTABLE_DIR, os.path.basename(dist_dir))
169 deps_host_path = self._exe_host_path + '_deps'
170 if os.path.exists(deps_host_path):
171 self._deps_host_path = deps_host_path
172 self._deps_device_path = self._exe_device_path + '_deps'
173 else:
174 self._deps_host_path = None
175 self._test_run = tr 169 self._test_run = tr
176 170
177 def Install(self, device): 171 def Install(self, device):
178 # TODO(jbudorick): Look into merging this with normal data deps pushing if 172 # TODO(jbudorick): Look into merging this with normal data deps pushing if
179 # executables become supported on nonlocal environments. 173 # executables become supported on nonlocal environments.
180 host_device_tuples = [(self._exe_host_path, self._exe_device_path)] 174 device.PushChangedFiles([(self._host_dist_dir, self._device_dist_dir)],
181 if self._deps_host_path: 175 delete_device_stale=True)
182 host_device_tuples.append((self._deps_host_path, self._deps_device_path))
183 device.PushChangedFiles(host_device_tuples)
184 176
185 def Run(self, test, device, flags=None, **kwargs): 177 def Run(self, test, device, flags=None, **kwargs):
186 tool = self._test_run.GetTool(device).GetTestWrapper() 178 tool = self._test_run.GetTool(device).GetTestWrapper()
187 if tool: 179 if tool:
188 cmd = [tool] 180 cmd = [tool]
189 else: 181 else:
190 cmd = [] 182 cmd = []
191 cmd.append(self._exe_device_path) 183 cmd.append(posixpath.join(self._device_dist_dir, self._exe_file_name))
192 184
193 if test: 185 if test:
194 cmd.append('--gtest_filter=%s' % ':'.join(test)) 186 cmd.append('--gtest_filter=%s' % ':'.join(test))
195 if flags: 187 if flags:
188 # TODO(agrieve): This won't work if multiple flags are passed.
196 cmd.append(flags) 189 cmd.append(flags)
197 cwd = constants.TEST_EXECUTABLE_DIR 190 cwd = constants.TEST_EXECUTABLE_DIR
198 191
199 env = { 192 env = {
200 'LD_LIBRARY_PATH': 193 'LD_LIBRARY_PATH': self._device_dist_dir
201 '%s/%s_deps' % (constants.TEST_EXECUTABLE_DIR, self._exe_file_name),
202 } 194 }
203 try: 195 try:
204 gcov_strip_depth = os.environ['NATIVE_COVERAGE_DEPTH_STRIP'] 196 gcov_strip_depth = os.environ['NATIVE_COVERAGE_DEPTH_STRIP']
205 external = device.GetExternalStoragePath() 197 external = device.GetExternalStoragePath()
206 env['GCOV_PREFIX'] = '%s/gcov' % external 198 env['GCOV_PREFIX'] = '%s/gcov' % external
207 env['GCOV_PREFIX_STRIP'] = gcov_strip_depth 199 env['GCOV_PREFIX_STRIP'] = gcov_strip_depth
208 except (device_errors.CommandFailedError, KeyError): 200 except (device_errors.CommandFailedError, KeyError):
209 pass 201 pass
210 202
211 output = device.RunShellCommand( 203 output = device.RunShellCommand(
212 cmd, cwd=cwd, env=env, check_return=True, large_output=True, **kwargs) 204 cmd, cwd=cwd, env=env, check_return=True, large_output=True, **kwargs)
213 return output 205 return output
214 206
215 def PullAppFiles(self, device, files, directory): 207 def PullAppFiles(self, device, files, directory):
216 pass 208 pass
217 209
218 def Clear(self, device): 210 def Clear(self, device):
219 device.KillAll(self._exe_file_name, blocking=True, timeout=30, quiet=True) 211 device.KillAll(self._exe_file_name, blocking=True, timeout=30, quiet=True)
220 212
221 213
222 class LocalDeviceGtestRun(local_device_test_run.LocalDeviceTestRun): 214 class LocalDeviceGtestRun(local_device_test_run.LocalDeviceTestRun):
223 215
224 def __init__(self, env, test_instance): 216 def __init__(self, env, test_instance):
225 assert isinstance(env, local_device_environment.LocalDeviceEnvironment) 217 assert isinstance(env, local_device_environment.LocalDeviceEnvironment)
226 assert isinstance(test_instance, gtest_test_instance.GtestTestInstance) 218 assert isinstance(test_instance, gtest_test_instance.GtestTestInstance)
227 super(LocalDeviceGtestRun, self).__init__(env, test_instance) 219 super(LocalDeviceGtestRun, self).__init__(env, test_instance)
228 220
229 if self._test_instance.apk: 221 if self._test_instance.apk:
230 self._delegate = _ApkDelegate(self._test_instance) 222 self._delegate = _ApkDelegate(self._test_instance)
231 elif self._test_instance.exe: 223 elif self._test_instance.exe_dist_dir:
232 self._delegate = _ExeDelegate(self, self._test_instance.exe) 224 self._delegate = _ExeDelegate(self, self._test_instance.exe_dist_dir)
233 self._crashes = set() 225 self._crashes = set()
234 self._servers = collections.defaultdict(list) 226 self._servers = collections.defaultdict(list)
235 227
236 #override 228 #override
237 def TestPackage(self): 229 def TestPackage(self):
238 return self._test_instance.suite 230 return self._test_instance.suite
239 231
240 #override 232 #override
241 def SetUp(self): 233 def SetUp(self):
242 @local_device_test_run.handle_shard_failures_with( 234 @local_device_test_run.handle_shard_failures_with(
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 def TearDown(self): 355 def TearDown(self):
364 @local_device_test_run.handle_shard_failures 356 @local_device_test_run.handle_shard_failures
365 def individual_device_tear_down(dev): 357 def individual_device_tear_down(dev):
366 for s in self._servers.get(str(dev), []): 358 for s in self._servers.get(str(dev), []):
367 s.TearDown() 359 s.TearDown()
368 360
369 tool = self.GetTool(dev) 361 tool = self.GetTool(dev)
370 tool.CleanUpEnvironment() 362 tool.CleanUpEnvironment()
371 363
372 self._env.parallel_devices.pMap(individual_device_tear_down) 364 self._env.parallel_devices.pMap(individual_device_tear_down)
OLDNEW
« no previous file with comments | « build/android/pylib/gtest/gtest_test_instance.py ('k') | build/android/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698