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

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

Issue 415463002: [Android] Configurable instrumentation test runner + test SDK levels. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 return 5 * 60 327 return 5 * 60
328 if 'MediumTest' in annotations: 328 if 'MediumTest' in annotations:
329 return 3 * 60 329 return 3 * 60
330 if 'SmallTest' in annotations: 330 if 'SmallTest' in annotations:
331 return 1 * 60 331 return 1 * 60
332 332
333 logging.warn(("Test size not found in annotations for test '{0}', using " + 333 logging.warn(("Test size not found in annotations for test '{0}', using " +
334 "1 minute for timeout.").format(test)) 334 "1 minute for timeout.").format(test))
335 return 1 * 60 335 return 1 * 60
336 336
337 def RunInstrumentationTest(self, test, test_package, instr_args, timeout):
338 """Runs a single instrumentation test.
339
340 Args:
341 test: Test class/method.
342 test_package: Package name of test apk.
343 instr_args: Extra key/value to pass to am instrument.
344 timeout: Timeout time in seconds.
345
346 Returns:
347 An instance of am_instrument_parser.TestResult object.
348 """
349 instrumentation_path = (
350 '%s/%s' % (test_package, self.options.test_runner))
351 args_with_filter = dict(instr_args)
352 args_with_filter['class'] = test
353 logging.info(args_with_filter)
354 (raw_results, _) = self.device.old_interface.Adb().StartInstrumentation(
355 instrumentation_path=instrumentation_path,
356 instrumentation_args=args_with_filter,
357 timeout_time=timeout)
358 assert len(raw_results) == 1
359 return raw_results[0]
360
361
337 def _RunTest(self, test, timeout): 362 def _RunTest(self, test, timeout):
338 try: 363 try:
339 return self.device.old_interface.RunInstrumentationTest( 364 return self.RunInstrumentationTest(
340 test, self.test_pkg.GetPackageName(), 365 test, self.test_pkg.GetPackageName(),
341 self._GetInstrumentationArgs(), timeout) 366 self._GetInstrumentationArgs(), timeout)
342 except (device_errors.CommandTimeoutError, 367 except (device_errors.CommandTimeoutError,
343 # TODO(jbudorick) Remove this once the underlying implementations 368 # TODO(jbudorick) Remove this once the underlying implementations
344 # for the above are switched or wrapped. 369 # for the above are switched or wrapped.
345 android_commands.errors.WaitForResponseTimedOutError): 370 android_commands.errors.WaitForResponseTimedOutError):
346 logging.info('Ran the test with timeout of %ds.' % timeout) 371 logging.info('Ran the test with timeout of %ds.' % timeout)
347 raise 372 raise
348 373
349 #override 374 #override
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 duration_ms = 0 418 duration_ms = 0
394 message = str(e) 419 message = str(e)
395 if not message: 420 if not message:
396 message = 'No information.' 421 message = 'No information.'
397 results.AddResult(test_result.InstrumentationTestResult( 422 results.AddResult(test_result.InstrumentationTestResult(
398 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, 423 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms,
399 log=message)) 424 log=message))
400 raw_result = None 425 raw_result = None
401 self.TestTeardown(test, raw_result) 426 self.TestTeardown(test, raw_result)
402 return (results, None if results.DidRunPass() else test) 427 return (results, None if results.DidRunPass() else test)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698