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

Side by Side Diff: build/android/pylib/instrumentation/test_runner.py

Issue 1315743004: [Android] Add a custom pylintrc for build/android/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 """Class for running instrumentation tests on a single device.""" 5 """Class for running instrumentation tests on a single device."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import re 9 import re
10 import sys 10 import sys
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 valgrind_tools.SetChromeTimeoutScale(self.device, timeout_scale) 267 valgrind_tools.SetChromeTimeoutScale(self.device, timeout_scale)
268 268
269 def _GetIndividualTestTimeoutScale(self, test): 269 def _GetIndividualTestTimeoutScale(self, test):
270 """Returns the timeout scale for the given |test|.""" 270 """Returns the timeout scale for the given |test|."""
271 annotations = self.test_pkg.GetTestAnnotations(test) 271 annotations = self.test_pkg.GetTestAnnotations(test)
272 timeout_scale = 1 272 timeout_scale = 1
273 if 'TimeoutScale' in annotations: 273 if 'TimeoutScale' in annotations:
274 try: 274 try:
275 timeout_scale = int(annotations['TimeoutScale']) 275 timeout_scale = int(annotations['TimeoutScale'])
276 except ValueError: 276 except ValueError:
277 logging.warning('Non-integer value of TimeoutScale ignored. (%s)' 277 logging.warning('Non-integer value of TimeoutScale ignored. (%s)',
278 % annotations['TimeoutScale']) 278 annotations['TimeoutScale'])
279 if self.options.wait_for_debugger: 279 if self.options.wait_for_debugger:
280 timeout_scale *= 100 280 timeout_scale *= 100
281 return timeout_scale 281 return timeout_scale
282 282
283 # pylint: disable=too-many-return-statements
283 def _GetIndividualTestTimeoutSecs(self, test): 284 def _GetIndividualTestTimeoutSecs(self, test):
284 """Returns the timeout in seconds for the given |test|.""" 285 """Returns the timeout in seconds for the given |test|."""
285 annotations = self.test_pkg.GetTestAnnotations(test) 286 annotations = self.test_pkg.GetTestAnnotations(test)
286 if 'Manual' in annotations: 287 if 'Manual' in annotations:
287 return 10 * 60 * 60 288 return 10 * 60 * 60
288 if 'IntegrationTest' in annotations: 289 if 'IntegrationTest' in annotations:
289 return 30 * 60 290 return 30 * 60
290 if 'External' in annotations: 291 if 'External' in annotations:
291 return 10 * 60 292 return 10 * 60
292 if 'EnormousTest' in annotations: 293 if 'EnormousTest' in annotations:
293 return 10 * 60 294 return 10 * 60
294 if 'LargeTest' in annotations or _PERF_TEST_ANNOTATION in annotations: 295 if 'LargeTest' in annotations or _PERF_TEST_ANNOTATION in annotations:
295 return 5 * 60 296 return 5 * 60
296 if 'MediumTest' in annotations: 297 if 'MediumTest' in annotations:
297 return 3 * 60 298 return 3 * 60
298 if 'SmallTest' in annotations: 299 if 'SmallTest' in annotations:
299 return 1 * 60 300 return 1 * 60
300 301
301 logging.warn(("Test size not found in annotations for test '%s', using " + 302 logging.warn("Test size not found in annotations for test '%s', using " +
302 "1 minute for timeout.") % test) 303 "1 minute for timeout.", test)
303 return 1 * 60 304 return 1 * 60
304 305
305 def _RunTest(self, test, timeout): 306 def _RunTest(self, test, timeout):
306 """Runs a single instrumentation test. 307 """Runs a single instrumentation test.
307 308
308 Args: 309 Args:
309 test: Test class/method. 310 test: Test class/method.
310 timeout: Timeout time in seconds. 311 timeout: Timeout time in seconds.
311 312
312 Returns: 313 Returns:
313 The raw output of am instrument as a list of lines. 314 The raw output of am instrument as a list of lines.
314 """ 315 """
315 extras = self._GetInstrumentationArgs() 316 extras = self._GetInstrumentationArgs()
316 extras['class'] = test 317 extras['class'] = test
317 return self.device.StartInstrumentation( 318 return self.device.StartInstrumentation(
318 '%s/%s' % (self.test_pkg.GetPackageName(), self.options.test_runner), 319 '%s/%s' % (self.test_pkg.GetPackageName(), self.options.test_runner),
319 raw=True, extras=extras, timeout=timeout, retries=3) 320 raw=True, extras=extras, timeout=timeout, retries=3)
320 321
322 # pylint: disable=no-self-use
321 def _GenerateTestResult(self, test, instr_result_code, instr_result_bundle, 323 def _GenerateTestResult(self, test, instr_result_code, instr_result_bundle,
322 statuses, start_ms, duration_ms): 324 statuses, start_ms, duration_ms):
323 results = instrumentation_test_instance.GenerateTestResults( 325 results = instrumentation_test_instance.GenerateTestResults(
324 instr_result_code, instr_result_bundle, statuses, start_ms, duration_ms) 326 instr_result_code, instr_result_bundle, statuses, start_ms, duration_ms)
325 for r in results: 327 for r in results:
326 if r.GetName() == test: 328 if r.GetName() == test:
327 return r 329 return r
328 logging.error('Could not find result for test: %s', test) 330 logging.error('Could not find result for test: %s', test)
329 return test_result.InstrumentationTestResult( 331 return test_result.InstrumentationTestResult(
330 test, base_test_result.ResultType.UNKNOWN, start_ms, duration_ms) 332 test, base_test_result.ResultType.UNKNOWN, start_ms, duration_ms)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 except device_errors.CommandTimeoutError as e: 365 except device_errors.CommandTimeoutError as e:
364 results.AddResult(test_result.InstrumentationTestResult( 366 results.AddResult(test_result.InstrumentationTestResult(
365 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, 367 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms,
366 log=str(e) or 'No information')) 368 log=str(e) or 'No information'))
367 except device_errors.DeviceUnreachableError as e: 369 except device_errors.DeviceUnreachableError as e:
368 results.AddResult(test_result.InstrumentationTestResult( 370 results.AddResult(test_result.InstrumentationTestResult(
369 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, 371 test, base_test_result.ResultType.CRASH, start_ms, duration_ms,
370 log=str(e) or 'No information')) 372 log=str(e) or 'No information'))
371 self.TestTeardown(test, results) 373 self.TestTeardown(test, results)
372 return (results, None if results.DidRunPass() else test) 374 return (results, None if results.DidRunPass() else test)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698