1 /* 2 * Copyright (c) 2021 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 16 #include <gmock/gmock.h> 17 #include <gtest/gtest.h> 18 #include <iostream> 19 #include <sstream> 20 #include <string> 21 #include <sys/mount.h> 22 #include <system_error> 23 #include <unistd.h> 24 25 #include "device/device_info.h" 26 #include "device/device_manager_agent.h" 27 #include "mountpoint/mount_point.h" 28 #include "network/kernel_talker.h" 29 #include "network/session_pool.h" 30 #include "network/softbus/softbus_session.h" 31 #include "securec.h" 32 #include "utils_directory.h" 33 #include "utils_log.h" 34 35 namespace OHOS { 36 namespace Storage { 37 namespace DistributedFile { 38 namespace Test { 39 using namespace testing::ext; 40 using namespace std; 41 42 static const string SRC_HEAD = "/data/service/el2/"; 43 static const string DST_HEAD = "/mnt/hmdfs/"; 44 static const string CACHE_HEAD = "/data/service/el2/"; 45 static const string SAME_ACCOUNT = "account"; 46 std::mutex cmdMutex_; 47 48 const int KEY_MAX_LEN = 32; 49 const int CID_MAX_LEN = 64; 50 struct UpdateSocketParam { 51 int32_t cmd; 52 int32_t newfd; 53 uint8_t status; 54 uint8_t protocol; 55 uint16_t udpPort; 56 uint8_t deviceType; 57 uint8_t masterKey[KEY_MAX_LEN]; 58 char cid[CID_MAX_LEN]; 59 int32_t linkType; 60 int32_t binderFd; 61 } __attribute__((packed)); 62 63 class DistributedFileDaemonServiceTest : public testing::Test { 64 public: 65 static void SetUpTestCase(void); 66 static void TearDownTestCase(void); 67 void SetUp(); 68 void TearDown(); 69 }; 70 SetUpTestCase(void)71void DistributedFileDaemonServiceTest::SetUpTestCase(void) 72 { 73 // input testsuit setup step,setup invoked before all testcases 74 } 75 TearDownTestCase(void)76void DistributedFileDaemonServiceTest::TearDownTestCase(void) 77 { 78 // input testsuit teardown step,teardown invoked after all testcases 79 } 80 SetUp(void)81void DistributedFileDaemonServiceTest::SetUp(void) 82 { 83 // input testcase setup step,setup invoked before each testcases 84 } 85 TearDown(void)86void DistributedFileDaemonServiceTest::TearDown(void) 87 { 88 // input testcase teardown step,teardown invoked after each testcases 89 } 90 91 92 /** 93 * @tc.name: mount_test_001 94 * @tc.desc: Verify the mount/umount function. 95 * @tc.type: FUNC 96 * @tc.require: Issue Number 97 */ 98 HWTEST_F(DistributedFileDaemonServiceTest, mount_umount_test_001, TestSize.Level1) 99 { 100 auto mp = make_unique<OHOS::Storage::DistributedFile::MountPoint>( 101 Utils::DfsuMountArgumentDescriptors::Alpha(100, SAME_ACCOUNT)); 102 103 shared_ptr<OHOS::Storage::DistributedFile::MountPoint> smp = move(mp); 104 105 try { 106 smp->Mount(); 107 smp->Umount(); 108 LOGE("testcase run OK"); 109 } catch (const exception &e) { 110 LOGE("%{public}s", e.what()); 111 FAIL(); 112 } 113 SUCCEED(); 114 } 115 } // namespace Test 116 } // namespace DistributedFile 117 } // namespace Storage 118 } // namespace OHOS 119