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

Side by Side Diff: build/android/pylib/single_test_runner.py

Issue 11232037: Retry tests on other bots if the device is unresponsive/offline (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: small improvement Created 8 years, 2 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 | Annotate | Revision Log
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 import glob 5 import glob
6 import logging 6 import logging
7 import os 7 import os
8 import sys 8 import sys
9 9
10 from base_test_runner import BaseTestRunner 10 from base_test_runner import BaseTestRunner
11 import android_commands
11 import debug_info 12 import debug_info
12 import constants 13 import constants
13 import perf_tests_helper 14 import perf_tests_helper
14 import run_tests_helper 15 import run_tests_helper
16 from android_commands import errors
15 from test_package_apk import TestPackageApk 17 from test_package_apk import TestPackageApk
16 from test_package_executable import TestPackageExecutable 18 from test_package_executable import TestPackageExecutable
17 from test_result import TestResults 19 from test_result import BaseTestResult, TestResults
18 20
19 21
20 class SingleTestRunner(BaseTestRunner): 22 class SingleTestRunner(BaseTestRunner):
21 """Single test suite attached to a single device. 23 """Single test suite attached to a single device.
22 24
23 Args: 25 Args:
24 device: Device to run the tests. 26 device: Device to run the tests.
25 test_suite: A specific test suite to run, empty to run all. 27 test_suite: A specific test suite to run, empty to run all.
26 gtest_filter: A gtest_filter flag. 28 gtest_filter: A gtest_filter flag.
27 test_arguments: Additional arguments to pass to the test binary. 29 test_arguments: Additional arguments to pass to the test binary.
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 self.test_results = TestResults.FromRun( 302 self.test_results = TestResults.FromRun(
301 ok=list(executed_results - failed_results), 303 ok=list(executed_results - failed_results),
302 failed=list(failed_results)) 304 failed=list(failed_results))
303 305
304 def RunTests(self): 306 def RunTests(self):
305 """Runs all tests (in rebaseline mode, runs each test in isolation). 307 """Runs all tests (in rebaseline mode, runs each test in isolation).
306 308
307 Returns: 309 Returns:
308 A TestResults object. 310 A TestResults object.
309 """ 311 """
310 if self.test_package.rebaseline: 312 try:
311 self.RebaselineTests() 313 if self.test_package.rebaseline:
312 else: 314 self.RebaselineTests()
313 if not self._gtest_filter: 315 else:
314 self._gtest_filter = ('-' + ':'.join(self.GetDisabledTests()) + ':' + 316 if not self._gtest_filter:
315 ':'.join(['*.' + x + '*' for x in 317 self._gtest_filter = ('-' + ':'.join(self.GetDisabledTests()) + ':' +
316 self.test_package.GetDisabledPrefixes()])) 318 ':'.join(['*.' + x + '*' for x in
317 self.RunTestsWithFilter() 319 self.test_package.GetDisabledPrefixes()]))
320 self.RunTestsWithFilter()
321 except errors.DeviceUnresponsiveError as e:
322 # Make sure this device is not attached
323 if android_commands.IsDeviceAttached(self.device):
324 raise e
325
326 # Wrap the results
327 logging.warning(e)
328 failed_tests = []
329 for t in self._gtest_filter.split(':'):
330 failed_tests += [BaseTestResult(t, '')]
331 self.test_results = TestResults.FromRun(
332 failed=failed_tests, device_exception=self.device)
333
318 return self.test_results 334 return self.test_results
319 335
320 def SetUp(self): 336 def SetUp(self):
321 """Sets up necessary test enviroment for the test suite.""" 337 """Sets up necessary test enviroment for the test suite."""
322 super(SingleTestRunner, self).SetUp() 338 super(SingleTestRunner, self).SetUp()
323 self.adb.ClearApplicationState(constants.CHROME_PACKAGE) 339 self.adb.ClearApplicationState(constants.CHROME_PACKAGE)
324 if self._performance_test_setup: 340 if self._performance_test_setup:
325 self._performance_test_setup.SetUp() 341 self._performance_test_setup.SetUp()
326 if self.dump_debug_info: 342 if self.dump_debug_info:
327 self.dump_debug_info.StartRecordingLog(True) 343 self.dump_debug_info.StartRecordingLog(True)
328 self.StripAndCopyFiles() 344 self.StripAndCopyFiles()
329 self.LaunchHelperToolsForTestSuite() 345 self.LaunchHelperToolsForTestSuite()
330 self.tool.SetupEnvironment() 346 self.tool.SetupEnvironment()
331 347
332 def TearDown(self): 348 def TearDown(self):
333 """Cleans up the test enviroment for the test suite.""" 349 """Cleans up the test enviroment for the test suite."""
334 self.tool.CleanUpEnvironment() 350 self.tool.CleanUpEnvironment()
335 if self.test_package.cleanup_test_files: 351 if self.test_package.cleanup_test_files:
336 self.adb.RemovePushedFiles() 352 self.adb.RemovePushedFiles()
337 if self.dump_debug_info: 353 if self.dump_debug_info:
338 self.dump_debug_info.StopRecordingLog() 354 self.dump_debug_info.StopRecordingLog()
339 if self._performance_test_setup: 355 if self._performance_test_setup:
340 self._performance_test_setup.TearDown() 356 self._performance_test_setup.TearDown()
341 if self.dump_debug_info: 357 if self.dump_debug_info:
342 self.dump_debug_info.ArchiveNewCrashFiles() 358 self.dump_debug_info.ArchiveNewCrashFiles()
343 super(SingleTestRunner, self).TearDown() 359 super(SingleTestRunner, self).TearDown()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698