Skip to content

Commit 1e6f919

Browse files
pdgendtfabiobaltieri
authored andcommitted
tests: logging: log_backend_uart: Fix stack overflow
Put the buffer data in a static buffer to reduce the needed stack size. Signed-off-by: Pieter De Gendt <[email protected]>
1 parent 8f07784 commit 1e6f919

File tree

1 file changed

+6
-3
lines changed
  • tests/subsys/logging/log_backend_uart/src

1 file changed

+6
-3
lines changed

tests/subsys/logging/log_backend_uart/src/main.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,22 @@ static void uart_emul_before(void *f)
5555

5656
ZTEST_F(log_backend_uart, test_log_backend_uart_multi_instance)
5757
{
58+
/* Prevent stack overflow by making it static */
59+
static uint8_t tx_content[SAMPLE_DATA_SIZE];
60+
size_t tx_len;
61+
5862
zassert_equal(log_backend_count_get(), EMUL_UART_NUM, "Unexpected number of instance(s)");
5963

6064
LOG_RAW(TEST_DATA);
6165

6266
for (size_t i = 0; i < EMUL_UART_NUM; i++) {
63-
uint8_t tx_content[SAMPLE_DATA_SIZE] = {0};
64-
size_t tx_len;
67+
memset(tx_content, 0, sizeof(tx_content));
6568

6669
tx_len = uart_emul_get_tx_data(fixture->dev[i], tx_content, sizeof(tx_content));
6770
zassert_equal(tx_len, strlen(TEST_DATA),
6871
"%d: TX buffer length does not match. Expected %d, got %d",
6972
i, strlen(TEST_DATA), tx_len);
70-
zassert_mem_equal(tx_content, TEST_DATA, strlen(tx_content));
73+
zassert_mem_equal(tx_content, TEST_DATA, strlen(TEST_DATA));
7174
}
7275
}
7376

0 commit comments

Comments
 (0)