提交 4c8ffce1 编写于 作者: O openharmony_ci 提交者: Gitee

!960 wifi测试用例修改(同步master)

Merge pull request !960 from shuisiyuan/wifi
...@@ -13,18 +13,15 @@ ...@@ -13,18 +13,15 @@
* limitations under the License. * limitations under the License.
*/ */
#include <unistd.h>
#include "hctest.h" #include "hctest.h"
#include "ohos_types.h" #include "ohos_types.h"
#include "wifi_device.h" #include "wifi_device.h"
#include "wifi_hotspot.h" #include "wifi_hotspot.h"
#include "lwip/netif.h"
#include "lwip/netifapi.h"
#include "lwip/ip4_addr.h"
#include "cmsis_os2.h" #include "cmsis_os2.h"
#include <unistd.h>
#define DEF_TIMEOUT 15 #define DEF_TIMEOUT 15
#define ONE_SECOND 1 #define ONE_SECOND 100
#define LEVEL_ERROR (-1) #define LEVEL_ERROR (-1)
#define LEVEL_ONE 1 #define LEVEL_ONE 1
#define LEVEL_TWO 2 #define LEVEL_TWO 2
...@@ -32,6 +29,7 @@ ...@@ -32,6 +29,7 @@
#define LEVEL_FOUR 4 #define LEVEL_FOUR 4
#define DEF_TASK_STACK 2000 #define DEF_TASK_STACK 2000
#define DEF_TASK_PRIORITY 20 #define DEF_TASK_PRIORITY 20
#define TEST_SSID_COUNT 9
static int g_apEnableSuccess = 0; static int g_apEnableSuccess = 0;
static int g_staScanSuccess = 0; static int g_staScanSuccess = 0;
...@@ -187,7 +185,7 @@ static void WaitScanResult(void) ...@@ -187,7 +185,7 @@ static void WaitScanResult(void)
{ {
int scanTimeout = DEF_TIMEOUT; int scanTimeout = DEF_TIMEOUT;
while (scanTimeout > 0) { while (scanTimeout > 0) {
sleep(ONE_SECOND); osDelay(ONE_SECOND);
scanTimeout--; scanTimeout--;
if (g_staScanSuccess == 1) { if (g_staScanSuccess == 1) {
printf("WaitScanResult:wait success[%d]s\n", (DEF_TIMEOUT - scanTimeout)); printf("WaitScanResult:wait success[%d]s\n", (DEF_TIMEOUT - scanTimeout));
...@@ -392,16 +390,18 @@ LITE_TEST_CASE(WifiServiceFuncTestSuite, testConnectDisConnect, Function | Mediu ...@@ -392,16 +390,18 @@ LITE_TEST_CASE(WifiServiceFuncTestSuite, testConnectDisConnect, Function | Mediu
LITE_TEST_CASE(WifiServiceFuncTestSuite, testHandleDeviceConfig, Function | MediumTest | Level2) LITE_TEST_CASE(WifiServiceFuncTestSuite, testHandleDeviceConfig, Function | MediumTest | Level2)
{ {
int netId = 0; int netId = 0;
const char* ssid1 = "XtsTestWifi1"; const char* ssid0 = "TestWifi01";
const char* ssid2 = "XtsTestWifi2"; const char* ssid[TEST_SSID_COUNT] = {"TestWifi02", "TestWifi03", "TestWifi04", "TestWifi05", "TestWifi06",
const char* ssid3 = "XtsTestWifi3"; "TestWifi07", "TestWifi08", "TestWifi09", "TestWifi10"};
const char* ssid10 = "TestWifi11";
const char* info = "12345678"; const char* info = "12345678";
unsigned char bssid[WIFI_MAC_LEN] = {0xac, 0x75, 0x1d, 0xd8, 0x55, 0xc1}; unsigned char bssid[WIFI_MAC_LEN] = {0xac, 0x75, 0x1d, 0xd8, 0x55, 0xc1};
WifiDeviceConfig config = {0}; WifiDeviceConfig config = {0};
config.freq = 20; config.freq = 20;
config.securityType = WIFI_SEC_TYPE_SAE; config.securityType = WIFI_SEC_TYPE_SAE;
config.wapiPskType = WIFI_PSK_TYPE_ASCII; config.wapiPskType = WIFI_PSK_TYPE_ASCII;
int ret = strncpy_s(config.ssid, WIFI_MAX_SSID_LEN, ssid1, strlen(ssid1));
int ret = strncpy_s(config.ssid, WIFI_MAX_SSID_LEN, ssid0, strlen(ssid0));
TEST_ASSERT_EQUAL_INT(WIFI_SUCCESS, ret); TEST_ASSERT_EQUAL_INT(WIFI_SUCCESS, ret);
ret = strncpy_s(config.preSharedKey, WIFI_MAX_KEY_LEN, info, strlen(info)); ret = strncpy_s(config.preSharedKey, WIFI_MAX_KEY_LEN, info, strlen(info));
TEST_ASSERT_EQUAL_INT(WIFI_SUCCESS, ret); TEST_ASSERT_EQUAL_INT(WIFI_SUCCESS, ret);
...@@ -413,7 +413,7 @@ LITE_TEST_CASE(WifiServiceFuncTestSuite, testHandleDeviceConfig, Function | Medi ...@@ -413,7 +413,7 @@ LITE_TEST_CASE(WifiServiceFuncTestSuite, testHandleDeviceConfig, Function | Medi
for (int i = 0; i < WIFI_MAX_CONFIG_SIZE - 1; i++) { for (int i = 0; i < WIFI_MAX_CONFIG_SIZE - 1; i++) {
config.securityType = WIFI_SEC_TYPE_PSK; config.securityType = WIFI_SEC_TYPE_PSK;
config.wapiPskType = WIFI_PSK_TYPE_HEX; config.wapiPskType = WIFI_PSK_TYPE_HEX;
ret = strncpy_s(config.ssid, WIFI_MAX_SSID_LEN, ssid2, sizeof(ssid2)); ret = strncpy_s(config.ssid, WIFI_MAX_SSID_LEN, ssid[i], sizeof(ssid[i]));
TEST_ASSERT_EQUAL_INT(WIFI_SUCCESS, ret); TEST_ASSERT_EQUAL_INT(WIFI_SUCCESS, ret);
ret = strncpy_s(config.preSharedKey, WIFI_MAX_KEY_LEN, info, strlen(info)); ret = strncpy_s(config.preSharedKey, WIFI_MAX_KEY_LEN, info, strlen(info));
TEST_ASSERT_EQUAL_INT(WIFI_SUCCESS, ret); TEST_ASSERT_EQUAL_INT(WIFI_SUCCESS, ret);
...@@ -425,7 +425,7 @@ LITE_TEST_CASE(WifiServiceFuncTestSuite, testHandleDeviceConfig, Function | Medi ...@@ -425,7 +425,7 @@ LITE_TEST_CASE(WifiServiceFuncTestSuite, testHandleDeviceConfig, Function | Medi
} }
} }
ret = strncpy_s(config.ssid, WIFI_MAX_SSID_LEN, ssid3, strlen(ssid3)); ret = strncpy_s(config.ssid, WIFI_MAX_SSID_LEN, ssid10, strlen(ssid10));
TEST_ASSERT_EQUAL_INT(WIFI_SUCCESS, ret); TEST_ASSERT_EQUAL_INT(WIFI_SUCCESS, ret);
ret = strncpy_s(config.preSharedKey, WIFI_MAX_KEY_LEN, info, strlen(info)); ret = strncpy_s(config.preSharedKey, WIFI_MAX_KEY_LEN, info, strlen(info));
TEST_ASSERT_EQUAL_INT(WIFI_SUCCESS, ret); TEST_ASSERT_EQUAL_INT(WIFI_SUCCESS, ret);
...@@ -523,7 +523,7 @@ LITE_TEST_CASE(WifiServiceFuncTestSuite, testEnableDisableHotSpot, Function | Me ...@@ -523,7 +523,7 @@ LITE_TEST_CASE(WifiServiceFuncTestSuite, testEnableDisableHotSpot, Function | Me
int timeout = 3; int timeout = 3;
g_apEnableSuccess = 0; g_apEnableSuccess = 0;
while (timeout > 0) { while (timeout > 0) {
sleep(ONE_SECOND); osDelay(ONE_SECOND);
timeout--; timeout--;
if (g_apEnableSuccess >= 1) { if (g_apEnableSuccess >= 1) {
printf("Wait %d seconds.\n", (DEF_TIMEOUT - timeout)); printf("Wait %d seconds.\n", (DEF_TIMEOUT - timeout));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册