修改用例

Signed-off-by: zhangpa2021 <zhangpan70@huawei.com>
This commit is contained in:
zhangpa2021 2022-09-16 14:40:42 +08:00
parent ecc8d93f83
commit c1f6e4078a
7 changed files with 235 additions and 100 deletions

View File

@ -19,10 +19,12 @@ static int ONE_SECOND = 1;
static int32_t g_currentSessionId4Data = -1;
static int32_t g_currentSessionId4Ctl = -1;
static int32_t g_currentSessionId4Proxy = -1;
static int32_t g_waitFlag = WAIT_DEF_VALUE;
static int32_t g_waitFlag4Data = WAIT_DEF_VALUE;
static int32_t g_waitFlag4Ctl = WAIT_DEF_VALUE;
static int32_t g_waitFlag4Proxy = WAIT_DEF_VALUE;
static int32_t g_passiveOpenRetFlag = SOFTBUS_OK;
static int32_t g_nodeOnlineCount = 0;
static int32_t g_nodeOfflineCount = 0;
@ -33,6 +35,7 @@ static int32_t g_sessionCloseCount4Data = 0;
static int32_t g_sessionCloseCount4Ctrl = 0;
static int32_t g_sessionOpenCount4Data = 0;
static int32_t g_sessionOpenCount4Ctrl = 0;
static int32_t g_sessionOpenCount4Proxy = 0;
static SessionAttribute* g_sessionAttr4Data = NULL;
static SessionAttribute* g_sessionAttr4Ctl = NULL;
@ -119,6 +122,12 @@ int Wait4Session(int timeout, WaitSessionType type)
hitFlag = 1;
}
break;
case SESSION_4PROXY:
if (g_waitFlag4Proxy != WAIT_DEF_VALUE) {
LOG("Wait4Session[proxy] succ,flag:%d", g_waitFlag4Proxy);
hitFlag = 1;
}
break;
default:
LOG("Wait4Session type error");
hitFlag = 1;
@ -142,6 +151,12 @@ int Wait4Session(int timeout, WaitSessionType type)
return SOFTBUS_ERR;
}
break;
case SESSION_4PROXY:
if (g_waitFlag4Proxy != WAIT_SUCCESS_VALUE) {
LOG("Wait4Session[proxy] fail[exp:%d, real:%d]", WAIT_SUCCESS_VALUE, g_waitFlag4Proxy);
return SOFTBUS_ERR;
}
break;
default:
return SOFTBUS_ERR;
}
@ -514,9 +529,9 @@ static int ProxySessionOpened(int sessionId, int result)
{
LOG("[cb][proxy]open session proxy sid[%d],rst[%d]", sessionId, result);
if (result == SOFTBUS_OK) {
g_waitFlag = WAIT_SUCCESS_VALUE;
g_waitFlag4Proxy = WAIT_SUCCESS_VALUE;
} else {
g_waitFlag = WAIT_FAIL_VALUE;
g_waitFlag4Proxy = WAIT_FAIL_VALUE;
}
return SOFTBUS_OK;
}
@ -524,7 +539,7 @@ static int ProxySessionOpened(int sessionId, int result)
static void ProxySessionClosed(int sessionId)
{
LOG("[cb][proxy]close session proxy sid[%d]", sessionId);
g_waitFlag = WAIT_SUCCESS_VALUE;
g_waitFlag4Proxy = WAIT_SUCCESS_VALUE;
}
static void ProxyBytesReceived(int sessionId, const void* data, unsigned int dataLen)
@ -532,9 +547,9 @@ static void ProxyBytesReceived(int sessionId, const void* data, unsigned int dat
LOG("[cb][proxy]ByteRec sid:%d, data len:%u", sessionId, dataLen);
if (data == NULL) {
LOG("[cb][proxy]ByteRec invalid data=null sid:[%d]", sessionId);
g_waitFlag = WAIT_FAIL_VALUE;
g_waitFlag4Proxy = WAIT_FAIL_VALUE;
} else {
g_waitFlag = WAIT_SUCCESS_VALUE;
g_waitFlag4Proxy = WAIT_SUCCESS_VALUE;
}
}
@ -543,9 +558,9 @@ static void ProxyMessageReceived(int sessionId, const void* data, unsigned int d
LOG("[cb][proxy]MessageRec sid:%d, data len:%u", sessionId, dataLen);
if (data == NULL) {
LOG("[cb][proxy]MessageRec invalid data=null sid[%d]", sessionId);
g_waitFlag = WAIT_FAIL_VALUE;
g_waitFlag4Proxy = WAIT_FAIL_VALUE;
} else {
g_waitFlag = WAIT_SUCCESS_VALUE;
g_waitFlag4Proxy = WAIT_SUCCESS_VALUE;
}
}
@ -564,6 +579,11 @@ void ResetWaitFlag4Ctl(void)
g_waitFlag4Ctl = WAIT_DEF_VALUE;
}
void ResetWaitFlag4Proxy(void)
{
g_waitFlag4Proxy = WAIT_DEF_VALUE;
}
void ResetwaitCount4Online(void)
{
g_nodeOnlineCount = 0;
@ -656,6 +676,34 @@ int CreateSsAndOpenSession4Ctl(void)
return ret;
}
int CreateSsAndOpenSession4Proxy(void)
{
int ret;
int timeout = 10;
ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_PROXY, g_sessionlistener4Proxy);
if (ret != SOFTBUS_OK) {
LOG("call CreateSessionServer[Proxy] fail, ret:%d", ret);
return ret;
}
int sessionId;
ResetWaitFlag();
sessionId = OpenSession(SESSION_NAME_PROXY, SESSION_NAME_PROXY, g_networkId, DEF_GROUP_ID, g_sessionAttr4Proxy);
if (sessionId < SESSION_ID_MIN) {
LOG("call OpenSession[Proxy] fail, ret sid:%d", sessionId);
return SOFTBUS_ERR;
}
SetCurrentSessionId4Proxy(sessionId);
LOG("call OpenSession[Proxy] success,sid:%d", sessionId);
ret = Wait4Session(timeout, SESSION_4PROXY);
if (ret != SOFTBUS_OK) {
LOG("OpenSession[Proxy] fail");
return SOFTBUS_ERR;
}
return ret;
}
int SendData4Data(DataType type, int size)
{
int ret;
@ -717,9 +765,9 @@ int SendData4Message(DataType type, int size)
g_expectDataSize = size;
ResetWaitFlag();
if (type == DATA_TYPE_MSG) {
ret = SendMessage(g_currentSessionId4Ctl, g_expectMessageContent, size);
ret = SendMessage(g_currentSessionId4Proxy, g_expectMessageContent, size);
} else if (type == DATA_TYPE_BYTE) {
ret = SendBytes(g_currentSessionId4Ctl, g_expectMessageContent, size);
ret = SendBytes(g_currentSessionId4Proxy, g_expectMessageContent, size);
} else {
LOG("[send data]invalid param[DataType]");
free(g_expectMessageContent);
@ -784,6 +832,30 @@ int CloseSessionAndRemoveSs4Ctl(void)
}
}
int CloseSessionAndRemoveSs4Proxy(void)
{
int ret4Close;
int timeout = 2;
ResetWaitFlag();
CloseSession(g_currentSessionId4Proxy);
ret4Close = Wait(timeout);
if (ret4Close == SOFTBUS_OK) {
LOG("CloseSession[Proxy] recv callback");
}
int ret4Ss;
ret4Ss = RemoveSessionServer(DEF_PKG_NAME, SESSION_NAME_PROXY);
if (ret4Ss != SOFTBUS_OK) {
LOG("RemoveSessionServer[Proxy] fail, ret:%d", ret4Ss);
}
if (ret4Ss != SOFTBUS_OK || ret4Close == SOFTBUS_OK) {
return SOFTBUS_ERR;
} else {
return SOFTBUS_OK;
}
}
int OpenSessionBatch4Data(char groupId[][GROUP_ID_LEN], int* sessionId, int count)
{
int ret;
@ -980,6 +1052,11 @@ SessionAttribute* GetSessionAttr4Ctl(void)
return g_sessionAttr4Ctl;
}
SessionAttribute* GetSessionAttr4Proxy(void)
{
return g_sessionAttr4Proxy;
}
void SetCurrentSessionId4Data(int sessionId)
{
g_currentSessionId4Data = sessionId;
@ -990,6 +1067,12 @@ void SetCurrentSessionId4Ctl(int sessionId)
g_currentSessionId4Ctl = sessionId;
}
void SetCurrentSessionId4Proxy(int sessionId)
{
g_currentSessionId4Proxy = sessionId;
}
int GetCurrentSessionId4Data(void)
{
return g_currentSessionId4Data;
@ -1000,6 +1083,17 @@ int GetCurrentSessionId4Ctl(void)
return g_currentSessionId4Ctl;
}
int GetCurrentSessionId4Proxy(void)
{
return g_currentSessionId4Proxy;
}
int GetOpenSessionCount4Proxy(void)
{
return g_sessionOpenCount4Proxy;
}
void TestSetUp(void)
{
g_defNodeStateCallback.events = EVENT_NODE_STATE_MASK;
@ -1067,7 +1161,7 @@ void TestSetUp(void)
}
if (g_sessionAttr4Ctl == NULL) {
g_sessionAttr4Ctl = (SessionAttribute*)calloc(1, sizeof(SessionAttribute));
g_sessionAttr4Ctl->dataType = TYPE_MESSAGE;
g_sessionAttr4Ctl->dataType = TYPE_BYTES;
}
if (g_sessionAttr4Pass == NULL) {
g_sessionAttr4Pass = (SessionAttribute*)calloc(1, sizeof(SessionAttribute));

View File

@ -122,6 +122,8 @@ extern "C" {
typedef enum {
SESSION_4DATA = 1,
SESSION_4CTL,
SESSION_4PROXY,
SESSION_4STREAM,
} WaitSessionType;
typedef enum {
@ -196,6 +198,7 @@ uint64_t GetCurrentTimeOfMs(void);
void ResetWaitFlag(void);
void ResetWaitFlag4Data(void);
void ResetWaitFlag4Ctl(void);
void ResetWaitFlag4Proxy(void);
void ResetwaitCount4Online(void);
void ResetwaitCount4Offline(void);
@ -204,6 +207,7 @@ int SendData4Message(DataType type, int size);
int CreateSsAndOpenSession4Data(void);
int CreateSsAndOpenSession4Ctl(void);
int CreateSsAndOpenSession4Proxy(void);
int OpenSessionBatch4Data(char groupId[][GROUP_ID_LEN], int* sessionId, int count);
int OpenSessionBatch4Ctl(char groupId[][GROUP_ID_LEN], int* sessionId, int count);
int CloseSessionBatch4Data(int* sessionId, int count);
@ -213,8 +217,10 @@ char* GetSoftbusPid(void);
char* GetNetworkId(void);
int GetCurrentSessionId4Data(void);
int GetCurrentSessionId4Ctl(void);
int GetCurrentSessionId4Proxy(void);
void SetCurrentSessionId4Data(int sessionId);
void SetCurrentSessionId4Ctl(int sessionId);
void SetCurrentSessionId4Proxy(int sessionId);
ISessionListener* GetSessionListenser4Data(void);
ISessionListener* GetSessionListenser4Ctl(void);
SessionAttribute* GetSessionAttr4Ctl(void);
@ -229,6 +235,7 @@ int GetClosedSessionCount4Ctrl(void);
int CloseSessionAndRemoveSs4Data(void);
int CloseSessionAndRemoveSs4Ctl(void);
int CloseSessionAndRemoveSs4Proxy(void);
#ifdef __cplusplus
}

View File

@ -27,6 +27,7 @@ static ISessionListener* g_sessionlist4Ctrl = NULL;
static ISessionListener* g_sessionlist4Perf = NULL;
static ISessionListener* g_sessionlist4Pass = NULL;
static ISessionListener* g_sessionlist4File = NULL;
static ISessionListener* g_sessionlist4Proxy = NULL;
static ISessionListener *g_sessionlist4Stream = NULL;
static const char* def_passwd = "OH2022@xa";
@ -379,6 +380,39 @@ static void OnPassMessageReceived(int sessionId, const void* data, unsigned int
LOG("[cb][pass]mesg received sid:%d, data-len:%d", sessionId, dataLen);
}
static int OnProxySessionOpened(int sessionId, int result)
{
LOG("[cb][Proxy]session opened sid:%d, ret:%d", sessionId, result);
return SOFTBUS_OK;
}
static void OnProxySessionClosed(int sessionId)
{
LOG("[cb][Proxy]session closed sid:%d", sessionId);
}
static void OnProxyBytesReceived(int sessionId, const void* data, unsigned int dataLen)
{
if (sessionId < 0) {
LOG("[cb][Proxy]byte received invalid session id[%d]", sessionId);
return;
}
LOG("[cb][Proxy]byte received sid:%d, data-len:%d", sessionId, dataLen);
int ret = SendBytes(sessionId, data, dataLen);
LOG("[cb][Proxy]byte received send back:%d", ret);
}
static void OnProxyMessageReceived(int sessionId, const void* data, unsigned int dataLen)
{
if (sessionId < 0) {
LOG("[cb][Proxy]mesg received invalid session id[%d]", sessionId);
return;
}
LOG("[cb][Proxy]mesg received sid:%d, data-len:%d", sessionId, dataLen);
int ret = SendMessage(sessionId, data, dataLen);
LOG("[cb][Proxy]mesg received send back:%d", ret);
}
/* net state callback */
static void OnNodeOnline(NodeBasicInfo* info)
{
@ -442,6 +476,14 @@ static void SetupCallback(void)
g_sessionlist4Pass->OnBytesReceived = OnPassBytesReceived;
}
if (g_sessionlist4Proxy == NULL) {
g_sessionlist4Proxy = (ISessionListener*)calloc(1, sizeof(ISessionListener));
g_sessionlist4Proxy->OnSessionOpened = OnProxySessionOpened;
g_sessionlist4Proxy->OnSessionClosed = OnProxySessionClosed;
g_sessionlist4Proxy->OnMessageReceived = OnProxyMessageReceived;
g_sessionlist4Proxy->OnBytesReceived = OnProxyBytesReceived;
}
if (g_sessionlist4File == NULL) {
g_sessionlist4File = (ISessionListener*)calloc(1, sizeof(ISessionListener));
g_sessionlist4File->OnSessionOpened = OnFileSessionOpened;
@ -484,6 +526,10 @@ static void TeardownCallback(void)
free(g_sessionlist4Pass);
g_sessionlist4Pass = NULL;
}
if (g_sessionlist4Proxy != NULL) {
free(g_sessionlist4Proxy);
g_sessionlist4Proxy = NULL;
}
if (g_sessionlist4File != NULL) {
free(g_sessionlist4File);
g_sessionlist4File = NULL;
@ -515,6 +561,8 @@ HWTEST_F(dsoftbusTest, test_create_ss, TestSize.Level3)
LOG("CreateSs[perf] ret:%d", perfRet);
int passRet = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_PASS, g_sessionlist4Pass);
LOG("CreateSs[pass] ret:%d", passRet);
int proxyRet = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_PROXY, g_sessionlist4Proxy);
LOG("CreateSs[Proxy] ret:%d", proxyRet);
int fileRet = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_FILE, g_sessionlist4File);
LOG("CreateSs[file] ret:%d", fileRet);
int streamRet = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_STREAM, g_sessionlist4Stream);
@ -522,7 +570,7 @@ HWTEST_F(dsoftbusTest, test_create_ss, TestSize.Level3)
int runtime = 0;
if (dataRet == SOFTBUS_OK && ctrlRet == SOFTBUS_OK && perfRet == SOFTBUS_OK
&& passRet == SOFTBUS_OK && fileRet == SOFTBUS_OK && streamRet == SOFTBUS_OK) {
&& passRet == SOFTBUS_OK && fileRet == SOFTBUS_OK && streamRet == SOFTBUS_OK && proxyRet == SOFTBUS_OK) {
LOG("CreateSs ok");
}
@ -551,6 +599,8 @@ HWTEST_F(dsoftbusTest, test_create_ss, TestSize.Level3)
LOG("RemoveSs[perf] ret:%d", ret);
ret = RemoveSessionServer(DEF_PKG_NAME, SESSION_NAME_PASS);
LOG("RemoveSs[pass] ret:%d", ret);
ret = RemoveSessionServer(DEF_PKG_NAME, SESSION_NAME_PROXY);
LOG("RemoveSs[Proxy] ret:%d", ret);
ret = RemoveSessionServer(DEF_PKG_NAME, SESSION_NAME_FILE);
LOG("RemoveSs[file] ret:%d", ret);
ret = RemoveSessionServer(DEF_PKG_NAME, SESSION_NAME_FILE);

View File

@ -62,13 +62,13 @@ void TransReliabilityTest::TearDownTestCase()
}
/**
* @tc.number : SUB_Softbus_Trans_Reli_0100
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Reli__0100
* @tc.name : SessionId doesnt existFailed to send byte
* @tc.desc : Test Transceiver data reliability
* @tc.type : RELI
* @tc.size : MediumTest
*/
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Reli_0100, TestSize.Level3)
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Comp_OpenSession_Reli__0100, TestSize.Level3)
{
int ret;
int sessionId = 0;
@ -78,13 +78,13 @@ HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Reli_0100, TestSize.Level3)
}
/**
* @tc.number : SUB_Softbus_Trans_Reli_0200
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Reli__0200
* @tc.name : SessionId closedFailed to send byte
* @tc.desc : Test Transceiver data reliability
* @tc.type : RELI
* @tc.size : MediumTest
*/
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Reli_0200, TestSize.Level3)
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Comp_OpenSession_Reli__0200, TestSize.Level3)
{
int ret;
ret = CreateSsAndOpenSession4Data();
@ -100,13 +100,13 @@ HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Reli_0200, TestSize.Level3)
}
/**
* @tc.number : SUB_Softbus_Trans_Reli_0300
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Reli__0300
* @tc.name : send data during OpenSession
* @tc.desc : Test Transceiver data reliability
* @tc.type : FUNC
* @tc.size : MediumTest
*/
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Reli_0300, TestSize.Level3)
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Comp_OpenSession_Reli__0300, TestSize.Level3)
{
int ret;
char* softbusPidStart;
@ -160,13 +160,13 @@ HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Reli_0300, TestSize.Level3)
}
/**
* @tc.number : SUB_Softbus_Trans_Reli_0400
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Reli__0400
* @tc.name : SessionId doesnt existFailed to send Message
* @tc.desc : Test Transceiver data reliability
* @tc.type : RELI
* @tc.size : MediumTest
*/
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Reli_0400, TestSize.Level3)
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Comp_OpenSession_Reli__0400, TestSize.Level3)
{
int ret;
int sessionId = 0;
@ -176,13 +176,13 @@ HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Reli_0400, TestSize.Level3)
}
/**
* @tc.number : SUB_Softbus_Trans_Session_Reli_0100
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Reli_0500
* @tc.name : CreateSessionServer repeatedly
* @tc.desc : Test session management reliability
* @tc.type : RELI
* @tc.size : MediumTest
*/
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_0100, TestSize.Level3)
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Comp_OpenSession_Reli_0500, TestSize.Level3)
{
int ret;
char sessionNames[][SESSION_NAME_SIZE_MAX] = { "com.communication.demo1.1", "com.communication.demo1.2",
@ -207,13 +207,13 @@ HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_0100, TestSize.Lev
}
/**
* @tc.number : SUB_Softbus_Trans_Session_Reli_0200
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Reli_0600
* @tc.name : CreateSessionServer input wrong value
* @tc.desc : Test session management reliability
* @tc.type : RELI
* @tc.size : MediumTest
*/
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_0200, TestSize.Level3)
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Comp_OpenSession_Reli_0600, TestSize.Level3)
{
int ret;
ret = CreateSessionServer(NULL, SESSION_NAME_DATA, GetSessionListenser4Data());
@ -239,13 +239,13 @@ HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_0200, TestSize.Lev
}
/**
* @tc.number : SUB_Softbus_Trans_Session_Reli_0300
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Reli_0700
* @tc.name : RemoveSessionServer input wrong value
* @tc.desc : Test session management reliability
* @tc.type : RELI
* @tc.size : MediumTest
*/
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_0300, TestSize.Level3)
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Comp_OpenSession_Reli_0700, TestSize.Level3)
{
int ret;
ret = RemoveSessionServer(NULL, SESSION_NAME_DATA);
@ -257,81 +257,65 @@ HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_0300, TestSize.Lev
}
/**
* @tc.number : SUB_Softbus_Trans_Session_Reli_0400
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Reli_0800
* @tc.name : RemoveSessionServer There are unclosed Session
* @tc.desc : Test session management reliability
* @tc.type : RELI
* @tc.size : MediumTest
*/
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_0400, TestSize.Level3)
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Comp_OpenSession_Reli_0800, TestSize.Level3)
{
int ret;
ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_DATA, GetSessionListenser4Data());
EXPECT_EQ(SOFTBUS_OK, ret) << "CreateSS[data] fail";
ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_CTL, GetSessionListenser4Ctl());
EXPECT_EQ(SOFTBUS_OK, ret) << "CreateSS[ctrl] fail";
int count = MAX_SESSION_NUM / 2;
int sessionId4Data[count];
int sessionId4Ctrl[count];
char groupId[][GROUP_ID_LEN] = { "g1", "g2", "g3", "g4", "g5", "g6", "g7", "g8" };
ret = OpenSessionBatch4Data(groupId, sessionId4Data, count);
EXPECT_EQ(SOFTBUS_OK, ret) << "OpenSessionWithDiffGroupId4Data fail";
ret = OpenSessionBatch4Ctl(groupId, sessionId4Ctrl, count);
EXPECT_EQ(SOFTBUS_OK, ret) << "OpenSessionWithDiffGroupId4Ctl fail";
ResetClosedSessionCount4Ctrl();
ResetClosedSessionCount4Data();
// remove session server, will close opened session
ret = RemoveSessionServer(DEF_PKG_NAME, SESSION_NAME_DATA);
EXPECT_EQ(SOFTBUS_OK, ret) << "RemoveSS[data] fail";
ret = RemoveSessionServer(DEF_PKG_NAME, SESSION_NAME_CTL);
EXPECT_EQ(SOFTBUS_OK, ret) << "RemoveSS[ctrl] fail";
// check close session callback
int timeout = 20;
while (timeout > 0) {
sleep(1);
if (GetClosedSessionCount4Ctrl() == count && GetClosedSessionCount4Data() == count) {
if (GetClosedSessionCount4Data() == count) {
LOG("callback count right, timeout:%d", timeout);
break;
}
timeout--;
}
EXPECT_EQ(count, GetClosedSessionCount4Ctrl());
EXPECT_EQ(count, GetClosedSessionCount4Data());
// create new,expect success
ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_DATA, GetSessionListenser4Data());
EXPECT_EQ(SOFTBUS_OK, ret) << "CreateSS[data] fail";
ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_CTL, GetSessionListenser4Ctl());
EXPECT_EQ(SOFTBUS_OK, ret) << "CreateSS[ctrl] fail";
ret = OpenSessionBatch4Data(groupId, sessionId4Data, count);
EXPECT_EQ(SOFTBUS_OK, ret) << "OpenSessionWithDiffGroupId4Data fail";
ret = OpenSessionBatch4Ctl(groupId, sessionId4Ctrl, count);
EXPECT_EQ(SOFTBUS_OK, ret) << "OpenSessionWithDiffGroupId4Ctl fail";
// close session,expect success
ret = CloseSessionBatch4Data(sessionId4Data, count);
EXPECT_EQ(SOFTBUS_OK, ret) << "CloseSessionBatch4Data fail";
ret = CloseSessionBatch4Ctl(sessionId4Ctrl, count);
EXPECT_EQ(SOFTBUS_OK, ret) << "CloseSessionBatch4Ctl fail";
// remove session server
ret = RemoveSessionServer(DEF_PKG_NAME, SESSION_NAME_DATA);
EXPECT_EQ(SOFTBUS_OK, ret) << "RemoveSS[data] fail";
ret = RemoveSessionServer(DEF_PKG_NAME, SESSION_NAME_CTL);
EXPECT_EQ(SOFTBUS_OK, ret) << "RemoveSS[ctrl] fail";
}
/**
* @tc.number : SUB_Softbus_Trans_Session_Reli_0500
* @tc.name : OpenSession SessionServer do not exist
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Reli_0900
* @tc.name : OpenSession, SessionServer do not exist
* @tc.desc : Test session management reliability
* @tc.type : RELI
* @tc.size : MediumTest
*/
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_0500, TestSize.Level3)
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Comp_OpenSession_Reli_0900, TestSize.Level3)
{
int ret;
int sessionId;
@ -344,13 +328,13 @@ HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_0500, TestSize.Lev
}
/**
* @tc.number : SUB_Softbus_Trans_Session_Reli_0600
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Reli_1000
* @tc.name : OpenSession Open the same one repeatedly
* @tc.desc : Test session management reliability
* @tc.type : RELI
* @tc.size : MediumTest
*/
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_0600, TestSize.Level3)
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Comp_OpenSession_Reli_1000, TestSize.Level3)
{
int ret;
int sessionId;
@ -369,13 +353,13 @@ HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_0600, TestSize.Lev
}
/**
* @tc.number : SUB_Softbus_Trans_Session_Reli_0700
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Reli_1100
* @tc.name : OpenSession input wrong value
* @tc.desc : Test session management reliability
* @tc.type : RELI
* @tc.size : MediumTest
*/
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_0700, TestSize.Level3)
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Comp_OpenSession_Reli_1100, TestSize.Level3)
{
int ret;
ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_DATA, GetSessionListenser4Data());
@ -412,13 +396,13 @@ HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_0700, TestSize.Lev
}
/**
* @tc.number : SUB_Softbus_Trans_Session_Reli_0800
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Reli_1200
* @tc.name : CloseSession repeatedly
* @tc.desc : Test session management reliability
* @tc.type : RELI
* @tc.size : MediumTest
*/
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_0800, TestSize.Level3)
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Comp_OpenSession_Reli_1200, TestSize.Level3)
{
int ret;
int sessionId;
@ -453,13 +437,13 @@ HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_0800, TestSize.Lev
}
/**
* @tc.number : SUB_Softbus_Trans_Session_Reli_0900
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Reli_1300
* @tc.name : CloseSession not exist sessionId
* @tc.desc : Test session management reliability
* @tc.type : RELI
* @tc.size : MediumTest
*/
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_0900, TestSize.Level3)
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Comp_OpenSession_Reli_1300, TestSize.Level3)
{
int ret;
int timeout = 3;
@ -483,13 +467,13 @@ HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_0900, TestSize.Lev
}
/**
* @tc.number : SUB_Softbus_Trans_Session_Reli_1000
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Reli_1400
* @tc.name : GetMySessionName input wrong value
* @tc.desc : Test session management reliability
* @tc.type : RELI
* @tc.size : MediumTest
*/
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_1000, TestSize.Level3)
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Comp_OpenSession_Reli_1400, TestSize.Level3)
{
int ret;
int sessionId;
@ -518,13 +502,13 @@ HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_1000, TestSize.Lev
}
/**
* @tc.number : SUB_Softbus_Trans_Session_Reli_1100
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Reli_1500
* @tc.name : GetPeersessionName input wrong value
* @tc.desc : Test session management reliability
* @tc.type : RELI
* @tc.size : MediumTest
*/
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_1100, TestSize.Level3)
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Comp_OpenSession_Reli_1500, TestSize.Level3)
{
int ret;
int sessionId;
@ -553,13 +537,13 @@ HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_1100, TestSize.Lev
}
/**
* @tc.number : SUB_Softbus_Trans_Session_Reli_1200
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Reli_1600
* @tc.name : GetPeerDeviceId input wrong value
* @tc.desc : Test session management reliability
* @tc.type : RELI
* @tc.size : MediumTest
*/
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_1200, TestSize.Level3)
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Comp_OpenSession_Reli_1600, TestSize.Level3)
{
int ret;
int sessionId;
@ -588,13 +572,13 @@ HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_1200, TestSize.Lev
}
/**
* @tc.number : SUB_Softbus_Trans_Session_Reli_1300
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Reli_1700
* @tc.name : OpenSession, no Session Server exists on the peer
* @tc.desc : Test session management reliability
* @tc.type : RELI
* @tc.size : MediumTest
*/
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Session_Reli_1300, TestSize.Level3)
HWTEST_F(TransReliabilityTest, SUB_Softbus_Trans_Comp_OpenSession_Reli_1700, TestSize.Level3)
{
int ret;
char* softbusPidStart;

View File

@ -177,14 +177,14 @@ HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_0500, TestSize.Leve
HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_0600, TestSize.Level3)
{
int ret;
ret = CreateSsAndOpenSession4Ctl();
ret = CreateSsAndOpenSession4Proxy();
ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
int size = 1;
ret = SendData4Message(DATA_TYPE_BYTE, size);
EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte, 1B) fail";
ret = CloseSessionAndRemoveSs4Ctl();
ret = CloseSessionAndRemoveSs4Proxy();
EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
}
@ -198,14 +198,14 @@ HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_0600, TestSize.Leve
HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_0700, TestSize.Level3)
{
int ret;
ret = CreateSsAndOpenSession4Ctl();
ret = CreateSsAndOpenSession4Proxy();
ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
int size = 2 * 1024;
ret = SendData4Message(DATA_TYPE_BYTE, size);
EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte,2M) fail";
ret = CloseSessionAndRemoveSs4Ctl();
ret = CloseSessionAndRemoveSs4Proxy();
EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
}
@ -219,14 +219,14 @@ HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_0700, TestSize.Leve
HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_0800, TestSize.Level3)
{
int ret;
ret = CreateSsAndOpenSession4Ctl();
ret = CreateSsAndOpenSession4Proxy();
ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
int size = 4 * 1024;
ret = SendData4Message(DATA_TYPE_BYTE, size);
EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(byte,Max) fail";
ret = CloseSessionAndRemoveSs4Ctl();
ret = CloseSessionAndRemoveSs4Proxy();
EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
}
@ -240,16 +240,16 @@ HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_0800, TestSize.Leve
HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_0900, TestSize.Level3)
{
int ret;
ret = CreateSsAndOpenSession4Ctl();
ret = CreateSsAndOpenSession4Proxy();
ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
int size = 0;
string emptyStr = "";
int sessionId = GetCurrentSessionId4Ctl();
int sessionId = GetCurrentSessionId4Proxy();
ret = SendBytes(sessionId, emptyStr.c_str(), size);
EXPECT_NE(SOFTBUS_OK, ret) << "call sendbytes(empty) fail";
ret = CloseSessionAndRemoveSs4Ctl();
ret = CloseSessionAndRemoveSs4Proxy();
EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
}
@ -263,14 +263,14 @@ HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_0900, TestSize.Leve
HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendBytes_Fun_1000, TestSize.Level3)
{
int ret;
ret = CreateSsAndOpenSession4Ctl();
ret = CreateSsAndOpenSession4Proxy();
ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
int size = 4 * 1024 + 1;
ret = SendData4Message(DATA_TYPE_BYTE, size);
EXPECT_NE(SOFTBUS_OK, ret) << "call sendbytes(empty) fail";
ret = CloseSessionAndRemoveSs4Ctl();
ret = CloseSessionAndRemoveSs4Proxy();
EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
}
@ -396,14 +396,14 @@ HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_0500, TestSize.Le
HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_0600, TestSize.Level3)
{
int ret;
ret = CreateSsAndOpenSession4Ctl();
ret = CreateSsAndOpenSession4Proxy();
ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
int size = 1;
ret = SendData4Message(DATA_TYPE_MSG, size);
EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(msg, 1B) fail";
ret = CloseSessionAndRemoveSs4Ctl();
ret = CloseSessionAndRemoveSs4Proxy();
EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
}
@ -417,14 +417,14 @@ HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_0600, TestSize.Le
HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_0700, TestSize.Level3)
{
int ret;
ret = CreateSsAndOpenSession4Ctl();
ret = CreateSsAndOpenSession4Proxy();
ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
int size = 1000;
ret = SendData4Message(DATA_TYPE_MSG, size);
EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(msg,1K) fail";
ret = CloseSessionAndRemoveSs4Ctl();
ret = CloseSessionAndRemoveSs4Proxy();
EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
}
@ -438,14 +438,14 @@ HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_0700, TestSize.Le
HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_0800, TestSize.Level3)
{
int ret;
ret = CreateSsAndOpenSession4Ctl();
ret = CreateSsAndOpenSession4Proxy();
ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
int size = TRANS_PROXY_MESSAGE_LENGTH_MAX;
ret = SendData4Message(DATA_TYPE_MSG, size);
EXPECT_EQ(SOFTBUS_OK, ret) << "SendData4Data(msg,Max) fail";
ret = CloseSessionAndRemoveSs4Ctl();
ret = CloseSessionAndRemoveSs4Proxy();
EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
}
@ -459,16 +459,16 @@ HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_0800, TestSize.Le
HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_0900, TestSize.Level3)
{
int ret;
ret = CreateSsAndOpenSession4Ctl();
ret = CreateSsAndOpenSession4Proxy();
ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
int size = 0;
string emptystr = "";
int sessionId = GetCurrentSessionId4Ctl();
int sessionId = GetCurrentSessionId4Proxy();
ret = SendMessage(sessionId, emptystr.c_str(), size);
EXPECT_NE(SOFTBUS_OK, ret) << "call sendmsg(empty) fail";
ret = CloseSessionAndRemoveSs4Ctl();
ret = CloseSessionAndRemoveSs4Proxy();
EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
}
@ -482,13 +482,13 @@ HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_0900, TestSize.Le
HWTEST_F(TransFuncTest, SUB_Softbus_Trans_Comp_SendMessage_Fun_1000, TestSize.Level3)
{
int ret;
ret = CreateSsAndOpenSession4Ctl();
ret = CreateSsAndOpenSession4Proxy();
ASSERT_EQ(SOFTBUS_OK, ret) << "create Ss and openS[data] fail";
int size = TRANS_PROXY_MESSAGE_LENGTH_MAX + 1;
ret = SendData4Message(DATA_TYPE_MSG, size);
EXPECT_NE(SOFTBUS_OK, ret) << "call sendmsg(Max+1) fail";
ret = CloseSessionAndRemoveSs4Ctl();
ret = CloseSessionAndRemoveSs4Proxy();
EXPECT_EQ(SOFTBUS_OK, ret) << "close session and remove Ss fail";
}

View File

@ -113,13 +113,13 @@ static int WaitStream(int timeout)
}
/**
* @tc.number : SUB_Softbus_Trans_SendStream_Func_0100
* @tc.number : SUB_Softbus_Trans_Comp_SendStream_0100
* @tc.name : test Stream
* @tc.desc : Test send stream function
* @tc.type : FUNC
* @tc.size : MediumTest
*/
HWTEST_F(TransStreamTest, SUB_Softbus_Trans_SendStream_Func_0100, TestSize.Level2) {
HWTEST_F(TransStreamTest, SUB_Softbus_Trans_Comp_SendStream_0100, TestSize.Level2) {
int ret;
string data = "send stream transmission test!!!!";

View File

@ -62,14 +62,14 @@ void TransSessionFuncTest::TearDownTestCase()
}
/**
* @tc.number : SUB_Softbus_Trans_Session_Func_0100
* @tc.name : one Client creates SessionServer + 1, Max succeeds, 1
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Func_0100
* @tc.name : one Client creates SessionServer + 1, Max succeeds, 1
* fails
* @tc.desc : Test session management
* @tc.type : FUNC
* @tc.size : MediumTest
* @tc.desc : Test session management
* @tc.type : FUNC
* @tc.size : MediumTest
*/
HWTEST_F(TransSessionFuncTest, SUB_Softbus_Trans_Session_Func_0100, TestSize.Level3)
HWTEST_F(TransSessionFuncTest, SUB_Softbus_Trans_Comp_OpenSession_Func_0100, TestSize.Level3)
{
int ret;
char sessionNames[][SESSION_NAME_SIZE_MAX] = { "com.communication.demo1.1", "com.communication.demo1.2",
@ -94,13 +94,13 @@ HWTEST_F(TransSessionFuncTest, SUB_Softbus_Trans_Session_Func_0100, TestSize.Lev
}
/**
* @tc.number : SUB_Softbus_Trans_Session_Func_0200
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Func_0200
* @tc.name : OpenSession + 1, Max succeeds, 1 fails
* @tc.desc : Test session management
* @tc.type : FUNC
* @tc.size : MediumTest
*/
HWTEST_F(TransSessionFuncTest, SUB_Softbus_Trans_Session_Func_0200, TestSize.Level3)
HWTEST_F(TransSessionFuncTest, SUB_Softbus_Trans_Comp_OpenSession_Func_0200, TestSize.Level3)
{
int ret;
ret = CreateSessionServer(DEF_PKG_NAME, SESSION_NAME_DATA, GetSessionListenser4Data());
@ -136,13 +136,13 @@ HWTEST_F(TransSessionFuncTest, SUB_Softbus_Trans_Session_Func_0200, TestSize.Lev
}
/**
* @tc.number : SUB_Softbus_Trans_Session_Func_0300
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Func_0300
* @tc.name : Obtain DevicedName based on Sessionid
* @tc.desc : Test session management
* @tc.type : FUNC
* @tc.size : MediumTest
*/
HWTEST_F(TransSessionFuncTest, SUB_Softbus_Trans_Session_Func_0300, TestSize.Level3)
HWTEST_F(TransSessionFuncTest, SUB_Softbus_Trans_Comp_OpenSession_Func_0300, TestSize.Level3)
{
int ret;
ret = CreateSsAndOpenSession4Data();
@ -164,13 +164,13 @@ HWTEST_F(TransSessionFuncTest, SUB_Softbus_Trans_Session_Func_0300, TestSize.Lev
}
/**
* @tc.number : SUB_Softbus_Trans_Session_Func_0400
* @tc.number : SUB_Softbus_Trans_Comp_OpenSession_Func_0400
* @tc.name : Obtain DevicedId based on Sessionid
* @tc.desc : Test session management
* @tc.type : FUNC
* @tc.size : MediumTest
*/
HWTEST_F(TransSessionFuncTest, SUB_Softbus_Trans_Session_Func_0400, TestSize.Level3)
HWTEST_F(TransSessionFuncTest, SUB_Softbus_Trans_Comp_OpenSession_Func_0400, TestSize.Level3)
{
int ret;
ret = CreateSsAndOpenSession4Ctl();