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

Side by Side Diff: build/android/pylib/instrumentation/setup.py

Issue 689293002: Add option to push files to device using isolate for instrumentation tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved shared functions into new base_setup module. Created 6 years, 1 month 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
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 """Generates test runner factory and tests for instrumentation tests.""" 5 """Generates test runner factory and tests for instrumentation tests."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 9
10 from pylib import constants
11 from pylib import valgrind_tools
12
13 from pylib.base import base_setup
14 from pylib.device import device_utils
10 from pylib.instrumentation import test_package 15 from pylib.instrumentation import test_package
11 from pylib.instrumentation import test_runner 16 from pylib.instrumentation import test_runner
12 17
18 DEVICE_DATA_DIR = 'chrome/test/data'
13 19
14 def Setup(test_options): 20 ISOLATE_FILE_PATHS = {
21 'AndroidWebViewTest': 'android_webview/android_webview_test_apk.isolate',
22 'ChromeShellTest': 'chrome/chrome_shell_test_apk.isolate',
23 'ContentShellTest': 'content/content_shell_test_apk.isolate',
24 'MojoTest': 'mojo/mojo_test_apk.isolate',
jbudorick 2014/11/03 15:52:32 I'll talk to you about this today, but it's probab
mikecase (-- gone --) 2014/11/03 19:20:05 Acknowledged.
25 }
26
27 DEPS_EXCLUSION_LIST = []
28
29 def _PushExtraSuiteDataDeps(device, test_apk):
30 """Pushes some extra data files/dirs needed by some test suite.
31
32 Args:
33 test_apk: The test suite basename for which to return file paths.
34 """
35 if test_apk in ['ChromeTest', 'ContentShellTest']:
36 test_files = 'net/data/ssl/certificates'
jbudorick 2014/11/03 15:52:33 Why isn't this directory handled in the .isolate f
mikecase (-- gone --) 2014/11/03 19:20:05 I would prefer to only have 1 function that does a
37 host_device_file_tuple = [
38 (os.path.join(constants.DIR_SOURCE_ROOT, test_files),
39 os.path.join(device.GetExternalStoragePath(), test_files))]
40 device.PushChangedFiles(host_device_file_tuple)
41
42
43 def _PushDataDeps(device, test_options):
44 valgrind_tools.PushFilesForTool(test_options.tool, device)
45
46 host_device_file_tuples = []
47 for dest_host_pair in test_options.test_data:
48 dst_src = dest_host_pair.split(':', 1)
49 dst_layer = dst_src[0]
50 host_src = dst_src[1]
51 host_test_files_path = os.path.join(constants.DIR_SOURCE_ROOT, host_src)
52 if os.path.exists(host_test_files_path):
53 host_device_file_tuples += [(
54 host_test_files_path,
55 '%s/%s/%s' % (
56 device.GetExternalStoragePath(),
57 DEVICE_DATA_DIR,
58 dst_layer))]
59 if host_device_file_tuples:
60 device.PushChangedFiles(host_device_file_tuples)
61
62
63 def Setup(test_options, devices):
15 """Create and return the test runner factory and tests. 64 """Create and return the test runner factory and tests.
16 65
17 Args: 66 Args:
18 test_options: An InstrumentationOptions object. 67 test_options: An InstrumentationOptions object.
19 68
20 Returns: 69 Returns:
21 A tuple of (TestRunnerFactory, tests). 70 A tuple of (TestRunnerFactory, tests).
22 """ 71 """
23 if (test_options.coverage_dir and not 72 if (test_options.coverage_dir and not
24 os.path.exists(test_options.coverage_dir)): 73 os.path.exists(test_options.coverage_dir)):
25 os.makedirs(test_options.coverage_dir) 74 os.makedirs(test_options.coverage_dir)
26 75
27 test_pkg = test_package.TestPackage(test_options.test_apk_path, 76 test_pkg = test_package.TestPackage(test_options.test_apk_path,
28 test_options.test_apk_jar_path, 77 test_options.test_apk_jar_path,
29 test_options.test_support_apk_path) 78 test_options.test_support_apk_path)
30 tests = test_pkg.GetAllMatchingTests( 79 tests = test_pkg.GetAllMatchingTests(
31 test_options.annotations, 80 test_options.annotations,
32 test_options.exclude_annotations, 81 test_options.exclude_annotations,
33 test_options.test_filter) 82 test_options.test_filter)
34 if not tests: 83 if not tests:
35 logging.error('No instrumentation tests to run with current args.') 84 logging.error('No instrumentation tests to run with current args.')
36 85
86 # TODO(mikecase): Remove this function once everything uses
87 # base_setup.PushDataDeps instead.
88 if test_options.test_data:
jbudorick 2014/11/03 15:52:33 This is only staying in here until you switch the
mikecase (-- gone --) 2014/11/03 19:20:05 Yes, once the recipes switch from using --test-dat
89 device_utils.DeviceUtils.parallel(devices).pMap(
90 _PushDataDeps, test_options)
91 else:
92 base_setup.GenerateDepsDirUsingIsolate(test_options.test_apk,
93 test_options.isolate_file_path,
94 ISOLATE_FILE_PATHS,
95 DEPS_EXCLUSION_LIST)
96 def DeviceDir(device):
97 return os.path.join(device.GetExternalStoragePath(), DEVICE_DATA_DIR)
jbudorick 2014/11/03 15:52:32 What happened to trying to get rid of DEVICE_DATA_
mikecase (-- gone --) 2014/11/03 19:20:05 If I do it, it will be in a different CL. It will
98
99 device_utils.DeviceUtils.parallel(devices).pMap(
100 (lambda d, opts: base_setup.PushDataDeps(d, DeviceDir(d), opts)),
jbudorick 2014/11/03 15:52:32 again w.r.t defining DeviceDir vs defining the lam
mikecase (-- gone --) 2014/11/03 19:20:05 Done.
101 test_options)
102
103 device_utils.DeviceUtils.parallel(devices).pMap(
104 _PushExtraSuiteDataDeps, test_options.test_apk)
105
37 def TestRunnerFactory(device, shard_index): 106 def TestRunnerFactory(device, shard_index):
38 return test_runner.TestRunner(test_options, device, shard_index, 107 return test_runner.TestRunner(test_options, device, shard_index,
39 test_pkg) 108 test_pkg)
40 109
41 return (TestRunnerFactory, tests) 110 return (TestRunnerFactory, tests)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698