summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2020-07-23 11:04:43 -0700
committerCommit Bot <commit-bot@chromium.org>2020-07-24 00:17:02 +0000
commit7b3bb434dddc391bd8df67739fee6be25b4f8b70 (patch)
treeaed04ca2cfecfe35c84eb090642b64b6d2133e0b /test
parent51670a3e1f0f28a8ba85aa52934351e5210e65df (diff)
downloadchrome-ec-7b3bb434dddc391bd8df67739fee6be25b4f8b70.tar.gz
run_device_tests.py: Explicitly set hardware write protect
Hardware write protect is something that can affect a test. We now explicitly set the state for each test. Currently only the flash_write_protect test has it enabled. BRANCH=none BUG=b:151105339 TEST=./run_device_tests.py Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I956e00b75bdf5fe416386f0ac9090f864e3733dc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2316161 Commit-Queue: Craig Hesling <hesling@chromium.org> Reviewed-by: Craig Hesling <hesling@chromium.org>
Diffstat (limited to 'test')
-rwxr-xr-xtest/run_device_tests.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/test/run_device_tests.py b/test/run_device_tests.py
index 64855aa478..436ecaee4a 100755
--- a/test/run_device_tests.py
+++ b/test/run_device_tests.py
@@ -61,7 +61,7 @@ class TestConfig:
def __init__(self, name, image_to_use=ImageType.RW, finish_regexes=None,
toggle_power=False, test_args=None, num_flash_attempts=2,
- timeout_secs=10):
+ timeout_secs=10, enable_hw_write_protect=False):
if test_args is None:
test_args = []
if finish_regexes is None:
@@ -74,6 +74,7 @@ class TestConfig:
self.toggle_power = toggle_power
self.num_flash_attempts = num_flash_attempts
self.timeout_secs = timeout_secs
+ self.enable_hw_write_protect = enable_hw_write_protect
self.logs = []
self.passed = False
self.num_fails = 0
@@ -91,7 +92,7 @@ ALL_TESTS = {
toggle_power=True),
'flash_write_protect':
TestConfig(name='flash_write_protect', image_to_use=ImageType.RO,
- toggle_power=True),
+ toggle_power=True, enable_hw_write_protect=True),
'mpu_ro':
TestConfig(name='mpu',
image_to_use=ImageType.RO,
@@ -173,6 +174,22 @@ def power(board_name, board_config, on):
subprocess.run(cmd).check_returncode()
+def hw_write_protect(board_name, enable):
+ """Enable/disable hardware write protect."""
+ if enable:
+ state = 'on'
+ else:
+ state = 'off'
+
+ cmd = [
+ 'dut-control',
+ '-n', board_name,
+ 'fw_wp_en' + ':' + state,
+ ]
+ logging.debug('Running command: "%s"', ' '.join(cmd))
+ subprocess.run(cmd).check_returncode()
+
+
def build(test_name, board_name):
"""Build specified test for specified board."""
cmd = [
@@ -356,6 +373,8 @@ def main():
time.sleep(1)
power(args.board, board_config, on=True)
+ hw_write_protect(args.board, test.enable_hw_write_protect)
+
# run the test
logging.info('Running test: "%s"', test.name)
console = get_console(args.board, board_config)