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 base_test_runner import BaseTestRunner | 10 from base_test_runner import BaseTestRunner |
11 import debug_info | 11 import debug_info |
12 import constants | 12 import constants |
| 13 import perf_tests_helper |
13 import run_tests_helper | 14 import run_tests_helper |
14 from test_package_apk import TestPackageApk | 15 from test_package_apk import TestPackageApk |
15 from test_package_executable import TestPackageExecutable | 16 from test_package_executable import TestPackageExecutable |
16 from test_result import TestResults | 17 from test_result import TestResults |
17 | 18 |
18 | 19 |
19 class SingleTestRunner(BaseTestRunner): | 20 class SingleTestRunner(BaseTestRunner): |
20 """Single test suite attached to a single device. | 21 """Single test suite attached to a single device. |
21 | 22 |
22 Args: | 23 Args: |
(...skipping 29 matching lines...) Expand all Loading... |
52 logging.warning('Test suite: ' + test_suite) | 53 logging.warning('Test suite: ' + test_suite) |
53 if os.path.splitext(test_suite)[1] == '.apk': | 54 if os.path.splitext(test_suite)[1] == '.apk': |
54 self.test_package = TestPackageApk(self.adb, device, | 55 self.test_package = TestPackageApk(self.adb, device, |
55 test_suite, timeout, rebaseline, performance_test, cleanup_test_files, | 56 test_suite, timeout, rebaseline, performance_test, cleanup_test_files, |
56 self.tool, self.dump_debug_info) | 57 self.tool, self.dump_debug_info) |
57 else: | 58 else: |
58 self.test_package = TestPackageExecutable( | 59 self.test_package = TestPackageExecutable( |
59 self.adb, device, | 60 self.adb, device, |
60 test_suite, timeout, rebaseline, performance_test, cleanup_test_files, | 61 test_suite, timeout, rebaseline, performance_test, cleanup_test_files, |
61 self.tool, self.dump_debug_info) | 62 self.tool, self.dump_debug_info) |
| 63 self._performance_test_setup = None |
| 64 if performance_test: |
| 65 self._performance_test_setup = perf_tests_helper.PerfTestSetup(self.adb) |
62 | 66 |
63 def _TestSuiteRequiresMockTestServer(self): | 67 def _TestSuiteRequiresMockTestServer(self): |
64 """Returns True if the test suite requires mock test server.""" | 68 """Returns True if the test suite requires mock test server.""" |
65 return False | 69 return False |
66 # TODO(yfriedman): Disabled because of flakiness. | 70 # TODO(yfriedman): Disabled because of flakiness. |
67 # (self.test_package.test_suite_basename == 'unit_tests' or | 71 # (self.test_package.test_suite_basename == 'unit_tests' or |
68 # self.test_package.test_suite_basename == 'net_unittests' or | 72 # self.test_package.test_suite_basename == 'net_unittests' or |
69 # False) | 73 # False) |
70 | 74 |
71 def _GetFilterFileName(self): | 75 def _GetFilterFileName(self): |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 def StripAndCopyFiles(self): | 253 def StripAndCopyFiles(self): |
250 """Strips and copies the required data files for the test suite.""" | 254 """Strips and copies the required data files for the test suite.""" |
251 self.test_package.StripAndCopyExecutable() | 255 self.test_package.StripAndCopyExecutable() |
252 self.test_package.PushDataAndPakFiles() | 256 self.test_package.PushDataAndPakFiles() |
253 self.tool.CopyFiles() | 257 self.tool.CopyFiles() |
254 test_data = self.GetDataFilesForTestSuite() | 258 test_data = self.GetDataFilesForTestSuite() |
255 if test_data and not self.fast_and_loose: | 259 if test_data and not self.fast_and_loose: |
256 # Make sure SD card is ready. | 260 # Make sure SD card is ready. |
257 self.adb.WaitForSdCardReady(20) | 261 self.adb.WaitForSdCardReady(20) |
258 for data in test_data: | 262 for data in test_data: |
259 self.CopyTestData([data], constants.TEST_DATA_DIR) | 263 self.CopyTestData([data], self.adb.GetExternalStorage()) |
260 | 264 |
261 def RunTestsWithFilter(self): | 265 def RunTestsWithFilter(self): |
262 """Runs a tests via a small, temporary shell script.""" | 266 """Runs a tests via a small, temporary shell script.""" |
263 self.test_package.CreateTestRunnerScript(self._gtest_filter, | 267 self.test_package.CreateTestRunnerScript(self._gtest_filter, |
264 self._test_arguments) | 268 self._test_arguments) |
265 self.test_results = self.test_package.RunTestsAndListResults() | 269 self.test_results = self.test_package.RunTestsAndListResults() |
266 | 270 |
267 def RebaselineTests(self): | 271 def RebaselineTests(self): |
268 """Runs all available tests, restarting in case of failures.""" | 272 """Runs all available tests, restarting in case of failures.""" |
269 if self._gtest_filter: | 273 if self._gtest_filter: |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 self._gtest_filter = ('-' + ':'.join(self.GetDisabledTests()) + ':' + | 314 self._gtest_filter = ('-' + ':'.join(self.GetDisabledTests()) + ':' + |
311 ':'.join(['*.' + x + '*' for x in | 315 ':'.join(['*.' + x + '*' for x in |
312 self.test_package.GetDisabledPrefixes()])) | 316 self.test_package.GetDisabledPrefixes()])) |
313 self.RunTestsWithFilter() | 317 self.RunTestsWithFilter() |
314 return self.test_results | 318 return self.test_results |
315 | 319 |
316 def SetUp(self): | 320 def SetUp(self): |
317 """Sets up necessary test enviroment for the test suite.""" | 321 """Sets up necessary test enviroment for the test suite.""" |
318 super(SingleTestRunner, self).SetUp() | 322 super(SingleTestRunner, self).SetUp() |
319 self.adb.ClearApplicationState(constants.CHROME_PACKAGE) | 323 self.adb.ClearApplicationState(constants.CHROME_PACKAGE) |
320 if self.test_package.performance_test: | 324 if self._performance_test_setup: |
321 self.adb.SetupPerformanceTest() | 325 self._performance_test_setup.SetUp() |
322 if self.dump_debug_info: | 326 if self.dump_debug_info: |
323 self.dump_debug_info.StartRecordingLog(True) | 327 self.dump_debug_info.StartRecordingLog(True) |
324 self.StripAndCopyFiles() | 328 self.StripAndCopyFiles() |
325 self.LaunchHelperToolsForTestSuite() | 329 self.LaunchHelperToolsForTestSuite() |
326 self.tool.SetupEnvironment() | 330 self.tool.SetupEnvironment() |
327 | 331 |
328 def TearDown(self): | 332 def TearDown(self): |
329 """Cleans up the test enviroment for the test suite.""" | 333 """Cleans up the test enviroment for the test suite.""" |
330 self.tool.CleanUpEnvironment() | 334 self.tool.CleanUpEnvironment() |
331 if self.test_package.cleanup_test_files: | 335 if self.test_package.cleanup_test_files: |
332 self.adb.RemovePushedFiles() | 336 self.adb.RemovePushedFiles() |
333 if self.dump_debug_info: | 337 if self.dump_debug_info: |
334 self.dump_debug_info.StopRecordingLog() | 338 self.dump_debug_info.StopRecordingLog() |
335 if self.test_package.performance_test: | 339 if self._performance_test_setup: |
336 self.adb.TearDownPerformanceTest() | 340 self._performance_test_setup.TearDown() |
337 if self.dump_debug_info: | 341 if self.dump_debug_info: |
338 self.dump_debug_info.ArchiveNewCrashFiles() | 342 self.dump_debug_info.ArchiveNewCrashFiles() |
339 super(SingleTestRunner, self).TearDown() | 343 super(SingleTestRunner, self).TearDown() |
OLD | NEW |