Skip to content

ostest: Implement mutex move test functionality #3025

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

Merged
merged 1 commit into from
Mar 24, 2025

Conversation

no1wudi
Copy link
Contributor

@no1wudi no1wudi commented Mar 12, 2025

Summary

This change enhances NuttX's test coverage by validating mutex behavior
in non-standard relocation scenarios, while explicitly noting this
extends beyond POSIX specifications. The test helps prevent regressions

in edge-case mutex handling.
* Add test case for mutex move functionality in ostest
* Verifies correct behavior when a mutex is relocated in memory
* Introduces new test structure with thread argument passing
* Includes validation of mutex state across thread operations
* Related to Rust language discussion: https://github.com/rust-lang/rust/pull/138400

Impact

* New feature added?: YES - Adds new mutex move test scenario
* Impact on user?: NO - Test suite enhancement only
* Impact on build?: NO - Existing test infrastructure used
* Impact on hardware?: NO - Pure software validation
* Impact on documentation?: NO - No user-facing docs changed
* Impact on security?: NO - Test-only code
* Impact on compatibility?: NO - Maintains existing POSIX compliance

Testing

ostest:

user_main: mutex test
Initializing mutex
Starting thread 1
Starting thread 2
                Thread1 Thread2
        Loops   32      32
        Errors  0       0

Testing moved mutex
Starting moved mutex thread 1
Starting moved mutex thread 2
                Thread1 Thread2
        Moved Loops     32      32
        Moved Errors    0       0

End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     1fc5ee0  1fc5ee0
ordblks         4        2
mxordblk  1fbacc0  1fc07e8
uordblks     ad30     5678
fordblks  1fbb1b0  1fc0868

@nuttxpr
Copy link

nuttxpr commented Mar 12, 2025

[Experimental Bot, please feedback here]

Yes, this PR appears to meet the NuttX requirements. The summary clearly explains the change, its purpose, and how it works. The impact section adequately addresses all points, and the testing section provides evidence of validation, including before and after logs (although minimal). The reference to the Rust discussion is helpful context but not a direct NuttX issue/PR.

Add a new test for moving mutexes to verify behavior when a mutex is relocated.
* Introduced mutex_thread_args_t structure for thread arguments
* Created moved_mutex_thread_func to handle mutex operations in threads
* Updated mutex_test to include mutex_move_test for comprehensive testing

Signed-off-by: Huang Qi <[email protected]>
@xiaoxiang781216 xiaoxiang781216 merged commit 16a16a9 into apache:master Mar 24, 2025
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants