未验证 提交 8029188b 编写于 作者: O openharmony_ci 提交者: Gitee

!1966 完善元能力、设备包管理和dsoftbus的xts用例

Merge pull request !1966 from 闻飞/master
......@@ -25,6 +25,7 @@ hctest_suite("ActsDsoftbusMgrTest") {
"//foundation/communication/dsoftbus/interfaces/kits/bus_center",
"//foundation/communication/dsoftbus/interfaces/kits/common",
"//foundation/communication/dsoftbus/core/common/include",
"//foundation/communication/dsoftbus/core/frame/common/include",
"//foundation/communication/dsoftbus/interfaces/kits/discovery",
"//foundation/communication/dsoftbus/adapter/common/include",
"//foundation/communication/dsoftbus/adapter/default_config/spec_config",
......
......@@ -14,6 +14,7 @@
*/
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include "hctest.h"
#include "securec.h"
......@@ -21,11 +22,17 @@
#include "softbus_bus_center.h"
#include "softbus_errcode.h"
#include "discovery_service.h"
#include "softbus_server_frame.h"
#include "cmsis_os.h"
#define UI_MAIN_TASK_DELAY 10000
#define MAINLOOP_STACK_SIZE 5120
#define SLEEP_TIME 4
static int32_t serverInit = 0;
static int g_subscribeId = 0;
static int g_publishId = 0;
static const char *g_pkgName = "Softbus_Kits";
static const char *g_erroPkgName = "Softbus_Erro_Kits";
static const int32_t ERRO_CAPDATA_LEN = 514;
......@@ -123,9 +130,31 @@ static IPublishCallback g_publishCb = {
LITE_TEST_SUIT(dsoftbus, discoveryservice, DiscoveryServiceTestSuite);
static void *ServerInit(void *arg)
{
printf("----------start ServerInit-------------\n");
InitSoftBusServer();
return NULL;
}
static void ThreadCreateTest(void *(*entry)(void *arg))
{
pthread_t tid;
pthread_attr_t threadAttr;
pthread_attr_init(&threadAttr);
pthread_attr_setstacksize(&threadAttr, MAINLOOP_STACK_SIZE);
pthread_create(&tid, &threadAttr, entry, 0);
}
static BOOL DiscoveryServiceTestSuiteSetUp(void)
{
printf("----------test case with DiscoveryServiceTestSuite start-------------\n");
if (GetServerIsInit() == false) {
printf("----------Server Is not Init-------------\n");
ThreadCreateTest(ServerInit);
sleep(SLEEP_TIME);
}
serverInit = 1;
return TRUE;
}
......@@ -154,6 +183,10 @@ LITE_TEST_CASE(DiscoveryServiceTestSuite, PublishServiceTest001, Function | Medi
.dataLen = sizeof("capdata2")
};
while (GetServerIsInit() == false) {
sleep(1);
}
osDelay(UI_MAIN_TASK_DELAY);
ret = PublishService(NULL, &testInfo, &g_publishCb);
TEST_ASSERT_TRUE(ret != 0);
......@@ -187,42 +220,6 @@ LITE_TEST_CASE(DiscoveryServiceTestSuite, PublishServiceTest001, Function | Medi
ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
TEST_ASSERT_TRUE(ret != 0);
testInfo.dataLen = sizeof("capdata1");
ret = PublishService(g_erroPkgName, &testInfo, &g_publishCb);
TEST_ASSERT_TRUE(ret != 0);
}
/**
* @tc.name: PublishServiceTest002
* @tc.desc: Verify normal case
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE(DiscoveryServiceTestSuite, PublishServiceTest002, Function | MediumTest | Level0)
{
int ret;
g_pInfo.publishId = GetPublishId();
ret = PublishService(g_pkgName, &g_pInfo, &g_publishCb);
TEST_ASSERT_TRUE(ret == SOFTBUS_DISCOVER_MANAGER_NOT_INIT);
g_pInfo1.publishId = GetPublishId();
ret = PublishService(g_pkgName, &g_pInfo1, &g_publishCb);
TEST_ASSERT_TRUE(ret == SOFTBUS_DISCOVER_MANAGER_NOT_INIT);
}
/**
* @tc.name: PublishServiceTest003
* @tc.desc: Verify same parameter again
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE(DiscoveryServiceTestSuite, PublishServiceTest003, Function | MediumTest | Level0)
{
int ret;
g_pInfo.publishId = GetPublishId();
ret = PublishService(g_pkgName, &g_pInfo, &g_publishCb);
TEST_ASSERT_TRUE(ret == SOFTBUS_DISCOVER_MANAGER_NOT_INIT);
}
/**
......@@ -235,52 +232,8 @@ LITE_TEST_CASE(DiscoveryServiceTestSuite, UnPublishServiceTest001, Function | Me
{
int ret;
int tmpId = GetPublishId();
g_pInfo.publishId = tmpId;
PublishService(g_pkgName, &g_pInfo, &g_publishCb);
ret = UnPublishService(NULL, tmpId);
TEST_ASSERT_TRUE(ret != 0);
ret = UnPublishService(g_erroPkgName, tmpId);
TEST_ASSERT_TRUE(ret != 0);
}
/**
* @tc.name: UnPublishServiceTest002
* @tc.desc: Verify normal case
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE(DiscoveryServiceTestSuite, UnPublishServiceTest002, Function | MediumTest | Level0)
{
int ret;
int tmpId1 = GetPublishId();
int tmpId2 = GetPublishId();
g_pInfo.publishId = tmpId1;
PublishService(g_pkgName, &g_pInfo, &g_publishCb);
g_pInfo1.publishId = tmpId2;
PublishService(g_pkgName, &g_pInfo1, &g_publishCb);
ret = UnPublishService(g_pkgName, tmpId1);
TEST_ASSERT_TRUE(ret == SOFTBUS_DISCOVER_MANAGER_NOT_INIT);
ret = UnPublishService(g_pkgName, tmpId2);
TEST_ASSERT_TRUE(ret == SOFTBUS_DISCOVER_MANAGER_NOT_INIT);
}
/**
* @tc.name: UnPublishServiceTest003
* @tc.desc: Verify same parameter again
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE(DiscoveryServiceTestSuite, UnPublishServiceTest003, Function | MediumTest | Level0)
{
int ret;
int tmpId = GetPublishId();
g_pInfo.publishId = tmpId;
PublishService(g_pkgName, &g_pInfo, &g_publishCb);
ret = UnPublishService(g_pkgName, tmpId);
TEST_ASSERT_TRUE(ret == SOFTBUS_DISCOVER_MANAGER_NOT_INIT);
}
/**
......@@ -307,9 +260,6 @@ LITE_TEST_CASE(DiscoveryServiceTestSuite, StartDiscoveryTest001, Function | Medi
ret = StartDiscovery(NULL, &testInfo, &g_subscribeCb);
TEST_ASSERT_TRUE(ret != 0);
ret = StartDiscovery(g_erroPkgName, &testInfo, &g_subscribeCb);
TEST_ASSERT_TRUE(ret != 0);
ret = StartDiscovery(g_pkgName, NULL, &g_subscribeCb);
TEST_ASSERT_TRUE(ret != 0);
......@@ -342,40 +292,6 @@ LITE_TEST_CASE(DiscoveryServiceTestSuite, StartDiscoveryTest001, Function | Medi
testInfo.dataLen = sizeof("capdata1");
}
/**
* @tc.name: StartDiscoveryTest002
* @tc.desc: Verify normal case
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE(DiscoveryServiceTestSuite, StartDiscoveryTest002, Function | MediumTest | Level0)
{
int ret;
g_sInfo.subscribeId = GetSubscribeId();
ret = StartDiscovery(g_pkgName, &g_sInfo, &g_subscribeCb);
TEST_ASSERT_TRUE(ret == SOFTBUS_DISCOVER_MANAGER_NOT_INIT);
g_sInfo1.subscribeId = GetSubscribeId();
ret = StartDiscovery(g_pkgName, &g_sInfo1, &g_subscribeCb);
TEST_ASSERT_TRUE(ret == SOFTBUS_DISCOVER_MANAGER_NOT_INIT);
}
/**
* @tc.name: StartDiscoveryTest003
* @tc.desc: Verify same parameter again
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE(DiscoveryServiceTestSuite, StartDiscoveryTest003, Function | MediumTest | Level0)
{
int ret;
g_sInfo.subscribeId = GetSubscribeId();
ret = StartDiscovery(g_pkgName, &g_sInfo, &g_subscribeCb);
TEST_ASSERT_TRUE(ret == SOFTBUS_DISCOVER_MANAGER_NOT_INIT);
}
/**
* @tc.name: StopDiscoveryTest001
* @tc.desc: Verify wrong parameter
......@@ -386,52 +302,8 @@ LITE_TEST_CASE(DiscoveryServiceTestSuite, StopDiscoveryTest001, Function | Mediu
{
int ret;
int tmpId = GetSubscribeId();
g_sInfo.subscribeId = tmpId;
StartDiscovery(g_pkgName, &g_sInfo, &g_subscribeCb);
ret = StopDiscovery(NULL, tmpId);
TEST_ASSERT_TRUE(ret != 0);
ret = StopDiscovery(g_erroPkgName, tmpId);
TEST_ASSERT_TRUE(ret != 0);
}
/**
* @tc.name: StopDiscoveryTest002
* @tc.desc: Verify normal case
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE(DiscoveryServiceTestSuite, StopDiscoveryTest002, Function | MediumTest | Level0)
{
int ret;
int tmpId1 = GetSubscribeId();
int tmpId2 = GetSubscribeId();
g_sInfo.subscribeId = tmpId1;
StartDiscovery(g_pkgName, &g_sInfo, &g_subscribeCb);
g_sInfo1.subscribeId = tmpId2;
StartDiscovery(g_pkgName, &g_sInfo1, &g_subscribeCb);
ret = StopDiscovery(g_pkgName, tmpId1);
TEST_ASSERT_TRUE(ret == SOFTBUS_DISCOVER_MANAGER_NOT_INIT);
ret = StopDiscovery(g_pkgName, tmpId2);
TEST_ASSERT_TRUE(ret == SOFTBUS_DISCOVER_MANAGER_NOT_INIT);
}
/**
* @tc.name: StopDiscoveryTest003
* @tc.desc: Verify same parameter again
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE(DiscoveryServiceTestSuite, StopDiscoveryTest003, Function | MediumTest | Level0)
{
int ret;
int tmpId = GetSubscribeId();
g_sInfo.subscribeId = tmpId;
StartDiscovery(g_pkgName, &g_sInfo, &g_subscribeCb);
ret = StopDiscovery(g_pkgName, tmpId);
TEST_ASSERT_TRUE(ret == SOFTBUS_DISCOVER_MANAGER_NOT_INIT);
}
RUN_TEST_SUITE(DiscoveryServiceTestSuite);
\ No newline at end of file
......@@ -31,24 +31,24 @@
#define LOG2_ERR(fmt, ...) printf("ERROR:%s:%d " fmt "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
enum StatusNum {
TRANS_STATE_NONE = 0, // 0
TRANS_STATE_INIT, // 1
TRANS_STATE_CREATE_SESSION_SERVER, // 2
TRANS_SET_FILE_SEND_LISTENER, // 3
TRANS_STATE_OPEN, // 4
TRANS_STATE_SEND_BYTE, // 5
TRANS_STATE_SEND_MESSAGE, // 6
TRANS_STATE_SEND_FILE, // 7
TRANS_STATE_CLOSE, // 8
TRANS_STATE_REMOVE_SESSION_SERVER, // 9
TRANS_STATE_CREATE_PHONE = 10, // 10
TRANS_STATE_GET_SESSION_NAME, // 11
TRANS_STATE_GET_DEVICE_ID, // 12
TRANS_STATE_NONE = 0,
TRANS_STATE_INIT,
TRANS_STATE_CREATE_SESSION_SERVER,
TRANS_SET_FILE_SEND_LISTENER,
TRANS_STATE_OPEN,
TRANS_STATE_SEND_BYTE,
TRANS_STATE_SEND_MESSAGE,
TRANS_STATE_SEND_FILE,
TRANS_STATE_CLOSE,
TRANS_STATE_REMOVE_SESSION_SERVER,
TRANS_STATE_CREATE_PHONE = 10,
TRANS_STATE_GET_SESSION_NAME,
TRANS_STATE_GET_DEVICE_ID,
TRANS_CLEAR_LOG,
TRANS_TEST_FIN,
LNN_STATE_JOINLNN = 20, // 20
LNN_STATE_LEAVELNN, // 21
LNN_STATE_JOINLNN = 20,
LNN_STATE_LEAVELNN,
};
const char *g_pkgName = "dms";
......@@ -148,81 +148,6 @@ LITE_TEST_CASE(SessionTestSuite, TestCreateSessionServer001, Function | MediumTe
ret = CreateSessionServer(g_pkgName, g_sessionName, NULL);
TEST_ASSERT_EQUAL_INT(SOFTBUS_INVALID_PARAM, ret);
ret = CreateSessionServer(g_pkgName, g_sessionName, &g_sessionlistener);
TEST_ASSERT_EQUAL_INT(SOFTBUS_INVALID_PARAM, ret);
ret = RemoveSessionServer(g_pkgName, g_sessionName);
TEST_ASSERT_EQUAL_INT(-1, ret);
}
/**
* @tc.name: TestCreateSessionServer002
* @tc.desc: extern module active publish, use the normal parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE(SessionTestSuite, TestCreateSessionServer002, Function | MediumTest | Level0)
{
int ret;
ret = CreateSessionServer(g_pkgName, g_sessionName, &g_sessionlistener);
TEST_ASSERT_EQUAL_INT(SOFTBUS_INVALID_PARAM, ret);
ret = RemoveSessionServer(g_pkgName, g_sessionName);
TEST_ASSERT_EQUAL_INT(-1, ret);
}
/**
* @tc.name: TestCreateSessionServer003
* @tc.desc: extern module active publish, use the same normal parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE(SessionTestSuite, TestCreateSessionServer003, Function | MediumTest | Level0)
{
int ret;
ret = CreateSessionServer(g_pkgName, g_sessionName, &g_sessionlistener);
TEST_ASSERT_EQUAL_INT(SOFTBUS_INVALID_PARAM, ret);
ret = CreateSessionServer(g_pkgName, g_sessionName, &g_sessionlistener);
TEST_ASSERT_EQUAL_INT(SOFTBUS_INVALID_PARAM, ret);
ret = RemoveSessionServer(g_pkgName, g_sessionName);
TEST_ASSERT_EQUAL_INT(-1, ret);
}
/**
* @tc.name: TestCreateSessionServer004
* @tc.desc: extern module active publish, create 9 sessionServer, succ 8, failed at 9th.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE(SessionTestSuite, TestCreateSessionServer004, Function | MediumTest | Level0)
{
int ret, i;
char const *sessionName[MAX_SESSION_SERVER_NUMBER + 1] = {
"ohos.distributedschedule.dms.test0",
"ohos.distributedschedule.dms.test1",
"ohos.distributedschedule.dms.test2",
"ohos.distributedschedule.dms.test3",
"ohos.distributedschedule.dms.test4",
"ohos.distributedschedule.dms.test5",
"ohos.distributedschedule.dms.test6",
"ohos.distributedschedule.dms.test7",
"ohos.distributedschedule.dms.test8"
};
for (i = 0; i < MAX_SESSION_SERVER_NUMBER; i++) {
ret = CreateSessionServer(g_pkgName, sessionName[i], &g_sessionlistener);
TEST_ASSERT_EQUAL_INT(SOFTBUS_INVALID_PARAM, ret);
}
ret = CreateSessionServer(g_pkgName, sessionName[i], &g_sessionlistener);
TEST_ASSERT_EQUAL_INT(SOFTBUS_INVALID_PARAM, ret);
for (i = 0; i < MAX_SESSION_SERVER_NUMBER; i++) {
ret = RemoveSessionServer(g_pkgName, sessionName[i]);
TEST_ASSERT_EQUAL_INT(-1, ret);
}
}
/**
......@@ -241,25 +166,6 @@ LITE_TEST_CASE(SessionTestSuite, TestRemoveSessionServer001, Function | MediumTe
TEST_ASSERT_EQUAL_INT(SOFTBUS_INVALID_PARAM, ret);
}
/**
* @tc.name: TestRemoveSessionServer002
* @tc.desc: extern module active publish, use the same parameter.
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE(SessionTestSuite, TestRemoveSessionServer002, Function | MediumTest | Level0)
{
int ret;
ret = CreateSessionServer(g_pkgName, g_sessionName, &g_sessionlistener);
TEST_ASSERT_EQUAL_INT(SOFTBUS_INVALID_PARAM, ret);
ret = RemoveSessionServer(g_pkgName, g_sessionName);
TEST_ASSERT_EQUAL_INT(-1, ret);
ret = RemoveSessionServer(g_pkgName, g_sessionName);
TEST_ASSERT_EQUAL_INT(-1, ret);
}
/**
* @tc.name: TestOpenSession001
* @tc.desc: extern module active publish, use the wrong parameter.
......@@ -285,12 +191,6 @@ LITE_TEST_CASE(SessionTestSuite, TestOpenSession001, Function | MediumTest | Lev
ret = OpenSession(g_sessionName, g_sessionName, g_networkid, g_groupid, NULL);
TEST_ASSERT_EQUAL_INT(INVALID_SESSION_ID, ret);
g_sessionAttr.dataType = TYPE_BUTT;
ret = OpenSession(g_sessionName, g_sessionName, g_networkid, g_groupid, &g_sessionAttr);
g_sessionAttr.dataType = TYPE_BYTES;
TEST_ASSERT_EQUAL_INT(INVALID_SESSION_ID, ret);
CloseSession(ret);
}
/**
......@@ -315,11 +215,6 @@ LITE_TEST_CASE(SessionTestSuite, TestSendBytes001, Function | MediumTest | Level
ret = SendBytes(sessionId, data, 0);
TEST_ASSERT_EQUAL_INT(SOFTBUS_INVALID_PARAM, ret);
ret = SoftbusGetConfig(SOFTBUS_INT_MAX_BYTES_LENGTH, (unsigned char *)&maxLen, sizeof(maxLen));
TEST_ASSERT_EQUAL_INT(SOFTBUS_OK, ret);
ret = SendMessage(sessionId, data, maxLen + 1);
TEST_ASSERT_EQUAL_INT(SOFTBUS_INVALID_PARAM, ret);
}
/**
......@@ -344,11 +239,6 @@ LITE_TEST_CASE(SessionTestSuite, TestSendMessage001, Function | MediumTest | Lev
ret = SendMessage(sessionId, data, 0);
TEST_ASSERT_EQUAL_INT(SOFTBUS_INVALID_PARAM, ret);
ret = SoftbusGetConfig(SOFTBUS_INT_MAX_MESSAGE_LENGTH, (unsigned char *)&maxLen, sizeof(maxLen));
TEST_ASSERT_EQUAL_INT(SOFTBUS_OK, ret);
ret = SendMessage(sessionId, data, maxLen + 1);
TEST_ASSERT_EQUAL_INT(SOFTBUS_INVALID_PARAM, ret);
}
......@@ -408,9 +298,6 @@ LITE_TEST_CASE(SessionTestSuite, TestSetFileSendListener001, Function | MediumTe
{
int ret = SetFileSendListener(g_testModuleName, g_testSessionName, NULL);
TEST_ASSERT_TRUE(ret == SOFTBUS_INVALID_PARAM);
ret = SetFileSendListener(g_testModuleName, g_testSessionName, &g_fileSendListener);
TEST_ASSERT_TRUE(ret != SOFTBUS_OK);
}
/**
......@@ -447,9 +334,6 @@ LITE_TEST_CASE(SessionTestSuite, TestSetFileReceiveListener001, Function | Mediu
{
int ret = SetFileReceiveListener(g_testModuleName, g_testSessionNamE2, NULL, "/data/");
TEST_ASSERT_TRUE(ret == SOFTBUS_INVALID_PARAM);
ret = SetFileReceiveListener(g_testModuleName, g_testSessionNamE2, &g_fileRecvListener, "/data/");
TEST_ASSERT_TRUE(ret != SOFTBUS_OK);
}
/**
......@@ -461,10 +345,8 @@ LITE_TEST_CASE(SessionTestSuite, TestSetFileReceiveListener001, Function | Mediu
LITE_TEST_CASE(SessionTestSuite, TestGetMySessionName001, Function | MediumTest | Level0)
{
int ret;
int sessionId;
int sessionId = -1;
int len = 5;
g_sessionAttr.dataType = TYPE_BYTES;
sessionId = OpenSession(g_sessionName, g_sessionName, g_networkid, g_groupid, &g_sessionAttr);
ret = GetMySessionName(sessionId, NULL, len);
TEST_ASSERT_EQUAL_INT(ret, SOFTBUS_INVALID_PARAM);
}
......@@ -478,10 +360,8 @@ LITE_TEST_CASE(SessionTestSuite, TestGetMySessionName001, Function | MediumTest
LITE_TEST_CASE(SessionTestSuite, TestGetPeerSessionName001, Function | MediumTest | Level0)
{
int ret;
int sessionId;
int sessionId = -1;
int len = 5;
g_sessionAttr.dataType = TYPE_BYTES;
sessionId = OpenSession(g_sessionName, g_sessionName, g_networkid, g_groupid, &g_sessionAttr);
ret = GetPeerSessionName(sessionId, NULL, len);
TEST_ASSERT_EQUAL_INT(ret, SOFTBUS_INVALID_PARAM);
}
......@@ -495,10 +375,8 @@ LITE_TEST_CASE(SessionTestSuite, TestGetPeerSessionName001, Function | MediumTes
LITE_TEST_CASE(SessionTestSuite, TestGetPeerDeviceId001, Function | MediumTest | Level0)
{
int ret;
int sessionId;
int sessionId = -1;
int len = 5;
g_sessionAttr.dataType = TYPE_BYTES;
sessionId = OpenSession(g_sessionName, g_sessionName, g_networkid, g_groupid, &g_sessionAttr);
ret = GetPeerDeviceId(sessionId, NULL, len);
TEST_ASSERT_EQUAL_INT(ret, SOFTBUS_INVALID_PARAM);
}
......
......@@ -14,27 +14,54 @@
*/
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include "hctest.h"
#include "securec.h"
#include "session.h"
#include "softbus_bus_center.h"
#include "softbus_errcode.h"
#include "softbus_server_frame.h"
#define MAINLOOP_STACK_SIZE 5120
#define TEST_PKG_NAME "com.softbus.test"
#define DEFAULT_NODE_STATE_CB_NUM 9
#define ERRO_CAPDATA_LEN 514
#define DEFAULT_LOCAL_DEVICE_TYPE_ID 0
#define SLEEP_TIME 4
#include "cmsis_os.h"
char TEST_PKG_ERROR_NAME[] = "com.softbus.error.test";
#define UI_MAIN_TASK_DELAY 10000
static int32_t serverInit = 0;
static int32_t g_subscribeId = 0;
static int32_t g_publishId = 0;
LITE_TEST_SUIT(dsoftbus, buscenter, BusCenterTestSuite);
static void *BusCenterServerInit(void *arg)
{
printf("----------start BusCenterServerInit-------------\n");
InitSoftBusServer();
return NULL;
}
static void ThreadCreateTest(void *(*entry)(void *arg))
{
pthread_t tid;
pthread_attr_t threadAttr;
pthread_attr_init(&threadAttr);
pthread_attr_setstacksize(&threadAttr, MAINLOOP_STACK_SIZE);
pthread_create(&tid, &threadAttr, entry, 0);
}
static BOOL BusCenterTestSuiteSetUp(void)
{
printf("----------test case with DsoftbusMgrTest start-------------\n");
if (GetServerIsInit() == false) {
printf("----------Server Is not Init-------------\n");
sleep(SLEEP_TIME);
}
return TRUE;
}
......@@ -167,6 +194,10 @@ LITE_TEST_CASE(BusCenterTestSuite, testJoinLNN0001, Function | MediumTest | Leve
printf("------start testJoinLNN------\n");
ConnectionAddr addr;
while (GetServerIsInit() == false) {
sleep(1);
}
osDelay(UI_MAIN_TASK_DELAY);
int32_t ret = JoinLNN(NULL, &addr, OnJoinLNNDone);
TEST_ASSERT_TRUE(ret == SOFTBUS_INVALID_PARAM);
ret = JoinLNN(TEST_PKG_NAME, NULL, OnJoinLNNDone);
......@@ -222,14 +253,9 @@ LITE_TEST_CASE(BusCenterTestSuite, testRegNodeDeviceStateCb002, Function | Mediu
{
int32_t i;
int32_t ret = 0;
for (i = 0; i <= DEFAULT_NODE_STATE_CB_NUM; ++i) {
if (i < DEFAULT_NODE_STATE_CB_NUM) {
ret = RegNodeDeviceStateCb(TEST_PKG_NAME, &g_nodeStateCb);
TEST_ASSERT_TRUE(ret == SOFTBUS_OK);
} else {
ret = RegNodeDeviceStateCb(TEST_PKG_NAME, &g_nodeStateCb);
TEST_ASSERT_TRUE(ret != SOFTBUS_OK);
}
for (i = 0; i < DEFAULT_NODE_STATE_CB_NUM; ++i) {
ret = RegNodeDeviceStateCb(TEST_PKG_NAME, &g_nodeStateCb);
TEST_ASSERT_TRUE(ret == SOFTBUS_OK);
}
for (i = 0; i < DEFAULT_NODE_STATE_CB_NUM; ++i) {
......@@ -270,10 +296,10 @@ LITE_TEST_CASE(BusCenterTestSuite, testGetLocalNodeDeviceInfo001, Function | Med
printf("------start testGetLocalNodeDeviceInfo------\n");
NodeBasicInfo info;
int32_t ret = GetLocalNodeDeviceInfo(TEST_PKG_NAME, &info);
TEST_ASSERT_TRUE(ret == SOFTBUS_ERR);
TEST_ASSERT_TRUE(ret == SOFTBUS_OK);
ret = strlen(info.networkId);
TEST_ASSERT_TRUE(ret != (NETWORK_ID_BUF_LEN - 1));
TEST_ASSERT_TRUE(info.deviceTypeId != DEFAULT_LOCAL_DEVICE_TYPE_ID);
TEST_ASSERT_TRUE(ret == (NETWORK_ID_BUF_LEN - 1));
TEST_ASSERT_TRUE(info.deviceTypeId == DEFAULT_LOCAL_DEVICE_TYPE_ID);
printf("------end testGetLocalNodeDeviceInfo------\n");
}
......@@ -290,11 +316,9 @@ LITE_TEST_CASE(BusCenterTestSuite, testGetNodeKeyInfo001, Function | MediumTest
char udid[UDID_BUF_LEN] = {0};
(void)memset_s(&info, sizeof(NodeBasicInfo), 0, sizeof(NodeBasicInfo));
TEST_ASSERT_TRUE(GetLocalNodeDeviceInfo(TEST_PKG_NAME, &info) == SOFTBUS_ERR);
TEST_ASSERT_TRUE(GetLocalNodeDeviceInfo(TEST_PKG_NAME, &info) == SOFTBUS_OK);
TEST_ASSERT_TRUE(GetNodeKeyInfo(TEST_PKG_NAME, info.networkId, NODE_KEY_UDID,
(uint8_t *)udid, UDID_BUF_LEN) != SOFTBUS_OK);
TEST_ASSERT_TRUE(GetNodeKeyInfo(TEST_PKG_NAME, info.networkId, NODE_KEY_UUID,
(uint8_t *)uuid, UUID_BUF_LEN) != SOFTBUS_OK);
(uint8_t *)udid, UDID_BUF_LEN) == SOFTBUS_OK);
TEST_ASSERT_TRUE(strlen(uuid) != (UUID_BUF_LEN - 1));
}
......@@ -311,7 +335,6 @@ LITE_TEST_CASE(BusCenterTestSuite, testStartTimeSync001, Function | MediumTest |
TEST_ASSERT_TRUE(StartTimeSync(NULL, networkId, LOW_ACCURACY, SHORT_PERIOD, &g_timeSyncCb) != SOFTBUS_OK);
TEST_ASSERT_TRUE(StartTimeSync(TEST_PKG_NAME, NULL, LOW_ACCURACY, SHORT_PERIOD, &g_timeSyncCb) != SOFTBUS_OK);
TEST_ASSERT_TRUE(StartTimeSync(TEST_PKG_NAME, networkId, LOW_ACCURACY, SHORT_PERIOD, &g_timeSyncCb) != SOFTBUS_OK);
TEST_ASSERT_TRUE(StartTimeSync(TEST_PKG_NAME, networkId, LOW_ACCURACY, SHORT_PERIOD, NULL) != SOFTBUS_OK);
}
......@@ -327,7 +350,6 @@ LITE_TEST_CASE(BusCenterTestSuite, testStartTimeSync002, Function | MediumTest |
TEST_ASSERT_TRUE(StopTimeSync(NULL, networkId) != SOFTBUS_OK);
TEST_ASSERT_TRUE(StopTimeSync(TEST_PKG_NAME, NULL) != SOFTBUS_OK);
TEST_ASSERT_TRUE(StopTimeSync(TEST_PKG_NAME, networkId) != SOFTBUS_OK);
}
/**
......@@ -371,33 +393,6 @@ LITE_TEST_CASE(BusCenterTestSuite, testPublishLNN001, Function | MediumTest | Le
ret = PublishLNN(TEST_PKG_NAME, &g_pInfo, &g_publishCb);
TEST_ASSERT_TRUE(ret != 0);
g_pInfo.dataLen = sizeof("capdata1");
ret = PublishLNN(TEST_PKG_ERROR_NAME, &g_pInfo, &g_publishCb);
TEST_ASSERT_TRUE(ret == 0);
}
/**
* @tc.name: testPublishLNN002
* @tc.desc: Verify normal case
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE(BusCenterTestSuite, testPublishLNN002, Function | MediumTest | Level0)
{
int32_t ret;
int tmpId1 = GetPublishId();
int tmpId2 = GetPublishId();
g_pInfo.publishId = tmpId1;
ret = PublishLNN(TEST_PKG_NAME, &g_pInfo, &g_publishCb);
TEST_ASSERT_TRUE(ret == 0);
g_pInfo1.publishId = tmpId2;
ret = PublishLNN(TEST_PKG_NAME, &g_pInfo1, &g_publishCb);
TEST_ASSERT_TRUE(ret == 0);
ret = StopPublishLNN(TEST_PKG_NAME, tmpId1);
TEST_ASSERT_TRUE(ret != 0);
ret = StopPublishLNN(TEST_PKG_NAME, tmpId2);
TEST_ASSERT_TRUE(ret != 0);
}
/**
......@@ -413,9 +408,6 @@ LITE_TEST_CASE(BusCenterTestSuite, testRefreshLNN001, Function | MediumTest | Le
ret = RefreshLNN(NULL, &g_sInfo, &g_refreshCb);
TEST_ASSERT_TRUE(ret != 0);
ret = RefreshLNN(TEST_PKG_ERROR_NAME, &g_sInfo, &g_refreshCb);
TEST_ASSERT_TRUE(ret == 0);
ret = RefreshLNN(TEST_PKG_NAME, NULL, &g_refreshCb);
TEST_ASSERT_TRUE(ret != 0);
......@@ -448,30 +440,6 @@ LITE_TEST_CASE(BusCenterTestSuite, testRefreshLNN001, Function | MediumTest | Le
g_sInfo.dataLen = sizeof("capdata1");
}
/**
* @tc.name: testRefreshLNN002
* @tc.desc: Verify normal case
* @tc.type: FUNC
* @tc.require:
*/
LITE_TEST_CASE(BusCenterTestSuite, testRefreshLNN002, Function | MediumTest | Level0)
{
int32_t ret;
int tmpId1 = GetSubscribeId();
int tmpId2 = GetSubscribeId();
g_sInfo.subscribeId = tmpId1;
ret = RefreshLNN(TEST_PKG_NAME, &g_sInfo, &g_refreshCb);
TEST_ASSERT_TRUE(ret == 0);
g_sInfo1.subscribeId = tmpId2;
ret = RefreshLNN(TEST_PKG_NAME, &g_sInfo1, &g_refreshCb);
TEST_ASSERT_TRUE(ret == 0);
ret = StopRefreshLNN(TEST_PKG_NAME, tmpId1);
TEST_ASSERT_TRUE(ret != 0);
ret = StopRefreshLNN(TEST_PKG_NAME, tmpId2);
TEST_ASSERT_TRUE(ret != 0);
}
/*
* @tc.name: testActiveMetaNode001
* @tc.desc: meta node interface test
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册