Skip to content
Browse files

tests: drivers: uart: Explicitly test incremental receive length

Add an explict test for the length of the receive event when
doing incremental receives.  This was not tested anywhere in the
normal code path (only implicitly in the abort, which wasn't
exercised on the only current implementation, nrfx).  So add an
explicit check for it during the chained reads, so that the
test can catch the case where multiple receive events do not set
the length correctly on events past the first.

Tested on nrf52840_pca10056.

Signed-off-by: Derek Hageman <>
  • Loading branch information...
Sizurka authored and nashif committed May 13, 2019
1 parent 02d6ea0 commit 5d65ee1383b2cfce44c6156acde7af13dd369d08
Showing with 4 additions and 0 deletions.
  1. +4 −0 tests/drivers/uart/uart_async_api/src/test_uart_async.c
@@ -77,6 +77,7 @@ u8_t chained_read_buf1[20];
u8_t chained_read_buf2[30];
u8_t buf_num = 1U;
u8_t *read_ptr;
volatile size_t read_len;

void test_chained_read_callback(struct uart_event *evt, void *user_data)
@@ -88,6 +89,7 @@ void test_chained_read_callback(struct uart_event *evt, void *user_data)
read_ptr = evt->data.rx.buf + evt->data.rx.offset;
read_len = evt->data.rx.len;
@@ -130,6 +132,8 @@ void test_chained_read(void)
uart_tx(uart_dev, tx_buf, sizeof(tx_buf), 100);
zassert_equal(k_sem_take(&tx_done, 100), 0, "TX_DONE timeout");
zassert_equal(k_sem_take(&rx_rdy, 1000), 0, "RX_RDY timeout");
zassert_equal(read_len, sizeof(tx_buf),
"Incorrect read length");
zassert_equal(memcmp(tx_buf, read_ptr, sizeof(tx_buf)),
"Buffers not equal");

0 comments on commit 5d65ee1

Please sign in to comment.
You can’t perform that action at this time.