mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fatfs/test: enable tests on SD card
This commit is contained in:
parent
e20e64ace9
commit
d6b1d0bb3d
@ -51,9 +51,8 @@ static void test_teardown(void)
|
||||
}
|
||||
|
||||
static const char* test_filename = "/sdcard/hello.txt";
|
||||
static const char* test_filename_utf_8 = "/sdcard/测试文件.txt";
|
||||
|
||||
TEST_CASE("Mount fails cleanly without card inserted", "[fatfs][ignore]")
|
||||
TEST_CASE("Mount fails cleanly without card inserted", "[fatfs][sd][ignore]")
|
||||
{
|
||||
size_t heap_size;
|
||||
HEAP_SIZE_CAPTURE(heap_size);
|
||||
@ -65,22 +64,22 @@ TEST_CASE("Mount fails cleanly without card inserted", "[fatfs][ignore]")
|
||||
};
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
printf("Initializing card, attempt %d ", i);
|
||||
printf("Initializing card, attempt %d\n", i);
|
||||
esp_err_t err = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, NULL);
|
||||
printf(" err=%d\n", err);
|
||||
TEST_ESP_ERR(ESP_FAIL, err);
|
||||
printf("err=%d\n", err);
|
||||
TEST_ESP_ERR(ESP_ERR_TIMEOUT, err);
|
||||
}
|
||||
HEAP_SIZE_CHECK(heap_size, 0);
|
||||
}
|
||||
|
||||
TEST_CASE("(SD) can create and write file", "[fatfs][sdcard][ignore]")
|
||||
TEST_CASE("(SD) can create and write file", "[fatfs][sd][test_env=UT_T1_SDMODE]")
|
||||
{
|
||||
test_setup();
|
||||
test_fatfs_create_file_with_text(test_filename, fatfs_test_hello_str);
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
TEST_CASE("(SD) can read file", "[fatfs][ignore]")
|
||||
TEST_CASE("(SD) can read file", "[fatfs][test_env=UT_T1_SDMODE]")
|
||||
{
|
||||
test_setup();
|
||||
test_fatfs_create_file_with_text(test_filename, fatfs_test_hello_str);
|
||||
@ -89,7 +88,7 @@ TEST_CASE("(SD) can read file", "[fatfs][ignore]")
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("(SD) overwrite and append file", "[fatfs][sdcard][ignore]")
|
||||
TEST_CASE("(SD) overwrite and append file", "[fatfs][sd][test_env=UT_T1_SDMODE]")
|
||||
{
|
||||
test_setup();
|
||||
test_fatfs_overwrite_append(test_filename);
|
||||
@ -97,56 +96,56 @@ TEST_CASE("(SD) overwrite and append file", "[fatfs][sdcard][ignore]")
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("(SD) can lseek", "[fatfs][sdcard][ignore]")
|
||||
TEST_CASE("(SD) can lseek", "[fatfs][sd][test_env=UT_T1_SDMODE]")
|
||||
{
|
||||
test_setup();
|
||||
test_fatfs_lseek("/sdcard/seek.txt");
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
TEST_CASE("(SD) stat returns correct values", "[fatfs][ignore]")
|
||||
TEST_CASE("(SD) stat returns correct values", "[fatfs][test_env=UT_T1_SDMODE]")
|
||||
{
|
||||
test_setup();
|
||||
test_fatfs_stat("/sdcard/stat.txt", "/sdcard");
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
TEST_CASE("(SD) unlink removes a file", "[fatfs][ignore]")
|
||||
TEST_CASE("(SD) unlink removes a file", "[fatfs][test_env=UT_T1_SDMODE]")
|
||||
{
|
||||
test_setup();
|
||||
test_fatfs_unlink("/sdcard/unlink.txt");
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
TEST_CASE("(SD) link copies a file, rename moves a file", "[fatfs][ignore]")
|
||||
TEST_CASE("(SD) link copies a file, rename moves a file", "[fatfs][test_env=UT_T1_SDMODE]")
|
||||
{
|
||||
test_setup();
|
||||
test_fatfs_link_rename("/sdcard/link");
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
TEST_CASE("(SD) can create and remove directories", "[fatfs][ignore]")
|
||||
TEST_CASE("(SD) can create and remove directories", "[fatfs][test_env=UT_T1_SDMODE]")
|
||||
{
|
||||
test_setup();
|
||||
test_fatfs_mkdir_rmdir("/sdcard/dir");
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
TEST_CASE("(SD) can opendir root directory of FS", "[fatfs][ignore]")
|
||||
TEST_CASE("(SD) can opendir root directory of FS", "[fatfs][test_env=UT_T1_SDMODE]")
|
||||
{
|
||||
test_setup();
|
||||
test_fatfs_can_opendir("/sdcard");
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
TEST_CASE("(SD) opendir, readdir, rewinddir, seekdir work as expected", "[fatfs][ignore]")
|
||||
TEST_CASE("(SD) opendir, readdir, rewinddir, seekdir work as expected", "[fatfs][test_env=UT_T1_SDMODE]")
|
||||
{
|
||||
test_setup();
|
||||
test_fatfs_opendir_readdir_rewinddir("/sdcard/dir");
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
TEST_CASE("(SD) multiple tasks can use same volume", "[fatfs][ignore]")
|
||||
TEST_CASE("(SD) multiple tasks can use same volume", "[fatfs][test_env=UT_T1_SDMODE]")
|
||||
{
|
||||
test_setup();
|
||||
test_fatfs_concurrent("/sdcard/f");
|
||||
@ -155,7 +154,7 @@ TEST_CASE("(SD) multiple tasks can use same volume", "[fatfs][ignore]")
|
||||
|
||||
static void speed_test(void* buf, size_t buf_size, size_t file_size, bool write);
|
||||
|
||||
TEST_CASE("(SD) write/read speed test", "[fatfs][sdcard][ignore]")
|
||||
TEST_CASE("(SD) write/read speed test", "[fatfs][sd][test_env=UT_T1_SDMODE]")
|
||||
{
|
||||
size_t heap_size;
|
||||
HEAP_SIZE_CAPTURE(heap_size);
|
||||
@ -165,7 +164,7 @@ TEST_CASE("(SD) write/read speed test", "[fatfs][sdcard][ignore]")
|
||||
for (size_t i = 0; i < buf_size / 4; ++i) {
|
||||
buf[i] = esp_random();
|
||||
}
|
||||
const size_t file_size = 4 * 1024 * 1024;
|
||||
const size_t file_size = 1 * 1024 * 1024;
|
||||
|
||||
speed_test(buf, 4 * 1024, file_size, true);
|
||||
speed_test(buf, 8 * 1024, file_size, true);
|
||||
@ -197,7 +196,7 @@ static void speed_test(void* buf, size_t buf_size, size_t file_size, bool write)
|
||||
TEST_ESP_OK(esp_vfs_fat_sdmmc_unmount());
|
||||
}
|
||||
|
||||
TEST_CASE("(SD) mount two FAT partitions, SDMMC and WL, at the same time", "[fatfs][sdcard][ignore]")
|
||||
TEST_CASE("(SD) mount two FAT partitions, SDMMC and WL, at the same time", "[fatfs][sd][test_env=UT_T1_SDMODE]")
|
||||
{
|
||||
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
|
||||
.format_if_mount_failed = true,
|
||||
@ -248,7 +247,10 @@ TEST_CASE("(SD) mount two FAT partitions, SDMMC and WL, at the same time", "[fat
|
||||
* Ensure that the text editor is UTF-8 compatible when compiling these tests.
|
||||
*/
|
||||
#if defined(CONFIG_FATFS_API_ENCODING_UTF_8) && (CONFIG_FATFS_CODEPAGE == 936)
|
||||
TEST_CASE("(SD) can read file using UTF-8 encoded strings", "[fatfs][ignore]")
|
||||
|
||||
static const char* test_filename_utf_8 = "/sdcard/测试文件.txt";
|
||||
|
||||
TEST_CASE("(SD) can read file using UTF-8 encoded strings", "[fatfs][sd][test_env=UT_T1_SDMODE]")
|
||||
{
|
||||
test_setup();
|
||||
test_fatfs_create_file_with_text(test_filename_utf_8, fatfs_test_hello_str_utf);
|
||||
@ -262,4 +264,4 @@ TEST_CASE("(SD) opendir, readdir, rewinddir, seekdir work as expected using UTF-
|
||||
test_fatfs_opendir_readdir_rewinddir_utf_8("/sdcard/目录");
|
||||
test_teardown();
|
||||
}
|
||||
#endif
|
||||
#endif // CONFIG_FATFS_API_ENCODING_UTF_8 && CONFIG_FATFS_CODEPAGE == 936
|
||||
|
Loading…
Reference in New Issue
Block a user