1cb7eb8c9Sopenharmony_ci/* 2cb7eb8c9Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 3cb7eb8c9Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4cb7eb8c9Sopenharmony_ci * you may not use this file except in compliance with the License. 5cb7eb8c9Sopenharmony_ci * You may obtain a copy of the License at 6cb7eb8c9Sopenharmony_ci * 7cb7eb8c9Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8cb7eb8c9Sopenharmony_ci * 9cb7eb8c9Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10cb7eb8c9Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11cb7eb8c9Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12cb7eb8c9Sopenharmony_ci * See the License for the specific language governing permissions and 13cb7eb8c9Sopenharmony_ci * limitations under the License. 14cb7eb8c9Sopenharmony_ci */ 15cb7eb8c9Sopenharmony_ci 16cb7eb8c9Sopenharmony_ci#include <gmock/gmock.h> 17cb7eb8c9Sopenharmony_ci#include <gtest/gtest.h> 18cb7eb8c9Sopenharmony_ci#include <iostream> 19cb7eb8c9Sopenharmony_ci#include <sstream> 20cb7eb8c9Sopenharmony_ci#include <string> 21cb7eb8c9Sopenharmony_ci#include <sys/mount.h> 22cb7eb8c9Sopenharmony_ci#include <system_error> 23cb7eb8c9Sopenharmony_ci#include <unistd.h> 24cb7eb8c9Sopenharmony_ci 25cb7eb8c9Sopenharmony_ci#include "device/device_info.h" 26cb7eb8c9Sopenharmony_ci#include "device/device_manager_agent.h" 27cb7eb8c9Sopenharmony_ci#include "mountpoint/mount_point.h" 28cb7eb8c9Sopenharmony_ci#include "network/kernel_talker.h" 29cb7eb8c9Sopenharmony_ci#include "network/session_pool.h" 30cb7eb8c9Sopenharmony_ci#include "network/softbus/softbus_session.h" 31cb7eb8c9Sopenharmony_ci#include "securec.h" 32cb7eb8c9Sopenharmony_ci#include "utils_directory.h" 33cb7eb8c9Sopenharmony_ci#include "utils_log.h" 34cb7eb8c9Sopenharmony_ci 35cb7eb8c9Sopenharmony_cinamespace OHOS { 36cb7eb8c9Sopenharmony_cinamespace Storage { 37cb7eb8c9Sopenharmony_cinamespace DistributedFile { 38cb7eb8c9Sopenharmony_cinamespace Test { 39cb7eb8c9Sopenharmony_ciusing namespace testing::ext; 40cb7eb8c9Sopenharmony_ciusing namespace std; 41cb7eb8c9Sopenharmony_ci 42cb7eb8c9Sopenharmony_cistatic const string SRC_HEAD = "/data/service/el2/"; 43cb7eb8c9Sopenharmony_cistatic const string DST_HEAD = "/mnt/hmdfs/"; 44cb7eb8c9Sopenharmony_cistatic const string CACHE_HEAD = "/data/service/el2/"; 45cb7eb8c9Sopenharmony_cistatic const string SAME_ACCOUNT = "account"; 46cb7eb8c9Sopenharmony_cistd::mutex cmdMutex_; 47cb7eb8c9Sopenharmony_ci 48cb7eb8c9Sopenharmony_ciconst int KEY_MAX_LEN = 32; 49cb7eb8c9Sopenharmony_ciconst int CID_MAX_LEN = 64; 50cb7eb8c9Sopenharmony_cistruct UpdateSocketParam { 51cb7eb8c9Sopenharmony_ci int32_t cmd; 52cb7eb8c9Sopenharmony_ci int32_t newfd; 53cb7eb8c9Sopenharmony_ci uint8_t status; 54cb7eb8c9Sopenharmony_ci uint8_t protocol; 55cb7eb8c9Sopenharmony_ci uint16_t udpPort; 56cb7eb8c9Sopenharmony_ci uint8_t deviceType; 57cb7eb8c9Sopenharmony_ci uint8_t masterKey[KEY_MAX_LEN]; 58cb7eb8c9Sopenharmony_ci char cid[CID_MAX_LEN]; 59cb7eb8c9Sopenharmony_ci int32_t linkType; 60cb7eb8c9Sopenharmony_ci int32_t binderFd; 61cb7eb8c9Sopenharmony_ci} __attribute__((packed)); 62cb7eb8c9Sopenharmony_ci 63cb7eb8c9Sopenharmony_ciclass DistributedFileDaemonServiceTest : public testing::Test { 64cb7eb8c9Sopenharmony_cipublic: 65cb7eb8c9Sopenharmony_ci static void SetUpTestCase(void); 66cb7eb8c9Sopenharmony_ci static void TearDownTestCase(void); 67cb7eb8c9Sopenharmony_ci void SetUp(); 68cb7eb8c9Sopenharmony_ci void TearDown(); 69cb7eb8c9Sopenharmony_ci}; 70cb7eb8c9Sopenharmony_ci 71cb7eb8c9Sopenharmony_civoid DistributedFileDaemonServiceTest::SetUpTestCase(void) 72cb7eb8c9Sopenharmony_ci{ 73cb7eb8c9Sopenharmony_ci // input testsuit setup step,setup invoked before all testcases 74cb7eb8c9Sopenharmony_ci} 75cb7eb8c9Sopenharmony_ci 76cb7eb8c9Sopenharmony_civoid DistributedFileDaemonServiceTest::TearDownTestCase(void) 77cb7eb8c9Sopenharmony_ci{ 78cb7eb8c9Sopenharmony_ci // input testsuit teardown step,teardown invoked after all testcases 79cb7eb8c9Sopenharmony_ci} 80cb7eb8c9Sopenharmony_ci 81cb7eb8c9Sopenharmony_civoid DistributedFileDaemonServiceTest::SetUp(void) 82cb7eb8c9Sopenharmony_ci{ 83cb7eb8c9Sopenharmony_ci // input testcase setup step,setup invoked before each testcases 84cb7eb8c9Sopenharmony_ci} 85cb7eb8c9Sopenharmony_ci 86cb7eb8c9Sopenharmony_civoid DistributedFileDaemonServiceTest::TearDown(void) 87cb7eb8c9Sopenharmony_ci{ 88cb7eb8c9Sopenharmony_ci // input testcase teardown step,teardown invoked after each testcases 89cb7eb8c9Sopenharmony_ci} 90cb7eb8c9Sopenharmony_ci 91cb7eb8c9Sopenharmony_ci 92cb7eb8c9Sopenharmony_ci/** 93cb7eb8c9Sopenharmony_ci * @tc.name: mount_test_001 94cb7eb8c9Sopenharmony_ci * @tc.desc: Verify the mount/umount function. 95cb7eb8c9Sopenharmony_ci * @tc.type: FUNC 96cb7eb8c9Sopenharmony_ci * @tc.require: Issue Number 97cb7eb8c9Sopenharmony_ci */ 98cb7eb8c9Sopenharmony_ciHWTEST_F(DistributedFileDaemonServiceTest, mount_umount_test_001, TestSize.Level1) 99cb7eb8c9Sopenharmony_ci{ 100cb7eb8c9Sopenharmony_ci auto mp = make_unique<OHOS::Storage::DistributedFile::MountPoint>( 101cb7eb8c9Sopenharmony_ci Utils::DfsuMountArgumentDescriptors::Alpha(100, SAME_ACCOUNT)); 102cb7eb8c9Sopenharmony_ci 103cb7eb8c9Sopenharmony_ci shared_ptr<OHOS::Storage::DistributedFile::MountPoint> smp = move(mp); 104cb7eb8c9Sopenharmony_ci 105cb7eb8c9Sopenharmony_ci try { 106cb7eb8c9Sopenharmony_ci smp->Mount(); 107cb7eb8c9Sopenharmony_ci smp->Umount(); 108cb7eb8c9Sopenharmony_ci LOGE("testcase run OK"); 109cb7eb8c9Sopenharmony_ci } catch (const exception &e) { 110cb7eb8c9Sopenharmony_ci LOGE("%{public}s", e.what()); 111cb7eb8c9Sopenharmony_ci FAIL(); 112cb7eb8c9Sopenharmony_ci } 113cb7eb8c9Sopenharmony_ci SUCCEED(); 114cb7eb8c9Sopenharmony_ci} 115cb7eb8c9Sopenharmony_ci} // namespace Test 116cb7eb8c9Sopenharmony_ci} // namespace DistributedFile 117cb7eb8c9Sopenharmony_ci} // namespace Storage 118cb7eb8c9Sopenharmony_ci} // namespace OHOS 119