Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a8c1ca30 authored by Les Lee's avatar Les Lee Committed by Android (Google) Code Review
Browse files

Merge "wifi: Add VTS for wifi hal and hostapd hal."

parents 45eeae8a 90e6565e
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -14,6 +14,27 @@
// limitations under the License.
//

cc_library_static {
    name: "VtsHalWifiV1_5TargetTestUtil",
    defaults: ["VtsHalTargetTestDefaults"],
    srcs: [
        "wifi_hidl_test_utils_1_5.cpp",
    ],
    export_include_dirs: [
        ".",
    ],
    shared_libs: [
        "libnativehelper",
    ],
    static_libs: [
        "VtsHalWifiV1_0TargetTestUtil",
        "android.hardware.wifi@1.0",
        "android.hardware.wifi@1.3",
        "android.hardware.wifi@1.5",
        "libwifi-system-iface",
    ],
}

cc_test {
    name: "VtsHalWifiV1_5TargetTest",
    defaults: ["VtsHalTargetTestDefaults"],
@@ -67,9 +88,11 @@ cc_test {
    defaults: ["VtsHalTargetTestDefaults"],
    srcs: [
        "wifi_chip_hidl_ap_test.cpp",
        "wifi_ap_iface_hidl_test.cpp",
    ],
    static_libs: [
        "VtsHalWifiV1_0TargetTestUtil",
        "VtsHalWifiV1_5TargetTestUtil",
        "android.hardware.wifi@1.0",
        "android.hardware.wifi@1.1",
        "android.hardware.wifi@1.2",
+97 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <VtsCoreUtil.h>
#include <VtsHalHidlTargetCallbackBase.h>
#include <android-base/logging.h>

#undef NAN  // NAN is defined in bionic/libc/include/math.h:38

#include <android/hardware/wifi/1.4/IWifiChipEventCallback.h>
#include <android/hardware/wifi/1.5/IWifi.h>
#include <android/hardware/wifi/1.5/IWifiApIface.h>
#include <android/hardware/wifi/1.5/IWifiChip.h>
#include <gtest/gtest.h>
#include <hidl/GtestPrinter.h>
#include <hidl/ServiceManagement.h>

#include "wifi_hidl_call_util.h"
#include "wifi_hidl_test_utils.h"
#include "wifi_hidl_test_utils_1_5.h"

using ::android::sp;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::wifi::V1_0::ChipModeId;
using ::android::hardware::wifi::V1_0::IfaceType;
using ::android::hardware::wifi::V1_0::IWifiIface;
using ::android::hardware::wifi::V1_0::WifiDebugRingBufferStatus;
using ::android::hardware::wifi::V1_0::WifiStatus;
using ::android::hardware::wifi::V1_0::WifiStatusCode;
using ::android::hardware::wifi::V1_4::IWifiChipEventCallback;
using ::android::hardware::wifi::V1_5::IWifiApIface;
using ::android::hardware::wifi::V1_5::IWifiChip;

/**
 * Fixture for IWifiChip tests that are conditioned on SoftAP support.
 */
class WifiApIfaceHidlTest : public ::testing::TestWithParam<std::string> {
   public:
    virtual void SetUp() override {
        isBridgedSupport_ = testing::checkSubstringInCommandOutput(
            "/system/bin/cmd wifi get-softap-supported-features",
            "wifi_softap_bridged_ap_supported");
        // Make sure to start with a clean state
        stopWifi(GetInstanceName());
    }

    virtual void TearDown() override { stopWifi(GetInstanceName()); }

   protected:
    bool isBridgedSupport_ = false;
    std::string GetInstanceName() { return GetParam(); }
};

/*
 * resetToFactoryMacAddress
 */
TEST_P(WifiApIfaceHidlTest, resetToFactoryMacAddressInBridgedModeTest) {
    if (!isBridgedSupport_) GTEST_SKIP() << "Missing Bridged AP support";
    sp<IWifiApIface> wifi_ap_iface =
        getBridgedWifiApIface_1_5(GetInstanceName());
    ASSERT_NE(nullptr, wifi_ap_iface.get());
    const auto& status = HIDL_INVOKE(wifi_ap_iface, resetToFactoryMacAddress);
    EXPECT_EQ(WifiStatusCode::SUCCESS, status.code);
}

/*
 * resetToFactoryMacAddress
 */
TEST_P(WifiApIfaceHidlTest, resetToFactoryMacAddressTest) {
    sp<IWifiApIface> wifi_ap_iface = getWifiApIface_1_5(GetInstanceName());
    ASSERT_NE(nullptr, wifi_ap_iface.get());
    const auto& status = HIDL_INVOKE(wifi_ap_iface, resetToFactoryMacAddress);
    EXPECT_EQ(WifiStatusCode::SUCCESS, status.code);
}

GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(WifiApIfaceHidlTest);
INSTANTIATE_TEST_SUITE_P(
    PerInstance, WifiApIfaceHidlTest,
    testing::ValuesIn(android::hardware::getAllHalInstanceNames(
        ::android::hardware::wifi::V1_5::IWifi::descriptor)),
    android::hardware::PrintInstanceNameToString);
+24 −20
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
 * limitations under the License.
 */

#include <VtsCoreUtil.h>
#include <VtsHalHidlTargetCallbackBase.h>
#include <android-base/logging.h>

@@ -51,6 +52,9 @@ using ::android::hardware::wifi::V1_5::IWifiChip;
class WifiChipHidlTest : public ::testing::TestWithParam<std::string> {
   public:
    virtual void SetUp() override {
        isBridgedSupport_ = testing::checkSubstringInCommandOutput(
            "/system/bin/cmd wifi get-softap-supported-features",
            "wifi_softap_bridged_ap_supported");
        // Make sure to start with a clean state
        stopWifi(GetInstanceName());

@@ -61,6 +65,7 @@ class WifiChipHidlTest : public ::testing::TestWithParam<std::string> {
    virtual void TearDown() override { stopWifi(GetInstanceName()); }

   protected:
    bool isBridgedSupport_ = false;
    // Helper function to configure the Chip in one of the supported modes.
    // Most of the non-mode-configuration-related methods require chip
    // to be first configured.
@@ -71,19 +76,12 @@ class WifiChipHidlTest : public ::testing::TestWithParam<std::string> {
        return mode_id;
    }

    WifiStatusCode createApIface(sp<IWifiApIface>* ap_iface) {
        configureChipForIfaceType(IfaceType::AP, true);
        const auto& status_and_iface = HIDL_INVOKE(wifi_chip_, createApIface);
        *ap_iface = IWifiApIface::castFrom(status_and_iface.second);
        return status_and_iface.first.code;
    }

    WifiStatusCode createBridgedApIface(sp<IWifiApIface>* ap_iface) {
    void createBridgedApIface(sp<IWifiApIface>* ap_iface) {
        configureChipForIfaceType(IfaceType::AP, true);
        const auto& status_and_iface =
            HIDL_INVOKE(wifi_chip_, createBridgedApIface);
        *ap_iface = status_and_iface.second;
        return status_and_iface.first.code;
        EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_iface.first.code);
    }

    sp<IWifiChip> wifi_chip_;
@@ -92,19 +90,25 @@ class WifiChipHidlTest : public ::testing::TestWithParam<std::string> {
    std::string GetInstanceName() { return GetParam(); }
};

// TODO: b/173999527. Add test for bridged API.

/*
 * resetToFactoryMacAddress
/**
 * createBridgedApIface & removeIfaceInstanceFromBridgedApIface
 */
TEST_P(WifiChipHidlTest, resetToFactoryMacAddressTest) {
TEST_P(WifiChipHidlTest,
       createBridgedApIfaceAndremoveIfaceInstanceFromBridgedApIfaceTest) {
    if (!isBridgedSupport_) GTEST_SKIP() << "Missing Bridged AP support";
    sp<IWifiApIface> wifi_ap_iface;
    const auto& status_code = createApIface(&wifi_ap_iface);
    if (status_code != WifiStatusCode::SUCCESS) {
        EXPECT_EQ(WifiStatusCode::ERROR_NOT_SUPPORTED, status_code);
    }
    const auto& status = HIDL_INVOKE(wifi_ap_iface, resetToFactoryMacAddress);
    EXPECT_EQ(WifiStatusCode::SUCCESS, status.code);
    createBridgedApIface(&wifi_ap_iface);
    ASSERT_NE(nullptr, wifi_ap_iface.get());
    const auto& status_and_name = HIDL_INVOKE(wifi_ap_iface, getName);
    EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_name.first.code);
    // TODO: b/173999527, add API to get instance name to replace it.
    std::string br_name = status_and_name.second;  // ap_br_ is the pre-fix
    std::string instance_name =
        br_name.substr(6, br_name.length());  // remove the pre-fex
    const auto& status_code =
        HIDL_INVOKE(wifi_chip_, removeIfaceInstanceFromBridgedApIface, br_name,
                    instance_name);
    EXPECT_EQ(WifiStatusCode::SUCCESS, status_code.code);
}

GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(WifiChipHidlTest);
+61 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <VtsHalHidlTargetCallbackBase.h>
#include <android-base/logging.h>

#undef NAN  // NAN is defined in bionic/libc/include/math.h:38

#include <android/hardware/wifi/1.5/IWifi.h>
#include <android/hardware/wifi/1.5/IWifiApIface.h>
#include <android/hardware/wifi/1.5/IWifiChip.h>
#include <gtest/gtest.h>
#include <hidl/GtestPrinter.h>
#include <hidl/ServiceManagement.h>

#include "wifi_hidl_call_util.h"
#include "wifi_hidl_test_utils.h"

using ::android::sp;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::wifi::V1_0::ChipModeId;
using ::android::hardware::wifi::V1_0::IfaceType;
using ::android::hardware::wifi::V1_5::IWifiApIface;
using ::android::hardware::wifi::V1_5::IWifiChip;

sp<IWifiChip> getWifiChip_1_5(const std::string& instance_name) {
    return IWifiChip::castFrom(getWifiChip(instance_name));
}

sp<IWifiApIface> getWifiApIface_1_5(const std::string& instance_name) {
    ChipModeId mode_id;
    sp<IWifiChip> wifi_chip_ = getWifiChip_1_5(instance_name);
    configureChipToSupportIfaceType(wifi_chip_, IfaceType::AP, &mode_id);
    const auto& status_and_iface = HIDL_INVOKE(wifi_chip_, createApIface);
    return IWifiApIface::castFrom(status_and_iface.second);
}

sp<IWifiApIface> getBridgedWifiApIface_1_5(const std::string& instance_name) {
    ChipModeId mode_id;
    sp<IWifiChip> wifi_chip_ = getWifiChip_1_5(instance_name);
    configureChipToSupportIfaceType(wifi_chip_, IfaceType::AP, &mode_id);
    const auto& status_and_iface =
        HIDL_INVOKE(wifi_chip_, createBridgedApIface);
    return IWifiApIface::castFrom(status_and_iface.second);
}
+35 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <android/hardware/wifi/1.5/IWifi.h>
#include <android/hardware/wifi/1.5/IWifiApIface.h>
#include <android/hardware/wifi/1.5/IWifiChip.h>

#include <getopt.h>

#include <VtsHalHidlTargetTestEnvBase.h>
// Helper functions to obtain references to the various HIDL interface objects.
// Note: We only have a single instance of each of these objects currently.
// These helper functions should be modified to return vectors if we support
// multiple instances.
android::sp<android::hardware::wifi::V1_5::IWifiChip> getWifiChip_1_5(
    const std::string& instance_name);
android::sp<android::hardware::wifi::V1_5::IWifiApIface> getWifiApIface_1_5(
    const std::string& instance_name);
android::sp<android::hardware::wifi::V1_5::IWifiApIface>
getBridgedWifiApIface_1_5(const std::string& instance_name);
Loading