cts: Fail script when build or flash fails

This change makes cts.py fail when building or flashing a module for
DUT or TH fails.

BUG=none
BRANCH=none
TEST=Made cts.py fail by injecting build and flash error

Change-Id: Iec1e11f4a8c261eb4c989b118df218e86cb6f5f1
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/393326
Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
Daisuke Nojiri
2016-09-30 16:37:48 -07:00
committed by chrome-bot
parent e40fb3ef58
commit a51cee362a
2 changed files with 11 additions and 7 deletions

View File

@@ -93,7 +93,7 @@ class Board(object):
for cmd in commands:
args += ['-c', cmd]
args += ['-c', 'shutdown']
sp.call(args)
return sp.call(args)
def build(self, module, ec_dir, debug=False):
"""Builds test suite module for board
@@ -116,7 +116,7 @@ class Board(object):
cmds.append('CTS_DEBUG=TRUE')
print ' '.join(cmds)
sp.call(cmds)
return sp.call(cmds)
def flash(self):
"""Flashes board with most recent build ec.bin"""
@@ -125,7 +125,7 @@ class Board(object):
'init',
'reset init',
'flash write_image erase %s %s' % (image_path, self.flash_offset)]
self.send_open_ocd_commands(cmd)
return self.send_open_ocd_commands(cmd)
def to_string(self):
s = ('Type: Board\n'

View File

@@ -94,14 +94,18 @@ class Cts(object):
def build(self):
"""Build images for DUT and TH"""
self.dut.build(self.module, self.ec_dir, self.debug)
self.th.build(self.module, self.ec_dir, self.debug)
if self.dut.build(self.module, self.ec_dir, self.debug):
raise RuntimeError('Building module %s for DUT failed' % (self.module))
if self.th.build(self.module, self.ec_dir, self.debug):
raise RuntimeError('Building module %s for TH failed' % (self.module))
def flash_boards(self):
"""Flashes th and dut boards with their most recently build ec.bin"""
self.identify_boards()
self.th.flash()
self.dut.flash()
if self.th.flash():
raise RuntimeError('Flashing TH failed')
if self.dut.flash():
raise RuntimeError('Flashing DUT failed')
def setup(self):
"""Setup boards"""