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>
diff --git a/scripts/sanitycheck b/scripts/sanitycheck
index a1f9c8c..1bd5d49 100755
--- a/scripts/sanitycheck
+++ b/scripts/sanitycheck
@@ -667,12 +667,23 @@
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 @@
args=(ser, rpipe, harness))
t.start()
+ logging.debug('Flash command: %s', command)
try:
if VERBOSE:
subprocess.check_call(command)
@@ -2945,6 +2957,18 @@
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.")