Skip to content

Commit

Permalink
Merge pull request #21127 from maribu/tests/sys/ztimer_mbox_get_timeo…
Browse files Browse the repository at this point in the history
…ut/flaky

tests/sys/ztimer_mbox_get_timeout: Fix flakyness
  • Loading branch information
maribu authored Jan 12, 2025
2 parents 7d0f751 + 71fa44c commit 85a0968
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 85a0968

Please sign in to comment.