1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #include "mountpoint/mount_point.h" 16 17 #include <memory> 18 #include <unistd.h> 19 20 #include "gtest/gtest.h" 21 22 #include "utils_directory.h" 23 24 namespace OHOS { 25 namespace Storage { 26 namespace DistributedFile { 27 namespace Test { 28 using namespace testing::ext; 29 using namespace std; 30 31 class MountPointTest : public testing::Test { 32 public: SetUpTestCase(void)33 static void SetUpTestCase(void) {}; TearDownTestCase(void)34 static void TearDownTestCase(void) {}; SetUp()35 void SetUp() {}; TearDown()36 void TearDown() {}; 37 }; 38 39 /** 40 * @tc.name: MountPointTest_MountPoint_0100 41 * @tc.desc: Verify the MountPoint class. 42 * @tc.type: FUNC 43 * @tc.require: I9KETY 44 */ 45 HWTEST_F(MountPointTest, MountPointTest_MountPoint_0100, TestSize.Level1) 46 { 47 GTEST_LOG_(INFO) << "MountPointTest_MountPoint_0100 start"; 48 Utils::MountArgument mountArg{.userId_ = 100, 49 .relativePath_ = "data/test", 50 .accountless_ = true}; 51 MountPoint point(mountArg); 52 EXPECT_EQ(point.GetID(), point.idGen_ - 1); 53 EXPECT_EQ(point.isAccountLess(), true); 54 EXPECT_EQ(point.ToString(), ""); 55 EXPECT_EQ(point.GetMountArgument().GetFullDst(), "/mnt/hmdfs/100/data/test"); 56 EXPECT_EQ(point.GetMountArgument().GetFullSrc(), "/data/service/el2/100/hmdfs/data/test"); 57 MountPoint point2(mountArg); 58 EXPECT_EQ(point == point2, true); 59 60 Utils::MountArgument mountArg2; 61 MountPoint point3(mountArg2); 62 EXPECT_EQ(point == point3, false); 63 64 point.Mount(); 65 point.Umount(); 66 GTEST_LOG_(INFO) << "MountPointTest_MountPoint_0100 end"; 67 } 68 } // namespace Test 69 } // namespace DistributedFile 70 } // namespace Storage 71 } // namespace OHOS 72