Use auth/assoc hostapd checks for WNM tests. A recent change introduced the ability to check the state of a DUT on the AP side (whether it is authenticated, associated, etc.). This change updates the WNM test to use these checks. A few minor updates to the tests are also included: - correct the operating class for 5 GHz VHT AP - rewording of some assert failure messages Change-Id: I71bc2a37b0730fa97c4e6ed7916df23ad94501d7 Reviewed-on: https://fuchsia-review.googlesource.com/c/antlion/+/918194 Commit-Queue: Karl Ward <karlward@google.com> Reviewed-by: Sam Balana <sbalana@google.com>
diff --git a/tests/wlan/functional/WlanWirelessNetworkManagementTest.py b/tests/wlan/functional/WlanWirelessNetworkManagementTest.py index eff7bd9..b886ec6 100644 --- a/tests/wlan/functional/WlanWirelessNetworkManagementTest.py +++ b/tests/wlan/functional/WlanWirelessNetworkManagementTest.py
@@ -47,8 +47,8 @@ * One Fuchsia device * One Whirlwind access point - Existing Fuchsia drivers do not yet support WNM features out-of-the-box, so these - tests check that WNM features are not enabled. + Existing Fuchsia drivers do not yet support WNM features out-of-the-box, so this + suite skips certain tests depending on whether specific WNM features are enabled. """ def setup_class(self): @@ -63,10 +63,10 @@ raise signals.TestAbortClass("At least one Fuchsia device is required") self.fuchsia_device = self.fuchsia_devices[0] - if self.fuchsia_device.association_mechanism != "policy": - raise AttributeError("Must use WLAN policy layer to test WNM.") - self.dut = create_wlan_device(self.fuchsia_device) + if self.fuchsia_device.association_mechanism != "policy": + raise AttributeError("Must use WLAN policy layer to test WNM") + self.access_point = self.access_points[0] def teardown_class(self): @@ -149,6 +149,11 @@ asserts.assert_true(self.dut.associate(ssid), "Failed to associate.") asserts.assert_true(self.dut.is_connected(), "Failed to connect.") client_mac = self._get_client_mac() + # Verify that DUT is actually associated (as seen from AP). + asserts.assert_true( + self.access_point.sta_associated(self.access_point.wlan_2g, client_mac), + "DUT is not associated on the 2.4GHz band", + ) ext_capabilities = self.access_point.get_sta_extended_capabilities( self.access_point.wlan_2g, client_mac @@ -170,6 +175,11 @@ asserts.assert_true(self.dut.associate(ssid), "Failed to associate.") asserts.assert_true(self.dut.is_connected(), "Failed to connect.") client_mac = self._get_client_mac() + # Verify that DUT is actually associated (as seen from AP). + asserts.assert_true( + self.access_point.sta_associated(self.access_point.wlan_2g, client_mac), + "DUT is not associated on the 2.4GHz band", + ) ext_capabilities = self.access_point.get_sta_extended_capabilities( self.access_point.wlan_2g, client_mac @@ -186,6 +196,11 @@ asserts.assert_true(self.dut.associate(ssid), "Failed to associate.") asserts.assert_true(self.dut.is_connected(), "Failed to connect.") client_mac = self._get_client_mac() + # Verify that DUT is actually associated (as seen from AP). + asserts.assert_true( + self.access_point.sta_associated(self.access_point.wlan_2g, client_mac), + "DUT is not associated on the 2.4GHz band", + ) ext_capabilities = self.access_point.get_sta_extended_capabilities( self.access_point.wlan_2g, client_mac @@ -195,7 +210,7 @@ "DUT is incorrectly advertising WNM Sleep Mode support", ) - def test_roam_on_btm_req(self): + def test_roam_on_btm_req_from_open_2g_to_open_5g(self): if not self.dut.feature_is_present("BSS_TRANSITION_MANAGEMENT"): raise signals.TestSkip("skipping test because BTM feature is not present") @@ -214,8 +229,8 @@ # Verify that DUT is actually associated (as seen from AP). client_mac = self._get_client_mac() asserts.assert_true( - client_mac in self.access_point.get_stas(self.access_point.wlan_2g), - "Client MAC not included in list of associated STAs on the 2.4GHz band", + self.access_point.sta_associated(self.access_point.wlan_2g, client_mac), + "DUT is not associated on the 2.4GHz band", ) # Setup 5 GHz AP with same SSID. @@ -235,7 +250,7 @@ neighbor_5g_ap = NeighborReportElement( dest_bssid, dest_bssid_info, - operating_class=126, + operating_class=116, channel_number=hostapd_constants.AP_DEFAULT_CHANNEL_5G, phy_type=PhyType.VHT, ) @@ -257,15 +272,19 @@ # Check that DUT has reassociated. REASSOC_DEADLINE = datetime.now(timezone.utc) + timedelta(seconds=2) while datetime.now(timezone.utc) < REASSOC_DEADLINE: - if client_mac in self.access_point.get_stas(self.access_point.wlan_5g): + if self.access_point.sta_associated(self.access_point.wlan_5g, client_mac): break else: time.sleep(0.25) # Verify that DUT roamed (as seen from AP). asserts.assert_true( - client_mac in self.access_point.get_stas(self.access_point.wlan_5g), - "Client MAC not included in list of associated STAs on the 5GHz band", + self.access_point.sta_authenticated(self.access_point.wlan_5g, client_mac), + "DUT is not authenticated on the 5GHz band", + ) + asserts.assert_true( + self.access_point.sta_associated(self.access_point.wlan_5g, client_mac), + "DUT is not associated on the 5GHz band", ) def test_btm_req_ignored_dut_unsupported(self): @@ -287,8 +306,8 @@ # Verify that DUT is actually associated (as seen from AP). client_mac = self._get_client_mac() asserts.assert_true( - client_mac in self.access_point.get_stas(self.access_point.wlan_2g), - "Client MAC not included in list of associated STAs on the 2.4GHz band", + self.access_point.sta_associated(self.access_point.wlan_2g, client_mac), + "DUT is not associated on the 2.4GHz band", ) # Setup 5 GHz AP with same SSID. @@ -325,7 +344,7 @@ REASSOC_DEADLINE = datetime.now(timezone.utc) + timedelta(seconds=2) while datetime.now(timezone.utc) < REASSOC_DEADLINE: # Fail if DUT has reassociated to 5 GHz AP (as seen from AP). - if client_mac in self.access_point.get_stas(self.access_point.wlan_5g): + if self.access_point.sta_associated(self.access_point.wlan_5g, client_mac): raise signals.TestFailure( "DUT unexpectedly roamed to target BSS after BTM request" ) @@ -334,8 +353,8 @@ # DUT should have stayed associated to original AP. asserts.assert_true( - client_mac in self.access_point.get_stas(self.access_point.wlan_2g), - "DUT lost association on the 2.4GHz band after BTM request", + self.access_point.sta_associated(self.access_point.wlan_2g, client_mac), + "DUT unexpectedly lost association on the 2.4GHz band after BTM request", ) def test_btm_req_target_ap_rejects_reassoc(self): @@ -357,8 +376,8 @@ # Verify that DUT is actually associated (as seen from AP). client_mac = self._get_client_mac() asserts.assert_true( - client_mac in self.access_point.get_stas(self.access_point.wlan_2g), - "Client MAC not included in list of associated STAs on the 2.4GHz band", + self.access_point.sta_associated(self.access_point.wlan_2g, client_mac), + "DUT is not associated on the 2.4GHz band", ) # Setup 5 GHz AP with same SSID, but reject all STAs. @@ -380,7 +399,7 @@ neighbor_5g_ap = NeighborReportElement( dest_bssid, dest_bssid_info, - operating_class=126, + operating_class=116, channel_number=hostapd_constants.AP_DEFAULT_CHANNEL_5G, phy_type=PhyType.VHT, ) @@ -400,20 +419,12 @@ # Check that DUT has not reassociated. REASSOC_DEADLINE = datetime.now(timezone.utc) + timedelta(seconds=2) while datetime.now(timezone.utc) < REASSOC_DEADLINE: - # Fail if DUT has reassociated to 5 GHz AP (as seen from AP). - if client_mac in self.access_point.get_stas(self.access_point.wlan_5g): - raise signals.TestFailure( - "DUT unexpectedly roamed to target BSS after BTM request" - ) + # Check that DUT has not reassociated to 5 GHz AP (as seen from AP). + if self.access_point.sta_associated(self.access_point.wlan_5g, client_mac): + raise signals.TestFailure("DUT unexpectedly roamed to 5GHz band") else: time.sleep(0.25) - # DUT should have stayed associated to original AP. - asserts.assert_true( - client_mac in self.access_point.get_stas(self.access_point.wlan_2g), - "DUT lost association on the 2.4GHz band after BTM request", - ) - if __name__ == "__main__": test_runner.main()