mirror of
https://gitee.com/openharmony/filemanagement_storage_service
synced 2024-11-23 15:09:48 +00:00
add volume, netlink, disk test cases
Signed-off-by: jiahaoluo <luojiahao5@huawei.com>
This commit is contained in:
parent
27bd39f568
commit
b7a5a90a6d
@ -70,6 +70,9 @@
|
||||
"//foundation/filemanagement/storage_service/services/storage_daemon/crypto/test:crypto_test",
|
||||
"//foundation/filemanagement/storage_service/services/storage_daemon/ipc/test:storage_daemon_ipc_test",
|
||||
"//foundation/filemanagement/storage_service/services/storage_daemon/user/test:storage_daemon_user_test",
|
||||
"//foundation/filemanagement/storage_service/services/storage_daemon/disk/test:storage_daemon_disk_test",
|
||||
"//foundation/filemanagement/storage_service/services/storage_daemon/volume/test:storage_daemon_volume_test",
|
||||
"//foundation/filemanagement/storage_service/services/storage_daemon/netlink/test:storage_daemon_netlink_test",
|
||||
"//foundation/filemanagement/storage_service/services/storage_daemon/utils/test:storage_daemon_utils_test",
|
||||
"//foundation/filemanagement/storage_service/services/storage_manager/ipc/test:proxy_test",
|
||||
"//foundation/filemanagement/storage_service/services/storage_manager/storage_daemon_communication/test:communication_test",
|
||||
|
@ -111,7 +111,6 @@ void DiskManager::ChangeDisk(dev_t device)
|
||||
for (auto &diskInfo : disk_) {
|
||||
if (diskInfo->GetDevice() == device) {
|
||||
diskInfo->ReadMetadata();
|
||||
// diskInfo->ReadPartition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
48
services/storage_daemon/disk/test/BUILD.gn
Normal file
48
services/storage_daemon/disk/test/BUILD.gn
Normal file
@ -0,0 +1,48 @@
|
||||
# Copyright (c) 2021 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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/test.gni")
|
||||
|
||||
ROOT_DIR = "//foundation/filemanagement/storage_service/services/storage_daemon"
|
||||
|
||||
ohos_unittest("disk_manager_test") {
|
||||
module_out_path = "filemanagement/storage_service/storage_daemon"
|
||||
|
||||
include_dirs = [
|
||||
"$ROOT_DIR/include",
|
||||
"//foundation/filemanagement/storage_service/utils/include",
|
||||
"//foundation/filemanagement/storage_service/services/storage_manager/include",
|
||||
"//foundation/filemanagement/storage_service/interfaces/innerkits/storage_manager/native",
|
||||
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"$ROOT_DIR/disk/src/disk_manager.cpp",
|
||||
"$ROOT_DIR/disk/test/disk_manager_test.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//third_party/googletest:gtest_main",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
}
|
||||
|
||||
group("storage_daemon_disk_test") {
|
||||
testonly = true
|
||||
deps = [ ":disk_manager_test" ]
|
||||
}
|
50
services/storage_daemon/disk/test/disk_manager_test.cpp
Normal file
50
services/storage_daemon/disk/test/disk_manager_test.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "storage_service_errno.h"
|
||||
#include "storage_service_log.h"
|
||||
#include "disk/disk_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace StorageDaemon {
|
||||
using namespace testing::ext;
|
||||
|
||||
class DiskManagerTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase(void) {};
|
||||
static void TearDownTestCase(void) {};
|
||||
void SetUp() {};
|
||||
void TearDown() {};
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.name: Storage_Service_DiskManagerTest_Instance_001
|
||||
* @tc.desc: Verify the Instance function.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000GGUOT
|
||||
*/
|
||||
HWTEST_F(DiskManagerTest, Storage_Service_DiskManagerTest_Instance_001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Storage_Service_DiskManagerTest_Instance_001 start";
|
||||
|
||||
DiskManager *diskManager = DiskManager::Instance();
|
||||
ASSERT_TRUE(diskManager != nullptr);
|
||||
|
||||
GTEST_LOG_(INFO) << "Storage_Service_DiskManagerTest_Instance_001 end";
|
||||
}
|
||||
} // STORAGE_DAEMON
|
||||
} // OHOS
|
@ -54,7 +54,7 @@ private:
|
||||
const std::string devPathDir_ = "/dev/block/%s";
|
||||
std::vector<std::string> supportMountType_ = { "ext2", "ext3", "ext4", "ntfs", "exfat", "vfat" };
|
||||
std::map<std::string, std::string> supportFormatType_ = {
|
||||
{"ext2", "mke2fs"}, {"ext3", "mke2fs"}, {"ext4", "mke2fs"}, {"ntfs", "mkfs.ntfs"}
|
||||
{"ext2", "mke2fs"}, {"ext3", "mke2fs"}, {"ext4", "mke2fs"}, {"ntfs", "mkfs.ntfs"}, {"exfat", "mkfs.exfat"}
|
||||
};
|
||||
|
||||
int32_t ReadMetadata();
|
||||
|
46
services/storage_daemon/netlink/test/BUILD.gn
Normal file
46
services/storage_daemon/netlink/test/BUILD.gn
Normal file
@ -0,0 +1,46 @@
|
||||
# Copyright (c) 2021 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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/test.gni")
|
||||
|
||||
ROOT_DIR = "//foundation/filemanagement/storage_service/services/storage_daemon"
|
||||
|
||||
ohos_unittest("netlink_manager_test") {
|
||||
module_out_path = "filemanagement/storage_service/storage_daemon"
|
||||
|
||||
include_dirs = [
|
||||
"$ROOT_DIR/include",
|
||||
"//foundation/filemanagement/storage_service/utils/include",
|
||||
"//foundation/filemanagement/storage_service/storage_manager/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"$ROOT_DIR/netlink/src/netlink_manager.cpp",
|
||||
"$ROOT_DIR/netlink/test/netlink_manager_test.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//third_party/googletest:gtest_main",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
}
|
||||
|
||||
group("storage_daemon_netlink_test") {
|
||||
testonly = true
|
||||
deps = [ ":netlink_manager_test" ]
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "storage_service_errno.h"
|
||||
#include "storage_service_log.h"
|
||||
#include "netlink/netlink_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace StorageDaemon {
|
||||
using namespace testing::ext;
|
||||
|
||||
class NetlinkManagerTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase(void) {};
|
||||
static void TearDownTestCase(void) {};
|
||||
void SetUp() {};
|
||||
void TearDown() {};
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.name: Storage_Service_NetlinkManagerTest_Instance_001
|
||||
* @tc.desc: Verify the Instance function.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000GGUOT
|
||||
*/
|
||||
HWTEST_F(NetlinkManagerTest, Storage_Service_NetlinkManagerTest_Instance_001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Storage_Service_NetlinkManagerTest_Instance_001 start";
|
||||
|
||||
NetlinkManager *netlinkManager = NetlinkManager::Instance();
|
||||
ASSERT_TRUE(netlinkManager != nullptr);
|
||||
|
||||
GTEST_LOG_(INFO) << "Storage_Service_NetlinkManagerTest_Instance_001 end";
|
||||
}
|
||||
} // STORAGE_DAEMON
|
||||
} // OHOS
|
@ -169,6 +169,7 @@ int32_t VolumeManager::Format(const std::string volId, const std::string fsType)
|
||||
LOGE("the volume %{public}s format failed.", volId.c_str());
|
||||
return err;
|
||||
}
|
||||
|
||||
return E_OK;
|
||||
}
|
||||
} // StorageDaemon
|
||||
|
48
services/storage_daemon/volume/test/BUILD.gn
Normal file
48
services/storage_daemon/volume/test/BUILD.gn
Normal file
@ -0,0 +1,48 @@
|
||||
# Copyright (c) 2021 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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/test.gni")
|
||||
|
||||
ROOT_DIR = "//foundation/filemanagement/storage_service/services/storage_daemon"
|
||||
|
||||
ohos_unittest("volume_manager_test") {
|
||||
module_out_path = "filemanagement/storage_service/storage_daemon"
|
||||
|
||||
include_dirs = [
|
||||
"$ROOT_DIR/include",
|
||||
"//foundation/filemanagement/storage_service/utils/include",
|
||||
"//foundation/filemanagement/storage_service/services/storage_manager/include",
|
||||
"//foundation/filemanagement/storage_service/interfaces/innerkits/storage_manager/native",
|
||||
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"$ROOT_DIR/volume/src/volume_manager.cpp",
|
||||
"$ROOT_DIR/volume/test/volume_manager_test.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//third_party/googletest:gtest_main",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
}
|
||||
|
||||
group("storage_daemon_volume_test") {
|
||||
testonly = true
|
||||
deps = [ ":volume_manager_test" ]
|
||||
}
|
50
services/storage_daemon/volume/test/volume_manager_test.cpp
Normal file
50
services/storage_daemon/volume/test/volume_manager_test.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "storage_service_errno.h"
|
||||
#include "storage_service_log.h"
|
||||
#include "volume/volume_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace StorageDaemon {
|
||||
using namespace testing::ext;
|
||||
|
||||
class VolumeManagerTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase(void) {};
|
||||
static void TearDownTestCase(void) {};
|
||||
void SetUp() {};
|
||||
void TearDown() {};
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.name: Storage_Service_VolumeManagerTest_Instance_001
|
||||
* @tc.desc: Verify the Instance function.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000GGUOT
|
||||
*/
|
||||
HWTEST_F(VolumeManagerTest, Storage_Service_VolumeManagerTest_Instance_001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Storage_Service_VolumeManagerTest_Instance_001 start";
|
||||
|
||||
VolumeManager *volumeManager = VolumeManager::Instance();
|
||||
ASSERT_TRUE(volumeManager != nullptr);
|
||||
|
||||
GTEST_LOG_(INFO) << "Storage_Service_VolumeManagerTest_Instance_001 end";
|
||||
}
|
||||
} // STORAGE_DAEMON
|
||||
} // OHOS
|
Loading…
Reference in New Issue
Block a user