1 /* 2 * Copyright (c) 2016 Intel Corporation. 3 * Copyright (c) 2020 Nordic Semiconductor ASA 4 * Copyright (c) 2023 Husqvarna AB 5 * 6 * SPDX-License-Identifier: Apache-2.0 7 */ 8 9 #include <zephyr/kernel.h> 10 #include <zephyr/ztest.h> 11 #include <zephyr/fs/fs.h> 12 #include <ff.h> 13 14 #ifdef CONFIG_DISK_DRIVER_RAM 15 #define DISK_NAME "RAM" 16 #elif defined(CONFIG_DISK_DRIVER_FLASH) 17 #define DISK_NAME DT_PROP(DT_NODELABEL(test_disk), disk_name) 18 #elif defined(CONFIG_DISK_DRIVER_SDMMC) 19 #define DISK_NAME "SD" 20 #elif defined(CONFIG_DISK_DRIVER_MMC) 21 #define DISK_NAME "SD2" 22 #else 23 #error "Failed to select DISK access type" 24 #endif 25 26 #define FATFS_MNTP "/"DISK_NAME":" 27 #if defined(CONFIG_FS_FATFS_LFN) 28 #define TEST_FILE FATFS_MNTP \ 29 "/testlongfilenamethatsmuchlongerthan8.3chars.text" 30 #else 31 #define TEST_FILE FATFS_MNTP"/testfile.txt" 32 #endif /* CONFIG_FS_FATFS_LFN */ 33 #define TEST_DIR FATFS_MNTP"/testdir" 34 #define TEST_DIR_FILE FATFS_MNTP"/testdir/testfile.txt" 35 36 extern struct fs_file_t filep; 37 extern const char test_str[]; 38 /* FatFs work area */ 39 extern FATFS fat_fs; 40 41 int check_file_dir_exists(const char *path); 42 int wipe_partition(void); 43 44 void test_fat_mount(void); 45 void test_fat_unmount(void); 46 void test_fat_file(void); 47 void test_fat_dir(void); 48 void test_fat_fs(void); 49 void test_fat_rename(void); 50 #ifdef CONFIG_FS_FATFS_REENTRANT 51 void test_fat_file_reentrant(void); 52 #endif /* CONFIG_FS_FATFS_REENTRANT */ 53