summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2014-07-07 14:48:24 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-07-08 02:14:53 +0000
commit244e7d3f0840541b8627acc19368f43c6e28d72a (patch)
tree904f3366ae20d40aebd531bb55cbf07cb284b2f2
parent2c4432f609bc261603f40fa0e5eba5b975514477 (diff)
downloadchrome-ec-244e7d3f0840541b8627acc19368f43c6e28d72a.tar.gz
Add test for flash_is_erased()
This test checks: - flash_is_erased() returns true when flash is erased. - flash_is_erased() returns false when the entire flash except one byte is erased. BUG=chrome-os-partner:30281 TEST=Check this test fails without the fix for flash_is_erased(), but passes with it. BRANCH=all (if the fix is cherry-picked) Change-Id: Id4fe5591381cabcdad9bb16ba820acd48e92ba13 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/206897 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--test/flash.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/flash.c b/test/flash.c
index 2bf6ee9925..2b3114854c 100644
--- a/test/flash.c
+++ b/test/flash.c
@@ -260,6 +260,26 @@ static int test_read(void)
return EC_SUCCESS;
}
+static int test_is_erased(void)
+{
+ int i;
+
+#ifdef EMU_BUILD
+ memset(__host_flash, 0xff, 1024);
+ TEST_ASSERT(flash_is_erased(0, 1024));
+
+ for (i = 0; i < 1024; ++i) {
+ __host_flash[i] = 0xec;
+ TEST_ASSERT(!flash_is_erased(0, 1024));
+ __host_flash[i] = 0xff;
+ }
+#else
+ ccprintf("Skip. Emulator only test.\n");
+#endif
+
+ return EC_SUCCESS;
+}
+
static int test_overwrite_current(void)
{
uint32_t offset, size;
@@ -421,6 +441,7 @@ static void run_test_step1(void)
mock_wp = 0;
RUN_TEST(test_read);
+ RUN_TEST(test_is_erased);
RUN_TEST(test_overwrite_current);
RUN_TEST(test_overwrite_other);
RUN_TEST(test_op_failure);