pw_kvs: Add tests for FlashPartition
Add test for FlashPartition::IsRegionErased case that can result in a false
negative.
Add FlashPartition::IsErased that checks if the entire partition is
erased.
Add additional tests for FlashPartition
Change-Id: I7f9a1da643b42bac89d0161d288a7ddcf1487649
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/13684
Commit-Queue: David Rogers <davidrogers@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
diff --git a/pw_kvs/public/pw_kvs/flash_memory.h b/pw_kvs/public/pw_kvs/flash_memory.h
index 46be588..a42891f 100644
--- a/pw_kvs/public/pw_kvs/flash_memory.h
+++ b/pw_kvs/public/pw_kvs/flash_memory.h
@@ -211,7 +211,7 @@
virtual StatusWithSize Write(Address address,
std::span<const std::byte> data);
- // Check to see if chunk of flash memory is erased. Address and len need to
+ // Check to see if chunk of flash partition is erased. Address and len need to
// be aligned with FlashMemory.
// Returns: OK, on success.
// TIMEOUT, on timeout.
@@ -222,6 +222,12 @@
size_t len,
bool* is_erased);
+ // Check if the entire partition is erased.
+ // Returns: same as IsRegionErased().
+ Status IsErased(bool* is_erased) {
+ return IsRegionErased(0, this->size_bytes(), is_erased);
+ }
+
// Checks to see if the data appears to be erased. No reads or writes occur;
// the FlashPartition simply compares the data to
// flash_.erased_memory_content().