Skip to content

Commit d265dad

Browse files
bjarki-andreasenkartben
authored andcommitted
tests: drivers: spi: spi_loopback: skip tests if invalid config
The spi_loopback_transceive() helper currently only prints a message if a configuration is invalid, continuing the test case as if it succeeded. This results in the test case using the helper trying to validate the result from a spi transaction that was skipped. Fix this by explicitly skipping the test using the ztest framework's ztest_test_skip() function, which skips the entire test case. Signed-off-by: Bjarki Arge Andreasen <[email protected]>
1 parent 6faa29d commit d265dad

File tree

1 file changed

+3
-3
lines changed
  • tests/drivers/spi/spi_loopback/src

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,13 @@ static void spi_loopback_transceive(struct spi_dt_spec *const spec,
196196
spi_loopback_gpio_cs_loopback_prepare();
197197
ret = spi_transceive_dt(spec, tx, rx);
198198
if (ret == -EINVAL || ret == -ENOTSUP) {
199-
TC_PRINT("Spi config invalid for this controller - skip\n");
200-
goto out;
199+
TC_PRINT("Spi config invalid for this controller\n");
200+
zassert_ok(pm_device_runtime_put(spec->bus));
201+
ztest_test_skip();
201202
}
202203
zassert_ok(ret, "SPI transceive failed, code %d", ret);
203204
/* There should be two CS triggers during the transaction, start and end */
204205
zassert_false(spi_loopback_gpio_cs_loopback_check(2));
205-
out:
206206
zassert_ok(pm_device_runtime_put(spec->bus));
207207
}
208208

0 commit comments

Comments
 (0)