Convert VtsHalWifiSupplicantV1_3TargetTest to be parameterized test

Bug: 142397658
Test: atest VtsHalWifiSupplicantV1_3TargetTest
Change-Id: I85a064b05439776c3083f8cf9762d5f2a994b959
This commit is contained in:
Dan Shi
2019-11-14 15:16:46 -08:00
parent 26ca8f9384
commit 79e804d6fb
6 changed files with 121 additions and 81 deletions

View File

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

View File

@@ -14,49 +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.3/ISupplicant.h>
#include "supplicant_hidl_test_utils.h"
#include "wifi_hidl_test_utils.h"
class WifiSupplicantHidlEnvironment_1_3 : public WifiSupplicantHidlEnvironment {
public:
// get the test environment singleton
static WifiSupplicantHidlEnvironment_1_3* Instance() {
static WifiSupplicantHidlEnvironment_1_3* instance =
new WifiSupplicantHidlEnvironment_1_3;
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>();
registerTestService<
::android::hardware::wifi::supplicant::V1_3::ISupplicant>();
}
private:
WifiSupplicantHidlEnvironment_1_3() {}
};
WifiSupplicantHidlEnvironment* gEnv =
WifiSupplicantHidlEnvironment_1_3::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

@@ -21,13 +21,25 @@
#include "supplicant_hidl_test_utils_1_3.h"
using ::android::sp;
using ::android::hardware::wifi::supplicant::V1_3::ISupplicant;
using ::android::hardware::wifi::supplicant::V1_3::ISupplicantStaIface;
using ::android::hardware::wifi::supplicant::V1_3::ISupplicantStaNetwork;
sp<ISupplicantStaIface> getSupplicantStaIface_1_3() {
return ISupplicantStaIface::castFrom(getSupplicantStaIface());
sp<ISupplicantStaIface> getSupplicantStaIface_1_3(
const android::sp<android::hardware::wifi::supplicant::V1_3::ISupplicant>&
supplicant) {
return ISupplicantStaIface::castFrom(getSupplicantStaIface(supplicant));
}
sp<ISupplicantStaNetwork> createSupplicantStaNetwork_1_3() {
return ISupplicantStaNetwork::castFrom(createSupplicantStaNetwork());
sp<ISupplicantStaNetwork> createSupplicantStaNetwork_1_3(
const android::sp<android::hardware::wifi::supplicant::V1_3::ISupplicant>&
supplicant) {
return ISupplicantStaNetwork::castFrom(
createSupplicantStaNetwork(supplicant));
}
sp<ISupplicant> getSupplicant_1_3(const std::string& supplicant_instance_name,
bool isP2pOn) {
return ISupplicant::castFrom(
getSupplicant(supplicant_instance_name, isP2pOn));
}

View File

@@ -17,12 +17,18 @@
#ifndef SUPPLICANT_HIDL_TEST_UTILS_1_3_H
#define SUPPLICANT_HIDL_TEST_UTILS_1_3_H
#include <android/hardware/wifi/supplicant/1.3/ISupplicant.h>
#include <android/hardware/wifi/supplicant/1.3/ISupplicantStaIface.h>
#include <android/hardware/wifi/supplicant/1.3/ISupplicantStaNetwork.h>
android::sp<android::hardware::wifi::supplicant::V1_3::ISupplicantStaIface>
getSupplicantStaIface_1_3();
getSupplicantStaIface_1_3(
const android::sp<android::hardware::wifi::supplicant::V1_3::ISupplicant>&
supplicant);
android::sp<android::hardware::wifi::supplicant::V1_3::ISupplicantStaNetwork>
createSupplicantStaNetwork_1_3();
createSupplicantStaNetwork_1_3(
const android::sp<android::hardware::wifi::supplicant::V1_3::ISupplicant>&
supplicant);
android::sp<android::hardware::wifi::supplicant::V1_3::ISupplicant>
getSupplicant_1_3(const std::string& supplicant_instance_name, bool isP2pOn);
#endif /* SUPPLICANT_HIDL_TEST_UTILS_1_3_H */

View File

@@ -14,13 +14,19 @@
* limitations under the License.
*/
#include <VtsHalHidlTargetTestBase.h>
#include <VtsCoreUtil.h>
#include <android/hardware/wifi/1.1/IWifi.h>
#include <android/hardware/wifi/supplicant/1.1/ISupplicant.h>
#include <android/hardware/wifi/supplicant/1.2/types.h>
#include <android/hardware/wifi/supplicant/1.3/ISupplicant.h>
#include <android/hardware/wifi/supplicant/1.3/ISupplicantStaIface.h>
#include <android/hardware/wifi/supplicant/1.3/ISupplicantStaIfaceCallback.h>
#include <android/hardware/wifi/supplicant/1.3/ISupplicantStaNetwork.h>
#include <android/hardware/wifi/supplicant/1.3/types.h>
#include <gtest/gtest.h>
#include <hidl/GtestPrinter.h>
#include <hidl/HidlSupport.h>
#include <hidl/ServiceManagement.h>
#include <hidl/Status.h>
#include "supplicant_hidl_test_utils.h"
@@ -40,6 +46,7 @@ using ::android::hardware::wifi::supplicant::V1_2::DppNetRole;
using ::android::hardware::wifi::supplicant::V1_2::DppProgressCode;
using ::android::hardware::wifi::supplicant::V1_3::ConnectionCapabilities;
using ::android::hardware::wifi::supplicant::V1_3::DppSuccessCode;
using ::android::hardware::wifi::supplicant::V1_3::ISupplicant;
using ::android::hardware::wifi::supplicant::V1_3::ISupplicantStaIface;
using ::android::hardware::wifi::supplicant::V1_3::ISupplicantStaIfaceCallback;
using ::android::hardware::wifi::supplicant::V1_3::ISupplicantStaNetwork;
@@ -48,16 +55,27 @@ using ::android::hardware::wifi::supplicant::V1_3::WpaDriverCapabilitiesMask;
#define TIMEOUT_PERIOD 60
class IfaceDppCallback;
class SupplicantStaIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
class SupplicantStaIfaceHidlTest
: public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
public:
virtual void SetUp() override {
startSupplicantAndWaitForHidlService();
EXPECT_TRUE(turnOnExcessiveLogging());
sta_iface_ = getSupplicantStaIface_1_3();
wifi_v1_0_instance_name_ = std::get<0>(GetParam());
supplicant_v1_3_instance_name_ = std::get<1>(GetParam());
isP2pOn_ =
testing::deviceSupportsFeature("android.hardware.wifi.direct");
startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_,
supplicant_v1_3_instance_name_);
supplicant_ =
getSupplicant_1_3(supplicant_v1_3_instance_name_, isP2pOn_);
EXPECT_TRUE(turnOnExcessiveLogging(supplicant_));
sta_iface_ = getSupplicantStaIface_1_3(supplicant_);
ASSERT_NE(sta_iface_.get(), nullptr);
}
virtual void TearDown() override { stopSupplicant(); }
virtual void TearDown() override {
stopSupplicant(wifi_v1_0_instance_name_);
}
int64_t pmkCacheExpirationTimeInSec;
std::vector<uint8_t> serializedPmkCacheEntry;
@@ -104,6 +122,11 @@ class SupplicantStaIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
// ISupplicantStaIface object used for all tests in this fixture.
sp<ISupplicantStaIface> sta_iface_;
sp<ISupplicant> supplicant_;
bool isP2pOn_ = false;
std::string wifi_v1_0_instance_name_;
std::string supplicant_v1_3_instance_name_;
bool isDppSupported() {
uint32_t keyMgmtMask = 0;
@@ -302,7 +325,7 @@ class IfaceBssTmHandlingDoneCallback : public IfaceCallback {
/*
* RegisterCallback_1_3
*/
TEST_F(SupplicantStaIfaceHidlTest, RegisterCallback_1_3) {
TEST_P(SupplicantStaIfaceHidlTest, RegisterCallback_1_3) {
sta_iface_->registerCallback_1_3(
new IfaceCallback(), [](const SupplicantStatus& status) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
@@ -312,7 +335,7 @@ TEST_F(SupplicantStaIfaceHidlTest, RegisterCallback_1_3) {
/*
* getConnectionCapabilities
*/
TEST_F(SupplicantStaIfaceHidlTest, GetConnectionCapabilities) {
TEST_P(SupplicantStaIfaceHidlTest, GetConnectionCapabilities) {
sta_iface_->getConnectionCapabilities(
[&](const SupplicantStatus& status,
ConnectionCapabilities /* capabilities */) {
@@ -323,7 +346,7 @@ TEST_F(SupplicantStaIfaceHidlTest, GetConnectionCapabilities) {
/*
* GetWpaDriverCapabilities
*/
TEST_F(SupplicantStaIfaceHidlTest, GetWpaDriverCapabilities) {
TEST_P(SupplicantStaIfaceHidlTest, GetWpaDriverCapabilities) {
sta_iface_->getWpaDriverCapabilities(
[&](const SupplicantStatus& status, uint32_t) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
@@ -333,7 +356,7 @@ TEST_F(SupplicantStaIfaceHidlTest, GetWpaDriverCapabilities) {
/*
* SetMboCellularDataStatus
*/
TEST_F(SupplicantStaIfaceHidlTest, SetMboCellularDataStatus) {
TEST_P(SupplicantStaIfaceHidlTest, SetMboCellularDataStatus) {
uint32_t driverCapMask = 0;
// Get MBO support from the device.
@@ -358,7 +381,7 @@ TEST_F(SupplicantStaIfaceHidlTest, SetMboCellularDataStatus) {
/*
* GetKeyMgmtCapabilities_1_3
*/
TEST_F(SupplicantStaIfaceHidlTest, GetKeyMgmtCapabilities_1_3) {
TEST_P(SupplicantStaIfaceHidlTest, GetKeyMgmtCapabilities_1_3) {
sta_iface_->getKeyMgmtCapabilities_1_3([&](const SupplicantStatus& status,
uint32_t keyMgmtMask) {
if (SupplicantStatusCode::SUCCESS != status.code) {
@@ -377,7 +400,7 @@ TEST_F(SupplicantStaIfaceHidlTest, GetKeyMgmtCapabilities_1_3) {
/*
* 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()) {
@@ -428,7 +451,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()) {
@@ -480,3 +503,12 @@ 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_3::ISupplicant::
descriptor))),
android::hardware::PrintInstanceTupleNameToString<>);

View File

@@ -16,9 +16,16 @@
#include <android-base/logging.h>
#include <VtsCoreUtil.h>
#include <VtsHalHidlTargetTestBase.h>
#include <android/hardware/wifi/1.0/IWifi.h>
#include <android/hardware/wifi/1.1/IWifi.h>
#include <android/hardware/wifi/supplicant/1.3/ISupplicant.h>
#include <android/hardware/wifi/supplicant/1.3/ISupplicantStaIface.h>
#include <android/hardware/wifi/supplicant/1.3/ISupplicantStaNetwork.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_3.h"
@@ -28,6 +35,7 @@ using ::android::hardware::hidl_string;
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_3::ISupplicant;
using ::android::hardware::wifi::supplicant::V1_3::ISupplicantStaIface;
using ::android::hardware::wifi::supplicant::V1_3::ISupplicantStaNetwork;
using ::android::hardware::wifi::supplicant::V1_3::OcspType;
@@ -37,23 +45,34 @@ constexpr OcspType kTestInvalidOcspType = (OcspType)-1;
} // namespace
class SupplicantStaNetworkHidlTest
: public ::testing::VtsHalHidlTargetTestBase {
: public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
public:
virtual void SetUp() override {
startSupplicantAndWaitForHidlService();
EXPECT_TRUE(turnOnExcessiveLogging());
sta_iface_ = getSupplicantStaIface_1_3();
ASSERT_NE(nullptr, sta_iface_.get());
sta_network_ = createSupplicantStaNetwork_1_3();
ASSERT_NE(nullptr, sta_network_.get());
wifi_v1_0_instance_name_ = std::get<0>(GetParam());
supplicant_v1_3_instance_name_ = std::get<1>(GetParam());
isP2pOn_ =
testing::deviceSupportsFeature("android.hardware.wifi.direct");
startSupplicantAndWaitForHidlService(wifi_v1_0_instance_name_,
supplicant_v1_3_instance_name_);
supplicant_ =
getSupplicant_1_3(supplicant_v1_3_instance_name_, isP2pOn_);
EXPECT_TRUE(turnOnExcessiveLogging(supplicant_));
sta_network_ = createSupplicantStaNetwork_1_3(supplicant_);
ASSERT_NE(sta_network_.get(), nullptr);
}
virtual void TearDown() override { stopSupplicant(); }
virtual void TearDown() override {
stopSupplicant(wifi_v1_0_instance_name_);
}
protected:
sp<ISupplicantStaIface> sta_iface_;
// ISupplicantStaNetwork object used for all tests in this fixture.
sp<ISupplicantStaNetwork> sta_network_;
sp<ISupplicant> supplicant_;
bool isP2pOn_ = false;
std::string wifi_v1_0_instance_name_;
std::string supplicant_v1_3_instance_name_;
bool isWapiSupported() {
uint32_t keyMgmtMask = 0;
@@ -78,7 +97,7 @@ class SupplicantStaNetworkHidlTest
/*
* SetGetOcsp
*/
TEST_F(SupplicantStaNetworkHidlTest, SetGetOcsp) {
TEST_P(SupplicantStaNetworkHidlTest, SetGetOcsp) {
OcspType testOcspType = kTestOcspType;
sta_network_->setOcsp(testOcspType, [](const SupplicantStatus &status) {
@@ -100,7 +119,7 @@ TEST_F(SupplicantStaNetworkHidlTest, SetGetOcsp) {
/*
* SetPmkCacheEntry
*/
TEST_F(SupplicantStaNetworkHidlTest, SetPmkCache) {
TEST_P(SupplicantStaNetworkHidlTest, SetPmkCache) {
uint8_t bytes[128] = {0};
std::vector<uint8_t> serializedEntry(bytes, bytes + sizeof(bytes));
@@ -113,7 +132,7 @@ TEST_F(SupplicantStaNetworkHidlTest, SetPmkCache) {
/*
* SetGetKeyMgmt_1_3, check new WAPI proto support
*/
TEST_F(SupplicantStaNetworkHidlTest, SetGetKeyMgmt_1_3) {
TEST_P(SupplicantStaNetworkHidlTest, SetGetKeyMgmt_1_3) {
uint32_t keyMgmt = (uint32_t)ISupplicantStaNetwork::KeyMgmtMask::WAPI_PSK;
sta_network_->setKeyMgmt_1_3(keyMgmt, [](const SupplicantStatus &status) {
@@ -155,7 +174,7 @@ TEST_F(SupplicantStaNetworkHidlTest, SetGetKeyMgmt_1_3) {
/*
* SetGetProto_1_3, check new WAPI proto support
*/
TEST_F(SupplicantStaNetworkHidlTest, SetGetProto_1_3) {
TEST_P(SupplicantStaNetworkHidlTest, SetGetProto_1_3) {
uint32_t wapiProto = (uint32_t)ISupplicantStaNetwork::ProtoMask::WAPI;
sta_network_->setProto(wapiProto, [](const SupplicantStatus &status) {
if (SupplicantStatusCode::SUCCESS != status.code) {
@@ -176,7 +195,7 @@ TEST_F(SupplicantStaNetworkHidlTest, SetGetProto_1_3) {
/*
* SetGetGroupCipher_1_3, check new WAPI support
*/
TEST_F(SupplicantStaNetworkHidlTest, SetGetGroupCipher_1_3) {
TEST_P(SupplicantStaNetworkHidlTest, SetGetGroupCipher_1_3) {
uint32_t groupCipher =
(uint32_t)ISupplicantStaNetwork::GroupCipherMask::SMS4;
@@ -203,7 +222,7 @@ TEST_F(SupplicantStaNetworkHidlTest, SetGetGroupCipher_1_3) {
/*
* SetGetPairwiseCipher_1_3, check new WAPI support
*/
TEST_F(SupplicantStaNetworkHidlTest, SetGetPairwiseCipher_1_3) {
TEST_P(SupplicantStaNetworkHidlTest, SetGetPairwiseCipher_1_3) {
uint32_t pairwiseCipher =
(uint32_t)ISupplicantStaNetwork::PairwiseCipherMask::SMS4;
@@ -230,7 +249,7 @@ TEST_F(SupplicantStaNetworkHidlTest, SetGetPairwiseCipher_1_3) {
/*
* SetGetWapiCertSuite
*/
TEST_F(SupplicantStaNetworkHidlTest, SetGetWapiCertSuite) {
TEST_P(SupplicantStaNetworkHidlTest, SetGetWapiCertSuite) {
hidl_string testWapiCertSuite = "suite";
if (isWapiSupported()) {
@@ -266,3 +285,12 @@ TEST_F(SupplicantStaNetworkHidlTest, SetGetWapiCertSuite) {
});
}
}
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_3::ISupplicant::
descriptor))),
android::hardware::PrintInstanceTupleNameToString<>);