Skip to content

Commit a13b59a

Browse files
committed
tests: drivers: spi: extend error_cases test.
Extend with no reconfiguration on every tranceive case. Signed-off-by: Bartlomiej Buczek <[email protected]>
1 parent 8d202cb commit a13b59a

File tree

1 file changed

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

1 file changed

+24
-0
lines changed

tests/drivers/spi/spi_error_cases/src/main.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,30 @@ ZTEST(spi_error_cases, test_spis_tx_buf_not_in_ram)
221221
zassert_equal(slave_rv, -ENOTSUP, "Got %d instead", slave_rv);
222222
}
223223

224+
ZTEST(spi_error_cases, test_no_configure_in_each_transceive)
225+
{
226+
int rv;
227+
struct spi_dt_spec spim_valid = spim;
228+
struct spi_dt_spec spim_invalid = spim;
229+
230+
/* configure device during first transceive with valid config */
231+
rv = spi_transceive_dt(&spim_valid, tdata.stx_set, tdata.srx_set);
232+
zassert_equal(rv, 0, "Got %d instead", rv);
233+
234+
/* change valid config frequency to invalid value */
235+
spim_valid.config.frequency = 124999;
236+
237+
/* make sure device is not reconfigured because conf structure pointer is the same
238+
thus do not report error because of invalid frequency setting */
239+
rv = spi_transceive_dt(&spim_valid, tdata.stx_set, tdata.srx_set);
240+
zassert_equal(rv, 0, "Got %d instead", rv);
241+
242+
/* use different config structure - force reconfiguration and thus report error */
243+
spim_invalid.config.frequency = 124999;
244+
rv = spi_transceive_dt(&spim_invalid, tdata.stx_set, tdata.srx_set);
245+
zassert_equal(rv, -EINVAL, "Got %d instead", rv);
246+
}
247+
224248
static void before(void *not_used)
225249
{
226250
ARG_UNUSED(not_used);

0 commit comments

Comments
 (0)