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

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: Cleans up |coverage_dir|, moves upload into its own function 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..03378b0887e1e8773276d810b2f5425c1db3bcfc 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,
+ 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:
@@ -270,9 +275,16 @@ def RunUnitTests(options):
def RunInstrumentationTests(options):
+ if options.coverage_bucket:
+ shutil.rmtree(options.coverage_dir, ignore_errors=True)
Isaac (away) 2013/08/20 23:28:10 not needed for triggered bots. Also, I'd prefer w
gkanwar1 2013/08/20 23:40:29 Good to know, removed. Not sure what you mean by s
Isaac (away) 2013/08/22 18:10:37 I mean, if you're going to delete a folder, print
gkanwar1 2013/08/22 18:12:11 Ah, got it. Good to know for the future. For this
+ os.mkdir(options.coverage_dir)
+
for test in INSTRUMENTATION_TESTS.itervalues():
RunInstrumentationSuite(options, test)
+ if options.coverage_bucket:
Isaac (away) 2013/08/20 23:28:10 Does this need to be called from RunInstrumentatio
gkanwar1 2013/08/20 23:40:29 Nope. It was there because it was acting sort of a
+ GenerateJavaCoverageReport(options)
+
def RunWebkitTests(options):
RunTestSuites(options, ['webkit_unit_tests'])
@@ -294,6 +306,44 @@ def GetTestStepCmds():
]
+def UploadCoverageData(options, path, coverage_type):
+ revision_file = os.path.join(CHROME_SRC, 'out', options.target,
+ REVISION_FILENAME)
Isaac (away) 2013/08/20 23:28:10 Would be better to use revision from build_propert
gkanwar1 2013/08/20 23:40:29 Ah, didn't realize that was in build_properties. D
+ # 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 = options.build_properties.get('buildername', 'unknown')
+
+ timehash = hash(time.time())
+
+ boto_config = os.path.join(bb_utils.BB_BUILD_DIR, 'site_config', '.boto')
+ os.environ['AWS_CREDENTIAL_FILE'] = boto_config
Isaac (away) 2013/08/20 23:28:10 These are set automatically on bots; this isn't ne
gkanwar1 2013/08/20 23:40:29 Good to know, removed.
+ os.environ['BOTO_CONFIG'] = boto_config
+ RunCmd([os.path.join(bb_utils.BB_BUILD_DIR, 'third_party',
Isaac (away) 2013/08/20 23:28:10 let's make the gsutil path a constant in bb_utils.
gkanwar1 2013/08/20 23:40:30 Done.
+ 'gsutil', 'gsutil'), '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))
+
+
+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')
@@ -354,6 +404,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 +433,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