From 71fa44c8147fa7fc618798fb7ab54128ee3893c1 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Fri, 10 Jan 2025 22:12:20 +0100 Subject: [PATCH] tests/sys/ztimer_mbox_get_timeout: Fix flakyness 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. --- tests/sys/ztimer_mbox_get_timeout/main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/sys/ztimer_mbox_get_timeout/main.c b/tests/sys/ztimer_mbox_get_timeout/main.c index 2fa632b96ce1..7edbea79df5e 100644 --- a/tests/sys/ztimer_mbox_get_timeout/main.c +++ b/tests/sys/ztimer_mbox_get_timeout/main.c @@ -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) @@ -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)); }