-
Notifications
You must be signed in to change notification settings - Fork 2k
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
tests/thread_race: add test for race conditions #8897
Conversation
Fixed for #8904 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found some things. I think this PR should be made dependent on #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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and below, no need of \n
in the puts()
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 #ifdef
s.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
tests/thread_race/main.c
Outdated
#endif | ||
|
||
/* Delay so we are not testing for race conditions also */ | ||
_spin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Please squash.
@kYc0o Squashed. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, forgot a change.
include ../Makefile.tests_common | ||
|
||
DISABLE_MODULE += auto_init | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot this part. I think this test should be run by the CI on hardware. Can you please add:
TEST_ON_CI_WHITELIST += all
just here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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