From f995584a6d16fca7245e2cd1390d706d4c793fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ga=C5=88o?= Date: Wed, 14 Sep 2022 11:20:31 +0200 Subject: [PATCH] fatfs: unittest fatfs ignores leading spaces --- components/fatfs/test/test_fatfs_common.c | 9 +++++++++ components/fatfs/test/test_fatfs_common.h | 2 ++ components/fatfs/test/test_fatfs_spiflash.c | 11 +++++++++++ 3 files changed, 22 insertions(+) diff --git a/components/fatfs/test/test_fatfs_common.c b/components/fatfs/test/test_fatfs_common.c index b9f79c9783..ddb8c5b242 100644 --- a/components/fatfs/test/test_fatfs_common.c +++ b/components/fatfs/test/test_fatfs_common.c @@ -891,6 +891,15 @@ void test_fatfs_concurrent(const char* filename_prefix) vSemaphoreDelete(args4.done); } +void test_leading_spaces(void){ + // fatfs should ignore leading and trailing whitespaces + // and files "/spiflash/ thelongfile.txt " and "/spiflash/thelongfile.txt" should be equivalent + // this feature is currently not implemented + FILE* f = fopen( "/spiflash/ thelongfile.txt ", "wb"); + fclose(f); + TEST_ASSERT_NULL(fopen("/spiflash/thelongfile.txt", "r")); +} + void test_fatfs_rw_speed(const char* filename, void* buf, size_t buf_size, size_t file_size, bool is_write) { const size_t buf_count = file_size / buf_size; diff --git a/components/fatfs/test/test_fatfs_common.h b/components/fatfs/test/test_fatfs_common.h index 7d05da5680..8b2ed0ea32 100644 --- a/components/fatfs/test/test_fatfs_common.h +++ b/components/fatfs/test/test_fatfs_common.h @@ -65,6 +65,8 @@ void test_fatfs_opendir_readdir_rewinddir(const char* dir_prefix); void test_fatfs_opendir_readdir_rewinddir_utf_8(const char* dir_prefix); +void test_leading_spaces(void); + void test_fatfs_rw_speed(const char* filename, void* buf, size_t buf_size, size_t file_size, bool write); void test_fatfs_info(const char* base_path, const char* filepath); diff --git a/components/fatfs/test/test_fatfs_spiflash.c b/components/fatfs/test/test_fatfs_spiflash.c index 19c33c0440..b1631608a6 100644 --- a/components/fatfs/test/test_fatfs_spiflash.c +++ b/components/fatfs/test/test_fatfs_spiflash.c @@ -176,6 +176,17 @@ TEST_CASE("(WL) multiple tasks can use same volume", "[fatfs][wear_levelling]") test_teardown(); } +TEST_CASE("(WL) fatfs does not ignore leading spaces", "[fatfs][wear_levelling]") +{ + // the functionality of ignoring leading and trailing whitespaces is not implemented yet + // when the feature is implemented, this test will fail + // please, remove the test and implement the functionality in fatfsgen.py to preserve the consistency + test_setup(); + test_leading_spaces(); + test_teardown(); +} + + TEST_CASE("(WL) write/read speed test", "[fatfs][wear_levelling][timeout=60]") { /* Erase partition before running the test to get consistent results */