test: Add scratchpad test

The first time the test runs it should pass. After rebooting, the test
should then fail because the scratchpad register is already set.

BRANCH=none
BUG=b:157059753
TEST=Build and flash bloonchipper
     On console:
     > runtest
       => PASS
     > reboot
     > runtest
       => PASS, which is WRONG
TEST=Build and flash dartmonkey
     On console:
     > runtest
       => PASS
     > reboot
     > runtest
       => FAILS, which is CORRECT

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I348d723d8083ecd0d9f5535785c8049f284a00b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2209189
Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
This commit is contained in:
Tom Hughes 2020-05-19 09:50:52 -07:00 committed by Commit Bot
parent 2f49516dd1
commit a3881b5632
7 changed files with 48 additions and 0 deletions

View File

@ -21,6 +21,7 @@ test-list-y=\
rollback \
rollback_entropy \
rtc \
scratchpad \
sha256 \
sha256_unrolled \
stm32f_rtc \

View File

@ -22,6 +22,7 @@ test-list-y=\
rollback \
rollback_entropy \
rtc \
scratchpad \
sha256 \
sha256_unrolled \
stm32f_rtc \

View File

@ -19,6 +19,7 @@ test-list-y=\
rollback \
rollback_entropy \
rtc \
scratchpad \
sha256 \
sha256_unrolled \
stm32f_rtc \

View File

@ -19,5 +19,6 @@ test-list-y=\
rollback \
rollback_entropy \
rtc \
scratchpad \
sha256 \
sha256_unrolled \

View File

@ -163,6 +163,7 @@ rollback_entropy-y=rollback_entropy.o
rsa-y=rsa.o
rsa3-y=rsa.o
rtc-y=rtc.o
scratchpad-y=scratchpad.o
sbs_charging-y=sbs_charging.o
sbs_charging_v2-y=sbs_charging_v2.o
sha256-y=sha256.o

34
test/scratchpad.c Normal file
View File

@ -0,0 +1,34 @@
/* Copyright 2020 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "system.h"
#include "test_util.h"
/**
* The first time this test runs, it should pass. After rebooting, the test
* should fail because the scratchpad register is set to 1.
*/
test_static int test_scratchpad(void)
{
int rv;
uint32_t scratch;
scratch = system_get_scratchpad();
TEST_EQ(scratch, 0, "%d");
rv = system_set_scratchpad(1);
TEST_EQ(rv, EC_SUCCESS, "%d");
scratch = system_get_scratchpad();
TEST_EQ(scratch, 1, "%d");
return EC_SUCCESS;
}
void run_test(void)
{
RUN_TEST(test_scratchpad);
test_print_result();
}

9
test/scratchpad.tasklist Normal file
View File

@ -0,0 +1,9 @@
/* Copyright 2020 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/**
* See CONFIG_TASK_LIST in config.h for details.
*/
#define CONFIG_TEST_TASK_LIST /* no tasks */