-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Multi thread Block Device Tests Fix - Ensure unique block address #9650
Multi thread Block Device Tests Fix - Ensure unique block address #9650
Conversation
@ARMmbed/mbed-os-maintainers , @ARMmbed/mbed-os-storage - please review. |
@offirko, thank you for your changes. |
|
||
// Make sure block address per each test is unique | ||
static unsigned block_seed = 1; | ||
srand(block_seed++); |
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 guess this is sufficient (block seed) for the test purpose or rather using time like getting from us ticker ?
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 didn't want to make a drastic change. I think this should be sufficient for this test purpose.
We simply need ~50 different addresses for this test, they don't have to be random per each test.I'm saying ~50 ((5 Threads x 10 iterations) because addresses may repeat as long as they do not run concurrently for different threads.
Because seed/rand are not really random, I believe once the test runs successfully it will remain stable. Using time will actually 'random' and then we might have collision issue (very very low probability as David mentioned below)
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 add this to the commit, will help
@offirko As far as I manage to understand, this solution decreases (very much) the probability of the problem, but doesn't eliminate it. The problem as I see it is the fact that multiple threads try to access the same block during the test. Theoretically, this can happen even with different seeds, as the block address is a modulo of the block device size. Maybe it would be better to make sure that the threads get different random block address before they start their work (maybe with a parameter). |
@davidsaada - pls see my answer to Martin above. |
The addresses dont have to change each run, just be unique. Because address seeds repeat themselves each run, rand() will produce repeating results that should not collide between different threads.
a68dcbc
to
be1c887
Compare
Ci started |
Test run: SUCCESSSummary: 12 of 12 test jobs passed |
Description
Fix multi-threaded block device tests to ensure unique block address per test
Pull request type