From 2f7660cdf3abbb55d7dbb3bb67f858c05b835cb5 Mon Sep 17 00:00:00 2001 From: Deepika Date: Thu, 16 Nov 2017 12:07:28 -0600 Subject: [PATCH] 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 --- TESTS/filesystem/dirs/main.cpp | 36 +++++++++++--------------------- TESTS/filesystem/fopen/fopen.cpp | 15 ++++--------- 2 files changed, 16 insertions(+), 35 deletions(-) diff --git a/TESTS/filesystem/dirs/main.cpp b/TESTS/filesystem/dirs/main.cpp index e20af58..9a37cfa 100644 --- a/TESTS/filesystem/dirs/main.cpp +++ b/TESTS/filesystem/dirs/main.cpp @@ -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); @@ -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(); diff --git a/TESTS/filesystem/fopen/fopen.cpp b/TESTS/filesystem/fopen/fopen.cpp index fb533b1..9ef21d5 100644 --- a/TESTS/filesystem/fopen/fopen.cpp +++ b/TESTS/filesystem/fopen/fopen.cpp @@ -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, '/'); @@ -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");