diff options
author | Tom Hughes <tomhughes@chromium.org> | 2020-05-19 09:50:52 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-27 04:44:31 +0000 |
commit | a3881b5632d2371374a69bcea64688d64c231e58 (patch) | |
tree | adee24ff65362f63543a47fec734b69729d79a79 /test/scratchpad.c | |
parent | 2f49516dd133f850eea302cc849725731185c119 (diff) | |
download | chrome-ec-a3881b5632d2371374a69bcea64688d64c231e58.tar.gz |
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>
Diffstat (limited to 'test/scratchpad.c')
-rw-r--r-- | test/scratchpad.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/scratchpad.c b/test/scratchpad.c new file mode 100644 index 0000000000..8af697f0ae --- /dev/null +++ b/test/scratchpad.c @@ -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(); +} |