Example #1
0
    def test_wifi_tracking_bssid_multi_listeners_found(self):
        """Test bssid tracking for multiple listeners
            1. Start BSSID tracking for 5g bssids
            2. Start BSSID tracking for 2g bssids
            3. Start WifiScanner scan on both bands.
            4. Valid the environment and check the APs are not in range.
            5. Attenuate the signal to make the APs in range.
            6. Verify onFound event triggered on both APs.
        """
        # Attenuate the signal to make APs invisible.
        self.attenuators[self.attenuator_id].set_atten(90)
        scan_setting = {
            "band": WifiEnums.WIFI_BAND_BOTH_WITH_DFS,
            "periodInMs": SCANTIME,
            "reportEvents": WifiEnums.REPORT_EVENT_AFTER_EACH_SCAN,
            "numBssidsPerScan": 32
        }
        track_setting_5g = {
            "bssidInfos": [self.bssid_5g],
            "apLostThreshold": 3
        }
        data_5g = start_wifi_track_bssid(self.dut, track_setting_5g)
        idx_5g = data_5g["Index"]

        track_setting_2g = {
            "bssidInfos": [self.bssid_2g],
            "apLostThreshold": 3
        }
        data_2g = start_wifi_track_bssid(self.dut, track_setting_2g)
        idx_2g = data_2g["Index"]

        valid_env = self.start_scan_and_validate_environment(
            scan_setting, self.combineBssids(track_setting_5g,
                                             track_setting_2g))
        try:
            asserts.assert_true(
                valid_env, "Test environment is not valid, AP is in range")
            self.attenuators[self.attenuator_id].set_atten(0)
            event_name = "{}{}{}{}onFound".format(BSSID_EVENT_TAG, idx_5g,
                                                  BSSID_EVENT_TAG, idx_2g)
            self.log.info("Waiting for the BSSID event {}".format(event_name))
            #waiting for 2x time to make sure
            event = self.dut.ed.pop_event(event_name, BSSID_EVENT_WAIT * 2)
            self.log.debug(event)
            found = self.check_bssid_in_found_result(
                self.combineBssids(track_setting_5g, track_setting_2g),
                event["data"]["Results"])
            asserts.assert_true(
                found,
                "Test failed because Bssid onFound event is not triggered")
        finally:
            self.dut.droid.wifiScannerStopBackgroundScan(self.scan_idx)
            if idx_5g:
                self.dut.droid.wifiScannerStopTrackingBssids(idx_5g)
            if idx_2g:
                self.dut.droid.wifiScannerStopTrackingBssids(idx_2g)
Example #2
0
    def track_bssid_with_vaild_scan_for_lost(self, track_setting):
        """Common logic for tracking a bssid for Lost event.

         1. Start Wifi Scanner scan with default scan settings.
         2. Validate the environment to check AP is not in range.
         3. Starts Wifi Scanner bssid tracking for interested bssids in track_setting.
         4. Attenuate the signal to make Bssids in range.
         5. Verified that onFound event is triggered for interested bssids in
            track setting.
         6. Attenuate the signal to make Bssids out of range.
         7. Verified that onLost event is triggered.

        Args:
            track_setting: Setting for bssid tracking.
            scan_setting: Setting used for starting the scan.

        Returns:
            True if Lost event occur for interested BSSID.
        """
        self.attenuators[self.attenuator_id].set_atten(90)
        valid_env = self.start_scan_and_validate_environment(
            self.default_scan_setting, track_setting["bssidInfos"])
        idx = None
        found = False
        try:
            asserts.assert_true(
                valid_env, "Test environment is not valid, AP is in range")
            data = start_wifi_track_bssid(self.dut, track_setting)
            idx = data["Index"]
            self.attenuators[self.attenuator_id].set_atten(0)
            #onFound event should be occurre before tracking for onLost event
            event_name = "{}{}onFound".format(BSSID_EVENT_TAG, idx)
            self.log.info("Waiting for the BSSID event {}".format(event_name))
            event = self.dut.ed.pop_event(event_name, BSSID_EVENT_WAIT)
            self.log.debug(event)
            found = self.check_bssid_in_found_result(
                track_setting["bssidInfos"], event["data"]["Results"])
            asserts.assert_true(
                found, "Test fail because Bssid is not found in event results")
            if found:
                self.attenuators[self.attenuator_id].set_atten(90)
                # log scan result for debugging
                for i in range(1, track_setting["apLostThreshold"]):
                    results = self.fetch_scan_result(self.scan_idx,
                                                     self.default_scan_setting)
                    self.log.debug("scan result {} {}".format(i, results))
                event_name = "{}{}onLost".format(BSSID_EVENT_TAG, idx)
                self.log.info(
                    "Waiting for the BSSID event {}".format(event_name))
                event = self.dut.ed.pop_event(event_name, BSSID_EVENT_WAIT)
                self.log.debug(event)
        except Empty as error:
            raise AssertionError(
                "Event {} did not triggered for {}\n{}".format(
                    event_name, track_setting["bssidInfos"], error))
        finally:
            self.dut.droid.wifiScannerStopBackgroundScan(self.scan_idx)
            if idx:
                self.dut.droid.wifiScannerStopTrackingBssids(idx)
Example #3
0
    def test_wifi_track_bssid_for_2g_while_scanning_5g_channels(self):
        """Test bssid track for 2g bssids while scanning 5g channels.

         1. Starts Wifi Scanner bssid tracking for 2g bssids in track_setting.
         2. Start Wifi Scanner scan for 5G Band only.
         3. Validate the environment to check AP is not in range.
         4. Attenuate the signal to make AP in range.
         5. Verified that onFound event isn't triggered for 2g bssids.
      """
        self.attenuators[self.attenuator_id].set_atten(90)
        scan_setting = {
            "band": WifiEnums.WIFI_BAND_5_GHZ,
            "periodInMs": SCANTIME,
            "reportEvents": WifiEnums.REPORT_EVENT_AFTER_EACH_SCAN,
            "numBssidsPerScan": 32
        }
        track_setting = {"bssidInfos": [self.bssid_2g], "apLostThreshold": 3}
        valid_env = self.start_scan_and_validate_environment(
            scan_setting, track_setting["bssidInfos"])
        idx = None
        try:
            asserts.assert_true(
                valid_env, "Test environment is not valid, AP is in range")
            data = start_wifi_track_bssid(self.dut, track_setting)
            idx = data["Index"]
            self.attenuators[self.attenuator_id].set_atten(0)
            event_name = "{}{}onFound".format(BSSID_EVENT_TAG, idx)
            self.log.info("Waiting for the BSSID event {}".format(event_name))
            #waiting for 2x time to make sure
            event = self.dut.ed.pop_event(event_name, BSSID_EVENT_WAIT * 2)
            self.log.debug(event)
            found = self.check_bssid_in_found_result(
                track_setting["bssidInfos"], event["data"]["Results"])
            asserts.assert_true(
                not found,
                "Test fail because Bssid onFound event is triggered")
        except Empty as error:
            self.log.info(
                "As excepted event didn't occurred with different scan setting"
            )
        finally:
            self.dut.droid.wifiScannerStopBackgroundScan(self.scan_idx)
            if idx:
                self.dut.droid.wifiScannerStopTrackingBssids(idx)
    def track_bssid_with_vaild_scan_for_found(self, track_setting):
        """Common logic for tracking a bssid for Found event.

         1. Starts Wifi Scanner bssid tracking for interested bssids in track_setting.
         2. Start Wifi Scanner scan with default scan settings.
         3. Validate the environment to check AP is not in range.
         4. Attenuate the signal to make AP in range.
         5. Verified that onFound event is triggered for interested bssids in
            track setting.

        Args:
            track_setting: Setting for bssid tracking.

        Returns:
            True if found event occur for interested BSSID.
        """
        self.attenuators[self.attenuator_id].set_atten(90)
        data = wutils.start_wifi_track_bssid(self.dut, track_setting)
        idx = data["Index"]
        self.start_scan_and_validate_environment(self.default_scan_setting,
                                                 track_setting["bssidInfos"])
        try:
            self.attenuators[self.attenuator_id].set_atten(0)
            event_name = "%s%sonFound" % (BSSID_EVENT_TAG, idx)
            self.log.info("Waiting for the BSSID event %s", event_name)
            event = self.dut.ed.pop_event(event_name, BSSID_EVENT_WAIT)
            self.log.debug(event)
            self.check_bssid_in_found_result(track_setting["bssidInfos"],
                                             event["data"]["Results"])
        except queue.Empty as error:
            self.log.error(error)
            # log scan result for debugging
            results = self.fetch_scan_result(self.scan_idx,
                                             self.default_scan_setting)
            self.log.debug("scan result %s", results)
            raise AssertionError(
                "Event %s did not triggered for %s\n%s" %
                (event_name, track_setting["bssidInfos"], error))
        finally:
            self.dut.droid.wifiScannerStopBackgroundScan(self.scan_idx)
            self.dut.droid.wifiScannerStopTrackingBssids(idx)