diff options
author | Vic Yang <victoryang@chromium.org> | 2013-06-19 00:29:08 +0800 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-07-11 04:26:10 -0700 |
commit | 62f2a33ff2ff37ad8226fd854712206f3ccd745e (patch) | |
tree | 7c4e226ce5269b37d61c6f7d6a5fbda0c5482d3a /test/flash.c | |
parent | b3f1d0d0593a430a5fb7605e5fc4337ae0a8833c (diff) | |
download | chrome-ec-62f2a33ff2ff37ad8226fd854712206f3ccd745e.tar.gz |
Add flash host read command test
This checks the correctness of data returned by flash read host command.
BUG=chrome-os-partner:19236
TEST=Pass all tests.
BRANCH=None
Change-Id: I3b97addb9b14922e9f33a71b865000ae9a8d40a8
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60963
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'test/flash.c')
-rw-r--r-- | test/flash.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/flash.c b/test/flash.c index ae1d6432df..73c4a95683 100644 --- a/test/flash.c +++ b/test/flash.c @@ -177,6 +177,17 @@ static int verify_write(int offset, int size, const char *data) TEST_ASSERT(size == (s)); \ } while (0) +int host_command_read(int offset, int size, char *out) +{ + struct ec_params_flash_read params; + + params.offset = offset; + params.size = size; + + return test_send_host_command(EC_CMD_FLASH_READ, 0, ¶ms, + sizeof(params), out, size); +} + int host_command_write(int offset, int size, const char *data) { uint8_t buf[256]; @@ -248,6 +259,26 @@ int host_command_region_info(enum ec_flash_region reg, uint32_t *offset, /*****************************************************************************/ /* Tests */ +static int test_read(void) +{ + char buf[16]; + +#ifdef EMU_BUILD + int i; + /* Fill in some numbers so they are not all 0xff */ + for (i = 0; i < sizeof(buf); ++i) + __host_flash[i] = i * i + i; +#endif + + /* The first few bytes in the flash should always contain some code */ + TEST_ASSERT(!flash_is_erased(0, sizeof(buf))); + + TEST_ASSERT(host_command_read(0, sizeof(buf), buf) == EC_RES_SUCCESS); + TEST_ASSERT_ARRAY_EQ(buf, (char *)CONFIG_FLASH_BASE, sizeof(buf)); + + return EC_SUCCESS; +} + static int test_overwrite_current(void) { uint32_t offset, size; @@ -420,6 +451,7 @@ static void run_test_step1(void) test_reset(); mock_wp = 0; + RUN_TEST(test_read); RUN_TEST(test_overwrite_current); RUN_TEST(test_overwrite_other); RUN_TEST(test_op_failure); |