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 | 14 |
15 | 15 |
16 def _TestSuiteRequiresMockTestServer(suite_name): | 16 def _TestSuiteRequiresMockTestServer(suite_name): |
17 """Returns True if the test suite requires mock test server.""" | 17 """Returns True if the test suite requires mock test server.""" |
18 tests_require_net_test_server = ['unit_tests', 'net_unittests', | 18 tests_require_net_test_server = ['unit_tests', 'net_unittests', |
19 'content_unittests', | 19 'content_unittests', |
20 'content_browsertests'] | 20 'content_browsertests'] |
21 return (suite_name in | 21 return (suite_name in |
22 tests_require_net_test_server) | 22 tests_require_net_test_server) |
23 | 23 |
24 | 24 |
25 class TestRunner(base_test_runner.BaseTestRunner): | 25 class TestRunner(base_test_runner.BaseTestRunner): |
26 def __init__(self, device, test_package, test_arguments, timeout, | 26 def __init__(self, test_options, device, test_package): |
27 cleanup_test_files, tool_name, build_type, push_deps): | |
28 """Single test suite attached to a single device. | 27 """Single test suite attached to a single device. |
29 | 28 |
30 Args: | 29 Args: |
| 30 test_options: A GTestOptions object containing the set of options |
| 31 relevant to running instrumentation tests. |
31 device: Device to run the tests. | 32 device: Device to run the tests. |
32 test_package: An instance of TestPackage class. | 33 test_package: An instance of TestPackage class. |
33 test_arguments: Additional arguments to pass to the test binary. | |
34 timeout: Timeout for each test. | |
35 cleanup_test_files: Whether or not to cleanup test files on device. | |
36 tool_name: Name of the Valgrind tool. | |
37 build_type: 'Release' or 'Debug'. | |
38 push_deps: If True, push all dependencies to the device. | |
39 """ | 34 """ |
40 super(TestRunner, self).__init__(device, tool_name, build_type, push_deps, | 35 |
41 cleanup_test_files) | 36 super(TestRunner, self).__init__(device, test_options.tool, |
| 37 test_options.build_type, |
| 38 test_options.push_deps, |
| 39 test_options.cleanup_test_files) |
| 40 |
42 self.test_package = test_package | 41 self.test_package = test_package |
43 self.test_package.tool = self.tool | 42 self.test_package.tool = self.tool |
44 self._test_arguments = test_arguments | 43 self._test_arguments = test_options.test_arguments |
| 44 |
| 45 timeout = test_options.timeout |
45 if timeout == 0: | 46 if timeout == 0: |
46 timeout = 60 | 47 timeout = 60 |
47 # On a VM (e.g. chromium buildbots), this timeout is way too small. | 48 # On a VM (e.g. chromium buildbots), this timeout is way too small. |
48 if os.environ.get('BUILDBOT_SLAVENAME'): | 49 if os.environ.get('BUILDBOT_SLAVENAME'): |
49 timeout = timeout * 2 | 50 timeout = timeout * 2 |
| 51 |
50 self._timeout = timeout * self.tool.GetTimeoutScale() | 52 self._timeout = timeout * self.tool.GetTimeoutScale() |
51 | 53 |
52 #override | 54 #override |
53 def InstallTestPackage(self): | 55 def InstallTestPackage(self): |
54 self.test_package.Install(self.adb) | 56 self.test_package.Install(self.adb) |
55 | 57 |
56 def GetAllTests(self): | 58 def GetAllTests(self): |
57 """Install test package and get a list of all tests.""" | 59 """Install test package and get a list of all tests.""" |
58 self.test_package.Install(self.adb) | 60 self.test_package.Install(self.adb) |
59 return self.test_package.GetAllTests(self.adb) | 61 return self.test_package.GetAllTests(self.adb) |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 super(TestRunner, self).SetUp() | 184 super(TestRunner, self).SetUp() |
183 if _TestSuiteRequiresMockTestServer(self.test_package.suite_name): | 185 if _TestSuiteRequiresMockTestServer(self.test_package.suite_name): |
184 self.LaunchChromeTestServerSpawner() | 186 self.LaunchChromeTestServerSpawner() |
185 self.tool.SetupEnvironment() | 187 self.tool.SetupEnvironment() |
186 | 188 |
187 #override | 189 #override |
188 def TearDown(self): | 190 def TearDown(self): |
189 """Cleans up the test enviroment for the test suite.""" | 191 """Cleans up the test enviroment for the test suite.""" |
190 self.tool.CleanUpEnvironment() | 192 self.tool.CleanUpEnvironment() |
191 super(TestRunner, self).TearDown() | 193 super(TestRunner, self).TearDown() |
OLD | NEW |