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

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

Issue 17267004: [Android] Enable using isolate files to get a list of data dependencies to push to the device. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Generate isolated files Created 7 years, 6 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
« base/base_unittests.isolate ('K') | « base/base_unittests.isolate ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5 import glob
6 import logging 6 import logging
7 import os 7 import os
8 import sys
8 9
9 from pylib import android_commands 10 from pylib import android_commands
11 from pylib import cmd_helper
10 from pylib import constants 12 from pylib import constants
11 from pylib import perf_tests_helper 13 from pylib import perf_tests_helper
12 from pylib.android_commands import errors 14 from pylib.android_commands import errors
13 from pylib.base import base_test_result 15 from pylib.base import base_test_result
14 from pylib.base import base_test_runner 16 from pylib.base import base_test_runner
15 from pylib.utils import run_tests_helper 17 from pylib.utils import run_tests_helper
16 18
17 import test_package_apk 19 import test_package_apk
18 import test_package_executable 20 import test_package_executable
19 21
22 sys.path.insert(
23 0, os.path.join(constants.DIR_SOURCE_ROOT, 'tools', 'swarm_client'))
24 import run_isolated
20 25
21 def _GetDataFilesForTestSuite(test_suite_basename): 26
27 _ISOLATE_FILE_PATHS = {
28 'base_unittests': 'base/base_unittests.isolate',
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):
22 """Returns a list of data files/dirs needed by the test suite. 39 """Returns a list of data files/dirs needed by the test suite.
23 40
24 Args: 41 Args:
25 test_suite_basename: The test suite basename for which to return file paths. 42 product_dir: Absolute path to product directory (e.g. /../out/Debug).
43 test_suite_basename: The test suite basename (e.g. base_unittests).
26 44
27 Returns: 45 Returns:
28 A list of test file and directory paths. 46 A list of test file and directory paths.
29 """ 47 """
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 assert isolated_content['os'] == 'android'
70 return isolated_content['files'].keys()
71
72 logging.info('Did not find an isolate file for the test suite.')
30 # Ideally, we'd just push all test data. However, it has >100MB, and a lot 73 # Ideally, we'd just push all test data. However, it has >100MB, and a lot
31 # of the files are not relevant (some are used for browser_tests, others for 74 # of the files are not relevant (some are used for browser_tests, others for
32 # features not supported, etc..). 75 # features not supported, etc..).
33 if test_suite_basename == 'base_unittests': 76 if test_suite_basename == 'unit_tests':
34 return [
35 'base/test/data/',
36 ]
37 elif test_suite_basename == 'unit_tests':
38 test_files = [ 77 test_files = [
39 'base/test/data/', 78 'base/test/data/',
40 'chrome/test/data/download-test1.lib', 79 'chrome/test/data/download-test1.lib',
41 'chrome/test/data/extensions/bad_magic.crx', 80 'chrome/test/data/extensions/bad_magic.crx',
42 'chrome/test/data/extensions/good.crx', 81 'chrome/test/data/extensions/good.crx',
43 'chrome/test/data/extensions/icon1.png', 82 'chrome/test/data/extensions/icon1.png',
44 'chrome/test/data/extensions/icon2.png', 83 'chrome/test/data/extensions/icon2.png',
45 'chrome/test/data/extensions/icon3.png', 84 'chrome/test/data/extensions/icon3.png',
46 'chrome/test/data/extensions/allow_silent_upgrade/', 85 'chrome/test/data/extensions/allow_silent_upgrade/',
47 'chrome/test/data/extensions/app/', 86 'chrome/test/data/extensions/app/',
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 symbols_dir) 312 symbols_dir)
274 313
275 #override 314 #override
276 def InstallTestPackage(self): 315 def InstallTestPackage(self):
277 self.test_package.StripAndCopyExecutable() 316 self.test_package.StripAndCopyExecutable()
278 self.test_package.PushDataAndPakFiles() 317 self.test_package.PushDataAndPakFiles()
279 318
280 #override 319 #override
281 def PushDataDeps(self): 320 def PushDataDeps(self):
282 self.tool.CopyFiles() 321 self.tool.CopyFiles()
283 test_data = _GetDataFilesForTestSuite(self.test_package.test_suite_basename) 322 test_data = _GetDataFilesForTestSuite(self.test_package.test_suite_dirname,
323 self.test_package.test_suite_basename)
284 if test_data: 324 if test_data:
285 # Make sure SD card is ready. 325 # Make sure SD card is ready.
286 self.adb.WaitForSdCardReady(20) 326 self.adb.WaitForSdCardReady(20)
287 for data in test_data: 327 for data in test_data:
288 self.CopyTestData([data], self.adb.GetExternalStorage()) 328 self.CopyTestData([data], self.adb.GetExternalStorage())
289 optional_test_data = _GetOptionalDataFilesForTestSuite( 329 optional_test_data = _GetOptionalDataFilesForTestSuite(
290 self.test_package.test_suite_basename) 330 self.test_package.test_suite_basename)
291 if optional_test_data: 331 if optional_test_data:
292 self.adb.WaitForSdCardReady(20) 332 self.adb.WaitForSdCardReady(20)
293 for data in optional_test_data: 333 for data in optional_test_data:
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 self.LaunchChromeTestServerSpawner() 407 self.LaunchChromeTestServerSpawner()
368 self.tool.SetupEnvironment() 408 self.tool.SetupEnvironment()
369 409
370 #override 410 #override
371 def TearDown(self): 411 def TearDown(self):
372 """Cleans up the test enviroment for the test suite.""" 412 """Cleans up the test enviroment for the test suite."""
373 self.tool.CleanUpEnvironment() 413 self.tool.CleanUpEnvironment()
374 if self._cleanup_test_files: 414 if self._cleanup_test_files:
375 self.adb.RemovePushedFiles() 415 self.adb.RemovePushedFiles()
376 super(TestRunner, self).TearDown() 416 super(TestRunner, self).TearDown()
OLDNEW
« base/base_unittests.isolate ('K') | « base/base_unittests.isolate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698