Skip to content

Commit 422b194

Browse files
authored
Merge pull request #12843 from ithinuel/bare_metal_storage
enable storage tests on baremetal
2 parents 5e76548 + 1005ea2 commit 422b194

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
#if !defined(MBED_CONF_RTOS_PRESENT)
19-
#error [NOT_SUPPORTED] Kvstore API test cases require a RTOS to run
20-
#else
21-
2218
#include "rtos/Thread.h"
2319
#include "mbed_trace.h"
2420
#include "mbed_error.h"
@@ -421,6 +417,7 @@ void test_file_system_store_edge_cases()
421417
TEST_ASSERT_EQUAL_ERROR_CODE(0, err);
422418
}
423419

420+
#ifdef MBED_CONF_RTOS_PRESENT
424421
void test_file_system_store_multi_threads()
425422
{
426423
utest_printf("\nTest Multi Threaded FileSystemStore Set Starts..\n");
@@ -494,6 +491,7 @@ void test_file_system_store_multi_threads()
494491
err = bd->deinit();
495492
TEST_ASSERT_EQUAL_ERROR_CODE(0, err);
496493
}
494+
#endif
497495

498496
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason)
499497
{
@@ -511,7 +509,9 @@ utest::v1::status_t test_setup(const size_t number_of_cases)
511509
Case cases[] = {
512510
Case("Testing functionality APIs unit test", test_file_system_store_functionality_unit_test, greentea_failure_handler),
513511
Case("Testing Edge Cases", test_file_system_store_edge_cases, greentea_failure_handler),
512+
#ifdef MBED_CONF_RTOS_PRESENT
514513
Case("Testing Multi Threads Set", test_file_system_store_multi_threads, greentea_failure_handler)
514+
#endif
515515
};
516516

517517
Specification specification(test_setup, cases);
@@ -525,4 +525,3 @@ int main()
525525
}
526526

527527
#endif //!SECURESTORE_ENABLED
528-
#endif // !defined(MBED_CONF_RTOS_PRESENT)

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
#if !defined(MBED_CONF_RTOS_PRESENT)
18-
#error [NOT_SUPPORTED] Kvstore API test cases require a RTOS to run
19-
#else
20-
2117
#include "SecureStore.h"
2218
#include "TDBStore.h"
19+
#ifdef MBED_CONF_RTOS_PRESENT
2320
#include "Thread.h"
21+
#endif
2422
#include "mbed_error.h"
2523
#include "FlashSimBlockDevice.h"
2624
#include "SlicingBlockDevice.h"
@@ -45,7 +43,9 @@ static size_t actual_size = 0;
4543
static const size_t buffer_size = 20;
4644
static const int num_of_threads = 3;
4745

46+
#ifdef MBED_CONF_RTOS_PRESENT
4847
static const char *keys[] = {"key1", "key2", "key3"};
48+
#endif
4949

5050
KVStore::info_t info;
5151
KVStore::iterator_t kvstore_it;
@@ -265,6 +265,7 @@ static void set_same_key_several_time()
265265
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res);
266266
}
267267

268+
#ifdef MBED_CONF_RTOS_PRESENT
268269
static void test_thread_set(char *th_key)
269270
{
270271
int res = kvstore->set((char *)th_key, data, data_size, 0);
@@ -302,6 +303,7 @@ static void set_several_keys_multithreaded()
302303
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res);
303304
}
304305
}
306+
#endif
305307

306308
//set key "write once" and try to set it again
307309
static void set_write_once_flag_try_set_twice()
@@ -706,6 +708,7 @@ static void get_key_that_was_set_twice()
706708
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res);
707709
}
708710

711+
#ifdef MBED_CONF_RTOS_PRESENT
709712
static void test_thread_get(const void *th_key)
710713
{
711714
int res = kvstore->get((char *)th_key, buffer, buffer_size, &actual_size, 0);
@@ -741,7 +744,7 @@ static void get_several_keys_multithreaded()
741744
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res);
742745
}
743746
}
744-
747+
#endif
745748

746749
/*----------------remove()------------------*/
747750

@@ -826,7 +829,9 @@ template_case_t template_cases[] = {
826829
{"set_key_undefined_flags", set_key_undefined_flags, greentea_failure_handler},
827830
{"set_buffer_size_is_zero", set_buffer_size_is_zero, greentea_failure_handler},
828831
{"set_same_key_several_time", set_same_key_several_time, greentea_failure_handler},
832+
#ifdef MBED_CONF_RTOS_PRESENT
829833
{"set_several_keys_multithreaded", set_several_keys_multithreaded, greentea_failure_handler},
834+
#endif
830835
{"set_write_once_flag_try_set_twice", set_write_once_flag_try_set_twice, greentea_failure_handler},
831836
{"set_write_once_flag_try_remove", set_write_once_flag_try_remove, greentea_failure_handler},
832837
{"set_key_value_one_byte_size", set_key_value_one_byte_size, greentea_failure_handler},
@@ -851,7 +856,9 @@ template_case_t template_cases[] = {
851856
{"get_non_existing_key", get_non_existing_key, greentea_failure_handler},
852857
{"get_removed_key", get_removed_key, greentea_failure_handler},
853858
{"get_key_that_was_set_twice", get_key_that_was_set_twice, greentea_failure_handler},
859+
#ifdef MBED_CONF_RTOS_PRESENT
854860
{"get_several_keys_multithreaded", get_several_keys_multithreaded, greentea_failure_handler},
861+
#endif
855862

856863
{"remove_key_null", remove_key_null, greentea_failure_handler},
857864
{"remove_key_length_exceeds_max", remove_key_length_exceeds_max, greentea_failure_handler},
@@ -912,4 +919,3 @@ int main()
912919
}
913920

914921
#endif //!SECURESTORE_ENABLED
915-
#endif // !defined(MBED_CONF_RTOS_PRESENT)

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,8 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
#if !defined(MBED_CONF_RTOS_PRESENT)
18-
#error [NOT_SUPPORTED] Kvstore API test cases require a RTOS to run
19-
#else
20-
2117
#include "SecureStore.h"
2218
#include "TDBStore.h"
23-
#include "Thread.h"
2419
#include "mbed_error.h"
2520
#include "FlashSimBlockDevice.h"
2621
#include "SlicingBlockDevice.h"
@@ -895,4 +890,3 @@ int main()
895890
}
896891

897892
#endif //!SECURESTORE_ENABLED
898-
#endif // !defined(MBED_CONF_RTOS_PRESENT)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ static void set_same_key_several_time()
146146
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res);
147147
}
148148

149+
#if defined(MBED_CONF_RTOS_PRESENT)
149150
static void test_thread_set(char *th_key)
150151
{
151152
TEST_SKIP_UNLESS(!init_res);
@@ -156,7 +157,6 @@ static void test_thread_set(char *th_key)
156157
//get several keys multithreaded
157158
static void set_several_keys_multithreaded()
158159
{
159-
#if defined(MBED_CONF_RTOS_PRESENT)
160160
TEST_SKIP_UNLESS(!init_res);
161161
rtos::Thread kvstore_thread[num_of_threads];
162162
osStatus threadStatus;
@@ -182,8 +182,8 @@ static void set_several_keys_multithreaded()
182182
res = kv_remove(keys[i]);
183183
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res);
184184
}
185-
#endif
186185
}
186+
#endif
187187

188188
//set key "write once" and try to set it again
189189
static void set_write_once_flag_try_set_twice()
@@ -468,6 +468,7 @@ static void get_key_that_was_set_twice()
468468
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res);
469469
}
470470

471+
#if defined(MBED_CONF_RTOS_PRESENT)
471472
static void test_thread_get(const void *th_key)
472473
{
473474
TEST_SKIP_UNLESS(!init_res);
@@ -481,7 +482,6 @@ static void test_thread_get(const void *th_key)
481482
//get several keys multithreaded
482483
static void get_several_keys_multithreaded()
483484
{
484-
#if defined(MBED_CONF_RTOS_PRESENT)
485485
TEST_SKIP_UNLESS(!init_res);
486486
int i = 0, res = 0;
487487
rtos::Thread kvstore_thread[num_of_threads];
@@ -507,8 +507,8 @@ static void get_several_keys_multithreaded()
507507
res = kv_remove(keys[i]);
508508
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res);
509509
}
510-
#endif
511510
}
511+
#endif
512512

513513
/*----------------remove()------------------*/
514514

0 commit comments

Comments
 (0)