diff --git a/tests/drivers/uart/uart_pm/src/main.c b/tests/drivers/uart/uart_pm/src/main.c index 6b640853b90..07e75ec8dd6 100644 --- a/tests/drivers/uart/uart_pm/src/main.c +++ b/tests/drivers/uart/uart_pm/src/main.c @@ -34,7 +34,10 @@ static void polling_verify(const struct device *dev, bool is_async, bool active) for (int i = 0; i < ARRAY_SIZE(outs); i++) { uart_poll_out(dev, outs[i]); - k_busy_wait(1000); + /* We need to wait until receiver gets the data. Receiver may have + * RX timeout so data is not received instantly. + */ + k_busy_wait(5000); if (active) { err = uart_poll_in(dev, &c); @@ -78,6 +81,12 @@ static bool async_verify(const struct device *dev, bool active) zassert_equal(err, 0, "Unexpected err: %d", err); + /* Wait a bit to ensure that polling transfer is already finished otherwise + * receiver might be enabled when there is an ongoing transfer and bytes + * will get corrupted. + */ + k_busy_wait(1000); + if (!DISABLED_RX) { err = uart_rx_enable(dev, rxbuf, sizeof(rxbuf), 1 * USEC_PER_MSEC); zassert_equal(err, 0, "Unexpected err: %d", err); @@ -90,7 +99,7 @@ static bool async_verify(const struct device *dev, bool active) if (!DISABLED_RX) { err = uart_rx_disable(dev); - zassert_equal(err, 0, "Unexpected err: %d", err); + zassert_true((err == 0) || (err == -EFAULT)); k_busy_wait(10000);