tests/xtimer_mutex_lock_timeout: add simple case test#11679
tests/xtimer_mutex_lock_timeout: add simple case test#11679cladmi merged 4 commits intoRIOT-OS:masterfrom
Conversation
comment for mutex_thread_t
timeout is modified from interupt context so must be volatile
|
The test successfully ran on |
cladmi
left a comment
There was a problem hiding this comment.
I agree with the functional part but still have some remarks with documentation/naming. Please see inline.
| * @brief shell command to test xtimer_mutex_lock_timeout | ||
| * | ||
| * the mutex is locked before the function call and | ||
| * the timeout is greater than XTIMER_BACKOFF (no spinning) |
There was a problem hiding this comment.
Please update in the direction, "the timeout will occur while waiting on the mutex" it would explain more the case without the need to mention spinning.
| * @brief shell command to test xtimer_mutex_lock_timeout | ||
| * | ||
| * the mutex is not locked before the function call and | ||
| * the timeout is greater than XTIMER_BACKOFF (no spinning) |
There was a problem hiding this comment.
Please update in the direction, "the timeout callback will be removed before triggering" it would explain more the case.
| /** | ||
| * Foward declarations | ||
| */ | ||
| static int cmd_test_xtimer_mutex_lock_timeout_greater_backoff(int argc, |
There was a problem hiding this comment.
Maybe update the function names to not mention 'backoff' but more what is tested, so testing with a free mutex and long timeout. Would match the documentation updates.
Same for the other function.
| mutex_t *mutex; | ||
| thread_t *thread; | ||
| int timeout; | ||
| volatile int timeout; |
There was a problem hiding this comment.
Agreed with the change, the value is modified in another context.
| mutex_t test_mutex = MUTEX_INIT; | ||
|
|
||
| /* timeout at one millisecond (1000 us) to make sure it does not spin. */ | ||
| if (xtimer_mutex_lock_timeout(&test_mutex, 1000) == 0) { |
There was a problem hiding this comment.
Please put the 1000 as a macro with the comment before so it can be re-used in both functions.
|
I changed the documentation/naming. Do you have more suggestions and are you ok with my changes? @cladmi |
cladmi
left a comment
There was a problem hiding this comment.
Some minor fixups inside. You can squash them directly.
Please squash everything, I will do a final round of check after.
| child.sendline("help") | ||
| if child.expect_exact(["> ", pexpect.TIMEOUT], timeout=1) == 0: | ||
| break | ||
| child.sendline("mutex_timeout_n_spin_unlocked") |
There was a problem hiding this comment.
The tests commands must also be updated.
5dc42d4 to
50e9ac4
Compare
|
Was notified IRL. Thanks for inline updating the documentation, I did not notice it was the documentation for the other function. https://github.com/RIOT-OS/RIOT/compare/5dc42d4f21306349841c1542d2471da685f3709a..50e9ac4d547ab8749f6b53f93f2c7baa89521ae4 |
|
I re-read with more details and currently the tests do not verify that the |
The new commit checks it. |
|
Should be checking it (if mutex locked) now correctly. |
|
I get the expected output for the test, on and the test successfully ran on Please squash. |
Adding a first normal test case where the mutex is unlocked and the timeout is long. The timer will not trigger in this test and instead wil be removed after getting the mutex.
New test function cmd_test_xtimer_mutex_lock_timeout_long_locked. In this test the mutex is locked and the timeout is long. When it works the thread continues running and stops waiting for the mutex and the function will return that it did not get the mutex.
99078f4 to
b3d2324
Compare
|
@cladmi I squashed. |
cladmi
left a comment
There was a problem hiding this comment.
ACK, reviewed and tested on many boards.
Note for reference: this currently only test the simple cases where the mutex is not changed while waiting, and the timing is not analyzed.
|
First pull request merged! Well done. |
|
Thank you. |
Contribution description
This pr implements normal test case tests for
xtimer_mutex_lock_timeoutinxtimer.c. As the timeout 1000us or 1 millisecond is used to make sure it does not spin. And adds a short comment for the struct it uses (mutex_thread_t). Also because the integertimeoutin the struct is modified from interupt context it must be volatile.Testing procedure
BOARD=native make -C tests/xtimer_mutex_lock timeout/ flash testoutput:
Issues/PRs references
the tracking pr: #11660