Skip to content

Commit 1cb6f7b

Browse files
author
Kyle Kearney
committed
Make devicekey remainder test more meaningful
As of 722628b, the "remainder" configuration also uses the default location near the end of flash. Which makes the two tests nearly identical with the exception that the "last two sectors" test correctly handles parts with a low (possibly 1:1) erase size to program size ratio. Therefore, change the "remainder" test to instead be a "default" test that uses the tdb_internal_address/size values, so that it a.) tests something meaningfully different and b.) tests using the custom TDB address/size values if they are provided. c.) functions correctly on devices where the default sector-based size computation does not work (e.g. because of the low erase size to program size ratio) and therefore a custom location and size has been specified. The is_conf_tdb_internal variable is unused and therefore removed.
1 parent eeb033f commit 1cb6f7b

File tree

1 file changed

+7
-10
lines changed
  • features/storage/TESTS/kvstore/direct_access_devicekey_test

1 file changed

+7
-10
lines changed

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static inline uint32_t align_down(uint64_t val, uint64_t size)
5050
return (((val) / size)) * size;
5151
}
5252

53-
int get_virtual_TDBStore_position(uint32_t conf_start_address, uint32_t conf_size, bool is_conf_tdb_internal,
53+
int get_virtual_TDBStore_position(uint32_t conf_start_address, uint32_t conf_size,
5454
uint32_t *tdb_start_address, uint32_t *tdb_end_address)
5555
{
5656
uint32_t bd_final_size = conf_size;
@@ -117,14 +117,14 @@ int get_virtual_TDBStore_position(uint32_t conf_start_address, uint32_t conf_si
117117
}
118118

119119

120-
void test_direct_access_to_devicekey_tdb_flashiap_remainder()
120+
void test_direct_access_to_devicekey_tdb_flashiap_default()
121121
{
122-
utest_printf("Test Direct Access To DeviceKey Test Entire FlashIAP Remainder\n");
122+
utest_printf("Test Direct Access To DeviceKey Test Entire FlashIAP Default Address\n");
123123

124124
uint32_t flash_bd_start_address;
125125
uint32_t flash_bd_end_address;
126126

127-
int err = get_virtual_TDBStore_position(0, 0, true, &flash_bd_start_address, &flash_bd_end_address);
127+
int err = get_virtual_TDBStore_position(MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS, MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE, &flash_bd_start_address, &flash_bd_end_address);
128128
TEST_SKIP_UNLESS_MESSAGE(err != -2, "Test skipped. Not enough available space on Internal FlashIAP");
129129
TEST_ASSERT_EQUAL(0, err);
130130
uint32_t flash_bd_size = flash_bd_end_address - flash_bd_start_address;
@@ -177,7 +177,7 @@ void test_direct_access_to_devicekey_tdb_last_two_sectors()
177177
uint32_t flash_bd_start_address;
178178
uint32_t flash_bd_end_address;
179179

180-
int err = get_virtual_TDBStore_position(0, 0, false, &flash_bd_start_address, &flash_bd_end_address);
180+
int err = get_virtual_TDBStore_position(0, 0, &flash_bd_start_address, &flash_bd_end_address);
181181
TEST_SKIP_UNLESS_MESSAGE(err != -2, "Test skipped. Not enough available space on Internal FlashIAP");
182182
TEST_ASSERT_EQUAL(0, err);
183183

@@ -258,7 +258,6 @@ void test_direct_access_to_device_inject_root()
258258
// Now use Direct Access To DeviceKey to retrieve it */
259259
uint32_t internal_start_address;
260260
uint32_t internal_rbp_size;
261-
bool is_conf_tdb_internal = false;
262261
if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "FILESYSTEM") == 0) {
263262
internal_start_address = MBED_CONF_STORAGE_FILESYSTEM_INTERNAL_BASE_ADDRESS;
264263
internal_rbp_size = MBED_CONF_STORAGE_FILESYSTEM_RBP_INTERNAL_SIZE;
@@ -268,7 +267,6 @@ void test_direct_access_to_device_inject_root()
268267
} else if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "TDB_INTERNAL") == 0) {
269268
internal_start_address = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS;
270269
internal_rbp_size = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE;
271-
is_conf_tdb_internal = true;
272270
} else if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "default") == 0) {
273271
#if COMPONENT_QSPIF || COMPONENT_SPIF || COMPONENT_DATAFLASH
274272
internal_start_address = MBED_CONF_STORAGE_TDB_EXTERNAL_INTERNAL_BASE_ADDRESS;
@@ -279,7 +277,6 @@ void test_direct_access_to_device_inject_root()
279277
#elif COMPONENT_FLASHIAP
280278
internal_start_address = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS;
281279
internal_rbp_size = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE;
282-
is_conf_tdb_internal = true;
283280
#else
284281
TEST_SKIP_UNLESS_MESSAGE(false, "Test skipped. No KVStore Internal");
285282
#endif
@@ -289,7 +286,7 @@ void test_direct_access_to_device_inject_root()
289286

290287
uint32_t tdb_st_add = 0;
291288
uint32_t tdb_end_add = 0;
292-
ret = get_virtual_TDBStore_position(internal_start_address, internal_rbp_size, is_conf_tdb_internal, &tdb_st_add, &tdb_end_add);
289+
ret = get_virtual_TDBStore_position(internal_start_address, internal_rbp_size, &tdb_st_add, &tdb_end_add);
293290
TEST_SKIP_UNLESS_MESSAGE(ret != -2, "Test skipped. Not enough available space on Internal FlashIAP");
294291
TEST_ASSERT_EQUAL(0, ret);
295292

@@ -329,7 +326,7 @@ utest::v1::status_t greentea_failure_handler(const Case *const source, const fai
329326
}
330327

331328
Case cases[] = {
332-
Case("Testing direct access to devicekey with tdb over flashiap remainder", test_direct_access_to_devicekey_tdb_flashiap_remainder, greentea_failure_handler),
329+
Case("Testing direct access to devicekey with tdb over flashiap default placement", test_direct_access_to_devicekey_tdb_flashiap_default, greentea_failure_handler),
333330
Case("Testing direct access to devicekey with tdb over last two sectors", test_direct_access_to_devicekey_tdb_last_two_sectors, greentea_failure_handler),
334331
Case("Testing direct access to injected devicekey ", test_direct_access_to_device_inject_root, greentea_failure_handler),
335332
};

0 commit comments

Comments
 (0)