Skip to content

Commit 631234b

Browse files
committed
[M252KG] Fix kvstore-static_tests failing with OOM
1 parent 9bf85ef commit 631234b

File tree

1 file changed

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

1 file changed

+15
-9
lines changed

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,20 @@ static char buffer[20] = {};
3131
static const size_t data_size = 5;
3232
static size_t actual_size = 0;
3333
static const size_t buffer_size = 20;
34+
35+
/* Adjust number of threads/keys dependent on platform memory resource */
36+
#if defined(TARGET_NUMAKER_M252KG)
37+
static const int num_of_threads = 2;
38+
static const char num_of_keys = 2;
39+
static const char *keys[] = {"key1", "key2"};
40+
#else
3441
static const int num_of_threads = 3;
3542
static const char num_of_keys = 3;
43+
static const char *keys[] = {"key1", "key2", "key3"};
44+
#endif
3645

3746
static const int heap_alloc_threshold_size = 4096;
3847

39-
static const char *keys[] = {"key1", "key2", "key3"};
40-
4148
static int init_res = MBED_ERROR_NOT_READY;
4249

4350
kv_info_t info;
@@ -147,10 +154,9 @@ static void set_several_keys_multithreaded()
147154
rtos::Thread kvstore_thread[num_of_threads];
148155
osStatus threadStatus;
149156

150-
kvstore_thread[0].start(callback(test_thread_set, (char *) keys[0]));
151-
kvstore_thread[1].start(callback(test_thread_set, (char *) keys[1]));
152-
kvstore_thread[2].start(callback(test_thread_set, (char *) keys[2]));
153-
157+
for (int i = 0; i < num_of_threads; i++) {
158+
kvstore_thread[i].start(callback(test_thread_set, (char *) keys[i]));
159+
}
154160

155161
for (int i = 0; i < num_of_threads; i++) {
156162
threadStatus = kvstore_thread[i].join();
@@ -473,9 +479,9 @@ static void get_several_keys_multithreaded()
473479
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res);
474480
}
475481

476-
kvstore_thread[0].start(callback(test_thread_get, "key1"));
477-
kvstore_thread[1].start(callback(test_thread_get, "key2"));
478-
kvstore_thread[2].start(callback(test_thread_get, "key3"));
482+
for (i = 0; i < num_of_threads; i++) {
483+
kvstore_thread[i].start(callback(test_thread_get, (char *) keys[i]));
484+
}
479485

480486
for (i = 0; i < num_of_threads; i++) {
481487
threadStatus = kvstore_thread[i].join();

0 commit comments

Comments
 (0)