From 8d13b6b65b9e4e0d4ebe376bb2c15f21c253b262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Chru=C5=9Bci=C5=84ski?= Date: Thu, 20 Mar 2025 09:28:25 +0100 Subject: [PATCH] tests: drivers: uart: async_api: Align test to gcov MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When CONFIG_COVERAGE is enabled then performance is degraded. In that case higher baudrates shall be avoided because CPU may not have enough time to handle UART interrupts. Limit baudrate to 115200 when CONFIG_COVERAGE=y. Signed-off-by: Krzysztof Chruściński --- .../uart/uart_async_api/src/test_uart_async.c | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/drivers/uart/uart_async_api/src/test_uart_async.c b/tests/drivers/uart/uart_async_api/src/test_uart_async.c index b3abe990009..d0b1ac779c6 100644 --- a/tests/drivers/uart/uart_async_api/src/test_uart_async.c +++ b/tests/drivers/uart/uart_async_api/src/test_uart_async.c @@ -82,16 +82,23 @@ static void uart_async_test_init(int idx) k_sem_reset(&rx_buf_released); k_sem_reset(&rx_disabled); -#ifdef CONFIG_UART_WIDE_DATA - const struct uart_config uart_cfg = { - .baudrate = 115200, - .parity = UART_CFG_PARITY_NONE, - .stop_bits = UART_CFG_STOP_BITS_1, - .data_bits = UART_CFG_DATA_BITS_9, - .flow_ctrl = UART_CFG_FLOW_CTRL_NONE + struct uart_config uart_cfg; + + zassert_equal(uart_config_get(uart_dev, &uart_cfg), 0); + + if (IS_ENABLED(CONFIG_COVERAGE)) { + /* When coverage is used then performance is degraded - avoid using + * higher baudrates. + */ + uart_cfg.baudrate = MIN(uart_cfg.baudrate, 115200); + } else if (IS_ENABLED(CONFIG_UART_WIDE_DATA)) { + uart_cfg.baudrate = 115200; + uart_cfg.parity = UART_CFG_PARITY_NONE; + uart_cfg.stop_bits = UART_CFG_STOP_BITS_1; + uart_cfg.data_bits = UART_CFG_DATA_BITS_9; + uart_cfg.flow_ctrl = UART_CFG_FLOW_CTRL_NONE; }; - __ASSERT_NO_MSG(uart_configure(uart_dev, &uart_cfg) == 0); -#endif + zassert_equal(uart_configure(uart_dev, &uart_cfg), 0); if (!initialized) { initialized = true;