From f67b2539ff2df0b3b05829bc2ccd323fe1047739 Mon Sep 17 00:00:00 2001 From: gengzhuangzhuang Date: Wed, 30 Jul 2025 19:59:18 +0800 Subject: [PATCH] fix dfs UT Signed-off-by: gengzhuangzhuang --- .../src/copy/file_copy_manager.cpp | 2 +- .../src/copy/remote_file_copy_manager.cpp | 2 +- .../copy/file_copy_manager_test.cpp | 13 +++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/frameworks/native/distributed_file_inner/src/copy/file_copy_manager.cpp b/frameworks/native/distributed_file_inner/src/copy/file_copy_manager.cpp index 7e45728b9..3e5c7e5a6 100644 --- a/frameworks/native/distributed_file_inner/src/copy/file_copy_manager.cpp +++ b/frameworks/native/distributed_file_inner/src/copy/file_copy_manager.cpp @@ -339,7 +339,7 @@ bool FileCopyManager::IsFile(const std::string &path) struct stat buf {}; int ret = stat(path.c_str(), &buf); if (ret == -1) { - LOGI("stat failed, errno is %{public}d, ", errno); + LOGE("stat failed, errno is %{public}d, ", errno); return false; } return (buf.st_mode & S_IFMT) == S_IFREG; diff --git a/frameworks/native/distributed_file_inner/src/copy/remote_file_copy_manager.cpp b/frameworks/native/distributed_file_inner/src/copy/remote_file_copy_manager.cpp index d7f0b9320..dc0418755 100644 --- a/frameworks/native/distributed_file_inner/src/copy/remote_file_copy_manager.cpp +++ b/frameworks/native/distributed_file_inner/src/copy/remote_file_copy_manager.cpp @@ -101,7 +101,7 @@ bool RemoteFileCopyManager::IsFile(const std::string &path) struct stat buf {}; int ret = stat(path.c_str(), &buf); if (ret == -1) { - LOGI("stat failed, errno is %{public}d, ", errno); + LOGE("stat failed, errno is %{public}d, ", errno); return false; } return (buf.st_mode & S_IFMT) == S_IFREG; diff --git a/test/unittests/distributed_file_inner/copy/file_copy_manager_test.cpp b/test/unittests/distributed_file_inner/copy/file_copy_manager_test.cpp index 501f247d7..4cfeae8b3 100644 --- a/test/unittests/distributed_file_inner/copy/file_copy_manager_test.cpp +++ b/test/unittests/distributed_file_inner/copy/file_copy_manager_test.cpp @@ -181,7 +181,7 @@ HWTEST_F(FileCopyManagerTest, FileCopyManager_Copy_0004, TestSize.Level0) * @tc.type: FUNC * @tc.require: I7TDJK */ -HWTEST_F(FileCopyManagerTest, FileCopyManager_Copy_0006, TestSize.Level0) +HWTEST_F(FileCopyManagerTest, FileCopyManager_Copy_0005, TestSize.Level0) { GTEST_LOG_(INFO) << "FileCopyManager_Copy_0005 Start"; string localUri = "/data/test/test.txt"; @@ -203,14 +203,14 @@ HWTEST_F(FileCopyManagerTest, FileCopyManager_Copy_0006, TestSize.Level0) } /** - * @tc.name: FileCopyManager_Copy_0007 + * @tc.name: FileCopyManager_Copy_0006 * @tc.desc: The execution of the Copy failed. * @tc.type: FUNC * @tc.require: I7TDJK */ -HWTEST_F(FileCopyManagerTest, FileCopyManager_Copy_0007, TestSize.Level0) +HWTEST_F(FileCopyManagerTest, FileCopyManager_Copy_0006, TestSize.Level0) { - GTEST_LOG_(INFO) << "FileCopyManager_Copy_0007 Start"; + GTEST_LOG_(INFO) << "FileCopyManager_Copy_0006 Start"; string srcUri = "file://docs/storage/media/100/local/files/Docs/1.txt"; string destUri = "file://docs/storage/media/100/local/files/Docs/a1.txt"; string srcPath = "/storage/media/100/local/files/Docs/1.txt"; @@ -222,7 +222,7 @@ HWTEST_F(FileCopyManagerTest, FileCopyManager_Copy_0007, TestSize.Level0) ret = Storage::DistributedFile::FileCopyManager::GetInstance()->Copy(srcUri, destUri, listener_); EXPECT_EQ(ret, ENOENT); - GTEST_LOG_(INFO) << "FileCopyManager_Copy_0007 End"; + GTEST_LOG_(INFO) << "FileCopyManager_Copy_0006 End"; } /** @@ -364,7 +364,7 @@ HWTEST_F(FileCopyManagerTest, FileCopyManager_ExecLocal_0003, TestSize.Level0) infos->srcUriIsFile, processCallback); // srcUriIsFile is true, destpath not exist auto ret = Storage::DistributedFile::FileCopyManager::GetInstance()->ExecLocal(infos); - EXPECT_EQ(ret, ENOTDIR); + EXPECT_NE(ret, E_OK); ASSERT_EQ(remove(srcpath.c_str()), 0); ASSERT_EQ(remove(destpath.c_str()), 0); GTEST_LOG_(INFO) << "FileCopyManager_ExecLocal_0003 End"; @@ -1003,6 +1003,7 @@ HWTEST_F(FileCopyManagerTest, FileCopyManager_Cancel_0004, TestSize.Level0) destUri = "destUri1"; ret = Storage::DistributedFile::FileCopyManager::GetInstance()->Cancel(srcUri, destUri); EXPECT_EQ(ret, E_OK); + Storage::DistributedFile::FileCopyManager::GetInstance()->FileInfosVec_.clear(); GTEST_LOG_(INFO) << "FileCopyManager_Cancel_0004 End"; } -- Gitee