| 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 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 pylib import android_commands | 10 from pylib import android_commands | 
| 11 from pylib import constants | 11 from pylib import constants | 
| 12 from pylib import perf_tests_helper | 12 from pylib import perf_tests_helper | 
| 13 from pylib.android_commands import errors | 13 from pylib.android_commands import errors | 
| 14 from pylib.base_test_runner import BaseTestRunner | 14 from pylib.base_test_runner import BaseTestRunner | 
| 15 from pylib.test_result import BaseTestResult, TestResults | 15 from pylib.test_result import BaseTestResult, TestResults | 
| 16 from pylib.utils import run_tests_helper | 16 from pylib.utils import run_tests_helper | 
| 17 | 17 | 
| 18 import debug_info | 18 import debug_info | 
| 19 from test_package_apk import TestPackageApk | 19 from test_package_apk import TestPackageApk | 
| 20 from test_package_executable import TestPackageExecutable | 20 from test_package_executable import TestPackageExecutable | 
| 21 | 21 | 
| 22 | 22 | 
|  | 23 CURFILE_PATH = os.path.abspath(os.path.dirname(__file__)) | 
|  | 24 | 
|  | 25 | 
| 23 class SingleTestRunner(BaseTestRunner): | 26 class SingleTestRunner(BaseTestRunner): | 
| 24   """Single test suite attached to a single device. | 27   """Single test suite attached to a single device. | 
| 25 | 28 | 
| 26   Args: | 29   Args: | 
| 27     device: Device to run the tests. | 30     device: Device to run the tests. | 
| 28     test_suite: A specific test suite to run, empty to run all. | 31     test_suite: A specific test suite to run, empty to run all. | 
| 29     gtest_filter: A gtest_filter flag. | 32     gtest_filter: A gtest_filter flag. | 
| 30     test_arguments: Additional arguments to pass to the test binary. | 33     test_arguments: Additional arguments to pass to the test binary. | 
| 31     timeout: Timeout for each test. | 34     timeout: Timeout for each test. | 
| 32     cleanup_test_files: Whether or not to cleanup test files on device. | 35     cleanup_test_files: Whether or not to cleanup test files on device. | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 77           self.dump_debug_info, | 80           self.dump_debug_info, | 
| 78           symbols_dir) | 81           symbols_dir) | 
| 79 | 82 | 
| 80   def _TestSuiteRequiresMockTestServer(self): | 83   def _TestSuiteRequiresMockTestServer(self): | 
| 81     """Returns True if the test suite requires mock test server.""" | 84     """Returns True if the test suite requires mock test server.""" | 
| 82     tests_require_net_test_server = ['unit_tests', 'net_unittests', | 85     tests_require_net_test_server = ['unit_tests', 'net_unittests', | 
| 83                                      'content_unittests'] | 86                                      'content_unittests'] | 
| 84     return (self.test_package.test_suite_basename in | 87     return (self.test_package.test_suite_basename in | 
| 85             tests_require_net_test_server) | 88             tests_require_net_test_server) | 
| 86 | 89 | 
| 87   def _GetFilterFileName(self): |  | 
| 88     """Returns the filename of gtest filter.""" |  | 
| 89     return os.path.join( |  | 
| 90         sys.path[0], 'gtest_filter', |  | 
| 91         self.test_package.test_suite_basename + '_disabled') |  | 
| 92 |  | 
| 93   def _GetAdditionalEmulatorFilterName(self): |  | 
| 94     """Returns the filename of additional gtest filter for emulator.""" |  | 
| 95     return os.path.join( |  | 
| 96         sys.path[0], 'gtest_filter', |  | 
| 97         self.test_package.test_suite_basename + |  | 
| 98         '_emulator_additional_disabled') |  | 
| 99 |  | 
| 100   def GetDisabledTests(self): | 90   def GetDisabledTests(self): | 
| 101     """Returns a list of disabled tests. | 91     """Returns a list of disabled tests. | 
| 102 | 92 | 
| 103     Returns: | 93     Returns: | 
| 104       A list of disabled tests obtained from gtest_filter/test_suite_disabled. | 94       A list of disabled tests obtained from 'filter' subdirectory. | 
| 105     """ | 95     """ | 
| 106     disabled_tests = run_tests_helper.GetExpectations(self._GetFilterFileName()) | 96     gtest_filter_base_path = os.path.join( | 
|  | 97         CURFILE_PATH, 'filter', self.test_package.test_suite_basename) | 
|  | 98     disabled_tests = run_tests_helper.GetExpectations( | 
|  | 99        gtest_filter_base_path + '_disabled') | 
| 107     if self._running_on_emulator: | 100     if self._running_on_emulator: | 
| 108       # Append emulator's filter file. | 101       # Append emulator's filter file. | 
| 109       disabled_tests.extend(run_tests_helper.GetExpectations( | 102       disabled_tests.extend(run_tests_helper.GetExpectations( | 
| 110           self._GetAdditionalEmulatorFilterName())) | 103           gtest_filter_base_path + '_emulator_additional_disabled')) | 
| 111     return disabled_tests | 104     return disabled_tests | 
| 112 | 105 | 
| 113   def GetDataFilesForTestSuite(self): | 106   def GetDataFilesForTestSuite(self): | 
| 114     """Returns a list of data files/dirs needed by the test suite.""" | 107     """Returns a list of data files/dirs needed by the test suite.""" | 
| 115     # Ideally, we'd just push all test data. However, it has >100MB, and a lot | 108     # Ideally, we'd just push all test data. However, it has >100MB, and a lot | 
| 116     # of the files are not relevant (some are used for browser_tests, others for | 109     # of the files are not relevant (some are used for browser_tests, others for | 
| 117     # features not supported, etc..). | 110     # features not supported, etc..). | 
| 118     if self.test_package.test_suite_basename in ['base_unittests', | 111     if self.test_package.test_suite_basename in ['base_unittests', | 
| 119                                                  'sql_unittests', | 112                                                  'sql_unittests', | 
| 120                                                  'unit_tests']: | 113                                                  'unit_tests']: | 
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 283   def TearDown(self): | 276   def TearDown(self): | 
| 284     """Cleans up the test enviroment for the test suite.""" | 277     """Cleans up the test enviroment for the test suite.""" | 
| 285     self.tool.CleanUpEnvironment() | 278     self.tool.CleanUpEnvironment() | 
| 286     if self.test_package.cleanup_test_files: | 279     if self.test_package.cleanup_test_files: | 
| 287       self.adb.RemovePushedFiles() | 280       self.adb.RemovePushedFiles() | 
| 288     if self.dump_debug_info: | 281     if self.dump_debug_info: | 
| 289       self.dump_debug_info.StopRecordingLog() | 282       self.dump_debug_info.StopRecordingLog() | 
| 290     if self.dump_debug_info: | 283     if self.dump_debug_info: | 
| 291       self.dump_debug_info.ArchiveNewCrashFiles() | 284       self.dump_debug_info.ArchiveNewCrashFiles() | 
| 292     super(SingleTestRunner, self).TearDown() | 285     super(SingleTestRunner, self).TearDown() | 
| OLD | NEW | 
|---|