From 1005ea28dff6566d0ceb1f3c644a4401c2914550 Mon Sep 17 00:00:00 2001 From: Wilfried Chauveau Date: Tue, 21 Apr 2020 17:53:43 +0100 Subject: [PATCH] enable storage tests on baremetal --- .../kvstore/filesystemstore_tests/main.cpp | 9 ++++----- .../kvstore/general_tests_phase_1/main.cpp | 18 ++++++++++++------ .../kvstore/general_tests_phase_2/main.cpp | 6 ------ .../TESTS/kvstore/static_tests/main.cpp | 8 ++++---- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/features/storage/TESTS/kvstore/filesystemstore_tests/main.cpp b/features/storage/TESTS/kvstore/filesystemstore_tests/main.cpp index b71c121864..bbf483201b 100644 --- a/features/storage/TESTS/kvstore/filesystemstore_tests/main.cpp +++ b/features/storage/TESTS/kvstore/filesystemstore_tests/main.cpp @@ -15,10 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if !defined(MBED_CONF_RTOS_PRESENT) -#error [NOT_SUPPORTED] Kvstore API test cases require a RTOS to run -#else - #include "rtos/Thread.h" #include "mbed_trace.h" #include "mbed_error.h" @@ -421,6 +417,7 @@ void test_file_system_store_edge_cases() TEST_ASSERT_EQUAL_ERROR_CODE(0, err); } +#ifdef MBED_CONF_RTOS_PRESENT void test_file_system_store_multi_threads() { utest_printf("\nTest Multi Threaded FileSystemStore Set Starts..\n"); @@ -494,6 +491,7 @@ void test_file_system_store_multi_threads() err = bd->deinit(); TEST_ASSERT_EQUAL_ERROR_CODE(0, err); } +#endif utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) { @@ -511,7 +509,9 @@ utest::v1::status_t test_setup(const size_t number_of_cases) Case cases[] = { Case("Testing functionality APIs unit test", test_file_system_store_functionality_unit_test, greentea_failure_handler), Case("Testing Edge Cases", test_file_system_store_edge_cases, greentea_failure_handler), +#ifdef MBED_CONF_RTOS_PRESENT Case("Testing Multi Threads Set", test_file_system_store_multi_threads, greentea_failure_handler) +#endif }; Specification specification(test_setup, cases); @@ -525,4 +525,3 @@ int main() } #endif //!SECURESTORE_ENABLED -#endif // !defined(MBED_CONF_RTOS_PRESENT) diff --git a/features/storage/TESTS/kvstore/general_tests_phase_1/main.cpp b/features/storage/TESTS/kvstore/general_tests_phase_1/main.cpp index 47d2959953..caf1c0c2d8 100644 --- a/features/storage/TESTS/kvstore/general_tests_phase_1/main.cpp +++ b/features/storage/TESTS/kvstore/general_tests_phase_1/main.cpp @@ -14,13 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if !defined(MBED_CONF_RTOS_PRESENT) -#error [NOT_SUPPORTED] Kvstore API test cases require a RTOS to run -#else - #include "SecureStore.h" #include "TDBStore.h" +#ifdef MBED_CONF_RTOS_PRESENT #include "Thread.h" +#endif #include "mbed_error.h" #include "FlashSimBlockDevice.h" #include "SlicingBlockDevice.h" @@ -45,7 +43,9 @@ static size_t actual_size = 0; static const size_t buffer_size = 20; static const int num_of_threads = 3; +#ifdef MBED_CONF_RTOS_PRESENT static const char *keys[] = {"key1", "key2", "key3"}; +#endif KVStore::info_t info; KVStore::iterator_t kvstore_it; @@ -265,6 +265,7 @@ static void set_same_key_several_time() TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res); } +#ifdef MBED_CONF_RTOS_PRESENT static void test_thread_set(char *th_key) { int res = kvstore->set((char *)th_key, data, data_size, 0); @@ -302,6 +303,7 @@ static void set_several_keys_multithreaded() TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res); } } +#endif //set key "write once" and try to set it again static void set_write_once_flag_try_set_twice() @@ -706,6 +708,7 @@ static void get_key_that_was_set_twice() TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res); } +#ifdef MBED_CONF_RTOS_PRESENT static void test_thread_get(const void *th_key) { int res = kvstore->get((char *)th_key, buffer, buffer_size, &actual_size, 0); @@ -741,7 +744,7 @@ static void get_several_keys_multithreaded() TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res); } } - +#endif /*----------------remove()------------------*/ @@ -826,7 +829,9 @@ template_case_t template_cases[] = { {"set_key_undefined_flags", set_key_undefined_flags, greentea_failure_handler}, {"set_buffer_size_is_zero", set_buffer_size_is_zero, greentea_failure_handler}, {"set_same_key_several_time", set_same_key_several_time, greentea_failure_handler}, +#ifdef MBED_CONF_RTOS_PRESENT {"set_several_keys_multithreaded", set_several_keys_multithreaded, greentea_failure_handler}, +#endif {"set_write_once_flag_try_set_twice", set_write_once_flag_try_set_twice, greentea_failure_handler}, {"set_write_once_flag_try_remove", set_write_once_flag_try_remove, greentea_failure_handler}, {"set_key_value_one_byte_size", set_key_value_one_byte_size, greentea_failure_handler}, @@ -851,7 +856,9 @@ template_case_t template_cases[] = { {"get_non_existing_key", get_non_existing_key, greentea_failure_handler}, {"get_removed_key", get_removed_key, greentea_failure_handler}, {"get_key_that_was_set_twice", get_key_that_was_set_twice, greentea_failure_handler}, +#ifdef MBED_CONF_RTOS_PRESENT {"get_several_keys_multithreaded", get_several_keys_multithreaded, greentea_failure_handler}, +#endif {"remove_key_null", remove_key_null, greentea_failure_handler}, {"remove_key_length_exceeds_max", remove_key_length_exceeds_max, greentea_failure_handler}, @@ -912,4 +919,3 @@ int main() } #endif //!SECURESTORE_ENABLED -#endif // !defined(MBED_CONF_RTOS_PRESENT) diff --git a/features/storage/TESTS/kvstore/general_tests_phase_2/main.cpp b/features/storage/TESTS/kvstore/general_tests_phase_2/main.cpp index c67950ec39..43942814f5 100644 --- a/features/storage/TESTS/kvstore/general_tests_phase_2/main.cpp +++ b/features/storage/TESTS/kvstore/general_tests_phase_2/main.cpp @@ -14,13 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if !defined(MBED_CONF_RTOS_PRESENT) -#error [NOT_SUPPORTED] Kvstore API test cases require a RTOS to run -#else - #include "SecureStore.h" #include "TDBStore.h" -#include "Thread.h" #include "mbed_error.h" #include "FlashSimBlockDevice.h" #include "SlicingBlockDevice.h" @@ -895,4 +890,3 @@ int main() } #endif //!SECURESTORE_ENABLED -#endif // !defined(MBED_CONF_RTOS_PRESENT) diff --git a/features/storage/TESTS/kvstore/static_tests/main.cpp b/features/storage/TESTS/kvstore/static_tests/main.cpp index 0e2b2dfd32..a4cc6d93b4 100644 --- a/features/storage/TESTS/kvstore/static_tests/main.cpp +++ b/features/storage/TESTS/kvstore/static_tests/main.cpp @@ -146,6 +146,7 @@ static void set_same_key_several_time() TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res); } +#if defined(MBED_CONF_RTOS_PRESENT) static void test_thread_set(char *th_key) { TEST_SKIP_UNLESS(!init_res); @@ -156,7 +157,6 @@ static void test_thread_set(char *th_key) //get several keys multithreaded static void set_several_keys_multithreaded() { -#if defined(MBED_CONF_RTOS_PRESENT) TEST_SKIP_UNLESS(!init_res); rtos::Thread kvstore_thread[num_of_threads]; osStatus threadStatus; @@ -182,8 +182,8 @@ static void set_several_keys_multithreaded() res = kv_remove(keys[i]); TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res); } -#endif } +#endif //set key "write once" and try to set it again static void set_write_once_flag_try_set_twice() @@ -468,6 +468,7 @@ static void get_key_that_was_set_twice() TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res); } +#if defined(MBED_CONF_RTOS_PRESENT) static void test_thread_get(const void *th_key) { TEST_SKIP_UNLESS(!init_res); @@ -481,7 +482,6 @@ static void test_thread_get(const void *th_key) //get several keys multithreaded static void get_several_keys_multithreaded() { -#if defined(MBED_CONF_RTOS_PRESENT) TEST_SKIP_UNLESS(!init_res); int i = 0, res = 0; rtos::Thread kvstore_thread[num_of_threads]; @@ -507,8 +507,8 @@ static void get_several_keys_multithreaded() res = kv_remove(keys[i]); TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res); } -#endif } +#endif /*----------------remove()------------------*/