Skip to content

Commit

Permalink
Incorporated the review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rajkan01 committed Nov 8, 2019
1 parent 8ecce14 commit d8e2dd5
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 26 deletions.
2 changes: 0 additions & 2 deletions components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,9 +872,7 @@ uint32_t SDBlockDevice::_go_idle_state()
if (R1_IDLE_STATE == response) {
break;
}
#if defined(MBED_CONF_RTOS_PRESENT)
rtos::ThisThread::sleep_for(1);
#endif
}
return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
#if !defined(MBED_CONF_RTOS_PRESENT)
#error [NOT_SUPPORTED] filesystem test cases requires RTOS to run
#error [NOT_SUPPORTED] filesystem test cases require a RTOS to run
#else

#include "mbed.h"
Expand Down
8 changes: 4 additions & 4 deletions features/device_key/TESTS/device_key/functionality/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
* 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"
Expand All @@ -32,6 +28,10 @@
using namespace utest::v1;
using namespace mbed;

#if !DEVICEKEY_ENABLED
#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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ void test_random_program_read_erase()
delete[] write_block;
}

#if defined(MBED_CONF_RTOS_PRESENT)
static void test_thread_job()
{
#if defined(MBED_CONF_RTOS_PRESENT)
static int thread_num = 0;
_mutex->lock();
int block_num = thread_num++ % TEST_NUM_OF_THREADS;
Expand All @@ -336,12 +336,10 @@ static void test_thread_job()
end:
delete[] read_block;
delete[] write_block;
#endif
}

void test_multi_threads()
{
#if defined(MBED_CONF_RTOS_PRESENT)
utest_printf("\nTest Multi Threaded Erase/Program/Read Starts..\n");

TEST_SKIP_UNLESS_MESSAGE(block_device != NULL, "no block device found.");
Expand Down Expand Up @@ -395,8 +393,8 @@ void test_multi_threads()

delete[] bd_thread;
}
#endif
}
#endif

void test_erase_functionality()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/
#if !defined(MBED_CONF_RTOS_PRESENT)
#error [NOT_SUPPORTED] Kvstore API test cases requires RTOS to run
#error [NOT_SUPPORTED] Kvstore API test cases require a RTOS to run
#else

#include "rtos/Thread.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/
#if !defined(MBED_CONF_RTOS_PRESENT)
#error [NOT_SUPPORTED] Kvstore API test cases requires RTOS to run
#error [NOT_SUPPORTED] Kvstore API test cases require a RTOS to run
#else

#include "SecureStore.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/
#if !defined(MBED_CONF_RTOS_PRESENT)
#error [NOT_SUPPORTED] Kvstore API test cases requires RTOS to run
#error [NOT_SUPPORTED] Kvstore API test cases require a RTOS to run
#else

#include "SecureStore.h"
Expand Down
5 changes: 3 additions & 2 deletions features/storage/TESTS/kvstore/static_tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ 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;
#else
/* Bare metal does not require memory for threads, so use just minimum for test */
static const int heap_alloc_threshold_size = MBED_CONF_TARGET_BOOT_STACK_SIZE;
#endif
static const char *keys[] = {"key1", "key2", "key3"};

Expand Down Expand Up @@ -69,7 +72,6 @@ static void parse_default_kv()
//init the blockdevice
static void kvstore_init()
{
#if defined(MBED_CONF_RTOS_PRESENT)
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;
Expand All @@ -79,7 +81,6 @@ 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()------------------*/
Expand Down
18 changes: 8 additions & 10 deletions features/storage/nvstore/TESTS/nvstore/functionality/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
* 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
Expand All @@ -31,6 +28,10 @@
#include <stdio.h>
#include <algorithm>

#if !NVSTORE_ENABLED
#error [NOT_SUPPORTED] NVSTORE needs to be enabled for this test
#else

using namespace utest::v1;

static const uint16_t max_test_keys = 20;
Expand Down Expand Up @@ -396,6 +397,7 @@ static void nvstore_basic_functionality_test()
delete[] nvstore_testing_buf_get;
}

#ifdef MBED_CONF_RTOS_PRESENT
static void thread_test_check_key(uint16_t key)
{
uint8_t get_buff[thr_test_max_data_size];
Expand All @@ -422,7 +424,6 @@ static void thread_test_check_key(uint16_t key)

}

#ifdef MBED_CONF_RTOS_PRESENT
static void thread_test_worker()
{
int ret;
Expand All @@ -444,11 +445,9 @@ static void thread_test_worker()
wait_ms(1);
}
}
#endif

static void nvstore_multi_thread_test()
{
#ifdef MBED_CONF_RTOS_PRESENT
int i, result;
uint16_t size;
uint16_t key;
Expand Down Expand Up @@ -562,8 +561,6 @@ static void nvstore_multi_thread_test()
}

nvstore.reset();

#endif
}


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

static void nvstore_race_test()
{
#ifdef MBED_CONF_RTOS_PRESENT
int i;
uint16_t initial_buf_size;
int ret;
Expand Down Expand Up @@ -668,8 +664,8 @@ static void nvstore_race_test()
delete[] buffs[i];
}
delete[] get_buff;
#endif
}
#endif



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

Case cases[] = {
Case("NVStore: Basic functionality", nvstore_basic_functionality_test, greentea_failure_handler),
#if defined(MBED_CONF_RTOS_PRESENT)
Case("NVStore: Race test", nvstore_race_test, greentea_failure_handler),
Case("NVStore: Multiple thread test", nvstore_multi_thread_test, greentea_failure_handler),
#endif
};

utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
Expand Down

0 comments on commit d8e2dd5

Please sign in to comment.