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

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: Fixes getting revision, boto config, unnecessary setup 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 260ec76086b7bbbcc87a69b220167861e72fc8ad..034a7195f1f04ea948813cc2b2de343caa70c3b1 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
@@ -26,6 +27,7 @@ import errors
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 +39,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,
frankf 2013/08/21 00:42:26 Didn't we decide all test apks should have coverag
gkanwar1 2013/08/21 00:55:15 Yep, this is a holdover from setting just ContentS
+ 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',
@@ -165,6 +168,8 @@ 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' % options.coverage_dir)
if test.host_driven_root:
args.append('--host-driven-root=%s' % test.host_driven_root)
if test.annotation:
@@ -294,6 +299,31 @@ def GetTestStepCmds():
]
+def UploadCoverageData(options, path, coverage_type):
frankf 2013/08/21 00:42:26 I'd just inline this
gkanwar1 2013/08/21 00:55:15 This is separate because the native coverage is go
+ revision = options.build_properties.get('got_revision', 'testing')
+ bot_id = options.build_properties.get('buildername', 'testing')
+
+ timehash = hash(time.time())
frankf 2013/08/21 00:42:26 Perhaps use something like hashlib.sha1(str(random
gkanwar1 2013/08/21 00:55:15 Done.
+
+ RunCmd([bb_utils.GSUTIL_PATH, 'cp', '-R', path, 'gs://%s/%s/%s/%s/%s' %
+ (options.coverage_bucket, coverage_type, bot_id, revision, timehash)])
+ bb_annotations.PrintLink(
+ 'Coverage report',
+ 'https://storage.googleapis.com/%s/%s/%s/%s/%s/index.html'
+ % (options.coverage_bucket, coverage_type, bot_id, revision, timehash))
frankf 2013/08/21 00:42:26 Not sure if having coverage_type in path is useful
gkanwar1 2013/08/21 00:55:15 We're going to be having a native and java coverag
+
+
+def GenerateJavaCoverageReport(options):
+ bb_annotations.PrintNamedStep('java_coverage_report')
+
+ coverage_html = os.path.join(options.coverage_dir, 'coverage_html')
+ RunCmd(['build/android/generate_emma_html.py',
+ '--coverage-dir', options.coverage_dir,
+ '--metadata-dir', os.path.join(CHROME_SRC, 'out', options.target),
+ '--output', os.path.join(coverage_html, 'coverage.html')])
+ UploadCoverageData(options, coverage_html, 'java')
+
+
def LogcatDump(options):
# Print logcat, kill logcat monitor
bb_annotations.PrintNamedStep('logcat_dump')
@@ -329,6 +359,9 @@ def MainTestWrapper(options):
if options.test_filter:
bb_utils.RunSteps(options.test_filter, GetTestStepCmds(), options)
+ if options.coverage_bucket:
+ GenerateJavaCoverageReport(options)
+
if options.experimental:
RunTestSuites(options, gtest_config.EXPERIMENTAL_TEST_SUITES)
@@ -354,6 +387,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 '
@@ -380,6 +416,9 @@ def main(argv):
return sys.exit('Unknown tests %s' % list(unknown_tests))
setattr(options, 'target', options.factory_properties.get('target', 'Debug'))
+ if options.coverage_bucket:
+ setattr(options, 'coverage_dir',
+ os.path.join(CHROME_SRC, 'out', options.target, 'coverage'))
MainTestWrapper(options)
« 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