Skip to content

Commit d6b1d0b

Browse files
committed
fatfs/test: enable tests on SD card
1 parent e20e64a commit d6b1d0b

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

components/fatfs/test/test_fatfs_sdmmc.c

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ static void test_teardown(void)
5151
}
5252

5353
static const char* test_filename = "/sdcard/hello.txt";
54-
static const char* test_filename_utf_8 = "/sdcard/测试文件.txt";
5554

56-
TEST_CASE("Mount fails cleanly without card inserted", "[fatfs][ignore]")
55+
TEST_CASE("Mount fails cleanly without card inserted", "[fatfs][sd][ignore]")
5756
{
5857
size_t heap_size;
5958
HEAP_SIZE_CAPTURE(heap_size);
@@ -65,22 +64,22 @@ TEST_CASE("Mount fails cleanly without card inserted", "[fatfs][ignore]")
6564
};
6665

6766
for (int i = 0; i < 3; ++i) {
68-
printf("Initializing card, attempt %d ", i);
67+
printf("Initializing card, attempt %d\n", i);
6968
esp_err_t err = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, NULL);
70-
printf(" err=%d\n", err);
71-
TEST_ESP_ERR(ESP_FAIL, err);
69+
printf("err=%d\n", err);
70+
TEST_ESP_ERR(ESP_ERR_TIMEOUT, err);
7271
}
7372
HEAP_SIZE_CHECK(heap_size, 0);
7473
}
7574

76-
TEST_CASE("(SD) can create and write file", "[fatfs][sdcard][ignore]")
75+
TEST_CASE("(SD) can create and write file", "[fatfs][sd][test_env=UT_T1_SDMODE]")
7776
{
7877
test_setup();
7978
test_fatfs_create_file_with_text(test_filename, fatfs_test_hello_str);
8079
test_teardown();
8180
}
8281

83-
TEST_CASE("(SD) can read file", "[fatfs][ignore]")
82+
TEST_CASE("(SD) can read file", "[fatfs][test_env=UT_T1_SDMODE]")
8483
{
8584
test_setup();
8685
test_fatfs_create_file_with_text(test_filename, fatfs_test_hello_str);
@@ -89,64 +88,64 @@ TEST_CASE("(SD) can read file", "[fatfs][ignore]")
8988
}
9089

9190

92-
TEST_CASE("(SD) overwrite and append file", "[fatfs][sdcard][ignore]")
91+
TEST_CASE("(SD) overwrite and append file", "[fatfs][sd][test_env=UT_T1_SDMODE]")
9392
{
9493
test_setup();
9594
test_fatfs_overwrite_append(test_filename);
9695
test_teardown();
9796
}
9897

9998

100-
TEST_CASE("(SD) can lseek", "[fatfs][sdcard][ignore]")
99+
TEST_CASE("(SD) can lseek", "[fatfs][sd][test_env=UT_T1_SDMODE]")
101100
{
102101
test_setup();
103102
test_fatfs_lseek("/sdcard/seek.txt");
104103
test_teardown();
105104
}
106105

107-
TEST_CASE("(SD) stat returns correct values", "[fatfs][ignore]")
106+
TEST_CASE("(SD) stat returns correct values", "[fatfs][test_env=UT_T1_SDMODE]")
108107
{
109108
test_setup();
110109
test_fatfs_stat("/sdcard/stat.txt", "/sdcard");
111110
test_teardown();
112111
}
113112

114-
TEST_CASE("(SD) unlink removes a file", "[fatfs][ignore]")
113+
TEST_CASE("(SD) unlink removes a file", "[fatfs][test_env=UT_T1_SDMODE]")
115114
{
116115
test_setup();
117116
test_fatfs_unlink("/sdcard/unlink.txt");
118117
test_teardown();
119118
}
120119

121-
TEST_CASE("(SD) link copies a file, rename moves a file", "[fatfs][ignore]")
120+
TEST_CASE("(SD) link copies a file, rename moves a file", "[fatfs][test_env=UT_T1_SDMODE]")
122121
{
123122
test_setup();
124123
test_fatfs_link_rename("/sdcard/link");
125124
test_teardown();
126125
}
127126

128-
TEST_CASE("(SD) can create and remove directories", "[fatfs][ignore]")
127+
TEST_CASE("(SD) can create and remove directories", "[fatfs][test_env=UT_T1_SDMODE]")
129128
{
130129
test_setup();
131130
test_fatfs_mkdir_rmdir("/sdcard/dir");
132131
test_teardown();
133132
}
134133

135-
TEST_CASE("(SD) can opendir root directory of FS", "[fatfs][ignore]")
134+
TEST_CASE("(SD) can opendir root directory of FS", "[fatfs][test_env=UT_T1_SDMODE]")
136135
{
137136
test_setup();
138137
test_fatfs_can_opendir("/sdcard");
139138
test_teardown();
140139
}
141140

142-
TEST_CASE("(SD) opendir, readdir, rewinddir, seekdir work as expected", "[fatfs][ignore]")
141+
TEST_CASE("(SD) opendir, readdir, rewinddir, seekdir work as expected", "[fatfs][test_env=UT_T1_SDMODE]")
143142
{
144143
test_setup();
145144
test_fatfs_opendir_readdir_rewinddir("/sdcard/dir");
146145
test_teardown();
147146
}
148147

149-
TEST_CASE("(SD) multiple tasks can use same volume", "[fatfs][ignore]")
148+
TEST_CASE("(SD) multiple tasks can use same volume", "[fatfs][test_env=UT_T1_SDMODE]")
150149
{
151150
test_setup();
152151
test_fatfs_concurrent("/sdcard/f");
@@ -155,7 +154,7 @@ TEST_CASE("(SD) multiple tasks can use same volume", "[fatfs][ignore]")
155154

156155
static void speed_test(void* buf, size_t buf_size, size_t file_size, bool write);
157156

158-
TEST_CASE("(SD) write/read speed test", "[fatfs][sdcard][ignore]")
157+
TEST_CASE("(SD) write/read speed test", "[fatfs][sd][test_env=UT_T1_SDMODE]")
159158
{
160159
size_t heap_size;
161160
HEAP_SIZE_CAPTURE(heap_size);
@@ -165,7 +164,7 @@ TEST_CASE("(SD) write/read speed test", "[fatfs][sdcard][ignore]")
165164
for (size_t i = 0; i < buf_size / 4; ++i) {
166165
buf[i] = esp_random();
167166
}
168-
const size_t file_size = 4 * 1024 * 1024;
167+
const size_t file_size = 1 * 1024 * 1024;
169168

170169
speed_test(buf, 4 * 1024, file_size, true);
171170
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)
197196
TEST_ESP_OK(esp_vfs_fat_sdmmc_unmount());
198197
}
199198

200-
TEST_CASE("(SD) mount two FAT partitions, SDMMC and WL, at the same time", "[fatfs][sdcard][ignore]")
199+
TEST_CASE("(SD) mount two FAT partitions, SDMMC and WL, at the same time", "[fatfs][sd][test_env=UT_T1_SDMODE]")
201200
{
202201
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
203202
.format_if_mount_failed = true,
@@ -248,7 +247,10 @@ TEST_CASE("(SD) mount two FAT partitions, SDMMC and WL, at the same time", "[fat
248247
* Ensure that the text editor is UTF-8 compatible when compiling these tests.
249248
*/
250249
#if defined(CONFIG_FATFS_API_ENCODING_UTF_8) && (CONFIG_FATFS_CODEPAGE == 936)
251-
TEST_CASE("(SD) can read file using UTF-8 encoded strings", "[fatfs][ignore]")
250+
251+
static const char* test_filename_utf_8 = "/sdcard/测试文件.txt";
252+
253+
TEST_CASE("(SD) can read file using UTF-8 encoded strings", "[fatfs][sd][test_env=UT_T1_SDMODE]")
252254
{
253255
test_setup();
254256
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-
262264
test_fatfs_opendir_readdir_rewinddir_utf_8("/sdcard/目录");
263265
test_teardown();
264266
}
265-
#endif
267+
#endif // CONFIG_FATFS_API_ENCODING_UTF_8 && CONFIG_FATFS_CODEPAGE == 936

0 commit comments

Comments
 (0)