File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,16 @@ using namespace utest::v1;
3434// (for more details about EVENTS_EVENT_SIZE see EventQueue constructor)
3535#define TEST_EQUEUE_SIZE (18 *EVENTS_EVENT_SIZE)
3636
37+ // By empirical, we take 80MHz CPU/2ms delay as base tolerance for time left test.
38+ // For higher CPU frequency, tolerance is fixed to 2ms.
39+ // For lower CPU frequency, tolerance is inversely proportional to CPU frequency.
40+ // E.g.:
41+ // 100MHz: 2ms
42+ // 80MHz: 2ms
43+ // 64MHz: 3ms
44+ // 48MHz: 4ms
45+ #define ALLOWED_TIME_LEFT_TOLERANCE_MS ((SystemCoreClock >= 80000000 ) ? 2 : ((80000000 * 2 + SystemCoreClock - 1 ) / SystemCoreClock))
46+
3747// flag for called
3848volatile bool touched = false ;
3949
@@ -283,7 +293,7 @@ int timeleft_events[2];
283293void check_time_left (EventQueue *queue, int index, int expected)
284294{
285295 const int event_id = timeleft_events[index];
286- TEST_ASSERT_INT_WITHIN (2 , expected, queue->time_left (event_id));
296+ TEST_ASSERT_INT_WITHIN (ALLOWED_TIME_LEFT_TOLERANCE_MS , expected, queue->time_left (event_id));
287297 touched = true ;
288298}
289299
You can’t perform that action at this time.
0 commit comments