sanitycheck: Allow custom arguments for west-flash

This allows you to use west to flash the device and pass custom
arguments to the flash command.

Signed-off-by: Andy Doan <andy@foundries.io>
This commit is contained in:
Andy Doan 2019-02-08 10:09:04 -06:00 committed by Kumar Gala
parent b3674f596b
commit 79c48849fe

View file

@ -667,12 +667,23 @@ class DeviceHandler(Handler):
def handle(self):
out_state = "failed"
if options.ninja:
generator_cmd = "ninja"
if options.west_flash is not None:
command = ["west", "flash", "--skip-rebuild", "-d", self.outdir]
# There are two ways this option is used.
# 1) bare: --west-flash
# This results in options.west_flash == []
# 2) with a value: --west-flash="--board-id=42"
# This results in options.west_flash == "--board-id=42"
if options.west_flash != []:
command.append('--')
command.append(options.west_flash)
else:
generator_cmd = "make"
if options.ninja:
generator_cmd = "ninja"
else:
generator_cmd = "make"
command = [generator_cmd, "-C", self.outdir, "flash"]
command = [generator_cmd, "-C", self.outdir, "flash"]
device = options.device_serial
ser = serial.Serial(
@ -696,6 +707,7 @@ class DeviceHandler(Handler):
args=(ser, rpipe, harness))
t.start()
logging.debug('Flash command: %s', command)
try:
if VERBOSE:
subprocess.check_call(command)
@ -2945,6 +2957,18 @@ Artificially long but functional example:
which will ultimately disable ccache.
"""
)
parser.add_argument(
"--west-flash", nargs='?', const=[],
help="""Uses west instead of ninja or make to flash when running with
--device-testing"
E.g
sanitycheck --device-testing --device-serial /dev/ttyACM0 \
--west-flash="--board-id=foobar"
will translate to
west flash -- --board-id=foobar
"""
)
parser.add_argument("--gcov-tool", default="gcov",
help="Path to the gcov tool. Default is gcov in the path.")