예제 #1
0
    def setup_class(self):
        """ Setup devices for tests and unpack params """
        self.dut_a = self.android_devices[0]
        self.dut_b = self.android_devices[1]

        req_params = ("wifi_network",)
        self.unpack_userparams(req_params)
        wutils.connect_to_wifi_network(self.dut_a, self.wifi_network)
        wutils.connect_to_wifi_network(self.dut_b, self.wifi_network)
        time.sleep(WAIT_FOR_IP)

        try:
            self.ipv4_dut_a = self.dut_a.droid.connectivityGetIPv4Addresses(
                WLAN)[0]
            self.ipv4_dut_b = self.dut_b.droid.connectivityGetIPv4Addresses(
                WLAN)[0]
            self.ipv6_dut_a = self.dut_a.droid.connectivityGetIPv6Addresses(
                WLAN)[0]
            self.ipv6_dut_b = self.dut_b.droid.connectivityGetIPv6Addresses(
                WLAN)[0]
        except Exception as e:
            asserts.abort_class("Failed to get IPv4/IPv6 address: %s" % e)

        self.crypt_auth_combos = iutils.generate_random_crypt_auth_combo()

        self.tcpdump_pid_a = None
        self.tcpdump_pid_b = None
예제 #2
0
    def test_wifi_tethering_open_network_5g_stress(self):
        """ Steps:

            1. Save wifi hotspot configuration with open network 5G band
               (Not allowed manually. b/72412729)
            2. Turn on wifi hotspot
            3. Connect tethered device and verify internet connectivity
            4. Turn off wifi hotspot
            5. Repeat steps 2 to 4
        """
        # save open network wifi ap configuration with 5G band
        config = {
            wutils.WifiEnums.SSID_KEY:
            self.open_network[wutils.WifiEnums.SSID_KEY]
        }
        config[wutils.WifiEnums.APBAND_KEY] = WIFI_CONFIG_APBAND_5G
        self._save_wifi_softap_configuration(self.hotspot_device, config)

        # turn on/off wifi hotspot, connect device
        for _ in range(9):
            self._turn_on_wifi_hotspot(self.hotspot_device)
            wutils.connect_to_wifi_network(self.tethered_devices[0],
                                           self.open_network)
            wutils.stop_wifi_tethering(self.hotspot_device)
            time.sleep(1)  # wait for some time before turning on hotspot
    def _verify_captive_portal(self, network, click_accept=ACCEPT_CONTINUE):
        """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:
            network: captive portal network to connect to
            click_accept: Notification to select to accept captive portal
        """
        # connect to captive portal wifi network
        wutils.connect_to_wifi_network(self.dut,
                                       network,
                                       check_connectivity=False)

        # run ui automator
        uutils.wait_and_click(self.dut, text="%s" % network["SSID"])
        if uutils.has_element(self.dut, text="%s" % click_accept):
            uutils.wait_and_click(self.dut, text="%s" % click_accept)

        # 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
        asserts.assert_true(
            wutils.validate_connection(self.dut, ping_gateway=False),
            "Failed to connect to internet. Captive portal test failed")
예제 #4
0
    def start_softap_and_connect_to_wifi_network(self, nw_params, softap_band):
        """Test concurrent wifi connection and softap.

        This helper method first starts SoftAp and then makes a wifi connection.
        1. Bring up softap and verify AP can be connected by a client device.
        2. Bring up wifi.
        3. Establish connection to a network.
        4. Run iperf on the wifi/softap connection to the network.
        5. Verify wifi state and softap state.

        Args:
            nw_params: Params for network STA connection.
            softap_band: Band for the AP.
        """
        softap_config = self.start_softap_and_verify(softap_band, False)
        wutils.connect_to_wifi_network(self.dut, nw_params)
        self.run_iperf_client((nw_params, self.dut))
        self.run_iperf_client((softap_config, self.dut_client))

        if len(self.android_devices) > 2:
            self.log.info("Testbed has extra devices, do more validation")
            self.verify_traffic_between_dut_clients(self.dut,
                                                    self.android_devices[2])

        asserts.assert_true(self.dut.droid.wifiCheckState(),
                            "Wifi is not reported as running")
        asserts.assert_true(self.dut.droid.wifiIsApEnabled(),
                            "SoftAp is not reported as running")
예제 #5
0
    def test_randomized_mac_used_during_connection(self):
        """Verify that the randomized MAC address and not the factory
        MAC address is used during connection by checking the softap logs.

        Steps:
        1. Set up softAP on dut_softap.
        2. Have dut connect to the softAp.
        3. Verify that only randomized MAC appears in softAp logs.
        """
        self.dut_softap.adb.shell(LOG_CLEAR)
        config = wutils.create_softap_config()
        wutils.start_wifi_tethering(self.dut_softap,
                                    config[wutils.WifiEnums.SSID_KEY],
                                    config[wutils.WifiEnums.PWD_KEY],
                                    WIFI_CONFIG_APBAND_2G)

        # Internet validation fails when dut_softap does not have a valid sim
        # supporting softap. Since this test is not checking for internet
        # validation, we suppress failure signals.
        wutils.connect_to_wifi_network(self.dut, config, assert_on_fail=False)
        mac = self.get_current_mac_address(self.dut)
        wutils.stop_wifi_tethering(self.dut_softap)

        self.is_valid_randomized_mac_address(mac)
        log = self.dut_softap.adb.shell(LOG_GREP.format(mac))
        asserts.assert_true(len(log) > 0, "Randomized MAC not in log.")
        log = self.dut_softap.adb.shell(LOG_GREP.format(self.dut_factory_mac))
        asserts.assert_true(len(log) == 0, "Factory MAC is in log.")
    def test_sta_turn_off_screen_can_be_pinged(self):
        """Verify DUT can be pinged by another device after idle for a while

        Steps:
        1. Ensure the 2GHz WPA-PSK network is visible in scan result.
        2. DUT and DUT_Client connect to the network and validate internet connection.
        3. Let DUT sleep for 5 minutes
        4. Check DUT can be pinged by DUT_Client
        """
        # DUT connect to AP
        wutils.connect_to_wifi_network(self.dut, self.wpa_networks[0]["2g"])
        wutils.connect_to_wifi_network(self.dut_client, self.wpa_networks[0]["2g"])
        # Check DUT and DUT_Client can ping each other successfully
        self.verify_traffic_between_devices(self.dut,self.dut_client)
        self.verify_traffic_between_devices(self.dut_client,self.dut)
        # DUT turn off screen and go sleep for 5 mins
        self.dut.droid.wakeLockRelease()
        self.dut.droid.goToSleepNow()
        # TODO(hsiuchangchen): find a way to check system already suspended
        #                      instead of waiting 5 mins
        self.log.info("Sleep for 5 minutes")
        time.sleep(300)
        # Verify DUT_Client can ping DUT when DUT sleeps
        self.verify_traffic_between_devices(self.dut,self.dut_client)
        self.dut.droid.wakeLockAcquireBright()
        self.dut.droid.wakeUpNow()
    def associate(self,
                  target_ssid,
                  target_pwd=None,
                  key_mgmt=None,
                  check_connectivity=True,
                  hidden=False):
        """Function to associate an Android WLAN device.

        Args:
            target_ssid: SSID to associate to.
            target_pwd: Password for the SSID, if necessary.
            key_mgmt: The hostapd wpa_key_mgmt value, distinguishes wpa3 from
                wpa2 for android tests.
            check_connectivity: Whether to check for internet connectivity.
            hidden: Whether the network is hidden.
        Returns:
            True if successfully connected to WLAN, False if not.
        """
        network = {'SSID': target_ssid, 'hiddenSSID': hidden}
        if target_pwd:
            network['password'] = target_pwd
        if key_mgmt:
            network['security'] = key_mgmt
        try:
            awutils.connect_to_wifi_network(
                self.device,
                network,
                check_connectivity=check_connectivity,
                hidden=hidden)
            return True
        except Exception as e:
            self.device.log.info('Failed to associated (%s)' % e)
            return False
    def test_connect_to_wpa_5g(self):
        """Verify DUT can connect to 5GHz WPA-PSK network

        Steps:
        1. Ensure the 5GHz WPA-PSK network is visible in scan result.
        2. Connect to the network and validate internet connection.
        """
        wutils.connect_to_wifi_network(self.dut, self.wpa_networks[0]["5g"])
    def test_connect_to_wep_2g(self):
        """Verify DUT can connect to 2GHz WEP network

        Steps:
        1. Ensure the 2GHz WEP network is visible in scan result.
        2. Connect to the network and validate internet connection.
        """
        wutils.connect_to_wifi_network(self.dut, self.wep_networks[0]["2g"])
    def test_firmware_crash_softap_reconnect_stress(self):
        """Firmware crash stress test for softap mode

        1. Turn off dut's Wi-Fi
        2. Turn on dut's hotspot and connected by dut client
        3. Trigger firmware crash
        4. Check ssr happened
        5. Check the connectivity of hotspot's client
        6. Repeat step 3~5
        """
        wutils.wifi_toggle_state(self.dut, False)
        # Setup Soft AP
        sap_config = wutils.create_softap_config()
        wutils.start_wifi_tethering(self.dut,
                                    sap_config[wutils.WifiEnums.SSID_KEY],
                                    sap_config[wutils.WifiEnums.PWD_KEY],
                                    wutils.WifiEnums.WIFI_CONFIG_APBAND_2G)
        config = {
            "SSID": sap_config[wutils.WifiEnums.SSID_KEY],
            "password": sap_config[wutils.WifiEnums.PWD_KEY]
        }
        # DUT client connects to softap
        wutils.wifi_toggle_state(self.dut_client, True)
        wutils.connect_to_wifi_network(self.dut_client,
                                       config,
                                       check_connectivity=False)
        # Ping the DUT
        dut_addr = self.dut.droid.connectivityGetIPv4Addresses(
            self.ap_iface)[0]
        asserts.assert_true(
            utils.adb_shell_ping(self.dut_client,
                                 count=10,
                                 dest_ip=dut_addr,
                                 timeout=20),
            "%s ping %s failed" % (self.dut_client.serial, dut_addr))
        for count in range(self.stress_count):
            self.log.info(
                "%s: %d/%d" %
                (self.current_test_name, count + 1, self.stress_count))
            wutils.reset_wifi(self.dut_client)
            # Trigger firmware crash
            self.trigger_wifi_firmware_crash(self.dut)
            # Connect DUT to Network
            wutils.connect_to_wifi_network(self.dut_client,
                                           config,
                                           check_connectivity=False)
            # Ping the DUT
            server_addr = self.dut.droid.connectivityGetIPv4Addresses(
                self.ap_iface)[0]
            asserts.assert_true(
                utils.adb_shell_ping(self.dut_client,
                                     count=10,
                                     dest_ip=server_addr,
                                     timeout=20),
                "%s ping %s failed" % (self.dut_client.serial, server_addr))
        wutils.stop_wifi_tethering(self.dut)
    def test_connect_to_5g_can_be_pinged(self):
        """Verify DUT can be pinged by another device when it connects to 5GHz AP

        Steps:
        1. Ensure the 5GHz WPA-PSK network is visible in scan result.
        2. Connect to the network and validate internet connection.
        3. Check DUT can be pinged by another device
        """
        wutils.connect_to_wifi_network(self.dut, self.wpa_networks[0]["5g"])
        wutils.connect_to_wifi_network(self.dut_client, self.wpa_networks[0]["5g"])
        self.verify_traffic_between_devices(self.dut,self.dut_client)
예제 #12
0
    def add_hiddenSSID_and_connect(self, hidden_network):
        """Add the hidden network and connect to it.

        Args:
            hidden_network: The hidden network config to connect to.

        """
        wutils.connect_to_wifi_network(self.dut, hidden_network, hidden=True)
        if not wutils.validate_connection(self.dut):
            raise signals.TestFailure("Fail to connect to internet on %s" %
                                      hidden_network)
    def test_IPv6_RA_packets(self):
        """ Test if the device filters the IPv6 packets

        Steps:
          1. Send a RA packet to DUT. DUT should accept this
          2. Send duplicate RA packets. The RA packets should be filtered
             for the next 30 seconds (1/6th of RA lifetime)
          3. The next RA packets should be accepted
        """
        # get mac address of the dut
        ap = self.access_points[0]
        wifi_network = copy.deepcopy(self.wpapsk_5g)
        wifi_network['meteredOverride'] = 1
        wutils.connect_to_wifi_network(self.dut, wifi_network)
        mac_addr = self.dut.droid.wifiGetConnectionInfo()['mac_address']
        self.log.info("mac_addr %s" % mac_addr)
        time.sleep(30)  # wait 30 sec before sending RAs

        # get the current ra count
        ra_count = self._get_icmp6intype134()

        # Start scapy to send RA to the phone's MAC
        ap.send_ra('wlan1', mac_addr, 0, 1)

        # get the latest ra count
        ra_count_latest = self._get_icmp6intype134()
        asserts.assert_true(ra_count_latest == ra_count + 1,
                            "Device dropped the first RA in sequence")

        # Generate and send 'x' number of duplicate RAs, for 1/6th of the the
        # lifetime of the original RA. Test assumes that the original RA has a
        # lifetime of 180s. Hence, all RAs received within the next 30s of the
        # original RA should be filtered.
        ra_count = ra_count_latest
        count = LIFETIME / LIFETIME_FRACTION / INTERVAL
        ap.send_ra('wlan1', mac_addr, interval=INTERVAL, count=count)

        # Fail test if at least 90% of RAs were not dropped.
        ra_count_latest = self._get_icmp6intype134()
        pkt_loss = count - (ra_count_latest - ra_count)
        percentage_loss = float(pkt_loss) / count * 100
        asserts.assert_true(
            percentage_loss >= 90, "Device did not filter "
            "duplicate RAs correctly. %d Percent of duplicate"
            " RAs were accepted" % (100 - percentage_loss))

        # Any new RA after this should be accepted.
        ap.send_ra('wlan1', mac_addr, interval=INTERVAL, count=1)
        ra_count_latest = self._get_icmp6intype134()
        asserts.assert_true(
            ra_count_latest == ra_count + 1,
            "Device did not accept new RA after 1/6th time "
            "interval. Device dropped a valid RA in sequence.")
예제 #14
0
    def connect_to_network_and_verify_mac_randomization(
            self, network, status=RANDOMIZATION_PERSISTENT):
        """Connect to the given network and verify MAC.

          Args:
              network: dict, the network information.
              status: int, MAC randomization level.

          Returns:
              The randomized MAC addresss string.

        """
        wutils.connect_to_wifi_network(self.dut, network)
        return self.verify_mac_randomization(network, status=status)
예제 #15
0
    def add_hiddenSSID_and_connect(self, hidden_network):
        """Add the hidden network and connect to it.

        Args:
            hidden_network: The hidden network config to connect to.

        """
        ret = self.dut.droid.wifiAddNetwork(hidden_network)
        asserts.assert_true(ret != -1, "Add network %r failed" % hidden_network)
        self.dut.droid.wifiEnableNetwork(ret, 0)
        wutils.connect_to_wifi_network(self.dut, hidden_network)
        if not wutils.validate_connection(self.dut):
            raise signals.TestFailure("Fail to connect to internet on %s" %
                                       hidden_network)
예제 #16
0
    def get_softap_acs(self, softap):
        """Connect to the softap on client-dut and get the softap channel
           information.

        Args:
            softap: The softap network configuration information.

        """
        wutils.connect_to_wifi_network(self.dut_client, softap,
            check_connectivity=False)
        softap_info = self.dut_client.droid.wifiGetConnectionInfo()
        self.log.debug("DUT is connected to softAP %s with details: %s" %
                       (softap[wutils.WifiEnums.SSID_KEY], softap_info))
        frequency = softap_info['frequency']
        return hostapd_constants.CHANNEL_MAP[frequency]
예제 #17
0
    def get_connection_data(self, ad, network):
        """Connect and get network id and ssid info from connection data.

        Args:
            ad: AndroidDevice to use for connection
            network: network info of the network to connect to

        Returns:
            A convenience dict with the connected network's ID and SSID.
        """
        wutils.connect_to_wifi_network(ad, network)
        connect_data = ad.droid.wifiGetConnectionInfo()
        ssid_id_dict = dict()
        ssid_id_dict[WifiEnums.NETID_KEY] = connect_data[WifiEnums.NETID_KEY]
        ssid_id_dict[WifiEnums.SSID_KEY] = connect_data[WifiEnums.SSID_KEY]
        return ssid_id_dict
    def test_IPv6_RA_with_RTT(self):
        """Test if the device filters IPv6 RA packets with different re-trans time

        Steps:
          1. Get the current RA count
          2. Send 400 packets with different re-trans time
          3. Verify that RA count increased by 400
          4. Verify internet connectivity
        """
        pkt_num = 400
        rtt_list = random.sample(range(10, 10000), pkt_num)
        self.log.info("RTT List: %s" % rtt_list)

        # get mac address of the dut
        ap = self.access_points[0]
        wutils.connect_to_wifi_network(self.dut, self.wpapsk_5g)
        mac_addr = self.dut.droid.wifiGetConnectionInfo()['mac_address']
        self.log.info("mac_addr %s" % mac_addr)
        time.sleep(30)  # wait 30 sec before sending RAs

        # get the current ra count
        ra_count = self._get_icmp6intype134()

        # start tcpdump on the device
        tcpdump_pid = start_tcpdump(self.dut, self.test_name)

        # send RA with differnt re-trans time
        for rtt in rtt_list:
            ap.send_ra('wlan1', mac_addr, 0, 1, rtt=rtt)

        # stop tcpdump and pull file
        time.sleep(60)
        pcap_file = stop_tcpdump(self.dut, tcpdump_pid, self.test_name)

        # get the new RA count
        new_ra_count = self._get_icmp6intype134()
        asserts.assert_true(new_ra_count >= ra_count + pkt_num,
                            "Device did not accept all RAs")

        # verify the RA pkts RTT match
        tcpdump_rtt_list = self._get_rtt_list_from_tcpdump(pcap_file)
        asserts.assert_true(
            set(rtt_list).issubset(set(tcpdump_rtt_list)),
            "RA packets didn't match with tcpdump")

        # verify if internet connectivity works after sending RA packets
        wutils.validate_connection(self.dut)
    def test_connection_to_new_networks(self):
        """Check if we can connect to new networks after Auto-update.

           Steps:
               1. Connect to a PSK network.
               2. Connect to an open network.
               3. Forget ntworks added in 1 & 2.
               TODO: (@bmahadev) Add WEP network once it's ready.

        """
        wutils.connect_to_wifi_network(self.dut, self.open_network[0]['5g'])
        wutils.connect_to_wifi_network(self.dut,
                                       self.reference_networks[0]['2g'])
        wutils.wifi_forget_network(
            self.dut, self.reference_networks[0]['2g'][WifiEnums.SSID_KEY])
        wutils.wifi_forget_network(
            self.dut, self.open_network[0]['5g'][WifiEnums.SSID_KEY])
    def test_firmware_crash_wifi_reconnect_stress(self):
        """Firmware crash stress test for station mode

        1. Turn on Wi-Fi and connect to access point
        2. Trigger firmware crash
        3. Check ssr happened
        4. Check dut can connect to access point
        5. Repeat step 2~4
        """
        wutils.wifi_toggle_state(self.dut, True)
        wutils.connect_to_wifi_network(self.dut, self.network)
        for count in range(self.stress_count):
            self.log.info(
                "%s: %d/%d" %
                (self.current_test_name, count + 1, self.stress_count))
            wutils.reset_wifi(self.dut)
            self.trigger_wifi_firmware_crash(self.dut)
            wutils.connect_to_wifi_network(self.dut, self.network)
 def test_ringbuffers_are_dumped_during_lsdebug(self):
     """Steps:
     1. Connect to a open network.
     2. Delete old files under data/vendor/tombstones/wifi
     3. Call lshal debug on wifi hal component
     4. Verify that files are created under data/vender/tombstones/wifi
     """
     wutils.connect_to_wifi_network(self.dut, self.open_network)
     time.sleep(DEFAULT_WAIT_TIME)
     self.dut.adb.shell("rm data/vendor/tombstones/wifi/*")
     try:
         self.dut.adb.shell("lshal debug [email protected]::IWifi")
     except UnicodeDecodeError:
         """ Gets this error because adb.shell trys to parse the output to a string
         but ringbuffer dumps should already be generated """
         self.log.info("Unicode decode error occurred, but this is ok")
     file_count_plus_one = self.dut.adb.shell("ls -l data/vendor/tombstones/wifi | wc -l")
     if int(file_count_plus_one) <= 1:
         raise signals.TestFailure("Failed to create ringbuffer debug files.")
예제 #22
0
    def start_softap_and_verify(self, band, check_connectivity=True):
        """Test startup of softap.

        1. Bring up AP mode.
        2. Verify SoftAP active using the client device.

        Args:
            band: wifi band to start soft ap on
            check_connectivity: If set, verify internet connectivity

        Returns:
            Softap config
        """
        config = self.create_softap_config()
        wutils.start_wifi_tethering(self.dut, config[WifiEnums.SSID_KEY],
                                    config[WifiEnums.PWD_KEY], band)
        for ad in self.android_devices[1:]:
            wutils.connect_to_wifi_network(
                ad, config, check_connectivity=check_connectivity)
        return config
예제 #23
0
    def start_traffic_and_softap(self, network, softap_band):
        """Start iPerf traffic on client dut, during softAP bring-up on dut.

        Args:
            network: Network information of the network to connect to.
            softap_band: The band to use for softAP.

        """
        if not network:
            # For a clean environment just bring up softap and return channel.
            softap = self.start_softap_and_verify(softap_band)
            channel = self.get_softap_acs(softap)
            return channel
        # Connect to the AP and start IPerf traffic, while we bring up softap.
        wutils.connect_to_wifi_network(self.dut_client, network)
        t = Thread(target=self.run_iperf_client,args=((network,self.dut_client),))
        t.setDaemon(True)
        t.start()
        time.sleep(1)
        softap = self.start_softap_and_verify(softap_band)
        t.join()
        channel = self.get_softap_acs(softap)
        return channel
예제 #24
0
    def test_roaming(self):
        network = self.reference_networks[0]["2g"]
        wutils.connect_to_wifi_network(self.dut, network)

        time.sleep(10)
        test_time_slot = int(self.total_test_hour /
                             self.log_capture_period_hour)
        edge_time_slot = int(self.total_test_hour %
                             self.log_capture_period_hour)

        for i in range(test_time_slot):
            self.browsing_test(self.log_capture_period_hour)
        if edge_time_slot:
            self.browsing_test(edge_time_slot)

        self.log.info("Total roaming times: {}".format(
            self.atten_roaming_count))
        self.log.info("Total ping times: {}".format(self.ping_count))
        self.log.info("Retry pass times: {}".format(self.retry_pass_count))
        self.log.info("Total fail times: {}".format(self.fail_count))
        if self.fail_count:
            signals.TestFailure('Find roaming fail condition',
                                extras={'Roaming fail times': self.fail_count})
예제 #25
0
    def test_mac_randomization_ap_sta(self):
        """Bring up STA and softAP and verify MAC randomization.

        Steps:
            1. Connect to a network and get randomized MAC.
            2. Bring up softAP on the DUT.
            3. Connect to softAP network on the client and get MAC.
            4. Verify AP and STA use different randomized MACs.
            5. Find the channel of the SoftAp network.
            6. Configure sniffer on that channel.
            7. Verify the factory MAC is not leaked.

        """
        wutils.set_wifi_country_code(self.dut, wutils.WifiEnums.CountryCode.US)
        wutils.set_wifi_country_code(self.dut_client,
                                     wutils.WifiEnums.CountryCode.US)
        mac_sta = self.connect_to_network_and_verify_mac_randomization(
            self.wpapsk_2g)
        softap = wutils.start_softap_and_verify(self, WIFI_CONFIG_APBAND_2G)
        wutils.connect_to_wifi_network(self.dut_client, softap)
        softap_info = self.dut_client.droid.wifiGetConnectionInfo()
        mac_ap = softap_info['mac_address']
        if mac_sta == mac_ap:
            raise signals.TestFailure("Same MAC address was used for both "
                                      "AP and STA: %s" % mac_sta)

        # Verify SoftAp MAC is randomized
        softap_mac = self.get_soft_ap_mac_address()
        message = (
            'Randomized SoftAp MAC and Factory SoftAp MAC are the same. '
            'Randomized SoftAp MAC = %s, Factory SoftAp MAC = %s' %
            (softap_mac, self.soft_ap_factory_mac))
        asserts.assert_true(softap_mac != self.soft_ap_factory_mac, message)

        softap_channel = hostapd_constants.CHANNEL_MAP[
            softap_info['frequency']]
        self.log.info("softap_channel = %s\n" % (softap_channel))
        result = self.packet_capture.configure_monitor_mode(
            hostapd_constants.BAND_2G, softap_channel)
        if not result:
            raise ValueError("Failed to configure channel for 2G band")
        self.pcap_procs = wutils.start_pcap(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 = '%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)
        self.verify_mac_is_found_in_pcap(softap_mac, packets)
        self.verify_mac_is_found_in_pcap(self.get_sta_mac_address(), packets)
    def test_firmware_crash_concurrent_reconnect_stress(self):
        """Firmware crash stress test for concurrent mode

        1. Turn on dut's Wi-Fi and connect to access point
        2. Turn on dut's hotspot and connected by dut client
        3. Trigger firmware crash
        4. Check ssr happened
        5. Check dut can connect to access point
        6. Check the connectivity of hotspot's client
        7. Repeat step 3~6
        """
        if self.dut.model not in self.dbs_supported_models:
            raise signals.TestSkip("%s does not support dual interfaces" %
                                   self.dut.model)

        # Connect DUT to Network
        wutils.wifi_toggle_state(self.dut, True)
        wutils.connect_to_wifi_network(self.dut, self.network)
        # Setup Soft AP
        sap_config = wutils.create_softap_config()
        wutils.start_wifi_tethering(self.dut,
                                    sap_config[wutils.WifiEnums.SSID_KEY],
                                    sap_config[wutils.WifiEnums.PWD_KEY],
                                    wutils.WifiEnums.WIFI_CONFIG_APBAND_2G)
        config = {
            "SSID": sap_config[wutils.WifiEnums.SSID_KEY],
            "password": sap_config[wutils.WifiEnums.PWD_KEY]
        }
        # Client connects to Softap
        wutils.wifi_toggle_state(self.dut_client, True)
        wutils.connect_to_wifi_network(self.dut_client, config)
        for count in range(self.stress_count):
            self.log.info(
                "%s: %d/%d" %
                (self.current_test_name, count + 1, self.stress_count))
            wutils.reset_wifi(self.dut_client)
            wutils.reset_wifi(self.dut)
            # Trigger firmware crash
            self.trigger_wifi_firmware_crash(self.dut)
            wutils.connect_to_wifi_network(self.dut, self.network)
            wutils.connect_to_wifi_network(self.dut_client, config)
        wutils.stop_wifi_tethering(self.dut)
예제 #27
0
 def test_wifi_connection_5G_with_mac_randomization(self):
     """Tests connection to 5G network with Connected MAC Randomization.
     """
     wutils.connect_to_wifi_network(self.dut, self.wpapsk_5g)
     mac = self.get_current_mac_address(self.dut)
     self.is_valid_randomized_mac_address(mac)
 def test_connect_to_wpa3_personal_5g(self):
     wutils.start_wifi_connection_scan_and_ensure_network_found(
         self.dut, self.wpa3_personal_5g[WifiEnums.SSID_KEY])
     wutils.connect_to_wifi_network(self.dut, self.owe_5g)