tests: drivers: uart: uart_pm: Minor adjustments in the test
Modifying arbitrary delay to cover for receivers with timeout. Adding a delay between polling and asynchronous checking to cover for cases when CPU processing is fast enough so that both checks may overlap. Allow error code for uart_rx_disable call. Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
a0bb05eb4c
commit
3424c7af7f
1 changed files with 11 additions and 2 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue