diff options
author | Tom Hughes <tomhughes@chromium.org> | 2020-05-29 13:59:00 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-30 05:16:17 +0000 |
commit | 77ae633c41e958ec91193c48ad3fbd6012d6739e (patch) | |
tree | 618a50531d03aee03643a0f46b14b8e710cf897d | |
parent | 8aedc7bdd2f404293ee93c65851dfa79c4990d73 (diff) | |
download | chrome-ec-77ae633c41e958ec91193c48ad3fbd6012d6739e.tar.gz |
test: Check the current image when running the MPU test
Locking RO or RW prevents code execution, so we can only test locking
the region that is not running.
BRANCH=none
BUG=b:155410753
TEST=With dragonclaw v0.2 connected to Segger J-Trace and servo micro:
./test/run_device_tests.py -t mpu_ro mpu_rw
=> PASS
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I4d4e135a79d8d3bc383cd1b5a60d42c1b68def4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2222975
Commit-Queue: Yicheng Li <yichengli@chromium.org>
Reviewed-by: Yicheng Li <yichengli@chromium.org>
-rw-r--r-- | test/mpu.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/test/mpu.c b/test/mpu.c index 02d179e832..b8c881364d 100644 --- a/test/mpu.c +++ b/test/mpu.c @@ -6,6 +6,7 @@ #include <stdbool.h> #include "mpu.h" #include "mpu_private.h" +#include "system.h" #include "test_util.h" struct mpu_info { @@ -156,17 +157,32 @@ test_static int test_mpu_protect_code_ram(void) void run_test(void) { + enum ec_image cur_image = system_get_image_copy(); + ccprintf("Running MPU test\n"); + RUN_TEST(reset_mpu); RUN_TEST(test_mpu_info); - RUN_TEST(reset_mpu); + /* * TODO(b/151105339): For all locked regions, check that we cannot * read/write/execute (depending on the configuration). */ - RUN_TEST(test_mpu_lock_ro_flash); - RUN_TEST(reset_mpu); - RUN_TEST(test_mpu_lock_rw_flash); + + /* + * Since locking prevents code execution, we can only lock the region + * that is not running or the test will hang. + */ + if (cur_image == EC_IMAGE_RW) { + RUN_TEST(reset_mpu); + RUN_TEST(test_mpu_lock_ro_flash); + } + + if (cur_image == EC_IMAGE_RO) { + RUN_TEST(reset_mpu); + RUN_TEST(test_mpu_lock_rw_flash); + } + RUN_TEST(reset_mpu); RUN_TEST(test_mpu_update_region_invalid_region); RUN_TEST(reset_mpu); |