From 16b04521ddbcec0e68a2400ca18b0fb2ffe96b46 Mon Sep 17 00:00:00 2001 From: Wyatt Hepler Date: Fri, 7 Feb 2020 16:00:14 -0800 Subject: pw_kvs: Move test; disable dumping to file - Move long-running Put test to a separate file. - Do not dump the KVS state to file by default to prevent files from showing up when the tests run. Change-Id: Ie466d06aa3e22819cad03713e866afae5c63cbe6 --- pw_kvs/key_value_store_test.cc | 48 +++++++++--------------------------------- 1 file changed, 10 insertions(+), 38 deletions(-) (limited to 'pw_kvs/key_value_store_test.cc') diff --git a/pw_kvs/key_value_store_test.cc b/pw_kvs/key_value_store_test.cc index 90043dc01..c54d6e773 100644 --- a/pw_kvs/key_value_store_test.cc +++ b/pw_kvs/key_value_store_test.cc @@ -12,22 +12,16 @@ // License for the specific language governing permissions and limitations under // the License. +#define DUMP_KVS_STATE_TO_FILE 0 +#define USE_MEMORY_BUFFER 1 +#define PW_LOG_USE_ULTRA_SHORT_NAMES 1 + #include "pw_kvs/key_value_store.h" #include #include -#if defined(__linux__) -#include -#endif // defined(__linux__) #include -#include - -#include "pw_span/span.h" - -#define PW_LOG_USE_ULTRA_SHORT_NAMES 1 -#include "pw_log/log.h" - -#define USE_MEMORY_BUFFER 1 +#include #include "gtest/gtest.h" #include "pw_checksum/ccitt_crc16.h" @@ -36,6 +30,7 @@ #include "pw_kvs_private/format.h" #include "pw_kvs_private/macros.h" #include "pw_log/log.h" +#include "pw_span/span.h" #include "pw_status/status.h" #include "pw_string/string_builder.h" @@ -90,7 +85,7 @@ struct FlashWithPartitionFake { FlashPartition partition; public: -#if defined(__linux__) +#if DUMP_KVS_STATE_TO_FILE Status Dump(const char* filename) { std::FILE* out_file = std::fopen(filename, "w+"); if (out_file == nullptr) { @@ -121,11 +116,8 @@ struct FlashWithPartitionFake { return status; } #else - Status Dump(const char* filename) { - (void)(filename); - return Status::OK; - } -#endif // defined(__linux__) + Status Dump(const char*) { return Status::OK; } +#endif // DUMP_KVS_STATE_TO_FILE }; typedef FlashWithPartitionFake<4 * 128 /*sector size*/, 6 /*sectors*/> Flash; @@ -165,8 +157,6 @@ class KvsAttributes { min_put_size_( RoundUpForAlignment(chunk_header_size_ + key_size_ + data_size_)) {} - size_t SectorHeaderSize() { return 0; } - size_t SectorHeaderMetaSize() { return 0; } size_t ChunkHeaderSize() { return chunk_header_size_; } size_t DataSize() { return data_size_; } size_t KeySize() { return key_size_; } @@ -269,23 +259,6 @@ TEST_F(EmptyInitializedKvs, Put_SameKeyDifferentValuesRepeatedly) { } } -TEST_F(EmptyInitializedKvs, Put_VaryingKeysAndValues) { - char value[] = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" // 52 - "34567890123"; // 64 (with final \0); - static_assert(sizeof(value) == 64); - - for (int i = 0; i < 2; ++i) { - for (unsigned key_size = 1; key_size < sizeof(value); ++key_size) { - for (unsigned value_size = 0; value_size < sizeof(value); ++value_size) { - ASSERT_EQ(Status::OK, - kvs_.Put(std::string_view(value, key_size), - as_bytes(span(value, value_size)))); - } - } - } -} - TEST_F(EmptyInitializedKvs, Delete_GetDeletedKey_ReturnsNotFound) { ASSERT_EQ(Status::OK, kvs_.Put("kEy", as_bytes(span("123")))); ASSERT_EQ(Status::OK, kvs_.Delete("kEy")); @@ -943,8 +916,7 @@ TEST_F(EmptyInitializedKvs, FillSector2) { } } - size_t expected_remaining = test_partition.sector_size_bytes() - - kvs_attr.SectorHeaderSize() - kSizeToFill; + size_t expected_remaining = test_partition.sector_size_bytes() - kSizeToFill; ASSERT_EQ(new_keyvalue_size, expected_remaining); const char* kNewKey = "NewKey"; -- cgit v1.2.3