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

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

Issue 2032253004: [Android] Ensure test names are unique during retry determination. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed Created 4 years, 6 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/local/device/local_device_test_run.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 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 logging 5 import logging
6 import os 6 import os
7 import posixpath 7 import posixpath
8 import re 8 import re
9 import time 9 import time
10 10
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 device, self._test_instance.package_info.cmdline_file) 167 device, self._test_instance.package_info.cmdline_file)
168 168
169 #override 169 #override
170 def _CreateShards(self, tests): 170 def _CreateShards(self, tests):
171 return tests 171 return tests
172 172
173 #override 173 #override
174 def _GetTests(self): 174 def _GetTests(self):
175 return self._test_instance.GetTests() 175 return self._test_instance.GetTests()
176 176
177 #override
178 def _GetTestName(self, test): 177 def _GetTestName(self, test):
178 # pylint: disable=no-self-use
179 return '%s#%s' % (test['class'], test['method']) 179 return '%s#%s' % (test['class'], test['method'])
180 180
181 def _GetTestNameForDisplay(self, test): 181 #override
182 def _GetUniqueTestName(self, test):
182 display_name = self._GetTestName(test) 183 display_name = self._GetTestName(test)
183 flags = test['flags'] 184 if 'flags' in test:
184 if flags.add: 185 flags = test['flags']
185 display_name = '%s with {%s}' % (display_name, ' '.join(flags.add)) 186 if flags.add:
186 if flags.remove: 187 display_name = '%s with {%s}' % (display_name, ' '.join(flags.add))
187 display_name = '%s without {%s}' % (display_name, ' '.join(flags.remove)) 188 if flags.remove:
189 display_name = '%s without {%s}' % (
190 display_name, ' '.join(flags.remove))
188 return display_name 191 return display_name
189 192
190 #override 193 #override
191 def _RunTest(self, device, test): 194 def _RunTest(self, device, test):
192 extras = {} 195 extras = {}
193 196
194 flags = None 197 flags = None
195 test_timeout_scale = None 198 test_timeout_scale = None
196 if self._test_instance.coverage_directory: 199 if self._test_instance.coverage_directory:
197 coverage_basename = '%s.ec' % ('%s_group' % test[0]['method'] 200 coverage_basename = '%s.ec' % ('%s_group' % test[0]['method']
(...skipping 21 matching lines...) Expand all
219 test_display_name = test_name 222 test_display_name = test_name
220 target = '%s/%s' % ( 223 target = '%s/%s' % (
221 self._test_instance.driver_package, 224 self._test_instance.driver_package,
222 self._test_instance.driver_name) 225 self._test_instance.driver_name)
223 extras.update( 226 extras.update(
224 self._test_instance.GetDriverEnvironmentVars( 227 self._test_instance.GetDriverEnvironmentVars(
225 test_list=test_names)) 228 test_list=test_names))
226 timeout = sum(timeouts) 229 timeout = sum(timeouts)
227 else: 230 else:
228 test_name = self._GetTestName(test) 231 test_name = self._GetTestName(test)
229 test_display_name = test_name 232 test_display_name = self._GetUniqueTestName(test)
230 target = '%s/%s' % ( 233 target = '%s/%s' % (
231 self._test_instance.test_package, self._test_instance.test_runner) 234 self._test_instance.test_package, self._test_instance.test_runner)
232 extras['class'] = test_name 235 extras['class'] = test_name
233 if 'flags' in test: 236 if 'flags' in test:
234 flags = test['flags'] 237 flags = test['flags']
235 test_display_name = self._GetTestNameForDisplay(test)
236 timeout = self._GetTimeoutFromAnnotations( 238 timeout = self._GetTimeoutFromAnnotations(
237 test['annotations'], test_display_name) 239 test['annotations'], test_display_name)
238 240
239 test_timeout_scale = self._GetTimeoutScaleFromAnnotations( 241 test_timeout_scale = self._GetTimeoutScaleFromAnnotations(
240 test['annotations']) 242 test['annotations'])
241 if test_timeout_scale and test_timeout_scale != 1: 243 if test_timeout_scale and test_timeout_scale != 1:
242 valgrind_tools.SetChromeTimeoutScale( 244 valgrind_tools.SetChromeTimeoutScale(
243 device, test_timeout_scale * self._test_instance.timeout_scale) 245 device, test_timeout_scale * self._test_instance.timeout_scale)
244 246
245 logging.info('preparing to run %s: %s', test_display_name, test) 247 logging.info('preparing to run %s: %s', test_display_name, test)
(...skipping 16 matching lines...) Expand all
262 valgrind_tools.SetChromeTimeoutScale( 264 valgrind_tools.SetChromeTimeoutScale(
263 device, self._test_instance.timeout_scale) 265 device, self._test_instance.timeout_scale)
264 266
265 # TODO(jbudorick): Make instrumentation tests output a JSON so this 267 # TODO(jbudorick): Make instrumentation tests output a JSON so this
266 # doesn't have to parse the output. 268 # doesn't have to parse the output.
267 result_code, result_bundle, statuses = ( 269 result_code, result_bundle, statuses = (
268 self._test_instance.ParseAmInstrumentRawOutput(output)) 270 self._test_instance.ParseAmInstrumentRawOutput(output))
269 results = self._test_instance.GenerateTestResults( 271 results = self._test_instance.GenerateTestResults(
270 result_code, result_bundle, statuses, start_ms, duration_ms) 272 result_code, result_bundle, statuses, start_ms, duration_ms)
271 273
272 # Add UNKNOWN results for any missing tests.
273 iterable_test = test if isinstance(test, list) else [test]
274 test_names = set(self._GetTestName(t) for t in iterable_test)
275 results_names = set(r.GetName() for r in results)
276 results.extend(
277 base_test_result.BaseTestResult(u, base_test_result.ResultType.UNKNOWN)
278 for u in test_names.difference(results_names))
279
280 # Update the result name if the test used flags. 274 # Update the result name if the test used flags.
281 if flags: 275 if flags:
282 for r in results: 276 for r in results:
283 if r.GetName() == test_name: 277 if r.GetName() == test_name:
284 r.SetName(test_display_name) 278 r.SetName(test_display_name)
285 279
280 # Add UNKNOWN results for any missing tests.
281 iterable_test = test if isinstance(test, list) else [test]
282 test_names = set(self._GetUniqueTestName(t) for t in iterable_test)
283 results_names = set(r.GetName() for r in results)
284 results.extend(
285 base_test_result.BaseTestResult(u, base_test_result.ResultType.UNKNOWN)
286 for u in test_names.difference(results_names))
287
286 # Update the result type if we detect a crash. 288 # Update the result type if we detect a crash.
287 if DidPackageCrashOnDevice(self._test_instance.test_package, device): 289 if DidPackageCrashOnDevice(self._test_instance.test_package, device):
288 for r in results: 290 for r in results:
289 if r.GetType() == base_test_result.ResultType.UNKNOWN: 291 if r.GetType() == base_test_result.ResultType.UNKNOWN:
290 r.SetType(base_test_result.ResultType.CRASH) 292 r.SetType(base_test_result.ResultType.CRASH)
291 293
292 # Handle failures by: 294 # Handle failures by:
293 # - optionally taking a screenshot 295 # - optionally taking a screenshot
294 # - logging the raw output at INFO level 296 # - logging the raw output at INFO level
295 # - clearing the application state while persisting permissions 297 # - clearing the application state while persisting permissions
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 timeout = v 349 timeout = v
348 break 350 break
349 else: 351 else:
350 logging.warning('Using default 1 minute timeout for %s', test_name) 352 logging.warning('Using default 1 minute timeout for %s', test_name)
351 timeout = 60 353 timeout = 60
352 354
353 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) 355 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations)
354 356
355 return timeout 357 return timeout
356 358
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/local/device/local_device_test_run.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698