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

Unified Diff: build/android/buildbot/bb_device_steps.py

Issue 23345003: [Android] Buildbot changes for EMMA code coverage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/buildbot/bb_run_bot.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/buildbot/bb_device_steps.py
diff --git a/build/android/buildbot/bb_device_steps.py b/build/android/buildbot/bb_device_steps.py
index f020281bb7d751434151ee4f9f9d4c5ddfd4affc..67a496c17d20ed33467e4a72bfa1ed447c1fda6c 100755
--- a/build/android/buildbot/bb_device_steps.py
+++ b/build/android/buildbot/bb_device_steps.py
@@ -9,6 +9,7 @@ import multiprocessing
import os
import shutil
import sys
+import time
import bb_utils
import bb_annotations
@@ -24,8 +25,10 @@ sys.path.append(os.path.join(
import errors
+SLAVE_SCRIPTS_DIR = os.path.join(bb_utils.BB_BUILD_DIR, 'scripts', 'slave')
CHROME_SRC = constants.DIR_SOURCE_ROOT
LOGCAT_DIR = os.path.join(CHROME_SRC, 'out', 'logcat')
+REVISION_FILENAME = 'FULL_BUILD_REVISION'
# Describes an instrumation test suite:
# test: Name of test we're running.
@@ -37,13 +40,14 @@ LOGCAT_DIR = os.path.join(CHROME_SRC, 'out', 'logcat')
# annotation: Annotation of the tests to include.
# exclude_annotation: The annotation of the tests to exclude.
I_TEST = collections.namedtuple('InstrumentationTest', [
- 'name', 'apk', 'apk_package', 'test_apk', 'test_data', 'host_driven_root',
- 'annotation', 'exclude_annotation', 'extra_flags'])
+ 'name', 'apk', 'apk_package', 'test_apk', 'test_data', 'coverage',
+ 'host_driven_root', 'annotation', 'exclude_annotation', 'extra_flags'])
-def I(name, apk, apk_package, test_apk, test_data, host_driven_root=None,
- annotation=None, exclude_annotation=None, extra_flags=None):
- return I_TEST(name, apk, apk_package, test_apk, test_data, host_driven_root,
- annotation, exclude_annotation, extra_flags)
+def I(name, apk, apk_package, test_apk, test_data, coverage=True,
+ host_driven_root=None, annotation=None, exclude_annotation=None,
+ extra_flags=None):
+ return I_TEST(name, apk, apk_package, test_apk, test_data, coverage,
+ host_driven_root, annotation, exclude_annotation, extra_flags)
INSTRUMENTATION_TESTS = dict((suite.name, suite) for suite in [
I('ContentShell',
@@ -55,8 +59,7 @@ INSTRUMENTATION_TESTS = dict((suite.name, suite) for suite in [
'ChromiumTestShell.apk',
'org.chromium.chrome.testshell',
'ChromiumTestShellTest',
- 'chrome:chrome/test/data/android/device_files',
- constants.CHROMIUM_TEST_SHELL_HOST_DRIVEN_DIR),
frankf 2013/08/20 22:43:37 Why is this removed?
gkanwar1 2013/08/20 23:01:06 Oops, I think this was a mistake in transferring,
+ 'chrome:chrome/test/data/android/device_files'),
I('AndroidWebView',
'AndroidWebView.apk',
'org.chromium.android_webview.shell',
@@ -165,6 +168,9 @@ def RunInstrumentationSuite(options, test, flunk_on_failure=True,
if options.flakiness_server:
args.append('--flakiness-dashboard-server=%s' %
options.flakiness_server)
+ if options.coverage_bucket and test.coverage:
+ args.append('--coverage-dir=%s' % os.path.join(
+ CHROME_SRC, 'out', options.target, 'coverage'))
if test.host_driven_root:
args.append('--host-driven-root=%s' % test.host_driven_root)
if test.annotation:
@@ -271,9 +277,50 @@ def RunUnitTests(options):
def RunInstrumentationTests(options):
+ coverage_dir = os.path.join(CHROME_SRC, 'out', options.target, 'coverage')
frankf 2013/08/20 22:43:37 We're doing this twice (line 172)
gkanwar1 2013/08/20 23:01:06 Done.
+ coverage_html = os.path.join(coverage_dir, 'coverage_html')
+ if options.coverage_bucket:
+ shutil.rmtree(coverage_dir, ignore_errors=True)
+ os.mkdir(coverage_dir)
+
for test in INSTRUMENTATION_TESTS.itervalues():
RunInstrumentationSuite(options, test)
+ if options.coverage_bucket:
+ bb_annotations.PrintNamedStep('coverage_report')
+
+ RunCmd(['build/android/generate_emma_html.py',
+ '--coverage-dir', coverage_dir,
+ '--metadata-dir', os.path.join(CHROME_SRC, 'out', options.target),
+ '--output', os.path.join(coverage_html, 'coverage.html')])
+
+ revision_file = os.path.join(CHROME_SRC, 'out', options.target,
+ REVISION_FILENAME)
+ # If the revision file doesn't exist, we're just testing the bot
+ if os.path.exists(revision_file):
+ with open(revision_file) as f:
+ revision = f.read()
+ else:
+ revision = 'testing'
+ bot_id = os.environ.get('BUILDBOT_BUILDERNAME')
frankf 2013/08/20 22:43:37 See options.build_properties.get* instances in thi
gkanwar1 2013/08/20 23:01:06 Done.
+ if not bot_id:
+ print 'BUILDBOT_BUILDERNAME must be set to upload coverage data.'
+ return
+
+ timehash = hash(time.time())
+
+ boto_config = os.path.join(bb_utils.BB_BUILD_DIR, 'site_config', '.boto')
+ os.environ['AWS_CREDENTIAL_FILE'] = boto_config
+ os.environ['BOTO_CONFIG'] = boto_config
frankf 2013/08/20 22:43:37 Not sure if you want change envir vars here. Is th
gkanwar1 2013/08/20 23:01:06 I couldn't find another way to do this. This is al
+ RunCmd([os.path.join(bb_utils.BB_BUILD_DIR, 'third_party',
+ 'gsutil', 'gsutil'), 'cp', '-R',
+ coverage_html, 'gs://%s/%s/%s/%s' %
+ (options.coverage_bucket, bot_id, revision, timehash)])
+ bb_annotations.PrintLink(
+ 'Coverage report',
+ 'https://storage.googleapis.com/%s/%s/%s/%s/coverage.html'
+ % (options.coverage_bucket, bot_id, revision, timehash))
+
def RunWebkitTests(options):
RunTestSuites(options, ['webkit_unit_tests'])
@@ -355,6 +402,9 @@ def GetDeviceStepsOptParser():
help='Install an apk by name')
parser.add_option('--reboot', action='store_true',
help='Reboot devices before running tests')
+ parser.add_option('--coverage-bucket',
+ help=('Bucket name to store coverage results. Coverage is '
+ 'only run if this is set.'))
parser.add_option(
'--flakiness-server',
help='The flakiness dashboard server to which the results should be '
« no previous file with comments | « no previous file | build/android/buildbot/bb_run_bot.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698