| 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.utils import run_tests_helper | |
| 15 | 14 |
| 16 import test_package_apk | 15 import test_package_apk |
| 17 import test_package_exe | 16 import test_package_exe |
| 18 | 17 |
| 19 | 18 |
| 20 def _TestSuiteRequiresMockTestServer(suite_basename): | 19 def _TestSuiteRequiresMockTestServer(suite_basename): |
| 21 """Returns True if the test suite requires mock test server.""" | 20 """Returns True if the test suite requires mock test server.""" |
| 22 tests_require_net_test_server = ['unit_tests', 'net_unittests', | 21 tests_require_net_test_server = ['unit_tests', 'net_unittests', |
| 23 'content_unittests', | 22 'content_unittests', |
| 24 'content_browsertests'] | 23 'content_browsertests'] |
| 25 return (suite_basename in | 24 return (suite_basename in |
| 26 tests_require_net_test_server) | 25 tests_require_net_test_server) |
| 27 | 26 |
| 28 | 27 |
| 29 class TestRunner(base_test_runner.BaseTestRunner): | 28 class TestRunner(base_test_runner.BaseTestRunner): |
| 30 def __init__(self, device, suite_name, test_arguments, timeout, | 29 def __init__(self, test_options, suite_path, device, |
| 31 cleanup_test_files, tool_name, build_type, | 30 test_apk_package_name=None, test_activity_name=None, |
| 32 push_deps, test_apk_package_name=None, | 31 command_line_file=None): |
| 33 test_activity_name=None, command_line_file=None): | |
| 34 """Single test suite attached to a single device. | 32 """Single test suite attached to a single device. |
| 35 | 33 |
| 36 Args: | 34 Args: |
| 35 test_options: A GTestOptions object containing the set of options |
| 36 relevant to running instrumentation tests. |
| 37 suite_path: The absolute path to a suite apk or executable file. |
| 37 device: Device to run the tests. | 38 device: Device to run the tests. |
| 38 suite_name: A specific test suite to run, empty to run all. | |
| 39 test_arguments: Additional arguments to pass to the test binary. | |
| 40 timeout: Timeout for each test. | |
| 41 cleanup_test_files: Whether or not to cleanup test files on device. | |
| 42 tool_name: Name of the Valgrind tool. | |
| 43 build_type: 'Release' or 'Debug'. | |
| 44 push_deps: If True, push all dependencies to the device. | |
| 45 test_apk_package_name: Apk package name for tests running in APKs. | 39 test_apk_package_name: Apk package name for tests running in APKs. |
| 46 test_activity_name: Test activity to invoke for APK tests. | 40 test_activity_name: Test activity to invoke for APK tests. |
| 47 command_line_file: Filename to use to pass arguments to tests. | 41 command_line_file: Filename to use to pass arguments to tests. |
| 48 """ | 42 """ |
| 49 super(TestRunner, self).__init__(device, tool_name, build_type, push_deps, | 43 super(TestRunner, self).__init__(device, test_options.tool, |
| 50 cleanup_test_files) | 44 test_options.build_type, |
| 51 self._test_arguments = test_arguments | 45 test_options.push_deps, |
| 46 test_options.cleanup_test_files) |
| 47 self._test_arguments = test_options.test_arguments |
| 48 timeout = test_options.timeout |
| 52 if timeout == 0: | 49 if timeout == 0: |
| 53 timeout = 60 | 50 timeout = 60 |
| 54 # On a VM (e.g. chromium buildbots), this timeout is way too small. | 51 # On a VM (e.g. chromium buildbots), this timeout is way too small. |
| 55 if os.environ.get('BUILDBOT_SLAVENAME'): | 52 if os.environ.get('BUILDBOT_SLAVENAME'): |
| 56 timeout = timeout * 2 | 53 timeout = timeout * 2 |
| 57 self.timeout = timeout * self.tool.GetTimeoutScale() | 54 self.timeout = timeout * self.tool.GetTimeoutScale() |
| 58 | 55 |
| 59 logging.warning('Test suite: ' + str(suite_name)) | 56 logging.warning('Test suite: ' + str(suite_path)) |
| 60 if os.path.splitext(suite_name)[1] == '.apk': | 57 if os.path.splitext(suite_path)[1] == '.apk': |
| 61 self.test_package = test_package_apk.TestPackageApk( | 58 self.test_package = test_package_apk.TestPackageApk( |
| 62 self.adb, | 59 self.adb, |
| 63 device, | 60 device, |
| 64 suite_name, | 61 suite_path, |
| 65 self.tool, | 62 self.tool, |
| 66 test_apk_package_name, | 63 test_apk_package_name, |
| 67 test_activity_name, | 64 test_activity_name, |
| 68 command_line_file) | 65 command_line_file) |
| 69 else: | 66 else: |
| 70 # Put a copy into the android out/target directory, to allow stack trace | 67 # Put a copy into the android out/target directory, to allow stack trace |
| 71 # generation. | 68 # generation. |
| 72 symbols_dir = os.path.join(constants.DIR_SOURCE_ROOT, 'out', build_type, | 69 symbols_dir = os.path.join(constants.DIR_SOURCE_ROOT, 'out', |
| 73 'lib.target') | 70 test_options.build_type, 'lib.target') |
| 74 self.test_package = test_package_exe.TestPackageExecutable( | 71 self.test_package = test_package_exe.TestPackageExecutable( |
| 75 self.adb, | 72 self.adb, |
| 76 device, | 73 device, |
| 77 suite_name, | 74 suite_path, |
| 78 self.tool, | 75 self.tool, |
| 79 symbols_dir) | 76 symbols_dir) |
| 80 | 77 |
| 81 #override | 78 #override |
| 82 def InstallTestPackage(self): | 79 def InstallTestPackage(self): |
| 83 self.test_package.Install() | 80 self.test_package.Install() |
| 84 | 81 |
| 85 #override | 82 #override |
| 86 def PushDataDeps(self): | 83 def PushDataDeps(self): |
| 87 self.adb.WaitForSdCardReady(20) | 84 self.adb.WaitForSdCardReady(20) |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 super(TestRunner, self).SetUp() | 202 super(TestRunner, self).SetUp() |
| 206 if _TestSuiteRequiresMockTestServer(self.test_package.suite_basename): | 203 if _TestSuiteRequiresMockTestServer(self.test_package.suite_basename): |
| 207 self.LaunchChromeTestServerSpawner() | 204 self.LaunchChromeTestServerSpawner() |
| 208 self.tool.SetupEnvironment() | 205 self.tool.SetupEnvironment() |
| 209 | 206 |
| 210 #override | 207 #override |
| 211 def TearDown(self): | 208 def TearDown(self): |
| 212 """Cleans up the test enviroment for the test suite.""" | 209 """Cleans up the test enviroment for the test suite.""" |
| 213 self.tool.CleanUpEnvironment() | 210 self.tool.CleanUpEnvironment() |
| 214 super(TestRunner, self).TearDown() | 211 super(TestRunner, self).TearDown() |
| OLD | NEW |