diff --git a/test/unittests/services_daemon/cloud_daemon_stub_test.cpp b/test/unittests/services_daemon/cloud_daemon_stub_test.cpp index 8082c1f7bf0ac0d5cedf7c3d290b628b85c1b1f5..73fa92ac3b770d3e00ef4f33603067b7ab3692c8 100644 --- a/test/unittests/services_daemon/cloud_daemon_stub_test.cpp +++ b/test/unittests/services_daemon/cloud_daemon_stub_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -12,14 +12,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#include +#include #include "cloud_file_daemon_interface_code.h" #include "ipc/cloud_daemon_stub.h" #include "utils_log.h" -#include -#include - namespace OHOS::FileManagement::CloudFile::Test { using namespace testing; using namespace testing::ext; @@ -37,6 +37,7 @@ public: void SetUp(); void TearDown(); std::shared_ptr cloudDaemonStub_; + static inline shared_ptr insMock = nullptr; }; void CloudDaemonStubTest::SetUpTestCase(void) @@ -51,12 +52,14 @@ void CloudDaemonStubTest::TearDownTestCase(void) void CloudDaemonStubTest::SetUp(void) { + insMock = make_shared(); cloudDaemonStub_ = std::make_shared(); GTEST_LOG_(INFO) << "SetUp"; } void CloudDaemonStubTest::TearDown(void) { + insMock = nullptr; GTEST_LOG_(INFO) << "TearDown"; } @@ -131,4 +134,25 @@ HWTEST_F(CloudDaemonStubTest, OnRemoteRequestTest003, TestSize.Level1) GTEST_LOG_(INFO) << "OnRemoteRequestTest End"; } +/** + * @tc.name: HandleStartFuseInnerTest001 + * @tc.desc: Verify the HandleStartFuseInner function + * @tc.type: FUNC + * @tc.require: issuesIB538J + */ +HWTEST_F(CloudDaemonStubTest, HandleStartFuseInnerTest001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "HandleStartFuseInnerTest start"; + try { + MessageParcel data; + MessageParcel reply; + int ret = cloudDaemonStub_->HandleStartFuseInner(data, reply); + EXPECT_EQ(ret, 0); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "HandleStartFuseInnerTest failed"; + } + GTEST_LOG_(INFO) << "HandleStartFuseInnerTest end"; +} + } // namespace OHOS::FileManagement::CloudSync::Test \ No newline at end of file diff --git a/test/unittests/services_daemon/cloud_daemon_test.cpp b/test/unittests/services_daemon/cloud_daemon_test.cpp index f5a96ef04fa15138aa08c49bef7f0e90a26d5add..1a7f3a9c426234f9be8e516e10c1e5a9e7349b22 100644 --- a/test/unittests/services_daemon/cloud_daemon_test.cpp +++ b/test/unittests/services_daemon/cloud_daemon_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -12,17 +12,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#include +#include +#include "dfs_error.h" +#include "fuse_assistant.h" +#include "fuse_manager/fuse_manager.h" #include "ipc/cloud_daemon.h" - #include "iremote_object.h" #include "system_ability_definition.h" - -#include "dfs_error.h" -#include "fuse_manager/fuse_manager.h" #include "utils_log.h" -#include -#include namespace OHOS::FileManagement::CloudFile::Test { using namespace testing; @@ -36,6 +36,7 @@ public: void SetUp(); void TearDown(); std::shared_ptr cloudDaemon_; + static inline shared_ptr insMock = nullptr; }; void CloudDaemonTest::SetUpTestCase(void) @@ -52,12 +53,16 @@ void CloudDaemonTest::SetUp(void) { int32_t saID = FILEMANAGEMENT_CLOUD_DAEMON_SERVICE_SA_ID; bool runOnCreate = true; + insMock = make_shared(); + FuseAssistantMock::ins = insMock; cloudDaemon_ = std::make_shared(saID, runOnCreate); GTEST_LOG_(INFO) << "SetUp"; } void CloudDaemonTest::TearDown(void) { + FuseAssistantMock::ins = nullptr; + insMock = nullptr; GTEST_LOG_(INFO) << "TearDown"; } @@ -113,6 +118,7 @@ HWTEST_F(CloudDaemonTest, OnStartTest2, TestSize.Level1) GTEST_LOG_(INFO) << "OnStart2 Start"; try { cloudDaemon_->state_ = ServiceRunningState::STATE_NOT_START; + cloudDaemon_->registerToService_ = true; cloudDaemon_->OnStart(); EXPECT_TRUE(true); } catch (...) { @@ -121,4 +127,142 @@ HWTEST_F(CloudDaemonTest, OnStartTest2, TestSize.Level1) } GTEST_LOG_(INFO) << "OnStart2 End"; } + +/** + * @tc.name: StartFuseTest001 + * @tc.desc: Verify the StartFuse function + * @tc.type: FUNC + * @tc.require: issuesIB538J + */ +HWTEST_F(CloudDaemonTest, StartFuseTest001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StartFuseTest001 start"; + std::cout << "StartFuseTest001 Start" << std::endl; + try { + int32_t userId = 100; + int32_t devFd = 10; + const char* path = "/cloud/test"; + int32_t ret = cloudDaemon_->StartFuse(userId, devFd, path); + EXPECT_EQ(ret, E_OK); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "StartFuseTest001 failed"; + } + GTEST_LOG_(INFO) << "StartFuseTest001 end"; +} + +/** + * @tc.name: StartFuseTest002 + * @tc.desc: Verify the StartFuse function + * @tc.type: FUNC + * @tc.require: issuesIB538J + */ +HWTEST_F(CloudDaemonTest, StartFuseTest002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StartFuseTest002 start"; + try { + int32_t userId = 100; + int32_t devFd = 10; + std::string path = "/cloud/test"; + EXPECT_CALL(*insMock, mkdir(_, _)).WillRepeatedly(Return(-1)); + int32_t ret = cloudDaemon_->StartFuse(userId, devFd, path); + EXPECT_EQ(ret, E_PATH); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "StartFuseTest002 failed"; + } + GTEST_LOG_(INFO) << "StartFuseTest002 end"; +} + +// /** +// * @tc.name: StartFuseTest003 +// * @tc.desc: Verify the StartFuse function +// * @tc.type: FUNC +// * @tc.require: issuesIB538J +// */ +HWTEST_F(CloudDaemonTest, StartFuseTest003, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StartFuseTest003 start"; + try { + int32_t userId = 100; + int32_t devFd = 10; + std::string path = "/cloud/test"; + EXPECT_CALL(*insMock, mkdir(_, _)).WillRepeatedly(Return(0)); + EXPECT_CALL(*insMock, chmod(_, _)).WillRepeatedly(Return(-1)); + int32_t ret = cloudDaemon_->StartFuse(userId, devFd, path); + EXPECT_EQ(ret, E_OK); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "StartFuseTest003 failed"; + } + GTEST_LOG_(INFO) << "StartFuseTest003 end"; +} + +// /** +// * @tc.name: StartFuseTest004 +// * @tc.desc: Verify the StartFuse function +// * @tc.type: FUNC +// * @tc.require: issuesIB538J +// */ +HWTEST_F(CloudDaemonTest, StartFuseTest004, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StartFuseTest004 start"; + try { + int32_t userId = 100; + int32_t devFd = 10; + std::string path = "/cloud/test"; + EXPECT_CALL(*insMock, mkdir(_, _)).WillRepeatedly(Return(0)); + EXPECT_CALL(*insMock, chown(_, _, _)).WillRepeatedly(Return(-1)); + int32_t ret = cloudDaemon_->StartFuse(userId, devFd, path); + EXPECT_EQ(ret, E_OK); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "StartFuseTest004 failed"; + } + GTEST_LOG_(INFO) << "StartFuseTest004 end"; +} + +/** + * @tc.name: StartFuseTest007 + * @tc.desc: Verify the StartFuse function + * @tc.type: FUNC + * @tc.require: issuesIB538J + */ +HWTEST_F(CloudDaemonTest, StartFuseTest007, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StartFuseTest007 start"; + try { + int32_t userId = 100; + int32_t devFd = 10; + std::string path = "/cloud_fuse/test"; + EXPECT_CALL(*insMock, mkdir(_, _)).WillRepeatedly(Return(0)); + EXPECT_CALL(*insMock, HandleStartMove(_)).WillRepeatedly(Return()); + int32_t ret = cloudDaemon_->StartFuse(userId, devFd, path); + EXPECT_EQ(ret, E_OK); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "StartFuseTest007 failed"; + } + GTEST_LOG_(INFO) << "StartFuseTest007 end"; +} + +/** + * @tc.name: OnAddSystemAbilityTest001 + * @tc.desc: Verify the OnStart function + * @tc.type: FUNC + * @tc.require: issuesIB538J + */ +HWTEST_F(CloudDaemonTest, OnAddSystemAbility001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "OnAddSystemAbility001 start"; + try { + const int32_t systemAbilityId = 100; + const std::string deviceId = "device_test"; + cloudDaemon_->OnAddSystemAbility(systemAbilityId, deviceId); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "OnAddSystemAbilityTest001 failed"; + } + GTEST_LOG_(INFO) << "OnAddSystemAbilityTest001 end"; +} } // namespace OHOS::FileManagement::CloudSync::Test \ No newline at end of file diff --git a/test/unittests/services_daemon/fuse_manager_test.cpp b/test/unittests/services_daemon/fuse_manager_test.cpp index f42b822f30fe8e65ed4297356cce935838b3a5e3..60ca2dcbb8336ca8338e90ec994604d8f5138d08 100644 --- a/test/unittests/services_daemon/fuse_manager_test.cpp +++ b/test/unittests/services_daemon/fuse_manager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -12,14 +12,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -#include "fuse_manager/fuse_manager.h" -#include "dfs_error.h" -#include "utils_log.h" -#include + #include #include #include +#include + +#include "dfs_error.h" +#include "fuse_assistant.h" +#include "fuse_manager/fuse_manager.h" +#include "fuse_i.h" +#include "utils_log.h" namespace OHOS::FileManagement::CloudFile::Test { using namespace testing; @@ -33,6 +36,7 @@ public: void SetUp(); void TearDown(); std::shared_ptr fuseManager_; + static inline shared_ptr insMock = nullptr; }; void FuseManagerTest::SetUpTestCase(void) @@ -48,12 +52,16 @@ void FuseManagerTest::TearDownTestCase(void) void FuseManagerTest::SetUp(void) { GTEST_LOG_(INFO) << "SetUp"; + insMock = make_shared(); + FuseAssistantMock::ins = insMock; fuseManager_ = std::make_shared(); } void FuseManagerTest::TearDown(void) { GTEST_LOG_(INFO) << "TearDown"; + FuseAssistantMock::ins = nullptr; + insMock = nullptr; } /** @@ -64,14 +72,303 @@ void FuseManagerTest::TearDown(void) */ HWTEST_F(FuseManagerTest, GetInstanceTest, TestSize.Level1) { - GTEST_LOG_(INFO) << "GetInstanceTest Start"; + GTEST_LOG_(INFO) << "GetInstanceTest start"; try { FuseManager::GetInstance(); EXPECT_TRUE(true); } catch (...) { EXPECT_TRUE(false); - GTEST_LOG_(INFO) << "GetInstanceTest ERROR"; + GTEST_LOG_(INFO) << "GetInstanceTest failed"; + } + GTEST_LOG_(INFO) << "GetInstanceTest end"; +} + +/** + * @tc.name: StartFuseTest001 + * @tc.desc: Verify the StartFuse function + * @tc.type: FUNC + * @tc.require: issuesIB538J + */ +HWTEST_F(FuseManagerTest, StartFuseTest001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StartFuseTest001 start"; + try { + struct fuse_session *fs = (struct fuse_session *)calloc(1, sizeof(struct fuse_session)); + EXPECT_CALL(*insMock, fuse_opt_add_arg(_, _)).WillOnce(Return(0)); + EXPECT_CALL(*insMock, fuse_session_new(_, _, _, _)).WillOnce(Return(fs)); + EXPECT_CALL(*insMock, fuse_session_destroy(fs)).WillOnce(Return()); + int32_t userId = 100; + int32_t devFd = open("/dev/fuse", O_RDWR); + string path = "/mnt/data/100/cloud_fuse"; + int ret = fuseManager_->StartFuse(userId, devFd, path); + free(fs); + EXPECT_EQ(ret, -1); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "StartFuseTest001 failed"; + } + GTEST_LOG_(INFO) << "StartFuseTest001 end"; +} + +/** + * @tc.name: StartFuseTest002 + * @tc.desc: Verify the StartFuse function + * @tc.type: FUNC + * @tc.require: issuesIB538J + */ +HWTEST_F(FuseManagerTest, StartFuseTest002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StartFuseTest002 start"; + try { + EXPECT_CALL(*insMock, fuse_opt_add_arg(_, _)).WillOnce(Return(-1)); + int32_t userId = 100; + int32_t devFd = open("/dev/fuse", O_RDWR); + string path = "/mnt/data/100/cloud_fuse"; + int ret = fuseManager_->StartFuse(userId, devFd, path); + EXPECT_EQ(ret, -EINVAL); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "StartFuseTest002 failed"; + } + GTEST_LOG_(INFO) << "StartFuseTest002 end"; +} + +/** + * @tc.name: StartFuseTest003 + * @tc.desc: Verify the StartFuse function + * @tc.type: FUNC + * @tc.require: issuesIB538J + */ +HWTEST_F(FuseManagerTest, StartFuseTest003, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StartFuseTest003 start"; + try { + EXPECT_CALL(*insMock, fuse_opt_add_arg(_, _)).WillOnce(Return(0)); + EXPECT_CALL(*insMock, fuse_session_new(_, _, _, _)).WillOnce(Return(nullptr)); + int32_t userId = 100; + int32_t devFd = open("/dev/fuse", O_RDWR); + string path = "/mnt/data/100/cloud_fuse"; + int ret = fuseManager_->StartFuse(userId, devFd, path); + EXPECT_EQ(ret, -EINVAL); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "StartFuseTest003 failed"; + } + GTEST_LOG_(INFO) << "StartFuseTest003 end"; +} + +/** + * @tc.name: StartFuseTest004 + * @tc.desc: Verify the StartFuse function + * @tc.type: FUNC + * @tc.require: issuesIB538J + */ +HWTEST_F(FuseManagerTest, StartFuseTest004, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StartFuseTest004 start"; + try { + struct fuse_session *fs = (struct fuse_session *)calloc(1, sizeof(struct fuse_session)); + EXPECT_CALL(*insMock, fuse_opt_add_arg(_, _)).WillOnce(Return(0)); + EXPECT_CALL(*insMock, fuse_session_new(_, _, _, _)).WillOnce(Return(fs)); + EXPECT_CALL(*insMock, fuse_session_destroy(fs)).WillOnce(Return()); + int32_t userId = 100; + int32_t devFd = open("/dev/fuse", O_RDWR); + string path = "/mnt/data/100/cloud"; + int ret = fuseManager_->StartFuse(userId, devFd, path); + free(fs); + EXPECT_EQ(ret, -1); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "StartFuseTest004 failed"; + } + GTEST_LOG_(INFO) << "StartFuseTest004 end"; +} + +/** + * @tc.name: StartFuseTest005 + * @tc.desc: Verify the StartFuse function + * @tc.type: FUNC + * @tc.require: issuesIB538J + */ +HWTEST_F(FuseManagerTest, StartFuseTest005, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StartFuseTest005 start"; + try { + EXPECT_CALL(*insMock, fuse_opt_add_arg(_, _)).WillOnce(Return(-1)); + int32_t userId = 100; + int32_t devFd = open("/dev/fuse", O_RDWR); + string path = "/mnt/data/100/cloud"; + int ret = fuseManager_->StartFuse(userId, devFd, path); + EXPECT_EQ(ret, -EINVAL); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "StartFuseTest005 failed"; + } + GTEST_LOG_(INFO) << "StartFuseTest005 end"; +} + +/** + * @tc.name: StartFuseTest006 + * @tc.desc: Verify the StartFuse function + * @tc.type: FUNC + * @tc.require: issuesIB538J + */ +HWTEST_F(FuseManagerTest, StartFuseTest006, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StartFuseTest006 start"; + try { + EXPECT_CALL(*insMock, fuse_opt_add_arg(_, _)).WillOnce(Return(0)); + EXPECT_CALL(*insMock, fuse_session_new(_, _, _, _)).WillOnce(Return(nullptr)); + int32_t userId = 100; + int32_t devFd = open("/dev/fuse", O_RDWR); + string path = "/mnt/data/100/cloud"; + int ret = fuseManager_->StartFuse(userId, devFd, path); + EXPECT_EQ(ret, -EINVAL); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "StartFuseTest006 failed"; + } + GTEST_LOG_(INFO) << "StartFuseTest006 end"; +} + +/** + * @tc.name: StartFuseTest007 + * @tc.desc: Verify the StartFuse function + * @tc.type: FUNC + * @tc.require: issuesIB538J + */ +HWTEST_F(FuseManagerTest, StartFuseTest007, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StartFuseTest007 start"; + try { + EXPECT_CALL(*insMock, fuse_opt_add_arg(_, _)).WillOnce(Return(0)); + int32_t userId = 100; + int32_t devFd = open("/dev/fuse", O_RDWR); + string path = "/invalid/data/100/cloud_fuse"; + int ret = fuseManager_->StartFuse(userId, devFd, path); + EXPECT_EQ(ret, -EINVAL); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "StartFuseTest007 failed"; + } + GTEST_LOG_(INFO) << "StartFuseTest007 end"; +} + +/** + * @tc.name: StartFuseTest008 + * @tc.desc: Verify the StartFuse function + * @tc.type: FUNC + * @tc.require: issuesIB538J + */ +HWTEST_F(FuseManagerTest, StartFuseTest008, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StartFuseTest008 start"; + try { + EXPECT_CALL(*insMock, fuse_opt_add_arg(_, _)).WillOnce(Return(0)); + int32_t userId = 100; + int32_t devFd = open("/dev/fuse", O_RDWR); + string path = "/mnt/other/100/cloud_fuse"; + int ret = fuseManager_->StartFuse(userId, devFd, path); + EXPECT_EQ(ret, -EINVAL); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "StartFuseTest008 failed"; + } + GTEST_LOG_(INFO) << "StartFuseTest008 end"; +} + +/** + * @tc.name: StartFuseTest009 + * @tc.desc: Verify the StartFuse function + * @tc.type: FUNC + * @tc.require: issuesIB538J + */ +HWTEST_F(FuseManagerTest, StartFuseTest009, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StartFuseTest009 start"; + try { + EXPECT_CALL(*insMock, fuse_opt_add_arg(_, _)).WillOnce(Return(0)); + int32_t userId = 100; + int32_t devFd = open("/dev/fuse", O_RDWR); + string path = "/mnt/data/abcd/cloud_fuse"; + int ret = fuseManager_->StartFuse(userId, devFd, path); + EXPECT_EQ(ret, -EINVAL); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "StartFuseTest009 failed"; + } + GTEST_LOG_(INFO) << "StartFuseTest009 end"; +} + +/** + * @tc.name: StartFuseTest012 + * @tc.desc: Verify the StartFuse function + * @tc.type: FUNC + * @tc.require: issuesIB538J + */ +HWTEST_F(FuseManagerTest, StartFuseTest010, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StartFuseTest010 start"; + try { + EXPECT_CALL(*insMock, fuse_opt_add_arg(_, _)).WillOnce(Return(0)); + int32_t userId = 100; + int32_t devFd = open("/dev/fuse", O_RDWR); + string path = "/mnt/data/100/invalid_suffix"; + int ret = fuseManager_->StartFuse(userId, devFd, path); + EXPECT_EQ(ret, -EINVAL); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "StartFuseTest010 failed"; + } + GTEST_LOG_(INFO) << "StartFuseTest010 end"; +} + +/** + * @tc.name: StartFuseTest011 + * @tc.desc: Verify the StartFuse function + * @tc.type: FUNC + * @tc.require: issuesIB538J + */ +HWTEST_F(FuseManagerTest, StartFuseTest011, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StartFuseTest011 start"; + try { + EXPECT_CALL(*insMock, fuse_opt_add_arg(_, _)).WillOnce(Return(0)); + int32_t userId = 100; + int32_t devFd = open("/dev/fuse", O_RDWR); + string path = "\0"; + int ret = fuseManager_->StartFuse(userId, devFd, path); + EXPECT_EQ(ret, -EINVAL); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "StartFuseTest011 failed"; + } + GTEST_LOG_(INFO) << "StartFuseTest011 end"; +} + +/** + * @tc.name: StartFuseTest012 + * @tc.desc: Verify the StartFuse function + * @tc.type: FUNC + * @tc.require: issuesIB538J + */ +HWTEST_F(FuseManagerTest, StartFuseTest012, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StartFuseTest012 start"; + try { + struct fuse_session *fs = (struct fuse_session *)calloc(1, sizeof(struct fuse_session)); + EXPECT_CALL(*insMock, fuse_opt_add_arg(_, _)).WillOnce(Return(0)); + EXPECT_CALL(*insMock, fuse_session_new(_, _, _, _)).WillOnce(Return(fs)); + int32_t userId = 1; + int32_t devFd = open("/dev/fuse", O_RDWR); + string path = "/mnt/data/234/cloud_fuse"; + int ret = fuseManager_->StartFuse(userId, devFd, path); + free(fs); + EXPECT_EQ(ret, -ENOMEM); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "StartFuseTest012 failed"; } - GTEST_LOG_(INFO) << "GetInstanceTest End"; + GTEST_LOG_(INFO) << "StartFuseTest012 end"; } } // namespace OHOS::FileManagement::CloudSync::Test \ No newline at end of file