mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #13949 from LDong-Arm/fat_filesystem_test_fix
Fix mbed::Dir type handling in fat_filesystempull/13965/head
commit
66ca70af94
|
@ -134,28 +134,28 @@ void test_read_dir()
|
||||||
err = dir.open(&fs, "test_read_dir");
|
err = dir.open(&fs, "test_read_dir");
|
||||||
TEST_ASSERT_EQUAL(0, err);
|
TEST_ASSERT_EQUAL(0, err);
|
||||||
|
|
||||||
struct dirent *de;
|
struct dirent de;
|
||||||
bool test_dir_found = false;
|
bool test_dir_found = false;
|
||||||
bool test_file_found = true;
|
bool test_file_found = true;
|
||||||
|
|
||||||
while ((de = readdir(&dir))) {
|
while (dir.read(&de) == 1) {
|
||||||
printf("d_name: %.32s, d_type: %x\n", de->d_name, de->d_type);
|
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_dir_found = true;
|
||||||
TEST_ASSERT_EQUAL(DT_DIR, de->d_type);
|
TEST_ASSERT_EQUAL(DT_DIR, de.d_type);
|
||||||
} else if (strcmp(de->d_name, "..") == 0) {
|
} else if (strcmp(de.d_name, "..") == 0) {
|
||||||
test_dir_found = true;
|
test_dir_found = true;
|
||||||
TEST_ASSERT_EQUAL(DT_DIR, de->d_type);
|
TEST_ASSERT_EQUAL(DT_DIR, de.d_type);
|
||||||
} else if (strcmp(de->d_name, "test_dir") == 0) {
|
} else if (strcmp(de.d_name, "test_dir") == 0) {
|
||||||
test_dir_found = true;
|
test_dir_found = true;
|
||||||
TEST_ASSERT_EQUAL(DT_DIR, de->d_type);
|
TEST_ASSERT_EQUAL(DT_DIR, de.d_type);
|
||||||
} else if (strcmp(de->d_name, "test_file") == 0) {
|
} else if (strcmp(de.d_name, "test_file") == 0) {
|
||||||
test_file_found = true;
|
test_file_found = true;
|
||||||
TEST_ASSERT_EQUAL(DT_REG, de->d_type);
|
TEST_ASSERT_EQUAL(DT_REG, de.d_type);
|
||||||
} else {
|
} else {
|
||||||
char *buf = new char[NAME_MAX];
|
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);
|
TEST_ASSERT_MESSAGE(false, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue