Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
ca7d3637
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ca7d3637
编写于
11月 20, 2020
作者:
M
mlinlmcc
提交者:
Gitee
11月 20, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
setup期间检查AP、STA、config,如果状态是enable,则disable,避免状态混乱影响测试用例执行
上级
9f76ebf1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
84 addition
and
71 deletion
+84
-71
communication_lite/wifiservice_hal/src/wifiservice_func_test.c
...nication_lite/wifiservice_hal/src/wifiservice_func_test.c
+84
-71
未找到文件。
communication_lite/wifiservice_hal/src/wifiservice_func_test.c
浏览文件 @
ca7d3637
...
...
@@ -32,12 +32,9 @@
#define LEVEL_FOUR 4
#define DEF_TASK_STACK 2000
#define DEF_TASK_PRIORITY 20
#define DEPE_AP_SSID "xts_execute"
#define DEF_NET_IF "wlan0"
static
int
g_apEnableSuccess
=
0
;
static
int
g_staScanSuccess
=
0
;
struct
netif
*
g_wsNetInterface
=
NULL
;
WifiEvent
g_wifiEventHandler
=
{
0
};
/**
...
...
@@ -216,14 +213,61 @@ LITE_TEST_SUIT(communication, wifiservice, WifiServiceFuncTestSuite);
*/
static
BOOL
WifiServiceFuncTestSuiteSetUp
(
void
)
{
WifiErrorCode
error
;
// check wifi stat
int
ret
=
IsWifiActive
();
if
(
ret
==
WIFI_STATE_AVALIABLE
)
{
printf
(
"[Setup]wifi is active, disbale now...
\n
"
);
error
=
DisableWifi
();
if
(
error
==
WIFI_SUCCESS
)
{
printf
(
"[Setup]disbale wifi success
\n
"
);
}
else
{
TEST_ASSERT_EQUAL_INT
(
error
,
WIFI_SUCCESS
);
printf
(
"[Setup]disbale wifi fail, please disable wifi, then run test cases!
\n
"
);
return
FALSE
;
}
}
// check AP stat
ret
=
IsHotspotActive
();
if
(
ret
==
WIFI_HOTSPOT_ACTIVE
)
{
printf
(
"[Setup]AP is active, disbale now...
\n
"
);
error
=
DisableHotspot
();
if
(
error
==
WIFI_SUCCESS
)
{
printf
(
"[Setup]disbale AP success
\n
"
);
}
else
{
TEST_ASSERT_EQUAL_INT
(
error
,
WIFI_SUCCESS
);
printf
(
"[Setup]disbale AP fail, please disable ap, then run test cases!
\n
"
);
return
FALSE
;
}
}
// check device config
WifiDeviceConfig
config
[
WIFI_MAX_CONFIG_SIZE
]
=
{
0
};
unsigned
int
size
=
WIFI_MAX_CONFIG_SIZE
;
error
=
GetDeviceConfigs
(
config
,
&
size
);
if
(
error
!=
ERROR_WIFI_NOT_AVAILABLE
)
{
printf
(
"[Setup]there is device config, clear now...
\n
"
);
int
count
=
0
;
for
(
int
i
=
0
;
i
<
WIFI_MAX_CONFIG_SIZE
;
i
++
)
{
if
(
&
config
[
i
]
!=
NULL
)
{
RemoveDevice
(
config
[
i
].
netId
);
count
++
;
}
}
printf
(
"[Setup]clear count [%d]
\n
"
,
count
);
}
// register wifi event
g_wifiEventHandler
.
OnWifiScanStateChanged
=
OnWifiScanStateChangedHandler
;
g_wifiEventHandler
.
OnWifiConnectionChanged
=
OnWifiConnectionChangedHandler
;
g_wifiEventHandler
.
OnHotspotStaJoin
=
OnHotspotStaJoinHandler
;
g_wifiEventHandler
.
OnHotspotStaLeave
=
OnHotspotStaLeaveHandler
;
g_wifiEventHandler
.
OnHotspotStateChanged
=
OnHotspotStateChangedHandler
;
WifiErrorCode
error
=
RegisterWifiEvent
(
&
g_wifiEventHandler
);
TEST_ASSERT_EQUAL_INT
(
error
,
WIFI_SUCCESS
);
error
=
RegisterWifiEvent
(
&
g_wifiEventHandler
);
TEST_ASSERT_EQUAL_INT
(
WIFI_SUCCESS
,
ret
);
if
(
error
!=
WIFI_SUCCESS
)
{
printf
(
"[Setup]register wifi event fail!
\n
"
);
return
FALSE
;
}
return
TRUE
;
...
...
@@ -248,11 +292,8 @@ static BOOL WifiServiceFuncTestSuiteTearDown(void)
* @tc.number : SUB_COMMUNICATION_WIFISERVICE_SDK_0100
* @tc.name : Test enable and disable wifi interface
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testEnableDisableWifi
,
LEVEL
2
)
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testEnableDisableWifi
,
Function
|
MediumTest
|
Level
2
)
{
int
stat
=
IsWifiActive
();
TEST_ASSERT_EQUAL_INT
(
stat
,
WIFI_STATE_NOT_AVALIABLE
);
...
...
@@ -282,11 +323,8 @@ LITE_TEST_CASE(WifiServiceFuncTestSuite, testEnableDisableWifi, LEVEL2)
* @tc.number : SUB_COMMUNICATION_WIFISERVICE_SDK_0200
* @tc.name : Test scan and get scan info interface
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testScan
,
LEVEL
2
)
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testScan
,
Function
|
MediumTest
|
Level
2
)
{
unsigned
int
size
=
WIFI_SCAN_HOTSPOT_LIMIT
;
WifiErrorCode
error
=
EnableWifi
();
...
...
@@ -322,20 +360,17 @@ LITE_TEST_CASE(WifiServiceFuncTestSuite, testScan, LEVEL2)
* @tc.number : SUB_COMMUNICATION_WIFISERVICE_SDK_0300
* @tc.name : Test connect and disconnect interface
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testConnectDisConnect
,
LEVEL
2
)
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testConnectDisConnect
,
Function
|
MediumTest
|
Level
2
)
{
int
netId
=
0
;
int
ssidLen
=
11
;
WifiErrorCode
error
;
WifiDeviceConfig
config
=
{
0
};
int
ret
=
memcpy_s
(
config
.
ssid
,
WIFI_MAX_SSID_LEN
,
"xts_execute"
,
ssidLen
);
const
char
*
ssid
=
"xts_execute"
;
int
ret
=
strncpy_s
(
config
.
ssid
,
WIFI_MAX_SSID_LEN
,
ssid
,
strlen
(
ssid
));
TEST_ASSERT_EQUAL_INT
(
ret
,
WIFI_SUCCESS
);
config
.
securityType
=
WIFI_SEC_TYPE_OPEN
;
error
=
AddDeviceConfig
(
&
config
,
&
netId
);
WifiErrorCode
error
=
AddDeviceConfig
(
&
config
,
&
netId
);
TEST_ASSERT_EQUAL_INT
(
error
,
WIFI_SUCCESS
);
error
=
ConnectTo
(
netId
);
...
...
@@ -353,38 +388,34 @@ LITE_TEST_CASE(WifiServiceFuncTestSuite, testConnectDisConnect, LEVEL2)
* @tc.number : SUB_COMMUNICATION_WIFISERVICE_SDK_0400
* @tc.name : Test handle device config interface
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testHandleDeviceConfig
,
LEVEL
2
)
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testHandleDeviceConfig
,
Function
|
MediumTest
|
Level
2
)
{
int
netId
=
0
;
int
ssidLen
=
11
;
int
keyLen
=
8
;
int
freq
=
20
;
const
char
*
ssid1
=
"XtsTestWifi1"
;
const
char
*
ssid2
=
"XtsTestWifi2"
;
const
char
*
ssid3
=
"XtsTestWifi3"
;
const
char
*
info
=
"12345678"
;
unsigned
char
bssid
[
WIFI_MAC_LEN
]
=
{
0xac
,
0x75
,
0x1d
,
0xd8
,
0x55
,
0xc1
};
WifiDeviceConfig
config
=
{
0
};
config
.
freq
=
freq
;
config
.
freq
=
20
;
config
.
securityType
=
WIFI_SEC_TYPE_SAE
;
config
.
wapiPskType
=
WIFI_PSK_TYPE_ASCII
;
int
ret
=
memcpy_s
(
config
.
ssid
,
WIFI_MAX_SSID_LEN
,
"XtsTestWifi"
,
ssidLen
);
int
ret
=
strncpy_s
(
config
.
ssid
,
WIFI_MAX_SSID_LEN
,
ssid1
,
strlen
(
ssid1
)
);
TEST_ASSERT_EQUAL_INT
(
ret
,
WIFI_SUCCESS
);
ret
=
memcpy_s
(
config
.
preSharedKey
,
WIFI_MAX_KEY_LEN
,
"12345678"
,
keyLen
);
ret
=
strncpy_s
(
config
.
preSharedKey
,
WIFI_MAX_KEY_LEN
,
info
,
strlen
(
info
)
);
TEST_ASSERT_EQUAL_INT
(
ret
,
WIFI_SUCCESS
);
ret
=
memcpy_s
(
config
.
bssid
,
WIFI_MAC_LEN
,
bssid
,
WIFI_MAC_LEN
);
TEST_ASSERT_EQUAL_INT
(
ret
,
WIFI_SUCCESS
);
WifiErrorCode
error
=
AddDeviceConfig
(
&
config
,
&
netId
);
TEST_ASSERT_EQUAL_INT
(
error
,
WIFI_SUCCESS
);
ssidLen
+=
1
;
int
addCount
=
9
;
for
(
int
i
=
0
;
i
<
addCount
;
i
++
)
{
for
(
int
i
=
0
;
i
<
WIFI_MAX_CONFIG_SIZE
-
1
;
i
++
)
{
config
.
securityType
=
WIFI_SEC_TYPE_PSK
;
config
.
wapiPskType
=
WIFI_PSK_TYPE_HEX
;
ret
=
memcpy_s
(
config
.
ssid
,
WIFI_MAX_SSID_LEN
,
"XtsTestWifi2"
,
ssidLen
);
ret
=
strncpy_s
(
config
.
ssid
,
WIFI_MAX_SSID_LEN
,
ssid2
,
sizeof
(
ssid2
)
);
TEST_ASSERT_EQUAL_INT
(
ret
,
WIFI_SUCCESS
);
ret
=
memcpy_s
(
config
.
preSharedKey
,
WIFI_MAX_KEY_LEN
,
"01234567"
,
keyLen
);
ret
=
strncpy_s
(
config
.
preSharedKey
,
WIFI_MAX_KEY_LEN
,
info
,
strlen
(
info
)
);
TEST_ASSERT_EQUAL_INT
(
ret
,
WIFI_SUCCESS
);
error
=
AddDeviceConfig
(
&
config
,
&
netId
);
TEST_ASSERT_EQUAL_INT
(
error
,
WIFI_SUCCESS
);
...
...
@@ -394,9 +425,9 @@ LITE_TEST_CASE(WifiServiceFuncTestSuite, testHandleDeviceConfig, LEVEL2)
}
}
ret
=
memcpy_s
(
config
.
ssid
,
WIFI_MAX_SSID_LEN
,
"XtsTestWifi3"
,
ssidLen
);
ret
=
strncpy_s
(
config
.
ssid
,
WIFI_MAX_SSID_LEN
,
ssid3
,
strlen
(
ssid3
)
);
TEST_ASSERT_EQUAL_INT
(
ret
,
WIFI_SUCCESS
);
ret
=
memcpy_s
(
config
.
preSharedKey
,
WIFI_MAX_KEY_LEN
,
"01234567"
,
keyLen
);
ret
=
strncpy_s
(
config
.
preSharedKey
,
WIFI_MAX_KEY_LEN
,
info
,
strlen
(
info
)
);
TEST_ASSERT_EQUAL_INT
(
ret
,
WIFI_SUCCESS
);
config
.
securityType
=
WIFI_SEC_TYPE_PSK
;
error
=
AddDeviceConfig
(
&
config
,
&
netId
);
...
...
@@ -421,18 +452,15 @@ LITE_TEST_CASE(WifiServiceFuncTestSuite, testHandleDeviceConfig, LEVEL2)
* @tc.number : SUB_COMMUNICATION_WIFISERVICE_SDK_0500
* @tc.name : Test handle AP config interface
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testHandleHotspotConfig
,
LEVEL
2
)
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testHandleHotspotConfig
,
Function
|
MediumTest
|
Level
2
)
{
int
keyLen
=
9
;
int
ssidLen
=
10
;
const
char
*
ssid
=
"XtsTestAp"
;
const
char
*
info
=
"12345678"
;
HotspotConfig
config
=
{
0
};
int
ret
=
memcpy_s
(
config
.
ssid
,
WIFI_MAX_SSID_LEN
,
"XtsTestAp"
,
ssidLen
);
int
ret
=
strncpy_s
(
config
.
ssid
,
WIFI_MAX_SSID_LEN
,
ssid
,
strlen
(
ssid
)
);
TEST_ASSERT_EQUAL_INT
(
ret
,
WIFI_SUCCESS
);
ret
=
memcpy_s
(
config
.
preSharedKey
,
WIFI_MAX_KEY_LEN
,
"12345678"
,
keyLen
);
ret
=
strncpy_s
(
config
.
preSharedKey
,
WIFI_MAX_KEY_LEN
,
info
,
strlen
(
info
)
);
TEST_ASSERT_EQUAL_INT
(
ret
,
WIFI_SUCCESS
);
config
.
securityType
=
WIFI_SEC_TYPE_PSK
;
WifiErrorCode
error
=
SetHotspotConfig
(
&
config
);
...
...
@@ -467,18 +495,15 @@ LITE_TEST_CASE(WifiServiceFuncTestSuite, testHandleHotspotConfig, LEVEL2)
* @tc.number : SUB_COMMUNICATION_WIFISERVICE_SDK_0600
* @tc.name : Test enable and disable AP interface
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testEnableDisableHotSpot
,
LEVEL
2
)
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testEnableDisableHotSpot
,
Function
|
MediumTest
|
Level
2
)
{
int
ssidLen
=
10
;
int
keyLen
=
9
;
const
char
*
ssid
=
"XtsTestAp"
;
const
char
*
info
=
"12345678"
;
HotspotConfig
config
=
{
0
};
int
ret
=
memcpy_s
(
config
.
ssid
,
WIFI_MAX_SSID_LEN
,
"XtsTestAp"
,
ssidLen
);
int
ret
=
strncpy_s
(
config
.
ssid
,
WIFI_MAX_SSID_LEN
,
ssid
,
strlen
(
ssid
)
);
TEST_ASSERT_EQUAL_INT
(
ret
,
WIFI_SUCCESS
);
ret
=
memcpy_s
(
config
.
preSharedKey
,
WIFI_MAX_KEY_LEN
,
"12345678"
,
keyLen
);
ret
=
strncpy_s
(
config
.
preSharedKey
,
WIFI_MAX_KEY_LEN
,
info
,
strlen
(
info
)
);
TEST_ASSERT_EQUAL_INT
(
ret
,
WIFI_SUCCESS
);
config
.
securityType
=
WIFI_SEC_TYPE_PSK
;
WifiErrorCode
error
=
SetHotspotConfig
(
&
config
);
...
...
@@ -520,11 +545,8 @@ LITE_TEST_CASE(WifiServiceFuncTestSuite, testEnableDisableHotSpot, LEVEL2)
* @tc.number : SUB_COMMUNICATION_WIFISERVICE_SDK_0700
* @tc.name : Test get signal Level interface
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testGetSignalLevel
,
LEVEL
2
)
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testGetSignalLevel
,
Function
|
MediumTest
|
Level
2
)
{
int
level
;
int
rssiNoLevel
=
-
90
;
...
...
@@ -563,11 +585,8 @@ LITE_TEST_CASE(WifiServiceFuncTestSuite, testGetSignalLevel, LEVEL2)
* @tc.number : SUB_COMMUNICATION_WIFISERVICE_SDK_0800
* @tc.name : test adavance scan interface
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testAdvanceScanType
,
LEVEL
2
)
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testAdvanceScanType
,
Function
|
MediumTest
|
Level
2
)
{
WifiErrorCode
error
=
EnableWifi
();
TEST_ASSERT_EQUAL_INT
(
error
,
WIFI_SUCCESS
);
...
...
@@ -620,11 +639,8 @@ LITE_TEST_CASE(WifiServiceFuncTestSuite, testAdvanceScanType, LEVEL2)
* @tc.number : SUB_COMMUNICATION_WIFISERVICE_SDK_0900
* @tc.name : test adavance scan interface with invalid parameter
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testAdvanceScanInvalidParam01
,
LEVEL
2
)
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testAdvanceScanInvalidParam01
,
Function
|
MediumTest
|
Level
2
)
{
WifiErrorCode
error
=
EnableWifi
();
TEST_ASSERT_EQUAL_INT
(
error
,
WIFI_SUCCESS
);
...
...
@@ -649,13 +665,10 @@ LITE_TEST_CASE(WifiServiceFuncTestSuite, testAdvanceScanInvalidParam01, LEVEL2)
/**
* @tc.number : SUB_COMMUNICATION_WIFISERVICE_SDK_1000
* @tc.name : test adavance scan interface with
invalid parameter
* @tc.name : test adavance scan interface with
different invalid scantype
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testAdvanceScanInvalidParam02
,
LEVEL
2
)
LITE_TEST_CASE
(
WifiServiceFuncTestSuite
,
testAdvanceScanInvalidParam02
,
Function
|
MediumTest
|
Level
2
)
{
WifiErrorCode
error
=
EnableWifi
();
TEST_ASSERT_EQUAL_INT
(
error
,
WIFI_SUCCESS
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录