Chromium Code Reviews| 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 | |
| 6 import logging | 5 import logging |
| 7 import os | 6 import os |
| 8 import sys | |
| 9 | 7 |
| 10 from pylib import android_commands | 8 from pylib import android_commands |
| 11 from pylib import cmd_helper | |
| 12 from pylib import constants | 9 from pylib import constants |
| 13 from pylib import perf_tests_helper | |
| 14 from pylib.android_commands import errors | 10 from pylib.android_commands import errors |
| 15 from pylib.base import base_test_result | 11 from pylib.base import base_test_result |
| 16 from pylib.base import base_test_runner | 12 from pylib.base import base_test_runner |
| 17 from pylib.utils import run_tests_helper | 13 from pylib.utils import run_tests_helper |
| 18 | 14 |
| 19 import test_package_apk | 15 import test_package_apk |
| 20 import test_package_executable | 16 import test_package_executable |
| 21 | 17 |
| 22 sys.path.insert( | |
| 23 0, os.path.join(constants.DIR_SOURCE_ROOT, 'tools', 'swarm_client')) | |
| 24 import run_isolated | |
| 25 | 18 |
| 26 | 19 # We're moving to using isolate files instead of harcoding |
| 27 _ISOLATE_FILE_PATHS = { | 20 # dependencies here. Look at the TODO in dispatch.py. |
| 28 'base_unittests': 'base/base_unittests.isolate', | 21 def _GetDataFilesForTestSuite(test_suite_basename): |
| 29 #'net_unittests': 'net/net_unittests.isolate', | |
| 30 #'unit_tests': 'chrome/unit_tests.isolate', | |
| 31 #'content_browsertests': 'content/content_browsertests.isolate', | |
| 32 #'content_unittests': 'content/content_unittests.isolate', | |
| 33 } | |
| 34 _ISOLATE_SCRIPT = os.path.join( | |
| 35 constants.DIR_SOURCE_ROOT, 'tools', 'swarm_client', 'isolate.py') | |
| 36 | |
| 37 | |
| 38 def _GetDataFilesForTestSuite(product_dir, test_suite_basename): | |
| 39 """Returns a list of data files/dirs needed by the test suite. | 22 """Returns a list of data files/dirs needed by the test suite. |
| 40 | 23 |
| 41 Args: | 24 Args: |
| 42 product_dir: Absolute path to product directory (e.g. /../out/Debug). | |
| 43 test_suite_basename: The test suite basename (e.g. base_unittests). | 25 test_suite_basename: The test suite basename (e.g. base_unittests). |
| 44 | 26 |
| 45 Returns: | 27 Returns: |
| 46 A list of test file and directory paths. | 28 A list of test file and directory paths. |
| 47 """ | 29 """ |
| 48 # TODO(frankf): *.isolated should be generated by gyp using foo_tests_run | |
| 49 # targets. This is a stop-gap solution as currently there are no such | |
| 50 # targets for content_unittests and content_browsertests. | |
| 51 isolate_rel_path = _ISOLATE_FILE_PATHS.get(test_suite_basename) | |
| 52 if isolate_rel_path: | |
| 53 isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, isolate_rel_path) | |
| 54 isolated_abs_path = os.path.join( | |
| 55 product_dir, '%s.isolated' % test_suite_basename) | |
| 56 assert os.path.exists(isolate_abs_path) | |
| 57 isolate_cmd = [ | |
| 58 'python', _ISOLATE_SCRIPT, | |
| 59 'check', | |
| 60 '--isolate=%s' % isolate_abs_path, | |
| 61 '--isolated=%s' % isolated_abs_path, | |
| 62 '-V', 'PRODUCT_DIR=%s' % product_dir, | |
| 63 '-V', 'OS=android', | |
| 64 '--outdir=%s' % product_dir, | |
| 65 ] | |
| 66 assert not cmd_helper.RunCmd(isolate_cmd) | |
| 67 with open(isolated_abs_path) as f: | |
| 68 isolated_content = run_isolated.load_isolated(f.read(), | |
| 69 os_flavor='android') | |
| 70 assert isolated_content['os'] == 'android' | |
| 71 return isolated_content['files'].keys() | |
| 72 | |
| 73 logging.info('Did not find an isolate file for the test suite.') | |
| 74 # Ideally, we'd just push all test data. However, it has >100MB, and a lot | 30 # Ideally, we'd just push all test data. However, it has >100MB, and a lot |
| 75 # of the files are not relevant (some are used for browser_tests, others for | 31 # of the files are not relevant (some are used for browser_tests, others for |
| 76 # features not supported, etc..). | 32 # features not supported, etc..). |
| 77 if test_suite_basename == 'unit_tests': | 33 if test_suite_basename == 'media_unittests': |
| 78 test_files = [ | |
| 79 'base/test/data/', | |
| 80 'chrome/test/data/download-test1.lib', | |
| 81 'chrome/test/data/extensions/bad_magic.crx', | |
| 82 'chrome/test/data/extensions/good.crx', | |
| 83 'chrome/test/data/extensions/icon1.png', | |
| 84 'chrome/test/data/extensions/icon2.png', | |
| 85 'chrome/test/data/extensions/icon3.png', | |
| 86 'chrome/test/data/extensions/allow_silent_upgrade/', | |
| 87 'chrome/test/data/extensions/app/', | |
| 88 'chrome/test/data/extensions/bad/', | |
| 89 'chrome/test/data/extensions/effective_host_permissions/', | |
| 90 'chrome/test/data/extensions/empty_manifest/', | |
| 91 'chrome/test/data/extensions/good/Extensions/', | |
| 92 'chrome/test/data/extensions/manifest_tests/', | |
| 93 'chrome/test/data/extensions/page_action/', | |
| 94 'chrome/test/data/extensions/permissions/', | |
| 95 'chrome/test/data/extensions/script_and_capture/', | |
| 96 'chrome/test/data/extensions/unpacker/', | |
| 97 'chrome/test/data/bookmarks/', | |
| 98 'chrome/test/data/components/', | |
| 99 'chrome/test/data/extensions/json_schema_test.js', | |
| 100 'chrome/test/data/History/', | |
| 101 'chrome/test/data/json_schema_validator/', | |
| 102 'chrome/test/data/pref_service/', | |
| 103 'chrome/test/data/simple_open_search.xml', | |
| 104 'chrome/test/data/top_sites/', | |
| 105 'chrome/test/data/web_app_info/', | |
| 106 'chrome/test/data/webui/', | |
| 107 'chrome/third_party/mock4js/', | |
| 108 'components/test/data/web_database', | |
| 109 'net/data/ssl/certificates', | |
| 110 'third_party/accessibility-developer-tools/gen/axs_testing.js', | |
| 111 'third_party/zlib/google/test/data', | |
| 112 ] | |
| 113 # The following are spell check data. Now only list the data under | |
| 114 # third_party/hunspell_dictionaries which are used by unit tests. | |
| 115 old_cwd = os.getcwd() | |
| 116 os.chdir(constants.DIR_SOURCE_ROOT) | |
| 117 test_files += glob.glob('third_party/hunspell_dictionaries/*.bdic') | |
| 118 os.chdir(old_cwd) | |
| 119 return test_files | |
| 120 elif test_suite_basename == 'media_unittests': | |
| 121 return [ | 34 return [ |
| 122 'media/test/data', | 35 'media/test/data', |
| 123 ] | 36 ] |
| 124 elif test_suite_basename == 'net_unittests': | 37 elif test_suite_basename == 'net_unittests': |
| 125 return [ | 38 return [ |
| 126 'chrome/test/data/animate1.gif', | 39 'chrome/test/data/animate1.gif', |
| 127 'chrome/test/data/simple.html', | 40 'chrome/test/data/simple.html', |
| 128 'net/data/cache_tests', | 41 'net/data/cache_tests', |
| 129 'net/data/filter_unittests', | 42 'net/data/filter_unittests', |
| 130 'net/data/ftp', | 43 'net/data/ftp', |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 test_arguments: Additional arguments to pass to the test binary. | 164 test_arguments: Additional arguments to pass to the test binary. |
| 252 timeout: Timeout for each test. | 165 timeout: Timeout for each test. |
| 253 cleanup_test_files: Whether or not to cleanup test files on device. | 166 cleanup_test_files: Whether or not to cleanup test files on device. |
| 254 tool_name: Name of the Valgrind tool. | 167 tool_name: Name of the Valgrind tool. |
| 255 build_type: 'Release' or 'Debug'. | 168 build_type: 'Release' or 'Debug'. |
| 256 in_webkit_checkout: Whether the suite is being run from a WebKit checkout. | 169 in_webkit_checkout: Whether the suite is being run from a WebKit checkout. |
| 257 push_deps: If True, push all dependencies to the device. | 170 push_deps: If True, push all dependencies to the device. |
| 258 test_apk_package_name: Apk package name for tests running in APKs. | 171 test_apk_package_name: Apk package name for tests running in APKs. |
| 259 test_activity_name: Test activity to invoke for APK tests. | 172 test_activity_name: Test activity to invoke for APK tests. |
| 260 command_line_file: Filename to use to pass arguments to tests. | 173 command_line_file: Filename to use to pass arguments to tests. |
| 174 deps_dir: The path to the dependency dir on the host to push to the device. | |
| 261 """ | 175 """ |
| 262 | 176 |
| 263 def __init__(self, device, test_suite, test_arguments, timeout, | 177 def __init__(self, device, test_suite, test_arguments, timeout, |
| 264 cleanup_test_files, tool_name, build_type, | 178 cleanup_test_files, tool_name, build_type, |
| 265 in_webkit_checkout, push_deps, test_apk_package_name=None, | 179 in_webkit_checkout, push_deps, test_apk_package_name=None, |
| 266 test_activity_name=None, command_line_file=None): | 180 test_activity_name=None, command_line_file=None, deps_dir=None): |
| 267 super(TestRunner, self).__init__(device, tool_name, build_type, push_deps) | 181 super(TestRunner, self).__init__(device, tool_name, build_type, push_deps) |
| 268 self._running_on_emulator = self.device.startswith('emulator') | 182 self._running_on_emulator = self.device.startswith('emulator') |
| 269 self._test_arguments = test_arguments | 183 self._test_arguments = test_arguments |
| 270 self.in_webkit_checkout = in_webkit_checkout | 184 self.in_webkit_checkout = in_webkit_checkout |
| 271 self._cleanup_test_files = cleanup_test_files | 185 self._cleanup_test_files = cleanup_test_files |
| 186 self._deps_dir = deps_dir | |
| 272 | 187 |
| 273 logging.warning('Test suite: ' + test_suite) | 188 logging.warning('Test suite: ' + test_suite) |
| 274 if os.path.splitext(test_suite)[1] == '.apk': | 189 if os.path.splitext(test_suite)[1] == '.apk': |
| 275 self.test_package = test_package_apk.TestPackageApk( | 190 self.test_package = test_package_apk.TestPackageApk( |
| 276 self.adb, | 191 self.adb, |
| 277 device, | 192 device, |
| 278 test_suite, | 193 test_suite, |
| 279 timeout, | 194 timeout, |
| 280 self._cleanup_test_files, | 195 self._cleanup_test_files, |
| 281 self.tool, | 196 self.tool, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 295 self._cleanup_test_files, | 210 self._cleanup_test_files, |
| 296 self.tool, | 211 self.tool, |
| 297 symbols_dir) | 212 symbols_dir) |
| 298 | 213 |
| 299 #override | 214 #override |
| 300 def InstallTestPackage(self): | 215 def InstallTestPackage(self): |
| 301 self.test_package.StripAndCopyExecutable() | 216 self.test_package.StripAndCopyExecutable() |
| 302 | 217 |
| 303 #override | 218 #override |
| 304 def PushDataDeps(self): | 219 def PushDataDeps(self): |
| 220 self.adb.WaitForSdCardReady(20) | |
| 305 self.test_package.PushDataAndPakFiles() | 221 self.test_package.PushDataAndPakFiles() |
| 306 self.tool.CopyFiles() | 222 self.tool.CopyFiles() |
| 307 test_data = _GetDataFilesForTestSuite(self.test_package.test_suite_dirname, | 223 if self._deps_dir: |
| 308 self.test_package.test_suite_basename) | 224 self.CopyTestData([p for p in os.listdir(self._deps_dir)], |
|
M-A Ruel
2013/07/08 17:56:02
replace this:
[p for p in os.listdir(self._deps_
| |
| 309 if test_data: | 225 self.adb.GetExternalStorage(), |
| 310 # Make sure SD card is ready. | 226 src_root=self._deps_dir) |
| 311 self.adb.WaitForSdCardReady(20) | 227 else: |
| 312 self.CopyTestData(test_data, self.adb.GetExternalStorage()) | 228 logging.info('Did not find an isolate file for the test suite.') |
| 229 deps_list = _GetDataFilesForTestSuite( | |
| 230 self.test_package.test_suite_basename) | |
| 231 self.CopyTestData(deps_list, self.adb.GetExternalStorage()) | |
| 232 | |
| 313 if self.test_package.test_suite_basename == 'webkit_unit_tests': | 233 if self.test_package.test_suite_basename == 'webkit_unit_tests': |
|
bulach
2013/07/04 11:05:21
as above, perhaps simplify this a bit by moving th
frankf
2013/07/09 01:09:35
Done.
| |
| 314 self.PushWebKitUnitTestsData() | 234 self.PushWebKitUnitTestsData() |
| 315 | 235 |
| 316 def PushWebKitUnitTestsData(self): | 236 def PushWebKitUnitTestsData(self): |
| 317 """Pushes the webkit_unit_tests data files to the device. | 237 """Pushes the webkit_unit_tests data files to the device. |
| 318 | 238 |
| 319 The path of this directory is different when the suite is being run as | 239 The path of this directory is different when the suite is being run as |
| 320 part of a WebKit check-out. | 240 part of a WebKit check-out. |
| 321 """ | 241 """ |
| 322 webkit_src = os.path.join(constants.DIR_SOURCE_ROOT, 'third_party', | 242 webkit_src = os.path.join(constants.DIR_SOURCE_ROOT, 'third_party', |
| 323 'WebKit') | 243 'WebKit') |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 self.LaunchChromeTestServerSpawner() | 304 self.LaunchChromeTestServerSpawner() |
| 385 self.tool.SetupEnvironment() | 305 self.tool.SetupEnvironment() |
| 386 | 306 |
| 387 #override | 307 #override |
| 388 def TearDown(self): | 308 def TearDown(self): |
| 389 """Cleans up the test enviroment for the test suite.""" | 309 """Cleans up the test enviroment for the test suite.""" |
| 390 self.tool.CleanUpEnvironment() | 310 self.tool.CleanUpEnvironment() |
| 391 if self._cleanup_test_files: | 311 if self._cleanup_test_files: |
| 392 self.adb.RemovePushedFiles() | 312 self.adb.RemovePushedFiles() |
| 393 super(TestRunner, self).TearDown() | 313 super(TestRunner, self).TearDown() |
| OLD | NEW |