Incorporated the review comments

-Added "rtos-api" in TESTS/configs/baremetal.json
-some test case used thread_sleep_for instead Thisthread::sleep_for
-Added the EOF character
-Disable completely the non supported test cases
pull/11721/head
RAJKUMAR KANAGARAJ 2019-11-07 05:41:12 -08:00
parent b1731ce3c8
commit f1139ebd8e
24 changed files with 49 additions and 100 deletions

View File

@ -1,6 +1,7 @@
{
"requires": [
"bare-metal",
"rtos-api",
"greentea-client",
"utest",
"unity",
@ -12,29 +13,29 @@
"littlefs",
"mbed-trace",
"device_key",
"storage_tdb_internal",
"storage_filesystem",
"storage_tdb_external",
"storage_tdb_internal",
"storage_filesystem",
"storage_tdb_external",
"lora",
"nfc",
"network-emac",
"nanostack-libservice",
"flashiap-block-device",
"system-storage",
"filesystemstore",
"SecureStore",
"storage",
"kv-map",
"direct-access-devicekey",
"tdbstore",
"kv-config",
"events",
"kv-global-api",
"sd"
"nfc",
"network-emac",
"nanostack-libservice",
"flashiap-block-device",
"system-storage",
"filesystemstore",
"SecureStore",
"storage",
"kv-map",
"direct-access-devicekey",
"tdbstore",
"kv-config",
"events",
"kv-global-api",
"sd"
],
"target_overrides": {
"*": {
"target.device_has_remove": ["EMAC", "USBDEVICE"]
"target.device_has_remove": ["EMAC", "USBDEVICE"]
}
}
}

View File

@ -86,7 +86,6 @@ void timer_timing_test()
// equeue tick timing test
void tick_timing_test()
{
#if defined(MBED_CONF_RTOS_PRESENT)
unsigned start = equeue_tick();
int prev = 0;
@ -99,13 +98,11 @@ void tick_timing_test()
TEST_ASSERT(next >= prev);
prev = next;
}
#endif
}
// equeue semaphore timing test
void semaphore_timing_test()
{
#if defined(MBED_CONF_RTOS_PRESENT)
srand(0);
timer.reset();
timer.start();
@ -130,7 +127,6 @@ void semaphore_timing_test()
}
equeue_sema_destroy(&sema);
#endif
}

View File

@ -104,4 +104,4 @@ void file_test_read(const char *file, size_t offset, const unsigned char *data,
float(data_length) / 1024, float(data_length) / timer.read() / 1024, timer.read());
}
#endif //#if INTEGRATION_TESTS
#endif //#if INTEGRATION_TESTS

View File

@ -24,4 +24,4 @@
void file_test_write(const char *file, size_t offset, const unsigned char *data, size_t data_length, size_t block_size);
void file_test_read(const char *file, size_t offset, const unsigned char *data, size_t data_length, size_t block_size);
#endif
#endif

View File

@ -134,9 +134,9 @@ void test_thread(void)
TEST_ASSERT_EQUAL(0xCBF43926, crc);
}
#if defined(MBED_CONF_RTOS_PRESENT)
void test_thread_safety()
{
#if defined(MBED_CONF_RTOS_PRESENT)
char test[] = "123456789";
uint32_t crc;
@ -153,15 +153,17 @@ void test_thread_safety()
// Wait for the thread to finish
t1.join();
#endif
}
#endif
Case cases[] = {
Case("Test supported polynomials", test_supported_polynomials),
Case("Test partial CRC", test_partial_crc),
Case("Test SD CRC polynomials", test_sd_crc),
Case("Test not supported polynomials", test_any_polynomial),
Case("Test thread safety", test_thread_safety)
#if defined(MBED_CONF_RTOS_PRESENT)
Case("Test thread safety", test_thread_safety),
#endif
Case("Test not supported polynomials", test_any_polynomial)
};
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)

View File

@ -43,12 +43,12 @@ volatile uint32_t multi_counter;
Timer gtimer;
#if defined(MBED_CONF_RTOS_PRESENT)
void sem_release(Semaphore *sem)
{
sem->release();
}
#endif
void stop_gtimer_set_flag(void)
{
@ -71,7 +71,6 @@ void increment_multi_counter(void)
*/
void test_multi_ticker(void)
{
#if defined(MBED_CONF_RTOS_PRESENT)
LowPowerTicker ticker[TICKER_COUNT];
const uint32_t extra_wait = 10; // extra 10ms wait time
@ -106,7 +105,6 @@ void test_multi_ticker(void)
// (e.g. when head event is removed), it's good to check if
// no more callbacks were triggered during detaching.
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
#endif
}
/** Test multi callback time
@ -142,7 +140,6 @@ void test_multi_call_time(void)
*/
void test_detach(void)
{
#if defined(MBED_CONF_RTOS_PRESENT)
LowPowerTicker ticker;
bool ret;
const float ticker_time_s = 0.1f;
@ -158,7 +155,6 @@ void test_detach(void)
ret = sem.try_acquire_for(wait_time_ms);
TEST_ASSERT_FALSE(ret);
#endif
}
/** Test single callback time via attach

View File

@ -19,9 +19,6 @@
#include "greentea-client/test_env.h"
#include "unity.h"
#include "utest.h"
#if defined(MBED_CONF_RTOS_PRESENT)
#include "rtos.h"
#endif
#include "hal/us_ticker_api.h"
#if !DEVICE_LPTICKER

View File

@ -18,9 +18,6 @@
#include "greentea-client/test_env.h"
#include "unity.h"
#include "utest.h"
#if defined(MBED_CONF_RTOS_PRESENT)
#include "rtos.h"
#endif
#include "rtc_api.h"
#if !DEVICE_RTC || !DEVICE_USTICKER

View File

@ -76,12 +76,11 @@ void ticker_callback_2(void)
}
}
#if defined(MBED_CONF_RTOS_PRESENT)
void sem_release(Semaphore *sem)
{
sem->release();
}
#endif
void stop_gtimer_set_flag(void)
@ -194,7 +193,6 @@ void test_case_2x_ticker()
*/
void test_multi_ticker(void)
{
#if defined(MBED_CONF_RTOS_PRESENT)
Ticker ticker[TICKER_COUNT];
const uint32_t extra_wait = 5; // extra 5ms wait time
@ -229,7 +227,6 @@ void test_multi_ticker(void)
// (e.g. when head event is removed), it's good to check if
// no more callbacks were triggered during detaching.
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
#endif
}
/** Test multi callback time
@ -265,7 +262,6 @@ void test_multi_call_time(void)
*/
void test_detach(void)
{
#if defined(MBED_CONF_RTOS_PRESENT)
Ticker ticker;
bool ret;
const float ticker_time_s = 0.1f;
@ -281,7 +277,6 @@ void test_detach(void)
ret = sem.try_acquire_for(wait_time_ms);
TEST_ASSERT_FALSE(ret);
#endif
}
/** Test single callback time via attach

View File

@ -13,11 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if !defined(MBED_CONF_RTOS_PRESENT)
#error [NOT_SUPPORTED] usticker test requires RTOS to run.
#else
#include "mbed.h"
#include "greentea-client/test_env.h"
#include "utest/utest.h"
@ -94,4 +89,3 @@ int main()
}
#endif // !DEVICE_USTICKER
#endif // !defined(MBED_CONF_RTOS_PRESENT)

View File

@ -15,7 +15,6 @@
*/
#ifndef MBED_TIMEOUT_TESTS_H
#define MBED_TIMEOUT_TESTS_H
#if defined(MBED_CONF_RTOS_PRESENT)
#include "mbed.h"
#include "unity/unity.h"
@ -414,5 +413,4 @@ void test_drift(void)
TEST_ASSERT_EQUAL_STRING_MESSAGE("pass", _key, "Host script reported a failure");
}
#endif // defined(MBED_CONF_RTOS_PRESENT)
#endif

View File

@ -19,9 +19,6 @@
#include "greentea-client/test_env.h"
#include "unity.h"
#include "utest.h"
#if defined(MBED_CONF_RTOS_PRESENT)
#include "rtos.h"
#endif
#include "hal/us_ticker_api.h"
#if !DEVICE_USTICKER

View File

@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if !DEVICE_USTICKER || !defined(MBED_CONF_RTOS_PRESENT)
#error [NOT_SUPPORTED] usticker test case requires RTOS to run and also usticker needs to be enabled for this target.
#if !DEVICE_USTICKER
#error [NOT_SUPPORTED] usticker not supported for this target.
#else
#include "mbed.h"
@ -243,4 +243,4 @@ int main()
return !Harness::run(specification);
}
#endif // !DEVICE_USTICKER || !defined(MBED_CONF_RTOS_PRESENT)
#endif // !DEVICE_USTICKER

View File

@ -120,7 +120,6 @@ void rtc_sleep_test()
/* Test that the RTC keeps counting even after ::rtc_free has been called. */
void rtc_persist_test()
{
#if defined(MBED_CONF_RTOS_PRESENT)
const uint32_t start = 100;
rtc_init();
rtc_write(start);
@ -135,7 +134,6 @@ void rtc_persist_test()
TEST_ASSERT_TRUE(enabled);
TEST_ASSERT_UINT32_WITHIN(WAIT_TOLERANCE, WAIT_TIME, stop - start);
#endif
}
/* Test time does not glitch backwards due to an incorrectly implemented ripple counter driver. */
@ -158,7 +156,6 @@ void rtc_glitch_test()
/* Test that the RTC correctly handles different time values. */
void rtc_range_test()
{
#if defined(MBED_CONF_RTOS_PRESENT)
static const uint32_t starts[] = {
0x00000000,
0xEFFFFFFF,
@ -175,7 +172,6 @@ void rtc_range_test()
TEST_ASSERT_UINT32_WITHIN(WAIT_TOLERANCE, WAIT_TIME, stop - start);
}
rtc_free();
#endif
}
/* Test that the RTC accuracy is at least 10%. */

View File

@ -35,10 +35,9 @@ void sleep_manager_locking_thread_test()
sleep_manager_unlock_deep_sleep();
}
}
#endif
void sleep_manager_multithread_test()
{
#if defined(MBED_CONF_RTOS_PRESENT)
{
Callback<void()> cb(sleep_manager_locking_thread_test);
Thread t1(osPriorityNormal, TEST_STACK_SIZE);
@ -55,8 +54,8 @@ void sleep_manager_multithread_test()
bool deep_sleep_allowed = sleep_manager_can_deep_sleep_test_check();
TEST_ASSERT_TRUE_MESSAGE(deep_sleep_allowed, "Deep sleep should be allowed");
#endif
}
#endif
void sleep_manager_locking_irq_test()
{
@ -93,7 +92,9 @@ utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
}
Case cases[] = {
#if defined(MBED_CONF_RTOS_PRESENT)
Case("deep sleep lock/unlock is thread safe", sleep_manager_multithread_test),
#endif
Case("deep sleep lock/unlock is IRQ safe", sleep_manager_irq_test),
};

View File

@ -118,7 +118,6 @@ void test_error_capturing()
*/
void test_error_context_capture()
{
#if defined(MBED_CONF_RTOS_PRESENT)
uint32_t error_value = 0xABCD;
mbed_error_ctx error_ctx = {0};
@ -126,6 +125,7 @@ void test_error_context_capture()
mbed_error_status_t status = mbed_get_last_error_info(&error_ctx);
TEST_ASSERT(status == MBED_SUCCESS);
TEST_ASSERT_EQUAL_UINT(error_value, error_ctx.error_value);
#if defined(MBED_CONF_RTOS_PRESENT)
TEST_ASSERT_EQUAL_UINT((uint32_t)osThreadGetId(), error_ctx.thread_id);
//Capture thread info and compare
@ -258,9 +258,9 @@ void MyErrorHook(const mbed_error_ctx *error_ctx)
/** Test error hook
*/
#if defined(MBED_CONF_RTOS_PRESENT)
void test_error_hook()
{
#if defined(MBED_CONF_RTOS_PRESENT)
if (MBED_SUCCESS != mbed_set_error_hook(MyErrorHook)) {
TEST_FAIL();
}
@ -269,8 +269,8 @@ void test_error_hook()
bool acquired = callback_sem.try_acquire_for(5000);
TEST_ASSERT(acquired);
#endif
}
#endif
#if MBED_CONF_PLATFORM_ERROR_HIST_ENABLED && defined(MBED_TEST_SIM_BLOCKDEVICE)
@ -358,13 +358,11 @@ utest::v1::status_t test_setup(const size_t number_of_cases)
Case cases[] = {
Case("Test error counting and reset", test_error_count_and_reset),
Case("Test error encoding, value capture, first and last errors", test_error_capturing),
#if MBED_CONF_RTOS_PRESENT
Case("Test error context capture", test_error_context_capture),
#endif //MBED_CONF_RTOS_PRESENT
Case("Test error hook", test_error_hook),
#if MBED_CONF_PLATFORM_ERROR_HIST_ENABLED
Case("Test error logging", test_error_logging),
#if MBED_CONF_RTOS_PRESENT
Case("Test error hook", test_error_hook),
Case("Test error handling multi-threaded", test_error_logging_multithread),
#endif //MBED_CONF_RTOS_PRESENT
#if MBED_CONF_PLATFORM_ERROR_HIST_ENABLED && defined(MBED_TEST_SIM_BLOCKDEVICE)

View File

@ -27,7 +27,6 @@ using utest::v1::Case;
extern uint32_t mbed_heap_size;
static const int test_timeout = 25;
#if defined(MBED_CONF_RTOS_PRESENT)
volatile bool thread_should_continue = true;
#define NUM_THREADS 4
#define THREAD_MALLOC_SIZE 100
@ -60,16 +59,15 @@ void task_using_malloc(void)
free(data);
}
}
#endif
/** Test for multithreaded heap allocations
Given multiple threads are started in parallel
When each of the threads allocate memory
Then the memory allocation succeed and @a malloc return valid memory
*/
#if defined(MBED_CONF_RTOS_PRESENT)
void test_multithread_allocation(void)
{
#if defined(MBED_CONF_RTOS_PRESENT)
// static stack for threads to reduce heap usage on devices with small RAM
// and eliminate run out of heap memory problem
uint8_t stack[NUM_THREADS][THREAD_STACK_SIZE];
@ -103,8 +101,8 @@ void test_multithread_allocation(void)
}
}
TEST_ASSERT_FALSE(thread_alloc_failure);
#endif
}
#endif
/** Test for multiple heap alloc and free calls */
#define ALLOC_ARRAY_SIZE 100
@ -203,7 +201,9 @@ void test_null_free(void)
Case cases[] = {
Case("Test 0 size allocation", test_zero_allocation),
Case("Test NULL pointer free", test_null_free),
#if defined(MBED_CONF_RTOS_PRESENT)
Case("Test multithreaded allocations", test_multithread_allocation),
#endif
Case("Test large allocation", test_big_allocation),
Case("Test multiple alloc and free calls", test_alloc_and_free)
};
@ -221,4 +221,4 @@ int main()
return !utest::v1::Harness::run(specification);
}
#endif // defined(MBED_RTOS_SINGLE_THREAD) || !DEVICE_USTICKER || !defined(MBED_CONF_RTOS_PRESENT)
#endif // defined(MBED_RTOS_SINGLE_THREAD) || !DEVICE_USTICKER

View File

@ -17,7 +17,6 @@
#ifndef MBEDMICRO_RTOS_MBED_THREADS_LOCK_GUARD
#define MBEDMICRO_RTOS_MBED_THREADS_LOCK_GUARD
#if defined(MBED_CONF_RTOS_PRESENT)
#include <rtos.h>
@ -50,5 +49,4 @@ private:
LockGuard &operator=(const LockGuard &);
rtos::Mutex &_mutex;
};
#endif /* #if defined(MBED_CONF_RTOS_PRESENT) */
#endif /* MBEDMICRO_RTOS_MBED_THREADS_LOCK_GUARD */

View File

@ -17,7 +17,6 @@
#ifndef MBEDMICRO_RTOS_MBED_THREADS_SYNCHRONIZED_INTEGRAL
#define MBEDMICRO_RTOS_MBED_THREADS_SYNCHRONIZED_INTEGRAL
#if defined(MBED_CONF_RTOS_PRESENT)
#include <rtos.h>
#include "LockGuard.h"
@ -76,5 +75,4 @@ private:
mutable rtos::Mutex _mutex;
T _value;
};
#endif /* #if defined(MBED_CONF_RTOS_PRESENT) */
#endif /* MBEDMICRO_RTOS_MBED_THREADS_SYNCHRONIZED_INTEGRAL */

View File

@ -171,11 +171,7 @@ USBEndpointTester::USBEndpointTester(USBPhy *phy, uint16_t vendor_id, uint16_t p
MBED_ASSERT(_endpoint_buffs[i] != NULL);
}
MBED_ASSERT(resolver.valid());
#if defined(MBED_CONF_RTOS_PRESENT)
queue = mbed::mbed_highprio_event_queue();
#else
queue = mbed::mbed_event_queue();
#endif
configuration_desc(0);
ctrl_buf = new uint8_t[CTRL_BUF_SIZE];
init();
@ -866,4 +862,4 @@ void USBEndpointTester::start_ep_in_abort_test()
write_start(_endpoints[EP_BULK_IN], _endpoint_buffs[EP_BULK_IN], (*_endpoint_configs)[EP_BULK_IN].max_packet);
write_start(_endpoints[EP_INT_IN], _endpoint_buffs[EP_INT_IN], (*_endpoint_configs)[EP_INT_IN].max_packet);
}
#endif
#endif

View File

@ -17,7 +17,6 @@
#ifndef USB_ENDPOINT_TESTER_H
#define USB_ENDPOINT_TESTER_H
#if defined(MBED_CONF_RTOS_PRESENT)
/* These headers are included for child class. */
#include "USBDescriptor.h"
@ -134,4 +133,3 @@ private:
};
#endif
#endif

View File

@ -58,11 +58,7 @@ USBTester::USBTester(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint1
int_in = resolver.endpoint_in(USB_EP_TYPE_INT, 64);
int_out = resolver.endpoint_out(USB_EP_TYPE_INT, 64);
MBED_ASSERT(resolver.valid());
#if defined(MBED_CONF_RTOS_PRESENT)
queue = mbed::mbed_highprio_event_queue();
#else
queue = mbed::mbed_event_queue();
#endif
configuration_desc(0);
ctrl_buf = new uint8_t[CTRL_BUF_SIZE];
init();
@ -708,4 +704,4 @@ void USBTester::epbulk_out_callback()
read_finish(bulk_out);
read_start(bulk_out, bulk_buf, sizeof(bulk_buf));
}
#endif
#endif

View File

@ -17,7 +17,6 @@
#ifndef USB_TESTER_H
#define USB_TESTER_H
#if defined(MBED_CONF_RTOS_PRESENT)
/* These headers are included for child class. */
#include "USBDescriptor.h"
@ -145,4 +144,3 @@ protected:
};
#endif
#endif

View File

@ -17,8 +17,6 @@
#ifndef Test_USBMSD_H
#define Test_USBMSD_H
#if defined(MBED_CONF_RTOS_PRESENT)
#include "USBMSD.h"
@ -133,4 +131,3 @@ volatile uint32_t TestUSBMSD::program_counter = 0;
volatile uint32_t TestUSBMSD::erase_counter = 0;
#endif // Test_USBMSD_H
#endif