• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 <benchmark/benchmark.h>
16 #include <string>
17 #include <vector>
18 
19 #include <gtest/gtest.h>
20 #include <osal_mem.h>
21 #include "hdf_base.h"
22 #include "hdf_sbuf.h"
23 #include "wifi_hal.h"
24 #include "wifi_hal_ap_feature.h"
25 #include "wifi_hal_base_feature.h"
26 #include "wifi_hal_sta_feature.h"
27 #include "securec.h"
28 #include <servmgr_hdi.h>
29 #include "v1_3/iwlan_interface.h"
30 #include "wlan_impl.h"
31 
32 using namespace std;
33 using namespace testing::ext;
34 
35 namespace  {
36 struct IWiFi *g_wifi = nullptr;
37 const int32_t WLAN_TX_POWER = 160;
38 const uint32_t WLAN_MIN_CHIPID = 0;
39 const uint32_t WLAN_MAX_CHIPID = 2;
40 const uint32_t IFNAME_MIN_NUM = 0;
41 const uint32_t IFNAME_MAX_NUM = 32;
42 const uint32_t MAX_IF_NAME_LENGTH = 16;
43 const uint32_t SIZE = 4;
44 const int32_t WLAN_BAND_2G = 0;
45 const int32_t WLAN_MAX_NUM_STA_WITH_AP = 4;
46 const uint32_t TEST_BUF_SIZE = 64;
47 const uint32_t TEST_PARAM_BUF_SIZE = 64;
48 const int32_t TEST_CMD = 123;
49 const uint32_t RESET_TIME = 20;
50 const int32_t WLAN_FREQ_MAX_NUM = 35;
51 const int32_t DEFAULT_COMBO_SIZE = 6;
52 const uint32_t MEAS_CHANNEL_TIME = 10;
53 
54 static struct IWlanInterface *g_wlanObj = nullptr;
55 class wlanBenchmarkTest : public benchmark::Fixture {
56 public:
57     void SetUp(const ::benchmark::State &state);
58     void TearDown(const ::benchmark::State &state);
59 };
60 
SetUp(const::benchmark::State & state)61 void wlanBenchmarkTest::SetUp(const ::benchmark::State &state)
62 {
63     int ret = WifiConstruct(&g_wifi);
64     ASSERT_EQ(HDF_SUCCESS, ret);
65 }
66 
TearDown(const::benchmark::State & state)67 void wlanBenchmarkTest::TearDown(const ::benchmark::State &state)
68 {
69     int ret = WifiDestruct(&g_wifi);
70     ASSERT_EQ(HDF_SUCCESS, ret);
71 }
72 
ParseScanResult(WifiScanResult * scanResult)73 static void ParseScanResult(WifiScanResult *scanResult)
74 {
75     printf("ParseScanResult: flags=%d, caps=%d, freq=%d, beaconInt=%d,\n",
76         scanResult->flags, scanResult->caps, scanResult->freq, scanResult->beaconInt);
77     printf("ParseScanResult: qual=%d, beaconIeLen=%d, level=%d, age=%d, ieLen=%d,\n",
78         scanResult->qual, scanResult->beaconIeLen, scanResult->level, scanResult->age, scanResult->ieLen);
79 }
80 
HalCallbackEvent(uint32_t event,void * respData,const char * ifName)81 static int32_t HalCallbackEvent(uint32_t event, void *respData, const char *ifName)
82 {
83     (void)event;
84     if (respData == nullptr) {
85         return HDF_FAILURE;
86     }
87     printf("HalCallbackEvent ifName = %s, event = %u\n", ifName, event);
88     switch (event) {
89         case WIFI_EVENT_SCAN_DONE:
90             printf("HalCallbackEvent WIFI_EVENT_SCAN_DONE Process\n");
91             break;
92         case WIFI_EVENT_SCAN_RESULT:
93             ParseScanResult((WifiScanResult *)respData);
94             break;
95         default:
96             break;
97     }
98     return HDF_SUCCESS;
99 }
100 
101 /**
102  * @tc.name:wifiHalstartandstop001
103  * @tc.desc: Wifi hal start and stop
104  * @tc.type: FUNC
105  */
106 
BENCHMARK_F(wlanBenchmarkTest,wifiHalstartandstop001)107 BENCHMARK_F(wlanBenchmarkTest, wifiHalstartandstop001)(
108     benchmark::State &st)
109 {
110     for (auto _ : st) {
111         g_wifi->start(g_wifi);
112         g_wifi->stop(g_wifi);
113     }
114 }
115 
116 BENCHMARK_REGISTER_F(wlanBenchmarkTest, wifiHalstartandstop001)->Iterations(100)->
117     Repetitions(3)->ReportAggregatesOnly();
118 
119 /**
120  * @tc.name:wifiHalstartScan001
121  * @tc.desc: Wifi startscan
122  * @tc.type: FUNC
123  */
124 
BENCHMARK_F(wlanBenchmarkTest,wifiHalstartScan001)125 BENCHMARK_F(wlanBenchmarkTest, wifiHalstartScan001)(
126     benchmark::State &st)
127 {
128     g_wifi->start(g_wifi);
129     int ret;
130     struct IWiFiSta *staFeature = nullptr;
131     const char *ifName = "wlan0";
132     WifiScan scan = {0};
133 
134     ret = g_wifi->registerEventCallback(HalCallbackEvent, ifName);
135     EXPECT_EQ(HDF_SUCCESS, ret);
136     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_STATION, (struct IWiFiBaseFeature **)&staFeature);
137     EXPECT_EQ(HDF_SUCCESS, ret);
138     EXPECT_NE(nullptr, staFeature);
139     for (auto _ : st) {
140     ret = staFeature->startScan(nullptr, &scan);
141     }
142     EXPECT_NE(ret, HDF_SUCCESS);
143     sleep(10);
144     g_wifi->stop(g_wifi);
145 }
146 
147 BENCHMARK_REGISTER_F(wlanBenchmarkTest, wifiHalstartScan001)->Iterations(100)->
148     Repetitions(3)->ReportAggregatesOnly();
149 
150 /**
151  * @tc.name:wifiHalStartChannelMeas001
152  * @tc.desc: Wifi hal StartChannelMeas
153  * @tc.type: FUNC
154  */
155 
BENCHMARK_F(wlanBenchmarkTest,wifiHalStartChannelMeas001)156 BENCHMARK_F(wlanBenchmarkTest, wifiHalStartChannelMeas001)(
157     benchmark::State &st)
158 {
159     int32_t rc = g_wlanObj->Start(g_wlanObj);
160     ASSERT_EQ(rc, HDF_SUCCESS);
161     const char *ifName = "wlan0";
162     struct MeasChannelParam measChannelParam;
163     struct MeasChannelResult measChannelResult = {0};
164 
165     measChannelParam.channelId = 1;
166     measChannelParam.measTime = 15;
167     rc = g_wlanObj->StartChannelMeas(g_wlanObj, ifName, &measChannelParam);
168     bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT);
169     ASSERT_TRUE(flag);
170     sleep(MEAS_CHANNEL_TIME);
171     for (auto _ : st) {
172     rc = g_wlanObj->GetChannelMeasResult(g_wlanObj, ifName, &measChannelResult);
173     }
174     flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT || rc == HDF_DEV_ERR_NODATA);
175     ASSERT_TRUE(flag);
176     rc = g_wlanObj->Stop(g_wlanObj);
177     ASSERT_EQ(rc, HDF_SUCCESS);
178 }
179 
180 BENCHMARK_REGISTER_F(wlanBenchmarkTest, wifiHalStartChannelMeas001)->Iterations(100)->
181     Repetitions(3)->ReportAggregatesOnly();
182 
183 /**
184  * @tc.name:wifiHalGetChannelMeasResult001
185  * @tc.desc: Wifi hal StartChannelMeas
186  * @tc.type: FUNC
187  */
188 
BENCHMARK_F(wlanBenchmarkTest,wifiHalGetChannelMeasResult001)189 BENCHMARK_F(wlanBenchmarkTest, wifiHalGetChannelMeasResult001)(
190     benchmark::State &st)
191 {
192     int32_t rc = g_wlanObj->Start(g_wlanObj);
193     ASSERT_EQ(rc, HDF_SUCCESS);
194     const char *ifName = "wlan0";
195     struct MeasChannelParam measChannelParam;
196     struct MeasChannelResult measChannelResult = {0};
197 
198     measChannelParam.channelId = 1;
199     measChannelParam.measTime = 15;
200     rc = g_wlanObj->StartChannelMeas(g_wlanObj, ifName, &measChannelParam);
201     bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT);
202     ASSERT_TRUE(flag);
203     sleep(MEAS_CHANNEL_TIME);
204     for (auto _ : st) {
205     rc = g_wlanObj->GetChannelMeasResult(g_wlanObj, ifName, &measChannelResult);
206     }
207     flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT || rc == HDF_DEV_ERR_NODATA);
208     ASSERT_TRUE(flag);
209     rc = g_wlanObj->Stop(g_wlanObj);
210     ASSERT_EQ(rc, HDF_SUCCESS);
211 }
212 
213 BENCHMARK_REGISTER_F(wlanBenchmarkTest, wifiHalGetChannelMeasResult001)->Iterations(100)->
214     Repetitions(3)->ReportAggregatesOnly();
215 
216 /**
217  * @tc.name:wifiHalcreateFeaturete001
218  * @tc.desc: Wifi hal create and destroy feature for ap mode benchmark test
219  * @tc.type: FUNC
220  */
221 
BENCHMARK_F(wlanBenchmarkTest,wifiHalcreateFeaturete001)222 BENCHMARK_F(wlanBenchmarkTest, wifiHalcreateFeaturete001)(
223     benchmark::State &st)
224 {
225     g_wifi->start(g_wifi);
226     int ret;
227     struct IWiFiAp *apFeature = nullptr;
228     for (auto _ : st) {
229         ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
230         g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
231     }
232     EXPECT_EQ(HDF_SUCCESS, ret);
233     g_wifi->stop(g_wifi);
234 }
235 
236 BENCHMARK_REGISTER_F(wlanBenchmarkTest, wifiHalcreateFeaturete001)->Iterations(100)->
237     Repetitions(3)->ReportAggregatesOnly();
238 
239 /**
240  * @tc.name:wifiHalcreateFeaturete002
241  * @tc.desc: Wifi hal create and destroy feature for sta mode benchmark test
242  * @tc.type: FUNC
243  */
244 
BENCHMARK_F(wlanBenchmarkTest,wifiHalcreateFeaturete002)245 BENCHMARK_F(wlanBenchmarkTest, wifiHalcreateFeaturete002)(
246     benchmark::State &st)
247 {
248     g_wifi->start(g_wifi);
249     int ret;
250     struct IWiFiSta *staFeature = nullptr;
251     for (auto _ : st) {
252         g_wifi->createFeature(PROTOCOL_80211_IFTYPE_STATION, (struct IWiFiBaseFeature **)&staFeature);
253         ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)staFeature);
254     }
255     EXPECT_EQ(HDF_SUCCESS, ret);
256     g_wifi->stop(g_wifi);
257 }
258 
259 BENCHMARK_REGISTER_F(wlanBenchmarkTest, wifiHalcreateFeaturete002)->Iterations(100)->
260     Repetitions(3)->ReportAggregatesOnly();
261 
262 /**
263  * @tc.name: WifiHalGetFeatureByIfName001
264  * @tc.desc: Wifi hal get feature by ifname benchmark test
265  * @tc.type: FUNC
266  */
267 
BENCHMARK_F(wlanBenchmarkTest,wifiHalGetFeatureByIfName001)268 BENCHMARK_F(wlanBenchmarkTest, wifiHalGetFeatureByIfName001)(
269     benchmark::State &st)
270 {
271     g_wifi->start(g_wifi);
272     int ret;
273     struct IWiFiAp *apFeature = nullptr;
274     struct IWiFiAp *apFeatureGet = nullptr;
275     const char *ifName0 = "wlanTest";
276     const char *ifName1 = "wlan0";
277     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
278     EXPECT_EQ(HDF_SUCCESS, ret);
279     EXPECT_NE(nullptr, apFeature);
280     ret = g_wifi->getFeatureByIfName(ifName0, (struct IWiFiBaseFeature **)&apFeatureGet);
281     EXPECT_NE(HDF_SUCCESS, ret);
282     for (auto _ : st) {
283         ret = g_wifi->getFeatureByIfName(ifName1, (struct IWiFiBaseFeature **)&apFeatureGet);
284     }
285     EXPECT_EQ(HDF_SUCCESS, ret);
286     EXPECT_NE(nullptr, apFeatureGet);
287     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
288     EXPECT_EQ(HDF_SUCCESS, ret);
289     g_wifi->stop(g_wifi);
290 }
291 
292 BENCHMARK_REGISTER_F(wlanBenchmarkTest, wifiHalGetFeatureByIfName001)->Iterations(100)->
293     Repetitions(3)->ReportAggregatesOnly();
294 
295 /**
296  * @tc.name: WifiHalRegisterEventCallback001
297  * @tc.desc: Wifi hal register callback benchmark test
298  * @tc.type: FUNC
299  */
300 
BENCHMARK_F(wlanBenchmarkTest,wifiHalregisterEventCallback001)301 BENCHMARK_F(wlanBenchmarkTest, wifiHalregisterEventCallback001)(
302     benchmark::State &st)
303 {
304     g_wifi->start(g_wifi);
305     int ret;
306     for (auto _ : st) {
307         ret = g_wifi->registerEventCallback(HalCallbackEvent, "wlan0");
308     }
309     EXPECT_EQ(HDF_SUCCESS, ret);
310     g_wifi->stop(g_wifi);
311 }
312 
313 BENCHMARK_REGISTER_F(wlanBenchmarkTest, wifiHalregisterEventCallback001)->Iterations(100)->
314     Repetitions(3)->ReportAggregatesOnly();
315 
316 /**
317  * @tc.name: WifiHalUnRegisterEventCallback001
318  * @tc.desc: Wifi hal unregister callback benchmark test
319  * @tc.type: FUNC
320  */
321 
BENCHMARK_F(wlanBenchmarkTest,wifiHalunregisterEventCallback001)322 BENCHMARK_F(wlanBenchmarkTest, wifiHalunregisterEventCallback001)(
323     benchmark::State &st)
324 {
325     g_wifi->start(g_wifi);
326     int ret;
327     for (auto _ : st) {
328         ret = g_wifi->unregisterEventCallback(HalCallbackEvent, "wlan0");
329     }
330     EXPECT_EQ(HDF_SUCCESS, ret);
331     g_wifi->stop(g_wifi);
332 }
333 
334 BENCHMARK_REGISTER_F(wlanBenchmarkTest, wifiHalunregisterEventCallback001)->Iterations(100)->
335     Repetitions(3)->ReportAggregatesOnly();
336 
337 /**
338  * @tc.name: WifiHalGetNetworkIfaceName001
339  * @tc.desc: Wifi hal get network iface name benchmark test
340  * @tc.type: FUNC
341  */
342 
BENCHMARK_F(wlanBenchmarkTest,WifiHalgetNetworkIfaceName001)343 BENCHMARK_F(wlanBenchmarkTest, WifiHalgetNetworkIfaceName001)(
344     benchmark::State &st)
345 {
346     g_wifi->start(g_wifi);
347     int ret;
348     const char *ifName=nullptr;
349     struct IWiFiAp *apFeature = nullptr;
350     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
351     EXPECT_EQ(HDF_SUCCESS, ret);
352     EXPECT_NE(nullptr, apFeature);
353     for (auto _ : st) {
354         ifName = apFeature->baseFeature.getNetworkIfaceName((const struct IWiFiBaseFeature *)apFeature);
355     }
356     EXPECT_NE(nullptr, ifName);
357     ret = strcmp(ifName, "wlan0");
358     EXPECT_EQ(0, ret);
359     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
360     EXPECT_EQ(HDF_SUCCESS, ret);
361     g_wifi->stop(g_wifi);
362 }
363 
364 BENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetNetworkIfaceName001)->Iterations(100)->
365     Repetitions(3)->ReportAggregatesOnly();
366 
367 /**
368  * @tc.name: WifiHalGetGetFeatureType001
369  * @tc.desc: Wifi hal get feature type benchmark test
370  * @tc.type: FUNC
371  */
372 
BENCHMARK_F(wlanBenchmarkTest,WifiHalgetFeatureType001)373 BENCHMARK_F(wlanBenchmarkTest, WifiHalgetFeatureType001)(
374     benchmark::State &st)
375 {
376     g_wifi->start(g_wifi);
377     int ret;
378     struct IWiFiAp *apFeature = nullptr;
379     int32_t type;
380     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
381     EXPECT_EQ(HDF_SUCCESS, ret);
382     EXPECT_NE(nullptr, apFeature);
383     for (auto _ : st) {
384         type = apFeature->baseFeature.getFeatureType((struct IWiFiBaseFeature *)apFeature);
385     }
386     EXPECT_EQ(PROTOCOL_80211_IFTYPE_AP, type);
387     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
388     EXPECT_EQ(HDF_SUCCESS, ret);
389     g_wifi->stop(g_wifi);
390 }
391 
392 BENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetFeatureType001)->Iterations(100)->
393     Repetitions(3)->ReportAggregatesOnly();
394 
395  /**
396  * @tc.name: WifiHalSetMacAddress001
397  * @tc.desc: Wifi hal set Mac address benchmark test
398  * @tc.type: FUNC
399  */
400 
BENCHMARK_F(wlanBenchmarkTest,WifiHalsetMacAddress001)401 BENCHMARK_F(wlanBenchmarkTest, WifiHalsetMacAddress001)(
402     benchmark::State &st)
403 {
404     g_wifi->start(g_wifi);
405     int ret;
406     struct IWiFiAp *apFeature = nullptr;
407     unsigned char errorMac[ETH_ADDR_LEN] = {0x11, 0x34, 0x56, 0x78, 0xab, 0xcd};
408     unsigned char mac[ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd};
409     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
410     EXPECT_EQ(HDF_SUCCESS, ret);
411     EXPECT_NE(nullptr, apFeature);
412     ret = apFeature->baseFeature.setMacAddress((struct IWiFiBaseFeature *)apFeature, nullptr, 0);
413     EXPECT_NE(HDF_SUCCESS, ret);
414     ret = apFeature->baseFeature.setMacAddress((struct IWiFiBaseFeature *)apFeature, errorMac, ETH_ADDR_LEN);
415     EXPECT_NE(HDF_SUCCESS, ret);
416     for (auto _ : st) {
417         ret = apFeature->baseFeature.setMacAddress((struct IWiFiBaseFeature *)apFeature, mac, ETH_ADDR_LEN);
418     }
419     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
420     EXPECT_EQ(HDF_SUCCESS, ret);
421     g_wifi->stop(g_wifi);
422 }
423 
424 BENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalsetMacAddress001)->Iterations(100)->
425     Repetitions(3)->ReportAggregatesOnly();
426 
427 /**
428  * @tc.name: WifiHalSetMacAddress002
429  * @tc.desc: Wifi hal set Mac address benchmark test
430  * @tc.type: FUNC
431  */
432 
BENCHMARK_F(wlanBenchmarkTest,WifiHalsetMacAddress002)433 BENCHMARK_F(wlanBenchmarkTest, WifiHalsetMacAddress002)(
434     benchmark::State &st)
435 {
436     g_wifi->start(g_wifi);
437     int ret;
438     struct IWiFiSta *staFeature = nullptr;
439     unsigned char errorMac[ETH_ADDR_LEN] = {0};
440     unsigned char mac[ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd};
441     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_STATION, (struct IWiFiBaseFeature **)&staFeature);
442     EXPECT_EQ(HDF_SUCCESS, ret);
443     EXPECT_NE(nullptr, staFeature);
444     ret = staFeature->baseFeature.setMacAddress((struct IWiFiBaseFeature *)staFeature, nullptr, 0);
445     EXPECT_NE(HDF_SUCCESS, ret);
446     ret = staFeature->baseFeature.setMacAddress((struct IWiFiBaseFeature *)staFeature, errorMac, ETH_ADDR_LEN);
447     EXPECT_NE(HDF_SUCCESS, ret);
448     for (auto _ : st) {
449         ret = staFeature->baseFeature.setMacAddress((struct IWiFiBaseFeature *)staFeature, mac, ETH_ADDR_LEN);
450     }
451     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)staFeature);
452     EXPECT_EQ(HDF_SUCCESS, ret);
453     g_wifi->stop(g_wifi);
454 }
455 
456 BENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalsetMacAddress002)->Iterations(100)->
457     Repetitions(3)->ReportAggregatesOnly();
458 
459 /**
460  * @tc.name: WifiHalSetTxPower001
461  * @tc.desc: Wifi hal set transmit power benchmark test
462  * @tc.type: FUNC
463  */
464 
BENCHMARK_F(wlanBenchmarkTest,WifiHalsetTxPower001)465 BENCHMARK_F(wlanBenchmarkTest, WifiHalsetTxPower001)(
466     benchmark::State &st)
467 {
468     g_wifi->start(g_wifi);
469     int ret;
470     struct IWiFiAp *apFeature = nullptr;
471     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
472     EXPECT_EQ(HDF_SUCCESS, ret);
473     EXPECT_NE(nullptr, apFeature);
474     ret = apFeature->baseFeature.setTxPower((struct IWiFiBaseFeature *)apFeature, 0);
475     EXPECT_NE(HDF_SUCCESS, ret);
476     for (auto _ : st) {
477         ret = apFeature->baseFeature.setTxPower((struct IWiFiBaseFeature *)apFeature, WLAN_TX_POWER);
478     }
479     EXPECT_EQ(HDF_SUCCESS, ret);
480     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
481     EXPECT_EQ(HDF_SUCCESS, ret);
482     g_wifi->stop(g_wifi);
483 }
484 
485 BENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalsetTxPower001)->Iterations(100)->
486     Repetitions(3)->ReportAggregatesOnly();
487 
488 /**
489  * @tc.name: WifiHalSetCountryCode001
490  * @tc.desc: Wifi hal set country code benchmark test
491  * @tc.type: FUNC
492  */
493 
BENCHMARK_F(wlanBenchmarkTest,WifiHalsetCountryCode001)494 BENCHMARK_F(wlanBenchmarkTest, WifiHalsetCountryCode001)(
495     benchmark::State &st)
496 {
497     g_wifi->start(g_wifi);
498     int ret;
499     struct IWiFiAp *apFeature = nullptr;
500     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
501     EXPECT_EQ(HDF_SUCCESS, ret);
502     EXPECT_NE(nullptr, apFeature);
503     ret = apFeature->setCountryCode(apFeature, nullptr, 0);
504     EXPECT_NE(HDF_SUCCESS, ret);
505     for (auto _ : st) {
506         ret = apFeature->setCountryCode(apFeature, "CN", 2);
507     }
508     EXPECT_EQ(HDF_SUCCESS, ret);
509     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
510     EXPECT_EQ(HDF_SUCCESS, ret);
511     g_wifi->stop(g_wifi);
512 }
513 
514 BENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalsetCountryCode001)->Iterations(100)->
515     Repetitions(3)->ReportAggregatesOnly();
516 
517 /**
518  * @tc.name: WifiHalGetIfNamesByChipId001
519  * @tc.desc: Obtain all ifNames and the number of the current chip
520  * @tc.type: FUNC
521  */
522 
BENCHMARK_F(wlanBenchmarkTest,WifiHalgetIfNamesByChipId001)523 BENCHMARK_F(wlanBenchmarkTest, WifiHalgetIfNamesByChipId001)(
524     benchmark::State &st)
525 {
526     g_wifi->start(g_wifi);
527     int ret;
528     struct IWiFiSta *staFeature = nullptr;
529     char *ifNames = nullptr;
530     unsigned int num = 0;
531     unsigned char chipId = 0;
532     uint8_t i;
533     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_STATION, (struct IWiFiBaseFeature **)&staFeature);
534     EXPECT_EQ(HDF_SUCCESS, ret);
535     EXPECT_NE(nullptr, staFeature);
536     ret = staFeature->baseFeature.getChipId((struct IWiFiBaseFeature *)staFeature, &chipId);
537     ASSERT_TRUE(chipId <= WLAN_MAX_CHIPID && chipId >= WLAN_MIN_CHIPID);
538     EXPECT_EQ(HDF_SUCCESS, ret);
539     ret = staFeature->baseFeature.getIfNamesByChipId(chipId, nullptr, nullptr);
540     EXPECT_NE(HDF_SUCCESS, ret);
541     for (auto _ : st) {
542         ret = staFeature->baseFeature.getIfNamesByChipId(chipId, &ifNames, &num);
543     }
544     EXPECT_NE(nullptr, ifNames);
545     EXPECT_EQ(HDF_SUCCESS, ret);
546     ASSERT_TRUE(num <= IFNAME_MAX_NUM && num >= IFNAME_MIN_NUM);
547     for (i = 0; i < num; i++) {
548         EXPECT_EQ(0, strncmp("wlan", ifNames + i * MAX_IF_NAME_LENGTH, SIZE));
549     }
550     free(ifNames);
551     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)staFeature);
552     EXPECT_EQ(HDF_SUCCESS, ret);
553     g_wifi->stop(g_wifi);
554 }
555 
556 BENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetIfNamesByChipId001)->Iterations(100)->
557     Repetitions(3)->ReportAggregatesOnly();
558 
559 /**
560  * @tc.name: WifiHalGetSupportFeature001
561  * @tc.desc: Get supported features
562  * @tc.type: FUNC
563  */
564 
BENCHMARK_F(wlanBenchmarkTest,WifiHalgetSupportFeature001)565 BENCHMARK_F(wlanBenchmarkTest, WifiHalgetSupportFeature001)(
566     benchmark::State &st)
567 {
568     g_wifi->start(g_wifi);
569     int ret;
570     uint8_t supportTest[PROTOCOL_80211_IFTYPE_NUM] = {0};
571     uint8_t support[PROTOCOL_80211_IFTYPE_NUM + 1] = {0};
572     ret = g_wifi->getSupportFeature(nullptr, 0);
573     EXPECT_NE(HDF_SUCCESS, ret);
574     ret = g_wifi->getSupportFeature(supportTest, PROTOCOL_80211_IFTYPE_NUM);
575     EXPECT_NE(HDF_SUCCESS, ret);
576     for (auto _ : st) {
577         ret = g_wifi->getSupportFeature(support, PROTOCOL_80211_IFTYPE_NUM + 1);
578     }
579     EXPECT_EQ(HDF_SUCCESS, ret);
580     g_wifi->stop(g_wifi);
581 }
582 
583 BENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetSupportFeature001)->Iterations(100)->
584     Repetitions(3)->ReportAggregatesOnly();
585 
586 /**
587  * @tc.name: WifiHalGetSupportCombo001
588  * @tc.desc: Get supported combo
589  * @tc.type: FUNC
590  */
591 
BENCHMARK_F(wlanBenchmarkTest,WifiHalgetSupportCombo001)592 BENCHMARK_F(wlanBenchmarkTest, WifiHalgetSupportCombo001)(
593     benchmark::State &st)
594 {
595     g_wifi->start(g_wifi);
596     int ret;
597     uint8_t support[PROTOCOL_80211_IFTYPE_NUM + 1] = {0};
598     uint64_t combo[DEFAULT_COMBO_SIZE] = {0};
599     ret = g_wifi->getSupportFeature(support, PROTOCOL_80211_IFTYPE_NUM + 1);
600     EXPECT_EQ(HDF_SUCCESS, ret);
601     for (auto _ : st) {
602         ret = g_wifi->getSupportCombo(nullptr, 0);
603     }
604     EXPECT_NE(HDF_SUCCESS, ret);
605     ret = g_wifi->getSupportCombo(combo, DEFAULT_COMBO_SIZE);
606     if (support[PROTOCOL_80211_IFTYPE_NUM] == 0) {
607         EXPECT_EQ(HDF_ERR_NOT_SUPPORT, ret);
608     } else {
609         EXPECT_EQ(HDF_SUCCESS, ret);
610     }
611     g_wifi->stop(g_wifi);
612 }
613 
614 BENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetSupportCombo001)->Iterations(100)->
615     Repetitions(3)->ReportAggregatesOnly();
616 
617 /**
618  * @tc.name: WifiHalGetDeviceMacAddress001
619  * @tc.desc: Get device Mac address for ap mode
620  * @tc.type: FUNC
621  */
622 
BENCHMARK_F(wlanBenchmarkTest,WifiHalgetDeviceMacAddress001)623 BENCHMARK_F(wlanBenchmarkTest, WifiHalgetDeviceMacAddress001)(
624     benchmark::State &st)
625 {
626     g_wifi->start(g_wifi);
627     int ret;
628     struct IWiFiAp *apFeature = nullptr;
629     unsigned char mac[ETH_ADDR_LEN] = {0};
630     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
631     EXPECT_EQ(HDF_SUCCESS, ret);
632     EXPECT_NE(nullptr, apFeature);
633     ret = apFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)apFeature, nullptr, 0);
634     EXPECT_NE(HDF_SUCCESS, ret);
635     ret = apFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)apFeature, mac, ETH_ADDR_LEN - 1);
636     EXPECT_NE(HDF_SUCCESS, ret);
637     for (auto _ : st) {
638         ret = apFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)apFeature, mac, ETH_ADDR_LEN);
639     }
640     EXPECT_NE(HDF_FAILURE, ret);
641     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
642     EXPECT_EQ(HDF_SUCCESS, ret);
643     g_wifi->stop(g_wifi);
644 }
645 
646 BENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetDeviceMacAddress001)->Iterations(100)->
647     Repetitions(3)->ReportAggregatesOnly();
648 
649 /**
650  * @tc.name: WifiHalGetDeviceMacAddress002
651  * @tc.desc: Get device Mac address for sta mode
652  * @tc.type: FUNC
653  */
654 
BENCHMARK_F(wlanBenchmarkTest,WifiHalgetDeviceMacAddress002)655 BENCHMARK_F(wlanBenchmarkTest, WifiHalgetDeviceMacAddress002)(
656     benchmark::State &st)
657 {
658     g_wifi->start(g_wifi);
659     int ret;
660     struct IWiFiSta *staFeature = nullptr;
661     unsigned char mac[ETH_ADDR_LEN] = {0};
662     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_STATION, (struct IWiFiBaseFeature **)&staFeature);
663     EXPECT_EQ(HDF_SUCCESS, ret);
664     EXPECT_NE(nullptr, staFeature);
665     ret = staFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)staFeature, nullptr, 0);
666     EXPECT_NE(HDF_SUCCESS, ret);
667     ret = staFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)staFeature, mac, ETH_ADDR_LEN - 1);
668     EXPECT_NE(HDF_SUCCESS, ret);
669     for (auto _ : st) {
670         ret = staFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)staFeature, mac, ETH_ADDR_LEN);
671     }
672     EXPECT_NE(HDF_FAILURE, ret);
673     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)staFeature);
674     EXPECT_EQ(HDF_SUCCESS, ret);
675     g_wifi->stop(g_wifi);
676 }
677 
678 BENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetDeviceMacAddress002)->Iterations(100)->
679     Repetitions(3)->ReportAggregatesOnly();
680 
681 /**
682  * @tc.name: WifiHaGetValidFreqsWithBand001
683  * @tc.desc: Get available frequencies
684  * @tc.type: FUNC
685  */
686 
BENCHMARK_F(wlanBenchmarkTest,WifiHalgetValidFreqsWithBand001)687 BENCHMARK_F(wlanBenchmarkTest, WifiHalgetValidFreqsWithBand001)(
688     benchmark::State &st)
689 {
690     g_wifi->start(g_wifi);
691     int ret;
692     struct IWiFiAp *apFeature = nullptr;
693     int32_t freq[WLAN_FREQ_MAX_NUM] = {0};
694     uint32_t num = 0;
695     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
696     EXPECT_EQ(HDF_SUCCESS, ret);
697     EXPECT_NE(nullptr, apFeature);
698     ret = apFeature->baseFeature.getValidFreqsWithBand((struct IWiFiBaseFeature *)apFeature,
699     WLAN_BAND_2G, nullptr, 0, nullptr);
700     EXPECT_NE(HDF_SUCCESS, ret);
701     for (auto _ : st) {
702         ret = apFeature->baseFeature.getValidFreqsWithBand((struct IWiFiBaseFeature *)apFeature,
703             WLAN_BAND_2G, freq, WLAN_FREQ_MAX_NUM, &num);
704     }
705     EXPECT_EQ(HDF_SUCCESS, ret);
706     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
707     EXPECT_EQ(HDF_SUCCESS, ret);
708     g_wifi->stop(g_wifi);
709 }
710 
711 BENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetValidFreqsWithBand001)->Iterations(100)->
712     Repetitions(3)->ReportAggregatesOnly();
713 
714 /**
715  * @tc.name: WifiHalGetAssociatedStas001
716  * @tc.desc: Get asscociated STA info benchmark test
717  * @tc.type: FUNC
718  */
719 
BENCHMARK_F(wlanBenchmarkTest,WifiHalgetAssociatedStas001)720 BENCHMARK_F(wlanBenchmarkTest, WifiHalgetAssociatedStas001)(
721     benchmark::State &st)
722 {
723     g_wifi->start(g_wifi);
724     int ret;
725     struct IWiFiAp *apFeature = nullptr;
726     struct StaInfo staInfo[WLAN_MAX_NUM_STA_WITH_AP] = {{0}};
727     uint32_t num = 0;
728     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
729     EXPECT_EQ(HDF_SUCCESS, ret);
730     EXPECT_NE(nullptr, apFeature);
731     ret = apFeature->getAssociatedStas(apFeature, nullptr, 0, nullptr);
732     EXPECT_NE(HDF_SUCCESS, ret);
733     for (auto _ : st) {
734         ret = apFeature->getAssociatedStas(apFeature, staInfo, WLAN_MAX_NUM_STA_WITH_AP, &num);
735     }
736     EXPECT_EQ(HDF_SUCCESS, ret);
737     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
738     EXPECT_EQ(HDF_SUCCESS, ret);
739     g_wifi->stop(g_wifi);
740 }
741 
742 BENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetAssociatedStas001)->Iterations(100)->
743     Repetitions(3)->ReportAggregatesOnly();
744 
745 /**
746  * @tc.name: WifiHalSetScanningMacAddress001
747  * @tc.desc: Set Mac address scanning benchmark test
748  * @tc.type: FUNC
749  */
750 
BENCHMARK_F(wlanBenchmarkTest,WifiHalsetScanningMacAddress001)751 BENCHMARK_F(wlanBenchmarkTest, WifiHalsetScanningMacAddress001)(
752     benchmark::State &st)
753 {
754     g_wifi->start(g_wifi);
755     int ret;
756     struct IWiFiSta *staFeature = nullptr;
757     unsigned char scanMac[ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd};
758     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_STATION, (struct IWiFiBaseFeature **)&staFeature);
759     EXPECT_EQ(HDF_SUCCESS, ret);
760     EXPECT_NE(nullptr, staFeature);
761     ret = staFeature->setScanningMacAddress(staFeature, nullptr, 0);
762     EXPECT_NE(HDF_SUCCESS, ret);
763     for (auto _ : st) {
764         ret = staFeature->setScanningMacAddress(staFeature, scanMac, ETH_ADDR_LEN);
765     }
766     EXPECT_EQ(HDF_ERR_NOT_SUPPORT, ret);
767     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)staFeature);
768     EXPECT_EQ(HDF_SUCCESS, ret);
769     g_wifi->stop(g_wifi);
770 }
771 
772 BENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalsetScanningMacAddress001)->Iterations(100)->
773     Repetitions(3)->ReportAggregatesOnly();
774 
775 /**
776  * @tc.name: WifiHalGetNetdevInfo001
777  * @tc.desc: Wifi hdi get netdev info benchmark test
778  * @tc.type: FUNC
779  */
780 
BENCHMARK_F(wlanBenchmarkTest,WifiHalgetNetDevInfo001)781 BENCHMARK_F(wlanBenchmarkTest, WifiHalgetNetDevInfo001)(
782     benchmark::State &st)
783 {
784     g_wifi->start(g_wifi);
785     int ret;
786     struct NetDeviceInfoResult netDeviceInfoResult;
787     (void)memset_s(&netDeviceInfoResult, sizeof(struct NetDeviceInfoResult), 0, sizeof(struct NetDeviceInfoResult));
788     for (auto _ : st) {
789         ret = g_wifi->getNetDevInfo(&netDeviceInfoResult);
790     }
791     EXPECT_EQ(ret, HDF_SUCCESS);
792     g_wifi->stop(g_wifi);
793 }
794 
795 BENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetNetDevInfo001)->Iterations(100)->
796     Repetitions(3)->ReportAggregatesOnly();
797 
798 
799 /**
800  * @tc.name: GetPowerModeTest001
801  * @tc.desc: Wifi hdi get power mode function test
802  * @tc.type: FUNC
803  */
804 
BENCHMARK_F(wlanBenchmarkTest,GetPowerMode001)805 BENCHMARK_F(wlanBenchmarkTest, GetPowerMode001)(
806     benchmark::State &st)
807 {
808     g_wifi->start(g_wifi);
809     int32_t ret;
810     struct IWiFiAp *apFeature = nullptr;
811     const char *ifName = "eth0";
812     uint8_t mode;
813 
814     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
815     EXPECT_EQ(ret, HDF_SUCCESS);
816     EXPECT_NE(apFeature, nullptr);
817     for (auto _ : st) {
818         ret = g_wifi->getPowerMode(nullptr, &mode);
819     }
820     EXPECT_NE(ret, HDF_SUCCESS);
821     ret = g_wifi->getPowerMode(ifName, nullptr);
822     EXPECT_NE(ret, HDF_SUCCESS);
823     ret = g_wifi->getPowerMode(ifName, &mode);
824     EXPECT_NE(ret, HDF_SUCCESS);
825     ret = g_wifi->getPowerMode(apFeature->baseFeature.ifName, nullptr);
826     EXPECT_NE(ret, HDF_SUCCESS);
827     ret = g_wifi->getPowerMode(apFeature->baseFeature.ifName, &mode);
828     bool flag = (ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
829     ASSERT_TRUE(flag);
830     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
831     EXPECT_EQ(ret, HDF_SUCCESS);
832     g_wifi->stop(g_wifi);
833 }
834 
835 BENCHMARK_REGISTER_F(wlanBenchmarkTest, GetPowerMode001)->Iterations(100)->
836     Repetitions(3)->ReportAggregatesOnly();
837 
838 /**
839  * @tc.name: SetPowerModeTest001
840  * @tc.desc: Wifi hdi set power mode function test
841  * @tc.type: FUNC
842  */
843 
BENCHMARK_F(wlanBenchmarkTest,SetPowerModeTest001)844 BENCHMARK_F(wlanBenchmarkTest, SetPowerModeTest001)(
845     benchmark::State &st)
846 {
847     g_wifi->start(g_wifi);
848     int32_t ret;
849     struct IWiFiAp *apFeature = nullptr;
850     const char *ifName = "eth0";
851 
852     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
853     EXPECT_EQ(ret, HDF_SUCCESS);
854     EXPECT_NE(apFeature, nullptr);
855     ret = g_wifi->setPowerMode(nullptr, WIFI_POWER_MODE_SLEEPING);
856     EXPECT_NE(ret, HDF_SUCCESS);
857     ret = g_wifi->setPowerMode(ifName, WIFI_POWER_MODE_SLEEPING);
858     EXPECT_NE(ret, HDF_SUCCESS);
859     for (auto _ : st) {
860         ret = g_wifi->setPowerMode(apFeature->baseFeature.ifName, WIFI_POWER_MODE_SLEEPING);
861     }
862     bool flag = (ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
863     ASSERT_TRUE(flag);
864     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
865     EXPECT_EQ(ret, HDF_SUCCESS);
866     g_wifi->stop(g_wifi);
867 }
868 
869 BENCHMARK_REGISTER_F(wlanBenchmarkTest, SetPowerModeTest001)->Iterations(100)->
870     Repetitions(3)->ReportAggregatesOnly();
871 
872 /**
873  * @tc.name: SetProjectionScreenParam001
874  * @tc.desc: wifi hal config projection screen function test
875  * @tc.type: FUNC
876  */
877 
BENCHMARK_F(wlanBenchmarkTest,SetProjectionScreenParam001)878 BENCHMARK_F(wlanBenchmarkTest, SetProjectionScreenParam001)(
879     benchmark::State &st)
880 {
881     g_wifi->start(g_wifi);
882     int32_t ret;
883     bool flag;
884     struct IWiFiAp *apFeature = nullptr;
885     ProjectionScreenParam *param;
886 
887     param = (ProjectionScreenParam *)OsalMemCalloc(sizeof(ProjectionScreenParam) + TEST_PARAM_BUF_SIZE);
888     EXPECT_NE(nullptr, param);
889     param->cmdId = TEST_CMD;
890     param->bufLen = 1;
891     param->buf[0] = 0;
892     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
893     EXPECT_EQ(ret, HDF_SUCCESS);
894     ret = g_wifi->setProjectionScreenParam(nullptr, nullptr);
895     EXPECT_NE(ret, HDF_SUCCESS);
896     ret = g_wifi->setProjectionScreenParam(apFeature->baseFeature.ifName, nullptr);
897     EXPECT_NE(ret, HDF_SUCCESS);
898     ret = g_wifi->setProjectionScreenParam(nullptr, param);
899     EXPECT_NE(ret, HDF_SUCCESS);
900     for (auto _ : st) {
901     ret = g_wifi->setProjectionScreenParam(apFeature->baseFeature.ifName, param);
902     }
903     EXPECT_NE(ret, HDF_SUCCESS);
904     for (int i = CMD_CLOSE_GO_CAC; i <= CMD_ID_CTRL_ROAM_CHANNEL; i++) {
905         param->cmdId = i;
906         ret = g_wifi->setProjectionScreenParam(apFeature->baseFeature.ifName, param);
907         flag = (ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
908         ASSERT_TRUE(flag);
909     }
910     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
911     EXPECT_EQ(ret, HDF_SUCCESS);
912     OsalMemFree(param);
913     g_wifi->stop(g_wifi);
914 }
915 
916 BENCHMARK_REGISTER_F(wlanBenchmarkTest, SetProjectionScreenParam001)->Iterations(100)->
917     Repetitions(3)->ReportAggregatesOnly();
918 
919 
920 /**
921  * @tc.name: SendCmdIoctl001
922  * @tc.desc: wifi hal send ioctl command function test
923  * @tc.type: FUNC
924  */
925 
BENCHMARK_F(wlanBenchmarkTest,SendCmdIoctl001)926 BENCHMARK_F(wlanBenchmarkTest, SendCmdIoctl001)(
927     benchmark::State &st)
928 {
929     g_wifi->start(g_wifi);
930     int32_t cmdId = 0;
931     int32_t ret;
932     bool flag;
933     struct IWiFiAp *apFeature = nullptr;
934     int8_t data[TEST_BUF_SIZE] = {0};
935     const char *ifName = "wlan0";
936 
937     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
938     EXPECT_EQ(ret, HDF_SUCCESS);
939     ret = g_wifi->sendCmdIoctl(nullptr, cmdId, nullptr, TEST_BUF_SIZE);
940     EXPECT_NE(ret, HDF_SUCCESS);
941     ret = g_wifi->sendCmdIoctl(ifName, cmdId, nullptr, TEST_BUF_SIZE);
942     EXPECT_NE(ret, HDF_SUCCESS);
943     for (auto _ : st) {
944         ret = g_wifi->sendCmdIoctl(nullptr, cmdId, data, TEST_BUF_SIZE);
945     }
946     EXPECT_NE(ret, HDF_SUCCESS);
947     for (cmdId = CMD_HID2D_MODULE_INIT; cmdId <= CMD_SET_CHAN_ADJUST; cmdId++) {
948         ret = g_wifi->sendCmdIoctl(ifName, cmdId, data, TEST_BUF_SIZE);
949         flag = (ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
950         ASSERT_TRUE(flag);
951     }
952     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
953     EXPECT_EQ(ret, HDF_SUCCESS);
954     g_wifi->stop(g_wifi);
955 }
956 
957 BENCHMARK_REGISTER_F(wlanBenchmarkTest, SendCmdIoctl001)->Iterations(100)->
958     Repetitions(3)->ReportAggregatesOnly();
959 
960 /**
961  * @tc.name: GetStationInfo001
962  * @tc.desc: Wifi hdi get station information function test
963  * @tc.type: FUNC
964  */
965 
BENCHMARK_F(wlanBenchmarkTest,GetStationInfo001)966 BENCHMARK_F(wlanBenchmarkTest, GetStationInfo001)(
967     benchmark::State &st)
968 {
969     g_wifi->start(g_wifi);
970     int32_t ret;
971     StationInfo info;
972     bool flag;
973     uint8_t mac[ETH_ADDR_LEN] = {0};
974     struct IWiFiAp *apFeature = nullptr;
975     const char *ifName = "wlan0";
976 
977     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
978     EXPECT_EQ(ret, HDF_SUCCESS);
979     ret = g_wifi->getStationInfo(nullptr, nullptr, nullptr, ETH_ADDR_LEN);
980     EXPECT_NE(ret, HDF_SUCCESS);
981     ret = g_wifi->getStationInfo(ifName, nullptr, nullptr, ETH_ADDR_LEN);
982     EXPECT_NE(ret, HDF_SUCCESS);
983     ret = g_wifi->getStationInfo(nullptr, &info, nullptr, ETH_ADDR_LEN);
984     EXPECT_NE(ret, HDF_SUCCESS);
985     ret = g_wifi->getStationInfo(nullptr, nullptr, mac, ETH_ADDR_LEN);
986     EXPECT_NE(ret, HDF_SUCCESS);
987     ret = g_wifi->getStationInfo(ifName, &info, nullptr, ETH_ADDR_LEN);
988     EXPECT_NE(ret, HDF_SUCCESS);
989     ret = g_wifi->getStationInfo(nullptr, &info, mac, ETH_ADDR_LEN);
990     EXPECT_NE(ret, HDF_SUCCESS);
991     ret = g_wifi->getStationInfo(ifName, nullptr, mac, ETH_ADDR_LEN);
992     EXPECT_NE(ret, HDF_SUCCESS);
993     for (auto _ : st) {
994         ret = g_wifi->getStationInfo(ifName, &info, mac, ETH_ADDR_LEN);
995     }
996     flag = (ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
997     ASSERT_TRUE(flag);
998     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
999     EXPECT_EQ(ret, HDF_SUCCESS);
1000     g_wifi->stop(g_wifi);
1001 }
1002 
1003 BENCHMARK_REGISTER_F(wlanBenchmarkTest, GetStationInfo001)->Iterations(100)->
1004     Repetitions(3)->ReportAggregatesOnly();
1005 
1006 /**
1007  * @tc.name: HalGetChipId001
1008  * @tc.desc: wifi hal get chip ID function test
1009  * @tc.type: FUNC
1010  */
1011 
BENCHMARK_F(wlanBenchmarkTest,GetChipId001)1012 BENCHMARK_F(wlanBenchmarkTest, GetChipId001)(
1013     benchmark::State &st)
1014 {
1015     g_wifi->start(g_wifi);
1016     int32_t ret;
1017     struct IWiFiSta *staFeature = nullptr;
1018     unsigned char chipId = 0;
1019 
1020     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_STATION, (struct IWiFiBaseFeature **)&staFeature);
1021     EXPECT_EQ(HDF_SUCCESS, ret);
1022     EXPECT_NE(nullptr, staFeature);
1023 
1024     ret = staFeature->baseFeature.getChipId(nullptr, &chipId);
1025     EXPECT_NE(HDF_SUCCESS, ret);
1026     ret = staFeature->baseFeature.getChipId((struct IWiFiBaseFeature *)staFeature, nullptr);
1027     EXPECT_NE(HDF_SUCCESS, ret);
1028     for (auto _ : st) {
1029         ret = staFeature->baseFeature.getChipId((struct IWiFiBaseFeature *)staFeature, &chipId);
1030     }
1031     ASSERT_TRUE(chipId < MAX_WLAN_DEVICE);
1032     EXPECT_EQ(HDF_SUCCESS, ret);
1033 
1034     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)staFeature);
1035     EXPECT_EQ(HDF_SUCCESS, ret);
1036     g_wifi->stop(g_wifi);
1037 }
1038 
1039 BENCHMARK_REGISTER_F(wlanBenchmarkTest, GetChipId001)->Iterations(100)->
1040     Repetitions(3)->ReportAggregatesOnly();
1041 
1042 /**
1043  * @tc.name: ResetDriver001
1044  * @tc.desc: wifi hal reset driver function test
1045  * @tc.type: FUNC
1046  */
1047 
BENCHMARK_F(wlanBenchmarkTest,ResetDriver001)1048 BENCHMARK_F(wlanBenchmarkTest, ResetDriver001)(
1049     benchmark::State &st)
1050 {
1051     g_wifi->start(g_wifi);
1052     int32_t ret;
1053     struct IWiFiSta *staFeature = nullptr;
1054     uint8_t chipId = 0;
1055     uint8_t chipIdInvalid = 20;
1056 
1057     ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_STATION, (struct IWiFiBaseFeature **)&staFeature);
1058     EXPECT_EQ(HDF_SUCCESS, ret);
1059     EXPECT_NE(nullptr, staFeature);
1060     ret = staFeature->baseFeature.getChipId((struct IWiFiBaseFeature *)staFeature, &chipId);
1061     ASSERT_TRUE(chipId < MAX_WLAN_DEVICE);
1062     EXPECT_EQ(HDF_SUCCESS, ret);
1063     for (auto _ : st) {
1064         ret = g_wifi->resetDriver(chipIdInvalid, "wlan0");
1065     }
1066     EXPECT_EQ(HDF_ERR_INVALID_PARAM, ret);
1067     ret = g_wifi->resetDriver(chipId, nullptr);
1068     EXPECT_EQ(HDF_ERR_INVALID_PARAM, ret);
1069     ret = g_wifi->resetDriver(chipId, staFeature->baseFeature.ifName);
1070     EXPECT_EQ(HDF_SUCCESS, ret);
1071     sleep(RESET_TIME);
1072     ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)staFeature);
1073     EXPECT_EQ(HDF_SUCCESS, ret);
1074     g_wifi->stop(g_wifi);
1075 }
1076 
1077 BENCHMARK_REGISTER_F(wlanBenchmarkTest, ResetDriver001)->Iterations(100)->
1078     Repetitions(3)->ReportAggregatesOnly();
1079 }
1080 BENCHMARK_MAIN();
1081 
1082