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 | 8 |
9 from pylib import android_commands | 9 from pylib import android_commands |
10 from pylib import constants | 10 from pylib import constants |
11 from pylib import perf_tests_helper | 11 from pylib import perf_tests_helper |
12 from pylib.android_commands import errors | 12 from pylib.android_commands import errors |
| 13 from pylib.base import base_test_result |
13 from pylib.base import base_test_runner | 14 from pylib.base import base_test_runner |
14 from pylib.base import test_result | |
15 from pylib.utils import run_tests_helper | 15 from pylib.utils import run_tests_helper |
16 | 16 |
17 import test_package_apk | 17 import test_package_apk |
18 import test_package_executable | 18 import test_package_executable |
19 | 19 |
20 | 20 |
21 def _GetDataFilesForTestSuite(test_suite_basename): | 21 def _GetDataFilesForTestSuite(test_suite_basename): |
22 """Returns a list of data files/dirs needed by the test suite. | 22 """Returns a list of data files/dirs needed by the test suite. |
23 | 23 |
24 Args: | 24 Args: |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 disabled_tests = run_tests_helper.GetExpectations( | 235 disabled_tests = run_tests_helper.GetExpectations( |
236 gtest_filter_base_path + '_disabled') | 236 gtest_filter_base_path + '_disabled') |
237 if self._running_on_emulator: | 237 if self._running_on_emulator: |
238 # Append emulator's filter file. | 238 # Append emulator's filter file. |
239 disabled_tests.extend(run_tests_helper.GetExpectations( | 239 disabled_tests.extend(run_tests_helper.GetExpectations( |
240 gtest_filter_base_path + '_emulator_additional_disabled')) | 240 gtest_filter_base_path + '_emulator_additional_disabled')) |
241 return disabled_tests | 241 return disabled_tests |
242 | 242 |
243 #override | 243 #override |
244 def RunTest(self, test): | 244 def RunTest(self, test): |
245 """Runs a test on a single device. | 245 test_results = base_test_result.TestRunResults() |
246 | |
247 Args: | |
248 test: a gtest filter string to run. | |
249 | |
250 Returns: | |
251 Tuple: (TestResults, test to retry or None) | |
252 """ | |
253 test_results = test_result.TestResults() | |
254 if not test: | 246 if not test: |
255 return test_results, None | 247 return test_results, None |
256 | 248 |
257 try: | 249 try: |
258 self.test_package.ClearApplicationState() | 250 self.test_package.ClearApplicationState() |
259 self.test_package.CreateTestRunnerScript(test, self._test_arguments) | 251 self.test_package.CreateTestRunnerScript(test, self._test_arguments) |
260 test_results = self.test_package.RunTestsAndListResults() | 252 test_results = self.test_package.RunTestsAndListResults() |
261 except errors.DeviceUnresponsiveError as e: | 253 except errors.DeviceUnresponsiveError as e: |
262 # Make sure this device is not attached | 254 # Make sure this device is not attached |
263 logging.warning(e) | 255 logging.warning(e) |
264 if android_commands.IsDeviceAttached(self.device): | 256 if android_commands.IsDeviceAttached(self.device): |
265 raise | 257 raise |
266 finally: | 258 finally: |
267 self.CleanupSpawningServerState() | 259 self.CleanupSpawningServerState() |
268 # Calculate unknown test results. | 260 # Calculate unknown test results. |
269 # TODO(frankf): Do not break TestResults encapsulation. | |
270 all_tests = set(test.split(':')) | 261 all_tests = set(test.split(':')) |
271 all_tests_ran = set([t.name for t in test_results.GetAll()]) | 262 all_tests_ran = set([t.GetName() for t in test_results.GetAll()]) |
272 unknown_tests = all_tests - all_tests_ran | 263 unknown_tests = all_tests - all_tests_ran |
273 test_results.unknown = [test_result.BaseTestResult(t, '') for t in | 264 test_results.AddResults( |
274 unknown_tests] | 265 [base_test_result.BaseTestResult(t, base_test_result.ResultType.UNKNOWN) |
275 retry = ':'.join([t.name for t in test_results.GetAllBroken()]) | 266 for t in unknown_tests]) |
| 267 retry = ':'.join([t.GetName() for t in test_results.GetNotPass()]) |
276 return test_results, retry | 268 return test_results, retry |
277 | 269 |
278 #override | 270 #override |
279 def SetUp(self): | 271 def SetUp(self): |
280 """Sets up necessary test enviroment for the test suite.""" | 272 """Sets up necessary test enviroment for the test suite.""" |
281 super(TestRunner, self).SetUp() | 273 super(TestRunner, self).SetUp() |
282 self.StripAndCopyFiles() | 274 self.StripAndCopyFiles() |
283 if _TestSuiteRequiresMockTestServer(self.test_package.test_suite_basename): | 275 if _TestSuiteRequiresMockTestServer(self.test_package.test_suite_basename): |
284 self.LaunchChromeTestServerSpawner() | 276 self.LaunchChromeTestServerSpawner() |
285 self.tool.SetupEnvironment() | 277 self.tool.SetupEnvironment() |
286 | 278 |
287 #override | 279 #override |
288 def TearDown(self): | 280 def TearDown(self): |
289 """Cleans up the test enviroment for the test suite.""" | 281 """Cleans up the test enviroment for the test suite.""" |
290 self.tool.CleanUpEnvironment() | 282 self.tool.CleanUpEnvironment() |
291 if self._cleanup_test_files: | 283 if self._cleanup_test_files: |
292 self.adb.RemovePushedFiles() | 284 self.adb.RemovePushedFiles() |
293 super(TestRunner, self).TearDown() | 285 super(TestRunner, self).TearDown() |
OLD | NEW |