Merge pull request from LDong-Arm/fat_filesystem_test_fix

Fix mbed::Dir type handling in fat_filesystem
pull/13965/head
Martin Kojtal 2020-11-25 14:38:18 +00:00 committed by GitHub
commit 66ca70af94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 12 deletions
storage/filesystem/fat/tests/TESTS/fat/fat_filesystem

View File

@ -134,28 +134,28 @@ void test_read_dir()
err = dir.open(&fs, "test_read_dir");
TEST_ASSERT_EQUAL(0, err);
struct dirent *de;
struct dirent de;
bool test_dir_found = false;
bool test_file_found = true;
while ((de = readdir(&dir))) {
printf("d_name: %.32s, d_type: %x\n", de->d_name, de->d_type);
while (dir.read(&de) == 1) {
printf("d_name: %.32s, d_type: %x\n", de.d_name, de.d_type);
if (strcmp(de->d_name, ".") == 0) {
if (strcmp(de.d_name, ".") == 0) {
test_dir_found = true;
TEST_ASSERT_EQUAL(DT_DIR, de->d_type);
} else if (strcmp(de->d_name, "..") == 0) {
TEST_ASSERT_EQUAL(DT_DIR, de.d_type);
} else if (strcmp(de.d_name, "..") == 0) {
test_dir_found = true;
TEST_ASSERT_EQUAL(DT_DIR, de->d_type);
} else if (strcmp(de->d_name, "test_dir") == 0) {
TEST_ASSERT_EQUAL(DT_DIR, de.d_type);
} else if (strcmp(de.d_name, "test_dir") == 0) {
test_dir_found = true;
TEST_ASSERT_EQUAL(DT_DIR, de->d_type);
} else if (strcmp(de->d_name, "test_file") == 0) {
TEST_ASSERT_EQUAL(DT_DIR, de.d_type);
} else if (strcmp(de.d_name, "test_file") == 0) {
test_file_found = true;
TEST_ASSERT_EQUAL(DT_REG, de->d_type);
TEST_ASSERT_EQUAL(DT_REG, de.d_type);
} else {
char *buf = new char[NAME_MAX];
snprintf(buf, NAME_MAX, "Unexpected file \"%s\"", de->d_name);
snprintf(buf, NAME_MAX, "Unexpected file \"%s\"", de.d_name);
TEST_ASSERT_MESSAGE(false, buf);
}
}