Skip to content

Commit c111ed3

Browse files
committed
Tests: Drivers: LowPowerTimeout: Update tests
Added unit tests for LowPowerTimeout API.
1 parent 5ce1df7 commit c111ed3

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

TESTS/mbed_drivers/lp_timeout/main.cpp

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
*/
1616

1717
#if !DEVICE_LOWPOWERTIMER
18-
#error [NOT_SUPPORTED] Low power timer not supported for this target
18+
#error [NOT_SUPPORTED] Low power timer not supported for this target
1919
#endif
2020

2121
#include "utest/utest.h"
2222
#include "unity/unity.h"
2323
#include "greentea-client/test_env.h"
2424

2525
#include "mbed.h"
26+
#include "../timeout/timeout_tests.h"
2627

2728
using namespace utest::v1;
2829

@@ -33,7 +34,8 @@ static LowPowerTimeout lpt;
3334
#define LONG_TIMEOUT (100000)
3435
#define SHORT_TIMEOUT (600)
3536

36-
void cb_done() {
37+
void cb_done()
38+
{
3739
complete = true;
3840
}
3941

@@ -119,29 +121,48 @@ void lp_timeout_500us(void)
119121

120122
}
121123

122-
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
124+
utest::v1::status_t greentea_failure_handler(const Case * const source, const failure_t reason)
125+
{
123126
greentea_case_failure_abort_handler(source, reason);
124127
return STATUS_CONTINUE;
125128
}
126129

127130
Case cases[] = {
131+
Case("Callback called once (with attach)", test_single_call<AttachTester<LowPowerTimeout> >),
132+
Case("Callback called once (with attach_us)", test_single_call<AttachUSTester<LowPowerTimeout> >),
133+
134+
Case("Callback not called when cancelled (with attach)", test_cancel<AttachUSTester<LowPowerTimeout> >),
135+
Case("Callback not called when cancelled (with attach_us)", test_cancel<AttachUSTester<LowPowerTimeout> >),
136+
137+
Case("Callback override (with attach)", test_override<AttachTester<LowPowerTimeout> >),
138+
Case("Callback override (with attach_us)", test_override<AttachUSTester<LowPowerTimeout> >),
139+
140+
Case("Multiple timeouts running in parallel (with attach)", test_multiple<AttachTester<LowPowerTimeout> >),
141+
Case("Multiple timeouts running in parallel (with attach_us)", test_multiple<AttachUSTester<LowPowerTimeout> >),
142+
143+
Case("Zero delay (with attach)", test_no_wait<AttachTester<LowPowerTimeout> >),
144+
Case("Zero delay (with attach_us)", test_no_wait<AttachUSTester<LowPowerTimeout> >),
145+
128146
Case("500us LowPowerTimeout", lp_timeout_500us, greentea_failure_handler),
129147
Case("1ms LowPowerTimeout", lp_timeout_1ms, greentea_failure_handler),
130148
Case("1sec LowPowerTimeout", lp_timeout_1s, greentea_failure_handler),
131149
Case("5sec LowPowerTimeout", lp_timeout_5s, greentea_failure_handler),
150+
132151
#if DEVICE_SLEEP
133152
Case("1sec LowPowerTimeout from sleep", lp_timeout_1s_sleep, greentea_failure_handler),
134153
Case("1sec LowPowerTimeout from deepsleep", lp_timeout_1s_deepsleep, greentea_failure_handler),
135154
#endif /* DEVICE_SLEEP */
136155
};
137156

138-
utest::v1::status_t greentea_test_setup(const size_t number_of_cases) {
157+
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
158+
{
139159
GREENTEA_SETUP(20, "default_auto");
140160
return greentea_test_setup_handler(number_of_cases);
141161
}
142162

143163
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
144164

145-
int main() {
165+
int main()
166+
{
146167
Harness::run(specification);
147168
}

0 commit comments

Comments
 (0)