19762338dSopenharmony_ci/*
29762338dSopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
39762338dSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
49762338dSopenharmony_ci * you may not use this file except in compliance with the License.
59762338dSopenharmony_ci * You may obtain a copy of the License at
69762338dSopenharmony_ci *
79762338dSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
89762338dSopenharmony_ci *
99762338dSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
109762338dSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
119762338dSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
129762338dSopenharmony_ci * See the License for the specific language governing permissions and
139762338dSopenharmony_ci * limitations under the License.
149762338dSopenharmony_ci */
159762338dSopenharmony_ci#include <benchmark/benchmark.h>
169762338dSopenharmony_ci#include <string>
179762338dSopenharmony_ci#include <vector>
189762338dSopenharmony_ci
199762338dSopenharmony_ci#include <gtest/gtest.h>
209762338dSopenharmony_ci#include <osal_mem.h>
219762338dSopenharmony_ci#include "hdf_base.h"
229762338dSopenharmony_ci#include "hdf_sbuf.h"
239762338dSopenharmony_ci#include "wifi_hal.h"
249762338dSopenharmony_ci#include "wifi_hal_ap_feature.h"
259762338dSopenharmony_ci#include "wifi_hal_base_feature.h"
269762338dSopenharmony_ci#include "wifi_hal_sta_feature.h"
279762338dSopenharmony_ci#include "securec.h"
289762338dSopenharmony_ci#include <servmgr_hdi.h>
299762338dSopenharmony_ci#include "v1_3/iwlan_interface.h"
309762338dSopenharmony_ci#include "wlan_impl.h"
319762338dSopenharmony_ci
329762338dSopenharmony_ciusing namespace std;
339762338dSopenharmony_ciusing namespace testing::ext;
349762338dSopenharmony_ci
359762338dSopenharmony_cinamespace  {
369762338dSopenharmony_cistruct IWiFi *g_wifi = nullptr;
379762338dSopenharmony_ciconst int32_t WLAN_TX_POWER = 160;
389762338dSopenharmony_ciconst uint32_t WLAN_MIN_CHIPID = 0;
399762338dSopenharmony_ciconst uint32_t WLAN_MAX_CHIPID = 2;
409762338dSopenharmony_ciconst uint32_t IFNAME_MIN_NUM = 0;
419762338dSopenharmony_ciconst uint32_t IFNAME_MAX_NUM = 32;
429762338dSopenharmony_ciconst uint32_t MAX_IF_NAME_LENGTH = 16;
439762338dSopenharmony_ciconst uint32_t SIZE = 4;
449762338dSopenharmony_ciconst int32_t WLAN_BAND_2G = 0;
459762338dSopenharmony_ciconst int32_t WLAN_MAX_NUM_STA_WITH_AP = 4;
469762338dSopenharmony_ciconst uint32_t TEST_BUF_SIZE = 64;
479762338dSopenharmony_ciconst uint32_t TEST_PARAM_BUF_SIZE = 64;
489762338dSopenharmony_ciconst int32_t TEST_CMD = 123;
499762338dSopenharmony_ciconst uint32_t RESET_TIME = 20;
509762338dSopenharmony_ciconst int32_t WLAN_FREQ_MAX_NUM = 35;
519762338dSopenharmony_ciconst int32_t DEFAULT_COMBO_SIZE = 6;
529762338dSopenharmony_ciconst uint32_t MEAS_CHANNEL_TIME = 10;
539762338dSopenharmony_ci
549762338dSopenharmony_cistatic struct IWlanInterface *g_wlanObj = nullptr;
559762338dSopenharmony_ciclass wlanBenchmarkTest : public benchmark::Fixture {
569762338dSopenharmony_cipublic:
579762338dSopenharmony_ci    void SetUp(const ::benchmark::State &state);
589762338dSopenharmony_ci    void TearDown(const ::benchmark::State &state);
599762338dSopenharmony_ci};
609762338dSopenharmony_ci
619762338dSopenharmony_civoid wlanBenchmarkTest::SetUp(const ::benchmark::State &state)
629762338dSopenharmony_ci{
639762338dSopenharmony_ci    int ret = WifiConstruct(&g_wifi);
649762338dSopenharmony_ci    ASSERT_EQ(HDF_SUCCESS, ret);
659762338dSopenharmony_ci}
669762338dSopenharmony_ci
679762338dSopenharmony_civoid wlanBenchmarkTest::TearDown(const ::benchmark::State &state)
689762338dSopenharmony_ci{
699762338dSopenharmony_ci    int ret = WifiDestruct(&g_wifi);
709762338dSopenharmony_ci    ASSERT_EQ(HDF_SUCCESS, ret);
719762338dSopenharmony_ci}
729762338dSopenharmony_ci
739762338dSopenharmony_cistatic void ParseScanResult(WifiScanResult *scanResult)
749762338dSopenharmony_ci{
759762338dSopenharmony_ci    printf("ParseScanResult: flags=%d, caps=%d, freq=%d, beaconInt=%d,\n",
769762338dSopenharmony_ci        scanResult->flags, scanResult->caps, scanResult->freq, scanResult->beaconInt);
779762338dSopenharmony_ci    printf("ParseScanResult: qual=%d, beaconIeLen=%d, level=%d, age=%d, ieLen=%d,\n",
789762338dSopenharmony_ci        scanResult->qual, scanResult->beaconIeLen, scanResult->level, scanResult->age, scanResult->ieLen);
799762338dSopenharmony_ci}
809762338dSopenharmony_ci
819762338dSopenharmony_cistatic int32_t HalCallbackEvent(uint32_t event, void *respData, const char *ifName)
829762338dSopenharmony_ci{
839762338dSopenharmony_ci    (void)event;
849762338dSopenharmony_ci    if (respData == nullptr) {
859762338dSopenharmony_ci        return HDF_FAILURE;
869762338dSopenharmony_ci    }
879762338dSopenharmony_ci    printf("HalCallbackEvent ifName = %s, event = %u\n", ifName, event);
889762338dSopenharmony_ci    switch (event) {
899762338dSopenharmony_ci        case WIFI_EVENT_SCAN_DONE:
909762338dSopenharmony_ci            printf("HalCallbackEvent WIFI_EVENT_SCAN_DONE Process\n");
919762338dSopenharmony_ci            break;
929762338dSopenharmony_ci        case WIFI_EVENT_SCAN_RESULT:
939762338dSopenharmony_ci            ParseScanResult((WifiScanResult *)respData);
949762338dSopenharmony_ci            break;
959762338dSopenharmony_ci        default:
969762338dSopenharmony_ci            break;
979762338dSopenharmony_ci    }
989762338dSopenharmony_ci    return HDF_SUCCESS;
999762338dSopenharmony_ci}
1009762338dSopenharmony_ci
1019762338dSopenharmony_ci/**
1029762338dSopenharmony_ci * @tc.name:wifiHalstartandstop001
1039762338dSopenharmony_ci * @tc.desc: Wifi hal start and stop
1049762338dSopenharmony_ci * @tc.type: FUNC
1059762338dSopenharmony_ci */
1069762338dSopenharmony_ci
1079762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, wifiHalstartandstop001)(
1089762338dSopenharmony_ci    benchmark::State &st)
1099762338dSopenharmony_ci{
1109762338dSopenharmony_ci    for (auto _ : st) {
1119762338dSopenharmony_ci        g_wifi->start(g_wifi);
1129762338dSopenharmony_ci        g_wifi->stop(g_wifi);
1139762338dSopenharmony_ci    }
1149762338dSopenharmony_ci}
1159762338dSopenharmony_ci
1169762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, wifiHalstartandstop001)->Iterations(100)->
1179762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
1189762338dSopenharmony_ci
1199762338dSopenharmony_ci/**
1209762338dSopenharmony_ci * @tc.name:wifiHalstartScan001
1219762338dSopenharmony_ci * @tc.desc: Wifi startscan
1229762338dSopenharmony_ci * @tc.type: FUNC
1239762338dSopenharmony_ci */
1249762338dSopenharmony_ci
1259762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, wifiHalstartScan001)(
1269762338dSopenharmony_ci    benchmark::State &st)
1279762338dSopenharmony_ci{
1289762338dSopenharmony_ci    g_wifi->start(g_wifi);
1299762338dSopenharmony_ci    int ret;
1309762338dSopenharmony_ci    struct IWiFiSta *staFeature = nullptr;
1319762338dSopenharmony_ci    const char *ifName = "wlan0";
1329762338dSopenharmony_ci    WifiScan scan = {0};
1339762338dSopenharmony_ci
1349762338dSopenharmony_ci    ret = g_wifi->registerEventCallback(HalCallbackEvent, ifName);
1359762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
1369762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_STATION, (struct IWiFiBaseFeature **)&staFeature);
1379762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
1389762338dSopenharmony_ci    EXPECT_NE(nullptr, staFeature);
1399762338dSopenharmony_ci    for (auto _ : st) {
1409762338dSopenharmony_ci    ret = staFeature->startScan(nullptr, &scan);
1419762338dSopenharmony_ci    }
1429762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
1439762338dSopenharmony_ci    sleep(10);
1449762338dSopenharmony_ci    g_wifi->stop(g_wifi);
1459762338dSopenharmony_ci}
1469762338dSopenharmony_ci
1479762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, wifiHalstartScan001)->Iterations(100)->
1489762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
1499762338dSopenharmony_ci
1509762338dSopenharmony_ci/**
1519762338dSopenharmony_ci * @tc.name:wifiHalStartChannelMeas001
1529762338dSopenharmony_ci * @tc.desc: Wifi hal StartChannelMeas
1539762338dSopenharmony_ci * @tc.type: FUNC
1549762338dSopenharmony_ci */
1559762338dSopenharmony_ci
1569762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, wifiHalStartChannelMeas001)(
1579762338dSopenharmony_ci    benchmark::State &st)
1589762338dSopenharmony_ci{
1599762338dSopenharmony_ci    int32_t rc = g_wlanObj->Start(g_wlanObj);
1609762338dSopenharmony_ci    ASSERT_EQ(rc, HDF_SUCCESS);
1619762338dSopenharmony_ci    const char *ifName = "wlan0";
1629762338dSopenharmony_ci    struct MeasChannelParam measChannelParam;
1639762338dSopenharmony_ci    struct MeasChannelResult measChannelResult = {0};
1649762338dSopenharmony_ci
1659762338dSopenharmony_ci    measChannelParam.channelId = 1;
1669762338dSopenharmony_ci    measChannelParam.measTime = 15;
1679762338dSopenharmony_ci    rc = g_wlanObj->StartChannelMeas(g_wlanObj, ifName, &measChannelParam);
1689762338dSopenharmony_ci    bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT);
1699762338dSopenharmony_ci    ASSERT_TRUE(flag);
1709762338dSopenharmony_ci    sleep(MEAS_CHANNEL_TIME);
1719762338dSopenharmony_ci    for (auto _ : st) {
1729762338dSopenharmony_ci    rc = g_wlanObj->GetChannelMeasResult(g_wlanObj, ifName, &measChannelResult);
1739762338dSopenharmony_ci    }
1749762338dSopenharmony_ci    flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT || rc == HDF_DEV_ERR_NODATA);
1759762338dSopenharmony_ci    ASSERT_TRUE(flag);
1769762338dSopenharmony_ci    rc = g_wlanObj->Stop(g_wlanObj);
1779762338dSopenharmony_ci    ASSERT_EQ(rc, HDF_SUCCESS);
1789762338dSopenharmony_ci}
1799762338dSopenharmony_ci
1809762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, wifiHalStartChannelMeas001)->Iterations(100)->
1819762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
1829762338dSopenharmony_ci
1839762338dSopenharmony_ci/**
1849762338dSopenharmony_ci * @tc.name:wifiHalGetChannelMeasResult001
1859762338dSopenharmony_ci * @tc.desc: Wifi hal StartChannelMeas
1869762338dSopenharmony_ci * @tc.type: FUNC
1879762338dSopenharmony_ci */
1889762338dSopenharmony_ci
1899762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, wifiHalGetChannelMeasResult001)(
1909762338dSopenharmony_ci    benchmark::State &st)
1919762338dSopenharmony_ci{
1929762338dSopenharmony_ci    int32_t rc = g_wlanObj->Start(g_wlanObj);
1939762338dSopenharmony_ci    ASSERT_EQ(rc, HDF_SUCCESS);
1949762338dSopenharmony_ci    const char *ifName = "wlan0";
1959762338dSopenharmony_ci    struct MeasChannelParam measChannelParam;
1969762338dSopenharmony_ci    struct MeasChannelResult measChannelResult = {0};
1979762338dSopenharmony_ci
1989762338dSopenharmony_ci    measChannelParam.channelId = 1;
1999762338dSopenharmony_ci    measChannelParam.measTime = 15;
2009762338dSopenharmony_ci    rc = g_wlanObj->StartChannelMeas(g_wlanObj, ifName, &measChannelParam);
2019762338dSopenharmony_ci    bool flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT);
2029762338dSopenharmony_ci    ASSERT_TRUE(flag);
2039762338dSopenharmony_ci    sleep(MEAS_CHANNEL_TIME);
2049762338dSopenharmony_ci    for (auto _ : st) {
2059762338dSopenharmony_ci    rc = g_wlanObj->GetChannelMeasResult(g_wlanObj, ifName, &measChannelResult);
2069762338dSopenharmony_ci    }
2079762338dSopenharmony_ci    flag = (rc == HDF_SUCCESS || rc == HDF_ERR_NOT_SUPPORT || rc == HDF_DEV_ERR_NODATA);
2089762338dSopenharmony_ci    ASSERT_TRUE(flag);
2099762338dSopenharmony_ci    rc = g_wlanObj->Stop(g_wlanObj);
2109762338dSopenharmony_ci    ASSERT_EQ(rc, HDF_SUCCESS);
2119762338dSopenharmony_ci}
2129762338dSopenharmony_ci
2139762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, wifiHalGetChannelMeasResult001)->Iterations(100)->
2149762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
2159762338dSopenharmony_ci
2169762338dSopenharmony_ci/**
2179762338dSopenharmony_ci * @tc.name:wifiHalcreateFeaturete001
2189762338dSopenharmony_ci * @tc.desc: Wifi hal create and destroy feature for ap mode benchmark test
2199762338dSopenharmony_ci * @tc.type: FUNC
2209762338dSopenharmony_ci */
2219762338dSopenharmony_ci
2229762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, wifiHalcreateFeaturete001)(
2239762338dSopenharmony_ci    benchmark::State &st)
2249762338dSopenharmony_ci{
2259762338dSopenharmony_ci    g_wifi->start(g_wifi);
2269762338dSopenharmony_ci    int ret;
2279762338dSopenharmony_ci    struct IWiFiAp *apFeature = nullptr;
2289762338dSopenharmony_ci    for (auto _ : st) {
2299762338dSopenharmony_ci        ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
2309762338dSopenharmony_ci        g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
2319762338dSopenharmony_ci    }
2329762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
2339762338dSopenharmony_ci    g_wifi->stop(g_wifi);
2349762338dSopenharmony_ci}
2359762338dSopenharmony_ci
2369762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, wifiHalcreateFeaturete001)->Iterations(100)->
2379762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
2389762338dSopenharmony_ci
2399762338dSopenharmony_ci/**
2409762338dSopenharmony_ci * @tc.name:wifiHalcreateFeaturete002
2419762338dSopenharmony_ci * @tc.desc: Wifi hal create and destroy feature for sta mode benchmark test
2429762338dSopenharmony_ci * @tc.type: FUNC
2439762338dSopenharmony_ci */
2449762338dSopenharmony_ci
2459762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, wifiHalcreateFeaturete002)(
2469762338dSopenharmony_ci    benchmark::State &st)
2479762338dSopenharmony_ci{
2489762338dSopenharmony_ci    g_wifi->start(g_wifi);
2499762338dSopenharmony_ci    int ret;
2509762338dSopenharmony_ci    struct IWiFiSta *staFeature = nullptr;
2519762338dSopenharmony_ci    for (auto _ : st) {
2529762338dSopenharmony_ci        g_wifi->createFeature(PROTOCOL_80211_IFTYPE_STATION, (struct IWiFiBaseFeature **)&staFeature);
2539762338dSopenharmony_ci        ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)staFeature);
2549762338dSopenharmony_ci    }
2559762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
2569762338dSopenharmony_ci    g_wifi->stop(g_wifi);
2579762338dSopenharmony_ci}
2589762338dSopenharmony_ci
2599762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, wifiHalcreateFeaturete002)->Iterations(100)->
2609762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
2619762338dSopenharmony_ci
2629762338dSopenharmony_ci/**
2639762338dSopenharmony_ci * @tc.name: WifiHalGetFeatureByIfName001
2649762338dSopenharmony_ci * @tc.desc: Wifi hal get feature by ifname benchmark test
2659762338dSopenharmony_ci * @tc.type: FUNC
2669762338dSopenharmony_ci */
2679762338dSopenharmony_ci
2689762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, wifiHalGetFeatureByIfName001)(
2699762338dSopenharmony_ci    benchmark::State &st)
2709762338dSopenharmony_ci{
2719762338dSopenharmony_ci    g_wifi->start(g_wifi);
2729762338dSopenharmony_ci    int ret;
2739762338dSopenharmony_ci    struct IWiFiAp *apFeature = nullptr;
2749762338dSopenharmony_ci    struct IWiFiAp *apFeatureGet = nullptr;
2759762338dSopenharmony_ci    const char *ifName0 = "wlanTest";
2769762338dSopenharmony_ci    const char *ifName1 = "wlan0";
2779762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
2789762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
2799762338dSopenharmony_ci    EXPECT_NE(nullptr, apFeature);
2809762338dSopenharmony_ci    ret = g_wifi->getFeatureByIfName(ifName0, (struct IWiFiBaseFeature **)&apFeatureGet);
2819762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
2829762338dSopenharmony_ci    for (auto _ : st) {
2839762338dSopenharmony_ci        ret = g_wifi->getFeatureByIfName(ifName1, (struct IWiFiBaseFeature **)&apFeatureGet);
2849762338dSopenharmony_ci    }
2859762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
2869762338dSopenharmony_ci    EXPECT_NE(nullptr, apFeatureGet);
2879762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
2889762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
2899762338dSopenharmony_ci    g_wifi->stop(g_wifi);
2909762338dSopenharmony_ci}
2919762338dSopenharmony_ci
2929762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, wifiHalGetFeatureByIfName001)->Iterations(100)->
2939762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
2949762338dSopenharmony_ci
2959762338dSopenharmony_ci/**
2969762338dSopenharmony_ci * @tc.name: WifiHalRegisterEventCallback001
2979762338dSopenharmony_ci * @tc.desc: Wifi hal register callback benchmark test
2989762338dSopenharmony_ci * @tc.type: FUNC
2999762338dSopenharmony_ci */
3009762338dSopenharmony_ci
3019762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, wifiHalregisterEventCallback001)(
3029762338dSopenharmony_ci    benchmark::State &st)
3039762338dSopenharmony_ci{
3049762338dSopenharmony_ci    g_wifi->start(g_wifi);
3059762338dSopenharmony_ci    int ret;
3069762338dSopenharmony_ci    for (auto _ : st) {
3079762338dSopenharmony_ci        ret = g_wifi->registerEventCallback(HalCallbackEvent, "wlan0");
3089762338dSopenharmony_ci    }
3099762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
3109762338dSopenharmony_ci    g_wifi->stop(g_wifi);
3119762338dSopenharmony_ci}
3129762338dSopenharmony_ci
3139762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, wifiHalregisterEventCallback001)->Iterations(100)->
3149762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
3159762338dSopenharmony_ci
3169762338dSopenharmony_ci/**
3179762338dSopenharmony_ci * @tc.name: WifiHalUnRegisterEventCallback001
3189762338dSopenharmony_ci * @tc.desc: Wifi hal unregister callback benchmark test
3199762338dSopenharmony_ci * @tc.type: FUNC
3209762338dSopenharmony_ci */
3219762338dSopenharmony_ci
3229762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, wifiHalunregisterEventCallback001)(
3239762338dSopenharmony_ci    benchmark::State &st)
3249762338dSopenharmony_ci{
3259762338dSopenharmony_ci    g_wifi->start(g_wifi);
3269762338dSopenharmony_ci    int ret;
3279762338dSopenharmony_ci    for (auto _ : st) {
3289762338dSopenharmony_ci        ret = g_wifi->unregisterEventCallback(HalCallbackEvent, "wlan0");
3299762338dSopenharmony_ci    }
3309762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
3319762338dSopenharmony_ci    g_wifi->stop(g_wifi);
3329762338dSopenharmony_ci}
3339762338dSopenharmony_ci
3349762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, wifiHalunregisterEventCallback001)->Iterations(100)->
3359762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
3369762338dSopenharmony_ci
3379762338dSopenharmony_ci/**
3389762338dSopenharmony_ci * @tc.name: WifiHalGetNetworkIfaceName001
3399762338dSopenharmony_ci * @tc.desc: Wifi hal get network iface name benchmark test
3409762338dSopenharmony_ci * @tc.type: FUNC
3419762338dSopenharmony_ci */
3429762338dSopenharmony_ci
3439762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, WifiHalgetNetworkIfaceName001)(
3449762338dSopenharmony_ci    benchmark::State &st)
3459762338dSopenharmony_ci{
3469762338dSopenharmony_ci    g_wifi->start(g_wifi);
3479762338dSopenharmony_ci    int ret;
3489762338dSopenharmony_ci    const char *ifName=nullptr;
3499762338dSopenharmony_ci    struct IWiFiAp *apFeature = nullptr;
3509762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
3519762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
3529762338dSopenharmony_ci    EXPECT_NE(nullptr, apFeature);
3539762338dSopenharmony_ci    for (auto _ : st) {
3549762338dSopenharmony_ci        ifName = apFeature->baseFeature.getNetworkIfaceName((const struct IWiFiBaseFeature *)apFeature);
3559762338dSopenharmony_ci    }
3569762338dSopenharmony_ci    EXPECT_NE(nullptr, ifName);
3579762338dSopenharmony_ci    ret = strcmp(ifName, "wlan0");
3589762338dSopenharmony_ci    EXPECT_EQ(0, ret);
3599762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
3609762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
3619762338dSopenharmony_ci    g_wifi->stop(g_wifi);
3629762338dSopenharmony_ci}
3639762338dSopenharmony_ci
3649762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetNetworkIfaceName001)->Iterations(100)->
3659762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
3669762338dSopenharmony_ci
3679762338dSopenharmony_ci/**
3689762338dSopenharmony_ci * @tc.name: WifiHalGetGetFeatureType001
3699762338dSopenharmony_ci * @tc.desc: Wifi hal get feature type benchmark test
3709762338dSopenharmony_ci * @tc.type: FUNC
3719762338dSopenharmony_ci */
3729762338dSopenharmony_ci
3739762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, WifiHalgetFeatureType001)(
3749762338dSopenharmony_ci    benchmark::State &st)
3759762338dSopenharmony_ci{
3769762338dSopenharmony_ci    g_wifi->start(g_wifi);
3779762338dSopenharmony_ci    int ret;
3789762338dSopenharmony_ci    struct IWiFiAp *apFeature = nullptr;
3799762338dSopenharmony_ci    int32_t type;
3809762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
3819762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
3829762338dSopenharmony_ci    EXPECT_NE(nullptr, apFeature);
3839762338dSopenharmony_ci    for (auto _ : st) {
3849762338dSopenharmony_ci        type = apFeature->baseFeature.getFeatureType((struct IWiFiBaseFeature *)apFeature);
3859762338dSopenharmony_ci    }
3869762338dSopenharmony_ci    EXPECT_EQ(PROTOCOL_80211_IFTYPE_AP, type);
3879762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
3889762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
3899762338dSopenharmony_ci    g_wifi->stop(g_wifi);
3909762338dSopenharmony_ci}
3919762338dSopenharmony_ci
3929762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetFeatureType001)->Iterations(100)->
3939762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
3949762338dSopenharmony_ci
3959762338dSopenharmony_ci /**
3969762338dSopenharmony_ci * @tc.name: WifiHalSetMacAddress001
3979762338dSopenharmony_ci * @tc.desc: Wifi hal set Mac address benchmark test
3989762338dSopenharmony_ci * @tc.type: FUNC
3999762338dSopenharmony_ci */
4009762338dSopenharmony_ci
4019762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, WifiHalsetMacAddress001)(
4029762338dSopenharmony_ci    benchmark::State &st)
4039762338dSopenharmony_ci{
4049762338dSopenharmony_ci    g_wifi->start(g_wifi);
4059762338dSopenharmony_ci    int ret;
4069762338dSopenharmony_ci    struct IWiFiAp *apFeature = nullptr;
4079762338dSopenharmony_ci    unsigned char errorMac[ETH_ADDR_LEN] = {0x11, 0x34, 0x56, 0x78, 0xab, 0xcd};
4089762338dSopenharmony_ci    unsigned char mac[ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd};
4099762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
4109762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
4119762338dSopenharmony_ci    EXPECT_NE(nullptr, apFeature);
4129762338dSopenharmony_ci    ret = apFeature->baseFeature.setMacAddress((struct IWiFiBaseFeature *)apFeature, nullptr, 0);
4139762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
4149762338dSopenharmony_ci    ret = apFeature->baseFeature.setMacAddress((struct IWiFiBaseFeature *)apFeature, errorMac, ETH_ADDR_LEN);
4159762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
4169762338dSopenharmony_ci    for (auto _ : st) {
4179762338dSopenharmony_ci        ret = apFeature->baseFeature.setMacAddress((struct IWiFiBaseFeature *)apFeature, mac, ETH_ADDR_LEN);
4189762338dSopenharmony_ci    }
4199762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
4209762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
4219762338dSopenharmony_ci    g_wifi->stop(g_wifi);
4229762338dSopenharmony_ci}
4239762338dSopenharmony_ci
4249762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalsetMacAddress001)->Iterations(100)->
4259762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
4269762338dSopenharmony_ci
4279762338dSopenharmony_ci/**
4289762338dSopenharmony_ci * @tc.name: WifiHalSetMacAddress002
4299762338dSopenharmony_ci * @tc.desc: Wifi hal set Mac address benchmark test
4309762338dSopenharmony_ci * @tc.type: FUNC
4319762338dSopenharmony_ci */
4329762338dSopenharmony_ci
4339762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, WifiHalsetMacAddress002)(
4349762338dSopenharmony_ci    benchmark::State &st)
4359762338dSopenharmony_ci{
4369762338dSopenharmony_ci    g_wifi->start(g_wifi);
4379762338dSopenharmony_ci    int ret;
4389762338dSopenharmony_ci    struct IWiFiSta *staFeature = nullptr;
4399762338dSopenharmony_ci    unsigned char errorMac[ETH_ADDR_LEN] = {0};
4409762338dSopenharmony_ci    unsigned char mac[ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd};
4419762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_STATION, (struct IWiFiBaseFeature **)&staFeature);
4429762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
4439762338dSopenharmony_ci    EXPECT_NE(nullptr, staFeature);
4449762338dSopenharmony_ci    ret = staFeature->baseFeature.setMacAddress((struct IWiFiBaseFeature *)staFeature, nullptr, 0);
4459762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
4469762338dSopenharmony_ci    ret = staFeature->baseFeature.setMacAddress((struct IWiFiBaseFeature *)staFeature, errorMac, ETH_ADDR_LEN);
4479762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
4489762338dSopenharmony_ci    for (auto _ : st) {
4499762338dSopenharmony_ci        ret = staFeature->baseFeature.setMacAddress((struct IWiFiBaseFeature *)staFeature, mac, ETH_ADDR_LEN);
4509762338dSopenharmony_ci    }
4519762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)staFeature);
4529762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
4539762338dSopenharmony_ci    g_wifi->stop(g_wifi);
4549762338dSopenharmony_ci}
4559762338dSopenharmony_ci
4569762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalsetMacAddress002)->Iterations(100)->
4579762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
4589762338dSopenharmony_ci
4599762338dSopenharmony_ci/**
4609762338dSopenharmony_ci * @tc.name: WifiHalSetTxPower001
4619762338dSopenharmony_ci * @tc.desc: Wifi hal set transmit power benchmark test
4629762338dSopenharmony_ci * @tc.type: FUNC
4639762338dSopenharmony_ci */
4649762338dSopenharmony_ci
4659762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, WifiHalsetTxPower001)(
4669762338dSopenharmony_ci    benchmark::State &st)
4679762338dSopenharmony_ci{
4689762338dSopenharmony_ci    g_wifi->start(g_wifi);
4699762338dSopenharmony_ci    int ret;
4709762338dSopenharmony_ci    struct IWiFiAp *apFeature = nullptr;
4719762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
4729762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
4739762338dSopenharmony_ci    EXPECT_NE(nullptr, apFeature);
4749762338dSopenharmony_ci    ret = apFeature->baseFeature.setTxPower((struct IWiFiBaseFeature *)apFeature, 0);
4759762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
4769762338dSopenharmony_ci    for (auto _ : st) {
4779762338dSopenharmony_ci        ret = apFeature->baseFeature.setTxPower((struct IWiFiBaseFeature *)apFeature, WLAN_TX_POWER);
4789762338dSopenharmony_ci    }
4799762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
4809762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
4819762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
4829762338dSopenharmony_ci    g_wifi->stop(g_wifi);
4839762338dSopenharmony_ci}
4849762338dSopenharmony_ci
4859762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalsetTxPower001)->Iterations(100)->
4869762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
4879762338dSopenharmony_ci
4889762338dSopenharmony_ci/**
4899762338dSopenharmony_ci * @tc.name: WifiHalSetCountryCode001
4909762338dSopenharmony_ci * @tc.desc: Wifi hal set country code benchmark test
4919762338dSopenharmony_ci * @tc.type: FUNC
4929762338dSopenharmony_ci */
4939762338dSopenharmony_ci
4949762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, WifiHalsetCountryCode001)(
4959762338dSopenharmony_ci    benchmark::State &st)
4969762338dSopenharmony_ci{
4979762338dSopenharmony_ci    g_wifi->start(g_wifi);
4989762338dSopenharmony_ci    int ret;
4999762338dSopenharmony_ci    struct IWiFiAp *apFeature = nullptr;
5009762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
5019762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
5029762338dSopenharmony_ci    EXPECT_NE(nullptr, apFeature);
5039762338dSopenharmony_ci    ret = apFeature->setCountryCode(apFeature, nullptr, 0);
5049762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
5059762338dSopenharmony_ci    for (auto _ : st) {
5069762338dSopenharmony_ci        ret = apFeature->setCountryCode(apFeature, "CN", 2);
5079762338dSopenharmony_ci    }
5089762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
5099762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
5109762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
5119762338dSopenharmony_ci    g_wifi->stop(g_wifi);
5129762338dSopenharmony_ci}
5139762338dSopenharmony_ci
5149762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalsetCountryCode001)->Iterations(100)->
5159762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
5169762338dSopenharmony_ci
5179762338dSopenharmony_ci/**
5189762338dSopenharmony_ci * @tc.name: WifiHalGetIfNamesByChipId001
5199762338dSopenharmony_ci * @tc.desc: Obtain all ifNames and the number of the current chip
5209762338dSopenharmony_ci * @tc.type: FUNC
5219762338dSopenharmony_ci */
5229762338dSopenharmony_ci
5239762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, WifiHalgetIfNamesByChipId001)(
5249762338dSopenharmony_ci    benchmark::State &st)
5259762338dSopenharmony_ci{
5269762338dSopenharmony_ci    g_wifi->start(g_wifi);
5279762338dSopenharmony_ci    int ret;
5289762338dSopenharmony_ci    struct IWiFiSta *staFeature = nullptr;
5299762338dSopenharmony_ci    char *ifNames = nullptr;
5309762338dSopenharmony_ci    unsigned int num = 0;
5319762338dSopenharmony_ci    unsigned char chipId = 0;
5329762338dSopenharmony_ci    uint8_t i;
5339762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_STATION, (struct IWiFiBaseFeature **)&staFeature);
5349762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
5359762338dSopenharmony_ci    EXPECT_NE(nullptr, staFeature);
5369762338dSopenharmony_ci    ret = staFeature->baseFeature.getChipId((struct IWiFiBaseFeature *)staFeature, &chipId);
5379762338dSopenharmony_ci    ASSERT_TRUE(chipId <= WLAN_MAX_CHIPID && chipId >= WLAN_MIN_CHIPID);
5389762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
5399762338dSopenharmony_ci    ret = staFeature->baseFeature.getIfNamesByChipId(chipId, nullptr, nullptr);
5409762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
5419762338dSopenharmony_ci    for (auto _ : st) {
5429762338dSopenharmony_ci        ret = staFeature->baseFeature.getIfNamesByChipId(chipId, &ifNames, &num);
5439762338dSopenharmony_ci    }
5449762338dSopenharmony_ci    EXPECT_NE(nullptr, ifNames);
5459762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
5469762338dSopenharmony_ci    ASSERT_TRUE(num <= IFNAME_MAX_NUM && num >= IFNAME_MIN_NUM);
5479762338dSopenharmony_ci    for (i = 0; i < num; i++) {
5489762338dSopenharmony_ci        EXPECT_EQ(0, strncmp("wlan", ifNames + i * MAX_IF_NAME_LENGTH, SIZE));
5499762338dSopenharmony_ci    }
5509762338dSopenharmony_ci    free(ifNames);
5519762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)staFeature);
5529762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
5539762338dSopenharmony_ci    g_wifi->stop(g_wifi);
5549762338dSopenharmony_ci}
5559762338dSopenharmony_ci
5569762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetIfNamesByChipId001)->Iterations(100)->
5579762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
5589762338dSopenharmony_ci
5599762338dSopenharmony_ci/**
5609762338dSopenharmony_ci * @tc.name: WifiHalGetSupportFeature001
5619762338dSopenharmony_ci * @tc.desc: Get supported features
5629762338dSopenharmony_ci * @tc.type: FUNC
5639762338dSopenharmony_ci */
5649762338dSopenharmony_ci
5659762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, WifiHalgetSupportFeature001)(
5669762338dSopenharmony_ci    benchmark::State &st)
5679762338dSopenharmony_ci{
5689762338dSopenharmony_ci    g_wifi->start(g_wifi);
5699762338dSopenharmony_ci    int ret;
5709762338dSopenharmony_ci    uint8_t supportTest[PROTOCOL_80211_IFTYPE_NUM] = {0};
5719762338dSopenharmony_ci    uint8_t support[PROTOCOL_80211_IFTYPE_NUM + 1] = {0};
5729762338dSopenharmony_ci    ret = g_wifi->getSupportFeature(nullptr, 0);
5739762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
5749762338dSopenharmony_ci    ret = g_wifi->getSupportFeature(supportTest, PROTOCOL_80211_IFTYPE_NUM);
5759762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
5769762338dSopenharmony_ci    for (auto _ : st) {
5779762338dSopenharmony_ci        ret = g_wifi->getSupportFeature(support, PROTOCOL_80211_IFTYPE_NUM + 1);
5789762338dSopenharmony_ci    }
5799762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
5809762338dSopenharmony_ci    g_wifi->stop(g_wifi);
5819762338dSopenharmony_ci}
5829762338dSopenharmony_ci
5839762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetSupportFeature001)->Iterations(100)->
5849762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
5859762338dSopenharmony_ci
5869762338dSopenharmony_ci/**
5879762338dSopenharmony_ci * @tc.name: WifiHalGetSupportCombo001
5889762338dSopenharmony_ci * @tc.desc: Get supported combo
5899762338dSopenharmony_ci * @tc.type: FUNC
5909762338dSopenharmony_ci */
5919762338dSopenharmony_ci
5929762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, WifiHalgetSupportCombo001)(
5939762338dSopenharmony_ci    benchmark::State &st)
5949762338dSopenharmony_ci{
5959762338dSopenharmony_ci    g_wifi->start(g_wifi);
5969762338dSopenharmony_ci    int ret;
5979762338dSopenharmony_ci    uint8_t support[PROTOCOL_80211_IFTYPE_NUM + 1] = {0};
5989762338dSopenharmony_ci    uint64_t combo[DEFAULT_COMBO_SIZE] = {0};
5999762338dSopenharmony_ci    ret = g_wifi->getSupportFeature(support, PROTOCOL_80211_IFTYPE_NUM + 1);
6009762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
6019762338dSopenharmony_ci    for (auto _ : st) {
6029762338dSopenharmony_ci        ret = g_wifi->getSupportCombo(nullptr, 0);
6039762338dSopenharmony_ci    }
6049762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
6059762338dSopenharmony_ci    ret = g_wifi->getSupportCombo(combo, DEFAULT_COMBO_SIZE);
6069762338dSopenharmony_ci    if (support[PROTOCOL_80211_IFTYPE_NUM] == 0) {
6079762338dSopenharmony_ci        EXPECT_EQ(HDF_ERR_NOT_SUPPORT, ret);
6089762338dSopenharmony_ci    } else {
6099762338dSopenharmony_ci        EXPECT_EQ(HDF_SUCCESS, ret);
6109762338dSopenharmony_ci    }
6119762338dSopenharmony_ci    g_wifi->stop(g_wifi);
6129762338dSopenharmony_ci}
6139762338dSopenharmony_ci
6149762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetSupportCombo001)->Iterations(100)->
6159762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
6169762338dSopenharmony_ci
6179762338dSopenharmony_ci/**
6189762338dSopenharmony_ci * @tc.name: WifiHalGetDeviceMacAddress001
6199762338dSopenharmony_ci * @tc.desc: Get device Mac address for ap mode
6209762338dSopenharmony_ci * @tc.type: FUNC
6219762338dSopenharmony_ci */
6229762338dSopenharmony_ci
6239762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, WifiHalgetDeviceMacAddress001)(
6249762338dSopenharmony_ci    benchmark::State &st)
6259762338dSopenharmony_ci{
6269762338dSopenharmony_ci    g_wifi->start(g_wifi);
6279762338dSopenharmony_ci    int ret;
6289762338dSopenharmony_ci    struct IWiFiAp *apFeature = nullptr;
6299762338dSopenharmony_ci    unsigned char mac[ETH_ADDR_LEN] = {0};
6309762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
6319762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
6329762338dSopenharmony_ci    EXPECT_NE(nullptr, apFeature);
6339762338dSopenharmony_ci    ret = apFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)apFeature, nullptr, 0);
6349762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
6359762338dSopenharmony_ci    ret = apFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)apFeature, mac, ETH_ADDR_LEN - 1);
6369762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
6379762338dSopenharmony_ci    for (auto _ : st) {
6389762338dSopenharmony_ci        ret = apFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)apFeature, mac, ETH_ADDR_LEN);
6399762338dSopenharmony_ci    }
6409762338dSopenharmony_ci    EXPECT_NE(HDF_FAILURE, ret);
6419762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
6429762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
6439762338dSopenharmony_ci    g_wifi->stop(g_wifi);
6449762338dSopenharmony_ci}
6459762338dSopenharmony_ci
6469762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetDeviceMacAddress001)->Iterations(100)->
6479762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
6489762338dSopenharmony_ci
6499762338dSopenharmony_ci/**
6509762338dSopenharmony_ci * @tc.name: WifiHalGetDeviceMacAddress002
6519762338dSopenharmony_ci * @tc.desc: Get device Mac address for sta mode
6529762338dSopenharmony_ci * @tc.type: FUNC
6539762338dSopenharmony_ci */
6549762338dSopenharmony_ci
6559762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, WifiHalgetDeviceMacAddress002)(
6569762338dSopenharmony_ci    benchmark::State &st)
6579762338dSopenharmony_ci{
6589762338dSopenharmony_ci    g_wifi->start(g_wifi);
6599762338dSopenharmony_ci    int ret;
6609762338dSopenharmony_ci    struct IWiFiSta *staFeature = nullptr;
6619762338dSopenharmony_ci    unsigned char mac[ETH_ADDR_LEN] = {0};
6629762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_STATION, (struct IWiFiBaseFeature **)&staFeature);
6639762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
6649762338dSopenharmony_ci    EXPECT_NE(nullptr, staFeature);
6659762338dSopenharmony_ci    ret = staFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)staFeature, nullptr, 0);
6669762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
6679762338dSopenharmony_ci    ret = staFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)staFeature, mac, ETH_ADDR_LEN - 1);
6689762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
6699762338dSopenharmony_ci    for (auto _ : st) {
6709762338dSopenharmony_ci        ret = staFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)staFeature, mac, ETH_ADDR_LEN);
6719762338dSopenharmony_ci    }
6729762338dSopenharmony_ci    EXPECT_NE(HDF_FAILURE, ret);
6739762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)staFeature);
6749762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
6759762338dSopenharmony_ci    g_wifi->stop(g_wifi);
6769762338dSopenharmony_ci}
6779762338dSopenharmony_ci
6789762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetDeviceMacAddress002)->Iterations(100)->
6799762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
6809762338dSopenharmony_ci
6819762338dSopenharmony_ci/**
6829762338dSopenharmony_ci * @tc.name: WifiHaGetValidFreqsWithBand001
6839762338dSopenharmony_ci * @tc.desc: Get available frequencies
6849762338dSopenharmony_ci * @tc.type: FUNC
6859762338dSopenharmony_ci */
6869762338dSopenharmony_ci
6879762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, WifiHalgetValidFreqsWithBand001)(
6889762338dSopenharmony_ci    benchmark::State &st)
6899762338dSopenharmony_ci{
6909762338dSopenharmony_ci    g_wifi->start(g_wifi);
6919762338dSopenharmony_ci    int ret;
6929762338dSopenharmony_ci    struct IWiFiAp *apFeature = nullptr;
6939762338dSopenharmony_ci    int32_t freq[WLAN_FREQ_MAX_NUM] = {0};
6949762338dSopenharmony_ci    uint32_t num = 0;
6959762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
6969762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
6979762338dSopenharmony_ci    EXPECT_NE(nullptr, apFeature);
6989762338dSopenharmony_ci    ret = apFeature->baseFeature.getValidFreqsWithBand((struct IWiFiBaseFeature *)apFeature,
6999762338dSopenharmony_ci    WLAN_BAND_2G, nullptr, 0, nullptr);
7009762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
7019762338dSopenharmony_ci    for (auto _ : st) {
7029762338dSopenharmony_ci        ret = apFeature->baseFeature.getValidFreqsWithBand((struct IWiFiBaseFeature *)apFeature,
7039762338dSopenharmony_ci            WLAN_BAND_2G, freq, WLAN_FREQ_MAX_NUM, &num);
7049762338dSopenharmony_ci    }
7059762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
7069762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
7079762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
7089762338dSopenharmony_ci    g_wifi->stop(g_wifi);
7099762338dSopenharmony_ci}
7109762338dSopenharmony_ci
7119762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetValidFreqsWithBand001)->Iterations(100)->
7129762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
7139762338dSopenharmony_ci
7149762338dSopenharmony_ci/**
7159762338dSopenharmony_ci * @tc.name: WifiHalGetAssociatedStas001
7169762338dSopenharmony_ci * @tc.desc: Get asscociated STA info benchmark test
7179762338dSopenharmony_ci * @tc.type: FUNC
7189762338dSopenharmony_ci */
7199762338dSopenharmony_ci
7209762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, WifiHalgetAssociatedStas001)(
7219762338dSopenharmony_ci    benchmark::State &st)
7229762338dSopenharmony_ci{
7239762338dSopenharmony_ci    g_wifi->start(g_wifi);
7249762338dSopenharmony_ci    int ret;
7259762338dSopenharmony_ci    struct IWiFiAp *apFeature = nullptr;
7269762338dSopenharmony_ci    struct StaInfo staInfo[WLAN_MAX_NUM_STA_WITH_AP] = {{0}};
7279762338dSopenharmony_ci    uint32_t num = 0;
7289762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
7299762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
7309762338dSopenharmony_ci    EXPECT_NE(nullptr, apFeature);
7319762338dSopenharmony_ci    ret = apFeature->getAssociatedStas(apFeature, nullptr, 0, nullptr);
7329762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
7339762338dSopenharmony_ci    for (auto _ : st) {
7349762338dSopenharmony_ci        ret = apFeature->getAssociatedStas(apFeature, staInfo, WLAN_MAX_NUM_STA_WITH_AP, &num);
7359762338dSopenharmony_ci    }
7369762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
7379762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
7389762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
7399762338dSopenharmony_ci    g_wifi->stop(g_wifi);
7409762338dSopenharmony_ci}
7419762338dSopenharmony_ci
7429762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetAssociatedStas001)->Iterations(100)->
7439762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
7449762338dSopenharmony_ci
7459762338dSopenharmony_ci/**
7469762338dSopenharmony_ci * @tc.name: WifiHalSetScanningMacAddress001
7479762338dSopenharmony_ci * @tc.desc: Set Mac address scanning benchmark test
7489762338dSopenharmony_ci * @tc.type: FUNC
7499762338dSopenharmony_ci */
7509762338dSopenharmony_ci
7519762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, WifiHalsetScanningMacAddress001)(
7529762338dSopenharmony_ci    benchmark::State &st)
7539762338dSopenharmony_ci{
7549762338dSopenharmony_ci    g_wifi->start(g_wifi);
7559762338dSopenharmony_ci    int ret;
7569762338dSopenharmony_ci    struct IWiFiSta *staFeature = nullptr;
7579762338dSopenharmony_ci    unsigned char scanMac[ETH_ADDR_LEN] = {0x12, 0x34, 0x56, 0x78, 0xab, 0xcd};
7589762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_STATION, (struct IWiFiBaseFeature **)&staFeature);
7599762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
7609762338dSopenharmony_ci    EXPECT_NE(nullptr, staFeature);
7619762338dSopenharmony_ci    ret = staFeature->setScanningMacAddress(staFeature, nullptr, 0);
7629762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
7639762338dSopenharmony_ci    for (auto _ : st) {
7649762338dSopenharmony_ci        ret = staFeature->setScanningMacAddress(staFeature, scanMac, ETH_ADDR_LEN);
7659762338dSopenharmony_ci    }
7669762338dSopenharmony_ci    EXPECT_EQ(HDF_ERR_NOT_SUPPORT, ret);
7679762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)staFeature);
7689762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
7699762338dSopenharmony_ci    g_wifi->stop(g_wifi);
7709762338dSopenharmony_ci}
7719762338dSopenharmony_ci
7729762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalsetScanningMacAddress001)->Iterations(100)->
7739762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
7749762338dSopenharmony_ci
7759762338dSopenharmony_ci/**
7769762338dSopenharmony_ci * @tc.name: WifiHalGetNetdevInfo001
7779762338dSopenharmony_ci * @tc.desc: Wifi hdi get netdev info benchmark test
7789762338dSopenharmony_ci * @tc.type: FUNC
7799762338dSopenharmony_ci */
7809762338dSopenharmony_ci
7819762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, WifiHalgetNetDevInfo001)(
7829762338dSopenharmony_ci    benchmark::State &st)
7839762338dSopenharmony_ci{
7849762338dSopenharmony_ci    g_wifi->start(g_wifi);
7859762338dSopenharmony_ci    int ret;
7869762338dSopenharmony_ci    struct NetDeviceInfoResult netDeviceInfoResult;
7879762338dSopenharmony_ci    (void)memset_s(&netDeviceInfoResult, sizeof(struct NetDeviceInfoResult), 0, sizeof(struct NetDeviceInfoResult));
7889762338dSopenharmony_ci    for (auto _ : st) {
7899762338dSopenharmony_ci        ret = g_wifi->getNetDevInfo(&netDeviceInfoResult);
7909762338dSopenharmony_ci    }
7919762338dSopenharmony_ci    EXPECT_EQ(ret, HDF_SUCCESS);
7929762338dSopenharmony_ci    g_wifi->stop(g_wifi);
7939762338dSopenharmony_ci}
7949762338dSopenharmony_ci
7959762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, WifiHalgetNetDevInfo001)->Iterations(100)->
7969762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
7979762338dSopenharmony_ci
7989762338dSopenharmony_ci
7999762338dSopenharmony_ci/**
8009762338dSopenharmony_ci * @tc.name: GetPowerModeTest001
8019762338dSopenharmony_ci * @tc.desc: Wifi hdi get power mode function test
8029762338dSopenharmony_ci * @tc.type: FUNC
8039762338dSopenharmony_ci */
8049762338dSopenharmony_ci
8059762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, GetPowerMode001)(
8069762338dSopenharmony_ci    benchmark::State &st)
8079762338dSopenharmony_ci{
8089762338dSopenharmony_ci    g_wifi->start(g_wifi);
8099762338dSopenharmony_ci    int32_t ret;
8109762338dSopenharmony_ci    struct IWiFiAp *apFeature = nullptr;
8119762338dSopenharmony_ci    const char *ifName = "eth0";
8129762338dSopenharmony_ci    uint8_t mode;
8139762338dSopenharmony_ci
8149762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
8159762338dSopenharmony_ci    EXPECT_EQ(ret, HDF_SUCCESS);
8169762338dSopenharmony_ci    EXPECT_NE(apFeature, nullptr);
8179762338dSopenharmony_ci    for (auto _ : st) {
8189762338dSopenharmony_ci        ret = g_wifi->getPowerMode(nullptr, &mode);
8199762338dSopenharmony_ci    }
8209762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
8219762338dSopenharmony_ci    ret = g_wifi->getPowerMode(ifName, nullptr);
8229762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
8239762338dSopenharmony_ci    ret = g_wifi->getPowerMode(ifName, &mode);
8249762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
8259762338dSopenharmony_ci    ret = g_wifi->getPowerMode(apFeature->baseFeature.ifName, nullptr);
8269762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
8279762338dSopenharmony_ci    ret = g_wifi->getPowerMode(apFeature->baseFeature.ifName, &mode);
8289762338dSopenharmony_ci    bool flag = (ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
8299762338dSopenharmony_ci    ASSERT_TRUE(flag);
8309762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
8319762338dSopenharmony_ci    EXPECT_EQ(ret, HDF_SUCCESS);
8329762338dSopenharmony_ci    g_wifi->stop(g_wifi);
8339762338dSopenharmony_ci}
8349762338dSopenharmony_ci
8359762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, GetPowerMode001)->Iterations(100)->
8369762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
8379762338dSopenharmony_ci
8389762338dSopenharmony_ci/**
8399762338dSopenharmony_ci * @tc.name: SetPowerModeTest001
8409762338dSopenharmony_ci * @tc.desc: Wifi hdi set power mode function test
8419762338dSopenharmony_ci * @tc.type: FUNC
8429762338dSopenharmony_ci */
8439762338dSopenharmony_ci
8449762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, SetPowerModeTest001)(
8459762338dSopenharmony_ci    benchmark::State &st)
8469762338dSopenharmony_ci{
8479762338dSopenharmony_ci    g_wifi->start(g_wifi);
8489762338dSopenharmony_ci    int32_t ret;
8499762338dSopenharmony_ci    struct IWiFiAp *apFeature = nullptr;
8509762338dSopenharmony_ci    const char *ifName = "eth0";
8519762338dSopenharmony_ci
8529762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
8539762338dSopenharmony_ci    EXPECT_EQ(ret, HDF_SUCCESS);
8549762338dSopenharmony_ci    EXPECT_NE(apFeature, nullptr);
8559762338dSopenharmony_ci    ret = g_wifi->setPowerMode(nullptr, WIFI_POWER_MODE_SLEEPING);
8569762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
8579762338dSopenharmony_ci    ret = g_wifi->setPowerMode(ifName, WIFI_POWER_MODE_SLEEPING);
8589762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
8599762338dSopenharmony_ci    for (auto _ : st) {
8609762338dSopenharmony_ci        ret = g_wifi->setPowerMode(apFeature->baseFeature.ifName, WIFI_POWER_MODE_SLEEPING);
8619762338dSopenharmony_ci    }
8629762338dSopenharmony_ci    bool flag = (ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
8639762338dSopenharmony_ci    ASSERT_TRUE(flag);
8649762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
8659762338dSopenharmony_ci    EXPECT_EQ(ret, HDF_SUCCESS);
8669762338dSopenharmony_ci    g_wifi->stop(g_wifi);
8679762338dSopenharmony_ci}
8689762338dSopenharmony_ci
8699762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, SetPowerModeTest001)->Iterations(100)->
8709762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
8719762338dSopenharmony_ci
8729762338dSopenharmony_ci/**
8739762338dSopenharmony_ci * @tc.name: SetProjectionScreenParam001
8749762338dSopenharmony_ci * @tc.desc: wifi hal config projection screen function test
8759762338dSopenharmony_ci * @tc.type: FUNC
8769762338dSopenharmony_ci */
8779762338dSopenharmony_ci
8789762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, SetProjectionScreenParam001)(
8799762338dSopenharmony_ci    benchmark::State &st)
8809762338dSopenharmony_ci{
8819762338dSopenharmony_ci    g_wifi->start(g_wifi);
8829762338dSopenharmony_ci    int32_t ret;
8839762338dSopenharmony_ci    bool flag;
8849762338dSopenharmony_ci    struct IWiFiAp *apFeature = nullptr;
8859762338dSopenharmony_ci    ProjectionScreenParam *param;
8869762338dSopenharmony_ci
8879762338dSopenharmony_ci    param = (ProjectionScreenParam *)OsalMemCalloc(sizeof(ProjectionScreenParam) + TEST_PARAM_BUF_SIZE);
8889762338dSopenharmony_ci    EXPECT_NE(nullptr, param);
8899762338dSopenharmony_ci    param->cmdId = TEST_CMD;
8909762338dSopenharmony_ci    param->bufLen = 1;
8919762338dSopenharmony_ci    param->buf[0] = 0;
8929762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
8939762338dSopenharmony_ci    EXPECT_EQ(ret, HDF_SUCCESS);
8949762338dSopenharmony_ci    ret = g_wifi->setProjectionScreenParam(nullptr, nullptr);
8959762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
8969762338dSopenharmony_ci    ret = g_wifi->setProjectionScreenParam(apFeature->baseFeature.ifName, nullptr);
8979762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
8989762338dSopenharmony_ci    ret = g_wifi->setProjectionScreenParam(nullptr, param);
8999762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
9009762338dSopenharmony_ci    for (auto _ : st) {
9019762338dSopenharmony_ci    ret = g_wifi->setProjectionScreenParam(apFeature->baseFeature.ifName, param);
9029762338dSopenharmony_ci    }
9039762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
9049762338dSopenharmony_ci    for (int i = CMD_CLOSE_GO_CAC; i <= CMD_ID_CTRL_ROAM_CHANNEL; i++) {
9059762338dSopenharmony_ci        param->cmdId = i;
9069762338dSopenharmony_ci        ret = g_wifi->setProjectionScreenParam(apFeature->baseFeature.ifName, param);
9079762338dSopenharmony_ci        flag = (ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
9089762338dSopenharmony_ci        ASSERT_TRUE(flag);
9099762338dSopenharmony_ci    }
9109762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
9119762338dSopenharmony_ci    EXPECT_EQ(ret, HDF_SUCCESS);
9129762338dSopenharmony_ci    OsalMemFree(param);
9139762338dSopenharmony_ci    g_wifi->stop(g_wifi);
9149762338dSopenharmony_ci}
9159762338dSopenharmony_ci
9169762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, SetProjectionScreenParam001)->Iterations(100)->
9179762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
9189762338dSopenharmony_ci
9199762338dSopenharmony_ci
9209762338dSopenharmony_ci/**
9219762338dSopenharmony_ci * @tc.name: SendCmdIoctl001
9229762338dSopenharmony_ci * @tc.desc: wifi hal send ioctl command function test
9239762338dSopenharmony_ci * @tc.type: FUNC
9249762338dSopenharmony_ci */
9259762338dSopenharmony_ci
9269762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, SendCmdIoctl001)(
9279762338dSopenharmony_ci    benchmark::State &st)
9289762338dSopenharmony_ci{
9299762338dSopenharmony_ci    g_wifi->start(g_wifi);
9309762338dSopenharmony_ci    int32_t cmdId = 0;
9319762338dSopenharmony_ci    int32_t ret;
9329762338dSopenharmony_ci    bool flag;
9339762338dSopenharmony_ci    struct IWiFiAp *apFeature = nullptr;
9349762338dSopenharmony_ci    int8_t data[TEST_BUF_SIZE] = {0};
9359762338dSopenharmony_ci    const char *ifName = "wlan0";
9369762338dSopenharmony_ci
9379762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
9389762338dSopenharmony_ci    EXPECT_EQ(ret, HDF_SUCCESS);
9399762338dSopenharmony_ci    ret = g_wifi->sendCmdIoctl(nullptr, cmdId, nullptr, TEST_BUF_SIZE);
9409762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
9419762338dSopenharmony_ci    ret = g_wifi->sendCmdIoctl(ifName, cmdId, nullptr, TEST_BUF_SIZE);
9429762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
9439762338dSopenharmony_ci    for (auto _ : st) {
9449762338dSopenharmony_ci        ret = g_wifi->sendCmdIoctl(nullptr, cmdId, data, TEST_BUF_SIZE);
9459762338dSopenharmony_ci    }
9469762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
9479762338dSopenharmony_ci    for (cmdId = CMD_HID2D_MODULE_INIT; cmdId <= CMD_SET_CHAN_ADJUST; cmdId++) {
9489762338dSopenharmony_ci        ret = g_wifi->sendCmdIoctl(ifName, cmdId, data, TEST_BUF_SIZE);
9499762338dSopenharmony_ci        flag = (ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
9509762338dSopenharmony_ci        ASSERT_TRUE(flag);
9519762338dSopenharmony_ci    }
9529762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
9539762338dSopenharmony_ci    EXPECT_EQ(ret, HDF_SUCCESS);
9549762338dSopenharmony_ci    g_wifi->stop(g_wifi);
9559762338dSopenharmony_ci}
9569762338dSopenharmony_ci
9579762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, SendCmdIoctl001)->Iterations(100)->
9589762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
9599762338dSopenharmony_ci
9609762338dSopenharmony_ci/**
9619762338dSopenharmony_ci * @tc.name: GetStationInfo001
9629762338dSopenharmony_ci * @tc.desc: Wifi hdi get station information function test
9639762338dSopenharmony_ci * @tc.type: FUNC
9649762338dSopenharmony_ci */
9659762338dSopenharmony_ci
9669762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, GetStationInfo001)(
9679762338dSopenharmony_ci    benchmark::State &st)
9689762338dSopenharmony_ci{
9699762338dSopenharmony_ci    g_wifi->start(g_wifi);
9709762338dSopenharmony_ci    int32_t ret;
9719762338dSopenharmony_ci    StationInfo info;
9729762338dSopenharmony_ci    bool flag;
9739762338dSopenharmony_ci    uint8_t mac[ETH_ADDR_LEN] = {0};
9749762338dSopenharmony_ci    struct IWiFiAp *apFeature = nullptr;
9759762338dSopenharmony_ci    const char *ifName = "wlan0";
9769762338dSopenharmony_ci
9779762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
9789762338dSopenharmony_ci    EXPECT_EQ(ret, HDF_SUCCESS);
9799762338dSopenharmony_ci    ret = g_wifi->getStationInfo(nullptr, nullptr, nullptr, ETH_ADDR_LEN);
9809762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
9819762338dSopenharmony_ci    ret = g_wifi->getStationInfo(ifName, nullptr, nullptr, ETH_ADDR_LEN);
9829762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
9839762338dSopenharmony_ci    ret = g_wifi->getStationInfo(nullptr, &info, nullptr, ETH_ADDR_LEN);
9849762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
9859762338dSopenharmony_ci    ret = g_wifi->getStationInfo(nullptr, nullptr, mac, ETH_ADDR_LEN);
9869762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
9879762338dSopenharmony_ci    ret = g_wifi->getStationInfo(ifName, &info, nullptr, ETH_ADDR_LEN);
9889762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
9899762338dSopenharmony_ci    ret = g_wifi->getStationInfo(nullptr, &info, mac, ETH_ADDR_LEN);
9909762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
9919762338dSopenharmony_ci    ret = g_wifi->getStationInfo(ifName, nullptr, mac, ETH_ADDR_LEN);
9929762338dSopenharmony_ci    EXPECT_NE(ret, HDF_SUCCESS);
9939762338dSopenharmony_ci    for (auto _ : st) {
9949762338dSopenharmony_ci        ret = g_wifi->getStationInfo(ifName, &info, mac, ETH_ADDR_LEN);
9959762338dSopenharmony_ci    }
9969762338dSopenharmony_ci    flag = (ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
9979762338dSopenharmony_ci    ASSERT_TRUE(flag);
9989762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
9999762338dSopenharmony_ci    EXPECT_EQ(ret, HDF_SUCCESS);
10009762338dSopenharmony_ci    g_wifi->stop(g_wifi);
10019762338dSopenharmony_ci}
10029762338dSopenharmony_ci
10039762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, GetStationInfo001)->Iterations(100)->
10049762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
10059762338dSopenharmony_ci
10069762338dSopenharmony_ci/**
10079762338dSopenharmony_ci * @tc.name: HalGetChipId001
10089762338dSopenharmony_ci * @tc.desc: wifi hal get chip ID function test
10099762338dSopenharmony_ci * @tc.type: FUNC
10109762338dSopenharmony_ci */
10119762338dSopenharmony_ci
10129762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, GetChipId001)(
10139762338dSopenharmony_ci    benchmark::State &st)
10149762338dSopenharmony_ci{
10159762338dSopenharmony_ci    g_wifi->start(g_wifi);
10169762338dSopenharmony_ci    int32_t ret;
10179762338dSopenharmony_ci    struct IWiFiSta *staFeature = nullptr;
10189762338dSopenharmony_ci    unsigned char chipId = 0;
10199762338dSopenharmony_ci
10209762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_STATION, (struct IWiFiBaseFeature **)&staFeature);
10219762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
10229762338dSopenharmony_ci    EXPECT_NE(nullptr, staFeature);
10239762338dSopenharmony_ci
10249762338dSopenharmony_ci    ret = staFeature->baseFeature.getChipId(nullptr, &chipId);
10259762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
10269762338dSopenharmony_ci    ret = staFeature->baseFeature.getChipId((struct IWiFiBaseFeature *)staFeature, nullptr);
10279762338dSopenharmony_ci    EXPECT_NE(HDF_SUCCESS, ret);
10289762338dSopenharmony_ci    for (auto _ : st) {
10299762338dSopenharmony_ci        ret = staFeature->baseFeature.getChipId((struct IWiFiBaseFeature *)staFeature, &chipId);
10309762338dSopenharmony_ci    }
10319762338dSopenharmony_ci    ASSERT_TRUE(chipId < MAX_WLAN_DEVICE);
10329762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
10339762338dSopenharmony_ci
10349762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)staFeature);
10359762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
10369762338dSopenharmony_ci    g_wifi->stop(g_wifi);
10379762338dSopenharmony_ci}
10389762338dSopenharmony_ci
10399762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, GetChipId001)->Iterations(100)->
10409762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
10419762338dSopenharmony_ci
10429762338dSopenharmony_ci/**
10439762338dSopenharmony_ci * @tc.name: ResetDriver001
10449762338dSopenharmony_ci * @tc.desc: wifi hal reset driver function test
10459762338dSopenharmony_ci * @tc.type: FUNC
10469762338dSopenharmony_ci */
10479762338dSopenharmony_ci
10489762338dSopenharmony_ciBENCHMARK_F(wlanBenchmarkTest, ResetDriver001)(
10499762338dSopenharmony_ci    benchmark::State &st)
10509762338dSopenharmony_ci{
10519762338dSopenharmony_ci    g_wifi->start(g_wifi);
10529762338dSopenharmony_ci    int32_t ret;
10539762338dSopenharmony_ci    struct IWiFiSta *staFeature = nullptr;
10549762338dSopenharmony_ci    uint8_t chipId = 0;
10559762338dSopenharmony_ci    uint8_t chipIdInvalid = 20;
10569762338dSopenharmony_ci
10579762338dSopenharmony_ci    ret = g_wifi->createFeature(PROTOCOL_80211_IFTYPE_STATION, (struct IWiFiBaseFeature **)&staFeature);
10589762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
10599762338dSopenharmony_ci    EXPECT_NE(nullptr, staFeature);
10609762338dSopenharmony_ci    ret = staFeature->baseFeature.getChipId((struct IWiFiBaseFeature *)staFeature, &chipId);
10619762338dSopenharmony_ci    ASSERT_TRUE(chipId < MAX_WLAN_DEVICE);
10629762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
10639762338dSopenharmony_ci    for (auto _ : st) {
10649762338dSopenharmony_ci        ret = g_wifi->resetDriver(chipIdInvalid, "wlan0");
10659762338dSopenharmony_ci    }
10669762338dSopenharmony_ci    EXPECT_EQ(HDF_ERR_INVALID_PARAM, ret);
10679762338dSopenharmony_ci    ret = g_wifi->resetDriver(chipId, nullptr);
10689762338dSopenharmony_ci    EXPECT_EQ(HDF_ERR_INVALID_PARAM, ret);
10699762338dSopenharmony_ci    ret = g_wifi->resetDriver(chipId, staFeature->baseFeature.ifName);
10709762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
10719762338dSopenharmony_ci    sleep(RESET_TIME);
10729762338dSopenharmony_ci    ret = g_wifi->destroyFeature((struct IWiFiBaseFeature *)staFeature);
10739762338dSopenharmony_ci    EXPECT_EQ(HDF_SUCCESS, ret);
10749762338dSopenharmony_ci    g_wifi->stop(g_wifi);
10759762338dSopenharmony_ci}
10769762338dSopenharmony_ci
10779762338dSopenharmony_ciBENCHMARK_REGISTER_F(wlanBenchmarkTest, ResetDriver001)->Iterations(100)->
10789762338dSopenharmony_ci    Repetitions(3)->ReportAggregatesOnly();
10799762338dSopenharmony_ci}
10809762338dSopenharmony_ciBENCHMARK_MAIN();
10819762338dSopenharmony_ci
1082