diff options
author | Roshan Pius <rpius@google.com> | 2018-07-25 12:32:00 -0700 |
---|---|---|
committer | kumachang <kumachang@google.com> | 2018-11-16 14:46:19 +0800 |
commit | 61c8ea596a9261a0913840f479ba6e5dc76527d3 (patch) | |
tree | 4181c8b16c778069155f85e6707c9c605c7f9f92 /wifi/supplicant | |
parent | 745badbe07badbd63c766a9e7290cf4abcff1766 (diff) | |
download | android_hardware_interfaces-61c8ea596a9261a0913840f479ba6e5dc76527d3.tar.gz android_hardware_interfaces-61c8ea596a9261a0913840f479ba6e5dc76527d3.tar.bz2 android_hardware_interfaces-61c8ea596a9261a0913840f479ba6e5dc76527d3.zip |
wifi(vts): Separate P2P specific tests
Similar to how NAN specific tests were separated from wifi HAL VTS
test suite, separate out P2P specific tests in wpa_supplicant HAL VTS test
suite.
Changes in the CL:
a) Use the |gEnv->isP2pOn| flag to skip P2P tests in SupplicantHidlTest.
b) Seprare SupplicantP2pIfaceHidlTest into a new test module.
Bug: 73306751
Test: Ran VTS tests
vts-tradefed run commandAndExit vts-hal --skip-all-system-status-check --primary-abi-only --skip-preconditions --module VtsHalWifiSupplicantV1_0Host -l INFO
vts-tradefed run commandAndExit vts-hal --skip-all-system-status-check --primary-abi-only --skip-preconditions --module VtsHalWifiSupplicantV1_1Host -l INFO
vts-tradefed run commandAndExit vts-hal --skip-all-system-status-check --primary-abi-only --skip-preconditions --module VtsHalWifiSupplicantP2pV1_0Target -l INFO
Change-Id: I65de3ff5cde023bfba2ac3a6c38ff9ad680de8bc
Diffstat (limited to 'wifi/supplicant')
7 files changed, 95 insertions, 15 deletions
diff --git a/wifi/supplicant/1.0/vts/functional/Android.bp b/wifi/supplicant/1.0/vts/functional/Android.bp index ee6a68e04..7a6857cf4 100644 --- a/wifi/supplicant/1.0/vts/functional/Android.bp +++ b/wifi/supplicant/1.0/vts/functional/Android.bp @@ -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", + ], +} diff --git a/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp b/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp index adf2a85ab..6ca0546cf 100644 --- a/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp +++ b/wifi/supplicant/1.0/vts/functional/VtsHalWifiSupplicantV1_0TargetTest.cpp @@ -44,7 +44,10 @@ 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; } diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp index c6ac03ce6..436b88b81 100644 --- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp +++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp @@ -30,6 +30,8 @@ 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 +74,13 @@ 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,10 @@ 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); + }); + } } diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp index bdedfba25..47c305600 100644 --- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp +++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.cpp @@ -225,7 +225,9 @@ 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; } diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h index d4a768fb5..21a1ae62d 100644 --- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h +++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test_utils.h @@ -23,6 +23,8 @@ #include <android/hardware/wifi/supplicant/1.0/ISupplicantStaNetwork.h> #include <android/hardware/wifi/supplicant/1.1/ISupplicant.h> +#include <getopt.h> + #include <VtsHalHidlTargetTestEnvBase.h> // Used to stop the android wifi framework before every test. @@ -50,11 +52,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 */ diff --git a/wifi/supplicant/1.1/vts/functional/VtsHalWifiSupplicantV1_1TargetTest.cpp b/wifi/supplicant/1.1/vts/functional/VtsHalWifiSupplicantV1_1TargetTest.cpp index 3d24fc3ee..9063a3ba4 100644 --- a/wifi/supplicant/1.1/vts/functional/VtsHalWifiSupplicantV1_1TargetTest.cpp +++ b/wifi/supplicant/1.1/vts/functional/VtsHalWifiSupplicantV1_1TargetTest.cpp @@ -30,8 +30,11 @@ 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,10 @@ 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; } diff --git a/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test.cpp b/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test.cpp index 7e773d611..28f980cf8 100644 --- a/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test.cpp +++ b/wifi/supplicant/1.1/vts/functional/supplicant_hidl_test.cpp @@ -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; |