Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(442)

Side by Side Diff: build/android/pylib/gtest/test_runner.py

Issue 18233018: [Android] Use isolate remap instead of check. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: webkit_unit_tests depend on third_party/hyphen/hyph_en_US.dic Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 == 'base_unittests': 33 if test_suite_basename == 'media_unittests':
78 return [
79 'base/test/data/',
80 ]
81 elif test_suite_basename == 'unit_tests':
82 test_files = [
83 'base/test/data/',
84 'chrome/test/data/download-test1.lib',
85 'chrome/test/data/extensions/bad_magic.crx',
86 'chrome/test/data/extensions/good.crx',
87 'chrome/test/data/extensions/icon1.png',
88 'chrome/test/data/extensions/icon2.png',
89 'chrome/test/data/extensions/icon3.png',
90 'chrome/test/data/extensions/allow_silent_upgrade/',
91 'chrome/test/data/extensions/app/',
92 'chrome/test/data/extensions/bad/',
93 'chrome/test/data/extensions/effective_host_permissions/',
94 'chrome/test/data/extensions/empty_manifest/',
95 'chrome/test/data/extensions/good/Extensions/',
96 'chrome/test/data/extensions/manifest_tests/',
97 'chrome/test/data/extensions/page_action/',
98 'chrome/test/data/extensions/permissions/',
99 'chrome/test/data/extensions/script_and_capture/',
100 'chrome/test/data/extensions/unpacker/',
101 'chrome/test/data/bookmarks/',
102 'chrome/test/data/components/',
103 'chrome/test/data/extensions/json_schema_test.js',
104 'chrome/test/data/History/',
105 'chrome/test/data/json_schema_validator/',
106 'chrome/test/data/pref_service/',
107 'chrome/test/data/simple_open_search.xml',
108 'chrome/test/data/top_sites/',
109 'chrome/test/data/web_app_info/',
110 'chrome/test/data/webui/',
111 'chrome/third_party/mock4js/',
112 'components/test/data/web_database',
113 'net/data/ssl/certificates',
114 'third_party/accessibility-developer-tools/gen/axs_testing.js',
115 'third_party/zlib/google/test/data',
116 ]
117 # The following are spell check data. Now only list the data under
118 # third_party/hunspell_dictionaries which are used by unit tests.
119 old_cwd = os.getcwd()
120 os.chdir(constants.DIR_SOURCE_ROOT)
121 test_files += glob.glob('third_party/hunspell_dictionaries/*.bdic')
122 os.chdir(old_cwd)
123 return test_files
124 elif test_suite_basename == 'media_unittests':
125 return [ 34 return [
126 'media/test/data', 35 'media/test/data',
127 ] 36 ]
128 elif test_suite_basename == 'net_unittests': 37 elif test_suite_basename == 'net_unittests':
129 return [ 38 return [
130 'chrome/test/data/animate1.gif', 39 'chrome/test/data/animate1.gif',
131 'chrome/test/data/simple.html', 40 'chrome/test/data/simple.html',
132 'net/data/cache_tests', 41 'net/data/cache_tests',
133 'net/data/filter_unittests', 42 'net/data/filter_unittests',
134 'net/data/ftp', 43 'net/data/ftp',
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 test_arguments: Additional arguments to pass to the test binary. 159 test_arguments: Additional arguments to pass to the test binary.
251 timeout: Timeout for each test. 160 timeout: Timeout for each test.
252 cleanup_test_files: Whether or not to cleanup test files on device. 161 cleanup_test_files: Whether or not to cleanup test files on device.
253 tool_name: Name of the Valgrind tool. 162 tool_name: Name of the Valgrind tool.
254 build_type: 'Release' or 'Debug'. 163 build_type: 'Release' or 'Debug'.
255 in_webkit_checkout: Whether the suite is being run from a WebKit checkout. 164 in_webkit_checkout: Whether the suite is being run from a WebKit checkout.
256 push_deps: If True, push all dependencies to the device. 165 push_deps: If True, push all dependencies to the device.
257 test_apk_package_name: Apk package name for tests running in APKs. 166 test_apk_package_name: Apk package name for tests running in APKs.
258 test_activity_name: Test activity to invoke for APK tests. 167 test_activity_name: Test activity to invoke for APK tests.
259 command_line_file: Filename to use to pass arguments to tests. 168 command_line_file: Filename to use to pass arguments to tests.
169 deps_dir: The path to the dependency dir on the host to push to the device.
260 """ 170 """
261 171
262 def __init__(self, device, test_suite, test_arguments, timeout, 172 def __init__(self, device, test_suite, test_arguments, timeout,
263 cleanup_test_files, tool_name, build_type, 173 cleanup_test_files, tool_name, build_type,
264 in_webkit_checkout, push_deps, test_apk_package_name=None, 174 in_webkit_checkout, push_deps, test_apk_package_name=None,
265 test_activity_name=None, command_line_file=None): 175 test_activity_name=None, command_line_file=None, deps_dir=None):
266 super(TestRunner, self).__init__(device, tool_name, build_type, push_deps) 176 super(TestRunner, self).__init__(device, tool_name, build_type, push_deps)
267 self._running_on_emulator = self.device.startswith('emulator') 177 self._running_on_emulator = self.device.startswith('emulator')
268 self._test_arguments = test_arguments 178 self._test_arguments = test_arguments
269 self.in_webkit_checkout = in_webkit_checkout 179 self.in_webkit_checkout = in_webkit_checkout
270 self._cleanup_test_files = cleanup_test_files 180 self._cleanup_test_files = cleanup_test_files
181 self._deps_dir = deps_dir
271 182
272 logging.warning('Test suite: ' + test_suite) 183 logging.warning('Test suite: ' + test_suite)
273 if os.path.splitext(test_suite)[1] == '.apk': 184 if os.path.splitext(test_suite)[1] == '.apk':
274 self.test_package = test_package_apk.TestPackageApk( 185 self.test_package = test_package_apk.TestPackageApk(
275 self.adb, 186 self.adb,
276 device, 187 device,
277 test_suite, 188 test_suite,
278 timeout, 189 timeout,
279 self._cleanup_test_files, 190 self._cleanup_test_files,
280 self.tool, 191 self.tool,
(...skipping 13 matching lines...) Expand all
294 self._cleanup_test_files, 205 self._cleanup_test_files,
295 self.tool, 206 self.tool,
296 symbols_dir) 207 symbols_dir)
297 208
298 #override 209 #override
299 def InstallTestPackage(self): 210 def InstallTestPackage(self):
300 self.test_package.StripAndCopyExecutable() 211 self.test_package.StripAndCopyExecutable()
301 212
302 #override 213 #override
303 def PushDataDeps(self): 214 def PushDataDeps(self):
215 self.adb.WaitForSdCardReady(20)
304 self.test_package.PushDataAndPakFiles() 216 self.test_package.PushDataAndPakFiles()
305 self.tool.CopyFiles() 217 self.tool.CopyFiles()
306 test_data = _GetDataFilesForTestSuite(self.test_package.test_suite_dirname,
307 self.test_package.test_suite_basename)
308 if test_data:
309 # Make sure SD card is ready.
310 self.adb.WaitForSdCardReady(20)
311 self.CopyTestData(test_data, self.adb.GetExternalStorage())
312 if self.test_package.test_suite_basename == 'webkit_unit_tests': 218 if self.test_package.test_suite_basename == 'webkit_unit_tests':
313 self.PushWebKitUnitTestsData() 219 self.PushWebKitUnitTestsData()
220 return
221
222 if not self._deps_dir:
223 logging.info('Did not find an isolate file for the test suite.')
224 for p in _GetDataFilesForTestSuite(self.test_package.test_suite_basename):
225 self.adb.PushIfNeeded(
226 os.path.join(constants.DIR_SOURCE_ROOT, p),
227 os.path.join(self.adb.GetExternalStorage(), p))
228 return
229
230 for p in os.listdir(self._deps_dir):
231 self.adb.PushIfNeeded(
232 os.path.join(self._deps_dir, p),
233 os.path.join(self.adb.GetExternalStorage(), p))
314 234
315 def PushWebKitUnitTestsData(self): 235 def PushWebKitUnitTestsData(self):
316 """Pushes the webkit_unit_tests data files to the device. 236 """Pushes the webkit_unit_tests data files to the device.
317 237
318 The path of this directory is different when the suite is being run as 238 The path of this directory is different when the suite is being run as
319 part of a WebKit check-out. 239 part of a WebKit check-out.
320 """ 240 """
321 webkit_src = os.path.join(constants.DIR_SOURCE_ROOT, 'third_party', 241 webkit_src = os.path.join(constants.DIR_SOURCE_ROOT, 'third_party',
322 'WebKit') 242 'WebKit')
323 if self.in_webkit_checkout: 243 if self.in_webkit_checkout:
324 webkit_src = os.path.join(constants.DIR_SOURCE_ROOT, '..', '..', '..') 244 webkit_src = os.path.join(constants.DIR_SOURCE_ROOT, '..', '..', '..')
325 245
326 self.adb.PushIfNeeded( 246 self.adb.PushIfNeeded(
327 os.path.join(webkit_src, 'Source/WebKit/chromium/tests/data'), 247 os.path.join(webkit_src, 'Source/WebKit/chromium/tests/data'),
328 os.path.join( 248 os.path.join(
329 self.adb.GetExternalStorage(), 249 self.adb.GetExternalStorage(),
330 'third_party/WebKit/Source/WebKit/chromium/tests/data')) 250 'third_party/WebKit/Source/WebKit/chromium/tests/data'))
251 self.adb.PushIfNeeded(
252 os.path.join(constants.DIR_SOURCE_ROOT,
253 'third_party/hyphen/hyph_en_US.dic'),
254 os.path.join(self.adb.GetExternalStorage(),
255 'third_party/hyphen/hyph_en_US.dic'))
331 256
332 # TODO(craigdh): There is no reason for this to be part of TestRunner. 257 # TODO(craigdh): There is no reason for this to be part of TestRunner.
333 def GetDisabledTests(self): 258 def GetDisabledTests(self):
334 """Returns a list of disabled tests. 259 """Returns a list of disabled tests.
335 260
336 Returns: 261 Returns:
337 A list of disabled tests obtained from 'filter' subdirectory. 262 A list of disabled tests obtained from 'filter' subdirectory.
338 """ 263 """
339 gtest_filter_base_path = os.path.join( 264 gtest_filter_base_path = os.path.join(
340 os.path.abspath(os.path.dirname(__file__)), 265 os.path.abspath(os.path.dirname(__file__)),
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 self.LaunchChromeTestServerSpawner() 303 self.LaunchChromeTestServerSpawner()
379 self.tool.SetupEnvironment() 304 self.tool.SetupEnvironment()
380 305
381 #override 306 #override
382 def TearDown(self): 307 def TearDown(self):
383 """Cleans up the test enviroment for the test suite.""" 308 """Cleans up the test enviroment for the test suite."""
384 self.tool.CleanUpEnvironment() 309 self.tool.CleanUpEnvironment()
385 if self._cleanup_test_files: 310 if self._cleanup_test_files:
386 self.adb.RemovePushedFiles() 311 self.adb.RemovePushedFiles()
387 super(TestRunner, self).TearDown() 312 super(TestRunner, self).TearDown()
OLDNEW
« no previous file with comments | « build/android/pylib/gtest/test_package.py ('k') | build/android/pylib/instrumentation/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698