Skip to content

Commit f532159

Browse files
committed
Timeout tests : unstable result
RTX waits, such as sem.wait(N), delays for between N-1 and N cycles. As lp_ticker is not so accurate as us_ticker, sometines, wait is expiring just before the lp_timeout.
1 parent 1ab05c2 commit f532159

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

TESTS/mbed_drivers/timeout/timeout_tests.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ void test_single_call(void)
8181
int32_t sem_slots = sem.wait(0);
8282
TEST_ASSERT_EQUAL(0, sem_slots);
8383

84-
sem_slots = sem.wait(TEST_DELAY_MS + 1);
84+
sem_slots = sem.wait(TEST_DELAY_MS + 2);
8585
TEST_ASSERT_EQUAL(1, sem_slots);
8686

87-
sem_slots = sem.wait(TEST_DELAY_MS + 1);
87+
sem_slots = sem.wait(TEST_DELAY_MS + 2);
8888
TEST_ASSERT_EQUAL(0, sem_slots);
8989

9090
timeout.detach();
@@ -114,7 +114,7 @@ void test_cancel(void)
114114
TEST_ASSERT_EQUAL(0, sem_slots);
115115
timeout.detach();
116116

117-
sem_slots = sem.wait(TEST_DELAY_MS + 1);
117+
sem_slots = sem.wait(TEST_DELAY_MS + 2);
118118
TEST_ASSERT_EQUAL(0, sem_slots);
119119
}
120120

@@ -147,7 +147,7 @@ void test_override(void)
147147
TEST_ASSERT_EQUAL(0, sem_slots);
148148
timeout.attach_callback(mbed::callback(sem_callback, &sem2), 2.0f * TEST_DELAY_US);
149149

150-
sem_slots = sem2.wait(2 * TEST_DELAY_MS + 1);
150+
sem_slots = sem2.wait(2 * TEST_DELAY_MS + 2);
151151
TEST_ASSERT_EQUAL(1, sem_slots);
152152
sem_slots = sem1.wait(0);
153153
TEST_ASSERT_EQUAL(0, sem_slots);
@@ -177,7 +177,7 @@ void test_multiple(void)
177177
for (size_t i = 0; i < NUM_TIMEOUTS; i++) {
178178
timeouts[i].attach_callback(mbed::callback(cnt_callback, &callback_count), TEST_DELAY_US);
179179
}
180-
Thread::wait(TEST_DELAY_MS + 1);
180+
Thread::wait(TEST_DELAY_MS + 2);
181181
TEST_ASSERT_EQUAL(NUM_TIMEOUTS, callback_count);
182182
}
183183

0 commit comments

Comments
 (0)