From ca1cf5884bc38e682953de560efbb38dafd5ee84 Mon Sep 17 00:00:00 2001 From: sexenteen <130895816+sexenteen@users.noreply.github.com> Date: Sun, 1 Nov 2026 17:35:53 +0800 Subject: [PATCH] fix[utest]: reset finish flags in the mailbox testcase so it can run twice --- src/utest/mailbox_tc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/utest/mailbox_tc.c b/src/utest/mailbox_tc.c index 9c4a30af8ed0..1122085b4fb5 100644 --- a/src/utest/mailbox_tc.c +++ b/src/utest/mailbox_tc.c @@ -391,6 +391,17 @@ static void test_dynamic_mailbox_send_recv(void) static rt_err_t utest_tc_init(void) { + /* This testcase may be run more than once in a single boot. The finish + * flags are set by the worker threads and read by the test body, so they + * must be cleared before every run. Otherwise the second run would skip + * the wait loop, detach/delete the mailbox while the worker threads are + * still blocked in rt_mb_recv(), and those threads would then use an + * already detached mailbox. */ + static_mb_recv_thread_finish = 0; + static_mb_send_thread_finish = 0; + dynamic_mb_recv_thread_finish = 0; + dynamic_mb_send_thread_finish = 0; + return RT_EOK; }