Skip to content

Commit 3d74526

Browse files
committed
enable common tickers & lp_tickers hal tests in baremetal mode
1 parent a252b07 commit 3d74526

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

TESTS/mbed_hal/common_tickers/main.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
#if !defined(MBED_CONF_RTOS_PRESENT)
19-
#error [NOT_SUPPORTED] usticker test cases require a RTOS to run
20-
#else
21-
2218
#include "mbed.h"
2319
#include "greentea-client/test_env.h"
2420
#include "unity.h"
@@ -28,13 +24,15 @@
2824
#include "hal/lp_ticker_api.h"
2925
#include "hal/mbed_lp_ticker_wrapper.h"
3026

27+
#ifdef MBED_CONF_RTOS_PRESENT
3128
#ifdef __cplusplus
3229
extern "C" {
3330
#endif
3431
#include "os_tick.h"
3532
#ifdef __cplusplus
3633
}
3734
#endif // __cplusplus
35+
#endif
3836

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

521+
#ifdef MBED_CONF_RTOS_PRESENT
523522
/* OS, common ticker and low power ticker wrapper
524523
* may make use of us ticker so suspend them for this test */
525524
osKernelSuspend();
525+
#endif
526526
#if DEVICE_LPTICKER && (LPTICKER_DELAY_TICKS > 0)
527527
/* Suspend the lp ticker wrapper since it makes use of the us ticker */
528528
ticker_suspend(get_lp_ticker_data());
@@ -552,7 +552,9 @@ utest::v1::status_t us_ticker_teardown(const Case *const source, const size_t pa
552552
lp_ticker_wrapper_resume();
553553
ticker_resume(get_lp_ticker_data());
554554
#endif
555+
#ifdef MBED_CONF_RTOS_PRESENT
555556
osKernelResume(0);
557+
#endif
556558

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

567+
#ifdef MBED_CONF_RTOS_PRESENT
565568
/* OS and common ticker may make use of lp ticker so suspend them for this test */
566569
osKernelSuspend();
570+
#endif
567571
ticker_suspend(get_lp_ticker_data());
568572

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

586590
ticker_resume(get_lp_ticker_data());
591+
#ifdef MBED_CONF_RTOS_PRESENT
587592
osKernelResume(0);
593+
#endif
588594

589595
return greentea_case_teardown_handler(source, passed, failed, reason);
590596
}
@@ -626,4 +632,3 @@ int main()
626632
return !Harness::run(specification);
627633
}
628634
#endif // !DEVICE_USTICKER
629-
#endif // !defined(MBED_CONF_RTOS_PRESENT)

TESTS/mbed_hal/common_tickers_freq/main.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
* freqency is valid.
2121
*/
2222

23-
#if !defined(MBED_CONF_RTOS_PRESENT)
24-
#error [NOT_SUPPORTED] common tickers frequency test cases require a RTOS to run.
25-
#else
26-
2723
#include "mbed.h"
2824
#include "greentea-client/test_env.h"
2925
#include "utest/utest.h"
@@ -187,16 +183,20 @@ Case cases[] = {
187183

188184
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
189185
{
186+
#ifdef MBED_CONF_RTOS_PRESENT
190187
/* Suspend RTOS Kernel so the timers are not in use. */
191188
osKernelSuspend();
189+
#endif
192190

193191
GREENTEA_SETUP(120, "timing_drift_auto");
194192
return greentea_test_setup_handler(number_of_cases);
195193
}
196194

197195
void greentea_test_teardown(const size_t passed, const size_t failed, const failure_t failure)
198196
{
197+
#ifdef MBED_CONF_RTOS_PRESENT
199198
osKernelResume(0);
199+
#endif
200200

201201
greentea_test_teardown_handler(passed, failed, failure);
202202
}
@@ -209,4 +209,3 @@ int main()
209209
}
210210

211211
#endif // defined(SKIP_TIME_DRIFT_TESTS) || !DEVICE_USTICKER
212-
#endif // !defined(MBED_CONF_RTOS_PRESENT)

TESTS/mbed_hal/lp_ticker/main.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
#if !defined(MBED_CONF_RTOS_PRESENT)
19-
#error [NOT_SUPPORTED] Low power timer test cases require a RTOS to run.
20-
#else
21-
2218
#include "mbed.h"
2319
#include "greentea-client/test_env.h"
2420
#include "unity.h"
@@ -167,8 +163,10 @@ void lp_ticker_glitch_test()
167163
#if DEVICE_LPTICKER
168164
utest::v1::status_t lp_ticker_deepsleep_test_setup_handler(const Case *const source, const size_t index_of_case)
169165
{
166+
#ifdef MBED_CONF_RTOS_PRESENT
170167
/* disable everything using the lp ticker for this test */
171168
osKernelSuspend();
169+
#endif
172170
ticker_suspend(get_lp_ticker_data());
173171
#if DEVICE_LPTICKER && (LPTICKER_DELAY_TICKS > 0)
174172
lp_ticker_wrapper_suspend();
@@ -185,7 +183,9 @@ utest::v1::status_t lp_ticker_deepsleep_test_teardown_handler(const Case *const
185183
lp_ticker_wrapper_resume();
186184
#endif
187185
ticker_resume(get_lp_ticker_data());
186+
#ifdef MBED_CONF_RTOS_PRESENT
188187
osKernelResume(0);
188+
#endif
189189
return greentea_case_teardown_handler(source, passed, failed, reason);
190190
}
191191
#endif
@@ -212,4 +212,3 @@ int main()
212212
}
213213

214214
#endif // !DEVICE_LPTICKER
215-
#endif // !defined(MBED_CONF_RTOS_PRESENT)

TESTS/mbed_hal/stack_size_unification/main.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
#if !defined(MBED_CONF_RTOS_PRESENT)
19-
#error [NOT_SUPPORTED] stack size unification test cases require a RTOS to run.
20-
#else
21-
2218
#include "mbed.h"
2319
#include "greentea-client/test_env.h"
2420
#include "unity.h"
@@ -30,12 +26,16 @@
3026

3127
using namespace utest::v1;
3228

29+
#ifdef MBED_CONF_RTOS_PRESENT
3330
extern osThreadAttr_t _main_thread_attr;
31+
#endif
3432
extern uint32_t mbed_stack_isr_size;
3533

3634
/* Exception for Nordic boards - BLE requires 2KB ISR stack. */
3735
#if defined(TARGET_NRF5x)
3836
#define EXPECTED_ISR_STACK_SIZE (2048)
37+
#elif !defined(MBED_CONF_RTOS_PRESENT)
38+
#define EXPECTED_ISR_STACK_SIZE (4096)
3939
#else
4040
#define EXPECTED_ISR_STACK_SIZE (1024)
4141
#endif
@@ -58,8 +58,10 @@ extern uint32_t mbed_stack_isr_size;
5858
void stack_size_unification_test()
5959
{
6060
TEST_ASSERT_EQUAL(EXPECTED_ISR_STACK_SIZE, mbed_stack_isr_size);
61+
#ifdef MBED_CONF_RTOS_PRESENT
6162
TEST_ASSERT_EQUAL(EXPECTED_MAIN_THREAD_STACK_SIZE, _main_thread_attr.stack_size);
6263
TEST_ASSERT_EQUAL(EXPECTED_USER_THREAD_DEFAULT_STACK_SIZE, OS_STACK_SIZE);
64+
#endif
6365
}
6466

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

8284
#endif // TARGET_RENESAS
83-
#endif // !defined(MBED_CONF_RTOS_PRESENT)

0 commit comments

Comments
 (0)