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

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

Issue 1173363008: [Android] Refactor browser test execution. (RELAND) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed. Created 5 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
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 import tempfile
11 11
12 from pylib import constants 12 from pylib import constants
13 from pylib.base import base_test_result 13 from pylib.base import base_test_result
14 from pylib.base import test_instance 14 from pylib.base import test_instance
15 from pylib.utils import apk_helper
15 16
16 sys.path.append(os.path.join( 17 sys.path.append(os.path.join(
17 constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib', 'common')) 18 constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib', 'common'))
18 import unittest_util 19 import unittest_util
19 20
20 21
21 BROWSER_TEST_SUITES = [ 22 BROWSER_TEST_SUITES = [
22 'components_browsertests', 23 'components_browsertests',
23 'content_browsertests', 24 'content_browsertests',
24 ] 25 ]
25 26
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
27 # 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
28 # isolate files since pushing deps to devices is expensive. 52 # isolate files since pushing deps to devices is expensive.
29 # Wildcards are allowed. 53 # Wildcards are allowed.
30 _DEPS_EXCLUSION_LIST = [ 54 _DEPS_EXCLUSION_LIST = [
31 'chrome/test/data/extensions/api_test', 55 'chrome/test/data/extensions/api_test',
32 'chrome/test/data/extensions/secure_shell', 56 'chrome/test/data/extensions/secure_shell',
33 'chrome/test/data/firefox*', 57 'chrome/test/data/firefox*',
34 'chrome/test/data/gpu', 58 'chrome/test/data/gpu',
35 'chrome/test/data/image_decoding', 59 'chrome/test/data/image_decoding',
36 'chrome/test/data/import', 60 'chrome/test/data/import',
37 'chrome/test/data/page_cycler', 61 'chrome/test/data/page_cycler',
38 'chrome/test/data/perf', 62 'chrome/test/data/perf',
39 'chrome/test/data/pyauto_private', 63 'chrome/test/data/pyauto_private',
40 'chrome/test/data/safari_import', 64 'chrome/test/data/safari_import',
41 'chrome/test/data/scroll', 65 'chrome/test/data/scroll',
42 'chrome/test/data/third_party', 66 'chrome/test/data/third_party',
43 'third_party/hunspell_dictionaries/*.dic', 67 'third_party/hunspell_dictionaries/*.dic',
44 # crbug.com/258690 68 # crbug.com/258690
45 'webkit/data/bmp_decoder', 69 'webkit/data/bmp_decoder',
46 'webkit/data/ico_decoder', 70 'webkit/data/ico_decoder',
47 ] 71 ]
48 72
49 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
50 # 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
51 # results. 82 # results.
52 _RE_TEST_STATUS = re.compile( 83 _RE_TEST_STATUS = re.compile(
53 r'\[ +((?:RUN)|(?:FAILED)|(?:OK)) +\] ?([^ ]+)(?: \((\d+) ms\))?$') 84 r'\[ +((?:RUN)|(?:FAILED)|(?:OK)) +\] ?([^ ]+)(?: \((\d+) ms\))?$')
54 _RE_TEST_RUN_STATUS = re.compile( 85 _RE_TEST_RUN_STATUS = re.compile(
55 r'\[ +(PASSED|RUNNER_FAILED|CRASHED) \] ?[^ ]+') 86 r'\[ +(PASSED|RUNNER_FAILED|CRASHED) \] ?[^ ]+')
56 87
57 88
58 # TODO(jbudorick): Make this a class method of GtestTestInstance once 89 # TODO(jbudorick): Make this a class method of GtestTestInstance once
59 # test_package_apk and test_package_exe are gone. 90 # test_package_apk and test_package_exe are gone.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 raise ValueError('Platform mode currently supports only 1 gtest suite') 130 raise ValueError('Platform mode currently supports only 1 gtest suite')
100 self._suite = args.suite_name[0] 131 self._suite = args.suite_name[0]
101 132
102 self._apk_path = os.path.join( 133 self._apk_path = os.path.join(
103 constants.GetOutDirectory(), '%s_apk' % self._suite, 134 constants.GetOutDirectory(), '%s_apk' % self._suite,
104 '%s-debug.apk' % self._suite) 135 '%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
131 if args.app_data_files: 183 if args.app_data_files:
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 logging.info(l) 285 logging.info(l)
234 return results 286 return results
235 287
236 #override 288 #override
237 def TearDown(self): 289 def TearDown(self):
238 """Clear the mappings created by SetUp.""" 290 """Clear the mappings created by SetUp."""
239 if self._isolate_delegate: 291 if self._isolate_delegate:
240 self._isolate_delegate.Clear() 292 self._isolate_delegate.Clear()
241 293
242 @property 294 @property
295 def activity(self):
296 return self._activity
297
298 @property
243 def apk(self): 299 def apk(self):
244 return self._apk_path 300 return self._apk_path
245 301
246 @property 302 @property
247 def app_file_dir(self): 303 def app_file_dir(self):
248 return self._app_data_file_dir 304 return self._app_data_file_dir
249 305
250 @property 306 @property
251 def app_files(self): 307 def app_files(self):
252 return self._app_data_files 308 return self._app_data_files
253 309
254 @property 310 @property
255 def exe(self): 311 def exe(self):
256 return self._exe_path 312 return self._exe_path
257 313
258 @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
259 def suite(self): 327 def suite(self):
260 return self._suite 328 return self._suite
261 329
OLDNEW
« no previous file with comments | « base/android/java/src/org/chromium/base/Log.java ('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