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

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

Powered by Google App Engine
This is Rietveld 408576698