-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bare metal green tea test for storage component #11825
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,10 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
#if !DEVICEKEY_ENABLED | ||
#error [NOT_SUPPORTED] DeviceKey needs to be enabled for this test | ||
#else | ||
|
||
#include "DeviceKey.h" | ||
#include "mbedtls/config.h" | ||
#include "utest/utest.h" | ||
|
@@ -28,10 +32,6 @@ | |
using namespace utest::v1; | ||
using namespace mbed; | ||
|
||
#if !DEVICEKEY_ENABLED | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
#error [NOT_SUPPORTED] DeviceKey needs to be enabled for this test | ||
#else | ||
|
||
#define MSG_VALUE_DUMMY "0" | ||
#define MSG_VALUE_LEN 32 | ||
#define MSG_KEY_LEN 32 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,9 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
#if defined(MBED_CONF_RTOS_PRESENT) | ||
#include "Thread.h" | ||
#endif | ||
#include "mbed_error.h" | ||
#include "greentea-client/test_env.h" | ||
#include "unity/unity.h" | ||
|
@@ -33,10 +35,10 @@ static size_t actual_size = 0; | |
static const size_t buffer_size = 20; | ||
static const int num_of_threads = 3; | ||
static const char num_of_keys = 3; | ||
|
||
#if defined(MBED_CONF_RTOS_PRESENT) | ||
/* Forked 3 threads plus misc, so minimum (4 * OS_STACK_SIZE) heap are required. */ | ||
static const int heap_alloc_threshold_size = 4 * OS_STACK_SIZE; | ||
|
||
#endif | ||
static const char *keys[] = {"key1", "key2", "key3"}; | ||
|
||
static int init_res = MBED_ERROR_NOT_READY; | ||
|
@@ -67,6 +69,7 @@ static void parse_default_kv() | |
//init the blockdevice | ||
static void kvstore_init() | ||
{ | ||
#if defined(MBED_CONF_RTOS_PRESENT) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If init is skipped, then why is not the whole |
||
uint8_t *dummy = new (std::nothrow) uint8_t[heap_alloc_threshold_size]; | ||
TEST_SKIP_UNLESS_MESSAGE(dummy, "Not enough heap to run test"); | ||
delete[] dummy; | ||
|
@@ -76,6 +79,7 @@ static void kvstore_init() | |
init_res = kv_reset(def_kv); | ||
TEST_SKIP_UNLESS_MESSAGE(init_res != MBED_ERROR_UNSUPPORTED, "Unsupported configuration. Test skipped."); | ||
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, init_res); | ||
#endif | ||
} | ||
|
||
/*----------------set()------------------*/ | ||
|
@@ -144,6 +148,7 @@ 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; | ||
|
@@ -169,6 +174,7 @@ static void set_several_keys_multithreaded() | |
res = kv_remove(keys[i]); | ||
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res); | ||
} | ||
#endif | ||
} | ||
|
||
//set key "write once" and try to set it again | ||
|
@@ -464,6 +470,7 @@ 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]; | ||
|
@@ -489,6 +496,7 @@ static void get_several_keys_multithreaded() | |
res = kv_remove(keys[i]); | ||
TEST_ASSERT_EQUAL_ERROR_CODE(MBED_SUCCESS, res); | ||
} | ||
#endif | ||
} | ||
|
||
/*----------------remove()------------------*/ | ||
|
@@ -924,7 +932,9 @@ Case cases[] = { | |
Case("set_buffer_null_size_not_zero", set_buffer_null_size_not_zero, greentea_failure_handler), | ||
Case("set_buffer_size_is_zero", set_buffer_size_is_zero, greentea_failure_handler), | ||
Case("set_same_key_several_time", set_same_key_several_time, greentea_failure_handler), | ||
#if defined(MBED_CONF_RTOS_PRESENT) | ||
Case("set_several_keys_multithreaded", set_several_keys_multithreaded, greentea_failure_handler), | ||
#endif | ||
Case("set_write_once_flag_try_set_twice", set_write_once_flag_try_set_twice, greentea_failure_handler), | ||
Case("set_write_once_flag_try_remove", set_write_once_flag_try_remove, greentea_failure_handler), | ||
Case("set_key_value_one_byte_size", set_key_value_one_byte_size, greentea_failure_handler), | ||
|
@@ -944,8 +954,9 @@ Case cases[] = { | |
Case("get_non_existing_key", get_non_existing_key, greentea_failure_handler), | ||
Case("get_removed_key", get_removed_key, greentea_failure_handler), | ||
Case("get_key_that_was_set_twice", get_key_that_was_set_twice, greentea_failure_handler), | ||
#if defined(MBED_CONF_RTOS_PRESENT) | ||
Case("get_several_keys_multithreaded", get_several_keys_multithreaded, greentea_failure_handler), | ||
|
||
#endif | ||
Case("remove_key_null", remove_key_null, greentea_failure_handler), | ||
Case("remove_key_length_exceeds_max", remove_key_length_exceeds_max, greentea_failure_handler), | ||
Case("remove_non_existing_key", remove_non_existing_key, greentea_failure_handler), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,10 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
#if !NVSTORE_ENABLED | ||
#error [NOT_SUPPORTED] NVSTORE needs to be enabled for this test | ||
#else | ||
|
||
#include "nvstore.h" | ||
#ifdef MBED_CONF_RTOS_PRESENT | ||
#include "Thread.h" | ||
|
@@ -27,10 +31,6 @@ | |
#include <stdio.h> | ||
#include <algorithm> | ||
|
||
#if !NVSTORE_ENABLED | ||
#error [NOT_SUPPORTED] NVSTORE needs to be enabled for this test | ||
#else | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, I don't see the point of moving the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This macro comes from "features/storage/nvstore/mbed_lib.json".i think this is fine to keep at the beginning There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not totally true. It can be disabled, if FLASH is not enabled: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I noticed, I will move this after nvstore.h file |
||
|
||
using namespace utest::v1; | ||
|
||
static const uint16_t max_test_keys = 20; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ThisThread::sleep_for()
is not requiring RTOS, so no need to guard.