summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2020-06-05 14:24:52 -0700
committerCommit Bot <commit-bot@chromium.org>2020-06-16 02:12:19 +0000
commit6af17f0cd227d96c9d74af87724d80b76995c35c (patch)
treebb98be8dbdcd759231f1ad7fd103baf2929fb4d7
parent4c17d005ff59601ae7a6bf85747dc43a5e2f2dac (diff)
downloadchrome-ec-6af17f0cd227d96c9d74af87724d80b76995c35c.tar.gz
test/run_device_tests.py: Allow specifying number of flashing attempts
This is to work around a bug where Segger JLink fails to flash after the flash_write_protect test has been run. BRANCH=none BUG=b:158327221 TEST=./test/run_device_tests.py -t flash_write_protect && \ ./test/run_device_tests.py -t flash_write_protect echo $? 0 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I70f3b86810b40c305b0221ecf6432568022c78c4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2233783 Commit-Queue: Craig Hesling <hesling@chromium.org> Reviewed-by: Craig Hesling <hesling@chromium.org>
-rwxr-xr-xtest/run_device_tests.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/test/run_device_tests.py b/test/run_device_tests.py
index cc6e302484..fce3a93471 100755
--- a/test/run_device_tests.py
+++ b/test/run_device_tests.py
@@ -60,7 +60,7 @@ class TestConfig:
"""Configuration for a given test."""
def __init__(self, name, image_to_use=ImageType.RW, finish_regexes=None,
- toggle_power=False, test_args=None):
+ toggle_power=False, test_args=None, num_flash_attempts=2):
if test_args is None:
test_args = []
if finish_regexes is None:
@@ -71,6 +71,7 @@ class TestConfig:
self.finish_regexes = finish_regexes
self.test_args = test_args
self.toggle_power = toggle_power
+ self.num_flash_attempts = num_flash_attempts
self.logs = []
self.passed = False
self.num_fails = 0
@@ -330,7 +331,19 @@ def main():
build(test.name, args.board)
# flash test binary
- if not flash(test.name, args.board):
+ # TODO(b/158327221): First attempt to flash fails after
+ # flash_write_protect test is run; works after second attempt.
+ flash_succeeded = False
+ for i in range(0, test.num_flash_attempts):
+ logging.debug('Flash attempt %d', i + 1)
+ if flash(test.name, args.board):
+ flash_succeeded = True
+ break
+ time.sleep(1)
+
+ if not flash_succeeded:
+ logging.debug('Flashing failed after max attempts: %d',
+ test.num_flash_attempts)
test.passed = False
continue