Skip to content

Commit

Permalink
tests/sys/ztimer_mbox_get_timeout: Fix flakyness
Browse files Browse the repository at this point in the history
On `native` when build with LLVM, time seems to not monotonically
increase, causing a test to be flaky.

This disables the part that is flaky on native on native.
  • Loading branch information
maribu committed Jan 10, 2025
1 parent 7d0f751 commit 71fa44c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/sys/ztimer_mbox_get_timeout/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static mbox_t mbox = MBOX_INIT(queue, ARRAY_SIZE(queue));

static void cb_mbox_put(void *arg)
{
mbox_try_put(&mbox, arg);
expect(mbox_try_put(&mbox, arg) == 1);
}

static void test_mbox_already_full(void)
Expand Down Expand Up @@ -91,11 +91,15 @@ static void test_msg_prior_timeout(void)
expect(ztimer_mbox_get_timeout(ZTIMER_USEC, &mbox, &got, wait_timeout_us) == 0);
uint32_t stop = ztimer_now(ZTIMER_USEC);

/* the function should return AFTER the message was send, but BEFORE the
* timeout was triggered */
expect(stop - start >= msg_timeout_us);
/* the function should return BEFORE the timeout was triggered */
expect(stop - start < wait_timeout_us);

#if !defined(BOARD_NATIVE64) && !defined(BOARD_NATIVE)
/* The function should return AFTER the message was send.
* This test is flaky on native, at least with LLVM. */
expect(stop - start >= msg_timeout_us);
#endif

/* we should have gotten the correct message */
expect((got.type == msg.type) && (got.content.value == msg.content.value));
}
Expand Down

0 comments on commit 71fa44c

Please sign in to comment.