Skip to content

enable common tickers & lp_tickers hal tests in baremetal mode #12827

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

Merged
merged 1 commit into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions TESTS/mbed_hal/common_tickers/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
* limitations under the License.
*/

#if !defined(MBED_CONF_RTOS_PRESENT)
#error [NOT_SUPPORTED] usticker test cases require a RTOS to run
#else

#include "mbed.h"
#include "greentea-client/test_env.h"
#include "unity.h"
Expand All @@ -28,13 +24,15 @@
#include "hal/lp_ticker_api.h"
#include "hal/mbed_lp_ticker_wrapper.h"

#ifdef MBED_CONF_RTOS_PRESENT
#ifdef __cplusplus
extern "C" {
#endif
#include "os_tick.h"
#ifdef __cplusplus
}
#endif // __cplusplus
#endif

#if !DEVICE_USTICKER
#error [NOT_SUPPORTED] test not supported
Expand Down Expand Up @@ -520,9 +518,11 @@ utest::v1::status_t us_ticker_setup(const Case *const source, const size_t index
{
intf = get_us_ticker_data()->interface;

#ifdef MBED_CONF_RTOS_PRESENT
/* OS, common ticker and low power ticker wrapper
* may make use of us ticker so suspend them for this test */
osKernelSuspend();
#endif
#if DEVICE_LPTICKER && (LPTICKER_DELAY_TICKS > 0)
/* Suspend the lp ticker wrapper since it makes use of the us ticker */
ticker_suspend(get_lp_ticker_data());
Expand Down Expand Up @@ -552,7 +552,9 @@ utest::v1::status_t us_ticker_teardown(const Case *const source, const size_t pa
lp_ticker_wrapper_resume();
ticker_resume(get_lp_ticker_data());
#endif
#ifdef MBED_CONF_RTOS_PRESENT
osKernelResume(0);
#endif

return greentea_case_teardown_handler(source, passed, failed, reason);
}
Expand All @@ -562,8 +564,10 @@ utest::v1::status_t lp_ticker_setup(const Case *const source, const size_t index
{
intf = get_lp_ticker_data()->interface;

#ifdef MBED_CONF_RTOS_PRESENT
/* OS and common ticker may make use of lp ticker so suspend them for this test */
osKernelSuspend();
#endif
ticker_suspend(get_lp_ticker_data());

intf->init();
Expand All @@ -584,7 +588,9 @@ utest::v1::status_t lp_ticker_teardown(const Case *const source, const size_t pa
prev_irq_handler = NULL;

ticker_resume(get_lp_ticker_data());
#ifdef MBED_CONF_RTOS_PRESENT
osKernelResume(0);
#endif

return greentea_case_teardown_handler(source, passed, failed, reason);
}
Expand Down Expand Up @@ -626,4 +632,3 @@ int main()
return !Harness::run(specification);
}
#endif // !DEVICE_USTICKER
#endif // !defined(MBED_CONF_RTOS_PRESENT)
9 changes: 4 additions & 5 deletions TESTS/mbed_hal/common_tickers_freq/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
* freqency is valid.
*/

#if !defined(MBED_CONF_RTOS_PRESENT)
#error [NOT_SUPPORTED] common tickers frequency test cases require a RTOS to run.
#else

#include "mbed.h"
#include "greentea-client/test_env.h"
#include "utest/utest.h"
Expand Down Expand Up @@ -187,16 +183,20 @@ Case cases[] = {

utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
{
#ifdef MBED_CONF_RTOS_PRESENT
/* Suspend RTOS Kernel so the timers are not in use. */
osKernelSuspend();
#endif

GREENTEA_SETUP(120, "timing_drift_auto");
return greentea_test_setup_handler(number_of_cases);
}

void greentea_test_teardown(const size_t passed, const size_t failed, const failure_t failure)
{
#ifdef MBED_CONF_RTOS_PRESENT
osKernelResume(0);
#endif

greentea_test_teardown_handler(passed, failed, failure);
}
Expand All @@ -209,4 +209,3 @@ int main()
}

#endif // defined(SKIP_TIME_DRIFT_TESTS) || !DEVICE_USTICKER
#endif // !defined(MBED_CONF_RTOS_PRESENT)
9 changes: 4 additions & 5 deletions TESTS/mbed_hal/lp_ticker/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
* limitations under the License.
*/

#if !defined(MBED_CONF_RTOS_PRESENT)
#error [NOT_SUPPORTED] Low power timer test cases require a RTOS to run.
#else

#include "mbed.h"
#include "greentea-client/test_env.h"
#include "unity.h"
Expand Down Expand Up @@ -167,8 +163,10 @@ void lp_ticker_glitch_test()
#if DEVICE_LPTICKER
utest::v1::status_t lp_ticker_deepsleep_test_setup_handler(const Case *const source, const size_t index_of_case)
{
#ifdef MBED_CONF_RTOS_PRESENT
/* disable everything using the lp ticker for this test */
osKernelSuspend();
#endif
ticker_suspend(get_lp_ticker_data());
#if DEVICE_LPTICKER && (LPTICKER_DELAY_TICKS > 0)
lp_ticker_wrapper_suspend();
Expand All @@ -185,7 +183,9 @@ utest::v1::status_t lp_ticker_deepsleep_test_teardown_handler(const Case *const
lp_ticker_wrapper_resume();
#endif
ticker_resume(get_lp_ticker_data());
#ifdef MBED_CONF_RTOS_PRESENT
osKernelResume(0);
#endif
return greentea_case_teardown_handler(source, passed, failed, reason);
}
#endif
Expand All @@ -212,4 +212,3 @@ int main()
}

#endif // !DEVICE_LPTICKER
#endif // !defined(MBED_CONF_RTOS_PRESENT)
11 changes: 6 additions & 5 deletions TESTS/mbed_hal/stack_size_unification/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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] stack size unification test cases require a RTOS to run.
#else

#include "mbed.h"
#include "greentea-client/test_env.h"
#include "unity.h"
Expand All @@ -30,12 +26,16 @@

using namespace utest::v1;

#ifdef MBED_CONF_RTOS_PRESENT
extern osThreadAttr_t _main_thread_attr;
#endif
extern uint32_t mbed_stack_isr_size;

/* Exception for Nordic boards - BLE requires 2KB ISR stack. */
#if defined(TARGET_NRF5x)
#define EXPECTED_ISR_STACK_SIZE (2048)
#elif !defined(MBED_CONF_RTOS_PRESENT)
#define EXPECTED_ISR_STACK_SIZE (4096)
#else
#define EXPECTED_ISR_STACK_SIZE (1024)
#endif
Expand All @@ -58,8 +58,10 @@ extern uint32_t mbed_stack_isr_size;
void stack_size_unification_test()
{
TEST_ASSERT_EQUAL(EXPECTED_ISR_STACK_SIZE, mbed_stack_isr_size);
#ifdef MBED_CONF_RTOS_PRESENT
TEST_ASSERT_EQUAL(EXPECTED_MAIN_THREAD_STACK_SIZE, _main_thread_attr.stack_size);
TEST_ASSERT_EQUAL(EXPECTED_USER_THREAD_DEFAULT_STACK_SIZE, OS_STACK_SIZE);
#endif
}

utest::v1::status_t test_setup(const size_t number_of_cases)
Expand All @@ -80,4 +82,3 @@ int main()
}

#endif // TARGET_RENESAS
#endif // !defined(MBED_CONF_RTOS_PRESENT)