Skip to content

Commit

Permalink
tests/thread_apis: Allow 20µs slop in k_busy_wait test
Browse files Browse the repository at this point in the history
When testing k_busy_wait(100), don't require that at least 100µs of CPU
time be consumed by the thread itself; some of that time may be used
elsewhere in the system. Instead, just make sure that at least 80µs is
accounted to the thread and allow 20µs to get used elsewhere.

Signed-off-by: Keith Packard <[email protected]>
  • Loading branch information
keith-packard authored and aescolar committed Dec 5, 2023
1 parent 9f42537 commit d70e8d5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/kernel/threads/thread_apis/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,13 @@ ZTEST(threads_lifecycle, test_k_busy_wait)

/* execution_cycles increases correctly */
dt = test_stats.execution_cycles - cycles;
zassert_true(dt >= k_us_to_cyc_floor64(100));

/* execution cycles may not increase by the full 100µs as the
* system may be doing something else during the busy
* wait. Experimentally, we see at least 80% of the cycles
* consumed in the busy wait loop on current test targets.
*/
zassert_true(dt >= k_us_to_cyc_floor64(80));
}

static void tp_entry(void *p1, void *p2, void *p3)
Expand Down

0 comments on commit d70e8d5

Please sign in to comment.