vts(wifi): Stop wifi fully instead of stopping framework
Stopping entire framework can cause other essential services to be stopped. When wifi is stopped, it does not interact with any of the wifi HAL's. Bug: 168278011 Test: atest --iterations 10 VtsHalWifiSupplicantP2pV1_0TargetTest VtsHalWifiSupplicantP2pV1_1TargetTest VtsHalWifiSupplicantP2pV1_2TargetTest VtsHalWifiSupplicantP2pV1_3TargetTest Change-Id: Ia93e78cf4c147e42dd3d68e24a582c0c1af15899
This commit is contained in:
parent
d973ce2ac1
commit
894739b6b0
3 changed files with 49 additions and 12 deletions
|
@ -38,12 +38,15 @@ class SupplicantHidlTest
|
||||||
: public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
|
: public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
|
||||||
public:
|
public:
|
||||||
virtual void SetUp() override {
|
virtual void SetUp() override {
|
||||||
|
// Stop Wi-Fi
|
||||||
|
ASSERT_TRUE(stopWifiFramework()); // stop & wait for wifi to shutdown.
|
||||||
|
|
||||||
wifi_instance_name_ = std::get<0>(GetParam());
|
wifi_instance_name_ = std::get<0>(GetParam());
|
||||||
supplicant_instance_name_ = std::get<1>(GetParam());
|
supplicant_instance_name_ = std::get<1>(GetParam());
|
||||||
|
std::system("/system/bin/start");
|
||||||
|
ASSERT_TRUE(waitForFrameworkReady());
|
||||||
isP2pOn_ =
|
isP2pOn_ =
|
||||||
testing::deviceSupportsFeature("android.hardware.wifi.direct");
|
testing::deviceSupportsFeature("android.hardware.wifi.direct");
|
||||||
// Stop Framework
|
|
||||||
std::system("/system/bin/stop");
|
|
||||||
stopSupplicant(wifi_instance_name_);
|
stopSupplicant(wifi_instance_name_);
|
||||||
startSupplicantAndWaitForHidlService(wifi_instance_name_,
|
startSupplicantAndWaitForHidlService(wifi_instance_name_,
|
||||||
supplicant_instance_name_);
|
supplicant_instance_name_);
|
||||||
|
@ -53,8 +56,8 @@ class SupplicantHidlTest
|
||||||
|
|
||||||
virtual void TearDown() override {
|
virtual void TearDown() override {
|
||||||
stopSupplicant(wifi_instance_name_);
|
stopSupplicant(wifi_instance_name_);
|
||||||
// Start Framework
|
// Start Wi-Fi
|
||||||
std::system("/system/bin/start");
|
startWifiFramework();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -48,6 +48,26 @@ using ::android::wifi_system::InterfaceTool;
|
||||||
using ::android::wifi_system::SupplicantManager;
|
using ::android::wifi_system::SupplicantManager;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function to wait for supplicant to be started by framework on wifi
|
||||||
|
// enable.
|
||||||
|
bool waitForSupplicantStart() { return waitForSupplicantState(true); }
|
||||||
|
|
||||||
|
// Helper function to wait for supplicant to be stopped by framework on wifi
|
||||||
|
// disable.
|
||||||
|
bool waitForSupplicantStop() { return waitForSupplicantState(false); }
|
||||||
|
|
||||||
// Helper function to initialize the driver and firmware to STA mode
|
// Helper function to initialize the driver and firmware to STA mode
|
||||||
// using the vendor HAL HIDL interface.
|
// using the vendor HAL HIDL interface.
|
||||||
|
@ -118,6 +138,18 @@ std::string getP2pIfaceName() {
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
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() {
|
||||||
|
std::system("svc wifi disable");
|
||||||
|
std::system("cmd wifi set-scan-always-available disabled");
|
||||||
|
return waitForSupplicantStop(); // wait for wifi to shutdown.
|
||||||
|
}
|
||||||
|
|
||||||
void stopSupplicant() { stopSupplicant(""); }
|
void stopSupplicant() { stopSupplicant(""); }
|
||||||
|
|
||||||
void stopSupplicant(const std::string& wifi_instance_name) {
|
void stopSupplicant(const std::string& wifi_instance_name) {
|
||||||
|
|
|
@ -29,9 +29,11 @@
|
||||||
|
|
||||||
#include "wifi_hidl_test_utils.h"
|
#include "wifi_hidl_test_utils.h"
|
||||||
|
|
||||||
|
// Used to start the android wifi framework after every test.
|
||||||
|
bool startWifiFramework();
|
||||||
|
|
||||||
// Used to stop the android wifi framework before every test.
|
// Used to stop the android wifi framework before every test.
|
||||||
void stopWifiFramework(const std::string& wifi_instance_name);
|
bool stopWifiFramework();
|
||||||
void startWifiFramework(const std::string& wifi_instance_name);
|
|
||||||
|
|
||||||
void stopSupplicant(const std::string& wifi_instance_name);
|
void stopSupplicant(const std::string& wifi_instance_name);
|
||||||
// Used to configure the chip, driver and start wpa_supplicant before every
|
// Used to configure the chip, driver and start wpa_supplicant before every
|
||||||
|
@ -70,16 +72,16 @@ class SupplicantHidlTestBase
|
||||||
: public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
|
: public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
|
||||||
public:
|
public:
|
||||||
virtual void SetUp() override {
|
virtual void SetUp() override {
|
||||||
|
// Stop Wi-Fi
|
||||||
|
ASSERT_TRUE(stopWifiFramework()); // stop & wait for wifi to shutdown.
|
||||||
|
|
||||||
// should always be v1.0 wifi
|
// should always be v1.0 wifi
|
||||||
wifi_v1_0_instance_name_ = std::get<0>(GetParam());
|
wifi_v1_0_instance_name_ = std::get<0>(GetParam());
|
||||||
supplicant_instance_name_ = std::get<1>(GetParam());
|
supplicant_instance_name_ = std::get<1>(GetParam());
|
||||||
std::system("/system/bin/start");
|
std::system("/system/bin/start");
|
||||||
ASSERT_TRUE(waitForFrameworkReady());
|
ASSERT_TRUE(waitForFrameworkReady());
|
||||||
|
|
||||||
isP2pOn_ =
|
isP2pOn_ =
|
||||||
testing::deviceSupportsFeature("android.hardware.wifi.direct");
|
testing::deviceSupportsFeature("android.hardware.wifi.direct");
|
||||||
// Stop Framework
|
|
||||||
std::system("/system/bin/stop");
|
|
||||||
stopSupplicant(wifi_v1_0_instance_name_);
|
stopSupplicant(wifi_v1_0_instance_name_);
|
||||||
startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_,
|
startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_,
|
||||||
supplicant_instance_name_);
|
supplicant_instance_name_);
|
||||||
|
@ -88,8 +90,8 @@ class SupplicantHidlTestBase
|
||||||
|
|
||||||
virtual void TearDown() override {
|
virtual void TearDown() override {
|
||||||
stopSupplicant(wifi_v1_0_instance_name_);
|
stopSupplicant(wifi_v1_0_instance_name_);
|
||||||
// Start Framework
|
// Start Wi-Fi
|
||||||
std::system("/system/bin/start");
|
startWifiFramework();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Reference in a new issue