From e371bbee46cf5a2a21339d2afcf2d59ef6f57d45 Mon Sep 17 00:00:00 2001 From: Kevin Shelton Date: Tue, 4 May 2021 13:16:50 -0700 Subject: fingerprint: Support flash_ec in dev test runner BRANCH=none BUG=b:151105339 TEST=with a dragonclaw rev 0.2: ./test/run_device_tests.py --flasher=servo_micro (flash_write_protect failed and the test runner hung after printing the test status, but this seems unrelated; all of the other tests looked to pass), ./test/run_device_tests.py and ./test/run_device_tests.py --flasher=jtrace (both get as far as executing flash_jlink.py, so the argument logic should be ok). Signed-off-by: Kevin Shelton Change-Id: I0d41fb2fa4170292dd5a1212c601cf059ce2ee7b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2872432 Reviewed-by: Tom Hughes Commit-Queue: Tom Hughes --- test/run_device_tests.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/test/run_device_tests.py b/test/run_device_tests.py index 6cc1702760..4bc4b020ea 100755 --- a/test/run_device_tests.py +++ b/test/run_device_tests.py @@ -28,7 +28,8 @@ from typing import Optional, BinaryIO, List import colorama # type: ignore[import] EC_DIR = Path(os.path.dirname(os.path.realpath(__file__))).parent -FLASH_SCRIPT = os.path.join(EC_DIR, 'util/flash_jlink.py') +JTRACE_FLASH_SCRIPT = os.path.join(EC_DIR, 'util/flash_jlink.py') +SERVO_MICRO_FLASH_SCRIPT = os.path.join(EC_DIR, 'util/flash_ec') ALL_TESTS_PASSED_REGEX = re.compile(r'Pass!\r\n') ALL_TESTS_FAILED_REGEX = re.compile(r'Fail! \(\d+ tests\)\r\n') @@ -54,6 +55,9 @@ DATA_ACCESS_VIOLATION_24000000_REGEX = re.compile( BLOONCHIPPER = 'bloonchipper' DARTMONKEY = 'dartmonkey' +JTRACE = 'jtrace' +SERVO_MICRO = 'servo_micro' + class ImageType(Enum): """EC Image type to use for the test.""" @@ -261,14 +265,19 @@ def build(test_name: str, board_name: str) -> None: subprocess.run(cmd).check_returncode() -def flash(test_name: str, board: str) -> bool: +def flash(test_name: str, board: str, flasher: str) -> bool: """Flash specified test to specified board.""" logging.info("Flashing test") - # TODO(b/151105339): Support ./util/flash_ec as well. It's slower, but only - # requires servo micro. + if flasher == JTRACE: + flash_script = JTRACE_FLASH_SCRIPT + elif flasher == SERVO_MICRO: + flash_script = SERVO_MICRO_FLASH_SCRIPT + else: + logging.error('Unknown flasher: "%s"', flasher) + return False cmd = [ - FLASH_SCRIPT, + flash_script, '--board', board, '--image', os.path.join(EC_DIR, 'build', board, test_name, test_name + '.bin'), @@ -411,6 +420,13 @@ def main(): default='DEBUG' ) + flasher_choices = [SERVO_MICRO, JTRACE] + parser.add_argument( + '--flasher', '-f', + choices=flasher_choices, + default=JTRACE + ) + args = parser.parse_args() logging.basicConfig(level=args.log_level) @@ -435,7 +451,7 @@ def main(): 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): + if flash(test.name, args.board, args.flasher): flash_succeeded = True break time.sleep(1) -- cgit v1.2.1