Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/sys/ztimer_mbox_get_timeout: Fix flakyness #21127

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading