summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/run_device_tests.py28
1 files 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)