Merge "vts: wifi: softap and p2p are optional feature per CDD" into pie-vts-dev am: a5f27a462e

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1322162

Change-Id: I7eae2ae4cd49ee2384f197c7e94ce6c8fed45235
This commit is contained in:
Treehugger Robot
2020-06-22 14:37:11 +00:00
committed by Automerger Merge Worker
10 changed files with 125 additions and 19 deletions

View File

@@ -29,17 +29,22 @@ using ::android::hardware::wifi::V1_0::WifiBand;
using ::android::hardware::wifi::V1_0::WifiStatusCode;
using ::android::sp;
extern WifiHidlEnvironment* gEnv;
/**
* Fixture to use for all AP Iface HIDL interface tests.
*/
class WifiApIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
if (!gEnv->isSoftApOn) return;
wifi_ap_iface_ = getWifiApIface();
ASSERT_NE(nullptr, wifi_ap_iface_.get());
}
virtual void TearDown() override { stopWifi(); }
virtual void TearDown() override {
if (!gEnv->isSoftApOn) return;
stopWifi();
}
protected:
sp<IWifiApIface> wifi_ap_iface_;
@@ -51,6 +56,7 @@ class WifiApIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
* successfully created.
*/
TEST(WifiApIfaceHidlTestNoFixture, Create) {
if (!gEnv->isSoftApOn) return;
EXPECT_NE(nullptr, getWifiApIface().get());
stopWifi();
}
@@ -60,6 +66,7 @@ TEST(WifiApIfaceHidlTestNoFixture, Create) {
* Ensures that the correct interface type is returned for AP interface.
*/
TEST_F(WifiApIfaceHidlTest, GetType) {
if (!gEnv->isSoftApOn) return;
const auto& status_and_type = HIDL_INVOKE(wifi_ap_iface_, getType);
EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_type.first.code);
EXPECT_EQ(IfaceType::AP, status_and_type.second);
@@ -71,6 +78,7 @@ TEST_F(WifiApIfaceHidlTest, GetType) {
* status code.
*/
TEST_F(WifiApIfaceHidlTest, SetCountryCode) {
if (!gEnv->isSoftApOn) return;
const android::hardware::hidl_array<int8_t, 2> kCountryCode{
std::array<int8_t, 2>{{0x55, 0x53}}};
EXPECT_EQ(WifiStatusCode::SUCCESS,
@@ -82,6 +90,7 @@ TEST_F(WifiApIfaceHidlTest, SetCountryCode) {
* Ensures that we can retrieve valid frequencies for 2.4 GHz band.
*/
TEST_F(WifiApIfaceHidlTest, GetValidFrequenciesForBand) {
if (!gEnv->isSoftApOn) return;
const auto& status_and_freqs = HIDL_INVOKE(
wifi_ap_iface_, getValidFrequenciesForBand, WifiBand::BAND_24GHZ);
EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_freqs.first.code);

View File

@@ -352,6 +352,7 @@ TEST_F(WifiChipHidlTest, GetDebugHostWakeReasonStats) {
* succeeds.
*/
TEST_F(WifiChipHidlTest, CreateApIface) {
if (!gEnv->isSoftApOn) return;
configureChipForIfaceType(IfaceType::AP, true);
sp<IWifiApIface> iface;
@@ -366,6 +367,7 @@ TEST_F(WifiChipHidlTest, CreateApIface) {
* iface name is returned via the list.
*/
TEST_F(WifiChipHidlTest, GetApIfaceNames) {
if (!gEnv->isSoftApOn) return;
configureChipForIfaceType(IfaceType::AP, true);
const auto& status_and_iface_names1 =
@@ -398,6 +400,7 @@ TEST_F(WifiChipHidlTest, GetApIfaceNames) {
* doesn't retrieve an iface object.
*/
TEST_F(WifiChipHidlTest, GetApIface) {
if (!gEnv->isSoftApOn) return;
configureChipForIfaceType(IfaceType::AP, true);
sp<IWifiApIface> ap_iface;
@@ -424,6 +427,7 @@ TEST_F(WifiChipHidlTest, GetApIface) {
* doesn't remove the iface.
*/
TEST_F(WifiChipHidlTest, RemoveApIface) {
if (!gEnv->isSoftApOn) return;
configureChipForIfaceType(IfaceType::AP, true);
sp<IWifiApIface> ap_iface;
@@ -727,6 +731,7 @@ TEST_F(WifiChipHidlTest, RemoveStaIface) {
* CreateRttController
*/
TEST_F(WifiChipHidlTest, CreateRttController) {
if (!gEnv->isSoftApOn) return;
configureChipForIfaceType(IfaceType::AP, true);
sp<IWifiApIface> iface;

View File

@@ -58,26 +58,33 @@ class WifiHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
public:
// Whether NaN feature is supported on the device.
bool isNanOn = false;
// Whether SoftAp feature is supported on the device.
bool isSoftApOn = false;
void usage(char* me, char* arg) {
fprintf(stderr,
"unrecognized option: %s\n\n"
"usage: %s <gtest options> <test options>\n\n"
"test options are:\n\n"
"-N, --nan_on: Whether NAN feature is supported\n",
"-N, --nan_on: Whether NAN feature is supported\n"
"-S, --softap_on: Whether SOFTAP feature is supported\n",
arg, me);
}
int initFromOptions(int argc, char** argv) {
static struct option options[] = {{"nan_on", no_argument, 0, 'N'},
{"softap_on", no_argument, 0, 'S'},
{0, 0, 0, 0}};
int c;
while ((c = getopt_long(argc, argv, "N", options, NULL)) >= 0) {
while ((c = getopt_long(argc, argv, "NS", options, NULL)) >= 0) {
switch (c) {
case 'N':
isNanOn = true;
break;
case 'S':
isSoftApOn = true;
break;
default:
usage(argv[0], argv[optind]);
return 2;

View File

@@ -39,7 +39,6 @@ cc_test {
srcs: [
"VtsHalWifiSupplicantV1_0TargetTest.cpp",
"supplicant_hidl_test.cpp",
"supplicant_p2p_iface_hidl_test.cpp",
"supplicant_sta_iface_hidl_test.cpp",
"supplicant_sta_network_hidl_test.cpp",
],
@@ -55,3 +54,23 @@ cc_test {
"libwifi-system-iface",
],
}
cc_test {
name: "VtsHalWifiSupplicantP2pV1_0TargetTest",
defaults: ["VtsHalTargetTestDefaults"],
srcs: [
"VtsHalWifiSupplicantV1_0TargetTest.cpp",
"supplicant_p2p_iface_hidl_test.cpp",
],
static_libs: [
"VtsHalWifiV1_0TargetTestUtil",
"VtsHalWifiSupplicantV1_0TargetTestUtil",
"android.hardware.wifi.supplicant@1.0",
"android.hardware.wifi.supplicant@1.1",
"android.hardware.wifi@1.0",
"libcrypto",
"libgmock",
"libwifi-system",
"libwifi-system-iface",
],
}

View File

@@ -44,7 +44,12 @@ int main(int argc, char** argv) {
::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
gEnv->init(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
int status = gEnv->initFromOptions(argc, argv);
if (status == 0) {
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
}
return status;
}

View File

@@ -30,6 +30,7 @@ using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatus;
using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode;
using ::android::hardware::wifi::supplicant::V1_0::IfaceType;
extern WifiSupplicantHidlEnvironment* gEnv;
class SupplicantHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
@@ -72,10 +73,14 @@ TEST_F(SupplicantHidlTest, ListInterfaces) {
std::find_if(ifaces.begin(), ifaces.end(), [](const auto& iface) {
return iface.type == IfaceType::STA;
}));
EXPECT_NE(ifaces.end(),
std::find_if(ifaces.begin(), ifaces.end(), [](const auto& iface) {
return iface.type == IfaceType::P2P;
}));
if (gEnv->isP2pOn) {
EXPECT_NE(
ifaces.end(),
std::find_if(ifaces.begin(), ifaces.end(), [](const auto& iface) {
return iface.type == IfaceType::P2P;
}));
}
}
/*
@@ -178,8 +183,11 @@ TEST_F(SupplicantHidlTest, SetConcurrencyPriority) {
IfaceType::STA, [](const SupplicantStatus& status) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
});
supplicant_->setConcurrencyPriority(
IfaceType::P2P, [](const SupplicantStatus& status) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
});
if (gEnv->isP2pOn) {
supplicant_->setConcurrencyPriority(
IfaceType::P2P, [](const SupplicantStatus& status) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
});
}
}

View File

@@ -225,7 +225,10 @@ sp<ISupplicant> getSupplicant() {
// For 1.1 supplicant, we need to add interfaces at initialization.
if (is_1_1(supplicant)) {
addSupplicantStaIface_1_1(supplicant);
addSupplicantP2pIface_1_1(supplicant);
if (gEnv->isP2pOn) {
addSupplicantP2pIface_1_1(supplicant);
}
}
return supplicant;
}

View File

@@ -23,8 +23,9 @@
#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaNetwork.h>
#include <android/hardware/wifi/supplicant/1.1/ISupplicant.h>
#include <VtsHalHidlTargetTestEnvBase.h>
#include <getopt.h>
#include <VtsHalHidlTargetTestEnvBase.h>
// Used to stop the android wifi framework before every test.
void stopWifiFramework();
void startWifiFramework();
@@ -50,11 +51,48 @@ bool turnOnExcessiveLogging();
class WifiSupplicantHidlEnvironment
: public ::testing::VtsHalHidlTargetTestEnvBase {
public:
protected:
virtual void HidlSetUp() override { stopSupplicant(); }
virtual void HidlTearDown() override {
startSupplicantAndWaitForHidlService();
}
public:
// Whether P2P feature is supported on the device.
bool isP2pOn = true;
void usage(char* me, char* arg) {
fprintf(stderr,
"unrecognized option: %s\n\n"
"usage: %s <gtest options> <test options>\n\n"
"test options are:\n\n"
"-P, --p2p_on: Whether P2P feature is supported\n",
arg, me);
}
int initFromOptions(int argc, char** argv) {
static struct option options[] = {{"p2p_off", no_argument, 0, 'P'},
{0, 0, 0, 0}};
int c;
while ((c = getopt_long(argc, argv, "P", options, NULL)) >= 0) {
switch (c) {
case 'P':
isP2pOn = false;
break;
default:
usage(argv[0], argv[optind]);
return 2;
}
}
if (optind < argc) {
usage(argv[0], argv[optind]);
return 2;
}
return 0;
}
};
#endif /* SUPPLICANT_HIDL_TEST_UTILS_H */

View File

@@ -30,7 +30,10 @@ class WifiSupplicantHidlEnvironment_1_1 : public WifiSupplicantHidlEnvironment {
return instance;
}
virtual void registerTestServices() override {
registerTestService<::android::hardware::wifi::V1_0::IWifi>();
registerTestService<::android::hardware::wifi::V1_1::IWifi>();
registerTestService<
::android::hardware::wifi::supplicant::V1_0::ISupplicant>();
registerTestService<
::android::hardware::wifi::supplicant::V1_1::ISupplicant>();
}
@@ -46,7 +49,12 @@ int main(int argc, char** argv) {
::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
gEnv->init(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
int status = gEnv->initFromOptions(argc, argv);
if (status == 0) {
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
}
return status;
}

View File

@@ -33,6 +33,8 @@ using ::android::hardware::wifi::supplicant::V1_0::IfaceType;
using ::android::hardware::wifi::supplicant::V1_1::ISupplicant;
using ::android::sp;
extern WifiSupplicantHidlEnvironment* gEnv;
class SupplicantHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
@@ -81,6 +83,7 @@ TEST_F(SupplicantHidlTest, AddStaInterface) {
* AddP2pInterface
*/
TEST_F(SupplicantHidlTest, AddP2pInterface) {
if (!gEnv->isP2pOn) return;
ISupplicant::IfaceInfo iface_info;
iface_info.name = getP2pIfaceName();
iface_info.type = IfaceType::P2P;
@@ -120,6 +123,7 @@ TEST_F(SupplicantHidlTest, RemoveStaInterface) {
* RemoveP2pInterface
*/
TEST_F(SupplicantHidlTest, RemoveP2pInterface) {
if (!gEnv->isP2pOn) return;
ISupplicant::IfaceInfo iface_info;
iface_info.name = getP2pIfaceName();
iface_info.type = IfaceType::P2P;