From 5d65ee1383b2cfce44c6156acde7af13dd369d08 Mon Sep 17 00:00:00 2001 From: Derek Hageman Date: Mon, 13 May 2019 16:13:22 -0600 Subject: [PATCH] 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 --- tests/drivers/uart/uart_async_api/src/test_uart_async.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/drivers/uart/uart_async_api/src/test_uart_async.c b/tests/drivers/uart/uart_async_api/src/test_uart_async.c index d1cd4363462..afe59a03a32 100644 --- a/tests/drivers/uart/uart_async_api/src/test_uart_async.c +++ b/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) break; case UART_RX_RDY: read_ptr = evt->data.rx.buf + evt->data.rx.offset; + read_len = evt->data.rx.len; k_sem_give(&rx_rdy); break; case UART_RX_BUF_REQUEST: @@ -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)), 0, "Buffers not equal");