| 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_executable import TestPackageExecutable | 13 from test_package_executable import TestPackageExecutable |
| 13 from test_result import TestResults | 14 from test_result import TestResults |
| 14 | 15 |
| 15 | 16 |
| 16 class SingleTestRunner(BaseTestRunner): | 17 class SingleTestRunner(BaseTestRunner): |
| 17 """Single test suite attached to a single device. | 18 """Single test suite attached to a single device. |
| 18 | 19 |
| 19 Args: | 20 Args: |
| 20 device: Device to run the tests. | 21 device: Device to run the tests. |
| 21 test_suite: A specific test suite to run, empty to run all. | 22 test_suite: A specific test suite to run, empty to run all. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 39 self._gtest_filter = gtest_filter | 40 self._gtest_filter = gtest_filter |
| 40 self._test_arguments = test_arguments | 41 self._test_arguments = test_arguments |
| 41 self.test_results = TestResults() | 42 self.test_results = TestResults() |
| 42 if dump_debug_info: | 43 if dump_debug_info: |
| 43 self.dump_debug_info = debug_info.GTestDebugInfo(self.adb, device, | 44 self.dump_debug_info = debug_info.GTestDebugInfo(self.adb, device, |
| 44 os.path.basename(test_suite), gtest_filter) | 45 os.path.basename(test_suite), gtest_filter) |
| 45 else: | 46 else: |
| 46 self.dump_debug_info = None | 47 self.dump_debug_info = None |
| 47 self.fast_and_loose = fast_and_loose | 48 self.fast_and_loose = fast_and_loose |
| 48 | 49 |
| 49 self.test_package = TestPackageExecutable(self.adb, device, | 50 if os.path.splitext(test_suite)[1] == '.apk': |
| 50 test_suite, timeout, rebaseline, performance_test, cleanup_test_files, | 51 self.test_package = TestPackageApk( |
| 51 tool, self.dump_debug_info) | 52 self.adb, device, |
| 53 test_suite, timeout, rebaseline, performance_test, cleanup_test_files, |
| 54 tool, self.dump_debug_info) |
| 55 else: |
| 56 self.test_package = TestPackageExecutable( |
| 57 self.adb, device, |
| 58 test_suite, timeout, rebaseline, performance_test, cleanup_test_files, |
| 59 tool, self.dump_debug_info) |
| 52 | 60 |
| 53 def _GetHttpServerDocumentRootForTestSuite(self): | 61 def _GetHttpServerDocumentRootForTestSuite(self): |
| 54 """Returns the document root needed by the test suite.""" | 62 """Returns the document root needed by the test suite.""" |
| 55 if self.test_package.test_suite_basename == 'page_cycler_tests': | 63 if self.test_package.test_suite_basename == 'page_cycler_tests': |
| 56 return os.path.join(run_tests_helper.CHROME_DIR, 'data', 'page_cycler') | 64 return os.path.join(run_tests_helper.CHROME_DIR, 'data', 'page_cycler') |
| 57 return None | 65 return None |
| 58 | 66 |
| 59 | 67 |
| 60 def _TestSuiteRequiresMockTestServer(self): | 68 def _TestSuiteRequiresMockTestServer(self): |
| 61 """Returns True if the test suite requires mock test server.""" | 69 """Returns True if the test suite requires mock test server.""" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 str(len(all_tests))) | 266 str(len(all_tests))) |
| 259 logging.info('Failed so far: ' + str(len(failed_results)) + ' ' + | 267 logging.info('Failed so far: ' + str(len(failed_results)) + ' ' + |
| 260 str([f.name for f in failed_results])) | 268 str([f.name for f in failed_results])) |
| 261 logging.info('Remaining: ' + str(len(all_tests - executed_names)) + ' ' + | 269 logging.info('Remaining: ' + str(len(all_tests - executed_names)) + ' ' + |
| 262 str(all_tests - executed_names)) | 270 str(all_tests - executed_names)) |
| 263 logging.info('*' * 80) | 271 logging.info('*' * 80) |
| 264 if executed_names == all_tests: | 272 if executed_names == all_tests: |
| 265 break | 273 break |
| 266 self.test_results = TestResults.FromOkAndFailed(list(executed_results - | 274 self.test_results = TestResults.FromOkAndFailed(list(executed_results - |
| 267 failed_results), | 275 failed_results), |
| 268 list(failed_results)) | 276 list(failed_results), |
| 277 False, False) |
| 269 | 278 |
| 270 def RunTests(self): | 279 def RunTests(self): |
| 271 """Runs all tests (in rebaseline mode, runs each test in isolation). | 280 """Runs all tests (in rebaseline mode, runs each test in isolation). |
| 272 | 281 |
| 273 Returns: | 282 Returns: |
| 274 A TestResults object. | 283 A TestResults object. |
| 275 """ | 284 """ |
| 276 if self.test_package.rebaseline: | 285 if self.test_package.rebaseline: |
| 277 self.RebaselineTests() | 286 self.RebaselineTests() |
| 278 else: | 287 else: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 300 def TearDown(self): | 309 def TearDown(self): |
| 301 """Cleans up the test enviroment for the test suite.""" | 310 """Cleans up the test enviroment for the test suite.""" |
| 302 self.test_package.tool.CleanUpEnvironment() | 311 self.test_package.tool.CleanUpEnvironment() |
| 303 if self.test_package.cleanup_test_files: | 312 if self.test_package.cleanup_test_files: |
| 304 self.adb.RemovePushedFiles() | 313 self.adb.RemovePushedFiles() |
| 305 if self.dump_debug_info: | 314 if self.dump_debug_info: |
| 306 self.dump_debug_info.StopRecordingLog() | 315 self.dump_debug_info.StopRecordingLog() |
| 307 if self.test_package.performance_test: | 316 if self.test_package.performance_test: |
| 308 self.adb.TearDownPerformanceTest() | 317 self.adb.TearDownPerformanceTest() |
| 309 super(SingleTestRunner, self).TearDown() | 318 super(SingleTestRunner, self).TearDown() |
| OLD | NEW |