ut failed

Signed-off-by: xzh457 <xiaozihan4@h-partners.com>
Change-Id: I83de7c76966f03a3cbd99387f4577ccfc912e85b
This commit is contained in:
xzh457 2024-11-15 16:05:02 +08:00
parent 8c7f598d21
commit 1f586b18fa
3 changed files with 12 additions and 13 deletions

View File

@ -411,20 +411,21 @@ HWTEST_F(TransAuthChannelTest, OperateAuthChannelInfoTest002, TestSize.Level1)
ASSERT_EQ(ret, SOFTBUS_OK);
ret = AddAuthChannelInfo(NULL);
EXPECT_EQ(ret, SOFTBUS_INVALID_PARAM);
DelAuthChannelInfoByChanId(TRANS_TEST_CHANNEL_ID);
bool isClient = true;
AuthChannelInfo *info = CreateAuthChannelInfo(g_sessionName, isClient);
info->authId = TRANS_TEST_AUTH_ID;
EXPECT_TRUE(info != nullptr);
ret = AddAuthChannelInfo(info);
ASSERT_EQ(ret, SOFTBUS_OK);
AuthChannelInfo *newInfo = (AuthChannelInfo *)SoftBusCalloc(sizeof(AuthChannelInfo));
ASSERT_TRUE(newInfo != nullptr);
int32_t channelId = info->appInfo.myData.channelId;
newInfo->authId = TRANS_TEST_AUTH_ID;
ret = GetAuthChannelInfoByChanId(channelId, newInfo);
EXPECT_EQ(ret, SOFTBUS_OK);
ret = AddAuthChannelInfo(info);
EXPECT_NE(ret, SOFTBUS_OK);
DelAuthChannelInfoByChanId(channelId);
DelAuthChannelInfoByAuthId(TRANS_TEST_AUTH_ID);
SoftBusFree(newInfo);
TransSessionMgrDeinit();
TransAuthDeinit();
@ -444,7 +445,6 @@ HWTEST_F(TransAuthChannelTest, OperateAuthChannelInfoTest003, TestSize.Level1)
ASSERT_EQ(ret, SOFTBUS_OK);
ret = TransCreateSessionServer(g_pkgName, g_sessionName, TRANS_TEST_INVALID_UID, TRANS_TEST_INVALID_PID);
ASSERT_EQ(ret, SOFTBUS_OK);
DelAuthChannelInfoByAuthId(TRANS_TEST_AUTH_ID);
bool isClient = true;
AuthChannelInfo *info = CreateAuthChannelInfo(g_sessionName, isClient);
ASSERT_TRUE(info != nullptr);
@ -454,7 +454,7 @@ HWTEST_F(TransAuthChannelTest, OperateAuthChannelInfoTest003, TestSize.Level1)
int32_t channelId = info->appInfo.myData.channelId;
ret = GetAuthIdByChannelId(channelId);
EXPECT_EQ(ret, TRANS_TEST_AUTH_ID);
DelAuthChannelInfoByChanId(channelId);
DelAuthChannelInfoByAuthId(TRANS_TEST_AUTH_ID);
ret = GetAuthIdByChannelId(channelId);
EXPECT_NE(ret, SOFTBUS_OK);
TransSessionMgrDeinit();
@ -469,6 +469,7 @@ HWTEST_F(TransAuthChannelTest, OperateAuthChannelInfoTest003, TestSize.Level1)
*/
HWTEST_F(TransAuthChannelTest, OperateAuthChannelInfoTest004, TestSize.Level1)
{
int32_t authId = TRANS_TEST_SESSION_ID;
int32_t ret = TransSessionMgrInit();
ASSERT_EQ(ret, SOFTBUS_OK);
ret = TransAuthInit(callback);
@ -478,17 +479,15 @@ HWTEST_F(TransAuthChannelTest, OperateAuthChannelInfoTest004, TestSize.Level1)
bool isClient = true;
AuthChannelInfo *info = CreateAuthChannelInfo(g_sessionName, isClient);
ASSERT_TRUE(info != nullptr);
info->authId = TRANS_TEST_AUTH_ID;
info->authId = TRANS_TEST_SESSION_ID;
ret = AddAuthChannelInfo(info);
ASSERT_EQ(ret, SOFTBUS_OK);
AuthChannelInfo *newInfo = (AuthChannelInfo *)SoftBusCalloc(sizeof(AuthChannelInfo));
ASSERT_TRUE(newInfo != nullptr);
ret = GetChannelInfoByAuthId(TRANS_TEST_AUTH_ID, newInfo);
ret = GetChannelInfoByAuthId(TRANS_TEST_SESSION_ID, newInfo);
EXPECT_EQ(ret, SOFTBUS_OK);
ret = memcmp(info, newInfo, sizeof(AuthChannelInfo));
EXPECT_EQ(ret, EOK);
DelAuthChannelInfoByAuthId(TRANS_TEST_AUTH_ID);
ret = GetChannelInfoByAuthId(TRANS_TEST_AUTH_ID, newInfo);
DelAuthChannelInfoByAuthId(authId);
ret = GetChannelInfoByAuthId(TRANS_TEST_SESSION_ID, newInfo);
EXPECT_NE(ret, SOFTBUS_OK);
SoftBusFree(newInfo);
TransSessionMgrDeinit();

View File

@ -1092,7 +1092,7 @@ HWTEST_F(TransLanePendingTest, TransWaitingFreeLane001, TestSize.Level1)
ret = TransAddFreeLaneToPending(laneReqId);
EXPECT_EQ(SOFTBUS_OK, ret);
ret = TransWaitingFreeLane(laneReqId);
EXPECT_EQ(SOFTBUS_OK, ret);
EXPECT_EQ(SOFTBUS_TRANS_LANE_IS_EXISTED, ret);
ret = TransDelLaneFreeFromPending(laneReqId, false);
EXPECT_EQ(SOFTBUS_OK, ret);
@ -1119,7 +1119,7 @@ HWTEST_F(TransLanePendingTest, TransFreeLaneByLaneHandle001, TestSize.Level1)
ret = TransAddFreeLaneToPending(laneReqId);
EXPECT_EQ(SOFTBUS_OK, ret);
ret = TransFreeLaneByLaneHandle(laneReqId, false);
EXPECT_EQ(SOFTBUS_OK, ret);
EXPECT_EQ(SOFTBUS_TRANS_LANE_IS_EXISTED, ret);
ret = TransDelLaneFreeFromPending(laneReqId, false);
EXPECT_EQ(SOFTBUS_OK, ret);

View File

@ -492,7 +492,7 @@ HWTEST_F(SoftbusProxyChannelMessageTest, TransProxyParseMessageTest001, TestSize
msg.msgHead.cipher = 0;
ASSERT_TRUE(EOK == memcpy_s(buf, len, &msg, len));
ret = TransProxyParseMessage(buf, len, &msg, &authHandle);
EXPECT_EQ(SOFTBUS_OK, ret);
EXPECT_EQ(SOFTBUS_TRANS_INVALID_MESSAGE_TYPE, ret);
/* test normal message encrypte, and channel not exist */
msg.msgHead.cipher = 1;