Loading wifi/hostapd/1.1/vts/functional/hostapd_hidl_test.cpp +211 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,14 @@ using ::android::hardware::wifi::hostapd::V1_0::HostapdStatusCode; using ::android::hardware::wifi::hostapd::V1_1::IHostapd; using ::android::hardware::wifi::hostapd::V1_1::IHostapdCallback; namespace { constexpr unsigned char kNwSsid[] = {'t', 'e', 's', 't', '1', '2', '3', '4', '5'}; constexpr char kNwPassphrase[] = "test12345"; constexpr int kIfaceChannel = 6; constexpr int kIfaceInvalidChannel = 567; } // namespace class HostapdHidlTest : public ::testing::VtsHalHidlTargetTestBase { public: virtual void SetUp() override { Loading @@ -45,6 +53,99 @@ class HostapdHidlTest : public ::testing::VtsHalHidlTargetTestBase { virtual void TearDown() override { stopHostapd(); } protected: std::string getPrimaryWlanIfaceName() { std::array<char, PROPERTY_VALUE_MAX> buffer; property_get("wifi.interface", buffer.data(), "wlan0"); return buffer.data(); } IHostapd::IfaceParams getIfaceParamsWithAcs() { ::android::hardware::wifi::hostapd::V1_0::IHostapd::IfaceParams iface_params; IHostapd::IfaceParams iface_params_1_1; iface_params.ifaceName = getPrimaryWlanIfaceName(); iface_params.hwModeParams.enable80211N = true; iface_params.hwModeParams.enable80211AC = false; iface_params.channelParams.enableAcs = true; iface_params.channelParams.acsShouldExcludeDfs = true; iface_params.channelParams.channel = 0; iface_params.channelParams.band = IHostapd::Band::BAND_ANY; iface_params_1_1.V1_0 = iface_params; return iface_params_1_1; } IHostapd::IfaceParams getIfaceParamsWithAcsAndChannelRange() { IHostapd::IfaceParams iface_params_1_1 = getIfaceParamsWithAcs(); IHostapd::ChannelParams channelParams; IHostapd::AcsChannelRange acsChannelRange; acsChannelRange.start = 1; acsChannelRange.end = 11; std::vector<IHostapd::AcsChannelRange> vec_acsChannelRange; vec_acsChannelRange.push_back(acsChannelRange); channelParams.acsChannelRanges = vec_acsChannelRange; iface_params_1_1.channelParams = channelParams; return iface_params_1_1; } IHostapd::IfaceParams getIfaceParamsWithAcsAndInvalidChannelRange() { IHostapd::IfaceParams iface_params_1_1 = getIfaceParamsWithAcsAndChannelRange(); iface_params_1_1.channelParams.acsChannelRanges[0].start = 222; iface_params_1_1.channelParams.acsChannelRanges[0].end = 999; return iface_params_1_1; } IHostapd::IfaceParams getIfaceParamsWithoutAcs() { ::android::hardware::wifi::hostapd::V1_0::IHostapd::IfaceParams iface_params; IHostapd::IfaceParams iface_params_1_1; iface_params.ifaceName = getPrimaryWlanIfaceName(); iface_params.hwModeParams.enable80211N = true; iface_params.hwModeParams.enable80211AC = false; iface_params.channelParams.enableAcs = false; iface_params.channelParams.acsShouldExcludeDfs = false; iface_params.channelParams.channel = kIfaceChannel; iface_params.channelParams.band = IHostapd::Band::BAND_2_4_GHZ; iface_params_1_1.V1_0 = iface_params; return iface_params_1_1; } IHostapd::IfaceParams getIfaceParamsWithInvalidChannel() { IHostapd::IfaceParams iface_params_1_1 = getIfaceParamsWithoutAcs(); iface_params_1_1.V1_0.channelParams.channel = kIfaceInvalidChannel; return iface_params_1_1; } IHostapd::NetworkParams getPskNwParams() { IHostapd::NetworkParams nw_params; nw_params.ssid = std::vector<uint8_t>(kNwSsid, kNwSsid + sizeof(kNwSsid)); nw_params.isHidden = false; nw_params.encryptionType = IHostapd::EncryptionType::WPA2; nw_params.pskPassphrase = kNwPassphrase; return nw_params; } IHostapd::NetworkParams getInvalidPskNwParams() { IHostapd::NetworkParams nw_params; nw_params.ssid = std::vector<uint8_t>(kNwSsid, kNwSsid + sizeof(kNwSsid)); nw_params.isHidden = false; nw_params.encryptionType = IHostapd::EncryptionType::WPA2; return nw_params; } IHostapd::NetworkParams getOpenNwParams() { IHostapd::NetworkParams nw_params; nw_params.ssid = std::vector<uint8_t>(kNwSsid, kNwSsid + sizeof(kNwSsid)); nw_params.isHidden = false; nw_params.encryptionType = IHostapd::EncryptionType::NONE; return nw_params; } // IHostapd object used for all tests in this fixture. sp<IHostapd> hostapd_; }; Loading @@ -65,3 +166,113 @@ TEST_F(HostapdHidlTest, registerCallback) { EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); }); } /** * Adds an access point with PSK network config & ACS enabled. * Access point creation should pass. */ TEST_F(HostapdHidlTest, AddPskAccessPointWithAcs) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithAcs(), getPskNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } /** * Adds an access point with PSK network config, ACS enabled & channel Range. * Access point creation should pass. */ TEST_F(HostapdHidlTest, AddPskAccessPointWithAcsAndChannelRange) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithAcsAndChannelRange(), getPskNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } /** * Adds an access point with invalid channel range. * Access point creation should fail. */ TEST_F(HostapdHidlTest, AddPskAccessPointWithAcsAndInvalidChannelRange) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithAcsAndInvalidChannelRange(), getPskNwParams()); EXPECT_NE(HostapdStatusCode::SUCCESS, status.code); } /** * Adds an access point with Open network config & ACS enabled. * Access point creation should pass. */ TEST_F(HostapdHidlTest, AddOpenAccessPointWithAcs) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithAcs(), getOpenNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } /** * Adds an access point with PSK network config & ACS disabled. * Access point creation should pass. */ TEST_F(HostapdHidlTest, AddPskAccessPointWithoutAcs) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithoutAcs(), getPskNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } /** * Adds an access point with Open network config & ACS disabled. * Access point creation should pass. */ TEST_F(HostapdHidlTest, AddOpenAccessPointWithoutAcs) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithoutAcs(), getOpenNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } /** * Adds & then removes an access point with PSK network config & ACS enabled. * Access point creation & removal should pass. */ TEST_F(HostapdHidlTest, RemoveAccessPointWithAcs) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithAcs(), getPskNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); status = HIDL_INVOKE(hostapd_, removeAccessPoint, getPrimaryWlanIfaceName()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } /** * Adds & then removes an access point with PSK network config & ACS disabled. * Access point creation & removal should pass. */ TEST_F(HostapdHidlTest, RemoveAccessPointWithoutAcs) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithoutAcs(), getPskNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); status = HIDL_INVOKE(hostapd_, removeAccessPoint, getPrimaryWlanIfaceName()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } /** * Adds an access point with invalid channel. * Access point creation should fail. */ TEST_F(HostapdHidlTest, AddPskAccessPointWithInvalidChannel) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithInvalidChannel(), getPskNwParams()); EXPECT_NE(HostapdStatusCode::SUCCESS, status.code); } /** * Adds an access point with invalid PSK network config. * Access point creation should fail. */ TEST_F(HostapdHidlTest, AddInvalidPskAccessPointWithoutAcs) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithoutAcs(), getInvalidPskNwParams()); EXPECT_NE(HostapdStatusCode::SUCCESS, status.code); } Loading
wifi/hostapd/1.1/vts/functional/hostapd_hidl_test.cpp +211 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,14 @@ using ::android::hardware::wifi::hostapd::V1_0::HostapdStatusCode; using ::android::hardware::wifi::hostapd::V1_1::IHostapd; using ::android::hardware::wifi::hostapd::V1_1::IHostapdCallback; namespace { constexpr unsigned char kNwSsid[] = {'t', 'e', 's', 't', '1', '2', '3', '4', '5'}; constexpr char kNwPassphrase[] = "test12345"; constexpr int kIfaceChannel = 6; constexpr int kIfaceInvalidChannel = 567; } // namespace class HostapdHidlTest : public ::testing::VtsHalHidlTargetTestBase { public: virtual void SetUp() override { Loading @@ -45,6 +53,99 @@ class HostapdHidlTest : public ::testing::VtsHalHidlTargetTestBase { virtual void TearDown() override { stopHostapd(); } protected: std::string getPrimaryWlanIfaceName() { std::array<char, PROPERTY_VALUE_MAX> buffer; property_get("wifi.interface", buffer.data(), "wlan0"); return buffer.data(); } IHostapd::IfaceParams getIfaceParamsWithAcs() { ::android::hardware::wifi::hostapd::V1_0::IHostapd::IfaceParams iface_params; IHostapd::IfaceParams iface_params_1_1; iface_params.ifaceName = getPrimaryWlanIfaceName(); iface_params.hwModeParams.enable80211N = true; iface_params.hwModeParams.enable80211AC = false; iface_params.channelParams.enableAcs = true; iface_params.channelParams.acsShouldExcludeDfs = true; iface_params.channelParams.channel = 0; iface_params.channelParams.band = IHostapd::Band::BAND_ANY; iface_params_1_1.V1_0 = iface_params; return iface_params_1_1; } IHostapd::IfaceParams getIfaceParamsWithAcsAndChannelRange() { IHostapd::IfaceParams iface_params_1_1 = getIfaceParamsWithAcs(); IHostapd::ChannelParams channelParams; IHostapd::AcsChannelRange acsChannelRange; acsChannelRange.start = 1; acsChannelRange.end = 11; std::vector<IHostapd::AcsChannelRange> vec_acsChannelRange; vec_acsChannelRange.push_back(acsChannelRange); channelParams.acsChannelRanges = vec_acsChannelRange; iface_params_1_1.channelParams = channelParams; return iface_params_1_1; } IHostapd::IfaceParams getIfaceParamsWithAcsAndInvalidChannelRange() { IHostapd::IfaceParams iface_params_1_1 = getIfaceParamsWithAcsAndChannelRange(); iface_params_1_1.channelParams.acsChannelRanges[0].start = 222; iface_params_1_1.channelParams.acsChannelRanges[0].end = 999; return iface_params_1_1; } IHostapd::IfaceParams getIfaceParamsWithoutAcs() { ::android::hardware::wifi::hostapd::V1_0::IHostapd::IfaceParams iface_params; IHostapd::IfaceParams iface_params_1_1; iface_params.ifaceName = getPrimaryWlanIfaceName(); iface_params.hwModeParams.enable80211N = true; iface_params.hwModeParams.enable80211AC = false; iface_params.channelParams.enableAcs = false; iface_params.channelParams.acsShouldExcludeDfs = false; iface_params.channelParams.channel = kIfaceChannel; iface_params.channelParams.band = IHostapd::Band::BAND_2_4_GHZ; iface_params_1_1.V1_0 = iface_params; return iface_params_1_1; } IHostapd::IfaceParams getIfaceParamsWithInvalidChannel() { IHostapd::IfaceParams iface_params_1_1 = getIfaceParamsWithoutAcs(); iface_params_1_1.V1_0.channelParams.channel = kIfaceInvalidChannel; return iface_params_1_1; } IHostapd::NetworkParams getPskNwParams() { IHostapd::NetworkParams nw_params; nw_params.ssid = std::vector<uint8_t>(kNwSsid, kNwSsid + sizeof(kNwSsid)); nw_params.isHidden = false; nw_params.encryptionType = IHostapd::EncryptionType::WPA2; nw_params.pskPassphrase = kNwPassphrase; return nw_params; } IHostapd::NetworkParams getInvalidPskNwParams() { IHostapd::NetworkParams nw_params; nw_params.ssid = std::vector<uint8_t>(kNwSsid, kNwSsid + sizeof(kNwSsid)); nw_params.isHidden = false; nw_params.encryptionType = IHostapd::EncryptionType::WPA2; return nw_params; } IHostapd::NetworkParams getOpenNwParams() { IHostapd::NetworkParams nw_params; nw_params.ssid = std::vector<uint8_t>(kNwSsid, kNwSsid + sizeof(kNwSsid)); nw_params.isHidden = false; nw_params.encryptionType = IHostapd::EncryptionType::NONE; return nw_params; } // IHostapd object used for all tests in this fixture. sp<IHostapd> hostapd_; }; Loading @@ -65,3 +166,113 @@ TEST_F(HostapdHidlTest, registerCallback) { EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); }); } /** * Adds an access point with PSK network config & ACS enabled. * Access point creation should pass. */ TEST_F(HostapdHidlTest, AddPskAccessPointWithAcs) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithAcs(), getPskNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } /** * Adds an access point with PSK network config, ACS enabled & channel Range. * Access point creation should pass. */ TEST_F(HostapdHidlTest, AddPskAccessPointWithAcsAndChannelRange) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithAcsAndChannelRange(), getPskNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } /** * Adds an access point with invalid channel range. * Access point creation should fail. */ TEST_F(HostapdHidlTest, AddPskAccessPointWithAcsAndInvalidChannelRange) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithAcsAndInvalidChannelRange(), getPskNwParams()); EXPECT_NE(HostapdStatusCode::SUCCESS, status.code); } /** * Adds an access point with Open network config & ACS enabled. * Access point creation should pass. */ TEST_F(HostapdHidlTest, AddOpenAccessPointWithAcs) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithAcs(), getOpenNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } /** * Adds an access point with PSK network config & ACS disabled. * Access point creation should pass. */ TEST_F(HostapdHidlTest, AddPskAccessPointWithoutAcs) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithoutAcs(), getPskNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } /** * Adds an access point with Open network config & ACS disabled. * Access point creation should pass. */ TEST_F(HostapdHidlTest, AddOpenAccessPointWithoutAcs) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithoutAcs(), getOpenNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } /** * Adds & then removes an access point with PSK network config & ACS enabled. * Access point creation & removal should pass. */ TEST_F(HostapdHidlTest, RemoveAccessPointWithAcs) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithAcs(), getPskNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); status = HIDL_INVOKE(hostapd_, removeAccessPoint, getPrimaryWlanIfaceName()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } /** * Adds & then removes an access point with PSK network config & ACS disabled. * Access point creation & removal should pass. */ TEST_F(HostapdHidlTest, RemoveAccessPointWithoutAcs) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithoutAcs(), getPskNwParams()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); status = HIDL_INVOKE(hostapd_, removeAccessPoint, getPrimaryWlanIfaceName()); EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); } /** * Adds an access point with invalid channel. * Access point creation should fail. */ TEST_F(HostapdHidlTest, AddPskAccessPointWithInvalidChannel) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithInvalidChannel(), getPskNwParams()); EXPECT_NE(HostapdStatusCode::SUCCESS, status.code); } /** * Adds an access point with invalid PSK network config. * Access point creation should fail. */ TEST_F(HostapdHidlTest, AddInvalidPskAccessPointWithoutAcs) { auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_1, getIfaceParamsWithoutAcs(), getInvalidPskNwParams()); EXPECT_NE(HostapdStatusCode::SUCCESS, status.code); }