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

335 automate flash file system hardware tests #366

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

HerrCooker
Copy link
Contributor

Implement first step for testing our filesystem. Future additions to these tests might be necessary.

@HerrCooker HerrCooker self-assigned this Feb 4, 2025
@HerrCooker HerrCooker linked an issue Feb 4, 2025 that may be closed by this pull request
5 tasks
Jan added 3 commits February 4, 2025 18:35
First step to test basic functionalities of our filesystem.

Checks:
- adding/moving/deleting files
- blocking sectors for fpga
- freeing blocked sectors
- move askEspForOkViaPico to AutomatedHWTests directory
- change affected CMake files accordingly
Problem:
- counter variable in "filesystemFindFittingStartSector" used to be uint8_t
- during testing this led to unwanted behaviour caused by overflow

Solution:
. make counter uint32_t

Additional:
- introduced numberOfFreeSectors to filesystemConfig for easier testing
- added matching behaviour to affecting functions
- introduced early check for moving file into blocked sector
@HerrCooker HerrCooker force-pushed the 335-automate-flash-file-system-hardware-tests branch from 84ea72c to 9522d32 Compare February 4, 2025 17:35
@HerrCooker
Copy link
Contributor Author

HerrCooker commented Feb 4, 2025

@DavidFederl I don't understand why the formatting tests fail. Weren't these meant to just give warnings?

@DavidFederl
Copy link
Contributor

@DavidFederl I don't understand why the formatting tests fail. Weren't these meant to just give warnings?

They do fail, when the rules are violated. They just don't fix the problem anymore and leave that to the contributor.

We discussed the we don't fail the workflow stuff for commitlint. But doesn't implement it yet.

refactor(hal): apply clang format

refactor(hal): apply clang format
@HerrCooker HerrCooker force-pushed the 335-automate-flash-file-system-hardware-tests branch from ccf2b21 to afb8fb0 Compare February 13, 2025 14:17
@glencoe
Copy link
Contributor

glencoe commented Feb 14, 2025

@DavidFederl I don't understand why the formatting tests fail. Weren't these meant to just give warnings?

They do fail, when the rules are violated. They just don't fix the problem anymore and leave that to the contributor.

We discussed the we don't fail the workflow stuff for commitlint. But doesn't implement it yet.

We could set the pipeline to not require the linters to pass before merging. I think i'd actually like that more than just raising a warning.

@glencoe
Copy link
Contributor

glencoe commented Feb 14, 2025

Implement first step for testing our filesystem. Future additions to these tests might be necessary.

That is very cool, but what is that first step? Can you be more specific in the commit msg? Nvm, you are more specific in the commit msg :D

@HerrCooker
Copy link
Contributor Author

I thought i was more specific in the commit message, by listing what this test is supposed to do. Not sure what i could add otherwise. Any ideas?

Comment on lines 18 to 22
filesystemConfig->filesystemStartSector = 1019;
filesystemConfig->filesystemEndSector = 1023;
filesystemConfig->flash = flashConfig;
filesystemConfig->numberOfFreeSectors = 1019;

Copy link
Contributor

Choose a reason for hiding this comment

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

Where do these numbers come from btw? Can you find a way to make that clearer? E.g., using object like macros or enums?

Copy link
Contributor

Choose a reason for hiding this comment

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

Overall this is quite a long function. Do you see reasonable ways to split it into smaller steps? Maybe at the points where comments are used for explanation atm?

@@ -59,12 +58,11 @@ void filesystemInit(flashConfiguration_t *flashConfig,

int32_t filesystemFindFittingStartSector(const filesystemConfiguration_t *filesystemConfig,
uint32_t numberOfRequiredBytes) {
int32_t newFileSector;
uint8_t counter = 0;
int32_t newFileSector = -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the semantics of -1 here? object like macro?

Comment on lines 86 to +89
filesystemConfig->fileSystem[filesystemConfig->numberOfEntries].entry.size = size;
filesystemConfig->fileSystem[filesystemConfig->numberOfEntries].entry.isConfig = isConfig;

// Set number of used sectors for this file
uint32_t numberOfUsedSectors = (size_t)ceilf(
Copy link
Contributor

Choose a reason for hiding this comment

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

not 100% sure rn, but these lines and the lines above seem to all handle a very specific aspect of the configuration. It might make sense to simplify the use here by wrapping them in functions. E.g. having

static inline void set_size(FsConfig *config, size_t size) {
  config->fileSystem[config->numberOfEntries].entry.size = size;
}

and afterwards just writing

set_size(filesystemConfig, size);

makes the code a lot easier to digest.

TEST_ASSERT_EQUAL(true, filesystemExists);
}

void testFileSystemDoesntExist() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I might be wrong, but it seems, your test name is describing the test case, as in "given the case that the file system does not exist".
Often it is more helpful though, to describe the expected behaviour.

(Tbh, actually we'd have to do both, but unity out-of-the-box does not provide an easy way to do that 😢)

TEST_ASSERT_EQUAL(false, filesystemExists);
}

void testFindFittingStartSector() {
Copy link
Contributor

Choose a reason for hiding this comment

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

That in turn is a really good name 👍

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

Successfully merging this pull request may close these issues.

automate Flash-File-System Hardware-Tests
3 participants