Skip to content

Commit b983b04

Browse files
nordic-pikrkartben
authored andcommitted
tests: drivers: spi: Add NULL spi_buf_set tests
Add test cases where spi_transceive gets NULL spi_buf_set once for tx and once for rx. Signed-off-by: Piotr Krzyzanowski <[email protected]>
1 parent fd8abcf commit b983b04

File tree

1 file changed

+24
-0
lines changed
  • tests/drivers/spi/spi_loopback/src

1 file changed

+24
-0
lines changed

tests/drivers/spi/spi_loopback/src/spi.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,30 @@ ZTEST(spi_loopback, test_spi_complete_large_transfers)
321321
"Large Buffer contents are different");
322322
}
323323

324+
ZTEST(spi_loopback, test_spi_null_tx_buf_set)
325+
{
326+
struct spi_dt_spec *spec = loopback_specs[spec_idx];
327+
static const uint8_t expected_nop_return_buf[BUF_SIZE] = { 0 };
328+
const struct spi_buf_set rx = spi_loopback_setup_xfer(rx_bufs_pool, 1,
329+
buffer_rx, BUF_SIZE);
330+
331+
(void)memset(buffer_rx, 0x77, BUF_SIZE);
332+
333+
spi_loopback_transceive(spec, NULL, &rx);
334+
335+
spi_loopback_compare_bufs(expected_nop_return_buf, buffer_rx, BUF_SIZE,
336+
buffer_print_rx, buffer_print_rx);
337+
}
338+
339+
ZTEST(spi_loopback, test_spi_null_rx_buf_set)
340+
{
341+
struct spi_dt_spec *spec = loopback_specs[spec_idx];
342+
const struct spi_buf_set tx = spi_loopback_setup_xfer(tx_bufs_pool, 1,
343+
NULL, BUF_SIZE);
344+
345+
spi_loopback_transceive(spec, &tx, NULL);
346+
}
347+
324348
ZTEST(spi_loopback, test_nop_nil_bufs)
325349
{
326350
struct spi_dt_spec *spec = loopback_specs[spec_idx];

0 commit comments

Comments
 (0)