From 7f6badd9770a911271a1c660d9f498788a42af7b Mon Sep 17 00:00:00 2001 From: Bartlomiej Buczek Date: Thu, 9 Oct 2025 15:09:55 +0200 Subject: [PATCH] [nrf fromlist] tests: drivers: spi: extend error_cases test. Extend with no reconfiguration on every tranceive case. Upstream PR #: 97275 Signed-off-by: Bartlomiej Buczek --- tests/drivers/spi/spi_error_cases/src/main.c | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/drivers/spi/spi_error_cases/src/main.c b/tests/drivers/spi/spi_error_cases/src/main.c index 4ebca6f1c2e..10ba036916b 100644 --- a/tests/drivers/spi/spi_error_cases/src/main.c +++ b/tests/drivers/spi/spi_error_cases/src/main.c @@ -221,6 +221,31 @@ ZTEST(spi_error_cases, test_spis_tx_buf_not_in_ram) zassert_equal(slave_rv, -ENOTSUP, "Got %d instead", slave_rv); } +ZTEST(spi_error_cases, test_no_configure_in_each_transceive) +{ + int rv; + struct spi_dt_spec spim_valid = spim; + struct spi_dt_spec spim_invalid = spim; + + /* configure device during first transceive with valid config */ + rv = spi_transceive_dt(&spim_valid, tdata.stx_set, tdata.srx_set); + zassert_equal(rv, 0, "Got %d instead", rv); + + /* change valid config frequency to invalid value */ + spim_valid.config.frequency = 124999; + + /* make sure device is not reconfigured because conf structure pointer is the same + * thus do not report error because of invalid frequency setting + */ + rv = spi_transceive_dt(&spim_valid, tdata.stx_set, tdata.srx_set); + zassert_equal(rv, 0, "Got %d instead", rv); + + /* use different config structure - force reconfiguration and thus report error */ + spim_invalid.config.frequency = 124999; + rv = spi_transceive_dt(&spim_invalid, tdata.stx_set, tdata.srx_set); + zassert_equal(rv, -EINVAL, "Got %d instead", rv); +} + static void before(void *not_used) { ARG_UNUSED(not_used);