tests/thread_race: add test for race conditions#8897
Conversation
|
Fixed for #8904 |
tests/thread_race/main.c
Outdated
| /* Volatile so it is not messed with by optimizations */ | ||
| volatile uint8_t i; | ||
|
|
||
| for (i=0; i<255; i++); |
There was a problem hiding this comment.
Here and below (for the if-else statements), please follow coding conventions. You may also run uncrustify on this file to correct it automatically.
There was a problem hiding this comment.
Sorry, still new to RIOT conventions. Uncrustified.
tests/thread_race/main.c
Outdated
|
|
||
| int main(void) | ||
| { | ||
| puts("Context swap race condition test application\n"); |
There was a problem hiding this comment.
Here and below, no need of \n in the puts() function.
tests/thread_race/main.c
Outdated
| #include "thread.h" | ||
|
|
||
| /* board.h for AVR_CONTEXT_SWAP_TRIGGER */ | ||
| #include "board.h" |
There was a problem hiding this comment.
Here and below, I don't like the non-generic nature on this tests, and why AVR should be treated in such special way... I see more convenient to have a generic test which works for all platforms without #ifdefs.
If this is due to #8896, please make this PR dependent on #8904, on which AVR_CONTEXT_SWAP_TRIGGER doesn't exist anymore.
There was a problem hiding this comment.
I was having some false negatives with thread_yield_higher, probably due to the slower clock on mega-xplained. AVR_CONTEXT_SWAP_TRIGGER is now removed.
| #endif | ||
|
|
||
| /* Delay so we are not testing for race conditions also */ | ||
| _spin(); |
There was a problem hiding this comment.
Can you explain a bit better this spin? If I understood correctly, this test is actually used to test race conditions isn't it?
There was a problem hiding this comment.
The first two checks are verifying that context swaps are working properly. Without these checks a more general problem with context swaps would be reported as a race condition. I added to the outputted text to clarify this.
bcc73fc to
a843eff
Compare
|
Squashed with requested changes incorporated. EDIT: Oops; wasn't supposed to squash. Unsquashed from backup. Sorry. |
a843eff to
bcc73fc
Compare
kYc0o
left a comment
There was a problem hiding this comment.
Looks good. Please squash.
|
@kYc0o Squashed. Thanks! |
| include ../Makefile.tests_common | ||
|
|
||
| DISABLE_MODULE += auto_init | ||
|
|
There was a problem hiding this comment.
I forgot this part. I think this test should be run by the CI on hardware. Can you please add:
TEST_ON_CI_WHITELIST += alljust here?
There was a problem hiding this comment.
Added support for CI hardware testing.
|
Thanks @ZetaR60 ! Let's see what Murdock has to say. |
|
Removed tests on hardware because unrelated errors block this PR. However the test added by this PR passed. |
|
Let's go! |
This adds a test for race conditions in context switching, especially for AVR_CONTEXT_SWAP_TRIGGER on the ATmega.
Tests for problem in #8896