Skip to content

Commit

Permalink
Add checks for removing files and directories to littlefs HW test
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickKa committed Dec 11, 2024
1 parent 1ab99de commit 1611d2f
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions Tests/HardwareTests/Littlefs.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ class LittlefsTest : public RODOS::StaticThread<stackSize>
{
EnableRfLatchupProtection();

PRINTF("\n\n");
PRINTF("littlefs test\n");
PRINTF("\n\nlittlefs test\n");

PRINTF("\n");
auto lfs = lfs_t{};
Expand All @@ -56,7 +55,6 @@ class LittlefsTest : public RODOS::StaticThread<stackSize>
PRINTF("Creating directory '%s' ...\n", directoryPath);
errorCode = lfs_mkdir(&lfs, directoryPath);
Check(errorCode == 0);

PRINTF("\n");
auto const * filePath = "MyFolder/MyFile";
PRINTF("Creating file '%s' ...\n", filePath);
Expand Down Expand Up @@ -92,6 +90,33 @@ class LittlefsTest : public RODOS::StaticThread<stackSize>
PRINTF("Closing file ...\n");
errorCode = lfs_file_close(&lfs, &file);
Check(errorCode == 0);

PRINTF("\n");
PRINTF("Removing the non-empty directory '%s' should fail ...\n", directoryPath);
errorCode = lfs_remove(&lfs, directoryPath);
PRINTF("Error code = %d == %d\n", errorCode, LFS_ERR_NOTEMPTY);
Check(errorCode == LFS_ERR_NOTEMPTY);
PRINTF("Removing the file '%s' ...\n", filePath);
errorCode = lfs_remove(&lfs, filePath);
Check(errorCode == 0);
PRINTF("Removing the empty directory '%s' ...\n", directoryPath);
errorCode = lfs_remove(&lfs, directoryPath);
Check(errorCode == 0);

PRINTF("\n");
PRINTF("Unmounting ...\n");
errorCode = lfs_unmount(&lfs);
Check(errorCode == 0);

PRINTF("\n");
if(AllChecksPassed())
{
PRINTF("ALL CHECKS PASSED :)\n");
}
else
{
PRINTF("SOME CHECKS FAILED :(\n");
}
}
} littlefsTest;
}

0 comments on commit 1611d2f

Please sign in to comment.