pw_kvs: Add flash partition test

Add unit tests for testing flash partition. Put the main test
implementation in to a common file that is used by end tests that
provide the actual partition to test.

Add configuration define PW_FLASH_MAX_FLASH_ALIGNMENT that is
used to size flash write buffers.

Change-Id: Ib3dd2381037d15bd61552184f59769074dece44f
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/13220
Commit-Queue: David Rogers <davidrogers@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
diff --git a/pw_kvs/public/pw_kvs/flash_memory.h b/pw_kvs/public/pw_kvs/flash_memory.h
index ac8f429..46be588 100644
--- a/pw_kvs/public/pw_kvs/flash_memory.h
+++ b/pw_kvs/public/pw_kvs/flash_memory.h
@@ -117,7 +117,7 @@
  private:
   const uint32_t sector_size_;
   const uint32_t flash_sector_count_;
-  const uint8_t alignment_;
+  const uint32_t alignment_;
   const uint32_t start_address_;
   const uint32_t start_sector_;
   const std::byte erased_memory_content_;
diff --git a/pw_kvs/public/pw_kvs/flash_partition_test.h b/pw_kvs/public/pw_kvs/flash_partition_test.h
new file mode 100644
index 0000000..8c8496d
--- /dev/null
+++ b/pw_kvs/public/pw_kvs/flash_partition_test.h
@@ -0,0 +1,28 @@
+// Copyright 2020 The Pigweed Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//     https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+#pragma once
+
+#include <cstddef>
+
+#include "pw_kvs/flash_memory.h"
+
+namespace pw::kvs::PartitionTest {
+
+void WriteTest(FlashPartition& partition, size_t test_iterations = 2);
+
+void EraseTest(FlashPartition& partition);
+
+void ReadOnlyTest(FlashPartition& partition);
+
+}  // namespace pw::kvs::PartitionTest