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 re | 7 import re |
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 pexpect | 11 from pylib import pexpect |
12 from pylib.base import base_test_result | 12 from pylib.base import base_test_result |
13 from pylib.base import base_test_runner | 13 from pylib.base import base_test_runner |
| 14 from pylib.perf import perf_control |
14 | 15 |
15 | 16 |
16 def _TestSuiteRequiresMockTestServer(suite_name): | 17 def _TestSuiteRequiresMockTestServer(suite_name): |
17 """Returns True if the test suite requires mock test server.""" | 18 """Returns True if the test suite requires mock test server.""" |
18 tests_require_net_test_server = ['unit_tests', 'net_unittests', | 19 tests_require_net_test_server = ['unit_tests', 'net_unittests', |
19 'content_unittests', | 20 'content_unittests', |
20 'content_browsertests'] | 21 'content_browsertests'] |
21 return (suite_name in | 22 return (suite_name in |
22 tests_require_net_test_server) | 23 tests_require_net_test_server) |
23 | 24 |
| 25 def _TestSuiteRequiresHighPerfMode(suite_name): |
| 26 """Returns True if the test suite requires high performance mode.""" |
| 27 return 'perftests' in suite_name |
24 | 28 |
25 class TestRunner(base_test_runner.BaseTestRunner): | 29 class TestRunner(base_test_runner.BaseTestRunner): |
26 def __init__(self, test_options, device, test_package): | 30 def __init__(self, test_options, device, test_package): |
27 """Single test suite attached to a single device. | 31 """Single test suite attached to a single device. |
28 | 32 |
29 Args: | 33 Args: |
30 test_options: A GTestOptions object. | 34 test_options: A GTestOptions object. |
31 device: Device to run the tests. | 35 device: Device to run the tests. |
32 test_package: An instance of TestPackage class. | 36 test_package: An instance of TestPackage class. |
33 """ | 37 """ |
34 | 38 |
35 super(TestRunner, self).__init__(device, test_options.tool, | 39 super(TestRunner, self).__init__(device, test_options.tool, |
36 test_options.push_deps, | 40 test_options.push_deps, |
37 test_options.cleanup_test_files) | 41 test_options.cleanup_test_files) |
38 | 42 |
39 self.test_package = test_package | 43 self.test_package = test_package |
40 self.test_package.tool = self.tool | 44 self.test_package.tool = self.tool |
41 self._test_arguments = test_options.test_arguments | 45 self._test_arguments = test_options.test_arguments |
42 | 46 |
43 timeout = test_options.timeout | 47 timeout = test_options.timeout |
44 if timeout == 0: | 48 if timeout == 0: |
45 timeout = 60 | 49 timeout = 60 |
46 # On a VM (e.g. chromium buildbots), this timeout is way too small. | 50 # On a VM (e.g. chromium buildbots), this timeout is way too small. |
47 if os.environ.get('BUILDBOT_SLAVENAME'): | 51 if os.environ.get('BUILDBOT_SLAVENAME'): |
48 timeout = timeout * 2 | 52 timeout = timeout * 2 |
49 | 53 |
50 self._timeout = timeout * self.tool.GetTimeoutScale() | 54 self._timeout = timeout * self.tool.GetTimeoutScale() |
| 55 self._perf_controller = perf_control.PerfControl(self.adb) |
51 | 56 |
52 #override | 57 #override |
53 def InstallTestPackage(self): | 58 def InstallTestPackage(self): |
54 self.test_package.Install(self.adb) | 59 self.test_package.Install(self.adb) |
55 | 60 |
56 def GetAllTests(self): | 61 def GetAllTests(self): |
57 """Install test package and get a list of all tests.""" | 62 """Install test package and get a list of all tests.""" |
58 self.test_package.Install(self.adb) | 63 self.test_package.Install(self.adb) |
59 return self.test_package.GetAllTests(self.adb) | 64 return self.test_package.GetAllTests(self.adb) |
60 | 65 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 for t in unknown_tests]) | 180 for t in unknown_tests]) |
176 retry = ':'.join([t.GetName() for t in test_results.GetNotPass()]) | 181 retry = ':'.join([t.GetName() for t in test_results.GetNotPass()]) |
177 return test_results, retry | 182 return test_results, retry |
178 | 183 |
179 #override | 184 #override |
180 def SetUp(self): | 185 def SetUp(self): |
181 """Sets up necessary test enviroment for the test suite.""" | 186 """Sets up necessary test enviroment for the test suite.""" |
182 super(TestRunner, self).SetUp() | 187 super(TestRunner, self).SetUp() |
183 if _TestSuiteRequiresMockTestServer(self.test_package.suite_name): | 188 if _TestSuiteRequiresMockTestServer(self.test_package.suite_name): |
184 self.LaunchChromeTestServerSpawner() | 189 self.LaunchChromeTestServerSpawner() |
| 190 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name): |
| 191 self._perf_controller.SetHighPerfMode() |
185 self.tool.SetupEnvironment() | 192 self.tool.SetupEnvironment() |
186 | 193 |
187 #override | 194 #override |
188 def TearDown(self): | 195 def TearDown(self): |
189 """Cleans up the test enviroment for the test suite.""" | 196 """Cleans up the test enviroment for the test suite.""" |
| 197 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name): |
| 198 self._perf_controller.RestoreOriginalPerfMode() |
190 self.test_package.ClearApplicationState(self.adb) | 199 self.test_package.ClearApplicationState(self.adb) |
191 self.tool.CleanUpEnvironment() | 200 self.tool.CleanUpEnvironment() |
192 super(TestRunner, self).TearDown() | 201 super(TestRunner, self).TearDown() |
OLD | NEW |