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

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

Merge "wifi: Support use "non-primy interface when testing hostapd Hal"

parents 7e9f34d5 78a04d6b
Loading
Loading
Loading
Loading
+18 −61
Original line number Diff line number Diff line
@@ -81,10 +81,9 @@ class HostapdHidlTest

    virtual void TearDown() override {
        HIDL_INVOKE_VOID_WITHOUT_ARGUMENTS(hostapd_, terminate);
        stopHostapd(wifi_instance_name_);
        // Wait 3 seconds to allow driver processing load/unload between two
        // test cases.
        //  Wait 3 seconds to allow terminate processing before kill hostapd.
        sleep(3);
        stopHostapd(wifi_instance_name_);
    }

   protected:
@@ -106,16 +105,6 @@ class HostapdHidlTest
        return status_and_name.second;
    }

    // TODO: b/177483254, remove it after fix wlan1 failure case.
    std::string getPrimaryWlanIfaceName() {
        std::array<char, PROPERTY_VALUE_MAX> buffer;
        auto res = property_get("ro.vendor.wifi.sap.interface", buffer.data(),
                                nullptr);
        if (res > 0) return buffer.data();
        property_get("wifi.interface", buffer.data(), "wlan0");
        return buffer.data();
    }

    IHostapd::IfaceParams getIfaceParamsWithoutAcs(std::string iface_name) {
        ::android::hardware::wifi::hostapd::V1_0::IHostapd::IfaceParams
            iface_params;
@@ -334,9 +323,7 @@ class HostapdHidlTest
 */
TEST_P(HostapdHidlTest, AddPskAccessPointWithAcs) {
    if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support";
    // TODO: Use setupApIfaceAndGetName after fixing b/177483254
    // std::string ifname = setupApIfaceAndGetName(false);
    std::string ifname = getPrimaryWlanIfaceName();
    std::string ifname = setupApIfaceAndGetName(false);
    auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_3,
                              getIfaceParamsWithAcs(ifname), getPskNwParams());
    EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
@@ -348,9 +335,7 @@ TEST_P(HostapdHidlTest, AddPskAccessPointWithAcs) {
 */
TEST_P(HostapdHidlTest, AddPskAccessPointWithAcsAndFreqRange) {
    if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support";
    // TODO: Use setupApIfaceAndGetName after fixing b/177483254
    // std::string ifname = setupApIfaceAndGetName(false);
    std::string ifname = getPrimaryWlanIfaceName();
    std::string ifname = setupApIfaceAndGetName(false);
    auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_3,
                              getIfaceParamsWithAcsAndFreqRange(ifname),
                              getPskNwParams());
@@ -363,9 +348,7 @@ TEST_P(HostapdHidlTest, AddPskAccessPointWithAcsAndFreqRange) {
 */
TEST_P(HostapdHidlTest, AddPskAccessPointWithAcsAndInvalidFreqRange) {
    if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support";
    // TODO: Use setupApIfaceAndGetName after fixing b/177483254
    // std::string ifname = setupApIfaceAndGetName(false);
    std::string ifname = getPrimaryWlanIfaceName();
    std::string ifname = setupApIfaceAndGetName(false);
    auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_3,
                              getIfaceParamsWithAcsAndInvalidFreqRange(ifname),
                              getPskNwParams());
@@ -378,9 +361,7 @@ TEST_P(HostapdHidlTest, AddPskAccessPointWithAcsAndInvalidFreqRange) {
 */
TEST_P(HostapdHidlTest, AddOpenAccessPointWithAcs) {
    if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support";
    // TODO: Use setupApIfaceAndGetName after fixing b/177483254
    // std::string ifname = setupApIfaceAndGetName(false);
    std::string ifname = getPrimaryWlanIfaceName();
    std::string ifname = setupApIfaceAndGetName(false);
    auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_3,
                              getIfaceParamsWithAcs(ifname), getOpenNwParams());
    EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
@@ -391,9 +372,7 @@ TEST_P(HostapdHidlTest, AddOpenAccessPointWithAcs) {
 * Access point creation should pass.
 */
TEST_P(HostapdHidlTest, AddPskAccessPointWithoutAcs) {
    // TODO: Use setupApIfaceAndGetName after fixing b/177483254
    // std::string ifname = setupApIfaceAndGetName(false);
    std::string ifname = getPrimaryWlanIfaceName();
    std::string ifname = setupApIfaceAndGetName(false);
    auto status =
        HIDL_INVOKE(hostapd_, addAccessPoint_1_3,
                    getIfaceParamsWithoutAcs(ifname), getPskNwParams());
@@ -405,9 +384,7 @@ TEST_P(HostapdHidlTest, AddPskAccessPointWithoutAcs) {
 * Access point creation should pass.
 */
TEST_P(HostapdHidlTest, AddPskAccessPointWithoutAcsAndNonMetered) {
    // TODO: Use setupApIfaceAndGetName after fixing b/177483254
    // std::string ifname = setupApIfaceAndGetName(false);
    std::string ifname = getPrimaryWlanIfaceName();
    std::string ifname = setupApIfaceAndGetName(false);
    auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_3,
                              getIfaceParamsWithoutAcs(ifname),
                              getPskNwParamsWithNonMetered());
@@ -419,9 +396,7 @@ TEST_P(HostapdHidlTest, AddPskAccessPointWithoutAcsAndNonMetered) {
 * Access point creation should pass.
 */
TEST_P(HostapdHidlTest, AddOpenAccessPointWithoutAcs) {
    // TODO: Use setupApIfaceAndGetName after fixing b/177483254
    // std::string ifname = setupApIfaceAndGetName(false);
    std::string ifname = getPrimaryWlanIfaceName();
    std::string ifname = setupApIfaceAndGetName(false);
    auto status =
        HIDL_INVOKE(hostapd_, addAccessPoint_1_3,
                    getIfaceParamsWithoutAcs(ifname), getOpenNwParams());
@@ -434,9 +409,7 @@ TEST_P(HostapdHidlTest, AddOpenAccessPointWithoutAcs) {
 */
TEST_P(HostapdHidlTest, AddSaeTransitionAccessPointWithoutAcs) {
    if (!isWpa3SaeSupport_) GTEST_SKIP() << "Missing SAE support";
    // TODO: Use setupApIfaceAndGetName after fixing b/177483254
    // std::string ifname = setupApIfaceAndGetName(false);
    std::string ifname = getPrimaryWlanIfaceName();
    std::string ifname = setupApIfaceAndGetName(false);
    auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_3,
                              getIfaceParamsWithoutAcs(ifname),
                              getSaeTransitionNwParams());
@@ -449,9 +422,7 @@ TEST_P(HostapdHidlTest, AddSaeTransitionAccessPointWithoutAcs) {
 */
TEST_P(HostapdHidlTest, AddSAEAccessPointWithoutAcs) {
    if (!isWpa3SaeSupport_) GTEST_SKIP() << "Missing SAE support";
    // TODO: Use setupApIfaceAndGetName after fixing b/177483254
    // std::string ifname = setupApIfaceAndGetName(false);
    std::string ifname = getPrimaryWlanIfaceName();
    std::string ifname = setupApIfaceAndGetName(false);
    auto status =
        HIDL_INVOKE(hostapd_, addAccessPoint_1_3,
                    getIfaceParamsWithoutAcs(ifname), getSaeNwParams());
@@ -464,9 +435,7 @@ TEST_P(HostapdHidlTest, AddSAEAccessPointWithoutAcs) {
 */
TEST_P(HostapdHidlTest, RemoveAccessPointWithAcs) {
    if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support";
    // TODO: Use setupApIfaceAndGetName after fixing b/177483254
    // std::string ifname = setupApIfaceAndGetName(false);
    std::string ifname = getPrimaryWlanIfaceName();
    std::string ifname = setupApIfaceAndGetName(false);
    auto status_1_2 =
        HIDL_INVOKE(hostapd_, addAccessPoint_1_3, getIfaceParamsWithAcs(ifname),
                    getPskNwParams());
@@ -482,9 +451,7 @@ TEST_P(HostapdHidlTest, RemoveAccessPointWithAcs) {
 * Access point creation & removal should pass.
 */
TEST_P(HostapdHidlTest, RemoveAccessPointWithoutAcs) {
    // TODO: Use setupApIfaceAndGetName after fixing b/177483254
    // std::string ifname = setupApIfaceAndGetName(false);
    std::string ifname = getPrimaryWlanIfaceName();
    std::string ifname = setupApIfaceAndGetName(false);
    auto status_1_2 =
        HIDL_INVOKE(hostapd_, addAccessPoint_1_3,
                    getIfaceParamsWithoutAcs(ifname), getPskNwParams());
@@ -500,9 +467,7 @@ TEST_P(HostapdHidlTest, RemoveAccessPointWithoutAcs) {
 * Access point creation should fail.
 */
TEST_P(HostapdHidlTest, AddPskAccessPointWithInvalidChannel) {
    // TODO: Use setupApIfaceAndGetName after fixing b/177483254
    // std::string ifname = setupApIfaceAndGetName(false);
    std::string ifname = getPrimaryWlanIfaceName();
    std::string ifname = setupApIfaceAndGetName(false);
    auto status =
        HIDL_INVOKE(hostapd_, addAccessPoint_1_3,
                    getIfaceParamsWithInvalidChannel(ifname), getPskNwParams());
@@ -514,9 +479,7 @@ TEST_P(HostapdHidlTest, AddPskAccessPointWithInvalidChannel) {
 * Access point creation should fail.
 */
TEST_P(HostapdHidlTest, AddInvalidPskAccessPointWithoutAcs) {
    // TODO: Use setupApIfaceAndGetName after fixing b/177483254
    // std::string ifname = setupApIfaceAndGetName(false);
    std::string ifname = getPrimaryWlanIfaceName();
    std::string ifname = setupApIfaceAndGetName(false);
    auto status =
        HIDL_INVOKE(hostapd_, addAccessPoint_1_3,
                    getIfaceParamsWithoutAcs(ifname), getInvalidPskNwParams());
@@ -529,9 +492,7 @@ TEST_P(HostapdHidlTest, AddInvalidPskAccessPointWithoutAcs) {
 */
TEST_P(HostapdHidlTest, AddInvalidSaeTransitionAccessPointWithoutAcs) {
    if (!isWpa3SaeSupport_) GTEST_SKIP() << "Missing SAE support";
    // TODO: Use setupApIfaceAndGetName after fixing b/177483254
    // std::string ifname = setupApIfaceAndGetName(false);
    std::string ifname = getPrimaryWlanIfaceName();
    std::string ifname = setupApIfaceAndGetName(false);
    auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_3,
                              getIfaceParamsWithoutAcs(ifname),
                              getInvalidSaeTransitionNwParams());
@@ -544,9 +505,7 @@ TEST_P(HostapdHidlTest, AddInvalidSaeTransitionAccessPointWithoutAcs) {
 */
TEST_P(HostapdHidlTest, AddInvalidSaeAccessPointWithoutAcs) {
    if (!isWpa3SaeSupport_) GTEST_SKIP() << "Missing SAE support";
    // TODO: Use setupApIfaceAndGetName after fixing b/177483254
    // std::string ifname = setupApIfaceAndGetName(false);
    std::string ifname = getPrimaryWlanIfaceName();
    std::string ifname = setupApIfaceAndGetName(false);
    auto status =
        HIDL_INVOKE(hostapd_, addAccessPoint_1_3,
                    getIfaceParamsWithoutAcs(ifname), getInvalidSaeNwParams());
@@ -558,9 +517,7 @@ TEST_P(HostapdHidlTest, AddInvalidSaeAccessPointWithoutAcs) {
 * when hotspot interface available.
 */
TEST_P(HostapdHidlTest, DisconnectClientWhenIfacAvailable) {
    // TODO: Use setupApIfaceAndGetName after fixing b/177483254
    // std::string ifname = setupApIfaceAndGetName(false);
    std::string ifname = getPrimaryWlanIfaceName();
    std::string ifname = setupApIfaceAndGetName(false);
    auto status_1_2 =
        HIDL_INVOKE(hostapd_, addAccessPoint_1_3,
                    getIfaceParamsWithoutAcs(ifname), getOpenNwParams());