Convert VtsHalWifiSupplicantV1_*TargetTest to be parameterized test

Bug: 142397658
Test: atest VtsHalWifiSupplicantV1_1TargetTest \
  VtsHalWifiSupplicantV1_2TargetTest \
  VtsHalWifiSupplicantP2pV1_2TargetTest

Change-Id: I14a3e94d0b3681c5a3ebd17435dc36d279790c79
This commit is contained in:
Dan Shi 2019-11-05 13:11:18 -08:00
parent 9392b58da0
commit d64367312e
15 changed files with 328 additions and 236 deletions

View file

@ -57,6 +57,11 @@ namespace {
// Helper function to initialize the driver and firmware to STA mode
// using the vendor HAL HIDL interface.
void initilializeDriverAndFirmware(const std::string& wifi_instance_name) {
// Skip if wifi instance is not set.
if (wifi_instance_name == "") {
return;
}
sp<IWifiChip> wifi_chip = getWifiChip(wifi_instance_name);
ChipModeId mode_id;
EXPECT_TRUE(configureChipToSupportIfaceType(
@ -66,6 +71,11 @@ void initilializeDriverAndFirmware(const std::string& wifi_instance_name) {
// Helper function to deinitialize the driver and firmware
// using the vendor HAL HIDL interface.
void deInitilializeDriverAndFirmware(const std::string& wifi_instance_name) {
// Skip if wifi instance is not set.
if (wifi_instance_name == "") {
return;
}
stopWifi(wifi_instance_name);
}

View file

@ -19,7 +19,7 @@ cc_library_static {
defaults: ["VtsHalTargetTestDefaults"],
srcs: ["supplicant_hidl_test_utils_1_1.cpp"],
export_include_dirs: [
"."
".",
],
static_libs: [
"VtsHalWifiV1_0TargetTestUtil",
@ -54,5 +54,8 @@ cc_test {
"libwifi-system",
"libwifi-system-iface",
],
test_suites: ["general-tests"],
test_suites: [
"general-tests",
"vts-core",
],
}

View file

@ -14,45 +14,8 @@
* limitations under the License.
*/
#include <android-base/logging.h>
#include <android/hardware/wifi/1.1/IWifi.h>
#include <android/hardware/wifi/supplicant/1.1/ISupplicant.h>
#include "supplicant_hidl_test_utils.h"
#include "wifi_hidl_test_utils.h"
class WifiSupplicantHidlEnvironment_1_1 : public WifiSupplicantHidlEnvironment {
public:
// get the test environment singleton
static WifiSupplicantHidlEnvironment_1_1* Instance() {
static WifiSupplicantHidlEnvironment_1_1* instance =
new WifiSupplicantHidlEnvironment_1_1;
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>();
}
private:
WifiSupplicantHidlEnvironment_1_1() {}
};
WifiSupplicantHidlEnvironment* gEnv =
WifiSupplicantHidlEnvironment_1_1::Instance();
int main(int argc, char** argv) {
::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
gEnv->init(&argc, argv);
int status = gEnv->initFromOptions(argc, argv);
if (status == 0) {
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
}
return status;
}
// TODO(b/143892896): Remove this file after wifi_hidl_test_utils.cpp is
// updated.
WifiSupplicantHidlEnvironment* gEnv = nullptr;

View file

@ -17,10 +17,12 @@
#include <android-base/logging.h>
#include <cutils/properties.h>
#include <VtsHalHidlTargetTestBase.h>
#include <VtsCoreUtil.h>
#include <android/hardware/wifi/1.0/IWifi.h>
#include <android/hardware/wifi/supplicant/1.0/types.h>
#include <android/hardware/wifi/supplicant/1.1/ISupplicant.h>
#include <hidl/GtestPrinter.h>
#include <hidl/ServiceManagement.h>
#include "supplicant_hidl_test_utils.h"
#include "supplicant_hidl_test_utils_1_1.h"
@ -33,22 +35,11 @@ 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 {
class SupplicantHidlTest : public SupplicantHidlTestBase {
public:
virtual void SetUp() override {
startSupplicantAndWaitForHidlService();
supplicant_ = getSupplicant_1_1();
ASSERT_NE(supplicant_.get(), nullptr);
}
virtual void TearDown() override { stopSupplicant(); }
virtual void SetUp() override { SupplicantHidlTestBase::SetUp(); }
protected:
// ISupplicant object used for all tests in this fixture.
sp<ISupplicant> supplicant_;
std::string getWlan0IfaceName() {
std::array<char, PROPERTY_VALUE_MAX> buffer;
property_get("wifi.interface", buffer.data(), "wlan0");
@ -65,7 +56,7 @@ class SupplicantHidlTest : public ::testing::VtsHalHidlTargetTestBase {
/*
* AddStaInterface
*/
TEST_F(SupplicantHidlTest, AddStaInterface) {
TEST_P(SupplicantHidlTest, AddStaInterface) {
ISupplicant::IfaceInfo iface_info;
iface_info.name = getWlan0IfaceName();
iface_info.type = IfaceType::STA;
@ -82,8 +73,8 @@ TEST_F(SupplicantHidlTest, AddStaInterface) {
/*
* AddP2pInterface
*/
TEST_F(SupplicantHidlTest, AddP2pInterface) {
if (!gEnv->isP2pOn) return;
TEST_P(SupplicantHidlTest, AddP2pInterface) {
if (isP2pOn_) return;
ISupplicant::IfaceInfo iface_info;
iface_info.name = getP2pIfaceName();
iface_info.type = IfaceType::P2P;
@ -100,7 +91,7 @@ TEST_F(SupplicantHidlTest, AddP2pInterface) {
/*
* RemoveStaInterface
*/
TEST_F(SupplicantHidlTest, RemoveStaInterface) {
TEST_P(SupplicantHidlTest, RemoveStaInterface) {
ISupplicant::IfaceInfo iface_info;
iface_info.name = getWlan0IfaceName();
iface_info.type = IfaceType::STA;
@ -122,8 +113,8 @@ TEST_F(SupplicantHidlTest, RemoveStaInterface) {
/*
* RemoveP2pInterface
*/
TEST_F(SupplicantHidlTest, RemoveP2pInterface) {
if (!gEnv->isP2pOn) return;
TEST_P(SupplicantHidlTest, RemoveP2pInterface) {
if (isP2pOn_) return;
ISupplicant::IfaceInfo iface_info;
iface_info.name = getP2pIfaceName();
iface_info.type = IfaceType::P2P;
@ -146,6 +137,23 @@ TEST_F(SupplicantHidlTest, RemoveP2pInterface) {
* Terminate
* This terminates the service.
*/
TEST_F(SupplicantHidlTest, Terminate) {
supplicant_->terminate();
TEST_P(SupplicantHidlTest, Terminate) { supplicant_->terminate(); }
static std::vector<std::string> get_wifi_instances() {
std::vector<std::string> instances =
android::hardware::getAllHalInstanceNames(
android::hardware::wifi::V1_0::IWifi::descriptor);
// Also test when wifi instance is not set.
instances.push_back("");
return instances;
}
INSTANTIATE_TEST_CASE_P(
PerInstance, SupplicantHidlTest,
testing::Combine(
testing::ValuesIn(get_wifi_instances()),
testing::ValuesIn(android::hardware::getAllHalInstanceNames(
android::hardware::wifi::supplicant::V1_1::ISupplicant::
descriptor))),
android::hardware::PrintInstanceTupleNameToString<>);

View file

@ -14,7 +14,6 @@
* limitations under the License.
*/
#include <VtsHalHidlTargetTestBase.h>
#include <android-base/logging.h>
#include "supplicant_hidl_test_utils.h"
@ -25,14 +24,19 @@ using ::android::hardware::wifi::supplicant::V1_1::ISupplicantStaIface;
using ::android::hardware::wifi::supplicant::V1_1::ISupplicantStaNetwork;
using ::android::sp;
sp<ISupplicant> getSupplicant_1_1() {
return ISupplicant::castFrom(getSupplicant());
sp<ISupplicant> getSupplicant_1_1(const std::string& supplicant_instance_name,
bool isP2pOn) {
return ISupplicant::castFrom(
getSupplicant(supplicant_instance_name, isP2pOn));
}
sp<ISupplicantStaIface> getSupplicantStaIface_1_1() {
return ISupplicantStaIface::castFrom(getSupplicantStaIface());
sp<ISupplicantStaIface> getSupplicantStaIface_1_1(
const sp<ISupplicant>& supplicant) {
return ISupplicantStaIface::castFrom(getSupplicantStaIface(supplicant));
}
sp<ISupplicantStaNetwork> createSupplicantStaNetwork_1_1() {
return ISupplicantStaNetwork::castFrom(createSupplicantStaNetwork());
sp<ISupplicantStaNetwork> createSupplicantStaNetwork_1_1(
const sp<ISupplicant>& supplicant) {
return ISupplicantStaNetwork::castFrom(
createSupplicantStaNetwork(supplicant));
}

View file

@ -14,20 +14,52 @@
* limitations under the License.
*/
#ifndef SUPPLICANT_HIDL_TEST_UTILS_1_1_H
#define SUPPLICANT_HIDL_TEST_UTILS_1_1_H
#pragma once
#pragma clang diagnostic ignored "-Wweak-vtables"
#include <VtsCoreUtil.h>
#include <android/hardware/wifi/supplicant/1.1/ISupplicant.h>
#include <android/hardware/wifi/supplicant/1.1/ISupplicantStaIface.h>
#include <android/hardware/wifi/supplicant/1.1/ISupplicantStaNetwork.h>
#include <gtest/gtest.h>
android::sp<android::hardware::wifi::supplicant::V1_1::ISupplicant>
getSupplicant_1_1();
getSupplicant_1_1(const std::string& supplicant_instance_name, bool isP2pOn);
android::sp<android::hardware::wifi::supplicant::V1_1::ISupplicantStaIface>
getSupplicantStaIface_1_1();
getSupplicantStaIface_1_1(
const android::sp<android::hardware::wifi::supplicant::V1_1::ISupplicant>&
supplicant);
android::sp<android::hardware::wifi::supplicant::V1_1::ISupplicantStaNetwork>
createSupplicantStaNetwork_1_1();
createSupplicantStaNetwork_1_1(
const android::sp<android::hardware::wifi::supplicant::V1_1::ISupplicant>&
supplicant);
#endif /* SUPPLICANT_HIDL_TEST_UTILS_1_1_H */
class SupplicantHidlTestBase
: public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
public:
virtual void SetUp() override {
wifi_v1_0_instance_name_ = std::get<0>(GetParam());
supplicant_v1_1_instance_name_ = std::get<1>(GetParam());
isP2pOn_ =
testing::deviceSupportsFeature("android.hardware.wifi.direct");
stopSupplicant(wifi_v1_0_instance_name_);
startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_,
supplicant_v1_1_instance_name_);
supplicant_ =
getSupplicant_1_1(supplicant_v1_1_instance_name_, isP2pOn_);
ASSERT_NE(supplicant_.get(), nullptr);
}
virtual void TearDown() override {
stopSupplicant(wifi_v1_0_instance_name_);
}
protected:
android::sp<android::hardware::wifi::supplicant::V1_1::ISupplicant>
supplicant_;
bool isP2pOn_ = false;
std::string wifi_v1_0_instance_name_;
std::string supplicant_v1_1_instance_name_;
};

View file

@ -16,9 +16,13 @@
#include <android-base/logging.h>
#include <VtsHalHidlTargetTestBase.h>
#include <VtsCoreUtil.h>
#include <android/hardware/wifi/1.0/IWifi.h>
#include <android/hardware/wifi/1.1/IWifi.h>
#include <android/hardware/wifi/supplicant/1.1/ISupplicantStaIface.h>
#include <gtest/gtest.h>
#include <hidl/GtestPrinter.h>
#include <hidl/ServiceManagement.h>
#include "supplicant_hidl_test_utils.h"
#include "supplicant_hidl_test_utils_1_1.h"
@ -29,26 +33,24 @@ using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::wifi::supplicant::V1_1::ISupplicantStaIface;
using ::android::hardware::wifi::supplicant::V1_1::ISupplicantStaIfaceCallback;
using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatus;
using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode;
using ::android::hardware::wifi::supplicant::V1_1::ISupplicant;
using ::android::hardware::wifi::supplicant::V1_1::ISupplicantStaIface;
using ::android::hardware::wifi::supplicant::V1_1::ISupplicantStaIfaceCallback;
class SupplicantStaIfaceHidlTest
: public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
startSupplicantAndWaitForHidlService();
EXPECT_TRUE(turnOnExcessiveLogging());
sta_iface_ = getSupplicantStaIface_1_1();
ASSERT_NE(sta_iface_.get(), nullptr);
}
class SupplicantStaIfaceHidlTest : public SupplicantHidlTestBase {
public:
virtual void SetUp() override {
SupplicantHidlTestBase::SetUp();
EXPECT_TRUE(turnOnExcessiveLogging(supplicant_));
sta_iface_ = getSupplicantStaIface_1_1(supplicant_);
ASSERT_NE(sta_iface_.get(), nullptr);
}
virtual void TearDown() override { stopSupplicant(); }
protected:
// ISupplicantStaIface object used for all tests in this fixture.
sp<ISupplicantStaIface> sta_iface_;
protected:
// ISupplicantStaIface object used for all tests in this fixture.
sp<ISupplicantStaIface> sta_iface_;
};
class IfaceCallback : public ISupplicantStaIfaceCallback {
@ -131,9 +133,19 @@ class IfaceCallback : public ISupplicantStaIfaceCallback {
/*
* RegisterCallback_1_1
*/
TEST_F(SupplicantStaIfaceHidlTest, RegisterCallback_1_1) {
sta_iface_->registerCallback_1_1(
new IfaceCallback(), [](const SupplicantStatus& status) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
});
TEST_P(SupplicantStaIfaceHidlTest, RegisterCallback_1_1) {
sta_iface_->registerCallback_1_1(
new IfaceCallback(), [](const SupplicantStatus& status) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
});
}
INSTANTIATE_TEST_CASE_P(
PerInstance, SupplicantStaIfaceHidlTest,
testing::Combine(
testing::ValuesIn(android::hardware::getAllHalInstanceNames(
android::hardware::wifi::V1_0::IWifi::descriptor)),
testing::ValuesIn(android::hardware::getAllHalInstanceNames(
android::hardware::wifi::supplicant::V1_1::ISupplicant::
descriptor))),
android::hardware::PrintInstanceTupleNameToString<>);

View file

@ -16,8 +16,11 @@
#include <android-base/logging.h>
#include <VtsHalHidlTargetTestBase.h>
#include <VtsCoreUtil.h>
#include <android/hardware/wifi/1.0/IWifi.h>
#include <android/hardware/wifi/supplicant/1.1/ISupplicantStaNetwork.h>
#include <hidl/GtestPrinter.h>
#include <hidl/ServiceManagement.h>
#include "supplicant_hidl_test_utils.h"
#include "supplicant_hidl_test_utils_1_1.h"
@ -26,27 +29,26 @@ using ::android::sp;
using ::android::hardware::hidl_vec;
using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatus;
using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode;
using ::android::hardware::wifi::supplicant::V1_1::ISupplicant;
using ::android::hardware::wifi::supplicant::V1_1::ISupplicantStaNetwork;
namespace {
constexpr uint8_t kTestIdentity[] = {0x45, 0x67, 0x98, 0x67, 0x56};
constexpr uint8_t kTestEncryptedIdentity[] = {0x35, 0x37, 0x58, 0x57, 0x26};
} // namespace
class SupplicantStaNetworkHidlTest
: public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
startSupplicantAndWaitForHidlService();
EXPECT_TRUE(turnOnExcessiveLogging());
sta_network_ = createSupplicantStaNetwork_1_1();
ASSERT_NE(sta_network_.get(), nullptr);
}
class SupplicantStaNetworkHidlTest : public SupplicantHidlTestBase {
public:
virtual void SetUp() override {
SupplicantHidlTestBase::SetUp();
EXPECT_TRUE(turnOnExcessiveLogging(supplicant_));
sta_network_ = createSupplicantStaNetwork_1_1(supplicant_);
ASSERT_NE(sta_network_.get(), nullptr);
}
virtual void TearDown() override { stopSupplicant(); }
protected:
// ISupplicantStaNetwork object used for all tests in this fixture.
sp<ISupplicantStaNetwork> sta_network_;
protected:
// ISupplicantStaNetwork object used for all tests in this fixture.
sp<ISupplicantStaNetwork> sta_network_;
};
/*
@ -54,36 +56,49 @@ class SupplicantStaNetworkHidlTest
* Ensures that an instance of the ISupplicantStaNetwork proxy object is
* successfully created.
*/
TEST(SupplicantStaNetworkHidlTestNoFixture, Create) {
startSupplicantAndWaitForHidlService();
EXPECT_NE(nullptr, createSupplicantStaNetwork_1_1().get());
stopSupplicant();
TEST_P(SupplicantStaNetworkHidlTest, Create) {
stopSupplicant(wifi_v1_0_instance_name_);
startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_,
supplicant_v1_1_instance_name_);
sp<ISupplicant> supplicant =
getSupplicant_1_1(supplicant_v1_1_instance_name_, isP2pOn_);
EXPECT_NE(nullptr, createSupplicantStaNetwork_1_1(supplicant).get());
}
/*
* Ensure that the encrypted imsi identity is set successfully.
*/
TEST_F(SupplicantStaNetworkHidlTest, setEapEncryptedImsiIdentity) {
std::vector<uint8_t> encrypted_identity(
kTestEncryptedIdentity,
kTestEncryptedIdentity + sizeof(kTestEncryptedIdentity));
sta_network_->setEapEncryptedImsiIdentity(
encrypted_identity, [](const SupplicantStatus &status) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
});
TEST_P(SupplicantStaNetworkHidlTest, setEapEncryptedImsiIdentity) {
std::vector<uint8_t> encrypted_identity(
kTestEncryptedIdentity,
kTestEncryptedIdentity + sizeof(kTestEncryptedIdentity));
sta_network_->setEapEncryptedImsiIdentity(
encrypted_identity, [](const SupplicantStatus &status) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
});
}
/*
* Ensure that the identity and the encrypted imsi identity are sent
* successfully.
*/
TEST_F(SupplicantStaNetworkHidlTest, SendNetworkEapIdentityResponse_1_1) {
sta_network_->sendNetworkEapIdentityResponse_1_1(
std::vector<uint8_t>(kTestIdentity,
kTestIdentity + sizeof(kTestIdentity)),
std::vector<uint8_t>(kTestEncryptedIdentity,
kTestIdentity + sizeof(kTestEncryptedIdentity)),
[](const SupplicantStatus &status) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
});
TEST_P(SupplicantStaNetworkHidlTest, SendNetworkEapIdentityResponse_1_1) {
sta_network_->sendNetworkEapIdentityResponse_1_1(
std::vector<uint8_t>(kTestIdentity,
kTestIdentity + sizeof(kTestIdentity)),
std::vector<uint8_t>(kTestEncryptedIdentity,
kTestIdentity + sizeof(kTestEncryptedIdentity)),
[](const SupplicantStatus &status) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
});
}
INSTANTIATE_TEST_CASE_P(
PerInstance, SupplicantStaNetworkHidlTest,
testing::Combine(
testing::ValuesIn(android::hardware::getAllHalInstanceNames(
android::hardware::wifi::V1_0::IWifi::descriptor)),
testing::ValuesIn(android::hardware::getAllHalInstanceNames(
android::hardware::wifi::supplicant::V1_1::ISupplicant::
descriptor))),
android::hardware::PrintInstanceTupleNameToString<>);

View file

@ -19,7 +19,7 @@ cc_library_static {
defaults: ["VtsHalTargetTestDefaults"],
srcs: ["supplicant_hidl_test_utils_1_2.cpp"],
export_include_dirs: [
"."
".",
],
static_libs: [
"VtsHalWifiV1_0TargetTestUtil",
@ -58,7 +58,10 @@ cc_test {
"libwifi-system",
"libwifi-system-iface",
],
test_suites: ["general-tests"],
test_suites: [
"general-tests",
"vts-core",
],
}
cc_test {
@ -82,5 +85,8 @@ cc_test {
"libwifi-system",
"libwifi-system-iface",
],
test_suites: [
"general-tests",
"vts-core",
],
}

View file

@ -14,47 +14,8 @@
* limitations under the License.
*/
#include <android-base/logging.h>
#include <android/hardware/wifi/1.1/IWifi.h>
#include <android/hardware/wifi/supplicant/1.2/ISupplicant.h>
#include "supplicant_hidl_test_utils.h"
#include "wifi_hidl_test_utils.h"
class WifiSupplicantHidlEnvironment_1_2 : public WifiSupplicantHidlEnvironment {
public:
// get the test environment singleton
static WifiSupplicantHidlEnvironment_1_2* Instance() {
static WifiSupplicantHidlEnvironment_1_2* instance =
new WifiSupplicantHidlEnvironment_1_2;
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>();
registerTestService<
::android::hardware::wifi::supplicant::V1_2::ISupplicant>();
}
private:
WifiSupplicantHidlEnvironment_1_2() {}
};
WifiSupplicantHidlEnvironment* gEnv =
WifiSupplicantHidlEnvironment_1_2::Instance();
int main(int argc, char** argv) {
::testing::AddGlobalTestEnvironment(gEnv);
::testing::InitGoogleTest(&argc, argv);
gEnv->init(&argc, argv);
int status = gEnv->initFromOptions(argc, argv);
if (status == 0) {
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
}
return status;
}
// TODO(b/143892896): Remove this file after wifi_hidl_test_utils.cpp is
// updated.
WifiSupplicantHidlEnvironment* gEnv = nullptr;

View file

@ -26,18 +26,24 @@ using ::android::hardware::wifi::supplicant::V1_2::ISupplicantP2pIface;
using ::android::hardware::wifi::supplicant::V1_2::ISupplicantStaIface;
using ::android::hardware::wifi::supplicant::V1_2::ISupplicantStaNetwork;
sp<ISupplicant> getSupplicant_1_2() {
return ISupplicant::castFrom(getSupplicant());
sp<ISupplicant> getSupplicant_1_2(const std::string& supplicant_instance_name,
bool isP2pOn) {
return ISupplicant::castFrom(
getSupplicant(supplicant_instance_name, isP2pOn));
}
sp<ISupplicantStaIface> getSupplicantStaIface_1_2() {
return ISupplicantStaIface::castFrom(getSupplicantStaIface());
sp<ISupplicantStaIface> getSupplicantStaIface_1_2(
const sp<ISupplicant>& supplicant) {
return ISupplicantStaIface::castFrom(getSupplicantStaIface(supplicant));
}
sp<ISupplicantStaNetwork> createSupplicantStaNetwork_1_2() {
return ISupplicantStaNetwork::castFrom(createSupplicantStaNetwork());
sp<ISupplicantStaNetwork> createSupplicantStaNetwork_1_2(
const sp<ISupplicant>& supplicant) {
return ISupplicantStaNetwork::castFrom(
createSupplicantStaNetwork(supplicant));
}
sp<ISupplicantP2pIface> getSupplicantP2pIface_1_2() {
return ISupplicantP2pIface::castFrom(getSupplicantP2pIface());
sp<ISupplicantP2pIface> getSupplicantP2pIface_1_2(
const sp<ISupplicant>& supplicant) {
return ISupplicantP2pIface::castFrom(getSupplicantP2pIface(supplicant));
}

View file

@ -14,24 +14,59 @@
* limitations under the License.
*/
#ifndef SUPPLICANT_HIDL_TEST_UTILS_1_2_H
#define SUPPLICANT_HIDL_TEST_UTILS_1_2_H
#pragma once
#pragma clang diagnostic ignored "-Wweak-vtables"
#include <VtsCoreUtil.h>
#include <android/hardware/wifi/supplicant/1.2/ISupplicant.h>
#include <android/hardware/wifi/supplicant/1.2/ISupplicantP2pIface.h>
#include <android/hardware/wifi/supplicant/1.2/ISupplicantStaIface.h>
#include <android/hardware/wifi/supplicant/1.2/ISupplicantStaNetwork.h>
#include <gtest/gtest.h>
android::sp<android::hardware::wifi::supplicant::V1_2::ISupplicant>
getSupplicant_1_2();
getSupplicant_1_2(const std::string& supplicant_instance_name, bool isP2pOn);
android::sp<android::hardware::wifi::supplicant::V1_2::ISupplicantStaIface>
getSupplicantStaIface_1_2();
getSupplicantStaIface_1_2(
const android::sp<android::hardware::wifi::supplicant::V1_2::ISupplicant>&
supplicant);
android::sp<android::hardware::wifi::supplicant::V1_2::ISupplicantStaNetwork>
createSupplicantStaNetwork_1_2();
createSupplicantStaNetwork_1_2(
const android::sp<android::hardware::wifi::supplicant::V1_2::ISupplicant>&
supplicant);
android::sp<android::hardware::wifi::supplicant::V1_2::ISupplicantP2pIface>
getSupplicantP2pIface_1_2();
getSupplicantP2pIface_1_2(
const android::sp<android::hardware::wifi::supplicant::V1_2::ISupplicant>&
supplicant);
#endif /* SUPPLICANT_HIDL_TEST_UTILS_1_2_H */
class SupplicantHidlTestBase
: public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
public:
virtual void SetUp() override {
wifi_v1_0_instance_name_ = std::get<0>(GetParam());
supplicant_v1_2_instance_name_ = std::get<1>(GetParam());
isP2pOn_ =
testing::deviceSupportsFeature("android.hardware.wifi.direct");
stopSupplicant(wifi_v1_0_instance_name_);
startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_,
supplicant_v1_2_instance_name_);
supplicant_ =
getSupplicant_1_2(supplicant_v1_2_instance_name_, isP2pOn_);
ASSERT_NE(supplicant_.get(), nullptr);
EXPECT_TRUE(turnOnExcessiveLogging(supplicant_));
}
virtual void TearDown() override {
stopSupplicant(wifi_v1_0_instance_name_);
}
protected:
android::sp<android::hardware::wifi::supplicant::V1_2::ISupplicant>
supplicant_;
bool isP2pOn_ = false;
std::string wifi_v1_0_instance_name_;
std::string supplicant_v1_2_instance_name_;
};

View file

@ -18,7 +18,11 @@
#include <VtsHalHidlTargetTestBase.h>
#include <VtsCoreUtil.h>
#include <android/hardware/wifi/1.0/IWifi.h>
#include <android/hardware/wifi/supplicant/1.2/ISupplicantP2pIface.h>
#include <hidl/GtestPrinter.h>
#include <hidl/ServiceManagement.h>
#include "supplicant_hidl_test_utils.h"
#include "supplicant_hidl_test_utils_1_2.h"
@ -26,6 +30,7 @@
using ::android::sp;
using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatus;
using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode;
using ::android::hardware::wifi::supplicant::V1_2::ISupplicant;
using ::android::hardware::wifi::supplicant::V1_2::ISupplicantP2pIface;
namespace {
@ -35,17 +40,15 @@ constexpr char kTestPassphrase[] = "P2pWorld1234";
constexpr uint8_t kTestZeroMacAddr[] = {[0 ... 5] = 0x0};
} // namespace
class SupplicantP2pIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
class SupplicantP2pIfaceHidlTest : public SupplicantHidlTestBase {
public:
virtual void SetUp() override {
startSupplicantAndWaitForHidlService();
EXPECT_TRUE(turnOnExcessiveLogging());
p2p_iface_ = getSupplicantP2pIface_1_2();
SupplicantHidlTestBase::SetUp();
EXPECT_TRUE(turnOnExcessiveLogging(supplicant_));
p2p_iface_ = getSupplicantP2pIface_1_2(supplicant_);
ASSERT_NE(p2p_iface_.get(), nullptr);
}
virtual void TearDown() override { stopSupplicant(); }
protected:
// ISupplicantP2pIface object used for all tests in this fixture.
sp<ISupplicantP2pIface> p2p_iface_;
@ -54,7 +57,7 @@ class SupplicantP2pIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
/*
* Verify that AddGroup_1_2 could create a group successfully.
*/
TEST_F(SupplicantP2pIfaceHidlTest, AddGroup_1_2_Success) {
TEST_P(SupplicantP2pIfaceHidlTest, AddGroup_1_2_Success) {
std::vector<uint8_t> ssid(kTestSsid, kTestSsid + sizeof(kTestSsid));
std::string passphrase = kTestPassphrase;
int freq = 0;
@ -73,7 +76,7 @@ TEST_F(SupplicantP2pIfaceHidlTest, AddGroup_1_2_Success) {
/*
* Verify that AddGroup_1_2 fails due to invalid SSID.
*/
TEST_F(SupplicantP2pIfaceHidlTest, AddGroup_1_2_FailureInvalidSsid) {
TEST_P(SupplicantP2pIfaceHidlTest, AddGroup_1_2_FailureInvalidSsid) {
std::vector<uint8_t> ssid;
std::string passphrase = kTestPassphrase;
int freq = 0;
@ -92,7 +95,7 @@ TEST_F(SupplicantP2pIfaceHidlTest, AddGroup_1_2_FailureInvalidSsid) {
/*
* Verify that AddGroup_1_2 fails due to invalid passphrase.
*/
TEST_F(SupplicantP2pIfaceHidlTest, AddGroup_1_2_FailureInvalidPassphrase) {
TEST_P(SupplicantP2pIfaceHidlTest, AddGroup_1_2_FailureInvalidPassphrase) {
std::vector<uint8_t> ssid(kTestSsid, kTestSsid + sizeof(kTestSsid));
std::string passphrase = "1234";
int freq = 0;
@ -111,7 +114,7 @@ TEST_F(SupplicantP2pIfaceHidlTest, AddGroup_1_2_FailureInvalidPassphrase) {
/*
* Verify that AddGroup_1_2 fails due to invalid frequency.
*/
TEST_F(SupplicantP2pIfaceHidlTest, AddGroup_1_2_FailureInvalidFrequency) {
TEST_P(SupplicantP2pIfaceHidlTest, AddGroup_1_2_FailureInvalidFrequency) {
std::vector<uint8_t> ssid(kTestSsid, kTestSsid + sizeof(kTestSsid));
std::string passphrase = kTestPassphrase;
int freq = 9999;
@ -134,7 +137,7 @@ bool isMacRandomizationSupported(const SupplicantStatus& status) {
/*
* Verify that setMacRandomization successes.
*/
TEST_F(SupplicantP2pIfaceHidlTest, EnableMacRandomization) {
TEST_P(SupplicantP2pIfaceHidlTest, EnableMacRandomization) {
p2p_iface_->setMacRandomization(true, [](const SupplicantStatus& status) {
if (!isMacRandomizationSupported(status)) return;
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
@ -157,3 +160,13 @@ TEST_F(SupplicantP2pIfaceHidlTest, EnableMacRandomization) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
});
}
INSTANTIATE_TEST_CASE_P(
PerInstance, SupplicantP2pIfaceHidlTest,
testing::Combine(
testing::ValuesIn(android::hardware::getAllHalInstanceNames(
android::hardware::wifi::V1_0::IWifi::descriptor)),
testing::ValuesIn(android::hardware::getAllHalInstanceNames(
android::hardware::wifi::supplicant::V1_2::ISupplicant::
descriptor))),
android::hardware::PrintInstanceTupleNameToString<>);

View file

@ -14,7 +14,8 @@
* limitations under the License.
*/
#include <VtsHalHidlTargetTestBase.h>
#include <VtsCoreUtil.h>
#include <android/hardware/wifi/1.0/IWifi.h>
#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaIfaceCallback.h>
#include <android/hardware/wifi/supplicant/1.0/types.h>
#include <android/hardware/wifi/supplicant/1.1/ISupplicantStaIfaceCallback.h>
@ -24,7 +25,9 @@
#include <android/hardware/wifi/supplicant/1.2/types.h>
#include <android/hardware/wifi/supplicant/1.3/ISupplicantStaIface.h>
#include <android/hardware/wifi/supplicant/1.3/types.h>
#include <hidl/GtestPrinter.h>
#include <hidl/HidlSupport.h>
#include <hidl/ServiceManagement.h>
#include <hidl/Status.h>
#include "supplicant_hidl_test_utils.h"
@ -42,6 +45,7 @@ using ::android::hardware::wifi::supplicant::V1_2::DppAkm;
using ::android::hardware::wifi::supplicant::V1_2::DppFailureCode;
using ::android::hardware::wifi::supplicant::V1_2::DppNetRole;
using ::android::hardware::wifi::supplicant::V1_2::DppProgressCode;
using ::android::hardware::wifi::supplicant::V1_2::ISupplicant;
using ::android::hardware::wifi::supplicant::V1_2::ISupplicantStaIface;
using ::android::hardware::wifi::supplicant::V1_2::ISupplicantStaIfaceCallback;
using ::android::hardware::wifi::supplicant::V1_2::ISupplicantStaNetwork;
@ -49,18 +53,16 @@ using ::android::hardware::wifi::supplicant::V1_2::ISupplicantStaNetwork;
#define TIMEOUT_PERIOD 60
class IfaceDppCallback;
class SupplicantStaIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
class SupplicantStaIfaceHidlTest : public SupplicantHidlTestBase {
public:
virtual void SetUp() override {
startSupplicantAndWaitForHidlService();
EXPECT_TRUE(turnOnExcessiveLogging());
sta_iface_ = getSupplicantStaIface_1_2();
SupplicantHidlTestBase::SetUp();
EXPECT_TRUE(turnOnExcessiveLogging(supplicant_));
sta_iface_ = getSupplicantStaIface_1_2(supplicant_);
ASSERT_NE(sta_iface_.get(), nullptr);
count_ = 0;
}
virtual void TearDown() override { stopSupplicant(); }
enum DppCallbackType {
ANY_CALLBACK = -2,
INVALID = -1,
@ -101,6 +103,7 @@ class SupplicantStaIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
// ISupplicantStaIface object used for all tests in this fixture.
sp<ISupplicantStaIface> sta_iface_;
bool isDppSupported() {
uint32_t keyMgmtMask = 0;
@ -254,7 +257,7 @@ class IfaceDppCallback : public IfaceCallback {
/*
* RegisterCallback_1_2
*/
TEST_F(SupplicantStaIfaceHidlTest, RegisterCallback_1_2) {
TEST_P(SupplicantStaIfaceHidlTest, RegisterCallback_1_2) {
sta_iface_->registerCallback_1_2(
new IfaceCallback(), [](const SupplicantStatus& status) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
@ -264,7 +267,7 @@ TEST_F(SupplicantStaIfaceHidlTest, RegisterCallback_1_2) {
/*
* GetKeyMgmtCapabilities
*/
TEST_F(SupplicantStaIfaceHidlTest, GetKeyMgmtCapabilities) {
TEST_P(SupplicantStaIfaceHidlTest, GetKeyMgmtCapabilities) {
sta_iface_->getKeyMgmtCapabilities(
[&](const SupplicantStatus& status, uint32_t keyMgmtMask) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
@ -280,7 +283,7 @@ TEST_F(SupplicantStaIfaceHidlTest, GetKeyMgmtCapabilities) {
/*
* AddDppPeerUriAndRomveUri
*/
TEST_F(SupplicantStaIfaceHidlTest, AddDppPeerUriAndRomveUri) {
TEST_P(SupplicantStaIfaceHidlTest, AddDppPeerUriAndRomveUri) {
// We need to first get the key management capabilities from the device.
// If DPP is not supported, we just pass the test.
if (!isDppSupported()) {
@ -312,7 +315,7 @@ TEST_F(SupplicantStaIfaceHidlTest, AddDppPeerUriAndRomveUri) {
/*
* StartDppEnrolleeInitiator
*/
TEST_F(SupplicantStaIfaceHidlTest, StartDppEnrolleeInitiator) {
TEST_P(SupplicantStaIfaceHidlTest, StartDppEnrolleeInitiator) {
// We need to first get the key management capabilities from the device.
// If DPP is not supported, we just pass the test.
if (!isDppSupported()) {
@ -376,7 +379,7 @@ TEST_F(SupplicantStaIfaceHidlTest, StartDppEnrolleeInitiator) {
/*
* StartDppConfiguratorInitiator
*/
TEST_F(SupplicantStaIfaceHidlTest, StartDppConfiguratorInitiator) {
TEST_P(SupplicantStaIfaceHidlTest, StartDppConfiguratorInitiator) {
// We need to first get the key management capabilities from the device.
// If DPP is not supported, we just pass the test.
if (!isDppSupported()) {
@ -443,3 +446,13 @@ TEST_F(SupplicantStaIfaceHidlTest, StartDppConfiguratorInitiator) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
});
}
INSTANTIATE_TEST_CASE_P(
PerInstance, SupplicantStaIfaceHidlTest,
testing::Combine(
testing::ValuesIn(android::hardware::getAllHalInstanceNames(
android::hardware::wifi::V1_0::IWifi::descriptor)),
testing::ValuesIn(android::hardware::getAllHalInstanceNames(
android::hardware::wifi::supplicant::V1_2::ISupplicant::
descriptor))),
android::hardware::PrintInstanceTupleNameToString<>);

View file

@ -16,8 +16,12 @@
#include <android-base/logging.h>
#include <VtsHalHidlTargetTestBase.h>
#include <VtsCoreUtil.h>
#include <android/hardware/wifi/1.0/IWifi.h>
#include <android/hardware/wifi/1.1/IWifi.h>
#include <android/hardware/wifi/supplicant/1.1/ISupplicantStaNetwork.h>
#include <hidl/GtestPrinter.h>
#include <hidl/ServiceManagement.h>
#include "supplicant_hidl_test_utils.h"
#include "supplicant_hidl_test_utils_1_2.h"
@ -26,24 +30,21 @@ using ::android::sp;
using ::android::hardware::hidl_vec;
using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatus;
using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode;
using ::android::hardware::wifi::supplicant::V1_2::ISupplicant;
using ::android::hardware::wifi::supplicant::V1_2::ISupplicantStaNetwork;
// namespace {
// constexpr uint8_t kTestIdentity[] = {0x45, 0x67, 0x98, 0x67, 0x56};
// constexpr uint8_t kTestEncryptedIdentity[] = {0x35, 0x37, 0x58, 0x57, 0x26};
//} // namespace
class SupplicantStaNetworkHidlTest
: public ::testing::VtsHalHidlTargetTestBase {
class SupplicantStaNetworkHidlTest : public SupplicantHidlTestBase {
public:
virtual void SetUp() override {
startSupplicantAndWaitForHidlService();
EXPECT_TRUE(turnOnExcessiveLogging());
sta_network_ = createSupplicantStaNetwork_1_2();
SupplicantHidlTestBase::SetUp();
sta_network_ = createSupplicantStaNetwork_1_2(supplicant_);
ASSERT_NE(sta_network_.get(), nullptr);
}
virtual void TearDown() override { stopSupplicant(); }
protected:
// ISupplicantStaNetwork object used for all tests in this fixture.
sp<ISupplicantStaNetwork> sta_network_;
@ -52,7 +53,7 @@ class SupplicantStaNetworkHidlTest
/*
* SetGetSaePassword
*/
TEST_F(SupplicantStaNetworkHidlTest, SetGetSaePassword) {
TEST_P(SupplicantStaNetworkHidlTest, SetGetSaePassword) {
std::string password = "topsecret";
sta_network_->setSaePassword(password, [](const SupplicantStatus &status) {
@ -69,7 +70,7 @@ TEST_F(SupplicantStaNetworkHidlTest, SetGetSaePassword) {
/*
* SetGetSaePasswordId
*/
TEST_F(SupplicantStaNetworkHidlTest, SetGetSaePasswordId) {
TEST_P(SupplicantStaNetworkHidlTest, SetGetSaePasswordId) {
std::string passwordId = "id1";
sta_network_->setSaePasswordId(
@ -87,7 +88,7 @@ TEST_F(SupplicantStaNetworkHidlTest, SetGetSaePasswordId) {
/*
* SetGetGroupMgmtCipher
*/
TEST_F(SupplicantStaNetworkHidlTest, SetGetGroupMgmtCipher) {
TEST_P(SupplicantStaNetworkHidlTest, SetGetGroupMgmtCipher) {
uint32_t groupMgmtCipher =
(uint32_t)ISupplicantStaNetwork::GroupMgmtCipherMask::BIP_GMAC_256;
@ -107,7 +108,7 @@ TEST_F(SupplicantStaNetworkHidlTest, SetGetGroupMgmtCipher) {
/*
* SetGetKeyMgmt_1_2
*/
TEST_F(SupplicantStaNetworkHidlTest, SetGetKeyMgmt_1_2) {
TEST_P(SupplicantStaNetworkHidlTest, SetGetKeyMgmt_1_2) {
uint32_t keyMgmt = (uint32_t)ISupplicantStaNetwork::KeyMgmtMask::SAE;
sta_network_->setKeyMgmt_1_2(keyMgmt, [](const SupplicantStatus &status) {
@ -124,7 +125,7 @@ TEST_F(SupplicantStaNetworkHidlTest, SetGetKeyMgmt_1_2) {
/*
* SetGetGroupCipher_1_2
*/
TEST_F(SupplicantStaNetworkHidlTest, SetGetGroupCipher_1_2) {
TEST_P(SupplicantStaNetworkHidlTest, SetGetGroupCipher_1_2) {
uint32_t groupCipher =
(uint32_t)ISupplicantStaNetwork::GroupCipherMask::GCMP_256;
@ -144,7 +145,7 @@ TEST_F(SupplicantStaNetworkHidlTest, SetGetGroupCipher_1_2) {
/*
* SetGetPairwiseCipher_1_2
*/
TEST_F(SupplicantStaNetworkHidlTest, SetGetPairwiseCipher_1_2) {
TEST_P(SupplicantStaNetworkHidlTest, SetGetPairwiseCipher_1_2) {
uint32_t pairwiseCipher =
(uint32_t)ISupplicantStaNetwork::PairwiseCipherMask::GCMP_256;
@ -164,7 +165,7 @@ TEST_F(SupplicantStaNetworkHidlTest, SetGetPairwiseCipher_1_2) {
/*
* EnableSuiteBEapOpenSslCiphers
*/
TEST_F(SupplicantStaNetworkHidlTest, EnableSuiteBEapOpenSslCiphers) {
TEST_P(SupplicantStaNetworkHidlTest, EnableSuiteBEapOpenSslCiphers) {
sta_network_->enableSuiteBEapOpenSslCiphers(
[](const SupplicantStatus &status) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
@ -179,7 +180,7 @@ TEST_F(SupplicantStaNetworkHidlTest, EnableSuiteBEapOpenSslCiphers) {
/*
* EnableTlsSuiteBEapPhase1Param
*/
TEST_F(SupplicantStaNetworkHidlTest, EnableTlsSuiteBEapPhase1Param) {
TEST_P(SupplicantStaNetworkHidlTest, EnableTlsSuiteBEapPhase1Param) {
sta_network_->enableTlsSuiteBEapPhase1Param(
true, [](const SupplicantStatus &status) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
@ -190,3 +191,13 @@ TEST_F(SupplicantStaNetworkHidlTest, EnableTlsSuiteBEapPhase1Param) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
});
}
INSTANTIATE_TEST_CASE_P(
PerInstance, SupplicantStaNetworkHidlTest,
testing::Combine(
testing::ValuesIn(android::hardware::getAllHalInstanceNames(
android::hardware::wifi::V1_0::IWifi::descriptor)),
testing::ValuesIn(android::hardware::getAllHalInstanceNames(
android::hardware::wifi::supplicant::V1_2::ISupplicant::
descriptor))),
android::hardware::PrintInstanceTupleNameToString<>);