Skip to content

tests: drivers: spi: spi_loopback: skip tests if invalid config #90321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bjarki-andreasen
Copy link
Collaborator

@bjarki-andreasen bjarki-andreasen commented May 22, 2025

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.

Before this patch:

===================================================================
START - test_spi_word_size_9
E: Word sizes other than 8 bits are not supported
Spi config invalid for this controller - skip

    Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/spi/spi_loopback/src/spi.c:628: spi_loopback_test_word_size: (memcmp(compare_data, rx_buffer, buffer_size) is true)
9-bit word buffer contents are different
 FAIL - test_spi_word_size_9 in 262.779 seconds
===================================================================

After this patch

START - test_spi_word_size_9
E: Word sizes other than 8 bits are not supported
Spi config invalid for this controller
 SKIP - test_spi_word_size_9 in 0.009 seconds

fixes: #90318

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]>
Copy link

@bjarki-andreasen bjarki-andreasen added the bug The issue is a bug, or the PR is fixing a bug label May 22, 2025
@decsny
Copy link
Member

decsny commented May 22, 2025

So, when I made this PR originally for this tests, I had done skips instead, but there was some kind of Ztest bug that was making a skip cause the test to fail so we decided not to use the skips. I don't know if it got fixed, FYI @djiatsaf-st and @yperess

@bjarki-andreasen
Copy link
Collaborator Author

So, when I made this PR originally for this tests, I had done skips instead, but there was some kind of Ztest bug that was making a skip cause the test to fail so we decided not to use the skips. I don't know if it got fixed, FYI @djiatsaf-st and @yperess

ok, will wait to hear back, but ztest_test_skip() is used widely in zephyr, it would have to be a platform bug of some sort I would imagine then :)

@decsny
Copy link
Member

decsny commented May 22, 2025

So, when I made this PR originally for this tests, I had done skips instead, but there was some kind of Ztest bug that was making a skip cause the test to fail so we decided not to use the skips. I don't know if it got fixed, FYI @djiatsaf-st and @yperess

ok, will wait to hear back, but ztest_test_skip() is used widely in zephyr, it would have to be a platform bug of some sort I would imagine then :)

no , it wasn't a platform bug, it was something with ztest, the test case would skip on the ST parts, and then the whole test suite would fail despite no individual test case failing, so we decided to just make the test pass instead of skip so the PR could merge

@JarmouniA
Copy link
Collaborator

ok, will wait to hear back, but ztest_test_skip() is used widely in zephyr, it would have to be a platform bug of some sort I would imagine then :)

@bjarki-andreasen #86611

@bjarki-andreasen
Copy link
Collaborator Author

@JarmouniA so, seems it is fixed now? We can use ztest_test_skip()?

@JarmouniA
Copy link
Collaborator

@JarmouniA so, seems it is fixed now? We can use ztest_test_skip()?

It appears so, @djiatsaf-st can confirm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: SPI SPI bus bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

drivers: spi: spi_loopback: drivers.spi.* fail
5 participants