summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2020-05-21 14:27:07 -0700
committerCommit Bot <commit-bot@chromium.org>2020-05-29 22:18:48 +0000
commita24fabd034ba18e997efa3d854974ba482ba042a (patch)
tree79008d7ed633e0ac8e02125537780a87cf34d9b3
parent083d64cdac4b99cc59052dcb6e4dc278988a5c6c (diff)
downloadchrome-ec-a24fabd034ba18e997efa3d854974ba482ba042a.tar.gz
test: Test return code on all public MPU functions
Note that test_mpu_lock_rw_flash currently fails on bloonchipper since we're trying to protect a size that's not power-of-two aligned to the address. This will be fixed in a followup commit. BRANCH=none BUG=b:151105339, b:155229277 TEST=Build and flash MPU test on bloonchipper: > runtest => Fails Running test_mpu_lock_rw_flash... 129: ASSERTION failed: rv == EC_SUCCESS EVAL: -5 == 0 Fail Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I82104bd7d4df5d15bb048b4649a3e52c8b426d9f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2217052 Commit-Queue: Yicheng Li <yichengli@chromium.org> Reviewed-by: Yicheng Li <yichengli@chromium.org>
-rw-r--r--test/mpu.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/mpu.c b/test/mpu.c
index 64c8c78407..02d179e832 100644
--- a/test/mpu.c
+++ b/test/mpu.c
@@ -111,16 +111,72 @@ test_static int test_mpu_update_region_invalid_alignment(void)
return EC_SUCCESS;
}
+test_static int test_mpu_lock_ro_flash(void)
+{
+ int rv;
+
+ rv = mpu_lock_ro_flash();
+ TEST_EQ(rv, EC_SUCCESS, "%d");
+
+ return EC_SUCCESS;
+}
+
+test_static int test_mpu_lock_rw_flash(void)
+{
+ int rv;
+
+ rv = mpu_lock_rw_flash();
+ TEST_EQ(rv, EC_SUCCESS, "%d");
+
+ return EC_SUCCESS;
+}
+
+test_static int test_mpu_protect_data_ram(void)
+{
+ int rv;
+
+ rv = mpu_protect_data_ram();
+ TEST_EQ(rv, EC_SUCCESS, "%d");
+
+ return EC_SUCCESS;
+}
+
+test_static int test_mpu_protect_code_ram(void)
+{
+ if (IS_ENABLED(CONFIG_EXTERNAL_STORAGE) ||
+ !IS_ENABLED(CONFIG_FLASH_PHYSICAL)) {
+ int rv;
+
+ rv = mpu_protect_code_ram();
+ TEST_EQ(rv, EC_SUCCESS, "%d");
+ }
+
+ return EC_SUCCESS;
+}
+
void run_test(void)
{
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);
+ RUN_TEST(reset_mpu);
RUN_TEST(test_mpu_update_region_invalid_region);
RUN_TEST(reset_mpu);
RUN_TEST(test_mpu_update_region_invalid_alignment);
RUN_TEST(reset_mpu);
+ RUN_TEST(test_mpu_protect_code_ram);
+ RUN_TEST(reset_mpu);
+ RUN_TEST(test_mpu_protect_data_ram);
+ RUN_TEST(reset_mpu);
+ /* This test must be last because it generates a panic */
RUN_TEST(test_mpu_update_region_valid_region);
RUN_TEST(reset_mpu);
test_print_result();