[autotest] Add serial flag for adb_host support in cli/atest.
User should be able to specify serials to pass to adb_host and
the board label will be autodetected and the serial will be
added as a host attribute. Currently only works only for 1
serial, a later cl will enable multiple serials.
Also refactored the label decorator logic into site_utils
and remote.RemoteHost.
BUG=chromium:535352
TEST=manually added hosts using the serial flag using cli/atest
and checking the host was correctly detected on a moblab.
Change-Id: I4c95377eaee4529ea99add4387be6dcf56a529fb
Reviewed-on: https://chromium-review.googlesource.com/303214
Commit-Ready: Kevin Cheng <kevcheng@chromium.org>
Tested-by: Kevin Cheng <kevcheng@chromium.org>
Reviewed-by: Kevin Cheng <kevcheng@chromium.org>
diff --git a/cli/host.py b/cli/host.py
index df82996..4ef26bf 100644
--- a/cli/host.py
+++ b/cli/host.py
@@ -435,6 +435,9 @@
', '.join('"%s"' % p
for p in self.protections)),
choices=self.protections)
+ self.parser.add_option('-s', '--serials',
+ help=('Comma separated list of adb-based device '
+ 'serials'))
def parse(self):
@@ -452,6 +455,12 @@
self._parse_lock_options(options)
self.locked = options.lock
self.platform = getattr(options, 'platform', None)
+ self.serials = getattr(options, 'serials', None)
+ if self.serials:
+ if len(self.hosts) > 1:
+ raise topic_common.CliError('Can not specify serials with '
+ 'multiple hosts')
+ self.serials = self.serials.split(',')
if options.protection:
self.data['protection'] = options.protection
return (options, leftover)