Skip to content

Commit f970de0

Browse files
nordic-krchaescolar
authored andcommitted
tests: drivers: uart: async_api: Fix uart_async_read_abort case
Read abort local variable was not reset. If suite was run more than once on the multiple UARTs it could result in test failure. Additionally, decreased the baudrate for that test to 9600 to prolong the transfer and ensure that RX abort happens before transfer is finised. Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
1 parent d3f409d commit f970de0

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,7 @@ static void *read_abort_setup(void)
625625

626626
uart_async_test_init(idx++);
627627

628+
test_read_abort_rx_cnt = 0;
628629
test_read_abort_rx_buf_req_once = false;
629630
failed_in_isr = false;
630631
uart_callback_set(uart_dev, test_read_abort_callback, NULL);
@@ -644,13 +645,22 @@ ZTEST_USER(uart_async_read_abort, test_read_abort)
644645
__aligned(sizeof(void *)) uint8_t rx_buf[100];
645646
__aligned(sizeof(void *)) uint8_t tx_buf[100];
646647
#endif /* NOCACHE_MEM */
648+
uint32_t baudrate;
647649

648650
memset(rx_buf, 0, sizeof(rx_buf));
649651
memset(tx_buf, 1, sizeof(tx_buf));
650652

651653
err = uart_config_get(uart_dev, &cfg);
652654
zassert_equal(err, 0);
653655

656+
/* Lets reduce the baudrate as we want to abort the transfer before it is
657+
* finished and k_timer precision depends on the system timer frequency
658+
* which might be low.
659+
*/
660+
baudrate = cfg.baudrate;
661+
cfg.baudrate = 9600;
662+
zassert_ok(uart_configure(uart_dev, &cfg));
663+
654664
/* Lets aim to abort after transmitting ~20 bytes (200 bauds) */
655665
t_us = (20 * 10 * 1000000) / cfg.baudrate;
656666

@@ -689,6 +699,8 @@ ZTEST_USER(uart_async_read_abort, test_read_abort)
689699
zassert_not_equal(k_sem_take(&rx_buf_coherency, K_NO_WAIT), 0,
690700
"All provided buffers are released");
691701

702+
cfg.baudrate = baudrate;
703+
zassert_ok(uart_configure(uart_dev, &cfg));
692704
}
693705

694706
static ZTEST_BMEM volatile size_t sent;

0 commit comments

Comments
 (0)