Skip to content

Commit 6999d25

Browse files
author
Cruz Monrreal
authored
Merge pull request #6935 from maciejbocianski/ticker_test_fix
ticker test improvement
2 parents fff3564 + 27bf6cf commit 6999d25

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

TESTS/mbed_drivers/lp_ticker/main.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,14 @@ void test_multi_ticker(void)
8080
}
8181

8282
Thread::wait(MULTI_TICKER_TIME_MS + extra_wait);
83+
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
84+
8385
for (int i = 0; i < TICKER_COUNT; i++) {
8486
ticker[i].detach();
8587
}
88+
// Because detach calls schedule_interrupt in some circumstances
89+
// (e.g. when head event is removed), it's good to check if
90+
// no more callbacks were triggered during detaching.
8691
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
8792

8893
multi_counter = 0;
@@ -91,9 +96,14 @@ void test_multi_ticker(void)
9196
}
9297

9398
Thread::wait(MULTI_TICKER_TIME_MS + TICKER_COUNT + extra_wait);
99+
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
100+
94101
for (int i = 0; i < TICKER_COUNT; i++) {
95102
ticker[i].detach();
96103
}
104+
// Because detach calls schedule_interrupt in some circumstances
105+
// (e.g. when head event is removed), it's good to check if
106+
// no more callbacks were triggered during detaching.
97107
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
98108
}
99109

TESTS/mbed_drivers/ticker/main.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,14 @@ void test_multi_ticker(void)
196196
}
197197

198198
Thread::wait(MULTI_TICKER_TIME_MS + extra_wait);
199+
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
200+
199201
for (int i = 0; i < TICKER_COUNT; i++) {
200202
ticker[i].detach();
201203
}
204+
// Because detach calls schedule_interrupt in some circumstances
205+
// (e.g. when head event is removed), it's good to check if
206+
// no more callbacks were triggered during detaching.
202207
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
203208

204209
multi_counter = 0;
@@ -207,9 +212,14 @@ void test_multi_ticker(void)
207212
}
208213

209214
Thread::wait(MULTI_TICKER_TIME_MS + TICKER_COUNT + extra_wait);
215+
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
216+
210217
for (int i = 0; i < TICKER_COUNT; i++) {
211218
ticker[i].detach();
212219
}
220+
// Because detach calls schedule_interrupt in some circumstances
221+
// (e.g. when head event is removed), it's good to check if
222+
// no more callbacks were triggered during detaching.
213223
TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter);
214224
}
215225

0 commit comments

Comments
 (0)