Skip to content

Fix spi loopback thread test on fail case #90766

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 2 commits into
base: main
Choose a base branch
from

Conversation

decsny
Copy link
Member

@decsny decsny commented May 28, 2025

In the case of thread test failing, it is not handled well and will mess up the execution of the rest of the test. This can be fixed as is done in the PR.

Also fixes a mistake on a value printed in the test log for the latency test, this problem did not actually affect the pass/fail of the test and neither does the fix to it.

The test that checks latency also prints a measurement of the latency
which is just a visual information for the test output. However, this
print uses a subtraction which can have an overflow in the case where
the kernel timer is behind, so just clamp to 0 in that case where there
is an overflow. This change does not affect the test pass/fail logic.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
@decsny decsny requested a review from Copilot May 28, 2025 19:39
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves the handling of failure cases in the SPI loopback thread test and corrects an error in the latency measurement log output. Key changes include:

  • Adding an overflow check for latency measurement before printing.
  • Replacing immediate assertions in SPI transfer threads with error logging via an atomic counter.
  • Aggregating thread test failures after joins with an assertion to determine overall test success.

@github-actions github-actions bot added the area: SPI SPI bus label May 28, 2025
@github-actions github-actions bot requested review from tbursztyka and teburd May 28, 2025 19:40
@decsny decsny force-pushed the spi_loopback_test_fixes branch from f2cab8f to 2f3f7ae Compare May 28, 2025 19:52
Right now the thread test case does not handle when the test fails, the
test will be aborted by ztest in one of the spawned threads, and cause
desynchronization which messes up the rest of the test. Fix by
synchronizing in the case of fails and return fail from main test thread
instead of the spawned ones.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
@decsny decsny force-pushed the spi_loopback_test_fixes branch from 2f3f7ae to b2b1198 Compare May 28, 2025 20:17
Copy link

@decsny decsny requested a review from kartben May 30, 2025 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: SPI SPI bus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants