Removed check for . and .. enteries in filesystem test

ChanFs -  Dot entries ("." and "..") in the sub-directory are filtered out and
they will never appear in the read items
pull/7774/head
Deepika 2017-11-16 12:07:28 -06:00 committed by deepikabhavnani
parent 2900de1bdf
commit 2f7660cdf3
2 changed files with 16 additions and 35 deletions

View File

@ -260,18 +260,12 @@ void test_multi_block_directory() {
TEST_ASSERT_EQUAL(0, res); TEST_ASSERT_EQUAL(0, res);
res = dir[0].open(&fs, "cactus"); res = dir[0].open(&fs, "cactus");
TEST_ASSERT_EQUAL(0, res); TEST_ASSERT_EQUAL(0, res);
res = dir[0].read(&ent);
TEST_ASSERT_EQUAL(1, res); #if (MBED_TEST_FILESYSTEM != FATFileSystem)
res = strcmp(ent.d_name, "."); char *dir_list[] = {".", ".."};
TEST_ASSERT_EQUAL(0, res); dir_file_check(dir_list, (sizeof(dir_list)/sizeof(dir_list[0])));
res = ent.d_type; #endif
TEST_ASSERT_EQUAL(DT_DIR, res);
res = dir[0].read(&ent);
TEST_ASSERT_EQUAL(1, res);
res = strcmp(ent.d_name, "..");
TEST_ASSERT_EQUAL(0, res);
res = ent.d_type;
TEST_ASSERT_EQUAL(DT_DIR, res);
for (int i = 0; i < 128; i++) { for (int i = 0; i < 128; i++) {
sprintf((char*)buffer, "test%d", i); sprintf((char*)buffer, "test%d", i);
res = dir[0].read(&ent); res = dir[0].read(&ent);
@ -308,18 +302,12 @@ void test_directory_remove() {
TEST_ASSERT_EQUAL(0, res); TEST_ASSERT_EQUAL(0, res);
res = dir[0].open(&fs, "potato"); res = dir[0].open(&fs, "potato");
TEST_ASSERT_EQUAL(0, res); TEST_ASSERT_EQUAL(0, res);
res = dir[0].read(&ent);
TEST_ASSERT_EQUAL(1, res); #if (MBED_TEST_FILESYSTEM != FATFileSystem)
res = strcmp(ent.d_name, "."); char *dir_list[] = {".", ".."};
TEST_ASSERT_EQUAL(0, res); dir_file_check(dir_list, (sizeof(dir_list)/sizeof(dir_list[0])));
res = ent.d_type; #endif
TEST_ASSERT_EQUAL(DT_DIR, res);
res = dir[0].read(&ent);
TEST_ASSERT_EQUAL(1, res);
res = strcmp(ent.d_name, "..");
TEST_ASSERT_EQUAL(0, res);
res = ent.d_type;
TEST_ASSERT_EQUAL(DT_DIR, res);
res = dir[0].read(&ent); res = dir[0].read(&ent);
TEST_ASSERT_EQUAL(0, res); TEST_ASSERT_EQUAL(0, res);
res = dir[0].close(); res = dir[0].close();

View File

@ -207,8 +207,10 @@ int32_t fsfat_filepath_remove_all(char* filepath)
pos = fpathbuf + strlen(fpathbuf); pos = fpathbuf + strlen(fpathbuf);
while (pos != fpathbuf) { while (pos != fpathbuf) {
/* If the remaining file path is the mount point path then finish as the mount point cannot be removed */ /* If the remaining file path is the mount point path then finish as the mount point cannot be removed */
if (strlen(fpathbuf) == strlen(FSFAT_FOPEN_TEST_MOUNT_PT_PATH) && strncmp(fpathbuf, FSFAT_FOPEN_TEST_MOUNT_PT_PATH, strlen(fpathbuf)) == 0) { if (strlen(fpathbuf) == strlen(FSFAT_FOPEN_TEST_MOUNT_PT_PATH)) {
break; if( strncmp(fpathbuf, FSFAT_FOPEN_TEST_MOUNT_PT_PATH, strlen(fpathbuf)) == 0) {
break;
}
} }
ret = remove(fpathbuf); ret = remove(fpathbuf);
pos = strrchr(fpathbuf, '/'); pos = strrchr(fpathbuf, '/');
@ -1100,15 +1102,6 @@ control_t fsfat_fopen_test_12(const size_t call_count)
*pos = '\0'; *pos = '\0';
dir = opendir(buf); dir = opendir(buf);
dp = readdir(dir);
TEST_ASSERT_MESSAGE(dp != 0, "Error: readdir() failed\n");
FSFAT_TEST_UTEST_MESSAGE(fsfat_fopen_utest_msg_g, FSFAT_UTEST_MSG_BUF_SIZE, "%s:Error: unexpected object name (name=%s, expected=%s).\n", __func__, dp->d_name, ".");
TEST_ASSERT_MESSAGE(strncmp(dp->d_name, ".", strlen(".")) == 0, fsfat_fopen_utest_msg_g);
dp = readdir(dir);
TEST_ASSERT_MESSAGE(dp != 0, "Error: readdir() failed\n");
FSFAT_TEST_UTEST_MESSAGE(fsfat_fopen_utest_msg_g, FSFAT_UTEST_MSG_BUF_SIZE, "%s:Error: unexpected object name (name=%s, expected=%s).\n", __func__, dp->d_name, "..");
TEST_ASSERT_MESSAGE(strncmp(dp->d_name, "..", strlen("..")) == 0, fsfat_fopen_utest_msg_g);
while ((dp = readdir(dir)) != NULL) { while ((dp = readdir(dir)) != NULL) {
FSFAT_DBGLOG("%s: filename: \"%s\"\n", __func__, dp->d_name); FSFAT_DBGLOG("%s: filename: \"%s\"\n", __func__, dp->d_name);
TEST_ASSERT_MESSAGE(dp != 0, "Error: readdir() failed\n"); TEST_ASSERT_MESSAGE(dp != 0, "Error: readdir() failed\n");