summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2017-07-02 12:28:31 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-07-08 20:38:53 -0700
commitb20a873d0f58809b77dd1c4d40706f0441e798e3 (patch)
tree225679f25be257cb0bafbf313448ba457f5c810f
parent74d09422e98320766641f9e96b3ec0fe93a9d842 (diff)
downloadchrome-ec-b20a873d0f58809b77dd1c4d40706f0441e798e3.tar.gz
eCTS: Run openocd and lsusb as a root
Running lsusb (to get iSerial) and openocd requires a privilege. This patch makes cts.py run these commands as a root. Opening ttyACM0 requires a privilege as well but it'll be done by asking a user to add themselves to dialout group. BUG=chromium:664309 BRANCH=none TEST=Run cts.py on a freshly set up cros_sdk chroot. Change-Id: Ib9d007459c4b1322b15f521a5253d833e2304c3c Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/558804 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--cts/common/board.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/cts/common/board.py b/cts/common/board.py
index f2dce110d7..db7f535391 100644
--- a/cts/common/board.py
+++ b/cts/common/board.py
@@ -79,7 +79,7 @@ class Board(object):
Returns:
List of serials
"""
- usb_args = ['lsusb', '-v', '-d', '0x0483:0x374b']
+ usb_args = ['sudo', 'lsusb', '-v', '-d', '0x0483:0x374b']
st_link_info = sp.check_output(usb_args)
st_serials = []
for line in st_link_info.split('\n'):
@@ -105,7 +105,7 @@ class Board(object):
Returns:
True if execution is successful or False otherwise.
"""
- args = ['openocd', '-s', OCD_SCRIPT_DIR,
+ args = ['sudo', 'openocd', '-s', OCD_SCRIPT_DIR,
'-f', self.openocd_config, '-c', 'hla_serial ' + self.hla_serial]
for cmd in commands:
@@ -194,7 +194,8 @@ class Board(object):
except serial.SerialException:
raise ValueError('Failed to open ' + self.tty_port + ' of ' + self.board +
'. Please make sure the port is available and you have' +
- ' permission to read it.')
+ ' permission to read it. Create dialout group and run:' +
+ ' sudo usermod -a -G dialout <username>.')
self.tty = tty
def read_tty(self, max_boot_count=1):