-
Notifications
You must be signed in to change notification settings - Fork 3k
Add BlockDevice unittests and fix issues they revealed #12398
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
Add BlockDevice unittests and fix issues they revealed #12398
Conversation
Incorrect addresses only cause error return values instead of assertion. ExhaustibleBlockDevice has working get/set_erase_cycle functions and an array preventing programming without erase. Fixed MBRBlockDevice partitioning function.
Test run: FAILEDSummary: 1 of 4 test jobs failed Failed test jobs:
|
There are failures in unittests |
Moved the existing BufferedBlockDevice to features/storage unittests and switched it to gmock. Added gmock-based unit tests to all other BlockDevice classes. SlicingBlockDevice test left as a module test.
efcd214
to
31ce764
Compare
Pull request has been modified.
I did not initialize all buffers properly. Once I did I saw the issue and just pushed a fix to it. |
CI restarted |
Test run: FAILEDSummary: 2 of 4 test jobs failed Failed test jobs:
|
CI started |
Test run: FAILEDSummary: 1 of 4 test jobs failed Failed test jobs:
|
Pull request has been modified.
Tests failed because I missed a memory leak in test code. I just pushed a commit fixing it. @SeppoTakalo , please review. |
CI restarted |
Test run: FAILEDSummary: 1 of 4 test jobs failed Failed test jobs:
|
I am sorry, |
Pull request has been modified.
Locally I ran all the newly added tests with |
CI started |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
Summary of changes
Add unittests to
BlockDevice
classes:BlockDeviceMock
inUNITTESTS/stub/BlockDevice_mock.h
, using gmockUNITTESTS/features/storage/blockdevice/
using the aforementioned mock class. Coverage is around 80-90%, the missing coverage are error returns on device failures, etc.BufferBlockDevice
moved from moduletests to unittests (now using gmock, instead of HeapBlockDevice).SlicingBlockDevice
left in module tests to showcase BD stacking.Source code fixes (added in a separate commit):
ExhaustibleBlockDevice
now really returns an error onprogram()
if the memory has not been erased before (according to the documentation).MBED_ASSERT
usage to run-time error codes. I don't see a reason why incorrect address or size would cause a whole program to crash.MBRBlockDevice::partition
had offset and size mixed up. This was never revealed because the existing greentea test split the memory in half (size was equal to offset). We are now unittesting a split into 4 partitions which revealed the mistake.Impact of changes
Not important.
Migration actions required
None
Documentation
Not required.
Pull request type
Test results
Reviewers
@SeppoTakalo
@VeijoPesonen