Merge pull request #12843 from ithinuel/bare_metal_storage

enable storage tests on baremetal
pull/12855/head
Martin Kojtal 2020-04-22 16:03:14 +02:00 committed by GitHub
commit 422b194114
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 21 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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()------------------*/