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

Side by Side Diff: build/android/buildbot/bb_device_steps.py

Issue 20210002: [Android] Sets up a coverage system for java using EMMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Break apart native and java coverage flags for gyp Created 7 years, 4 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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import collections 6 import collections
7 import glob 7 import glob
8 import multiprocessing 8 import multiprocessing
9 import os 9 import os
10 import shutil 10 import shutil
11 import sys 11 import sys
12 12
13 import bb_utils 13 import bb_utils
14 import bb_annotations 14 import bb_annotations
15 15
16 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) 16 sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
17 import provision_devices 17 import provision_devices
18 from pylib import android_commands 18 from pylib import android_commands
19 from pylib import constants 19 from pylib import constants
20 from pylib.gtest import gtest_config 20 from pylib.gtest import gtest_config
21 21
22 sys.path.append(os.path.join( 22 sys.path.append(os.path.join(
23 constants.DIR_SOURCE_ROOT, 'third_party', 'android_testrunner')) 23 constants.DIR_SOURCE_ROOT, 'third_party', 'android_testrunner'))
24 import errors 24 import errors
25 25
26 26
27 SLAVE_SCRIPTS_DIR = os.path.join(bb_utils.BB_BUILD_DIR, 'scripts', 'slave')
27 CHROME_SRC = constants.DIR_SOURCE_ROOT 28 CHROME_SRC = constants.DIR_SOURCE_ROOT
28 LOGCAT_DIR = os.path.join(CHROME_SRC, 'out', 'logcat') 29 LOGCAT_DIR = os.path.join(CHROME_SRC, 'out', 'logcat')
30 COVERAGE_DIR = os.path.join(CHROME_SRC, 'out', 'coverage')
frankf 2013/08/13 23:33:39 Move this to constants.py
gkanwar1 2013/08/15 19:49:20 Done.
31 REVISION_FILENAME = 'FULL_BUILD_REVISION'
29 32
30 # Describes an instrumation test suite: 33 # Describes an instrumation test suite:
31 # test: Name of test we're running. 34 # test: Name of test we're running.
32 # apk: apk to be installed. 35 # apk: apk to be installed.
33 # apk_package: package for the apk to be installed. 36 # apk_package: package for the apk to be installed.
34 # test_apk: apk to run tests on. 37 # test_apk: apk to run tests on.
35 # test_data: data folder in format destination:source. 38 # test_data: data folder in format destination:source.
36 # host_driven_root: The host-driven test root directory. 39 # host_driven_root: The host-driven test root directory.
37 # annotation: Annotation of the tests to include. 40 # annotation: Annotation of the tests to include.
38 # exclude_annotation: The annotation of the tests to exclude. 41 # exclude_annotation: The annotation of the tests to exclude.
39 I_TEST = collections.namedtuple('InstrumentationTest', [ 42 I_TEST = collections.namedtuple('InstrumentationTest', [
40 'name', 'apk', 'apk_package', 'test_apk', 'test_data', 'host_driven_root', 43 'name', 'apk', 'apk_package', 'test_apk', 'test_data', 'coverage',
41 'annotation', 'exclude_annotation', 'extra_flags']) 44 'host_driven_root', 'annotation', 'exclude_annotation', 'extra_flags'])
42 45
43 def I(name, apk, apk_package, test_apk, test_data, host_driven_root=None, 46 def I(name, apk, apk_package, test_apk, test_data, coverage=False,
44 annotation=None, exclude_annotation=None, extra_flags=None): 47 host_driven_root=None, annotation=None, exclude_annotation=None,
45 return I_TEST(name, apk, apk_package, test_apk, test_data, host_driven_root, 48 extra_flags=None):
46 annotation, exclude_annotation, extra_flags) 49 return I_TEST(name, apk, apk_package, test_apk, test_data, coverage,
50 host_driven_root, annotation, exclude_annotation, extra_flags)
47 51
48 INSTRUMENTATION_TESTS = dict((suite.name, suite) for suite in [ 52 INSTRUMENTATION_TESTS = dict((suite.name, suite) for suite in [
49 I('ContentShell', 53 I('ContentShell',
50 'ContentShell.apk', 54 'ContentShell.apk',
51 'org.chromium.content_shell_apk', 55 'org.chromium.content_shell_apk',
52 'ContentShellTest', 56 'ContentShellTest',
53 'content:content/test/data/android/device_files'), 57 'content:content/test/data/android/device_files',
58 coverage=True),
54 I('ChromiumTestShell', 59 I('ChromiumTestShell',
55 'ChromiumTestShell.apk', 60 'ChromiumTestShell.apk',
56 'org.chromium.chrome.testshell', 61 'org.chromium.chrome.testshell',
57 'ChromiumTestShellTest', 62 'ChromiumTestShellTest',
58 'chrome:chrome/test/data/android/device_files', 63 'chrome:chrome/test/data/android/device_files',
59 constants.CHROMIUM_TEST_SHELL_HOST_DRIVEN_DIR), 64 host_driven_root=constants.CHROMIUM_TEST_SHELL_HOST_DRIVEN_DIR),
60 I('AndroidWebView', 65 I('AndroidWebView',
61 'AndroidWebView.apk', 66 'AndroidWebView.apk',
62 'org.chromium.android_webview.shell', 67 'org.chromium.android_webview.shell',
63 'AndroidWebViewTest', 68 'AndroidWebViewTest',
64 'webview:android_webview/test/data/device_files'), 69 'webview:android_webview/test/data/device_files'),
65 ]) 70 ])
66 71
67 VALID_TESTS = set(['chromedriver', 'ui', 'unit', 'webkit', 'webkit_layout', 72 VALID_TESTS = set(['chromedriver', 'ui', 'unit', 'webkit', 'webkit_layout',
68 'webrtc']) 73 'webrtc'])
69 74
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 InstallApk(options, test) 163 InstallApk(options, test)
159 args = ['--test-apk', test.test_apk, '--test_data', test.test_data, 164 args = ['--test-apk', test.test_apk, '--test_data', test.test_data,
160 '--verbose'] 165 '--verbose']
161 if options.target == 'Release': 166 if options.target == 'Release':
162 args.append('--release') 167 args.append('--release')
163 if options.asan: 168 if options.asan:
164 args.append('--tool=asan') 169 args.append('--tool=asan')
165 if options.flakiness_server: 170 if options.flakiness_server:
166 args.append('--flakiness-dashboard-server=%s' % 171 args.append('--flakiness-dashboard-server=%s' %
167 options.flakiness_server) 172 options.flakiness_server)
173 if options.coverage_bucket and test.coverage:
174 args.append('--coverage-dir=%s' % COVERAGE_DIR)
168 if test.host_driven_root: 175 if test.host_driven_root:
169 args.append('--python_test_root=%s' % test.host_driven_root) 176 args.append('--python_test_root=%s' % test.host_driven_root)
170 if test.annotation: 177 if test.annotation:
171 args.extend(['-A', test.annotation]) 178 args.extend(['-A', test.annotation])
172 if test.exclude_annotation: 179 if test.exclude_annotation:
173 args.extend(['-E', test.exclude_annotation]) 180 args.extend(['-E', test.exclude_annotation])
174 if test.extra_flags: 181 if test.extra_flags:
175 args.extend(test.extra_flags) 182 args.extend(test.extra_flags)
176 if python_only: 183 if python_only:
177 args.append('-p') 184 args.append('-p')
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 272
266 273
267 def RunUnitTests(options): 274 def RunUnitTests(options):
268 RunTestSuites(options, gtest_config.STABLE_TEST_SUITES) 275 RunTestSuites(options, gtest_config.STABLE_TEST_SUITES)
269 276
270 277
271 def RunInstrumentationTests(options): 278 def RunInstrumentationTests(options):
272 for test in INSTRUMENTATION_TESTS.itervalues(): 279 for test in INSTRUMENTATION_TESTS.itervalues():
273 RunInstrumentationSuite(options, test) 280 RunInstrumentationSuite(options, test)
274 281
282 if options.coverage_bucket:
283 shutil.rmtree(COVERAGE_DIR, ignore_errors=True)
284 os.mkdir(COVERAGE_DIR)
285 RunCmd(['build/android/generate_emma_html.py',
286 '--coverage-dir', COVERAGE_DIR,
287 '--metadata-dir', os.path.join('out', options.target),
frankf 2013/08/13 23:33:39 How does this work? Did yo forget constants.DIR_SO
gkanwar1 2013/08/15 19:49:20 It's relative to the python running directory, whi
288 '--output', os.path.join(COVERAGE_DIR, 'coverage.html')])
289 revision_file = os.path.join(CHROME_SRC, 'out', options.target,
290 REVISION_FILENAME)
291
292 # If the revision file doesn't exist, we're just testing the bot
293 if os.path.exists(revision_file):
294 with open(revision_file) as f:
295 revision = f.read()
296 else:
297 revision = 'testing'
298
299 RunCmd([os.path.join(bb_utils.BB_BUILD_DIR, 'scripts',
300 'slave', 'gsutil_cp_dir.py'),
301 os.path.join(COVERAGE_DIR), 'gs://%s/%s' %
302 (options.coverage_bucket, revision)])
frankf 2013/08/13 23:33:39 As it stands, you're going to upload from all fyi
gkanwar1 2013/08/15 19:49:20 Yep, good point. Changing url to gs://<bucket>/<bo
303 bb_annotations.PrintLink(
304 'Coverage report',
305 'https://storage.googleapis.com/%s/%s/coverage.html'
306 % (options.coverage_bucket, revision))
307
275 308
276 def RunWebkitTests(options): 309 def RunWebkitTests(options):
277 RunTestSuites(options, ['webkit_unit_tests']) 310 RunTestSuites(options, ['webkit_unit_tests'])
278 RunWebkitLint(options.target) 311 RunWebkitLint(options.target)
279 312
280 313
281 def RunWebRTCTests(options): 314 def RunWebRTCTests(options):
282 RunTestSuites(options, gtest_config.WEBRTC_TEST_SUITES) 315 RunTestSuites(options, gtest_config.WEBRTC_TEST_SUITES)
283 316
284 317
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 help='Run experiemental tests') 379 help='Run experiemental tests')
347 parser.add_option('-f', '--test-filter', metavar='<filter>', default=[], 380 parser.add_option('-f', '--test-filter', metavar='<filter>', default=[],
348 action='append', 381 action='append',
349 help=('Run a test suite. Test suites: "%s"' % 382 help=('Run a test suite. Test suites: "%s"' %
350 '", "'.join(VALID_TESTS))) 383 '", "'.join(VALID_TESTS)))
351 parser.add_option('--asan', action='store_true', help='Run tests with asan.') 384 parser.add_option('--asan', action='store_true', help='Run tests with asan.')
352 parser.add_option('--install', metavar='<apk name>', 385 parser.add_option('--install', metavar='<apk name>',
353 help='Install an apk by name') 386 help='Install an apk by name')
354 parser.add_option('--reboot', action='store_true', 387 parser.add_option('--reboot', action='store_true',
355 help='Reboot devices before running tests') 388 help='Reboot devices before running tests')
389 parser.add_option('--coverage-bucket',
390 help=('Bucket name to store coverage results. Coverage is '
391 'only run if this is set.'))
356 parser.add_option( 392 parser.add_option(
357 '--flakiness-server', 393 '--flakiness-server',
358 help='The flakiness dashboard server to which the results should be ' 394 help='The flakiness dashboard server to which the results should be '
359 'uploaded.') 395 'uploaded.')
360 parser.add_option( 396 parser.add_option(
361 '--auto-reconnect', action='store_true', 397 '--auto-reconnect', action='store_true',
362 help='Push script to device which restarts adbd on disconnections.') 398 help='Push script to device which restarts adbd on disconnections.')
363 parser.add_option( 399 parser.add_option(
364 '--logcat-dump-output', 400 '--logcat-dump-output',
365 help='The logcat dump output will be "tee"-ed into this file') 401 help='The logcat dump output will be "tee"-ed into this file')
(...skipping 12 matching lines...) Expand all
378 if unknown_tests: 414 if unknown_tests:
379 return sys.exit('Unknown tests %s' % list(unknown_tests)) 415 return sys.exit('Unknown tests %s' % list(unknown_tests))
380 416
381 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) 417 setattr(options, 'target', options.factory_properties.get('target', 'Debug'))
382 418
383 MainTestWrapper(options) 419 MainTestWrapper(options)
384 420
385 421
386 if __name__ == '__main__': 422 if __name__ == '__main__':
387 sys.exit(main(sys.argv)) 423 sys.exit(main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698