Skip to content

Commit

Permalink
Removed check for . and .. enteries in filesystem test
Browse files Browse the repository at this point in the history
ChanFs -  Dot entries ("." and "..") in the sub-directory are filtered out and
they will never appear in the read items
  • Loading branch information
Deepika committed Nov 17, 2017
1 parent 2900de1 commit 2f7660c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 35 deletions.
36 changes: 12 additions & 24 deletions TESTS/filesystem/dirs/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,18 +260,12 @@ void test_multi_block_directory() {
TEST_ASSERT_EQUAL(0, res);
res = dir[0].open(&fs, "cactus");
TEST_ASSERT_EQUAL(0, 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);
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);

#if (MBED_TEST_FILESYSTEM != FATFileSystem)
char *dir_list[] = {".", ".."};
dir_file_check(dir_list, (sizeof(dir_list)/sizeof(dir_list[0])));
#endif

for (int i = 0; i < 128; i++) {
sprintf((char*)buffer, "test%d", i);
res = dir[0].read(&ent);
Expand Down Expand Up @@ -308,18 +302,12 @@ void test_directory_remove() {
TEST_ASSERT_EQUAL(0, res);
res = dir[0].open(&fs, "potato");
TEST_ASSERT_EQUAL(0, 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);
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);

#if (MBED_TEST_FILESYSTEM != FATFileSystem)
char *dir_list[] = {".", ".."};
dir_file_check(dir_list, (sizeof(dir_list)/sizeof(dir_list[0])));
#endif

res = dir[0].read(&ent);
TEST_ASSERT_EQUAL(0, res);
res = dir[0].close();
Expand Down
15 changes: 4 additions & 11 deletions TESTS/filesystem/fopen/fopen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ int32_t fsfat_filepath_remove_all(char* filepath)
pos = fpathbuf + strlen(fpathbuf);
while (pos != fpathbuf) {
/* 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) {
break;
if (strlen(fpathbuf) == strlen(FSFAT_FOPEN_TEST_MOUNT_PT_PATH)) {
if( strncmp(fpathbuf, FSFAT_FOPEN_TEST_MOUNT_PT_PATH, strlen(fpathbuf)) == 0) {
break;
}
}
ret = remove(fpathbuf);
pos = strrchr(fpathbuf, '/');
Expand Down Expand Up @@ -1100,15 +1102,6 @@ control_t fsfat_fopen_test_12(const size_t call_count)
*pos = '\0';
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) {
FSFAT_DBGLOG("%s: filename: \"%s\"\n", __func__, dp->d_name);
TEST_ASSERT_MESSAGE(dp != 0, "Error: readdir() failed\n");
Expand Down

0 comments on commit 2f7660c

Please sign in to comment.