| 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. |
| 31 device: Device to run the tests. | 31 device: Device to run the tests. |
| 32 test_package: An instance of TestPackage class. | 32 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 """ | 33 """ |
| 40 super(TestRunner, self).__init__(device, tool_name, build_type, push_deps, | 34 |
| 41 cleanup_test_files) | 35 super(TestRunner, self).__init__(device, test_options.tool, |
| 36 test_options.build_type, |
| 37 test_options.push_deps, |
| 38 test_options.cleanup_test_files) |
| 39 |
| 42 self.test_package = test_package | 40 self.test_package = test_package |
| 43 self.test_package.tool = self.tool | 41 self.test_package.tool = self.tool |
| 44 self._test_arguments = test_arguments | 42 self._test_arguments = test_options.test_arguments |
| 43 |
| 44 timeout = test_options.timeout |
| 45 if timeout == 0: | 45 if timeout == 0: |
| 46 timeout = 60 | 46 timeout = 60 |
| 47 # On a VM (e.g. chromium buildbots), this timeout is way too small. | 47 # On a VM (e.g. chromium buildbots), this timeout is way too small. |
| 48 if os.environ.get('BUILDBOT_SLAVENAME'): | 48 if os.environ.get('BUILDBOT_SLAVENAME'): |
| 49 timeout = timeout * 2 | 49 timeout = timeout * 2 |
| 50 |
| 50 self._timeout = timeout * self.tool.GetTimeoutScale() | 51 self._timeout = timeout * self.tool.GetTimeoutScale() |
| 51 | 52 |
| 52 #override | 53 #override |
| 53 def InstallTestPackage(self): | 54 def InstallTestPackage(self): |
| 54 self.test_package.Install(self.adb) | 55 self.test_package.Install(self.adb) |
| 55 | 56 |
| 56 def GetAllTests(self): | 57 def GetAllTests(self): |
| 57 """Install test package and get a list of all tests.""" | 58 """Install test package and get a list of all tests.""" |
| 58 self.test_package.Install(self.adb) | 59 self.test_package.Install(self.adb) |
| 59 return self.test_package.GetAllTests(self.adb) | 60 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() | 183 super(TestRunner, self).SetUp() |
| 183 if _TestSuiteRequiresMockTestServer(self.test_package.suite_name): | 184 if _TestSuiteRequiresMockTestServer(self.test_package.suite_name): |
| 184 self.LaunchChromeTestServerSpawner() | 185 self.LaunchChromeTestServerSpawner() |
| 185 self.tool.SetupEnvironment() | 186 self.tool.SetupEnvironment() |
| 186 | 187 |
| 187 #override | 188 #override |
| 188 def TearDown(self): | 189 def TearDown(self): |
| 189 """Cleans up the test enviroment for the test suite.""" | 190 """Cleans up the test enviroment for the test suite.""" |
| 190 self.tool.CleanUpEnvironment() | 191 self.tool.CleanUpEnvironment() |
| 191 super(TestRunner, self).TearDown() | 192 super(TestRunner, self).TearDown() |
| OLD | NEW |