Skip to content

Commit

Permalink
bench(periodic_tasks): assert both task count bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
hegza committed Feb 21, 2025
1 parent ec68a42 commit 3c084a7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions examples/periodic_tasks/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,16 @@ fn main() -> ! {
(TASK2_COUNT, TASK2),
(TASK3_COUNT, TASK3),
] {
// allow off-by-one
// Assert task count is at least the expected count. There may be one less as the
// final in-flight task might get interrupted by the test end.
ma::assert_ge!(
*count,
(TEST_DURATION.to_nanos() as usize / task.period_ns as usize) - 1
)
);
ma::assert_le!(
*count,
(TEST_DURATION.to_nanos() as usize / task.period_ns as usize)
);
}

// Make sure serial is done printing before proceeding to the next iteration
Expand Down

0 comments on commit 3c084a7

Please sign in to comment.