diff options
author | Cassidy Burden <cburden@google.com> | 2016-07-29 10:00:31 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-08-01 16:04:59 -0700 |
commit | 471aae79081b9a9097e5f57c8d6792f72853b03f (patch) | |
tree | c542e5932fb077f45acda24fe7f5fd347a130de8 /binary_search_tool | |
parent | a742f71e420a07c474a8fb9307426ddb0574dcf3 (diff) | |
download | toolchain-utils-471aae79081b9a9097e5f57c8d6792f72853b03f.tar.gz |
binary search tool: Add android bisector to bisect.py
Add android bisector implementation to bisect.py. Additionally add
simple cleanup.sh script.
TEST=Tested with full android bisection
Change-Id: Ib6c6ea85614dbe3d54865d9695863ee625588a2d
Reviewed-on: https://chrome-internal-review.googlesource.com/272166
Commit-Ready: Cassidy Burden <cburden@google.com>
Tested-by: Cassidy Burden <cburden@google.com>
Reviewed-by: Caroline Tice <cmtice@google.com>
Diffstat (limited to 'binary_search_tool')
-rwxr-xr-x | binary_search_tool/android/cleanup.sh | 11 | ||||
-rwxr-xr-x | binary_search_tool/bisect.py | 77 |
2 files changed, 88 insertions, 0 deletions
diff --git a/binary_search_tool/android/cleanup.sh b/binary_search_tool/android/cleanup.sh new file mode 100755 index 00000000..c89c337d --- /dev/null +++ b/binary_search_tool/android/cleanup.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# +# Copyright 2016 Google Inc. All Rights Reserved. +# +# This script is part of the Android binary search triage process. +# It should be the last script called by the user, after the user has +# successfully run the bisection tool and found their bad items. This script +# will perform all necessary cleanup for the bisection tool. +# + +rm android/common.sh diff --git a/binary_search_tool/bisect.py b/binary_search_tool/bisect.py index 235e9546..6315c81c 100755 --- a/binary_search_tool/bisect.py +++ b/binary_search_tool/bisect.py @@ -214,6 +214,61 @@ class BisectObject(Bisector): return 0 +class BisectAndroid(Bisector): + """The class for Android bisection steps.""" + + android_setup = 'android/setup.sh' + android_cleanup = 'android/cleanup.sh' + default_dir = os.path.expanduser('~/ANDROID_BISECT') + + def __init__(self, options, overrides): + super(BisectAndroid, self).__init__(options, overrides) + self.method_name = 'Android' + self.default_kwargs = { + 'get_initial_items': 'android/get_initial_items.sh', + 'switch_to_good': 'android/switch_to_good.sh', + 'switch_to_bad': 'android/switch_to_bad.sh', + 'install_script': 'android/install.sh', + 'test_script': 'android/interactive_test.sh', + 'prune': True, + 'file_args': True, + 'noincremental': False, + } + self.options = options + if options.dir: + os.environ['BISECT_DIR'] = options.dir + self.options.dir = os.environ.get('BISECT_DIR', self.default_dir) + + self.ArgOverride(self.default_kwargs, overrides) + + def PreRun(self): + num_jobs = "NUM_JOBS='%s'" % self.options.num_jobs + device_id = "" + if self.options.device_id: + device_id = "ANDROID_SERIAL='%s'" % self.options.device_id + + cmd = ('%s %s %s %s' % (num_jobs, device_id, self.android_setup, + self.options.android_src)) + ret, _, _ = self.ce.RunCommandWExceptionCleanup(cmd, print_to_console=True) + if ret: + self.logger.LogError('Android bisector setup failed w/ error %d' % ret) + return 1 + + os.environ['BISECT_STAGE'] = 'TRIAGE' + return 0 + + def Run(self): + return binary_search_state.Run(**self.default_kwargs) + + def PostRun(self): + cmd = self.android_cleanup + ret, _, _ = self.ce.RunCommandWExceptionCleanup(cmd, print_to_console=True) + if ret: + self.logger.LogError('Android bisector cleanup failed w/ error %d' % ret) + return 1 + return 0 + + def Run(bisector): log = logger.GetLogger() @@ -280,6 +335,28 @@ def Main(argv): 'empty).')) parser_object.set_defaults(handler=BisectObject) + parser_android = subparsers.add_parser('android') + parser_android.add_argument('android_src', help='Path to android source tree') + parser_android.add_argument('--dir', + help=('Bisection directory to use, sets ' + '$BISECT_DIR if provided. Defaults to ' + 'current value of $BISECT_DIR (or ' + '~/ANDROID_BISECT/ if $BISECT_DIR is ' + 'empty).')) + parser_android.add_argument('-j', '--num_jobs', + type=int, + default=1, + help=('Number of jobs that make and various ' + 'scripts for bisector can spawn. Setting ' + 'this value too high can freeze up your ' + 'machine!')) + parser_android.add_argument('--device_id', + default='', + help=('Device id for device used for testing. ' + 'Use this if you have multiple Android ' + 'devices plugged into your machine.')) + parser_android.set_defaults(handler=BisectAndroid) + options, remaining = parser.parse_known_args(argv) if remaining: overrides = override_parser.parse_args(remaining) |