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

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

Issue 15261003: Add a new script bb_host_steps.py which handles all host side steps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: First Full CL Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/buildbot/bb_host_steps.py » ('j') | build/android/buildbot/bb_host_steps.py » ('J')
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 f9e2883b18900d4a53a7680cc2f43ba061a61de7..e9fde8e73acf08ab1435dff0618297fd34f062b4 100755
--- a/build/android/buildbot/bb_device_steps.py
+++ b/build/android/buildbot/bb_device_steps.py
@@ -5,15 +5,13 @@
import collections
import glob
-import json
import multiprocessing
-import optparse
import os
-import pipes
import shutil
-import subprocess
import sys
+import bb_utils
+
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from pylib import android_commands
from pylib import buildbot_report
@@ -25,8 +23,6 @@ sys.path.append(os.path.join(
import errors
-TESTING = 'BUILDBOT_TESTING' in os.environ
-
CHROME_SRC = constants.CHROME_DIR
# Describes an instrumation test suite:
@@ -61,34 +57,7 @@ INSTRUMENTATION_TESTS = dict((suite.name, suite) for suite in [
VALID_TESTS = set(['chromedriver', 'ui', 'unit', 'webkit', 'webkit_layout'])
-
-def SpawnCmd(command):
- """Spawn a process without waiting for termination."""
- print '>', ' '.join(map(pipes.quote, command))
- sys.stdout.flush()
- if TESTING:
- class MockPopen(object):
- @staticmethod
- def wait():
- return 0
- return MockPopen()
-
- return subprocess.Popen(command, cwd=CHROME_SRC)
-
-def RunCmd(command, flunk_on_failure=True, halt_on_failure=False):
- """Run a command relative to the chrome source root."""
- code = SpawnCmd(command).wait()
- print '<', ' '.join(map(pipes.quote, command))
- if code != 0:
- print 'ERROR: process exited with code %d' % code
- if flunk_on_failure:
- buildbot_report.PrintError()
- else:
- buildbot_report.PrintWarning()
- # Allow steps to have both halting (i.e. 1) and non-halting exit codes.
- if code != 0 and code != 88 and halt_on_failure:
- raise OSError()
- return code
+R = bb_utils.RunCmd
Isaac (away) 2013/06/04 04:34:12 This is fine, but how about we name this RunCmd?
Siva Chandra 2013/06/04 19:42:40 Done.
# multiprocessing map_async requires a top-level function for pickle library.
@@ -105,7 +74,7 @@ def RebootDevices():
buildbot_report.PrintNamedStep('Reboot devices')
# Early return here to avoid presubmit dependence on adb,
# which might not exist in this checkout.
- if TESTING:
+ if bb_utils.TESTING:
return
devices = android_commands.GetAttachedDevices()
print 'Rebooting: %s' % devices
@@ -140,7 +109,7 @@ def RunTestSuites(options, suites):
cmd = ['build/android/run_tests.py', '-s', suite.name] + args
if suite.is_suite_exe:
cmd.append('--exe')
- RunCmd(cmd)
+ R(cmd)
def RunBrowserTestSuite(options):
"""Manages an invocation of run_browser_tests.py.
@@ -154,12 +123,12 @@ def RunBrowserTestSuite(options):
if options.asan:
args.append('--tool=asan')
buildbot_report.PrintNamedStep(constants.BROWSERTEST_SUITE_NAME)
- RunCmd(['build/android/run_browser_tests.py'] + args)
+ R(['build/android/run_browser_tests.py'] + args)
def RunChromeDriverTests():
"""Run all the steps for running chromedriver tests."""
buildbot_report.PrintNamedStep('chromedriver_annotation')
- RunCmd(['chrome/test/chromedriver/run_buildbot_steps.py',
+ R(['chrome/test/chromedriver/run_buildbot_steps.py',
'--android-package=%s' % constants.CHROMIUM_TEST_SHELL_PACKAGE])
@@ -168,7 +137,7 @@ def CheckInstall():
buildbot_report.PrintNamedStep('Check device install')
# This step checks if apks can be installed on the devices.
args = ['--apk', 'build/android/CheckInstallApk-debug.apk']
- RunCmd(['build/android/adb_install_apk.py'] + args, halt_on_failure=True)
+ R(['build/android/adb_install_apk.py'] + args, halt_on_failure=True)
def InstallApk(options, test, print_step=False):
@@ -185,7 +154,7 @@ def InstallApk(options, test, print_step=False):
if options.target == 'Release':
args.append('--release')
- RunCmd(['build/android/adb_install_apk.py'] + args, halt_on_failure=True)
+ R(['build/android/adb_install_apk.py'] + args, halt_on_failure=True)
def RunInstrumentationSuite(options, test):
@@ -210,13 +179,13 @@ def RunInstrumentationSuite(options, test):
if test.host_driven_root:
args.append('--python_test_root=%s' % test.host_driven_root)
- RunCmd(['build/android/run_instrumentation_tests.py'] + args)
+ R(['build/android/run_instrumentation_tests.py'] + args)
def RunWebkitLint(target):
"""Lint WebKit's TestExpectation files."""
buildbot_report.PrintNamedStep('webkit_lint')
- RunCmd(['webkit/tools/layout_tests/run_webkit_tests.py',
+ R(['webkit/tools/layout_tests/run_webkit_tests.py',
'--lint-test-files',
'--chromium',
'--target', target])
@@ -256,35 +225,35 @@ def RunWebkitLayoutTests(options):
cmd_args.extend(
['--additional-expectations=%s' % os.path.join(CHROME_SRC, *f)])
- RunCmd(['webkit/tools/layout_tests/run_webkit_tests.py'] + cmd_args,
+ R(['webkit/tools/layout_tests/run_webkit_tests.py'] + cmd_args,
flunk_on_failure=False)
def MainTestWrapper(options):
# Restart adb to work around bugs, sleep to wait for usb discovery.
- RunCmd(['adb', 'kill-server'])
- RunCmd(['adb', 'start-server'])
- RunCmd(['sleep', '1'])
+ R(['adb', 'kill-server'])
+ R(['adb', 'start-server'])
+ R(['sleep', '1'])
# Spawn logcat monitor
logcat_dir = os.path.join(CHROME_SRC, 'out/logcat')
shutil.rmtree(logcat_dir, ignore_errors=True)
- SpawnCmd(['build/android/adb_logcat_monitor.py', logcat_dir])
+ bb_utils.SpawnCmd(['build/android/adb_logcat_monitor.py', logcat_dir])
# Wait for logcat_monitor to pull existing logcat
- RunCmd(['sleep', '5'])
+ R(['sleep', '5'])
if options.reboot:
RebootDevices()
# Device check and alert emails
buildbot_report.PrintNamedStep('device_status_check')
- RunCmd(['build/android/device_status_check.py'], halt_on_failure=True)
+ R(['build/android/device_status_check.py'], halt_on_failure=True)
# Provision devices
buildbot_report.PrintNamedStep('provision_devices')
target = options.factory_properties.get('target', 'Debug')
- RunCmd(['build/android/provision_devices.py', '-t', target])
+ R(['build/android/provision_devices.py', '-t', target])
# Check to see if devices can install apks.
CheckInstall()
@@ -314,30 +283,19 @@ def MainTestWrapper(options):
# Print logcat, kill logcat monitor
buildbot_report.PrintNamedStep('logcat_dump')
- RunCmd(['build/android/adb_logcat_printer.py', logcat_dir])
+ R(['build/android/adb_logcat_printer.py', logcat_dir])
buildbot_report.PrintNamedStep('test_report')
for report in glob.glob(
os.path.join(CHROME_SRC, 'out', options.target, 'test_logs', '*.log')):
- RunCmd(['cat', report])
+ R(['cat', report])
os.remove(report)
def main(argv):
- parser = optparse.OptionParser()
-
- def convert_json(option, _, value, parser):
- setattr(parser.values, option.dest, json.loads(value))
-
- parser.add_option('--build-properties', action='callback',
- callback=convert_json, type='string', default={},
- help='build properties in JSON format')
- parser.add_option('--factory-properties', action='callback',
- callback=convert_json, type='string', default={},
- help='factory properties in JSON format')
- parser.add_option('--slave-properties', action='callback',
- callback=convert_json, type='string', default={},
- help='Properties set by slave script in JSON format')
+ buildbot_report.PrintNamedStep('Run tests')
+
+ parser = bb_utils.GetParser()
parser.add_option('--experimental', action='store_true',
help='Run experiemental tests')
parser.add_option('-f', '--test-filter', metavar='<filter>', default=[],
@@ -356,18 +314,12 @@ def main(argv):
help='Push script to device which restarts adbd on disconnections.')
options, args = parser.parse_args(argv[1:])
- def ParserError(msg):
- """We avoid parser.error because it calls sys.exit."""
- parser.print_help()
- print >> sys.stderr, '\nERROR:', msg
- return 1
-
if args:
- return ParserError('Unused args %s' % args)
+ return parser.Error('Unused args %s' % args)
unknown_tests = set(options.test_filter) - VALID_TESTS
if unknown_tests:
- return ParserError('Unknown tests %s' % list(unknown_tests))
+ return parser.Error('Unknown tests %s' % list(unknown_tests))
setattr(options, 'target', options.factory_properties.get('target', 'Debug'))
« no previous file with comments | « no previous file | build/android/buildbot/bb_host_steps.py » ('j') | build/android/buildbot/bb_host_steps.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698