Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 logging | 5 import logging |
| 6 import os | 6 import os |
| 7 import sys | 7 import sys |
| 8 | 8 |
| 9 from base_test_runner import BaseTestRunner | 9 from base_test_runner import BaseTestRunner |
| 10 import debug_info | 10 import debug_info |
| 11 import run_tests_helper | 11 import run_tests_helper |
| 12 from test_package_apk import TestPackageApk | 12 from test_package_apk import TestPackageApk |
| 13 from test_package_executable import TestPackageExecutable | 13 from test_package_executable import TestPackageExecutable |
| 14 from test_result import TestResults | 14 from test_result import TestResults |
| 15 | 15 |
| 16 # adb_interface.py is under ../../third_party/android_testrunner/ | |
| 17 sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), '..', | |
| 18 '..', 'third_party', 'android_testrunner')) | |
| 19 import run_command | |
| 20 | |
| 16 | 21 |
| 17 class SingleTestRunner(BaseTestRunner): | 22 class SingleTestRunner(BaseTestRunner): |
| 18 """Single test suite attached to a single device. | 23 """Single test suite attached to a single device. |
| 19 | 24 |
| 20 Args: | 25 Args: |
| 21 device: Device to run the tests. | 26 device: Device to run the tests. |
| 22 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. |
| 23 gtest_filter: A gtest_filter flag. | 28 gtest_filter: A gtest_filter flag. |
| 24 test_arguments: Additional arguments to pass to the test binary. | 29 test_arguments: Additional arguments to pass to the test binary. |
| 25 timeout: Timeout for each test. | 30 timeout: Timeout for each test. |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 if not self._gtest_filter: | 290 if not self._gtest_filter: |
| 286 self._gtest_filter = ('-' + ':'.join(self.GetDisabledTests()) + ':' + | 291 self._gtest_filter = ('-' + ':'.join(self.GetDisabledTests()) + ':' + |
| 287 ':'.join(['*.' + x + '*' for x in | 292 ':'.join(['*.' + x + '*' for x in |
| 288 self.test_package.GetDisabledPrefixes()])) | 293 self.test_package.GetDisabledPrefixes()])) |
| 289 self.RunTestsWithFilter() | 294 self.RunTestsWithFilter() |
| 290 return self.test_results | 295 return self.test_results |
| 291 | 296 |
| 292 def SetUp(self): | 297 def SetUp(self): |
| 293 """Sets up necessary test enviroment for the test suite.""" | 298 """Sets up necessary test enviroment for the test suite.""" |
| 294 super(SingleTestRunner, self).SetUp() | 299 super(SingleTestRunner, self).SetUp() |
| 300 # Sometimes adb server may crash and the connection to the device lost, | |
| 301 # which will block the test. So kill the server each time the test starts | |
| 302 # and the connection to the device will be re-established. | |
| 303 run_command.RunCommand('adb kill-server') | |
|
John Grabowski
2012/07/10 06:14:09
prefer self.adb.SomethingOrOther() to a 'run comma
Wei James(wistoch)
2012/07/10 14:26:48
fixed.
define Start/Kill/RestartAdbServer in adb
| |
| 304 | |
| 295 if self.test_package.performance_test: | 305 if self.test_package.performance_test: |
| 296 if run_tests_helper.IsRunningAsBuildbot(): | 306 if run_tests_helper.IsRunningAsBuildbot(): |
| 297 self.adb.SetJavaAssertsEnabled(enable=False) | 307 self.adb.SetJavaAssertsEnabled(enable=False) |
| 298 self.adb.Reboot(full_reboot=False) | 308 self.adb.Reboot(full_reboot=False) |
| 299 self.adb.SetupPerformanceTest() | 309 self.adb.SetupPerformanceTest() |
| 300 if self.dump_debug_info: | 310 if self.dump_debug_info: |
| 301 self.dump_debug_info.StartRecordingLog(True) | 311 self.dump_debug_info.StartRecordingLog(True) |
| 302 self.StripAndCopyFiles() | 312 self.StripAndCopyFiles() |
| 303 self.LaunchHelperToolsForTestSuite() | 313 self.LaunchHelperToolsForTestSuite() |
| 304 self.test_package.tool.SetupEnvironment() | 314 self.test_package.tool.SetupEnvironment() |
| 305 | 315 |
| 306 def TearDown(self): | 316 def TearDown(self): |
| 307 """Cleans up the test enviroment for the test suite.""" | 317 """Cleans up the test enviroment for the test suite.""" |
| 308 self.test_package.tool.CleanUpEnvironment() | 318 self.test_package.tool.CleanUpEnvironment() |
| 309 if self.test_package.cleanup_test_files: | 319 if self.test_package.cleanup_test_files: |
| 310 self.adb.RemovePushedFiles() | 320 self.adb.RemovePushedFiles() |
| 311 if self.dump_debug_info: | 321 if self.dump_debug_info: |
| 312 self.dump_debug_info.StopRecordingLog() | 322 self.dump_debug_info.StopRecordingLog() |
| 313 if self.test_package.performance_test: | 323 if self.test_package.performance_test: |
| 314 self.adb.TearDownPerformanceTest() | 324 self.adb.TearDownPerformanceTest() |
| 315 super(SingleTestRunner, self).TearDown() | 325 super(SingleTestRunner, self).TearDown() |
| OLD | NEW |