• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include <gtest/gtest.h>
16 #include <servmgr_hdi.h>
17 #include "v1_1/iwlan_interface.h"
18 #include "wlan_callback_impl.h"
19 #include "wlan_impl.h"
20 
21 #define HDF_LOG_TAG service_manager_test
22 using namespace testing::ext;
23 
24 namespace HdiTest {
25 const int32_t WLAN_FREQ_MAX_NUM = 35;
26 const int32_t WLAN_TX_POWER = 160;
27 const int32_t DEFAULT_COMBO_SIZE = 6;
28 const int32_t WLAN_MAX_NUM_STA_WITH_AP = 4;
29 const uint32_t RESET_TIME = 3;
30 const uint32_t MEAS_CHANNEL_TIME = 1;
31 const uint32_t SCAN_TIME = 3;
32 const char *WLAN_SERVICE_NAME = "wlan_interface_service";
33 
34 class HdfWifiServiceCTest : public testing::Test {
35 public:
36     static void SetUpTestCase();
37     static void TearDownTestCase();
38     void SetUp();
39     void TearDown();
40 };
41 
42 static struct IWlanInterface *g_wlanObj = nullptr;
43 struct IWlanCallback *g_wlanCallbackObj = nullptr;
SetUpTestCase()44 void HdfWifiServiceCTest::SetUpTestCase()
45 {
46     g_wlanObj = IWlanInterfaceGetInstance(WLAN_SERVICE_NAME, false);
47     g_wlanCallbackObj = WlanCallbackServiceGet();
48     ASSERT_TRUE(g_wlanObj != nullptr);
49     ASSERT_TRUE(g_wlanCallbackObj != nullptr);
50 }
51 
TearDownTestCase()52 void HdfWifiServiceCTest::TearDownTestCase()
53 {
54     IWlanInterfaceReleaseInstance(WLAN_SERVICE_NAME, g_wlanObj, false);
55     WlanCallbackServiceRelease(g_wlanCallbackObj);
56 }
57 
SetUp()58 void HdfWifiServiceCTest::SetUp()
59 {
60     int32_t rc = g_wlanObj->Start(g_wlanObj);
61     ASSERT_EQ(rc, HDF_SUCCESS);
62 }
63 
TearDown()64 void HdfWifiServiceCTest::TearDown()
65 {
66     int32_t rc = g_wlanObj->Stop(g_wlanObj);
67     ASSERT_EQ(rc, HDF_SUCCESS);
68 }
69 
70 /**
71  * @tc.name: GetSupportFeatureComboTest_001
72  * @tc.desc: Wifi hdi get support feature and combo function test
73  * @tc.type: FUNC
74  * @tc.require: AR000FRMJB
75  */
76 HWTEST_F(HdfWifiServiceCTest, GetSupportFeatureComboTest_001, TestSize.Level1)
77 {
78     uint8_t supType[PROTOCOL_80211_IFTYPE_NUM + 1] = {0};
79     uint32_t supTypeLen = PROTOCOL_80211_IFTYPE_NUM + 1;
80     uint64_t combo[DEFAULT_COMBO_SIZE] = {0};
81     uint32_t supTypeLenInvalid = 6;
82 
83     int32_t rc = g_wlanObj->GetSupportFeature(g_wlanObj, supType, &supTypeLenInvalid);
84     ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
85     rc = g_wlanObj->GetSupportFeature(g_wlanObj, supType, &supTypeLen);
86     ASSERT_EQ(rc, HDF_SUCCESS);
87     rc = g_wlanObj->GetSupportCombo(g_wlanObj, combo);
88     ASSERT_NE(rc, HDF_FAILURE);
89 }
90 
91 /**
92  * @tc.name: CreateFeatureTest_002
93  * @tc.desc: Wifi hdi create feature function test
94  * @tc.type: FUNC
95  * @tc.require: AR000FRMJB
96  */
97 HWTEST_F(HdfWifiServiceCTest, CreateFeatureTest_002, TestSize.Level1)
98 {
99     struct HdfFeatureInfo ifeature;
100     const int32_t wlanType = PROTOCOL_80211_IFTYPE_AP;
101 
102     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
103     if (rc == HDF_SUCCESS) {
104         printf("ifname = %s\n", ifeature.ifName);
105         printf("type = %d\n", ifeature.type);
106         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
107         ASSERT_EQ(rc, HDF_SUCCESS);
108     }
109 }
110 
111 /**
112  * @tc.name: GetFeatureByIfNameTest_003
113  * @tc.desc: Wifi hdi get feature by ifname function test
114  * @tc.type: FUNC
115  * @tc.require: AR000FRMJB
116  */
117 HWTEST_F(HdfWifiServiceCTest, GetFeatureByIfNameTest_003, TestSize.Level1)
118 {
119     const int32_t wlanType = PROTOCOL_80211_IFTYPE_AP;
120     struct HdfFeatureInfo ifeature;
121     const char *ifNameInvalid = "wlanTest";
122 
123     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
124     if (rc == HDF_SUCCESS) {
125         rc = g_wlanObj->GetFeatureByIfName(g_wlanObj, ifNameInvalid, &ifeature);
126         ASSERT_NE(rc, HDF_SUCCESS);
127         rc = g_wlanObj->GetFeatureByIfName(g_wlanObj, ifeature.ifName, &ifeature);
128         ASSERT_EQ(rc, HDF_SUCCESS);
129         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
130         ASSERT_EQ(rc, HDF_SUCCESS);
131     }
132 }
133 
134 /**
135  * @tc.name: GetNetworkIfaceNameTest_004
136  * @tc.desc: Wifi hdi get network interface name function test on AP feature
137  * @tc.type: FUNC
138  * @tc.require: AR000FRMJB
139  */
140 HWTEST_F(HdfWifiServiceCTest, GetNetworkIfaceNameTest_004, TestSize.Level1)
141 {
142     const int32_t wlanType = PROTOCOL_80211_IFTYPE_AP;
143     struct HdfFeatureInfo ifeature;
144     char ifNames[IFNAMSIZ] = {0};
145 
146     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
147     if (rc == HDF_SUCCESS) {
148         rc = g_wlanObj->GetNetworkIfaceName(g_wlanObj, &ifeature, ifNames, IFNAMSIZ);
149         ASSERT_EQ(rc, HDF_SUCCESS);
150         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
151         ASSERT_EQ(rc, HDF_SUCCESS);
152     }
153 }
154 
155 /**
156  * @tc.name: GetFeatureTypeTest_005
157  * @tc.desc: Wifi hdi get feature type function test on AP feature
158  * @tc.type: FUNC
159  * @tc.require: AR000FRMJB
160  */
161 HWTEST_F(HdfWifiServiceCTest, GetFeatureTypeTest_005, TestSize.Level1)
162 {
163     const int32_t wlanType = PROTOCOL_80211_IFTYPE_AP;
164     struct HdfFeatureInfo ifeature;
165     int32_t featureType;
166 
167     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
168     if (rc == HDF_SUCCESS) {
169         rc = g_wlanObj->GetFeatureType(g_wlanObj, &ifeature, &featureType);
170         ASSERT_EQ(rc, HDF_SUCCESS);
171         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
172         ASSERT_EQ(rc, HDF_SUCCESS);
173     }
174 }
175 
176 /**
177  * @tc.name: SetMacAddressTest_006
178  * @tc.desc: Wifi hdi set mac addr function test on AP feature
179  * @tc.type: FUNC
180  * @tc.require: AR000FRMJB
181  */
182 HWTEST_F(HdfWifiServiceCTest, SetMacAddressTest_006, TestSize.Level1)
183 {
184     uint8_t mac[ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd};
185     const int32_t wlanType = PROTOCOL_80211_IFTYPE_AP;
186     struct HdfFeatureInfo ifeature;
187     uint32_t macLen = ETH_ADDR_LEN;
188     uint8_t errorMac[ETH_ADDR_LEN] = {0x11, 0x34, 0x56, 0x78, 0xab, 0xcd};
189 
190     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
191     if (rc == HDF_SUCCESS) {
192         rc = g_wlanObj->SetMacAddress(g_wlanObj, &ifeature, errorMac, macLen);
193         ASSERT_NE(rc, HDF_SUCCESS);
194         rc = g_wlanObj->SetMacAddress(g_wlanObj, &ifeature, mac, macLen);
195         bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT || rc == HDF_ERR_DEVICE_BUSY);
196         ASSERT_TRUE(flag);
197         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
198         ASSERT_EQ(rc, HDF_SUCCESS);
199     }
200 }
201 
202 /**
203  * @tc.name: GetDeviceMacAddressTest_007
204  * @tc.desc: Wifi hdi get device mac addr function test on AP feature
205  * @tc.type: FUNC
206  * @tc.require: AR000FRMJB
207  */
208 HWTEST_F(HdfWifiServiceCTest, GetDeviceMacAddressTest_007, TestSize.Level1)
209 {
210     const int32_t wlanType = PROTOCOL_80211_IFTYPE_AP;
211     struct HdfFeatureInfo ifeature;
212     uint8_t mac[ETH_ADDR_LEN] = {0};
213     uint32_t macLen = ETH_ADDR_LEN;
214 
215     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
216     if (rc == HDF_SUCCESS) {
217         rc = g_wlanObj->GetDeviceMacAddress(g_wlanObj, &ifeature, mac, &macLen, ETH_ADDR_LEN);
218         ASSERT_EQ(rc, HDF_SUCCESS);
219         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
220         ASSERT_EQ(rc, HDF_SUCCESS);
221     }
222 }
223 
224 /**
225  * @tc.name: GetFreqsWithBandTest_008
226  * @tc.desc: Wifi hdi get freqs function test on AP feature
227  * @tc.type: FUNC
228  * @tc.require: AR000FRMJB
229  */
230 HWTEST_F(HdfWifiServiceCTest, GetFreqsWithBandTest_008, TestSize.Level1)
231 {
232     const int32_t wlanType = PROTOCOL_80211_IFTYPE_AP;
233     struct HdfFeatureInfo ifeature;
234     struct HdfWifiInfo wifiInfo;
235     int32_t freq[WLAN_FREQ_MAX_NUM] = {0};
236     uint32_t freqLen = WLAN_FREQ_MAX_NUM ;
237     wifiInfo.band = IEEE80211_BAND_2GHZ;
238     wifiInfo.size = WLAN_FREQ_MAX_NUM;
239     struct HdfWifiInfo wifiInfoInvalid;
240     wifiInfoInvalid.band = IEEE80211_NUM_BANDS;
241     wifiInfoInvalid.size = WLAN_FREQ_MAX_NUM;
242     uint32_t i;
243 
244     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
245     if (rc == HDF_SUCCESS) {
246         rc = g_wlanObj->GetFreqsWithBand(g_wlanObj, &ifeature, &wifiInfoInvalid, freq, &freqLen);
247         ASSERT_NE(rc, HDF_SUCCESS);
248         rc = g_wlanObj->GetFreqsWithBand(g_wlanObj, &ifeature, &wifiInfo, freq, &freqLen);
249         ASSERT_EQ(rc, HDF_SUCCESS);
250         if (rc == HDF_SUCCESS) {
251             for (i = 0; i < freqLen; i++) {
252                 printf("%s: freq[%d] = %d\n", __func__, i, freq[i]);
253             }
254         }
255 
256         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
257         ASSERT_EQ(rc, HDF_SUCCESS);
258     }
259 }
260 
261 /**
262  * @tc.name: SetTxPowerTest_009
263  * @tc.desc: Wifi hdi set tx power function test on AP feature
264  * @tc.type: FUNC
265  * @tc.require: AR000FRMJB
266  */
267 HWTEST_F(HdfWifiServiceCTest, SetTxPowerTest_009, TestSize.Level1)
268 {
269     const int32_t wlanType = PROTOCOL_80211_IFTYPE_AP;
270     struct HdfFeatureInfo ifeature;
271     int32_t power = WLAN_TX_POWER;
272 
273     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
274     if (rc == HDF_SUCCESS) {
275         rc = g_wlanObj->SetTxPower(g_wlanObj, &ifeature, power);
276         ASSERT_EQ(rc, HDF_SUCCESS);
277         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
278         ASSERT_EQ(rc, HDF_SUCCESS);
279     }
280 }
281 
282 /**
283  * @tc.name: GetChipIdTest_010
284  * @tc.desc: Wifi hdi get chip id function test on STA feature
285  * @tc.type: FUNC
286  * @tc.require: AR000FRMJB
287  */
288 HWTEST_F(HdfWifiServiceCTest, GetChipIdTest_010, TestSize.Level1)
289 {
290     const int32_t wlanType = PROTOCOL_80211_IFTYPE_STATION;
291     struct HdfFeatureInfo ifeature;
292     uint8_t chipId = 0;
293     uint8_t chipIdInvalid = 100;
294     unsigned int num = 0;
295     char ifNames[IFNAMSIZ] = {0};
296 
297     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
298     if (rc == HDF_SUCCESS) {
299         rc = g_wlanObj->GetChipId(g_wlanObj, &ifeature, &chipId);
300         ASSERT_EQ(rc, HDF_SUCCESS);
301         rc = g_wlanObj->GetIfNamesByChipId(g_wlanObj, chipIdInvalid, ifNames, IFNAMSIZ, &num);
302         ASSERT_NE(rc, HDF_SUCCESS);
303         rc = g_wlanObj->GetIfNamesByChipId(g_wlanObj, chipId, ifNames, IFNAMSIZ, &num);
304         printf("ifnames = %s\n", ifNames);
305         ASSERT_EQ(rc, HDF_SUCCESS);
306         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
307         ASSERT_EQ(rc, HDF_SUCCESS);
308     }
309 }
310 
311 /**
312  * @tc.name: SetScanningMacAddressTest_011
313  * @tc.desc: Wifi hdi set scanning mac addr function test
314  * @tc.type: FUNC
315  * @tc.require: AR000FRMJB
316  */
317 HWTEST_F(HdfWifiServiceCTest, SetScanningMacAddressTest_011, TestSize.Level1)
318 {
319     const int32_t wlanType = PROTOCOL_80211_IFTYPE_STATION;
320     struct HdfFeatureInfo ifeature;
321     uint8_t scanMac[ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd};
322     uint32_t macLen = ETH_ADDR_LEN;
323 
324     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
325     if (rc == HDF_SUCCESS) {
326         rc = g_wlanObj->SetScanningMacAddress(g_wlanObj, &ifeature, scanMac, macLen);
327         ASSERT_NE(rc, HDF_FAILURE);
328         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
329         ASSERT_EQ(rc, HDF_SUCCESS);
330     }
331 }
332 
333 /**
334  * @tc.name: GetNetdevInfoTest_012
335  * @tc.desc: Wifi hdi get netdev info function test
336  * @tc.type: FUNC
337  * @tc.require: AR000FRMJB
338  */
339 HWTEST_F(HdfWifiServiceCTest, GetNetdevInfoTest_012, TestSize.Level1)
340 {
341     int32_t rc;
342     struct HdfNetDeviceInfoResult netDeviceInfoResult;
343 
344     (void)memset_s(
345         &netDeviceInfoResult, sizeof(struct HdfNetDeviceInfoResult), 0, sizeof(struct HdfNetDeviceInfoResult));
346     rc = g_wlanObj->GetNetDevInfo(g_wlanObj, (struct HdfNetDeviceInfoResult *)&netDeviceInfoResult);
347     ASSERT_EQ(rc, HDF_SUCCESS);
348 }
349 
350 /**
351  * @tc.name: GetPowerModeTest_013
352  * @tc.desc: Wifi hdi get power mode function test
353  * @tc.type: FUNC
354  * @tc.require: AR000H60O7
355  */
356 HWTEST_F(HdfWifiServiceCTest, GetPowerModeTest_013, TestSize.Level1)
357 {
358     struct HdfFeatureInfo ifeature;
359     uint8_t mode = 0;
360 
361     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, PROTOCOL_80211_IFTYPE_AP, &ifeature);
362     if (rc == HDF_SUCCESS) {
363         rc = g_wlanObj->GetPowerMode(g_wlanObj, &ifeature, &mode);
364         bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT);
365         ASSERT_TRUE(flag);
366         printf("mode = 0x%02x\n", mode);
367         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
368         ASSERT_EQ(rc, HDF_SUCCESS);
369     }
370 }
371 
372 /**
373  * @tc.name: SetPowerModeTest_014
374  * @tc.desc: Wifi hdi set power mode function test
375  * @tc.type: FUNC
376  * @tc.require: AR000H60O7
377  */
378 HWTEST_F(HdfWifiServiceCTest, SetPowerModeTest_014, TestSize.Level1)
379 {
380     struct HdfFeatureInfo ifeature;
381     uint8_t mode = WIFI_POWER_MODE_SLEEPING;
382 
383     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, PROTOCOL_80211_IFTYPE_AP, &ifeature);
384     if (rc == HDF_SUCCESS) {
385         rc = g_wlanObj->SetPowerMode(g_wlanObj, &ifeature, mode);
386         bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT);
387         ASSERT_TRUE(flag);
388         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
389         ASSERT_EQ(rc, HDF_SUCCESS);
390     }
391 }
392 
393 /**
394  * @tc.name: RegisterEventCallbackTest_015
395  * @tc.desc: Wifi hdi register event call back function test
396  * @tc.type: FUNC
397  * @tc.require: AR000FRMJB
398  */
399 HWTEST_F(HdfWifiServiceCTest, RegisterEventCallbackTest_015, TestSize.Level1)
400 {
401     const char *ifName = "wlan0";
402     int32_t rc = g_wlanObj->RegisterEventCallback(g_wlanObj, g_wlanCallbackObj, ifName);
403     ASSERT_EQ(rc, HDF_SUCCESS);
404 }
405 
406 /**
407  * @tc.name: ResetDriverTest_016
408  * @tc.desc: Wifi hdi reset driver function test
409  * @tc.type: FUNC
410  * @tc.require: AR000FRMJB
411  */
412 HWTEST_F(HdfWifiServiceCTest, ResetDriverTest_016, TestSize.Level1)
413 {
414     int32_t wlanType = PROTOCOL_80211_IFTYPE_STATION;
415     struct HdfFeatureInfo ifeature;
416     const char *ifName = "wlan0";
417     uint8_t chipId = 0;
418     int32_t rc;
419 
420     rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
421     if (rc == HDF_SUCCESS) {
422         rc = g_wlanObj->GetChipId(g_wlanObj, &ifeature, &chipId);
423         ASSERT_EQ(rc, HDF_SUCCESS);
424         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
425         ASSERT_EQ(rc, HDF_SUCCESS);
426         rc = g_wlanObj->ResetDriver(g_wlanObj, chipId, ifName);
427         ASSERT_EQ(rc, HDF_SUCCESS);
428         sleep(RESET_TIME);
429     }
430 }
431 
432 /**
433  * @tc.name: StartScanTest_017
434  * @tc.desc: Wifi hdi start scan function test
435  * @tc.type: FUNC
436  * @tc.require: AR000FRMJB
437  */
438 HWTEST_F(HdfWifiServiceCTest, StartScanTest_017, TestSize.Level1)
439 {
440     int32_t rc;
441     const int32_t wlanType = PROTOCOL_80211_IFTYPE_STATION;
442     struct HdfFeatureInfo ifeature;
443     struct HdfWifiScan scan = {0};
444 
445     rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
446     if (rc == HDF_SUCCESS) {
447         rc = g_wlanObj->StartScan(g_wlanObj, nullptr, &scan);
448         ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
449         rc = g_wlanObj->StartScan(g_wlanObj, &ifeature, nullptr);
450         ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
451         rc = g_wlanObj->StartScan(g_wlanObj, &ifeature, &scan);
452         ASSERT_EQ(rc, HDF_SUCCESS);
453         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
454         ASSERT_EQ(rc, HDF_SUCCESS);
455         sleep(SCAN_TIME);
456     }
457 }
458 
459 /**
460  * @tc.name: UnregisterEventCallbackTest_018
461  * @tc.desc: Wifi hdi unreister event call back function test
462  * @tc.type: FUNC
463  * @tc.require: AR000FRMJB
464  */
465 HWTEST_F(HdfWifiServiceCTest, UnregisterEventCallbackTest_018, TestSize.Level1)
466 {
467     const char *ifName = "wlan0";
468     int32_t rc = g_wlanObj->UnregisterEventCallback(g_wlanObj, g_wlanCallbackObj, ifName);
469     ASSERT_EQ(rc, HDF_SUCCESS);
470 }
471 
472 /**
473  * @tc.name: GetAssociatedStasTest_019
474  * @tc.desc: Wifi hdi get assoc stas function test
475  * @tc.type: FUNC
476  * @tc.require:
477  */
478 HWTEST_F(HdfWifiServiceCTest, GetAssociatedStasTest_019, TestSize.Level1)
479 {
480     const int32_t wlanType = PROTOCOL_80211_IFTYPE_AP;
481     struct HdfFeatureInfo ifeature;
482     struct HdfStaInfo staInfo[WLAN_MAX_NUM_STA_WITH_AP] = {{0}};
483     uint32_t staInfoLen = WLAN_MAX_NUM_STA_WITH_AP;
484     uint32_t num = 0;
485 
486     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
487     if (rc == HDF_SUCCESS) {
488         rc = g_wlanObj->GetAssociatedStas(g_wlanObj, &ifeature, staInfo, &staInfoLen, &num);
489         ASSERT_EQ(rc, HDF_SUCCESS);
490         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
491         ASSERT_EQ(rc, HDF_SUCCESS);
492     }
493 }
494 
495 /**
496  * @tc.name: SetCountryCodeTest_020
497  * @tc.desc: Wifi hdi set country code function test
498  * @tc.type: FUNC
499  * @tc.require:
500  */
501 HWTEST_F(HdfWifiServiceCTest, SetCountryCodeTest_020, TestSize.Level1)
502 {
503     const char *code = "CN";
504     const int32_t wlanType = PROTOCOL_80211_IFTYPE_AP;
505     struct HdfFeatureInfo ifeature;
506     const char *codeDigital = "99";
507     uint32_t size = 2;
508 
509     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
510     if (rc == HDF_SUCCESS) {
511         rc = g_wlanObj->SetCountryCode(g_wlanObj, &ifeature, codeDigital, size);
512         bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT);
513         ASSERT_TRUE(flag);
514         rc = g_wlanObj->SetCountryCode(g_wlanObj, &ifeature, code, size);
515         ASSERT_EQ(rc, HDF_SUCCESS);
516         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
517         ASSERT_EQ(rc, HDF_SUCCESS);
518     }
519 }
520 
521 /**
522  * @tc.name: CreateFeatureTest_021
523  * @tc.desc: Wifi hdi create feature function test
524  * @tc.type: FUNC
525  * @tc.require: AR000H603L
526  */
527 HWTEST_F(HdfWifiServiceCTest, CreateFeatureTest_021, TestSize.Level1)
528 {
529     struct HdfFeatureInfo ifeature;
530     const int32_t wlanType = PROTOCOL_80211_IFTYPE_STATION;
531     int32_t wlanTypeInvalid = PROTOCOL_80211_IFTYPE_NUM;
532 
533     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanTypeInvalid, &ifeature);
534     ASSERT_EQ(rc, HDF_FAILURE);
535     rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
536     if (rc == HDF_SUCCESS) {
537         printf("ifname = %s\n", ifeature.ifName);
538         printf("type = %d\n", ifeature.type);
539         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
540         ASSERT_EQ(rc, HDF_SUCCESS);
541     }
542 }
543 
544 /**
545  * @tc.name: GetChipIdTest_022
546  * @tc.desc: Wifi hdi get chip id function test
547  * @tc.type: FUNC
548  * @tc.require: AR000H603L
549  */
550 HWTEST_F(HdfWifiServiceCTest, GetChipIdTest_022, TestSize.Level1)
551 {
552     const int32_t wlanType = PROTOCOL_80211_IFTYPE_AP;
553     struct HdfFeatureInfo ifeature;
554     uint8_t chipId = 0;
555 
556     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
557     if (rc == HDF_SUCCESS) {
558         rc = g_wlanObj->GetChipId(g_wlanObj, &ifeature, &chipId);
559         ASSERT_EQ(rc, HDF_SUCCESS);
560         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
561         ASSERT_EQ(rc, HDF_SUCCESS);
562     }
563 }
564 
565 /**
566  * @tc.name: GetDeviceMacAddressTest_023
567  * @tc.desc: Wifi hdi get device mac addr function test on STA feature
568  * @tc.type: FUNC
569  * @tc.require: AR000H603L
570  */
571 HWTEST_F(HdfWifiServiceCTest, GetDeviceMacAddressTest_023, TestSize.Level1)
572 {
573     const int32_t wlanType = PROTOCOL_80211_IFTYPE_STATION;
574     struct HdfFeatureInfo ifeature;
575     uint8_t mac[ETH_ADDR_LEN] = {0};
576     uint32_t macLen = ETH_ADDR_LEN;
577 
578     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
579     if (rc == HDF_SUCCESS) {
580         rc = g_wlanObj->GetDeviceMacAddress(g_wlanObj, &ifeature, mac, &macLen, ETH_ADDR_LEN);
581         ASSERT_EQ(rc, HDF_SUCCESS);
582         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
583         ASSERT_EQ(rc, HDF_SUCCESS);
584     }
585 }
586 
587 /**
588  * @tc.name: GetFeatureByIfNameTest_024
589  * @tc.desc: Wifi hdi get feature by ifname function test
590  * @tc.type: FUNC
591  * @tc.require: AR000H603L
592  */
593 HWTEST_F(HdfWifiServiceCTest, GetFeatureByIfNameTest_024, TestSize.Level1)
594 {
595     const int32_t wlanType = PROTOCOL_80211_IFTYPE_STATION;
596     struct HdfFeatureInfo ifeature;
597     const char *ifNameInvalid = "wlanTest";
598 
599     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
600     if (rc == HDF_SUCCESS) {
601         rc = g_wlanObj->GetFeatureByIfName(g_wlanObj, ifNameInvalid, &ifeature);
602         ASSERT_NE(rc, HDF_SUCCESS);
603         rc = g_wlanObj->GetFeatureByIfName(g_wlanObj, ifeature.ifName, &ifeature);
604         ASSERT_EQ(rc, HDF_SUCCESS);
605         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
606         ASSERT_EQ(rc, HDF_SUCCESS);
607     }
608 }
609 
610 /**
611  * @tc.name: SetMacAddressTest_025
612  * @tc.desc: Wifi hdi set mac addr function test on STA feature
613  * @tc.type: FUNC
614  * @tc.require: AR000H603L
615  */
616 HWTEST_F(HdfWifiServiceCTest, SetMacAddressTest_025, TestSize.Level1)
617 {
618     uint8_t mac[ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd};
619     const int32_t wlanType = PROTOCOL_80211_IFTYPE_STATION;
620     struct HdfFeatureInfo ifeature;
621     uint32_t macLen = ETH_ADDR_LEN;
622     uint8_t errorMac[ETH_ADDR_LEN] = {0x11, 0x34, 0x56, 0x78, 0xab, 0xcd};
623 
624     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
625     if (rc == HDF_SUCCESS) {
626         rc = g_wlanObj->SetMacAddress(g_wlanObj, &ifeature, errorMac, macLen);
627         ASSERT_NE(rc, HDF_SUCCESS);
628         rc = g_wlanObj->SetMacAddress(g_wlanObj, &ifeature, mac, macLen);
629         bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT || rc == HDF_ERR_DEVICE_BUSY);
630         ASSERT_TRUE(flag);
631         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
632         ASSERT_EQ(rc, HDF_SUCCESS);
633     }
634 }
635 
636 /**
637  * @tc.name: GetPowerModeTest_026
638  * @tc.desc: Wifi hdi get power mode function test
639  * @tc.type: FUNC
640  * @tc.require: AR000H603L
641  */
642 HWTEST_F(HdfWifiServiceCTest, GetPowerModeTest_026, TestSize.Level1)
643 {
644     struct HdfFeatureInfo ifeature;
645     uint8_t mode = 0;
646 
647     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, PROTOCOL_80211_IFTYPE_STATION, &ifeature);
648     if (rc == HDF_SUCCESS) {
649         rc = g_wlanObj->GetPowerMode(g_wlanObj, &ifeature, &mode);
650         bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT);
651         ASSERT_TRUE(flag);
652         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
653         ASSERT_EQ(rc, HDF_SUCCESS);
654     }
655 }
656 
657 /**
658  * @tc.name: SetPowerModeTest_027
659  * @tc.desc: Wifi hdi set power mode function test
660  * @tc.type: FUNC
661  * @tc.require: AR000H603L
662  */
663 HWTEST_F(HdfWifiServiceCTest, SetPowerModeTest_027, TestSize.Level1)
664 {
665     struct HdfFeatureInfo ifeature;
666     uint8_t mode = WIFI_POWER_MODE_GENERAL;
667 
668     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, PROTOCOL_80211_IFTYPE_AP, &ifeature);
669     if (rc == HDF_SUCCESS) {
670         rc = g_wlanObj->SetPowerMode(g_wlanObj, &ifeature, mode);
671         bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT);
672         ASSERT_TRUE(flag);
673         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
674         ASSERT_EQ(rc, HDF_SUCCESS);
675     }
676 }
677 
678 /**
679  * @tc.name: SetPowerModeTest_028
680  * @tc.desc: Wifi hdi set power mode function test
681  * @tc.type: FUNC
682  * @tc.require: AR000H603L
683  */
684 HWTEST_F(HdfWifiServiceCTest, SetPowerModeTest_028, TestSize.Level1)
685 {
686     struct HdfFeatureInfo ifeature;
687     uint8_t mode = WIFI_POWER_MODE_THROUGH_WALL;
688 
689     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, PROTOCOL_80211_IFTYPE_AP, &ifeature);
690     if (rc == HDF_SUCCESS) {
691         rc = g_wlanObj->SetPowerMode(g_wlanObj, &ifeature, mode);
692         bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT);
693         ASSERT_TRUE(flag);
694         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
695         ASSERT_EQ(rc, HDF_SUCCESS);
696     }
697 }
698 
699 /**
700  * @tc.name: SetPowerModeTest_029
701  * @tc.desc: Wifi hdi set power mode function test
702  * @tc.type: FUNC
703  * @tc.require: AR000H603L
704  */
705 HWTEST_F(HdfWifiServiceCTest, SetPowerModeTest_029, TestSize.Level1)
706 {
707     struct HdfFeatureInfo ifeature;
708     uint8_t mode = WIFI_POWER_MODE_NUM;
709 
710     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, PROTOCOL_80211_IFTYPE_AP, &ifeature);
711     if (rc == HDF_SUCCESS) {
712         rc = g_wlanObj->SetPowerMode(g_wlanObj, &ifeature, mode);
713         ASSERT_NE(rc, HDF_SUCCESS);
714         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
715         ASSERT_EQ(rc, HDF_SUCCESS);
716     }
717 }
718 
719 /**
720  * @tc.name: SetPowerModeTest_30
721  * @tc.desc: Wifi hdi set power mode function test
722  * @tc.type: FUNC
723  * @tc.require: AR000H603L
724  */
725 HWTEST_F(HdfWifiServiceCTest, SetPowerModeTest_030, TestSize.Level1)
726 {
727     struct HdfFeatureInfo ifeature;
728     uint8_t mode = WIFI_POWER_MODE_SLEEPING;
729 
730     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, PROTOCOL_80211_IFTYPE_STATION, &ifeature);
731     if (rc == HDF_SUCCESS) {
732         rc = g_wlanObj->SetPowerMode(g_wlanObj, &ifeature, mode);
733         bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT);
734         ASSERT_TRUE(flag);
735         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
736         ASSERT_EQ(rc, HDF_SUCCESS);
737     }
738 }
739 
740 /**
741  * @tc.name: SetPowerModeTest_031
742  * @tc.desc: Wifi hdi set power mode function test
743  * @tc.type: FUNC
744  * @tc.require: AR000H603L
745  */
746 HWTEST_F(HdfWifiServiceCTest, SetPowerModeTest_031, TestSize.Level1)
747 {
748     struct HdfFeatureInfo ifeature;
749     uint8_t mode = WIFI_POWER_MODE_GENERAL;
750 
751     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, PROTOCOL_80211_IFTYPE_STATION, &ifeature);
752     if (rc == HDF_SUCCESS) {
753         rc = g_wlanObj->SetPowerMode(g_wlanObj, &ifeature, mode);
754         bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT);
755         ASSERT_TRUE(flag);
756         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
757         ASSERT_EQ(rc, HDF_SUCCESS);
758     }
759 }
760 
761 /**
762  * @tc.name: SetPowerModeTest_032
763  * @tc.desc: Wifi hdi set power mode function test
764  * @tc.type: FUNC
765  * @tc.require: AR000H603L
766  */
767 HWTEST_F(HdfWifiServiceCTest, SetPowerModeTest_032, TestSize.Level1)
768 {
769     struct HdfFeatureInfo ifeature;
770     uint8_t mode = WIFI_POWER_MODE_THROUGH_WALL;
771 
772     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, PROTOCOL_80211_IFTYPE_STATION, &ifeature);
773     if (rc == HDF_SUCCESS) {
774         rc = g_wlanObj->SetPowerMode(g_wlanObj, &ifeature, mode);
775         bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT);
776         ASSERT_TRUE(flag);
777         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
778         ASSERT_EQ(rc, HDF_SUCCESS);
779     }
780 }
781 
782 /**
783  * @tc.name: SetPowerModeTest_033
784  * @tc.desc: Wifi hdi set power mode function test
785  * @tc.type: FUNC
786  * @tc.require: AR000H603L
787  */
788 HWTEST_F(HdfWifiServiceCTest, SetPowerModeTest_033, TestSize.Level1)
789 {
790     struct HdfFeatureInfo ifeature;
791     uint8_t mode = WIFI_POWER_MODE_NUM;
792 
793     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, PROTOCOL_80211_IFTYPE_STATION, &ifeature);
794     if (rc == HDF_SUCCESS) {
795         rc = g_wlanObj->SetPowerMode(g_wlanObj, &ifeature, mode);
796         ASSERT_NE(rc, HDF_SUCCESS);
797         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
798         ASSERT_EQ(rc, HDF_SUCCESS);
799     }
800 }
801 
802 /**
803  * @tc.name: StartChannelMeasTest_034
804  * @tc.desc: Wifi hdi start channel meas and get meas result function test
805  * @tc.type: FUNC
806  * @tc.require: AR000H603J
807  */
808 HWTEST_F(HdfWifiServiceCTest, StartChannelMeasTest_034, TestSize.Level1)
809 {
810     const char *ifName = "wlan0";
811     struct MeasChannelParam measChannelParam;
812     struct MeasChannelResult measChannelResult = {0};
813 
814     measChannelParam.channelId = 1;
815     measChannelParam.measTime = 15;
816     int32_t rc = g_wlanObj->StartChannelMeas(g_wlanObj, ifName, &measChannelParam);
817     bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT || rc == HDF_DEV_ERR_NETDOWN);
818     ASSERT_TRUE(flag);
819     sleep(MEAS_CHANNEL_TIME);
820     rc = g_wlanObj->GetChannelMeasResult(g_wlanObj, ifName, &measChannelResult);
821     flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT || rc == HDF_DEV_ERR_NODATA);
822     ASSERT_TRUE(flag);
823     rc = g_wlanObj->StartChannelMeas(g_wlanObj, nullptr, &measChannelParam);
824     ASSERT_NE(rc, HDF_SUCCESS);
825     rc = g_wlanObj->StartChannelMeas(g_wlanObj, ifName, nullptr);
826     ASSERT_NE(rc, HDF_SUCCESS);
827     rc = g_wlanObj->GetChannelMeasResult(g_wlanObj, nullptr, &measChannelResult);
828     ASSERT_NE(rc, HDF_SUCCESS);
829     rc = g_wlanObj->GetChannelMeasResult(g_wlanObj, ifName, nullptr);
830     ASSERT_NE(rc, HDF_SUCCESS);
831 }
832 
833 /**
834  * @tc.name: SetProjectionScreenParam_035
835  * @tc.desc: Wifi hdi set paramters to optimize projectino screen function test
836  * @tc.type: FUNC
837  * @tc.require: AR000HDUEE
838  */
839 HWTEST_F(HdfWifiServiceCTest, SetProjectionScreenParam_035, TestSize.Level1)
840 {
841     const char *ifName = "wlan0";
842     int32_t rc;
843     struct ProjectionScreenCmdParam param;
844     int8_t data = 0;
845     (void)memset_s(&param, sizeof(struct ProjectionScreenCmdParam), 0, sizeof(struct ProjectionScreenCmdParam));
846 
847     param.buf = &data;
848     param.bufLen = sizeof(data);
849     param.cmdId = CMD_CLOSE_GO_CAC;
850     rc = g_wlanObj->SetProjectionScreenParam(g_wlanObj, ifName, &param);
851     printf("ScreenParam = %d, rc = %d.\n", CMD_CLOSE_GO_CAC, rc);
852     bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT);
853     ASSERT_TRUE(flag);
854 }
855 
856 /**
857  * @tc.name: SetProjectionScreenParam_036
858  * @tc.desc: Wifi hdi set paramters to optimize projectino screen function test
859  * @tc.type: FUNC
860  * @tc.require:
861  */
862 HWTEST_F(HdfWifiServiceCTest, SetProjectionScreenParam_036, TestSize.Level1)
863 {
864     const char *ifName = "wlan0";
865     int32_t rc;
866     struct ProjectionScreenCmdParam param;
867     int8_t data = 0;
868     (void)memset_s(&param, sizeof(struct ProjectionScreenCmdParam), 0, sizeof(struct ProjectionScreenCmdParam));
869 
870     param.buf = &data;
871     param.bufLen = sizeof(data);
872     param.cmdId = CMD_SET_GO_CSA_CHANNEL;
873     rc = g_wlanObj->SetProjectionScreenParam(g_wlanObj, ifName, &param);
874     printf("ScreenParam = %d, rc = %d.\n", CMD_SET_GO_CSA_CHANNEL, rc);
875     bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT || rc == HDF_DEV_ERR_NETDOWN);
876     ASSERT_TRUE(flag);
877 }
878 
879 /**
880  * @tc.name: SetProjectionScreenParam_037
881  * @tc.desc: Wifi hdi set paramters to optimize projectino screen function test
882  * @tc.type: FUNC
883  * @tc.require:
884  */
885 HWTEST_F(HdfWifiServiceCTest, SetProjectionScreenParam_037, TestSize.Level1)
886 {
887     const char *ifName = "wlan0";
888     int32_t rc;
889     struct ProjectionScreenCmdParam param;
890     int8_t data = 0;
891     (void)memset_s(&param, sizeof(struct ProjectionScreenCmdParam), 0, sizeof(struct ProjectionScreenCmdParam));
892 
893     param.buf = &data;
894     param.bufLen = sizeof(data);
895     param.cmdId = CMD_SET_GO_RADAR_DETECT;
896     rc = g_wlanObj->SetProjectionScreenParam(g_wlanObj, ifName, &param);
897     printf("ScreenParam = %d, rc = %d.\n", CMD_SET_GO_RADAR_DETECT, rc);
898     bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT || rc == HDF_DEV_ERR_NETDOWN);
899     ASSERT_TRUE(flag);
900 }
901 
902 /**
903  * @tc.name: SetProjectionScreenParam_038
904  * @tc.desc: Wifi hdi set paramters to optimize projectino screen function test
905  * @tc.type: FUNC
906  * @tc.require:
907  */
908 HWTEST_F(HdfWifiServiceCTest, SetProjectionScreenParam_038, TestSize.Level1)
909 {
910     const char *ifName = "wlan0";
911     int32_t rc;
912     struct ProjectionScreenCmdParam param;
913     int8_t data = 0;
914     (void)memset_s(&param, sizeof(struct ProjectionScreenCmdParam), 0, sizeof(struct ProjectionScreenCmdParam));
915 
916     param.buf = &data;
917     param.bufLen = sizeof(data);
918     param.cmdId = CMD_ID_MCC_STA_P2P_QUOTA_TIME;
919     rc = g_wlanObj->SetProjectionScreenParam(g_wlanObj, ifName, &param);
920     printf("ScreenParam = %d, rc = %d.\n", CMD_ID_MCC_STA_P2P_QUOTA_TIME, rc);
921     bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT || rc == HDF_DEV_ERR_NETDOWN);
922     ASSERT_TRUE(flag);
923 }
924 
925 /**
926  * @tc.name: SetProjectionScreenParam_039
927  * @tc.desc: Wifi hdi set paramters to optimize projectino screen function test
928  * @tc.type: FUNC
929  * @tc.require:
930  */
931 HWTEST_F(HdfWifiServiceCTest, SetProjectionScreenParam_039, TestSize.Level1)
932 {
933     const char *ifName = "wlan0";
934     int32_t rc;
935     struct ProjectionScreenCmdParam param;
936     int8_t data = 0;
937     (void)memset_s(&param, sizeof(struct ProjectionScreenCmdParam), 0, sizeof(struct ProjectionScreenCmdParam));
938 
939     param.buf = &data;
940     param.bufLen = sizeof(data);
941     param.cmdId = CMD_ID_CTRL_ROAM_CHANNEL;
942     rc = g_wlanObj->SetProjectionScreenParam(g_wlanObj, ifName, &param);
943     printf("ScreenParam = %d, rc = %d.\n", CMD_ID_CTRL_ROAM_CHANNEL, rc);
944     bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT || rc == HDF_DEV_ERR_NETDOWN);
945     ASSERT_TRUE(flag);
946 }
947 
948 /**
949  * @tc.name: SendCmdIoctl_040
950  * @tc.desc: Wifi hdi send ioctl command function test
951  * @tc.type: FUNC
952  * @tc.require: AR000HDUEE
953  */
954 HWTEST_F(HdfWifiServiceCTest, SendCmdIoctl_040, TestSize.Level1)
955 {
956     const char *ifName = "wlan0";
957     int32_t rc;
958     bool flag;
959 
960     uint8_t deviceType = 5;
961     rc = g_wlanObj->WifiSendCmdIoctl(g_wlanObj, ifName, CMD_HID2D_MODULE_INIT, (const int8_t *)&deviceType,
962         sizeof(deviceType));
963     printf("SendCmdIoctl MODULE_INIT, rc=%d.\n", rc);
964     flag = ((rc == HDF_SUCCESS) || (rc == HDF_ERR_NOT_SUPPORT));
965     ASSERT_TRUE(flag);
966 }
967 
968 /**
969  * @tc.name: SendCmdIoctl_041
970  * @tc.desc: Wifi hdi send ioctl command function test
971  * @tc.type: FUNC
972  * @tc.require:
973  */
974 HWTEST_F(HdfWifiServiceCTest, SendCmdIoctl_041, TestSize.Level1)
975 {
976     const char *ifName = "wlan0";
977     int32_t rc;
978     bool flag;
979 
980     uint8_t batterylevel = 50;
981     rc = g_wlanObj->WifiSendCmdIoctl(g_wlanObj, ifName, CMD_SET_BATTERY_LEVEL, (const int8_t *)&batterylevel,
982         sizeof(batterylevel));
983     printf("SendCmdIoctl BATTERY_LEVEL, rc=%d.\n", rc);
984     flag = ((rc == HDF_SUCCESS) || (rc == HDF_ERR_NOT_SUPPORT));
985     ASSERT_TRUE(flag);
986 }
987 
988 /**
989  * @tc.name: SendCmdIoctl_042
990  * @tc.desc: Wifi hdi send ioctl command function test
991  * @tc.type: FUNC
992  * @tc.require:
993  */
994 HWTEST_F(HdfWifiServiceCTest, SendCmdIoctl_042, TestSize.Level1)
995 {
996     const char *ifName = "wlan0";
997     int32_t rc;
998     bool flag;
999 
1000     struct AdjustChannelInfo chanInfo;
1001     chanInfo.msgId = 5;
1002     chanInfo.chanNumber = 36;
1003     chanInfo.bandwidth = 80;
1004     chanInfo.switchType = 0;
1005     rc = g_wlanObj->WifiSendCmdIoctl(g_wlanObj, ifName, CMD_SET_CHAN_ADJUST, (const int8_t *)&chanInfo,
1006         sizeof(chanInfo));
1007     printf("SendCmdIoctl CHAN_ADJUST, rc=%d.\n", rc);
1008     flag = ((rc == HDF_SUCCESS) || (rc == HDF_ERR_NOT_SUPPORT) || (rc == HDF_DEV_ERR_NETDOWN));
1009     ASSERT_TRUE(flag);
1010 }
1011 
1012 /**
1013  * @tc.name: GetStaInfo_043
1014  * @tc.desc: Wifi hdi get station information function test
1015  * @tc.type: FUNC
1016  * @tc.require:
1017  */
1018 HWTEST_F(HdfWifiServiceCTest, GetStaInfo_043, TestSize.Level1)
1019 {
1020     const char *ifName = "wlan0";
1021     int32_t rc;
1022     struct WifiStationInfo info;
1023     bool flag;
1024     uint8_t mac[ETH_ADDR_LEN] = {0};
1025 
1026     rc = g_wlanObj->GetStaInfo(g_wlanObj, ifName, &info, mac, ETH_ADDR_LEN);
1027     flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT);
1028     ASSERT_TRUE(flag);
1029 }
1030 
1031 /**
1032  * @tc.name: GetFeatureTypeTest_044
1033  * @tc.desc: Wifi hdi get feature type function test on STA feature
1034  * @tc.type: FUNC
1035  * @tc.require:
1036  */
1037 HWTEST_F(HdfWifiServiceCTest, GetFeatureTypeTest_044, TestSize.Level1)
1038 {
1039     const int32_t wlanType = PROTOCOL_80211_IFTYPE_STATION;
1040     struct HdfFeatureInfo ifeature;
1041     int32_t featureType;
1042 
1043     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
1044     if (rc == HDF_SUCCESS) {
1045         rc = g_wlanObj->GetFeatureType(g_wlanObj, &ifeature, &featureType);
1046         ASSERT_EQ(rc, HDF_SUCCESS);
1047         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
1048         ASSERT_EQ(rc, HDF_SUCCESS);
1049     }
1050 }
1051 
1052 /**
1053  * @tc.name: GetFreqsWithBandTest_045
1054  * @tc.desc: Wifi hdi get freqs function test on STA feature
1055  * @tc.type: FUNC
1056  * @tc.require:
1057  */
1058 HWTEST_F(HdfWifiServiceCTest, GetFreqsWithBandTest_045, TestSize.Level1)
1059 {
1060     const int32_t wlanType = PROTOCOL_80211_IFTYPE_STATION;
1061     struct HdfFeatureInfo ifeature;
1062     struct HdfWifiInfo wifiInfo;
1063     int32_t freq[WLAN_FREQ_MAX_NUM] = {0};
1064     uint32_t freqLen = WLAN_FREQ_MAX_NUM;
1065     wifiInfo.band = IEEE80211_BAND_2GHZ;
1066     wifiInfo.size = WLAN_FREQ_MAX_NUM;
1067     uint32_t i;
1068 
1069     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
1070     if (rc == HDF_SUCCESS) {
1071         rc = g_wlanObj->GetFreqsWithBand(g_wlanObj, &ifeature, &wifiInfo, freq, &freqLen);
1072         ASSERT_EQ(rc, HDF_SUCCESS);
1073         if (rc == HDF_SUCCESS) {
1074             for (i = 0; i < freqLen; i++) {
1075                 printf("%s: freq[%d] = %d\n", __func__, i, freq[i]);
1076             }
1077         }
1078 
1079         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
1080         ASSERT_EQ(rc, HDF_SUCCESS);
1081     }
1082 }
1083 
1084 /**
1085  * @tc.name: GetNetworkIfaceNameTest_046
1086  * @tc.desc: Wifi hdi get network interface name function test on STA feature
1087  * @tc.type: FUNC
1088  * @tc.require:
1089  */
1090 HWTEST_F(HdfWifiServiceCTest, GetNetworkIfaceNameTest_046, TestSize.Level1)
1091 {
1092     const int32_t wlanType = PROTOCOL_80211_IFTYPE_STATION;
1093     struct HdfFeatureInfo ifeature;
1094     char ifNames[IFNAMSIZ] = {0};
1095 
1096     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
1097     if (rc == HDF_SUCCESS) {
1098         rc = g_wlanObj->GetNetworkIfaceName(g_wlanObj, &ifeature, ifNames, IFNAMSIZ);
1099         ASSERT_EQ(rc, HDF_SUCCESS);
1100         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
1101         ASSERT_EQ(rc, HDF_SUCCESS);
1102     }
1103 }
1104 
1105 /**
1106  * @tc.name: SetTxPowerTest_047
1107  * @tc.desc: Wifi hdi set tx power function test on STA feature
1108  * @tc.type: FUNC
1109  * @tc.require:
1110  */
1111 HWTEST_F(HdfWifiServiceCTest, SetTxPowerTest_047, TestSize.Level1)
1112 {
1113     const int32_t wlanType = PROTOCOL_80211_IFTYPE_STATION;
1114     struct HdfFeatureInfo ifeature;
1115     int32_t power = WLAN_TX_POWER;
1116 
1117     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
1118     if (rc == HDF_SUCCESS) {
1119         rc = g_wlanObj->SetTxPower(g_wlanObj, &ifeature, power);
1120         ASSERT_EQ(rc, HDF_SUCCESS);
1121         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
1122         ASSERT_EQ(rc, HDF_SUCCESS);
1123     }
1124 }
1125 
1126 /**
1127  * @tc.name: GetSignalPollInfo_048
1128  * @tc.desc: Wifi hdi get signal information
1129  * @tc.type: FUNC
1130  * @tc.require:
1131  */
1132 HWTEST_F(HdfWifiServiceCTest, GetSignalPollInfo_048, TestSize.Level1)
1133 {
1134     const int32_t wlanType = PROTOCOL_80211_IFTYPE_STATION;
1135     struct HdfFeatureInfo ifeature;
1136     const char *ifName = "wlan0";
1137     struct SignalPollResult signalResult;
1138     (void)memset_s(&signalResult, sizeof(struct SignalPollResult), 0, sizeof(struct SignalPollResult));
1139 
1140     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
1141     if (rc == HDF_SUCCESS) {
1142         rc = g_wlanObj->GetSignalPollInfo(g_wlanObj, ifName, &signalResult);
1143         bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT);
1144         printf("GetSignalPollInfo rc = %d.\n", rc);
1145         ASSERT_TRUE(flag);
1146         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
1147         ASSERT_EQ(rc, HDF_SUCCESS);
1148     }
1149 }
1150 
1151 /**
1152  * @tc.name: StartPnoScan_049
1153  * @tc.desc: Wifi hdi start pno scan
1154  * @tc.type: FUNC
1155  * @tc.require:
1156  */
1157 HWTEST_F(HdfWifiServiceCTest, StartPnoScan_049, TestSize.Level1)
1158 {
1159     const int32_t wlanType = PROTOCOL_80211_IFTYPE_STATION;
1160     struct HdfFeatureInfo ifeature;
1161     const char *ifName = "wlan0";
1162     string ssid1 = "xa-hw";
1163     string ssid2 = "xa-hw-03";
1164     struct PnoSettings pnoSettings;
1165     (void)memset_s(&pnoSettings, sizeof(struct PnoSettings), 0, sizeof(struct PnoSettings));
1166     pnoSettings.min2gRssi = -100;
1167     pnoSettings.min5gRssi = -120;
1168     pnoSettings.scanIntervalMs = 60000;
1169     pnoSettings.scanIterations = 3;
1170 
1171     pnoSettings.pnoNetworksLen = 2;
1172     pnoSettings.pnoNetworks = (struct PnoNetwork *)OsalMemCalloc(sizeof(struct PnoNetwork) * 2);
1173     pnoSettings.pnoNetworks[0].isHidden = 1;
1174     pnoSettings.pnoNetworks[0].ssid.ssid = const_cast<char*>(ssid1.c_str());
1175     pnoSettings.pnoNetworks[0].ssid.ssidLen = ssid1.length();
1176     pnoSettings.pnoNetworks[0].freqsLen = 2;
1177     pnoSettings.pnoNetworks[0].freqs = (int32_t *)OsalMemCalloc(sizeof(int32_t) * 2);
1178     pnoSettings.pnoNetworks[0].freqs[0] = 2412;
1179     pnoSettings.pnoNetworks[0].freqs[1] = 2447;
1180     pnoSettings.pnoNetworks[1].isHidden = 0;
1181     pnoSettings.pnoNetworks[1].ssid.ssid = const_cast<char*>(ssid2.c_str());
1182     pnoSettings.pnoNetworks[1].ssid.ssidLen = ssid2.length();
1183 
1184     int32_t rc = g_wlanObj->RegisterEventCallback(g_wlanObj, g_wlanCallbackObj, ifName);
1185     ASSERT_EQ(rc, HDF_SUCCESS);
1186     rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
1187     if (rc == HDF_SUCCESS) {
1188         rc = g_wlanObj->StartPnoScan(g_wlanObj, nullptr, &pnoSettings);
1189         ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
1190         rc = g_wlanObj->StartPnoScan(g_wlanObj, ifName, nullptr);
1191         ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
1192         rc = g_wlanObj->StartPnoScan(g_wlanObj, ifName, &pnoSettings);
1193         bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT);
1194         ASSERT_TRUE(flag);
1195         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
1196         ASSERT_EQ(rc, HDF_SUCCESS);
1197     }
1198     rc = g_wlanObj->UnregisterEventCallback(g_wlanObj, g_wlanCallbackObj, ifName);
1199     ASSERT_EQ(rc, HDF_SUCCESS);
1200     OsalMemFree(pnoSettings.pnoNetworks[0].freqs);
1201     OsalMemFree(pnoSettings.pnoNetworks);
1202 }
1203 
1204 /**
1205  * @tc.name: StopPnoScan_050
1206  * @tc.desc: Wifi hdi stop pno scan
1207  * @tc.type: FUNC
1208  * @tc.require:
1209  */
1210 HWTEST_F(HdfWifiServiceCTest, StopPnoScan_050, TestSize.Level1)
1211 {
1212     const int32_t wlanType = PROTOCOL_80211_IFTYPE_STATION;
1213     struct HdfFeatureInfo ifeature;
1214     const char *ifName = "wlan0";
1215 
1216     int32_t rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
1217     if (rc == HDF_SUCCESS) {
1218         rc = g_wlanObj->StopPnoScan(g_wlanObj, nullptr);
1219         ASSERT_EQ(rc, HDF_ERR_INVALID_PARAM);
1220         rc = g_wlanObj->StopPnoScan(g_wlanObj, ifName);
1221         bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT);
1222         ASSERT_TRUE(flag);
1223         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
1224         ASSERT_EQ(rc, HDF_SUCCESS);
1225     }
1226 }
1227 
1228 /**
1229  * @tc.name: StartScanTest_051
1230  * @tc.desc: Wifi hdi start scan function test
1231  * @tc.type: FUNC
1232  * @tc.require:
1233  */
1234 HWTEST_F(HdfWifiServiceCTest, StartScanTest_051, TestSize.Level1)
1235 {
1236     int32_t rc;
1237     const int32_t wlanType = PROTOCOL_80211_IFTYPE_STATION;
1238     string ssid1 = "xa-hw";
1239     struct HdfFeatureInfo ifeature;
1240     struct HdfWifiScan scan;
1241 
1242     (void)memset_s(&scan, sizeof(struct HdfWifiScan), 0, sizeof(struct HdfWifiScan));
1243     scan.ssidsLen = 1;
1244     scan.ssids = (HdfWifiDriverScanSsid *)OsalMemCalloc(sizeof(HdfWifiDriverScanSsid) * (scan.ssidsLen));
1245     scan.ssids[0].ssid = const_cast<char*>(ssid1.c_str());
1246     scan.ssids[0].ssidLen = ssid1.length();
1247     scan.freqsLen = 2;
1248     scan.freqs = (int32_t *)OsalMemCalloc(sizeof(int32_t) * (scan.freqsLen));
1249     scan.freqs[0] = 2412;
1250     scan.freqs[1] = 2447;
1251     scan.bssidLen = 6;
1252     scan.bssid = (uint8_t *)OsalMemCalloc(sizeof(uint8_t) * (scan.bssidLen));
1253     scan.bssid[0] = 0x12;
1254     scan.bssid[1] = 0x34;
1255     scan.bssid[2] = 0x56;
1256     scan.bssid[3] = 0x78;
1257     scan.bssid[4] = 0x9A;
1258     scan.bssid[5] = 0xBC;
1259 
1260     rc = g_wlanObj->CreateFeature(g_wlanObj, wlanType, &ifeature);
1261     if (rc == HDF_SUCCESS) {
1262         rc = g_wlanObj->StartScan(g_wlanObj, &ifeature, &scan);
1263         ASSERT_EQ(rc, HDF_SUCCESS);
1264         rc = g_wlanObj->DestroyFeature(g_wlanObj, &ifeature);
1265         ASSERT_EQ(rc, HDF_SUCCESS);
1266         sleep(SCAN_TIME);
1267     }
1268     OsalMemFree(scan.bssid);
1269     OsalMemFree(scan.freqs);
1270     OsalMemFree(scan.ssids);
1271 }
1272 };
1273