Skip to content

Commit dd753ab

Browse files
authored
Merge pull request #11825 from rajkan01/feature-baremetal-greentea-storage
Bare metal green tea test for storage component
2 parents 09d9287 + d8e2dd5 commit dd753ab

File tree

7 files changed

+40
-11
lines changed
  • components/storage/blockdevice/COMPONENT_SD/TESTS/filesystem/parallel
  • features/storage

7 files changed

+40
-11
lines changed

components/storage/blockdevice/COMPONENT_SD/TESTS/filesystem/parallel/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
#if !defined(MBED_CONF_RTOS_PRESENT)
17+
#error [NOT_SUPPORTED] filesystem test cases require a RTOS to run
18+
#else
1619

1720
#include "mbed.h"
1821
#include "greentea-client/test_env.h"
@@ -207,3 +210,4 @@ int main()
207210
{
208211
return !Harness::run(specification);
209212
}
213+
#endif // !defined(MBED_CONF_RTOS_PRESENT)

features/storage/TESTS/blockdevice/general_block_device/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ void test_random_program_read_erase()
308308
delete[] write_block;
309309
}
310310

311+
#if defined(MBED_CONF_RTOS_PRESENT)
311312
static void test_thread_job()
312313
{
313314
static int thread_num = 0;
@@ -392,8 +393,8 @@ void test_multi_threads()
392393

393394
delete[] bd_thread;
394395
}
395-
396396
}
397+
#endif
397398

398399
void test_erase_functionality()
399400
{
@@ -727,7 +728,9 @@ typedef struct {
727728
template_case_t template_cases[] = {
728729
{"Testing Init block device", test_init_bd, greentea_failure_handler},
729730
{"Testing read write random blocks", test_random_program_read_erase, greentea_failure_handler},
731+
#if defined(MBED_CONF_RTOS_PRESENT)
730732
{"Testing multi threads erase program read", test_multi_threads, greentea_failure_handler},
733+
#endif
731734
{"Testing contiguous erase, write and read", test_contiguous_erase_write_read, greentea_failure_handler},
732735
{"Testing BlockDevice erase functionality", test_erase_functionality, greentea_failure_handler},
733736
{"Testing program read small data sizes", test_program_read_small_data_sizes, greentea_failure_handler},

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
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
1821

1922
#include "rtos/Thread.h"
2023
#include "mbed_trace.h"
@@ -522,3 +525,4 @@ int main()
522525
}
523526

524527
#endif // !defined(TARGET_K64F) && !defined(TARGET_ARM_FM)
528+
#endif // !defined(MBED_CONF_RTOS_PRESENT)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
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
1720

1821
#include "SecureStore.h"
1922
#include "TDBStore.h"
@@ -857,3 +860,4 @@ int main()
857860
}
858861

859862
#endif // !defined(TARGET_K64F) && !defined(TARGET_ARM_FM)
863+
#endif // !defined(MBED_CONF_RTOS_PRESENT)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
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
1720

1821
#include "SecureStore.h"
1922
#include "TDBStore.h"
@@ -860,3 +863,4 @@ int main()
860863
}
861864

862865
#endif // !defined(TARGET_K64F) && !defined(TARGET_ARM_FM)
866+
#endif // !defined(MBED_CONF_RTOS_PRESENT)

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
* limitations under the License.
1616
*/
1717

18+
#if defined(MBED_CONF_RTOS_PRESENT)
1819
#include "Thread.h"
20+
#endif
1921
#include "mbed_error.h"
2022
#include "greentea-client/test_env.h"
2123
#include "unity/unity.h"
@@ -33,10 +35,13 @@ static size_t actual_size = 0;
3335
static const size_t buffer_size = 20;
3436
static const int num_of_threads = 3;
3537
static const char num_of_keys = 3;
36-
38+
#if defined(MBED_CONF_RTOS_PRESENT)
3739
/* Forked 3 threads plus misc, so minimum (4 * OS_STACK_SIZE) heap are required. */
3840
static const int heap_alloc_threshold_size = 4 * OS_STACK_SIZE;
39-
41+
#else
42+
/* Bare metal does not require memory for threads, so use just minimum for test */
43+
static const int heap_alloc_threshold_size = MBED_CONF_TARGET_BOOT_STACK_SIZE;
44+
#endif
4045
static const char *keys[] = {"key1", "key2", "key3"};
4146

4247
static int init_res = MBED_ERROR_NOT_READY;
@@ -144,6 +149,7 @@ static void test_thread_set(char *th_key)
144149
//get several keys multithreaded
145150
static void set_several_keys_multithreaded()
146151
{
152+
#if defined(MBED_CONF_RTOS_PRESENT)
147153
TEST_SKIP_UNLESS(!init_res);
148154
rtos::Thread kvstore_thread[num_of_threads];
149155
osStatus threadStatus;
@@ -169,6 +175,7 @@ static void set_several_keys_multithreaded()
169175
res = kv_remove(keys[i]);
170176
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res);
171177
}
178+
#endif
172179
}
173180

174181
//set key "write once" and try to set it again
@@ -464,6 +471,7 @@ static void test_thread_get(const void *th_key)
464471
//get several keys multithreaded
465472
static void get_several_keys_multithreaded()
466473
{
474+
#if defined(MBED_CONF_RTOS_PRESENT)
467475
TEST_SKIP_UNLESS(!init_res);
468476
int i = 0, res = 0;
469477
rtos::Thread kvstore_thread[num_of_threads];
@@ -489,6 +497,7 @@ static void get_several_keys_multithreaded()
489497
res = kv_remove(keys[i]);
490498
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res);
491499
}
500+
#endif
492501
}
493502

494503
/*----------------remove()------------------*/
@@ -924,7 +933,9 @@ Case cases[] = {
924933
Case("set_buffer_null_size_not_zero", set_buffer_null_size_not_zero, greentea_failure_handler),
925934
Case("set_buffer_size_is_zero", set_buffer_size_is_zero, greentea_failure_handler),
926935
Case("set_same_key_several_time", set_same_key_several_time, greentea_failure_handler),
936+
#if defined(MBED_CONF_RTOS_PRESENT)
927937
Case("set_several_keys_multithreaded", set_several_keys_multithreaded, greentea_failure_handler),
938+
#endif
928939
Case("set_write_once_flag_try_set_twice", set_write_once_flag_try_set_twice, greentea_failure_handler),
929940
Case("set_write_once_flag_try_remove", set_write_once_flag_try_remove, greentea_failure_handler),
930941
Case("set_key_value_one_byte_size", set_key_value_one_byte_size, greentea_failure_handler),
@@ -944,8 +955,9 @@ Case cases[] = {
944955
Case("get_non_existing_key", get_non_existing_key, greentea_failure_handler),
945956
Case("get_removed_key", get_removed_key, greentea_failure_handler),
946957
Case("get_key_that_was_set_twice", get_key_that_was_set_twice, greentea_failure_handler),
958+
#if defined(MBED_CONF_RTOS_PRESENT)
947959
Case("get_several_keys_multithreaded", get_several_keys_multithreaded, greentea_failure_handler),
948-
960+
#endif
949961
Case("remove_key_null", remove_key_null, greentea_failure_handler),
950962
Case("remove_key_length_exceeds_max", remove_key_length_exceeds_max, greentea_failure_handler),
951963
Case("remove_non_existing_key", remove_non_existing_key, greentea_failure_handler),

features/storage/nvstore/TESTS/nvstore/functionality/main.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
1718
#include "nvstore.h"
1819
#ifdef MBED_CONF_RTOS_PRESENT
1920
#include "Thread.h"
@@ -396,6 +397,7 @@ static void nvstore_basic_functionality_test()
396397
delete[] nvstore_testing_buf_get;
397398
}
398399

400+
#ifdef MBED_CONF_RTOS_PRESENT
399401
static void thread_test_check_key(uint16_t key)
400402
{
401403
uint8_t get_buff[thr_test_max_data_size];
@@ -422,7 +424,6 @@ static void thread_test_check_key(uint16_t key)
422424

423425
}
424426

425-
#ifdef MBED_CONF_RTOS_PRESENT
426427
static void thread_test_worker()
427428
{
428429
int ret;
@@ -444,11 +445,9 @@ static void thread_test_worker()
444445
wait_ms(1);
445446
}
446447
}
447-
#endif
448448

449449
static void nvstore_multi_thread_test()
450450
{
451-
#ifdef MBED_CONF_RTOS_PRESENT
452451
int i, result;
453452
uint16_t size;
454453
uint16_t key;
@@ -562,8 +561,6 @@ static void nvstore_multi_thread_test()
562561
}
563562

564563
nvstore.reset();
565-
566-
#endif
567564
}
568565

569566

@@ -578,7 +575,6 @@ static void race_test_worker(void *buf)
578575

579576
static void nvstore_race_test()
580577
{
581-
#ifdef MBED_CONF_RTOS_PRESENT
582578
int i;
583579
uint16_t initial_buf_size;
584580
int ret;
@@ -668,8 +664,8 @@ static void nvstore_race_test()
668664
delete[] buffs[i];
669665
}
670666
delete[] get_buff;
671-
#endif
672667
}
668+
#endif
673669

674670

675671

@@ -681,8 +677,10 @@ utest::v1::status_t greentea_failure_handler(const Case *const source, const fai
681677

682678
Case cases[] = {
683679
Case("NVStore: Basic functionality", nvstore_basic_functionality_test, greentea_failure_handler),
680+
#if defined(MBED_CONF_RTOS_PRESENT)
684681
Case("NVStore: Race test", nvstore_race_test, greentea_failure_handler),
685682
Case("NVStore: Multiple thread test", nvstore_multi_thread_test, greentea_failure_handler),
683+
#endif
686684
};
687685

688686
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)

0 commit comments

Comments
 (0)