Skip to content
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 moduletests for FileSystemStore #12652

Merged
merged 1 commit into from
Mar 19, 2020

Conversation

jarlamsa
Copy link
Contributor

Summary of changes

Baseline for the tests is similar to the TDBStore.
Differing from TDBStore moduletests, FileSystemStore doesn't include
tests for reserved data or corrupting the blockdevice, as it corrupts
the filesystem also.

Impact of changes

Migration actions required

Documentation

None


Pull request type

[X] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[X] Tests / results supplied as part of this PR

Reviewers

@SeppoTakalo @VeijoPesonen


Baseline for the tests is similar to the TDBStore.
Differing from TDBStore moduletests, FileSystemStore doesn't include
tests for reserved data or corrupting the blockdevice, as it corrupts
the filesystem also.

TEST_F(FileSystemStoreModuleTest, erased_set_get)
{
EXPECT_EQ(store->deinit(), MBED_SUCCESS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume these test can't be run in random order.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the tests are run in the order they are written. But that shouldn't matter as the tests are separate and setup and teardown are ran for each test.

Copy link
Contributor

@LDong-Arm LDong-Arm Apr 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jarlamsa This test case fails if BlockDevice::erase() actually performs an erase, unless we call fs->reformat() afterwards. We didn't see this issue because HeapBlockDevice::erase() is essentially a no-op. But now I'm working on de-allocating the heap buffer on erase, and get the failure. (Same happens, if we memset the buffer to 0xFF instead of de-allocate it.)

I can add the reformat to make it pass. But erasing the underlying BlockDevice sounds like restarting everything from scratch? Could you please explain me the use case we're trying to test here? Thanks in advance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you want to deallocate the heap buffer on erase? That doesn't sound like correct behavior.

Copy link
Contributor

@LDong-Arm LDong-Arm Apr 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If deallocating the heap is not correct, then what about a BlockDevice that does an actual erase (e.g. like many flash devices) and sets values to 0xFF, for example? If I didn't miss anything, this test case relies on the assumption that data is unaltered when BlockDevice::erase() is called?

In my opinion, FileSystemStore should be compatible with any block device that's compliant with BlockDevice API requirements, rather than tied to specific behaviours? (I mean, I personally think a test case is only meaningful if it tests something generally applicable.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Referring to this test case, I think it can be safely deleted, erasing the whole heap underneath the filesystem just corrupts the filesystem.

But regarding the deallocation of the allocated memory from the heap when erasing, it really sounds just wrong. Now the allocation for HeapBlockDevice is done on init and deallocation is done on destructor, how do you plan to change this?

Copy link
Contributor

@LDong-Arm LDong-Arm Apr 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HeapBlockDevice::init() only allocates an array of null pointers to blocks, not individual blocks. Only when a block is used in HeapBlockDevice::program(), the particular blocks being programmed is allocated and added to the array of pointers.
My HeapBlockDevice::erase() change only frees blocks being erased. The destructor, as before, frees all block and the array of pointers. So in terms of behaviour, it's still self-consistent, I think.

But if the change looks redundant I can remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that explains it. LGTM.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheers

Copy link
Contributor

@VeijoPesonen VeijoPesonen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@mergify mergify bot added the needs: CI label Mar 19, 2020
@0xc0170
Copy link
Contributor

0xc0170 commented Mar 19, 2020

CI started

@mbed-ci
Copy link

mbed-ci commented Mar 19, 2020

Test run: SUCCESS

Summary: 1 of 1 test jobs passed
Build number : 1
Build artifacts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants