Skip to content

Commit ac99126

Browse files
Veijo Pesonen0xc0170
authored andcommitted
Fixes features-storage-tests-kvstore-static_tests test case bugs
At least with LPC55S69's default TDBStore configuration it's impossible to run storage Greentea tests without exhausting the memory reserved for storing keys. Fixes an issue where number of keys were removed based on number of threads which didn't have anything to do with the test case. Fixes an issue where number of keys were assumed to be constant but variable number was used for configuration.
1 parent 68f8ad6 commit ac99126

File tree

1 file changed

+9
-7
lines changed
  • features/storage/TESTS/kvstore/static_tests

1 file changed

+9
-7
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,17 @@ static const size_t data_size = 5;
3434
static size_t actual_size = 0;
3535
static const size_t buffer_size = 20;
3636
static const int num_of_threads = 3;
37-
static const char num_of_keys = 3;
37+
static const char num_of_keys = 11;
3838
#if defined(MBED_CONF_RTOS_PRESENT)
3939
/* Forked 3 threads plus misc, so minimum (4 * OS_STACK_SIZE) heap are required. */
4040
static const int heap_alloc_threshold_size = 4 * OS_STACK_SIZE;
4141
#else
4242
/* Bare metal does not require memory for threads, so use just minimum for test */
4343
static const int heap_alloc_threshold_size = MBED_CONF_TARGET_BOOT_STACK_SIZE;
4444
#endif
45-
static const char *keys[] = {"key1", "key2", "key3"};
45+
static const char *keys[num_of_keys] = { "key1", "key2", "key3", "key4", "key5", "key6", "key7", "key8", "key9",
46+
"key10", "key11"
47+
};
4648

4749
static int init_res = MBED_ERROR_NOT_READY;
4850

@@ -298,14 +300,14 @@ static void set_several_key_value_sizes()
298300

299301
name[6] = 0;
300302

301-
for (i = 0; i < 26; i++) {
303+
for (i = 0; i < num_of_keys; i++) {
302304
c = i + 'a';
303305
name[5] = c;
304306
res = kv_set(name, name, sizeof(name), 0);
305307
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res);
306308
}
307309

308-
for (i = 0; i < 26; i++) {
310+
for (i = 0; i < num_of_keys; i++) {
309311
c = i + 'a';
310312
name[5] = c;
311313
res = kv_get(name, buffer, sizeof(buffer), &actual_size);
@@ -328,7 +330,7 @@ static void set_several_unvalid_key_names()
328330

329331
name[6] = 0;
330332

331-
for (i = 0; i < 11; i++) {
333+
for (i = 0; i < num_of_keys; i++) {
332334
name[5] = unvalid[i];
333335
res = kv_set(name, name, sizeof(name), 0);
334336
if (unvalid[i] != '/') {
@@ -817,7 +819,7 @@ static void iterator_next_full_list()
817819
res = kv_iterator_close(kvstore_it);
818820
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res);
819821

820-
for (i = 0; i < num_of_threads; i++) {
822+
for (i = 0; i < num_of_keys; i++) {
821823
res = kv_remove(keys[i]);
822824
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res);
823825
}
@@ -855,7 +857,7 @@ static void iterator_next_remove_while_iterating()
855857

856858
int i = 0, res = 0;
857859

858-
for (i = 0; i < num_of_keys; i++) {
860+
for (i = 0; i < 3; i++) {
859861
int res = kv_set(keys[i], data, data_size, 0);
860862
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res);
861863
}

0 commit comments

Comments
 (0)