From 5751f901850661277d2cbf1e42413c161568ff24 Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Tue, 3 Jan 2023 09:31:58 +0100 Subject: [PATCH] tests: logging: log_msg: Fix test after mpsc_pbuf changes Test started to fail after updated in mpsc_pbuf. It was failing for two reasons: - Expected capacity was not updated after change in mpsc_pbuf which now has full capacity (does not use extra byte for empty vs full distinction). - Messages were claimed without freeing. It was faulty even before the update since mpsc_pbuf is single consumer so only one message can be claimed at a time. However, test was passing before unexpectedly. Signed-off-by: Krzysztof Chruscinski --- tests/subsys/logging/log_msg/src/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/subsys/logging/log_msg/src/main.c b/tests/subsys/logging/log_msg/src/main.c index 6a9b4e59619..b87ae791b46 100644 --- a/tests/subsys/logging/log_msg/src/main.c +++ b/tests/subsys/logging/log_msg/src/main.c @@ -549,7 +549,7 @@ ZTEST(log_msg, test_saturate) uint32_t exp_len = ROUND_UP(offsetof(struct log_msg, data) + 2 * sizeof(void *), Z_LOG_MSG2_ALIGNMENT); - uint32_t exp_capacity = (CONFIG_LOG_BUFFER_SIZE - 1) / exp_len; + uint32_t exp_capacity = CONFIG_LOG_BUFFER_SIZE / exp_len; int mode; union log_msg_generic *msg; @@ -574,9 +574,11 @@ ZTEST(log_msg, test_saturate) msg = z_log_msg_claim(NULL); zassert_equal(log_msg_get_timestamp(&msg->log), i, "Unexpected timestamp used for message id"); + z_log_msg_free(msg); } msg = z_log_msg_claim(NULL); + zassert_equal(msg, NULL, "Expected no pending messages"); }