From 99f87d8ac9f6cd4b00866733f7baf4a13bc071fe Mon Sep 17 00:00:00 2001 From: Martin Vychodil Date: Mon, 6 Jul 2026 10:35:16 +0200 Subject: [PATCH] test(vfs): reformat WL FATFS in setup to avoid stale-partition flakes Reformat the test partition before each mount so those tests always start from a known-empty filesystem. Co-authored-by: Cursor --- components/vfs/test_apps/main/test_vfs_access.c | 4 +++- components/vfs/test_apps/main/test_vfs_append.c | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/components/vfs/test_apps/main/test_vfs_access.c b/components/vfs/test_apps/main/test_vfs_access.c index e3752208030..7f37bc11341 100644 --- a/components/vfs/test_apps/main/test_vfs_access.c +++ b/components/vfs/test_apps/main/test_vfs_access.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -68,6 +68,8 @@ static inline void test_spi_flash_setup(void) .max_files = 5 }; + //reformat the partition to ensure having a fresh copy for each test + TEST_ESP_OK(esp_vfs_fat_spiflash_format_rw_wl("/spiflash", NULL)); TEST_ESP_OK(esp_vfs_fat_spiflash_mount_rw_wl("/spiflash", NULL, &mount_config, &test_wl_handle)); } diff --git a/components/vfs/test_apps/main/test_vfs_append.c b/components/vfs/test_apps/main/test_vfs_append.c index 80aa8e5f954..c790619dc49 100644 --- a/components/vfs/test_apps/main/test_vfs_append.c +++ b/components/vfs/test_apps/main/test_vfs_append.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -82,9 +82,10 @@ TEST_CASE("open() with O_APPEND on FATFS works well", "[vfs][FATFS]") wl_handle_t test_wl_handle; esp_vfs_fat_sdmmc_mount_config_t mount_config = { - .format_if_mount_failed = true, .max_files = 2 }; + //reformat the partition to ensure having a fresh copy for each test + TEST_ESP_OK(esp_vfs_fat_spiflash_format_rw_wl("/spiflash", NULL)); TEST_ESP_OK(esp_vfs_fat_spiflash_mount_rw_wl("/spiflash", NULL, &mount_config, &test_wl_handle)); test_append("/spiflash/file.txt");