Skip to content

Commit

Permalink
tests: uart_async_api: update test for dma usage
Browse files Browse the repository at this point in the history
1. ensure the two dma buffers all aligned with 32 bits
2. clean the rx_data_idx at test begin

Signed-off-by: Hake Huang <[email protected]>
  • Loading branch information
hakehuang committed Oct 2, 2024
1 parent e5cba7d commit 7152b13
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions tests/drivers/uart/uart_async_api/src/test_uart_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,17 +324,21 @@ ZTEST_USER(uart_async_multi_rx, test_multiple_rx_enable)
}

#if NOCACHE_MEM
static __aligned(32) uint8_t chained_read_buf[2][8] __used __NOCACHE;
static __aligned(32) uint8_t chained_read_buf_0[8] __used __NOCACHE;
static __aligned(32) uint8_t chained_read_buf_1[8] __used __NOCACHE;
static __aligned(32) uint8_t chained_cpy_buf[10] __used __NOCACHE;
#else
ZTEST_BMEM uint8_t chained_read_buf[2][8];
ZTEST_BMEM uint8_t chained_read_buf_0[8];
ZTEST_BMEM uint8_t chained_read_buf_1[8];
ZTEST_BMEM uint8_t chained_cpy_buf[10];
#endif /* NOCACHE_MEM */
ZTEST_BMEM volatile uint8_t rx_data_idx;
ZTEST_BMEM uint8_t rx_buf_idx;

ZTEST_BMEM uint8_t *read_ptr;

static uint8_t *chained_read_buf[2] = {chained_read_buf_0, chained_read_buf_1};

static void test_chained_read_callback(const struct device *dev,
struct uart_event *evt, void *user_data)
{
Expand All @@ -352,9 +356,8 @@ static void test_chained_read_callback(const struct device *dev,
rx_data_idx += evt->data.rx.len;
break;
case UART_RX_BUF_REQUEST:
err = uart_rx_buf_rsp(dev,
chained_read_buf[rx_buf_idx],
sizeof(chained_read_buf[0]));
err = uart_rx_buf_rsp(dev, chained_read_buf[rx_buf_idx],
sizeof(chained_read_buf_0));
zassert_equal(err, 0);
rx_buf_idx = !rx_buf_idx ? 1 : 0;
break;
Expand Down Expand Up @@ -389,9 +392,10 @@ ZTEST_USER(uart_async_chain_read, test_chained_read)

err = uart_rx_enable(uart_dev,
chained_read_buf[rx_buf_idx++],
sizeof(chained_read_buf[0]),
sizeof(chained_read_buf_0),
rx_timeout_ms * USEC_PER_MSEC);

Check notice on line 396 in tests/drivers/uart/uart_async_api/src/test_uart_async.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

tests/drivers/uart/uart_async_api/src/test_uart_async.c:396 - err = uart_rx_enable(uart_dev, - chained_read_buf[rx_buf_idx++], - sizeof(chained_read_buf_0), + err = uart_rx_enable(uart_dev, chained_read_buf[rx_buf_idx++], sizeof(chained_read_buf_0),
zassert_equal(err, 0);
rx_data_idx = 0;

for (int i = 0; i < iter; i++) {
zassert_not_equal(k_sem_take(&rx_disabled, K_MSEC(10)),
Expand All @@ -406,7 +410,7 @@ ZTEST_USER(uart_async_chain_read, test_chained_read)
"Unexpected amount of data received %d exp:%d",
rx_data_idx, sizeof(tx_buf));
zassert_equal(memcmp(tx_buf, chained_cpy_buf, sizeof(tx_buf)), 0,
"Buffers not equal");
"Buffers not equal exp %s, real %s", tx_buf, chained_cpy_buf);
rx_data_idx = 0;
}
uart_rx_disable(uart_dev);
Expand Down

0 comments on commit 7152b13

Please sign in to comment.