Skip to content

Commit 739455a

Browse files
author
Kyle Kearney
committed
Improve reliability of KVStore general tests
In kvstore_init, prior to initializing the kvstore, erase the underlying block storage device. This ensures that each test run starts from a consistent state and avoids failures that can result if a previous test run left the storage in an inconsistent state.
1 parent 66eb594 commit 739455a

File tree

2 files changed

+4
-0
lines changed
  • features/storage/TESTS/kvstore

2 files changed

+4
-0
lines changed

features/storage/TESTS/kvstore/general_tests_phase_1/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ static void kvstore_init()
8585
res = bd->init();
8686
TEST_ASSERT_EQUAL_ERROR_CODE(0, res);
8787
int erase_val = bd->get_erase_value();
88+
// Clear out any stale data that might be left from a previous test
89+
bd->erase(0, bd->size());
8890
res = bd->deinit();
8991
TEST_ASSERT_EQUAL_ERROR_CODE(0, res);
9092

features/storage/TESTS/kvstore/general_tests_phase_2/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ static void kvstore_init()
8585
res = bd->init();
8686
TEST_ASSERT_EQUAL_ERROR_CODE(0, res);
8787
int erase_val = bd->get_erase_value();
88+
// Clear out any stale data that might be left from a previous test
89+
bd->erase(0, bd->size());
8890
res = bd->deinit();
8991
TEST_ASSERT_EQUAL_ERROR_CODE(0, res);
9092

0 commit comments

Comments
 (0)