From 719c4f403603e62bd11bcd562019b23438b727c0 Mon Sep 17 00:00:00 2001 From: Alberto Escolar Piedras Date: Wed, 10 Apr 2024 11:03:03 +0200 Subject: [PATCH] boards: nrf_bsim: bst hooks: Call tests delete only once bst_delete() is called from an ON_EXIT hook, which can be called several times if an exit hook itself fails and calls exit on its own. This is not what most tests destructors will expect, and they may do weird things in this case. So let's not call into it again. Signed-off-by: Alberto Escolar Piedras --- boards/native/nrf_bsim/common/bstests_entry.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/boards/native/nrf_bsim/common/bstests_entry.c b/boards/native/nrf_bsim/common/bstests_entry.c index c1f08deb9cd..da1a3557147 100644 --- a/boards/native/nrf_bsim/common/bstests_entry.c +++ b/boards/native/nrf_bsim/common/bstests_entry.c @@ -224,6 +224,13 @@ void bst_main(void) */ uint8_t bst_delete(void) { + static bool already_deleted; + + if (already_deleted) { + return bst_result; + } + already_deleted = true; + if (current_test && current_test->test_delete_f) { current_test->test_delete_f(); }