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

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

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 8 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
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 logging 5 import logging
6 import os 6 import os
7 import re 7 import re
8 import shutil 8 import shutil
9 import sys 9 import sys
10 import tempfile
10 11
11 from pylib import constants 12 from pylib import constants
12 from pylib.base import base_test_result 13 from pylib.base import base_test_result
13 from pylib.base import test_instance 14 from pylib.base import test_instance
15 from pylib.utils import apk_helper
14 16
15 sys.path.append(os.path.join( 17 sys.path.append(os.path.join(
16 constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib', 'common')) 18 constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib', 'common'))
17 import unittest_util 19 import unittest_util
18 20
19 21
22 BROWSER_TEST_SUITES = [
23 'components_browsertests',
24 'content_browsertests',
25 ]
26
27
28 _DEFAULT_ISOLATE_FILE_PATHS = {
29 'base_unittests': 'base/base_unittests.isolate',
30 'blink_heap_unittests':
31 'third_party/WebKit/Source/platform/heap/BlinkHeapUnitTests.isolate',
32 'breakpad_unittests': 'breakpad/breakpad_unittests.isolate',
33 'cc_perftests': 'cc/cc_perftests.isolate',
34 'components_browsertests': 'components/components_browsertests.isolate',
35 'components_unittests': 'components/components_unittests.isolate',
36 'content_browsertests': 'content/content_browsertests.isolate',
37 'content_unittests': 'content/content_unittests.isolate',
38 'media_perftests': 'media/media_perftests.isolate',
39 'media_unittests': 'media/media_unittests.isolate',
40 'midi_unittests': 'media/midi/midi_unittests.isolate',
41 'net_unittests': 'net/net_unittests.isolate',
42 'sql_unittests': 'sql/sql_unittests.isolate',
43 'sync_unit_tests': 'sync/sync_unit_tests.isolate',
44 'ui_base_unittests': 'ui/base/ui_base_tests.isolate',
45 'unit_tests': 'chrome/unit_tests.isolate',
46 'webkit_unit_tests':
47 'third_party/WebKit/Source/web/WebKitUnitTests.isolate',
48 }
49
50
20 # Used for filtering large data deps at a finer grain than what's allowed in 51 # Used for filtering large data deps at a finer grain than what's allowed in
21 # isolate files since pushing deps to devices is expensive. 52 # isolate files since pushing deps to devices is expensive.
22 # Wildcards are allowed. 53 # Wildcards are allowed.
23 _DEPS_EXCLUSION_LIST = [ 54 _DEPS_EXCLUSION_LIST = [
24 'chrome/test/data/extensions/api_test', 55 'chrome/test/data/extensions/api_test',
25 'chrome/test/data/extensions/secure_shell', 56 'chrome/test/data/extensions/secure_shell',
26 'chrome/test/data/firefox*', 57 'chrome/test/data/firefox*',
27 'chrome/test/data/gpu', 58 'chrome/test/data/gpu',
28 'chrome/test/data/image_decoding', 59 'chrome/test/data/image_decoding',
29 'chrome/test/data/import', 60 'chrome/test/data/import',
30 'chrome/test/data/page_cycler', 61 'chrome/test/data/page_cycler',
31 'chrome/test/data/perf', 62 'chrome/test/data/perf',
32 'chrome/test/data/pyauto_private', 63 'chrome/test/data/pyauto_private',
33 'chrome/test/data/safari_import', 64 'chrome/test/data/safari_import',
34 'chrome/test/data/scroll', 65 'chrome/test/data/scroll',
35 'chrome/test/data/third_party', 66 'chrome/test/data/third_party',
36 'third_party/hunspell_dictionaries/*.dic', 67 'third_party/hunspell_dictionaries/*.dic',
37 # crbug.com/258690 68 # crbug.com/258690
38 'webkit/data/bmp_decoder', 69 'webkit/data/bmp_decoder',
39 'webkit/data/ico_decoder', 70 'webkit/data/ico_decoder',
40 ] 71 ]
41 72
42 73
74 _EXTRA_NATIVE_TEST_ACTIVITY = (
75 'org.chromium.native_test.NativeTestInstrumentationTestRunner.'
76 'NativeTestActivity')
77 _EXTRA_SHARD_SIZE_LIMIT =(
78 'org.chromium.native_test.NativeTestInstrumentationTestRunner.'
79 'ShardSizeLimit')
80
43 # TODO(jbudorick): Remove these once we're no longer parsing stdout to generate 81 # TODO(jbudorick): Remove these once we're no longer parsing stdout to generate
44 # results. 82 # results.
45 _RE_TEST_STATUS = re.compile( 83 _RE_TEST_STATUS = re.compile(
46 r'\[ +((?:RUN)|(?:FAILED)|(?:OK)) +\] ?([^ ]+)(?: \((\d+) ms\))?$') 84 r'\[ +((?:RUN)|(?:FAILED)|(?:OK)) +\] ?([^ ]+)(?: \((\d+) ms\))?$')
47 _RE_TEST_RUN_STATUS = re.compile( 85 _RE_TEST_RUN_STATUS = re.compile(
48 r'\[ +(PASSED|RUNNER_FAILED|CRASHED) \] ?[^ ]+') 86 r'\[ +(PASSED|RUNNER_FAILED|CRASHED) \] ?[^ ]+')
49 87
50 88
51 # TODO(jbudorick): Make this a class method of GtestTestInstance once 89 # TODO(jbudorick): Make this a class method of GtestTestInstance once
52 # test_package_apk and test_package_exe are gone. 90 # test_package_apk and test_package_exe are gone.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 123
86 class GtestTestInstance(test_instance.TestInstance): 124 class GtestTestInstance(test_instance.TestInstance):
87 125
88 def __init__(self, args, isolate_delegate, error_func): 126 def __init__(self, args, isolate_delegate, error_func):
89 super(GtestTestInstance, self).__init__() 127 super(GtestTestInstance, self).__init__()
90 # TODO(jbudorick): Support multiple test suites. 128 # TODO(jbudorick): Support multiple test suites.
91 if len(args.suite_name) > 1: 129 if len(args.suite_name) > 1:
92 raise ValueError('Platform mode currently supports only 1 gtest suite') 130 raise ValueError('Platform mode currently supports only 1 gtest suite')
93 self._suite = args.suite_name[0] 131 self._suite = args.suite_name[0]
94 132
95 if (self._suite == 'content_browsertests' or 133 self._apk_path = os.path.join(
96 self._suite == 'components_browsertests'): 134 constants.GetOutDirectory(), '%s_apk' % self._suite,
97 error_func('%s are not currently supported ' 135 '%s-debug.apk' % self._suite)
98 'in platform mode.' % self._suite)
99 self._apk_path = os.path.join(
100 constants.GetOutDirectory(), 'apks', '%s.apk' % self._suite)
101 else:
102 self._apk_path = os.path.join(
103 constants.GetOutDirectory(), '%s_apk' % self._suite,
104 '%s-debug.apk' % self._suite)
105 self._exe_path = os.path.join(constants.GetOutDirectory(), 136 self._exe_path = os.path.join(constants.GetOutDirectory(),
106 self._suite) 137 self._suite)
107 if not os.path.exists(self._apk_path): 138 if not os.path.exists(self._apk_path):
108 self._apk_path = None 139 self._apk_path = None
140 self._activity = None
141 self._package = None
142 self._runner = None
143 else:
144 helper = apk_helper.ApkHelper(self._apk_path)
145 self._activity = helper.GetActivityName()
146 self._package = helper.GetPackageName()
147 self._runner = helper.GetInstrumentationName()
148 self._extras = {
149 _EXTRA_NATIVE_TEST_ACTIVITY: self._activity,
150 }
151 if self._suite in BROWSER_TEST_SUITES:
152 self._extras[_EXTRA_SHARD_SIZE_LIMIT] = 1
153
109 if not os.path.exists(self._exe_path): 154 if not os.path.exists(self._exe_path):
110 self._exe_path = None 155 self._exe_path = None
111 if not self._apk_path and not self._exe_path: 156 if not self._apk_path and not self._exe_path:
112 error_func('Could not find apk or executable for %s' % self._suite) 157 error_func('Could not find apk or executable for %s' % self._suite)
113 158
114 self._data_deps = [] 159 self._data_deps = []
115 if args.test_filter: 160 if args.test_filter:
116 self._gtest_filter = args.test_filter 161 self._gtest_filter = args.test_filter
117 elif args.test_filter_file: 162 elif args.test_filter_file:
118 with open(args.test_filter_file, 'r') as f: 163 with open(args.test_filter_file, 'r') as f:
119 self._gtest_filter = ':'.join(l.strip() for l in f) 164 self._gtest_filter = ':'.join(l.strip() for l in f)
120 else: 165 else:
121 self._gtest_filter = None 166 self._gtest_filter = None
167
168 if not args.isolate_file_path:
169 default_isolate_file_path = _DEFAULT_ISOLATE_FILE_PATHS.get(self._suite)
170 if default_isolate_file_path:
171 args.isolate_file_path = os.path.join(
172 constants.DIR_SOURCE_ROOT, default_isolate_file_path)
173
122 if args.isolate_file_path: 174 if args.isolate_file_path:
123 self._isolate_abs_path = os.path.abspath(args.isolate_file_path) 175 self._isolate_abs_path = os.path.abspath(args.isolate_file_path)
124 self._isolate_delegate = isolate_delegate 176 self._isolate_delegate = isolate_delegate
125 self._isolated_abs_path = os.path.join( 177 self._isolated_abs_path = os.path.join(
126 constants.GetOutDirectory(), '%s.isolated' % self._suite) 178 constants.GetOutDirectory(), '%s.isolated' % self._suite)
127 else: 179 else:
128 logging.warning('No isolate file provided. No data deps will be pushed.'); 180 logging.warning('No isolate file provided. No data deps will be pushed.');
129 self._isolate_delegate = None 181 self._isolate_delegate = None
130 182
183 if args.app_data_files:
184 self._app_data_files = args.app_data_files
185 if args.app_data_file_dir:
186 self._app_data_file_dir = args.app_data_file_dir
187 else:
188 self._app_data_file_dir = tempfile.mkdtemp()
189 logging.critical('Saving app files to %s', self._app_data_file_dir)
190 else:
191 self._app_data_files = None
192 self._app_data_file_dir = None
193
131 #override 194 #override
132 def TestType(self): 195 def TestType(self):
133 return 'gtest' 196 return 'gtest'
134 197
135 #override 198 #override
136 def SetUp(self): 199 def SetUp(self):
137 """Map data dependencies via isolate.""" 200 """Map data dependencies via isolate."""
138 if self._isolate_delegate: 201 if self._isolate_delegate:
139 self._isolate_delegate.Remap( 202 self._isolate_delegate.Remap(
140 self._isolate_abs_path, self._isolated_abs_path) 203 self._isolate_abs_path, self._isolated_abs_path)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 logging.info(l) 285 logging.info(l)
223 return results 286 return results
224 287
225 #override 288 #override
226 def TearDown(self): 289 def TearDown(self):
227 """Clear the mappings created by SetUp.""" 290 """Clear the mappings created by SetUp."""
228 if self._isolate_delegate: 291 if self._isolate_delegate:
229 self._isolate_delegate.Clear() 292 self._isolate_delegate.Clear()
230 293
231 @property 294 @property
295 def activity(self):
296 return self._activity
297
298 @property
232 def apk(self): 299 def apk(self):
233 return self._apk_path 300 return self._apk_path
234 301
235 @property 302 @property
303 def app_file_dir(self):
304 return self._app_data_file_dir
305
306 @property
307 def app_files(self):
308 return self._app_data_files
309
310 @property
236 def exe(self): 311 def exe(self):
237 return self._exe_path 312 return self._exe_path
238 313
239 @property 314 @property
315 def extras(self):
316 return self._extras
317
318 @property
319 def package(self):
320 return self._package
321
322 @property
323 def runner(self):
324 return self._runner
325
326 @property
240 def suite(self): 327 def suite(self):
241 return self._suite 328 return self._suite
242 329
OLDNEW
« no previous file with comments | « build/android/pylib/gtest/filter/webkit_unit_tests_disabled ('k') | build/android/pylib/gtest/local_device_gtest_run.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698