diff options
-rwxr-xr-x | acts/framework/acts/controllers/packet_capture.py | 11 | ||||
-rw-r--r-- | acts/framework/acts/libs/uicd/uicd_cli.py | 2 | ||||
-rw-r--r-- | acts/framework/acts/test_utils/net/connectivity_const.py | 6 | ||||
-rw-r--r-- | acts/framework/acts/test_utils/net/connectivity_test_utils.py | 15 | ||||
-rwxr-xr-x | acts/framework/acts/test_utils/wifi/wifi_test_utils.py | 13 | ||||
-rw-r--r-- | acts/tests/google/net/CaptivePortalTest.py | 209 | ||||
-rwxr-xr-x | acts/tests/google/wifi/WifiChaosTest.py | 10 | ||||
-rwxr-xr-x | acts/tests/google/wifi/WifiMacRandomizationTest.py | 28 | ||||
-rwxr-xr-x | acts/tests/google/wifi/WifiNetworkSuggestionTest.py | 195 | ||||
-rwxr-xr-x | acts/tests/google/wifi/WifiPasspointTest.py | 4 | ||||
-rwxr-xr-x | acts/tests/google/wifi/WifiScannerMultiScanTest.py | 8 | ||||
-rwxr-xr-x | acts/tests/google/wifi/WifiScannerScanTest.py | 61 | ||||
-rw-r--r-- | acts/tests/google/wifi/p2p/functional/WifiP2pSnifferTest.py | 11 | ||||
-rw-r--r-- | acts/tests/google/wifi/rtt/functional/RangeAwareTest.py | 10 |
14 files changed, 406 insertions, 177 deletions
diff --git a/acts/framework/acts/controllers/packet_capture.py b/acts/framework/acts/controllers/packet_capture.py index 828c2fe5a1..d10ffadceb 100755 --- a/acts/framework/acts/controllers/packet_capture.py +++ b/acts/framework/acts/controllers/packet_capture.py @@ -106,7 +106,12 @@ class PacketCapture(object): self._create_interface(MON_2G, 'monitor') self._create_interface(MON_5G, 'monitor') - self._create_interface(SCAN_IFACE, 'managed') + self.managed_mode = True + result = self.ssh.run('ifconfig -a', ignore_status=True) + if result.stderr or SCAN_IFACE not in result.stdout: + self.managed_mode = False + if self.managed_mode: + self._create_interface(SCAN_IFACE, 'managed') self.pcap_properties = dict() self._pcap_stop_lock = threading.Lock() @@ -116,6 +121,8 @@ class PacketCapture(object): Create mon0/mon1 for 2G/5G monitor mode and wlan2 for managed mode. """ + if mode == 'monitor': + self.ssh.run('ifconfig wlan%s down' % iface[-1], ignore_status=True) self.ssh.run('iw dev %s del' % iface, ignore_status=True) self.ssh.run('iw phy%s interface add %s type %s' % (iface[-1], iface, mode), ignore_status=True) @@ -171,6 +178,8 @@ class PacketCapture(object): Returns: List of dictionaries each representing a found network. """ + if not self.managed_mode: + raise PacketCaptureError('Managed mode not setup') result = self.ssh.run('iw dev %s scan' % SCAN_IFACE) if result.stderr: raise PacketCaptureError('Failed to get scan dump') diff --git a/acts/framework/acts/libs/uicd/uicd_cli.py b/acts/framework/acts/libs/uicd/uicd_cli.py index b542cf099f..8388551c14 100644 --- a/acts/framework/acts/libs/uicd/uicd_cli.py +++ b/acts/framework/acts/libs/uicd/uicd_cli.py @@ -45,7 +45,7 @@ class UicdCli(object): containing them. log_path: Directory for storing logs generated by Uicd. """ - self._uicd_zip = uicd_zip + self._uicd_zip = uicd_zip[0] if isinstance(uicd_zip, list) else uicd_zip self._uicd_path = tempfile.mkdtemp(prefix='uicd') self._log_path = log_path if self._log_path: diff --git a/acts/framework/acts/test_utils/net/connectivity_const.py b/acts/framework/acts/test_utils/net/connectivity_const.py index f4865ab077..946d2c6f7e 100644 --- a/acts/framework/acts/test_utils/net/connectivity_const.py +++ b/acts/framework/acts/test_utils/net/connectivity_const.py @@ -64,6 +64,12 @@ MULTIPATH_PREFERENCE_HANDOVER = 1 << 0 MULTIPATH_PREFERENCE_RELIABILITY = 1 << 1 MULTIPATH_PREFERENCE_PERFORMANCE = 1 << 2 +# Private DNS constants +DNS_GOOGLE = "dns.google" +PRIVATE_DNS_MODE_OFF = "off" +PRIVATE_DNS_MODE_OPPORTUNISTIC = "opportunistic" +PRIVATE_DNS_MODE_STRICT = "hostname" + # IpSec constants SOCK_STREAM = 1 SOCK_DGRAM = 2 diff --git a/acts/framework/acts/test_utils/net/connectivity_test_utils.py b/acts/framework/acts/test_utils/net/connectivity_test_utils.py index 02167c966c..4b7668c315 100644 --- a/acts/framework/acts/test_utils/net/connectivity_test_utils.py +++ b/acts/framework/acts/test_utils/net/connectivity_test_utils.py @@ -14,6 +14,7 @@ # limitations under the License. from acts import asserts +from acts.test_utils.net import connectivity_const as cconst def start_natt_keepalive(ad, src_ip, src_port, dst_ip, interval = 10): """ Start NAT-T keep alive on dut """ @@ -61,3 +62,17 @@ def stop_natt_keepalive(ad, key): ad.droid.connectivityRemovePacketKeepaliveReceiverKey(key) return status + +def set_private_dns(ad, dns_mode, hostname=None): + """ Set private DNS mode on dut """ + if dns_mode == cconst.PRIVATE_DNS_MODE_OFF: + ad.droid.setPrivateDnsMode(False) + else: + ad.droid.setPrivateDnsMode(True, hostname) + + mode = ad.droid.getPrivateDnsMode() + host = ad.droid.getPrivateDnsSpecifier() + ad.log.info("DNS mode is %s and DNS server is %s" % (mode, host)) + asserts.assert_true(dns_mode == mode and host == hostname, + "Failed to set DNS mode to %s and DNS to %s" % \ + (dns_mode, hostname)) diff --git a/acts/framework/acts/test_utils/wifi/wifi_test_utils.py b/acts/framework/acts/test_utils/wifi/wifi_test_utils.py index b2ae9a4808..6e29e61243 100755 --- a/acts/framework/acts/test_utils/wifi/wifi_test_utils.py +++ b/acts/framework/acts/test_utils/wifi/wifi_test_utils.py @@ -44,7 +44,6 @@ DEFAULT_TIMEOUT = 10 SHORT_TIMEOUT = 30 ROAMING_TIMEOUT = 30 WIFI_CONNECTION_TIMEOUT_DEFAULT = 30 -WIFI_ABNORMAL_CONNECTION_TIME = 10 # Speed of light in m/s. SPEED_OF_LIGHT = 299792458 @@ -1166,9 +1165,7 @@ def _wait_for_connect_event(ad, ssid=None, id=None, tries=1): if id is None and ssid is None: for i in range(tries): try: - start = time.time() conn_result = ad.ed.pop_event(wifi_constants.WIFI_CONNECTED, 30) - _assert_connection_time(start) break except Empty: pass @@ -1176,25 +1173,16 @@ def _wait_for_connect_event(ad, ssid=None, id=None, tries=1): # If ssid or network id is specified, wait for specific connect event. for i in range(tries): try: - start = time.time() conn_result = ad.ed.pop_event(wifi_constants.WIFI_CONNECTED, 30) if id and conn_result['data'][WifiEnums.NETID_KEY] == id: - _assert_connection_time(start) break elif ssid and conn_result['data'][WifiEnums.SSID_KEY] == ssid: - _assert_connection_time(start) break except Empty: pass return conn_result -def _assert_connection_time(start): - duration = time.time() - start - asserts.assert_true( - duration < WIFI_ABNORMAL_CONNECTION_TIME, - "Took " + str(duration) + "s to connect to network, " + - " expected " + str(WIFI_ABNORMAL_CONNECTION_TIME)) def wait_for_disconnect(ad, timeout=10): """Wait for a disconnect event within the specified timeout. @@ -1430,6 +1418,7 @@ def _wifi_connect_by_id(ad, network_id, num_of_tries=1): finally: ad.droid.wifiStopTrackingStateChange() + def wifi_connect_using_network_request(ad, network, network_specifier, num_of_tries=3, assert_on_fail=True): """Connect an Android device to a wifi network using network request. diff --git a/acts/tests/google/net/CaptivePortalTest.py b/acts/tests/google/net/CaptivePortalTest.py new file mode 100644 index 0000000000..10240e4032 --- /dev/null +++ b/acts/tests/google/net/CaptivePortalTest.py @@ -0,0 +1,209 @@ +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import time + +from acts import asserts +from acts import base_test +from acts import signals +from acts.libs.uicd.uicd_cli import UicdCli +from acts.test_decorators import test_tracker_info +from acts.test_utils.net import connectivity_const as cconst +from acts.test_utils.net import connectivity_test_utils as cutils +from acts.test_utils.wifi import wifi_test_utils as wutils + +WifiEnums = wutils.WifiEnums +IFACE = "InterfaceName" +TIME_OUT = 20 +WLAN = "wlan0" + + +class CaptivePortalTest(base_test.BaseTestClass): + """ Tests for Captive portal """ + + def setup_class(self): + """Setup devices for tests and unpack params + + Required params: + 1. rk_captive_portal: SSID of ruckus captive portal network in dict + 2. gg_captive_portal: SSID of guestgate network in dict + 3. uicd_workflows: uicd workflow that specify click actions to accept + a captive portal connection. Ex: Click on SignIn, Accept & Continue + //wireless/android/platform/testing/wifi/configs/uicd/ + 4. uic_zip: Zip file location of UICD application + """ + self.dut = self.android_devices[0] + wutils.wifi_test_device_init(self.dut) + wutils.wifi_toggle_state(self.dut, True) + req_params = ["rk_captive_portal", + "gg_captive_portal", + "uicd_workflows", + "uicd_zip"] + self.unpack_userparams(req_param_names=req_params,) + self.ui = UicdCli(self.uicd_zip, self.uicd_workflows) + self.rk_workflow_config = "rk_captive_portal_%s" % self.dut.model + self.gg_workflow_config = "gg_captive_portal_%s" % self.dut.model + + def teardown_class(self): + """ Reset devices """ + cutils.set_private_dns(self.dut, cconst.PRIVATE_DNS_MODE_OPPORTUNISTIC) + + def setup_test(self): + """ Setup device """ + self.dut.unlock_screen() + + def teardown_test(self): + """ Reset to default state after each test """ + wutils.reset_wifi(self.dut) + + def on_fail(self, test_name, begin_time): + self.dut.take_bug_report(test_name, begin_time) + + ### Helper methods ### + + def _verify_captive_portal(self, network, uicd_workflow): + """Connect to captive portal network using uicd workflow + + Steps: + 1. Connect to captive portal network + 2. Run uicd workflow to accept connection + 3. Verify internet connectivity + + Args: + 1. network: captive portal network to connect to + 2. uicd_workflow: ui workflow to accept captive portal conn + """ + # connect to captive portal wifi network + wutils.start_wifi_connection_scan_and_ensure_network_found( + self.dut, network[WifiEnums.SSID_KEY]) + wutils.wifi_connect(self.dut, network, check_connectivity=False) + + # run uicd + self.ui.run(self.dut.serial, uicd_workflow) + + # wait for sometime for captive portal connection to go through + curr_time = time.time() + while time.time() < curr_time + TIME_OUT: + link_prop = self.dut.droid.connectivityGetActiveLinkProperties() + self.log.debug("Link properties %s" % link_prop) + if link_prop and link_prop[IFACE] == WLAN: + break + time.sleep(2) + + # verify connectivity + internet = wutils.validate_connection(self.dut, + wutils.DEFAULT_PING_ADDR) + if not internet: + raise signals.TestFailure("Failed to connect to internet on %s" % + network[WifiEnums.SSID_KEY]) + + ### Test Cases ### + + @test_tracker_info(uuid="b035b4f9-40f7-42f6-9941-ec27afe15040") + def test_ruckus_captive_portal_default(self): + """Verify captive portal network + + Steps: + 1. Set default private dns mode + 2. Connect to ruckus captive portal network + 3. Verify connectivity + """ + # set private dns to opportunistic + cutils.set_private_dns(self.dut, cconst.PRIVATE_DNS_MODE_OPPORTUNISTIC) + + # verify connection to captive portal network + self._verify_captive_portal(self.rk_captive_portal, + self.rk_workflow_config) + + @test_tracker_info(uuid="8ea18d80-0170-41b1-8945-fe14bcd4feab") + def test_ruckus_captive_portal_private_dns_off(self): + """Verify captive portal network + + Steps: + 1. Turn off private dns mode + 2. Connect to ruckus captive portal network + 3. Verify connectivity + """ + # turn off private dns + cutils.set_private_dns(self.dut, cconst.PRIVATE_DNS_MODE_OFF) + + # verify connection to captive portal network + self._verify_captive_portal(self.rk_captive_portal, + self.rk_workflow_config) + + @test_tracker_info(uuid="e8e05907-55f7-40e5-850c-b3111ceb31a4") + def test_ruckus_captive_portal_private_dns_strict(self): + """Verify captive portal network + + Steps: + 1. Set strict private dns mode + 2. Connect to ruckus captive portal network + 3. Verify connectivity + """ + # set private dns to strict mode + cutils.set_private_dns(self.dut, + cconst.PRIVATE_DNS_MODE_STRICT, + cconst.DNS_GOOGLE) + + # verify connection to captive portal network + self._verify_captive_portal(self.rk_captive_portal, + self.rk_workflow_config) + + @test_tracker_info(uuid="76e49800-f141-4fd2-9969-562585eb1e7a") + def test_guestgate_captive_portal_default(self): + """Verify captive portal network + + Steps: + 1. Set default private dns mode + 2. Connect to guestgate captive portal network + 3. Verify connectivity + """ + # set private dns to opportunistic + cutils.set_private_dns(self.dut, cconst.PRIVATE_DNS_MODE_OPPORTUNISTIC) + + # verify connection to captive portal network + self._verify_captive_portal(self.gg_captive_portal, "gg_captive_portal") + + @test_tracker_info(uuid="0aea0cac-0f42-406b-84ba-62c1ef74adfc") + def test_guestgate_captive_portal_private_dns_off(self): + """Verify captive portal network + + Steps: + 1. Turn off private dns mode + 2. Connect to guestgate captive portal network + 3. Verify connectivity + """ + # turn off private dns + cutils.set_private_dns(self.dut, cconst.PRIVATE_DNS_MODE_OFF) + + # verify connection to captive portal network + self._verify_captive_portal(self.gg_captive_portal, "gg_captive_portal") + + @test_tracker_info(uuid="39124dcc-2fd3-4d33-b129-a1c8150b7f2a") + def test_guestgate_captive_portal_private_dns_strict(self): + """Verify captive portal network + + Steps: + 1. Set strict private dns mode + 2. Connect to guestgate captive portal network + 3. Verify connectivity + """ + # set private dns to strict mode + cutils.set_private_dns(self.dut, + cconst.PRIVATE_DNS_MODE_STRICT, + cconst.DNS_GOOGLE) + + # verify connection to captive portal network + self._verify_captive_portal(self.gg_captive_portal, "gg_captive_portal") diff --git a/acts/tests/google/wifi/WifiChaosTest.py b/acts/tests/google/wifi/WifiChaosTest.py index aa36588f42..9bd2651610 100755 --- a/acts/tests/google/wifi/WifiChaosTest.py +++ b/acts/tests/google/wifi/WifiChaosTest.py @@ -213,15 +213,13 @@ class WifiChaosTest(WifiBaseTest): Steps: 1. Send a few link probes. - 2. Verify that at least one link probe succeeded. - 3. Ensure that the device and AP did not crash (by checking that the + 2. Ensure that the device and AP did not crash (by checking that the device remains connected to the expected network). """ results = wutils.send_link_probes( self.dut, NUM_LINK_PROBES, PROBE_DELAY_SEC) - asserts.assert_true(any(result.is_success for result in results), - "Expect at least 1 probe success: " + str(results)) + self.log.info("Link Probe results: %s" % (results,)) wifi_info = self.dut.droid.wifiGetConnectionInfo() expected = network[WifiEnums.SSID_KEY] @@ -272,9 +270,9 @@ class WifiChaosTest(WifiBaseTest): self.send_link_probes(network) wutils.wifi_forget_network(self.dut, ssid) time.sleep(WAIT_BEFORE_CONNECTION) - except: + except Exception as e: self.log.error("Connection to %s network failed on the %d " - "attempt." % (ssid, attempt)) + "attempt with exception %s." % (ssid, attempt, e)) # TODO:(bmahadev) Uncomment after scan issue is fixed. # self.dut.take_bug_report(ssid, begin_time) # self.dut.cat_adb_log(ssid, begin_time) diff --git a/acts/tests/google/wifi/WifiMacRandomizationTest.py b/acts/tests/google/wifi/WifiMacRandomizationTest.py index 09630d7714..fa01d45b61 100755 --- a/acts/tests/google/wifi/WifiMacRandomizationTest.py +++ b/acts/tests/google/wifi/WifiMacRandomizationTest.py @@ -272,14 +272,15 @@ class WifiMacRandomizationTest(WifiBaseTest): @test_tracker_info(uuid="2dd0a05e-a318-45a6-81cd-962e098fa242") def test_set_mac_randomization_to_none(self): self.pcap_procs = wutils.start_pcap( - self.packet_capture, 'dual', self.log_path, self.test_name) + self.packet_capture, 'dual', self.test_name) network = self.wpapsk_2g # Set macRandomizationSetting to RANDOMIZATION_NONE. network["macRand"] = RANDOMIZATION_NONE self.connect_to_network_and_verify_mac_randomization(network, status=RANDOMIZATION_NONE) - pcap_fname = os.path.join(self.log_path, self.test_name, - (self.test_name + '_2G.pcap')) + pcap_fname = '%s_%s.pcap' % \ + (self.pcap_procs[hostapd_constants.BAND_2G][1], + hostapd_constants.BAND_2G.upper()) time.sleep(SHORT_TIMEOUT) wutils.stop_pcap(self.packet_capture, self.pcap_procs, False) packets = rdpcap(pcap_fname) @@ -461,14 +462,15 @@ class WifiMacRandomizationTest(WifiBaseTest): if not result: raise ValueError("Failed to configure channel for 2G band") self.pcap_procs = wutils.start_pcap( - self.packet_capture, 'dual', self.log_path, self.test_name) + self.packet_capture, 'dual', self.test_name) # re-connect to the softAp network after sniffer is started wutils.connect_to_wifi_network(self.dut_client, self.wpapsk_2g) wutils.connect_to_wifi_network(self.dut_client, softap) time.sleep(SHORT_TIMEOUT) wutils.stop_pcap(self.packet_capture, self.pcap_procs, False) - pcap_fname = os.path.join(self.log_path, self.test_name, - (self.test_name + '_2G.pcap')) + pcap_fname = '%s_%s.pcap' % \ + (self.pcap_procs[hostapd_constants.BAND_2G][1], + hostapd_constants.BAND_2G.upper()) packets = rdpcap(pcap_fname) self.verify_mac_not_found_in_pcap(self.soft_ap_factory_mac, packets) self.verify_mac_not_found_in_pcap(self.sta_factory_mac, packets) @@ -520,13 +522,14 @@ class WifiMacRandomizationTest(WifiBaseTest): """ self.pcap_procs = wutils.start_pcap( - self.packet_capture, 'dual', self.log_path, self.test_name) + self.packet_capture, 'dual', self.test_name) time.sleep(SHORT_TIMEOUT) network = self.wpapsk_5g rand_mac = self.connect_to_network_and_verify_mac_randomization(network) wutils.send_link_probes(self.dut, 3, 3) - pcap_fname = os.path.join(self.log_path, self.test_name, - (self.test_name + '_5G.pcap')) + pcap_fname = '%s_%s.pcap' % \ + (self.pcap_procs[hostapd_constants.BAND_5G][1], + hostapd_constants.BAND_5G.upper()) wutils.stop_pcap(self.packet_capture, self.pcap_procs, False) time.sleep(SHORT_TIMEOUT) packets = rdpcap(pcap_fname) @@ -546,11 +549,12 @@ class WifiMacRandomizationTest(WifiBaseTest): """ self.pcap_procs = wutils.start_pcap( - self.packet_capture, 'dual', self.log_path, self.test_name) + self.packet_capture, 'dual', self.test_name) wutils.start_wifi_connection_scan(self.dut) time.sleep(SHORT_TIMEOUT) wutils.stop_pcap(self.packet_capture, self.pcap_procs, False) - pcap_fname = os.path.join(self.log_path, self.test_name, - (self.test_name + '_2G.pcap')) + pcap_fname = '%s_%s.pcap' % \ + (self.pcap_procs[hostapd_constants.BAND_2G][1], + hostapd_constants.BAND_2G.upper()) packets = rdpcap(pcap_fname) self.verify_mac_not_found_in_pcap(self.sta_factory_mac, packets) diff --git a/acts/tests/google/wifi/WifiNetworkSuggestionTest.py b/acts/tests/google/wifi/WifiNetworkSuggestionTest.py index 5cb27767f7..27f859ce19 100755 --- a/acts/tests/google/wifi/WifiNetworkSuggestionTest.py +++ b/acts/tests/google/wifi/WifiNetworkSuggestionTest.py @@ -31,11 +31,17 @@ from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest from acts.test_utils.wifi import wifi_constants WifiEnums = wutils.WifiEnums +# EAP Macros +EAP = WifiEnums.Eap +EapPhase2 = WifiEnums.EapPhase2 +# Enterprise Config Macros +Ent = WifiEnums.Enterprise # Default timeout used for reboot, toggle WiFi and Airplane mode, # for the system to settle down after the operation. DEFAULT_TIMEOUT = 10 + class WifiNetworkSuggestionTest(WifiBaseTest): """Tests for WifiNetworkSuggestion API surface. @@ -53,22 +59,42 @@ class WifiNetworkSuggestionTest(WifiBaseTest): wutils.wifi_test_device_init(self.dut) req_params = [] opt_param = [ - "open_network", "reference_networks" + "open_network", "reference_networks", "radius_conf_2g", "radius_conf_5g", "ca_cert", + "eap_identity", "eap_password" ] self.unpack_userparams( req_param_names=req_params, opt_param_names=opt_param) if "AccessPoint" in self.user_params: - self.legacy_configure_ap_and_start(wpa_network=True, - wep_network=True) + self.legacy_configure_ap_and_start( + wpa_network=True, ent_network=True, + radius_conf_2g=self.radius_conf_2g, + radius_conf_5g=self.radius_conf_5g,) asserts.assert_true( len(self.reference_networks) > 0, "Need at least one reference network with psk.") - self.wpa_psk_2g = self.reference_networks[0]["2g"] - self.wpa_psk_5g = self.reference_networks[0]["5g"] - self.open_2g = self.open_network[0]["2g"] - self.open_5g = self.open_network[0]["5g"] + if hasattr(self, "reference_networks"): + self.wpa_psk_2g = self.reference_networks[0]["2g"] + self.wpa_psk_5g = self.reference_networks[0]["5g"] + if hasattr(self, "open_network"): + self.open_2g = self.open_network[0]["2g"] + self.open_5g = self.open_network[0]["5g"] + if hasattr(self, "ent_networks"): + self.ent_network_2g = self.ent_networks[0]["2g"] + self.ent_network_5g = self.ent_networks[0]["5g"] + self.config_aka = { + Ent.EAP: int(EAP.AKA), + WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY], + } + self.config_ttls = { + Ent.EAP: int(EAP.TTLS), + Ent.CA_CERT: self.ca_cert, + Ent.IDENTITY: self.eap_identity, + Ent.PASSWORD: self.eap_password, + Ent.PHASE2: int(EapPhase2.MSCHAPV2), + WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY], + } self.dut.droid.wifiRemoveNetworkSuggestions([]) def setup_test(self): @@ -84,6 +110,7 @@ class WifiNetworkSuggestionTest(WifiBaseTest): self.dut.droid.wifiRemoveNetworkSuggestions([]) self.dut.droid.wifiDisconnect() wutils.reset_wifi(self.dut) + wutils.wifi_toggle_state(self.dut, False) self.dut.ed.clear_all_events() def on_fail(self, test_name, begin_time): @@ -149,6 +176,47 @@ class WifiNetworkSuggestionTest(WifiBaseTest): self.dut.droid.wifiStopTrackingNetworkSuggestionStateChange() self.dut.ed.clear_all_events() + def remove_suggestions_disconnect_and_ensure_no_connection_back(self, + network_suggestions, + expected_ssid): + self.dut.log.info("Removing network suggestions") + asserts.assert_true( + self.dut.droid.wifiRemoveNetworkSuggestions(network_suggestions), + "Failed to remove suggestions") + # Ensure we did not disconnect + wutils.ensure_no_disconnect(self.dut) + + # Trigger a disconnect and wait for the disconnect. + self.dut.droid.wifiDisconnect() + wutils.wait_for_disconnect(self.dut) + self.dut.ed.clear_all_events() + + # Now ensure that we didn't connect back. + asserts.assert_false( + wutils.wait_for_connect(self.dut, expected_ssid, assert_on_fail=False), + "Device should not connect back") + + def _test_connect_to_wifi_network_reboot_config_store(self, + network_suggestions, + wifi_network): + """ Test network suggestion with reboot config store + + Args: + 1. network_suggestions: network suggestions in list to add to the device. + 2. wifi_network: expected wifi network to connect to + """ + + self.add_suggestions_and_ensure_connection( + network_suggestions, wifi_network[WifiEnums.SSID_KEY], None) + + # Reboot and wait for connection back to the same suggestion. + self.dut.reboot() + time.sleep(DEFAULT_TIMEOUT) + + wutils.wait_for_connect(self.dut, wifi_network[WifiEnums.SSID_KEY]) + + self.remove_suggestions_disconnect_and_ensure_no_connection_back( + network_suggestions, wifi_network[WifiEnums.SSID_KEY]) @test_tracker_info(uuid="bda8ed20-4382-4380-831a-64cf77eca108") def test_connect_to_wpa_psk_2g(self): @@ -164,25 +232,9 @@ class WifiNetworkSuggestionTest(WifiBaseTest): self.add_suggestions_and_ensure_connection( [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY], False) - self.dut.log.info("Removing network suggestions"); - asserts.assert_true( - self.dut.droid.wifiRemoveNetworkSuggestions([self.wpa_psk_2g]), - "Failed to remove suggestions") - # Ensure we did not disconnect - wutils.ensure_no_disconnect(self.dut) - - # Trigger a disconnect and wait for the disconnect. - self.dut.droid.wifiDisconnect() - wutils.wait_for_disconnect(self.dut) - self.dut.ed.clear_all_events() - - # Now ensure that we didn't connect back. - asserts.assert_false( - wutils.wait_for_connect(self.dut, - self.wpa_psk_2g[WifiEnums.SSID_KEY], - assert_on_fail=False), - "Device should not connect back") + self.remove_suggestions_disconnect_and_ensure_no_connection_back( + [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY]) @test_tracker_info(uuid="f54bc250-d9e9-4f00-8b5b-b866e8550b43") def test_connect_to_highest_priority(self): @@ -209,15 +261,8 @@ class WifiNetworkSuggestionTest(WifiBaseTest): self.wpa_psk_2g[WifiEnums.SSID_KEY], None) - # Remove all suggestions - self.dut.log.info("Removing network suggestions"); - asserts.assert_true( - self.dut.droid.wifiRemoveNetworkSuggestions([]), - "Failed to remove suggestions") - # Trigger a disconnect and wait for the disconnect. - self.dut.droid.wifiDisconnect() - wutils.wait_for_disconnect(self.dut) - self.dut.ed.clear_all_events() + self.remove_suggestions_disconnect_and_ensure_no_connection_back( + [], self.wpa_psk_2g[WifiEnums.SSID_KEY]) # Reverse the priority. # Add suggestions & wait for the connection event. @@ -228,7 +273,6 @@ class WifiNetworkSuggestionTest(WifiBaseTest): self.wpa_psk_5g[WifiEnums.SSID_KEY], None) - @test_tracker_info(uuid="b1d27eea-23c8-4c4f-b944-ef118e4cc35f") def test_connect_to_wpa_psk_2g_with_post_connection_broadcast(self): """ Adds a network suggestion and ensure that the device connected. @@ -246,25 +290,8 @@ class WifiNetworkSuggestionTest(WifiBaseTest): self.add_suggestions_and_ensure_connection( [network_suggestion], self.wpa_psk_2g[WifiEnums.SSID_KEY], True) - self.dut.log.info("Removing network suggestions"); - asserts.assert_true( - self.dut.droid.wifiRemoveNetworkSuggestions([network_suggestion]), - "Failed to remove suggestions") - # Ensure we did not disconnect - wutils.ensure_no_disconnect(self.dut) - - # Trigger a disconnect and wait for the disconnect. - self.dut.droid.wifiDisconnect() - wutils.wait_for_disconnect(self.dut) - self.dut.ed.clear_all_events() - - # Now ensure that we didn't connect back. - asserts.assert_false( - wutils.wait_for_connect(self.dut, - self.wpa_psk_2g[WifiEnums.SSID_KEY], - assert_on_fail=False), - "Device should not connect back") - + self.remove_suggestions_disconnect_and_ensure_no_connection_back( + [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY]) @test_tracker_info(uuid="a036a24d-29c0-456d-ae6a-afdde34da710") def test_connect_to_wpa_psk_5g_reboot_config_store(self): @@ -281,35 +308,45 @@ class WifiNetworkSuggestionTest(WifiBaseTest): 5. Wait for the device to connect to back to it. 6. Remove the suggestions and ensure the device does not connect back. """ - self.add_suggestions_and_ensure_connection( - [self.wpa_psk_5g], self.wpa_psk_5g[WifiEnums.SSID_KEY], - None) - - # Reboot and wait for connection back to the same suggestion. - self.dut.reboot() - time.sleep(DEFAULT_TIMEOUT) + self._test_connect_to_wifi_network_reboot_config_store( + [self.wpa_psk_5g], self.wpa_psk_5g) - wutils.wait_for_connect(self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY]) + @test_tracker_info(uuid="61649a2b-0f00-4272-9b9b-40ad5944da31") + def test_connect_to_wpa_ent_config_aka_reboot_config_store(self): + """ + Adds a network suggestion and ensure that the device connects to it + after reboot. - self.dut.log.info("Removing network suggestions"); - asserts.assert_true( - self.dut.droid.wifiRemoveNetworkSuggestions([self.wpa_psk_5g]), - "Failed to remove suggestions") - # Ensure we did not disconnect - wutils.ensure_no_disconnect(self.dut) + Steps: + 1. Send a Enterprise AKA network suggestion to the device. + 2. Wait for the device to connect to it. + 3. Ensure that we did not receive the post connection broadcast. + 4. Reboot the device. + 5. Wait for the device to connect to the wifi network. + 6. Remove suggestions and ensure device doesn't connect back to it. + """ + self._test_connect_to_wifi_network_reboot_config_store( + [self.config_aka], self.ent_network_2g) - # Trigger a disconnect and wait for the disconnect. - self.dut.droid.wifiDisconnect() - wutils.wait_for_disconnect(self.dut) - self.dut.ed.clear_all_events() + @test_tracker_info(uuid="98b2d40a-acb4-4a2f-aba1-b069e2a1d09d") + def test_connect_to_wpa_ent_config_ttls_pap_reboot_config_store(self): + """ + Adds a network suggestion and ensure that the device connects to it + after reboot. - # Now ensure that we didn't connect back. - asserts.assert_false( - wutils.wait_for_connect(self.dut, - self.wpa_psk_5g[WifiEnums.SSID_KEY], - assert_on_fail=False), - "Device should not connect back") + Steps: + 1. Send a Enterprise TTLS PAP network suggestion to the device. + 2. Wait for the device to connect to it. + 3. Ensure that we did not receive the post connection broadcast. + 4. Reboot the device. + 5. Wait for the device to connect to the wifi network. + 6. Remove suggestions and ensure device doesn't connect back to it. + """ + config = dict(self.config_ttls) + config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.PAP.value + self._test_connect_to_wifi_network_reboot_config_store( + [config], self.ent_network_2g) @test_tracker_info(uuid="554b5861-22d0-4922-a5f4-712b4cf564eb") def test_fail_to_connect_to_wpa_psk_5g_when_not_approved(self): @@ -383,7 +420,7 @@ class WifiNetworkSuggestionTest(WifiBaseTest): [network_suggestion], self.wpa_psk_2g[WifiEnums.SSID_KEY], True) - # Simulate user forgeting the ephemeral network. + # Simulate user forgetting the ephemeral network. self.dut.droid.wifiDisableEphemeralNetwork( self.wpa_psk_2g[WifiEnums.SSID_KEY]) wutils.wait_for_disconnect(self.dut) diff --git a/acts/tests/google/wifi/WifiPasspointTest.py b/acts/tests/google/wifi/WifiPasspointTest.py index 5ca9a49e12..b867faad98 100755 --- a/acts/tests/google/wifi/WifiPasspointTest.py +++ b/acts/tests/google/wifi/WifiPasspointTest.py @@ -73,11 +73,13 @@ class WifiPasspointTest(acts.base_test.BaseTestClass): self.unknown_fqdn = UNKNOWN_FQDN # Setup Uicd cli object for UI interation. self.ui = UicdCli(self.uicd_zip[0], self.uicd_workflows) + self.passpoint_workflow = "passpoint-login_%s" % self.dut.model def setup_test(self): self.dut.droid.wakeLockAcquireBright() self.dut.droid.wakeUpNow() + self.dut.unlock_screen() def teardown_test(self): @@ -180,7 +182,7 @@ class WifiPasspointTest(acts.base_test.BaseTestClass): "Passpoint Provisioning status %s" % dut_event['data'][ 'status']) if int(dut_event['data']['status']) == 7: - self.ui.run(self.dut.serial, "passpoint-login") + self.ui.run(self.dut.serial, self.passpoint_workflow) # Clear all previous events. self.dut.ed.clear_all_events() diff --git a/acts/tests/google/wifi/WifiScannerMultiScanTest.py b/acts/tests/google/wifi/WifiScannerMultiScanTest.py index 1b33e57e64..491b07a425 100755 --- a/acts/tests/google/wifi/WifiScannerMultiScanTest.py +++ b/acts/tests/google/wifi/WifiScannerMultiScanTest.py @@ -231,6 +231,14 @@ class WifiScannerMultiScanTest(WifiBaseTest): def __init__(self, controllers): WifiBaseTest.__init__(self, controllers) + self.tests = ( + 'test_wifi_two_scans_at_same_interval', + 'test_wifi_two_scans_at_different_interval', + 'test_wifi_scans_24GHz_and_both', + 'test_wifi_scans_5GHz_and_both', + 'test_wifi_scans_batch_and_24GHz', + 'test_wifi_scans_batch_and_5GHz', + 'test_wifi_scans_24GHz_5GHz_full_result',) def setup_class(self): # If running in a setup with attenuators, set attenuation on all diff --git a/acts/tests/google/wifi/WifiScannerScanTest.py b/acts/tests/google/wifi/WifiScannerScanTest.py index 9b06641e37..eaef028eee 100755 --- a/acts/tests/google/wifi/WifiScannerScanTest.py +++ b/acts/tests/google/wifi/WifiScannerScanTest.py @@ -61,19 +61,9 @@ class WifiScannerScanTest(WifiBaseTest): "test_wifi_scanner_with_wifi_off", "test_single_scan_report_each_scan_for_channels_with_enumerated_params", "test_single_scan_report_each_scan_for_band_with_enumerated_params", - "test_wifi_scanner_batch_scan_channel_sanity", - "test_wifi_scanner_batch_scan_period_too_short", - "test_batch_scan_report_buffer_full_for_channels_with_enumerated_params", - "test_batch_scan_report_buffer_full_for_band_with_enumerated_params", - "test_batch_scan_report_each_scan_for_channels_with_enumerated_params", - "test_batch_scan_report_each_scan_for_band_with_enumerated_params", "test_single_scan_report_full_scan_for_channels_with_enumerated_params", "test_single_scan_report_full_scan_for_band_with_enumerated_params", - "test_batch_scan_report_full_scan_for_channels_with_enumerated_params", - "test_batch_scan_report_full_scan_for_band_with_enumerated_params", - "test_wifi_connection_while_single_scan", "test_single_scan_while_pno", - "test_wifi_connection_and_pno_while_batch_scan", "test_wifi_scanner_single_scan_in_isolated", "test_wifi_scanner_with_invalid_numBssidsPerScan", "test_wifi_scanner_dual_radio_low_latency", @@ -776,50 +766,6 @@ class WifiScannerScanTest(WifiBaseTest): len(scan_settings), scan_settings)) self.wifi_scanner_batch_scan_full(scan_settings[0]) - @test_tracker_info(uuid="740e1c18-911a-43d2-9317-3827ecf71d3b") - def test_wifi_connection_while_single_scan(self): - """Test configuring a connection parallel to wifi scanner single scan. - - 1. Start WifiScanner single scan for both band with default scan settings. - 2. Configure a connection to reference network. - 3. Verify that connection to reference network occurred. - 2. Verify that scanner report single scan results. - """ - self.attenuators[ATTENUATOR].set_atten(0) - data = wutils.start_wifi_single_scan(self.dut, - self.default_scan_setting) - idx = data["Index"] - scan_rt = data["ScanElapsedRealtime"] - self.log.info("Wifi single shot scan started with index: {}".format( - idx)) - asserts.assert_true(self.connect_to_reference_network(), NETWORK_ERROR) - time.sleep(10) #wait for connection to be active - asserts.assert_true( - wutils.validate_connection(self.dut, self.ping_addr), - "Error, No internet connection for current network") - #generating event wait time from scan setting plus leeway - scan_time, scan_channels = wutils.get_scan_time_and_channels( - self.wifi_chs, self.default_scan_setting, self.stime_channel) - wait_time = int(scan_time / 1000) + self.leeway - validity = False - try: - event_name = "{}{}onResults".format(EVENT_TAG, idx) - self.log.debug("Waiting for event: {} for time {}".format( - event_name, wait_time)) - event = self.dut.ed.pop_event(event_name, wait_time) - self.log.debug("Event received: {}".format(event)) - results = event["data"]["Results"] - bssids, validity = self.proces_and_valid_batch_scan_result( - results, scan_rt, event["data"][KEY_RET], - self.default_scan_setting) - self.log.info("Scan number Buckets: {}\nTotal BSSID: {}".format( - len(results), bssids)) - asserts.assert_true( - len(results) == 1 and bssids >= 1, EMPTY_RESULT) - except queue.Empty as error: - raise AssertionError( - "Event did not triggered for single scan {}".format(error)) - @test_tracker_info(uuid="e9a7cfb5-21c4-4c40-8169-8d88b65a1dee") def test_single_scan_while_pno(self): """Test wifi scanner single scan parallel to PNO connection. @@ -832,6 +778,13 @@ class WifiScannerScanTest(WifiBaseTest): 6. Verify connection occurred through PNO. """ self.log.info("Check connection through PNO for reference network") + self.attenuators[ATTENUATOR].set_atten(0) + asserts.assert_true(self.connect_to_reference_network(), NETWORK_ERROR) + time.sleep(10) #wait for connection to be active + asserts.assert_true( + wutils.validate_connection(self.dut, self.ping_addr), + "Error, No internet connection for current network") + current_network = self.dut.droid.wifiGetConnectionInfo() self.log.info("Current network: {}".format(current_network)) asserts.assert_true('network_id' in current_network, NETWORK_ID_ERROR) diff --git a/acts/tests/google/wifi/p2p/functional/WifiP2pSnifferTest.py b/acts/tests/google/wifi/p2p/functional/WifiP2pSnifferTest.py index a359debd70..f9d2b23120 100644 --- a/acts/tests/google/wifi/p2p/functional/WifiP2pSnifferTest.py +++ b/acts/tests/google/wifi/p2p/functional/WifiP2pSnifferTest.py @@ -25,7 +25,7 @@ from acts.test_decorators import test_tracker_info from acts.test_utils.wifi.p2p.WifiP2pBaseTest import WifiP2pBaseTest from acts.test_utils.wifi.p2p import wifi_p2p_test_utils as wp2putils from acts.test_utils.wifi.p2p import wifi_p2p_const as p2pconsts -from acts.controllers.ap_lib import hostapd_constants +from acts.controllers.ap_lib.hostapd_constants import BAND_2G from scapy.all import * WPS_PBC = wp2putils.WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_PBC @@ -53,7 +53,7 @@ class WifiP2pSnifferTest(WifiP2pBaseTest): def setup_test(self): super(WifiP2pSnifferTest, self).setup_test() self.pcap_procs = wutils.start_pcap( - self.packet_capture, '2g', self.log_path, self.test_name) + self.packet_capture, '2g', self.test_name) def teardown_test(self): self.verify_mac_no_leakage() @@ -62,8 +62,7 @@ class WifiP2pSnifferTest(WifiP2pBaseTest): def configure_packet_capture(self): """Configure packet capture on the social channels.""" self.packet_capture = self.packet_capture[0] - result = self.packet_capture.configure_monitor_mode( - hostapd_constants.BAND_2G, 6) + result = self.packet_capture.configure_monitor_mode(BAND_2G, 6) if not result: raise ValueError("Failed to configure channel for 2G band") @@ -72,8 +71,8 @@ class WifiP2pSnifferTest(WifiP2pBaseTest): self.log.info("Stopping packet capture") wutils.stop_pcap(self.packet_capture, self.pcap_procs, False) # Verify factory MAC is not leaked in 2G pcaps - pcap_fname = os.path.join(self.log_path, self.test_name, - (self.test_name + '_2G.pcap')) + pcap_fname = '%s_%s.pcap' % (self.pcap_procs[BAND_2G][1], + BAND_2G.upper()) packets = rdpcap(pcap_fname) wutils.verify_mac_not_found_in_pcap(self.dut1_mac, packets) wutils.verify_mac_not_found_in_pcap(self.dut2_mac, packets) diff --git a/acts/tests/google/wifi/rtt/functional/RangeAwareTest.py b/acts/tests/google/wifi/rtt/functional/RangeAwareTest.py index 8c60e8239f..4eff048dff 100644 --- a/acts/tests/google/wifi/rtt/functional/RangeAwareTest.py +++ b/acts/tests/google/wifi/rtt/functional/RangeAwareTest.py @@ -274,22 +274,22 @@ class RangeAwareTest(AwareBaseTest, RttBaseTest): "Missing (timed-out) results", extras=extras) asserts.assert_false( - stats['any_lci_mismatch'], "LCI mismatch", extras=extras) + stats_reverse_direction['any_lci_mismatch'], "LCI mismatch", extras=extras) asserts.assert_false( - stats['any_lcr_mismatch'], "LCR mismatch", extras=extras) + stats_reverse_direction['any_lcr_mismatch'], "LCR mismatch", extras=extras) asserts.assert_equal( - stats['num_invalid_rssi'], 0, "Invalid RSSI", extras=extras) + stats_reverse_direction['num_invalid_rssi'], 0, "Invalid RSSI", extras=extras) asserts.assert_true( stats_reverse_direction['num_failures'] <= self.rtt_max_failure_rate_two_sided_rtt_percentage * - stats['num_results'] / 100, + stats_reverse_direction['num_results'] / 100, "Failure rate is too high", extras=extras) if accuracy_evaluation: asserts.assert_true( stats_reverse_direction['num_range_out_of_margin'] <= self.rtt_max_margin_exceeded_rate_two_sided_rtt_percentage * - stats['num_success_results'] / 100, + stats_reverse_direction['num_success_results'] / 100, "Results exceeding error margin rate is too high", extras=extras) |