From 181f960ad62e310b122895c538c1b1d5f65b8546 Mon Sep 17 00:00:00 2001 From: Daisuke Nojiri Date: Tue, 20 Jun 2017 18:09:50 -0700 Subject: eCTS: Strip board serial string If we don't strip a serial string read from a file, TH serial doesn't match with the one read from lsusb. It causes TH to be recognized as a DUT. This patch also makes error messages more helpful when DUT is not found or multiple DUTs are connected. BUG=none BRANCH=none TEST=cts/cts.py -m meta, task Change-Id: Ifcf96089b9620ef8809a7d2924dacf67d3af419c Signed-off-by: Daisuke Nojiri Reviewed-on: https://chromium-review.googlesource.com/542019 Reviewed-by: Randall Spangler --- cts/common/board.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cts/common/board.py b/cts/common/board.py index 7714179c41..090b3eb931 100644 --- a/cts/common/board.py +++ b/cts/common/board.py @@ -284,7 +284,8 @@ class TestHarness(Board): return # serial was already loaded try: with open(self.serial_path, mode='r') as ser_f: - self.hla_serial = ser_f.read() + serial = ser_f.read() + self.hla_serial = serial.strip() return except IOError: msg = ('Your TH board has not been identified.\n' @@ -357,9 +358,15 @@ class DeviceUnderTest(Board): # If len(dut) is 0 then your dut doesn't use an st-link device, so we # don't have to worry about its serial number - if len(dut) != 1: - msg = ('Your TH serial number is incorrect, or your have' - ' too many st-link devices attached.') + if not dut: + msg = ('Failed to find serial for DUT.\n' + 'Is ' + self.board + ' connected?') + raise RuntimeError(msg) + if len(dut) > 1: + msg = ('Found multiple DUTs.\n' + 'You can connect only one DUT at a time. This may be caused by\n' + 'an incorrect TH serial. Check if ' + self.th.serial_path + '\n' + 'contains a correct serial.') raise RuntimeError(msg) # Found your other st-link device serial! -- cgit v1.2.1