Skip to content

Commit d1efa2a

Browse files
committed
fix(sdcard): correct author name in diagram files and remove obsolete test function
1 parent d18804f commit d1efa2a

File tree

4 files changed

+17
-70
lines changed

4 files changed

+17
-70
lines changed

tests/validation/sdcard/diagram.esp32.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"version": 1,
3-
"author": "Jakub Andrysek",
3+
"author": "Jakub Andrýsek",
44
"editor": "wokwi",
55
"parts": [
66
{

tests/validation/sdcard/diagram.esp32c3.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
[ "sd1:DI", "esp32:6", "green", [ "v0.09", "h-142.56" ] ],
2828
[ "sd1:CS", "esp32:7", "green", [ "h-57.66", "v-9.3" ] ],
2929
[ "sd1:VCC", "esp32:3V3", "red", [ "v11", "h-124.94", "v132.15" ] ],
30-
[ "sd1:VCC", "esp32:3V3.2", "red", [ "h-28.8", "v-124.94", "h-172.8", "v57.6", "h18.22" ] ],
3130
[ "sd1:GND", "esp32:GND.7", "black", [ "h0" ] ]
3231
],
3332
"dependencies": {}

tests/validation/sdcard/diagram.esp32s2.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
2525
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
2626
[ "sd1:GND", "esp32:GND.1", "black", [ "v-0.11", "h-96", "v115.2", "h-105.33" ] ],
27-
[ "sd1:DI", "esp32:23", "green", [ "v14", "h6" ] ],
2827
[ "sd1:VCC", "esp32:3V3", "red", [ "v-0.14", "h-38.4", "v-105.6", "h-162.93" ] ],
2928
[ "sd1:CS", "esp32:34", "green", [ "h-86.4", "v-0.06" ] ],
3029
[ "sd1:DI", "esp32:35", "green", [ "h-76.8", "v0.09" ] ],

tests/validation/sdcard/sdcard.ino

Lines changed: 16 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ void test_nonexistent_spi_interface(void) {
9393
void run_multiple_ways(SpiTestFunction test_function, uint8_t max_files = MAX_FILES, bool format_if_empty = false) {
9494
run_first_init(test_function, max_files, format_if_empty);
9595
run_init_continuous(test_function, max_files, format_if_empty);
96-
test_nonexistent_spi_interface();
9796
}
9897

9998
void test_sd_basic(void) {
@@ -316,73 +315,16 @@ void test_sd_nested_directories(void) {
316315
});
317316
}
318317

319-
void test_sd_file_count_in_directoryOLD(void) {
320-
Serial.println("Running test_sd_file_count_in_directory");
321-
322-
run_multiple_ways([](SPITestConfig &config) {
323-
// Create test directory
324-
TEST_ASSERT_TRUE_MESSAGE(config.sd->mkdir("/counttest"), "Failed to create /counttest");
325-
326-
// Function to count files in directory
327-
auto countFilesInDir = [&config](const char *dirPath) -> int {
328-
File dir = config.sd->open(dirPath);
329-
if (!dir || !dir.isDirectory()) {
330-
return -1;
331-
}
332-
333-
int count = 0;
334-
File entry = dir.openNextFile();
335-
while (entry) {
336-
if (!entry.isDirectory()) {
337-
count++;
338-
}
339-
entry.close();
340-
entry = dir.openNextFile();
341-
}
342-
dir.close();
343-
return count;
344-
};
345-
346-
// Initially should be empty
347-
TEST_ASSERT_EQUAL_MESSAGE(0, countFilesInDir("/counttest"), "Directory should initially be empty");
348-
349-
// Create files one by one and verify count
350-
for (int i = 1; i <= 5; i++) {
351-
char filename[50];
352-
snprintf(filename, sizeof(filename), "/counttest/file_%d.txt", i);
353-
354-
File file = config.sd->open(filename, FILE_WRITE);
355-
TEST_ASSERT_TRUE_MESSAGE(file, "Failed to create numbered file");
356-
file.printf("Content of file %d", i);
357-
file.close();
358-
359-
TEST_ASSERT_EQUAL_MESSAGE(i, countFilesInDir("/counttest"), "File count mismatch after creating file");
360-
}
361-
362-
// Create a subdirectory (should not affect file count)
363-
TEST_ASSERT_TRUE_MESSAGE(config.sd->mkdir("/counttest/subdir"), "Failed to create subdirectory");
364-
TEST_ASSERT_EQUAL_MESSAGE(5, countFilesInDir("/counttest"), "File count should not change with subdirectory");
365-
366-
// Remove files one by one and verify count
367-
for (int i = 5; i >= 1; i--) {
368-
char filename[50];
369-
snprintf(filename, sizeof(filename), "/counttest/file_%d.txt", i);
370-
371-
TEST_ASSERT_TRUE_MESSAGE(config.sd->remove(filename), "Failed to remove numbered file");
372-
TEST_ASSERT_EQUAL_MESSAGE(i - 1, countFilesInDir("/counttest"), "File count mismatch after removing file");
373-
}
374-
375-
// Clean up
376-
TEST_ASSERT_TRUE_MESSAGE(config.sd->rmdir("/counttest/subdir"), "Failed to remove subdirectory");
377-
TEST_ASSERT_TRUE_MESSAGE(config.sd->rmdir("/counttest"), "Failed to remove test directory");
378-
});
379-
}
380-
381318
void test_sd_file_count_in_directory(void) {
382319
Serial.println("Running test_sd_file_count_in_directory");
383320
run_multiple_ways([](SPITestConfig &config) {
384321
const char *fileBasePath = "/dir/a/b";
385322
const int numFiles = 5;
323+
324+
auto getExpectedFile = [fileBasePath](int i) -> std::pair<String, String> {
325+
return {String(fileBasePath) + "/file" + String(i) + ".txt", "data:" + String(i)};
326+
};
327+
386328
{
387329
// create nested directories
388330
TEST_ASSERT_TRUE_MESSAGE(config.sd->mkdir("/dir"), "mkdir /dir failed");
@@ -404,10 +346,6 @@ void test_sd_file_count_in_directory(void) {
404346
File d = config.sd->open(fileBasePath);
405347
TEST_ASSERT_TRUE_MESSAGE(d && d.isDirectory(), "open(/dir/a/b) not a directory");
406348

407-
auto getExpectedFile = [fileBasePath](int i) -> std::pair<String, String> {
408-
return {String(fileBasePath) + "/file" + String(i) + ".txt", "data:" + String(i)};
409-
};
410-
411349
bool found[numFiles] = {false};
412350
int count = 0;
413351

@@ -446,6 +384,16 @@ void test_sd_file_count_in_directory(void) {
446384
TEST_ASSERT_TRUE_MESSAGE(found[i], ("Expected file not found: " + expectedPath).c_str());
447385
}
448386
}
387+
388+
// Cleanup: remove files and directories in reverse order (deepest first)
389+
for (int i = 0; i < numFiles; ++i) {
390+
auto [filePath, _] = getExpectedFile(i);
391+
TEST_ASSERT_TRUE_MESSAGE(config.sd->remove(filePath.c_str()), ("Failed to remove file: " + filePath).c_str());
392+
}
393+
// Remove directories
394+
TEST_ASSERT_TRUE_MESSAGE(config.sd->rmdir("/dir/a/b"), "Failed to remove directory: /dir/a/b");
395+
TEST_ASSERT_TRUE_MESSAGE(config.sd->rmdir("/dir/a"), "Failed to remove directory: /dir/a");
396+
TEST_ASSERT_TRUE_MESSAGE(config.sd->rmdir("/dir"), "Failed to remove directory: /dir");
449397
});
450398
}
451399

@@ -575,6 +523,7 @@ void setup() {
575523
#endif
576524

577525
UNITY_BEGIN();
526+
RUN_TEST(test_nonexistent_spi_interface);
578527
RUN_TEST(test_sd_basic);
579528
RUN_TEST(test_sd_dir);
580529
RUN_TEST(test_sd_file_operations);

0 commit comments

Comments
 (0)