Skip to content

Commit d7b553e

Browse files
nordic-krchnordicjm
authored andcommitted
[nrf fromtree] tests: drivers: uart: async_api: Align test to gcov
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 <[email protected]> (cherry picked from commit 8d13b6b)
1 parent c7e570d commit d7b553e

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

tests/drivers/uart/uart_async_api/src/test_uart_async.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,23 @@ static void uart_async_test_init(int idx)
8282
k_sem_reset(&rx_buf_released);
8383
k_sem_reset(&rx_disabled);
8484

85-
#ifdef CONFIG_UART_WIDE_DATA
86-
const struct uart_config uart_cfg = {
87-
.baudrate = 115200,
88-
.parity = UART_CFG_PARITY_NONE,
89-
.stop_bits = UART_CFG_STOP_BITS_1,
90-
.data_bits = UART_CFG_DATA_BITS_9,
91-
.flow_ctrl = UART_CFG_FLOW_CTRL_NONE
85+
struct uart_config uart_cfg;
86+
87+
zassert_equal(uart_config_get(uart_dev, &uart_cfg), 0);
88+
89+
if (IS_ENABLED(CONFIG_COVERAGE)) {
90+
/* When coverage is used then performance is degraded - avoid using
91+
* higher baudrates.
92+
*/
93+
uart_cfg.baudrate = MIN(uart_cfg.baudrate, 115200);
94+
} else if (IS_ENABLED(CONFIG_UART_WIDE_DATA)) {
95+
uart_cfg.baudrate = 115200;
96+
uart_cfg.parity = UART_CFG_PARITY_NONE;
97+
uart_cfg.stop_bits = UART_CFG_STOP_BITS_1;
98+
uart_cfg.data_bits = UART_CFG_DATA_BITS_9;
99+
uart_cfg.flow_ctrl = UART_CFG_FLOW_CTRL_NONE;
92100
};
93-
__ASSERT_NO_MSG(uart_configure(uart_dev, &uart_cfg) == 0);
94-
#endif
101+
zassert_equal(uart_configure(uart_dev, &uart_cfg), 0);
95102

96103
if (!initialized) {
97104
initialized = true;

0 commit comments

Comments
 (0)