mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Remove dependencies on the HIDL Vendor HAL from
the hostapd and supplicant VTS tests.
Bug: 205044134
Test: atest VtsHalHostapdTargetTest
atest VtsHalWifiSupplicantStaIfaceTargetTest \
VtsHalWifiSupplicantStaNetworkTargetTest \
VtsHalWifiSupplicantP2pIfaceTargetTest
Change-Id: Ibdc5ea1f482a5c886029e5048d884ac15ac4d56e
This commit is contained in:
@@ -20,20 +20,10 @@ cc_test {
|
||||
"libvndksupport",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.wifi-V1-ndk",
|
||||
"android.hardware.wifi.hostapd-V1-ndk",
|
||||
"VtsHalWifiV1_0TargetTestUtil",
|
||||
"VtsHalWifiV1_5TargetTestUtil",
|
||||
"VtsHalWifiHostapdV1_0TargetTestUtil",
|
||||
"android.hardware.wifi.hostapd@1.0",
|
||||
"android.hardware.wifi.hostapd@1.1",
|
||||
"android.hardware.wifi.hostapd@1.2",
|
||||
"android.hardware.wifi.hostapd@1.3",
|
||||
"android.hardware.wifi@1.0",
|
||||
"android.hardware.wifi@1.1",
|
||||
"android.hardware.wifi@1.2",
|
||||
"android.hardware.wifi@1.3",
|
||||
"android.hardware.wifi@1.4",
|
||||
"android.hardware.wifi@1.5",
|
||||
"libwifi-system-iface",
|
||||
"VtsHalWifiTargetTestUtil",
|
||||
],
|
||||
test_suites: [
|
||||
"general-tests",
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <android/hardware/wifi/1.0/IWifi.h>
|
||||
#include <android/hardware/wifi/hostapd/1.3/IHostapd.h>
|
||||
#include <aidl/android/hardware/wifi/IWifi.h>
|
||||
|
||||
#include <VtsCoreUtil.h>
|
||||
#include <aidl/Gtest.h>
|
||||
@@ -24,12 +23,11 @@
|
||||
#include <android/binder_manager.h>
|
||||
#include <binder/IServiceManager.h>
|
||||
#include <binder/ProcessState.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
#include <hostapd_hidl_call_util.h>
|
||||
#include <hostapd_hidl_test_utils.h>
|
||||
#include <wifi_hidl_test_utils.h>
|
||||
#include <wifi_hidl_test_utils_1_5.h>
|
||||
|
||||
#include "wifi_aidl_test_utils.h"
|
||||
|
||||
using aidl::android::hardware::wifi::IWifi;
|
||||
using aidl::android::hardware::wifi::IWifiApIface;
|
||||
using aidl::android::hardware::wifi::hostapd::BandMask;
|
||||
using aidl::android::hardware::wifi::hostapd::BnHostapdCallback;
|
||||
using aidl::android::hardware::wifi::hostapd::ChannelBandwidth;
|
||||
@@ -44,6 +42,8 @@ using aidl::android::hardware::wifi::hostapd::NetworkParams;
|
||||
using android::ProcessState;
|
||||
|
||||
namespace {
|
||||
const std::string kWifiInstanceNameStr = std::string() + IWifi::descriptor + "/default";
|
||||
const char* kWifiInstanceName = kWifiInstanceNameStr.c_str();
|
||||
const unsigned char kNwSsid[] = {'t', 'e', 's', 't', '1', '2', '3', '4', '5'};
|
||||
const std::string kPassphrase = "test12345";
|
||||
const std::string kInvalidMinPassphrase = "test";
|
||||
@@ -75,17 +75,13 @@ class HostapdAidl : public testing::TestWithParam<std::string> {
|
||||
"/system/bin/cmd wifi get-softap-supported-features",
|
||||
"wifi_softap_wpa3_sae_supported");
|
||||
isBridgedSupport = testing::checkSubstringInCommandOutput(
|
||||
"/system/bin/cmd wifi get-softap-supported-features",
|
||||
"wifi_softap_bridged_ap_supported");
|
||||
const std::vector<std::string> instances = android::hardware::getAllHalInstanceNames(
|
||||
::android::hardware::wifi::V1_0::IWifi::descriptor);
|
||||
EXPECT_NE(0, instances.size());
|
||||
wifiInstanceName = instances[0];
|
||||
"/system/bin/cmd wifi get-softap-supported-features",
|
||||
"wifi_softap_bridged_ap_supported");
|
||||
}
|
||||
|
||||
virtual void TearDown() override {
|
||||
if (getWifi(wifiInstanceName) != nullptr) {
|
||||
stopWifi(wifiInstanceName);
|
||||
if (getWifi(kWifiInstanceName) != nullptr) {
|
||||
stopWifiService(kWifiInstanceName);
|
||||
}
|
||||
hostapd->terminate();
|
||||
// Wait 3 seconds to allow terminate to complete
|
||||
@@ -93,24 +89,23 @@ class HostapdAidl : public testing::TestWithParam<std::string> {
|
||||
}
|
||||
|
||||
std::shared_ptr<IHostapd> hostapd;
|
||||
std::string wifiInstanceName;
|
||||
bool isAcsSupport;
|
||||
bool isWpa3SaeSupport;
|
||||
bool isBridgedSupport;
|
||||
|
||||
std::string setupApIfaceAndGetName(bool isBridged) {
|
||||
android::sp<::android::hardware::wifi::V1_0::IWifiApIface> wifi_ap_iface;
|
||||
std::shared_ptr<IWifiApIface> wifi_ap_iface;
|
||||
if (isBridged) {
|
||||
wifi_ap_iface = getBridgedWifiApIface_1_5(wifiInstanceName);
|
||||
wifi_ap_iface = getBridgedWifiApIface(kWifiInstanceName);
|
||||
} else {
|
||||
wifi_ap_iface = getWifiApIface_1_5(wifiInstanceName);
|
||||
wifi_ap_iface = getWifiApIface(kWifiInstanceName);
|
||||
}
|
||||
EXPECT_NE(nullptr, wifi_ap_iface.get());
|
||||
|
||||
const auto& status_and_name = HIDL_INVOKE(wifi_ap_iface, getName);
|
||||
EXPECT_EQ(android::hardware::wifi::V1_0::WifiStatusCode::SUCCESS,
|
||||
status_and_name.first.code);
|
||||
return status_and_name.second;
|
||||
std::string ap_iface_name;
|
||||
auto status = wifi_ap_iface->getName(&ap_iface_name);
|
||||
EXPECT_TRUE(status.isOk());
|
||||
return ap_iface_name;
|
||||
}
|
||||
|
||||
IfaceParams getIfaceParamsWithoutAcs(std::string iface_name) {
|
||||
|
||||
@@ -36,20 +36,11 @@ cc_test {
|
||||
"libvndksupport",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.wifi@1.0",
|
||||
"android.hardware.wifi@1.1",
|
||||
"android.hardware.wifi@1.2",
|
||||
"android.hardware.wifi@1.3",
|
||||
"android.hardware.wifi@1.4",
|
||||
"android.hardware.wifi@1.5",
|
||||
"android.hardware.wifi.supplicant@1.0",
|
||||
"android.hardware.wifi.supplicant@1.1",
|
||||
"android.hardware.wifi-V1-ndk",
|
||||
"android.hardware.wifi.supplicant-V2-ndk",
|
||||
"libwifi-system",
|
||||
"libwifi-system-iface",
|
||||
"VtsHalWifiV1_0TargetTestUtil",
|
||||
"VtsHalWifiV1_5TargetTestUtil",
|
||||
"VtsHalWifiSupplicantV1_0TargetTestUtil",
|
||||
"VtsHalWifiTargetTestUtil",
|
||||
],
|
||||
test_suites: [
|
||||
"general-tests",
|
||||
@@ -70,20 +61,11 @@ cc_test {
|
||||
"libvndksupport",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.wifi@1.0",
|
||||
"android.hardware.wifi@1.1",
|
||||
"android.hardware.wifi@1.2",
|
||||
"android.hardware.wifi@1.3",
|
||||
"android.hardware.wifi@1.4",
|
||||
"android.hardware.wifi@1.5",
|
||||
"android.hardware.wifi.supplicant@1.0",
|
||||
"android.hardware.wifi.supplicant@1.1",
|
||||
"android.hardware.wifi-V1-ndk",
|
||||
"android.hardware.wifi.supplicant-V2-ndk",
|
||||
"libwifi-system",
|
||||
"libwifi-system-iface",
|
||||
"VtsHalWifiV1_0TargetTestUtil",
|
||||
"VtsHalWifiV1_5TargetTestUtil",
|
||||
"VtsHalWifiSupplicantV1_0TargetTestUtil",
|
||||
"VtsHalWifiTargetTestUtil",
|
||||
],
|
||||
test_suites: [
|
||||
"general-tests",
|
||||
@@ -104,20 +86,11 @@ cc_test {
|
||||
"libvndksupport",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.wifi@1.0",
|
||||
"android.hardware.wifi@1.1",
|
||||
"android.hardware.wifi@1.2",
|
||||
"android.hardware.wifi@1.3",
|
||||
"android.hardware.wifi@1.4",
|
||||
"android.hardware.wifi@1.5",
|
||||
"android.hardware.wifi.supplicant@1.0",
|
||||
"android.hardware.wifi.supplicant@1.1",
|
||||
"android.hardware.wifi-V1-ndk",
|
||||
"android.hardware.wifi.supplicant-V2-ndk",
|
||||
"libwifi-system",
|
||||
"libwifi-system-iface",
|
||||
"VtsHalWifiV1_0TargetTestUtil",
|
||||
"VtsHalWifiV1_5TargetTestUtil",
|
||||
"VtsHalWifiSupplicantV1_0TargetTestUtil",
|
||||
"VtsHalWifiTargetTestUtil",
|
||||
],
|
||||
test_suites: [
|
||||
"general-tests",
|
||||
|
||||
@@ -14,16 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SUPPLICANT_TEST_UTILS_H
|
||||
#define SUPPLICANT_TEST_UTILS_H
|
||||
#pragma once
|
||||
|
||||
#include <VtsCoreUtil.h>
|
||||
#include <aidl/android/hardware/wifi/IWifi.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android/hardware/wifi/1.0/IWifi.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
#include <supplicant_hidl_test_utils.h>
|
||||
#include <wifi_system/supplicant_manager.h>
|
||||
|
||||
#include "wifi_aidl_test_utils.h"
|
||||
|
||||
using aidl::android::hardware::wifi::IfaceConcurrencyType;
|
||||
using aidl::android::hardware::wifi::IWifi;
|
||||
using aidl::android::hardware::wifi::IWifiChip;
|
||||
using aidl::android::hardware::wifi::supplicant::IfaceInfo;
|
||||
using aidl::android::hardware::wifi::supplicant::ISupplicant;
|
||||
using aidl::android::hardware::wifi::supplicant::ISupplicantP2pIface;
|
||||
@@ -31,6 +33,90 @@ using aidl::android::hardware::wifi::supplicant::ISupplicantStaIface;
|
||||
using aidl::android::hardware::wifi::supplicant::KeyMgmtMask;
|
||||
using android::wifi_system::SupplicantManager;
|
||||
|
||||
const std::string kWifiInstanceName = std::string() + IWifi::descriptor + "/default";
|
||||
|
||||
// Initialize the driver and firmware to STA mode using the vendor HAL.
|
||||
void initializeDriverAndFirmware(const std::string& wifi_instance_name) {
|
||||
// Skip if wifi instance is not set.
|
||||
if (wifi_instance_name == "") {
|
||||
return;
|
||||
}
|
||||
if (getWifi(wifi_instance_name.c_str()) != nullptr) {
|
||||
std::shared_ptr<IWifiChip> wifi_chip = getWifiChip(wifi_instance_name.c_str());
|
||||
int mode_id;
|
||||
EXPECT_TRUE(configureChipToSupportConcurrencyType(wifi_chip, IfaceConcurrencyType::STA,
|
||||
&mode_id));
|
||||
} else {
|
||||
LOG(WARNING) << __func__ << ": Vendor HAL not supported";
|
||||
}
|
||||
}
|
||||
|
||||
// Deinitialize the driver and firmware using the vendor HAL.
|
||||
void deInitializeDriverAndFirmware(const std::string& wifi_instance_name) {
|
||||
// Skip if wifi instance is not set.
|
||||
if (wifi_instance_name == "") {
|
||||
return;
|
||||
}
|
||||
if (getWifi(wifi_instance_name.c_str()) != nullptr) {
|
||||
stopWifiService(wifi_instance_name.c_str());
|
||||
} else {
|
||||
LOG(WARNING) << __func__ << ": Vendor HAL not supported";
|
||||
}
|
||||
}
|
||||
|
||||
bool waitForSupplicantState(bool is_running) {
|
||||
SupplicantManager supplicant_manager;
|
||||
int count = 50; /* wait at most 5 seconds for completion */
|
||||
while (count-- > 0) {
|
||||
if (supplicant_manager.IsSupplicantRunning() == is_running) {
|
||||
return true;
|
||||
}
|
||||
usleep(100000);
|
||||
}
|
||||
LOG(ERROR) << "Supplicant not " << is_running ? "running" : "stopped";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool waitForSupplicantStart() {
|
||||
return waitForSupplicantState(true);
|
||||
}
|
||||
|
||||
bool waitForSupplicantStop() {
|
||||
return waitForSupplicantState(false);
|
||||
}
|
||||
|
||||
bool waitForWifiHalStop(const std::string& wifi_instance_name) {
|
||||
std::shared_ptr<IWifi> wifi = getWifi(wifi_instance_name.c_str());
|
||||
int count = 50; /* wait at most 5 seconds for completion */
|
||||
while (count-- > 0) {
|
||||
if (wifi != nullptr) {
|
||||
bool started = false;
|
||||
auto status = wifi->isStarted(&started);
|
||||
if (status.isOk() && !started) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
usleep(100000);
|
||||
wifi = getWifi(wifi_instance_name.c_str());
|
||||
}
|
||||
LOG(ERROR) << "Wifi HAL was not stopped";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool waitForFrameworkReady() {
|
||||
int waitCount = 15;
|
||||
do {
|
||||
// Check whether package service is ready or not.
|
||||
if (!testing::checkSubstringInCommandOutput("/system/bin/service check package",
|
||||
": not found")) {
|
||||
return true;
|
||||
}
|
||||
LOG(INFO) << "Framework is not ready";
|
||||
sleep(1);
|
||||
} while (waitCount-- > 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string getStaIfaceName() {
|
||||
std::array<char, PROPERTY_VALUE_MAX> buffer;
|
||||
property_get("wifi.interface", buffer.data(), "wlan0");
|
||||
@@ -43,14 +129,6 @@ std::string getP2pIfaceName() {
|
||||
return std::string(buffer.data());
|
||||
}
|
||||
|
||||
std::string getWifiInstanceName() {
|
||||
const std::vector<std::string> instances =
|
||||
android::hardware::getAllHalInstanceNames(
|
||||
::android::hardware::wifi::V1_0::IWifi::descriptor);
|
||||
EXPECT_NE(0, instances.size());
|
||||
return instances.size() != 0 ? instances[0] : "";
|
||||
}
|
||||
|
||||
bool keyMgmtSupported(std::shared_ptr<ISupplicantStaIface> iface,
|
||||
KeyMgmtMask expected) {
|
||||
KeyMgmtMask caps;
|
||||
@@ -68,17 +146,33 @@ bool isFilsSupported(std::shared_ptr<ISupplicantStaIface> iface) {
|
||||
}
|
||||
|
||||
void startSupplicant() {
|
||||
initializeDriverAndFirmware(getWifiInstanceName());
|
||||
initializeDriverAndFirmware(kWifiInstanceName);
|
||||
SupplicantManager supplicant_manager;
|
||||
ASSERT_TRUE(supplicant_manager.StartSupplicant());
|
||||
ASSERT_TRUE(supplicant_manager.IsSupplicantRunning());
|
||||
}
|
||||
|
||||
// Wrapper around the implementation in supplicant_hidl_test_util.
|
||||
void stopSupplicantService() { stopSupplicant(getWifiInstanceName()); }
|
||||
void stopSupplicantService() {
|
||||
SupplicantManager supplicant_manager;
|
||||
ASSERT_TRUE(supplicant_manager.StopSupplicant());
|
||||
deInitializeDriverAndFirmware(kWifiInstanceName);
|
||||
ASSERT_FALSE(supplicant_manager.IsSupplicantRunning());
|
||||
}
|
||||
|
||||
bool startWifiFramework() {
|
||||
std::system("svc wifi enable");
|
||||
std::system("cmd wifi set-scan-always-available enabled");
|
||||
return waitForSupplicantStart(); // wait for wifi to start.
|
||||
}
|
||||
|
||||
bool stopWifiFramework(const std::string& wifi_instance_name) {
|
||||
std::system("svc wifi disable");
|
||||
std::system("cmd wifi set-scan-always-available disabled");
|
||||
return waitForSupplicantStop() && waitForWifiHalStop(wifi_instance_name);
|
||||
}
|
||||
|
||||
void initializeService() {
|
||||
ASSERT_TRUE(stopWifiFramework(getWifiInstanceName()));
|
||||
ASSERT_TRUE(stopWifiFramework(kWifiInstanceName));
|
||||
std::system("/system/bin/start");
|
||||
ASSERT_TRUE(waitForFrameworkReady());
|
||||
stopSupplicantService();
|
||||
@@ -106,5 +200,3 @@ std::shared_ptr<ISupplicant> getSupplicant(const char* supplicant_name) {
|
||||
}
|
||||
return supplicant;
|
||||
}
|
||||
|
||||
#endif // SUPPLICANT_TEST_UTILS_H
|
||||
Reference in New Issue
Block a user