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

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

Issue 2392643003: Removes files from //build that we don't need (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 """Generates test runner factory and tests for instrumentation tests."""
6
7 import logging
8 import os
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
15 from pylib.instrumentation import test_package
16 from pylib.instrumentation import test_runner
17
18 DEVICE_DATA_DIR = 'chrome/test/data'
19
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 }
25
26 DEPS_EXCLUSION_LIST = []
27
28 # TODO(mikecase): Remove this function and the constant DEVICE_DATA_DIR
29 # once all data deps are pushed to the same location on the device.
30 def _PushExtraSuiteDataDeps(device, test_apk):
31 """Pushes some extra data files/dirs needed by some test suite.
32
33 Args:
34 test_apk: The test suite basename for which to return file paths.
35 """
36 if test_apk in ['ChromeTest', 'ContentShellTest']:
37 test_files = 'net/data/ssl/certificates'
38 host_device_file_tuple = [
39 (os.path.join(constants.DIR_SOURCE_ROOT, test_files),
40 os.path.join(device.GetExternalStoragePath(), test_files))]
41 device.PushChangedFiles(host_device_file_tuple)
42
43
44 # TODO(mikecase): Remove this function once everything uses
45 # base_setup.PushDataDeps to push data deps to the device.
46 def _PushDataDeps(device, test_options):
47 valgrind_tools.PushFilesForTool(test_options.tool, device)
48
49 host_device_file_tuples = []
50 for dest_host_pair in test_options.test_data:
51 dst_src = dest_host_pair.split(':', 1)
52 dst_layer = dst_src[0]
53 host_src = dst_src[1]
54 host_test_files_path = os.path.join(constants.DIR_SOURCE_ROOT, host_src)
55 if os.path.exists(host_test_files_path):
56 host_device_file_tuples += [(
57 host_test_files_path,
58 '%s/%s/%s' % (
59 device.GetExternalStoragePath(),
60 DEVICE_DATA_DIR,
61 dst_layer))]
62 if host_device_file_tuples:
63 device.PushChangedFiles(host_device_file_tuples)
64
65
66 def Setup(test_options, devices):
67 """Create and return the test runner factory and tests.
68
69 Args:
70 test_options: An InstrumentationOptions object.
71
72 Returns:
73 A tuple of (TestRunnerFactory, tests).
74 """
75 if (test_options.coverage_dir and not
76 os.path.exists(test_options.coverage_dir)):
77 os.makedirs(test_options.coverage_dir)
78
79 test_pkg = test_package.TestPackage(test_options.test_apk_path,
80 test_options.test_apk_jar_path,
81 test_options.test_support_apk_path)
82 tests = test_pkg.GetAllMatchingTests(
83 test_options.annotations,
84 test_options.exclude_annotations,
85 test_options.test_filter)
86 if not tests:
87 logging.error('No instrumentation tests to run with current args.')
88
89 if test_options.test_data:
90 device_utils.DeviceUtils.parallel(devices).pMap(
91 _PushDataDeps, test_options)
92
93 if test_options.isolate_file_path:
94 i = base_setup.GenerateDepsDirUsingIsolate(test_options.test_apk,
95 test_options.isolate_file_path,
96 ISOLATE_FILE_PATHS,
97 DEPS_EXCLUSION_LIST)
98 def push_data_deps_to_device_dir(device):
99 base_setup.PushDataDeps(device, device.GetExternalStoragePath(),
100 test_options)
101 device_utils.DeviceUtils.parallel(devices).pMap(
102 push_data_deps_to_device_dir)
103 if i:
104 i.Clear()
105
106 device_utils.DeviceUtils.parallel(devices).pMap(
107 _PushExtraSuiteDataDeps, test_options.test_apk)
108
109 def TestRunnerFactory(device, shard_index):
110 return test_runner.TestRunner(test_options, device, shard_index,
111 test_pkg)
112
113 return (TestRunnerFactory, tests)
OLDNEW
« no previous file with comments | « build/android/pylib/instrumentation/json_perf_parser.py ('k') | build/android/pylib/instrumentation/test_jar.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698