Skip to content

Commit 13c5b64

Browse files
committed
general_tests_phase_2: SecureStore's underlying TDBStore must be large enough
The test case set_add_data_set_key_value_five_Kbytes stores 5KB of value, and to allow for overheads, we allocate at least 8KB per area of TDBStore (so 16KB for two areas of a whole TDBStore).
1 parent 76cf78d commit 13c5b64

File tree

1 file changed

+7
-2
lines changed
  • storage/kvstore/tests/TESTS/kvstore/general_tests_phase_2

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ static void kvstore_init()
7979
// be a close enough approximation to act as a guideline for how much of the block device we
8080
// need to erase in order to ensure a stable initial condition.
8181
const size_t PAGES_ESTIMATE = 40;
82+
const size_t MIN_TDBSTORE_SIZE = 2 * 8 * 1024; // two areas, minimum 8KB per area
8283

8384
int res;
8485
size_t program_size, erase_size, ul_bd_size, rbp_bd_size;
@@ -133,8 +134,12 @@ static void kvstore_init()
133134
erase_size = sec_bd->get_erase_size();
134135
// We must be able to hold at least 10 small keys (20 program sectors) and master record + internal data
135136
// but minimum of 2 erase sectors, so that the garbage collection way work
136-
ul_bd_size = align_up(program_size * PAGES_ESTIMATE, erase_size * 2);
137-
rbp_bd_size = align_up(program_size * PAGES_ESTIMATE, erase_size * 2);
137+
// Also, the total size needs to be large enough for set_add_data_set_key_value_five_Kbytes (5KB value)
138+
// and to allow for overheads, we require at least 2 * 8KB for two areas per TDBStore
139+
ul_bd_size = program_size * PAGES_ESTIMATE;
140+
ul_bd_size = ul_bd_size > MIN_TDBSTORE_SIZE ? ul_bd_size : MIN_TDBSTORE_SIZE;
141+
ul_bd_size = align_up(ul_bd_size, erase_size * 2);
142+
rbp_bd_size = ul_bd_size;
138143

139144
res = sec_bd->deinit();
140145
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res);

0 commit comments

Comments
 (0)