mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2025-02-26 06:18:10 +00:00
add distributed ledger ut test
Signed-off-by: jeosif <liubao6@huawei.com> Change-Id: Ic97e0409d710849dae9e0b1df63f8b7c7bd7a3b4
This commit is contained in:
parent
c71471c9c1
commit
7f16ae0329
@ -69,7 +69,9 @@ typedef struct {
|
||||
typedef enum {
|
||||
ONLINE_HICHAIN = 0,
|
||||
ONLINE_METANODE,
|
||||
ONLINE_MIX
|
||||
ONLINE_MIX,
|
||||
|
||||
AUTH_TYPE_BUTT,
|
||||
} AuthType;
|
||||
|
||||
typedef struct {
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "auth_interface.h"
|
||||
#include "bus_center_info_key.h"
|
||||
#include "lnn_node_info.h"
|
||||
|
||||
@ -52,6 +53,8 @@ void LnnDeinitDistributedLedger(void);
|
||||
|
||||
ReportCategory LnnAddOnlineNode(NodeInfo *info);
|
||||
ReportCategory LnnSetNodeOffline(const char *udid, ConnectionAddrType type, int32_t authId);
|
||||
int32_t LnnSetAuthTypeValue(uint32_t *authTypeValue, AuthType type);
|
||||
int32_t LnnClearAuthTypeValue(uint32_t *authTypeValue, AuthType type);
|
||||
void LnnRemoveNode(const char *udid);
|
||||
NodeInfo *LnnGetNodeInfoById(const char *id, IdCategory type);
|
||||
bool LnnSetDLDeviceInfoName(const char *udid, const char *name);
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include <securec.h>
|
||||
|
||||
#include "auth_interface.h"
|
||||
#include "lnn_connection_addr_utils.h"
|
||||
#include "lnn_fast_offline.h"
|
||||
#include "lnn_lane_info.h"
|
||||
@ -77,7 +76,7 @@ static DistributedNetLedger g_distributedNetLedger;
|
||||
|
||||
int32_t LnnSetAuthTypeValue(uint32_t *authTypeValue, AuthType type)
|
||||
{
|
||||
if (authTypeValue == NULL || type >= BIT_COUNT) {
|
||||
if (authTypeValue == NULL || type >= AUTH_TYPE_BUTT) {
|
||||
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "in para error!");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
@ -87,7 +86,7 @@ int32_t LnnSetAuthTypeValue(uint32_t *authTypeValue, AuthType type)
|
||||
|
||||
int32_t LnnClearAuthTypeValue(uint32_t *authTypeValue, AuthType type)
|
||||
{
|
||||
if (authTypeValue == NULL || type >= BIT_COUNT) {
|
||||
if (authTypeValue == NULL || type >= AUTH_TYPE_BUTT) {
|
||||
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "in para error!");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ ohos_unittest("LNNTest") {
|
||||
"unittest/lane_test.cpp",
|
||||
"unittest/ledger_lane_hub_test.cpp",
|
||||
"unittest/lnn_huks_test.cpp",
|
||||
"unittest/lnn_net_ledger_test.cpp",
|
||||
"unittest/net_builder_test.cpp",
|
||||
"unittest/net_ledger_test.cpp",
|
||||
]
|
||||
|
@ -14,39 +14,43 @@
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <net/if.h>
|
||||
#include <cerrno>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
#include <net/if.h>
|
||||
#include <securec.h>
|
||||
#include <string>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <cerrno>
|
||||
#include <vector>
|
||||
|
||||
#include "auth_interface.h"
|
||||
#include "bus_center_info_key.h"
|
||||
#include "bus_center_manager.h"
|
||||
#include "lnn_bus_center_ipc.h"
|
||||
#include "lnn_connection_addr_utils.h"
|
||||
#include "lnn_network_manager.h"
|
||||
#include "lnn_distributed_net_ledger.h"
|
||||
#include "lnn_event_monitor.h"
|
||||
#include "lnn_ipc_utils.h"
|
||||
#include "lnn_local_net_ledger.h"
|
||||
#include "lnn_meta_node_ledger.h"
|
||||
#include "lnn_network_manager.h"
|
||||
#include "lnn_sync_item_info.h"
|
||||
#include "lnn_time_sync_manager.h"
|
||||
#include "message_handler.h"
|
||||
#include "softbus_bus_center.h"
|
||||
#include "softbus_conn_interface.h"
|
||||
#include "lnn_ipc_utils.h"
|
||||
#include "lnn_meta_node_ledger.h"
|
||||
#include "lnn_time_sync_manager.h"
|
||||
#include "softbus_def.h"
|
||||
#include "softbus_errcode.h"
|
||||
#include "softbus_log.h"
|
||||
#include "softbus_permission.h"
|
||||
#include "lnn_bus_center_ipc.h"
|
||||
|
||||
|
||||
namespace OHOS {
|
||||
using namespace testing::ext;
|
||||
|
@ -40,7 +40,7 @@ constexpr uint32_t REMOTE_AUTH_PORT = 7070;
|
||||
constexpr uint32_t REMOTE_PROXY_PORT = 8080;
|
||||
constexpr char REMOTE_WLAN_IP[] = "10.146.181.134";
|
||||
constexpr char LOCAL_NETWORK_ID[] = "444455556666abcdef";
|
||||
constexpr uint32_t FILE_DEFAULT_LINK_NUM = 4;
|
||||
constexpr uint32_t FILE_DEFAULT_LINK_NUM = 3;
|
||||
constexpr uint32_t LANE_PREFERRED_LINK_NUM = 2;
|
||||
constexpr uint32_t LANE_LINK_NUM = 2;
|
||||
|
||||
@ -256,12 +256,12 @@ HWTEST_F(LaneTest, LANE_SELECT_Test_001, TestSize.Level1)
|
||||
selectParam.transType = LANE_T_FILE;
|
||||
selectParam.expectedBw = 0;
|
||||
int32_t ret = SelectLane(NODE_NETWORK_ID, &selectParam, &recommendList, &listNum);
|
||||
EXPECT_TRUE(ret == SOFTBUS_OK);
|
||||
EXPECT_EQ(ret, SOFTBUS_OK);
|
||||
EXPECT_TRUE(recommendList != nullptr);
|
||||
EXPECT_TRUE(listNum == FILE_DEFAULT_LINK_NUM);
|
||||
LaneLinkType fileLinkList[FILE_DEFAULT_LINK_NUM] = {LANE_WLAN_5G, LANE_P2P, LANE_WLAN_2P4G, LANE_BR};
|
||||
EXPECT_EQ(listNum, FILE_DEFAULT_LINK_NUM);
|
||||
LaneLinkType fileLinkList[FILE_DEFAULT_LINK_NUM] = {LANE_WLAN_5G, LANE_P2P, LANE_BR};
|
||||
for (uint32_t i = 0; i < listNum; i++) {
|
||||
EXPECT_TRUE(fileLinkList[i] == recommendList[i]);
|
||||
EXPECT_EQ(fileLinkList[i], recommendList[i]) << "i = " << i;
|
||||
}
|
||||
SoftBusFree(recommendList);
|
||||
}
|
||||
|
@ -17,12 +17,23 @@
|
||||
#include <securec.h>
|
||||
|
||||
#include "bus_center_info_key.h"
|
||||
#include "bus_center_manager.h"
|
||||
#include "client_bus_center_manager.h"
|
||||
#include "lnn_connection_addr_utils.h"
|
||||
#include "lnn_distributed_net_ledger.h"
|
||||
#include "lnn_huks_utils.h"
|
||||
#include "lnn_lane_info.h"
|
||||
#include "lnn_lane_manager.h"
|
||||
#include "lnn_local_net_ledger.h"
|
||||
#include "lnn_meta_node_ledger.h"
|
||||
#include "lnn_network_id.h"
|
||||
#include "lnn_net_ledger.h"
|
||||
#include "lnn_net_ledger.c"
|
||||
#include "lnn_node_info.h"
|
||||
#include "lnn_sync_item_info.h"
|
||||
#include "message_handler.h"
|
||||
#include "softbus_adapter_mem.h"
|
||||
#include "softbus_bus_center.h"
|
||||
#include "softbus_errcode.h"
|
||||
#include "softbus_log.h"
|
||||
#include "softbus_utils.h"
|
||||
@ -51,6 +62,7 @@ constexpr char NODE4_UDID[] = "123456ABCDEY";
|
||||
constexpr char NODE4_NETWORK_ID[] = "235689BNHFCY";
|
||||
constexpr char NODE4_UUID[] = "235689BNHFCY";
|
||||
constexpr char NODE4_BT_MAC[] = "56789TTY";
|
||||
constexpr char NODE5_NETWORK_ID[] = "235689BNHFCZ";
|
||||
constexpr uint32_t REMOTE_PROXY_PORT = 8080;
|
||||
constexpr uint32_t REMOTE_AUTH_PORT = 7070;
|
||||
constexpr uint32_t REMOTE_SESSION_PORT = 6060;
|
||||
@ -297,6 +309,138 @@ static void ConstructAllCapacityLocalInfo()
|
||||
EXPECT_TRUE(ret == SOFTBUS_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: SOFTBUS_DUMP_PRINT_NET_CAPACITY_Test_001
|
||||
* @tc.desc: SoftbusDumpPrintNetCapacity test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(LedgerLaneHubTest, SOFTBUS_DUMP_PRINT_NET_CAPACITY_Test_001, TestSize.Level1)
|
||||
{
|
||||
int fd = 0;
|
||||
NodeBasicInfo nodeInfo;
|
||||
|
||||
(void)memset_s(&nodeInfo, sizeof(NodeBasicInfo), 0, sizeof(NodeBasicInfo));
|
||||
(void)strncpy_s(nodeInfo.networkId, NETWORK_ID_BUF_LEN, NODE5_NETWORK_ID, strlen(NODE5_NETWORK_ID));
|
||||
EXPECT_NE(SoftbusDumpPrintNetCapacity(fd, &nodeInfo), SOFTBUS_OK);
|
||||
|
||||
ConstructCommonLocalInfo();
|
||||
ConstructWiFiLocalInfo(true);
|
||||
|
||||
(void)memset_s(&nodeInfo, sizeof(NodeBasicInfo), 0, sizeof(NodeBasicInfo));
|
||||
(void)strncpy_s(nodeInfo.networkId, NETWORK_ID_BUF_LEN, LOCAL_NETWORKID, strlen(LOCAL_NETWORKID));
|
||||
EXPECT_EQ(SoftbusDumpPrintNetCapacity(fd, &nodeInfo), SOFTBUS_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: SOFTBUS_DUMP_PRINT_NET_TYPE_Test_001
|
||||
* @tc.desc: SoftbusDumpPrintNetType test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(LedgerLaneHubTest, SOFTBUS_DUMP_PRINT_NET_TYPE_Test_001, TestSize.Level1)
|
||||
{
|
||||
int fd = 0;
|
||||
NodeBasicInfo nodeInfo;
|
||||
|
||||
(void)memset_s(&nodeInfo, sizeof(NodeBasicInfo), 0, sizeof(NodeBasicInfo));
|
||||
(void)strncpy_s(nodeInfo.networkId, NETWORK_ID_BUF_LEN, NODE5_NETWORK_ID, strlen(NODE5_NETWORK_ID));
|
||||
EXPECT_NE(SoftbusDumpPrintNetType(fd, &nodeInfo), SOFTBUS_OK);
|
||||
|
||||
ConstructCommonLocalInfo();
|
||||
ConstructWiFiLocalInfo(true);
|
||||
|
||||
(void)memset_s(&nodeInfo, sizeof(NodeBasicInfo), 0, sizeof(NodeBasicInfo));
|
||||
(void)strncpy_s(nodeInfo.networkId, NETWORK_ID_BUF_LEN, LOCAL_NETWORKID, strlen(LOCAL_NETWORKID));
|
||||
EXPECT_EQ(SoftbusDumpPrintNetType(fd, &nodeInfo), SOFTBUS_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: LNN_SET_NODE_DATA_CHANGE_FLAG_Test_001
|
||||
* @tc.desc: Lnn Set Node Data Change Flag test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(LedgerLaneHubTest, LNN_SET_NODE_DATA_CHANGE_FLAG_Test_001, TestSize.Level1)
|
||||
{
|
||||
char *networkId = nullptr;
|
||||
char networkIdSecond[NETWORK_ID_BUF_LEN] = "1234";
|
||||
uint16_t dataChangeFlag = 0;
|
||||
EXPECT_EQ(LnnSetNodeDataChangeFlag(networkId, dataChangeFlag), SOFTBUS_ERR);
|
||||
EXPECT_EQ(LnnSetNodeDataChangeFlag(networkIdSecond, dataChangeFlag), SOFTBUS_ERR);
|
||||
|
||||
ConstructCommonLocalInfo();
|
||||
EXPECT_EQ(LnnSetNodeDataChangeFlag(LOCAL_NETWORKID, dataChangeFlag), SOFTBUS_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: LNN_SET_DATA_CHANGE_FLAG_Test_001
|
||||
* @tc.desc: Lnn Set Data Change Flag test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(LedgerLaneHubTest, LNN_SET_DATA_CHANGE_FLAG_Test_001, TestSize.Level1)
|
||||
{
|
||||
NodeInfo info;
|
||||
(void)memset_s(&info, sizeof(NodeInfo), 0, sizeof(NodeInfo));
|
||||
NodeInfo *nodeinfo = nullptr;
|
||||
uint16_t dataChangeFlag = 0;
|
||||
EXPECT_TRUE(LnnSetDataChangeFlag(nodeinfo, dataChangeFlag) == SOFTBUS_INVALID_PARAM);
|
||||
nodeinfo = &info;
|
||||
EXPECT_TRUE(LnnSetDataChangeFlag(nodeinfo, dataChangeFlag) == SOFTBUS_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: LNN_GET_DATA_CHANGE_FLAG_Test_001
|
||||
* @tc.desc: Lnn Get Data Change Flag test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(LedgerLaneHubTest, LNN_GET_DATA_CHANGE_FLAG_Test_001, TestSize.Level1)
|
||||
{
|
||||
NodeInfo info;
|
||||
(void)memset_s(&info, sizeof(NodeInfo), 0, sizeof(NodeInfo));
|
||||
NodeInfo *nodeinfo = nullptr;
|
||||
EXPECT_TRUE(LnnGetDataChangeFlag(nodeinfo) == 0);
|
||||
nodeinfo = &info;
|
||||
EXPECT_TRUE(LnnGetDataChangeFlag(nodeinfo) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: LNN_GET_LOCAL_STR_INFO_Test_001
|
||||
* @tc.desc: Lnn Get Local Str Info test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(LedgerLaneHubTest, LNN_GET_LOCAL_STR_INFO_Test_001, TestSize.Level1)
|
||||
{
|
||||
NodeInfo info;
|
||||
(void)memset_s(&info, sizeof(NodeInfo), 0, sizeof(NodeInfo));
|
||||
char *nodeInfo = reinterpret_cast<char*>(&info);
|
||||
uint32_t len = 0;
|
||||
EXPECT_TRUE(LnnSetLocalStrInfo(NUM_KEY_DATA_CHANGE_FLAG, nodeInfo) == SOFTBUS_INVALID_PARAM);
|
||||
EXPECT_TRUE(LnnGetLocalStrInfo(NUM_KEY_AUTH_PORT, nodeInfo, len) == SOFTBUS_INVALID_PARAM);
|
||||
EXPECT_TRUE(LnnGetLocalStrInfo(NUM_KEY_SESSION_PORT, nodeInfo, len) == SOFTBUS_INVALID_PARAM);
|
||||
EXPECT_TRUE(LnnGetLocalStrInfo(NUM_KEY_PROXY_PORT, nodeInfo, len) == SOFTBUS_INVALID_PARAM);
|
||||
EXPECT_TRUE(LnnGetLocalStrInfo(NUM_KEY_NET_CAP, nodeInfo, len) == SOFTBUS_INVALID_PARAM);
|
||||
EXPECT_TRUE(LnnGetLocalStrInfo(NUM_KEY_DISCOVERY_TYPE, nodeInfo, len) == SOFTBUS_INVALID_PARAM);
|
||||
EXPECT_TRUE(LnnGetLocalStrInfo(NUM_KEY_DEV_TYPE_ID, nodeInfo, len) == SOFTBUS_INVALID_PARAM);
|
||||
EXPECT_TRUE(LnnGetLocalStrInfo(NUM_KEY_MASTER_NODE_WEIGHT, nodeInfo, len) == SOFTBUS_INVALID_PARAM);
|
||||
EXPECT_TRUE(LnnGetLocalStrInfo(NUM_KEY_P2P_ROLE, nodeInfo, len) == SOFTBUS_INVALID_PARAM);
|
||||
EXPECT_TRUE(LnnGetLocalStrInfo(NUM_KEY_DATA_CHANGE_FLAG, nodeInfo, len) == SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: LNN_INIT_LOCAL_LEDGER_DELAY_Test_001
|
||||
* @tc.desc: Lnn Init Local Ledger Delay test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(LedgerLaneHubTest, LNN_INIT_LOCAL_LEDGER_DELAY_Test_001, TestSize.Level1)
|
||||
{
|
||||
EXPECT_TRUE(LnnInitLocalLedgerDelay() == SOFTBUS_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: LANE_HUB_WLAN2P4G_MESSAGE_LANE_Test_001
|
||||
* @tc.desc: Wlan2P4G message lane test
|
||||
@ -305,8 +449,11 @@ static void ConstructAllCapacityLocalInfo()
|
||||
*/
|
||||
HWTEST_F(LedgerLaneHubTest, LANE_HUB_WLAN2P4G_MESSAGE_LANE_Test_001, TestSize.Level1)
|
||||
{
|
||||
NodeInfo *info = nullptr;
|
||||
EXPECT_EQ(LnnAddOnlineNode(info), REPORT_NONE);
|
||||
ConstructWlan2P4GNode();
|
||||
LnnAddOnlineNode(&g_nodeInfo[WLAN2P4G_NUM]);
|
||||
LnnAddOnlineNode(&g_nodeInfo[WLAN2P4G_NUM]);
|
||||
ConstructCommonLocalInfo();
|
||||
ConstructWiFiLocalInfo(false);
|
||||
|
||||
|
@ -1,174 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 <securec.h>
|
||||
|
||||
#include "bus_center_info_key.h"
|
||||
#include "lnn_net_ledger.h"
|
||||
#include "lnn_connection_addr_utils.h"
|
||||
#include "lnn_network_id.h"
|
||||
#include "bus_center_manager.h"
|
||||
#include "client_bus_center_manager.h"
|
||||
#include "lnn_distributed_net_ledger.h"
|
||||
#include "lnn_huks_utils.h"
|
||||
#include "lnn_local_net_ledger.h"
|
||||
#include "lnn_meta_node_ledger.h"
|
||||
#include "lnn_node_info.h"
|
||||
#include "softbus_bus_center.h"
|
||||
#include "softbus_errcode.h"
|
||||
#include "softbus_log.h"
|
||||
#include "softbus_utils.h"
|
||||
#include "softbus_adapter_mem.h"
|
||||
#include "lnn_net_ledger.c"
|
||||
|
||||
namespace OHOS {
|
||||
using namespace testing::ext;
|
||||
|
||||
class LnnNetLedgerTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void LnnNetLedgerTest::SetUpTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void LnnNetLedgerTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void LnnNetLedgerTest::SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void LnnNetLedgerTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: LNN_SET_NODE_DATA_CHANGE_FLAG_Test_001
|
||||
* @tc.desc: Lnn Set Node Data Change Flag test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(LnnNetLedgerTest, LNN_SET_NODE_DATA_CHANGE_FLAG_Test_001, TestSize.Level0)
|
||||
{
|
||||
char *networkId = nullptr;
|
||||
char networkIdSecond[NETWORK_ID_BUF_LEN] = "1234";
|
||||
uint16_t dataChangeFlag = 0;
|
||||
EXPECT_TRUE(LnnSetNodeDataChangeFlag(networkId, dataChangeFlag) == SOFTBUS_ERR);
|
||||
EXPECT_TRUE(LnnSetNodeDataChangeFlag(networkIdSecond, dataChangeFlag) == SOFTBUS_ERR);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: SOFTBUS_DUMP_PRINT_NET_CAPACITY_Test_001
|
||||
* @tc.desc: SoftbusDumpPrintNetCapacity test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(LnnNetLedgerTest, SOFTBUS_DUMP_PRINT_NET_CAPACITY_Test_001, TestSize.Level0)
|
||||
{
|
||||
int fd = 0;
|
||||
NodeBasicInfo nodeInfo;
|
||||
(void)memset_s(&nodeInfo, sizeof(NodeBasicInfo), 0, sizeof(NodeBasicInfo));
|
||||
EXPECT_TRUE(SoftbusDumpPrintNetCapacity(fd, &nodeInfo) == SOFTBUS_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: SOFTBUS_DUMP_PRINT_NET_TYPE_Test_001
|
||||
* @tc.desc: SoftbusDumpPrintNetType test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(LnnNetLedgerTest, SOFTBUS_DUMP_PRINT_NET_TYPE_Test_001, TestSize.Level0)
|
||||
{
|
||||
int fd = 0;
|
||||
NodeBasicInfo nodeInfo;
|
||||
(void)memset_s(&nodeInfo, sizeof(NodeBasicInfo), 0, sizeof(NodeBasicInfo));
|
||||
EXPECT_TRUE(SoftbusDumpPrintNetType(fd, &nodeInfo) == SOFTBUS_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: LNN_SET_DATA_CHANGE_FLAG_Test_001
|
||||
* @tc.desc: Lnn Set Data Change Flag test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(LnnNetLedgerTest, LNN_SET_DATA_CHANGE_FLAG_Test_001, TestSize.Level0)
|
||||
{
|
||||
NodeInfo info;
|
||||
(void)memset_s(&info, sizeof(NodeInfo), 0, sizeof(NodeInfo));
|
||||
NodeInfo *nodeinfo = nullptr;
|
||||
uint16_t dataChangeFlag = 0;
|
||||
EXPECT_TRUE(LnnSetDataChangeFlag(nodeinfo, dataChangeFlag) == SOFTBUS_INVALID_PARAM);
|
||||
nodeinfo = &info;
|
||||
EXPECT_TRUE(LnnSetDataChangeFlag(nodeinfo, dataChangeFlag) == SOFTBUS_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: LNN_GET_DATA_CHANGE_FLAG_Test_001
|
||||
* @tc.desc: Lnn Get Data Change Flag test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(LnnNetLedgerTest, LNN_GET_DATA_CHANGE_FLAG_Test_001, TestSize.Level0)
|
||||
{
|
||||
NodeInfo info;
|
||||
(void)memset_s(&info, sizeof(NodeInfo), 0, sizeof(NodeInfo));
|
||||
NodeInfo *nodeinfo = nullptr;
|
||||
EXPECT_TRUE(LnnGetDataChangeFlag(nodeinfo) == 0);
|
||||
nodeinfo = &info;
|
||||
EXPECT_TRUE(LnnGetDataChangeFlag(nodeinfo) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: LNN_GET_LOCAL_STR_INFO_Test_001
|
||||
* @tc.desc: Lnn Get Local Str Info test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(LnnNetLedgerTest, LNN_GET_LOCAL_STR_INFO_Test_001, TestSize.Level0)
|
||||
{
|
||||
NodeInfo info;
|
||||
(void)memset_s(&info, sizeof(NodeInfo), 0, sizeof(NodeInfo));
|
||||
char *nodeInfo = reinterpret_cast<char*>(&info);
|
||||
uint32_t len = 0;
|
||||
EXPECT_TRUE(LnnSetLocalStrInfo(NUM_KEY_DATA_CHANGE_FLAG, nodeInfo) == SOFTBUS_INVALID_PARAM);
|
||||
EXPECT_TRUE(LnnGetLocalStrInfo(NUM_KEY_AUTH_PORT, nodeInfo, len) == SOFTBUS_INVALID_PARAM);
|
||||
EXPECT_TRUE(LnnGetLocalStrInfo(NUM_KEY_SESSION_PORT, nodeInfo, len) == SOFTBUS_INVALID_PARAM);
|
||||
EXPECT_TRUE(LnnGetLocalStrInfo(NUM_KEY_PROXY_PORT, nodeInfo, len) == SOFTBUS_INVALID_PARAM);
|
||||
EXPECT_TRUE(LnnGetLocalStrInfo(NUM_KEY_NET_CAP, nodeInfo, len) == SOFTBUS_INVALID_PARAM);
|
||||
EXPECT_TRUE(LnnGetLocalStrInfo(NUM_KEY_DISCOVERY_TYPE, nodeInfo, len) == SOFTBUS_INVALID_PARAM);
|
||||
EXPECT_TRUE(LnnGetLocalStrInfo(NUM_KEY_DEV_TYPE_ID, nodeInfo, len) == SOFTBUS_INVALID_PARAM);
|
||||
EXPECT_TRUE(LnnGetLocalStrInfo(NUM_KEY_MASTER_NODE_WEIGHT, nodeInfo, len) == SOFTBUS_INVALID_PARAM);
|
||||
EXPECT_TRUE(LnnGetLocalStrInfo(NUM_KEY_P2P_ROLE, nodeInfo, len) == SOFTBUS_INVALID_PARAM);
|
||||
EXPECT_TRUE(LnnGetLocalStrInfo(NUM_KEY_DATA_CHANGE_FLAG, nodeInfo, len) == SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: LNN_INIT_LOCAL_LEDGER_DELAY_Test_001
|
||||
* @tc.desc: Lnn Init Local Ledger Delay test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(LnnNetLedgerTest, LNN_INIT_LOCAL_LEDGER_DELAY_Test_001, TestSize.Level0)
|
||||
{
|
||||
EXPECT_TRUE(LnnInitLocalLedgerDelay() == SOFTBUS_OK);
|
||||
}
|
||||
} // namespace OHOS
|
@ -19,12 +19,14 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "auth_interface.h"
|
||||
#include "bus_center_manager.h"
|
||||
#include "lnn_decision_db.h"
|
||||
#include "lnn_decision_db.c"
|
||||
#include "lnn_distributed_net_ledger.h"
|
||||
#include "lnn_event_monitor.h"
|
||||
#include "lnn_local_net_ledger.h"
|
||||
#include "lnn_network_manager.h"
|
||||
#include "lnn_node_info.h"
|
||||
#include "softbus_log.h"
|
||||
#include "softbus_utils.h"
|
||||
#include "softbus_errcode.h"
|
||||
@ -34,6 +36,8 @@ namespace OHOS {
|
||||
using namespace testing::ext;
|
||||
constexpr uint32_t TEST_DATA_LEN = 10;
|
||||
constexpr uint8_t DEFAULT_SIZE = 5;
|
||||
constexpr char NODE1_UDID[] = "123456ABCDEF";
|
||||
constexpr char NODE2_UDID[] = "123456ABCDEG";
|
||||
|
||||
class NetLedgerTest : public testing::Test {
|
||||
public:
|
||||
@ -60,6 +64,35 @@ void NetLedgerTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: AUTH_TYPE_VALUE_SET_CLEAR_Test_001
|
||||
* @tc.desc: auth type value set and clear test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(NetLedgerTest, AUTH_TYPE_VALUE_SET_CLEAR_Test_001, TestSize.Level1)
|
||||
{
|
||||
int32_t ret;
|
||||
uint32_t authType = 0;
|
||||
uint32_t *authTypeValue = nullptr;
|
||||
|
||||
ret = LnnSetAuthTypeValue(authTypeValue, ONLINE_HICHAIN);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
ret = LnnClearAuthTypeValue(authTypeValue, ONLINE_HICHAIN);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
|
||||
authTypeValue = &authType;
|
||||
ret = LnnSetAuthTypeValue(authTypeValue, AUTH_TYPE_BUTT);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
ret = LnnClearAuthTypeValue(authTypeValue, AUTH_TYPE_BUTT);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
|
||||
ret = LnnSetAuthTypeValue(authTypeValue, ONLINE_METANODE);
|
||||
EXPECT_EQ(ret, SOFTBUS_OK);
|
||||
ret = LnnClearAuthTypeValue(authTypeValue, ONLINE_HICHAIN);
|
||||
EXPECT_EQ(ret, SOFTBUS_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: BUILD_TRUSTED_DEV_INFO_RECORD_Test_001
|
||||
* @tc.desc: build trusted dev info record test
|
||||
@ -68,13 +101,17 @@ void NetLedgerTest::TearDown()
|
||||
*/
|
||||
HWTEST_F(NetLedgerTest, BUILD_TRUSTED_DEV_INFO_RECORD_Test_001, TestSize.Level1)
|
||||
{
|
||||
int32_t ret;
|
||||
const char *udid = "testdata";
|
||||
TrustedDevInfoRecord record;
|
||||
int32_t ret;
|
||||
|
||||
(void)memset_s(&record, sizeof(TrustedDevInfoRecord), 0, sizeof(TrustedDevInfoRecord));
|
||||
ret = BuildTrustedDevInfoRecord(udid, &record);
|
||||
EXPECT_TRUE(ret == SOFTBUS_OK);
|
||||
EXPECT_EQ(ret, SOFTBUS_OK);
|
||||
|
||||
udid = nullptr;
|
||||
ret = BuildTrustedDevInfoRecord(udid, &record);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -89,8 +126,9 @@ HWTEST_F(NetLedgerTest, LNN_GET_TRUSTED_DEV_INFO_FROM_DB_Test_001, TestSize.Leve
|
||||
int32_t ret;
|
||||
|
||||
char *udidArray = new char[TEST_DATA_LEN];
|
||||
ASSERT_NE(udidArray, nullptr);
|
||||
ret = LnnGetTrustedDevInfoFromDb(&udidArray, &num);
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
EXPECT_EQ(ret, SOFTBUS_ERR);
|
||||
delete[] udidArray;
|
||||
}
|
||||
|
||||
@ -100,7 +138,7 @@ HWTEST_F(NetLedgerTest, LNN_GET_TRUSTED_DEV_INFO_FROM_DB_Test_001, TestSize.Leve
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(NetLedgerTest, DL_GET_Test_001, TestSize.Level0)
|
||||
HWTEST_F(NetLedgerTest, DL_GET_Test_001, TestSize.Level1)
|
||||
{
|
||||
char networkId[DEFAULT_SIZE] = "1234";
|
||||
int32_t info = 1234;
|
||||
@ -117,7 +155,7 @@ HWTEST_F(NetLedgerTest, DL_GET_Test_001, TestSize.Level0)
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(NetLedgerTest, LNN_ADD_META_INFO_Test_001, TestSize.Level0)
|
||||
HWTEST_F(NetLedgerTest, LNN_ADD_META_INFO_Test_001, TestSize.Level1)
|
||||
{
|
||||
NodeInfo info;
|
||||
(void)memset_s(&info, sizeof(NodeInfo), 0, sizeof(NodeInfo));
|
||||
@ -130,7 +168,7 @@ HWTEST_F(NetLedgerTest, LNN_ADD_META_INFO_Test_001, TestSize.Level0)
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(NetLedgerTest, LNN_DELETE_META_INFO_Test_001, TestSize.Level0)
|
||||
HWTEST_F(NetLedgerTest, LNN_DELETE_META_INFO_Test_001, TestSize.Level1)
|
||||
{
|
||||
char udid[DEFAULT_SIZE] = "1234";
|
||||
ConnectionAddrType type = CONNECTION_ADDR_WLAN;
|
||||
@ -143,7 +181,7 @@ HWTEST_F(NetLedgerTest, LNN_DELETE_META_INFO_Test_001, TestSize.Level0)
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(NetLedgerTest, LNN_ADD_ONLINE_NODE_Test_001, TestSize.Level0)
|
||||
HWTEST_F(NetLedgerTest, LNN_ADD_ONLINE_NODE_Test_001, TestSize.Level1)
|
||||
{
|
||||
NodeInfo *info = nullptr;
|
||||
EXPECT_TRUE(LnnAddOnlineNode(info) == REPORT_NONE);
|
||||
@ -158,7 +196,7 @@ HWTEST_F(NetLedgerTest, LNN_ADD_ONLINE_NODE_Test_001, TestSize.Level0)
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(NetLedgerTest, GET_ALL_ONLINE_AND_META_NODE_INFO_Test_001, TestSize.Level0)
|
||||
HWTEST_F(NetLedgerTest, GET_ALL_ONLINE_AND_META_NODE_INFO_Test_001, TestSize.Level1)
|
||||
{
|
||||
NodeBasicInfo base;
|
||||
NodeBasicInfo *info = nullptr;
|
||||
@ -171,4 +209,55 @@ HWTEST_F(NetLedgerTest, GET_ALL_ONLINE_AND_META_NODE_INFO_Test_001, TestSize.Lev
|
||||
infoNum = DEFAULT_SIZE;
|
||||
EXPECT_TRUE(LnnGetAllOnlineAndMetaNodeInfo(&info, &infoNum) == SOFTBUS_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: LNN_META_INFO_ADD_DEL_Test_001
|
||||
* @tc.desc: lnn add and del meta info test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(NetLedgerTest, LNN_META_INFO_ADD_DEL_Test_001, TestSize.Level1)
|
||||
{
|
||||
int32_t ret;
|
||||
NodeInfo info;
|
||||
|
||||
ret = LnnDeleteMetaInfo(NODE2_UDID, CONNECTION_ADDR_ETH);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
(void)memset_s(&info, sizeof(NodeInfo), 0, sizeof(NodeInfo));
|
||||
LnnSetDeviceUdid(&info, NODE1_UDID);
|
||||
info.metaInfo.metaDiscType = CONNECTION_ADDR_ETH;
|
||||
ret = LnnAddMetaInfo(&info);
|
||||
EXPECT_EQ(ret, SOFTBUS_OK);
|
||||
ret = LnnDeleteMetaInfo(NODE1_UDID, CONNECTION_ADDR_MAX);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
ret = LnnDeleteMetaInfo(NODE1_UDID, CONNECTION_ADDR_BLE);
|
||||
EXPECT_EQ(ret, SOFTBUS_OK);
|
||||
ret = LnnDeleteMetaInfo(NODE1_UDID, CONNECTION_ADDR_ETH);
|
||||
EXPECT_EQ(ret, SOFTBUS_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: LNN_GET_REMOTE_NUM16_INFO_Test_001
|
||||
* @tc.desc: lnn get remote num16 info test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(NetLedgerTest, LNN_GET_REMOTE_NUM16_INFO_Test_001, TestSize.Level1)
|
||||
{
|
||||
int32_t ret;
|
||||
int16_t info1 = 0;
|
||||
int16_t *info2 = nullptr;
|
||||
constexpr char *networkId = nullptr;
|
||||
|
||||
ret = LnnGetRemoteNum16Info(NODE1_UDID, NUM_KEY_META_NODE, &info1);
|
||||
EXPECT_NE(ret, SOFTBUS_INVALID_PARAM);
|
||||
ret = LnnGetRemoteNum16Info(networkId, NUM_KEY_META_NODE, &info1);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
ret = LnnGetRemoteNum16Info(networkId, NUM_KEY_META_NODE, info2);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
ret = LnnGetRemoteNum16Info(NODE1_UDID, STRING_KEY_BEGIN, &info1);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
ret = LnnGetRemoteNum16Info(NODE1_UDID, BYTE_KEY_END, &info1);
|
||||
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
Loading…
x
Reference in New Issue
Block a user