Esempio n. 1
0
 def run_test(self):
     """
     Execute the test
     """
     LabWifiBase.run_test(self)
     self._trigger_dfs()
     return Global.SUCCESS, "No errors"
Esempio n. 2
0
    def run_test(self):
        """
        Run test
        """

        LabWifiBase.run_test(self)
        LabWifiKPIBase.run_test(self)

        self._networking_api.set_wifi_power("off")
        time.sleep(self._wait_btwn_cmd)
        # Start log monitoring
        self._networking_api.start_wifi_connection_log()
        self._networking_api.set_wifi_power("on")

        # Get the log and trigger it !
        time_to_reconnect = self.__check_logs_and_compute_time()

        if time_to_reconnect > self._time_target:
            msg = "Reconnection time too long : %ss. Expected : %ss" % (
                time_to_reconnect, self._time_target)
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        return_msg = "No errors - Time to connect : %ss - Target : %ss" % (
            time_to_reconnect, self._time_target)
        return Global.SUCCESS, return_msg
Esempio n. 3
0
    def run_test(self):
        """
        Execute the test
        """
        LabWifiBase.run_test(self)

        # Start log monitoring
        self._networking_api.start_wifi_connection_log()

        # Try to connect to the WiFi network
        self._networking_api.wifi_connect(self._ssid, self._connection_expected)

        # Control the connection status
        connection_status = self._networking_api.\
            get_wifi_connection_status_log(self._ssid)
        self._logger.info("Connection log read: %s" % connection_status)

        if self._connection_expected and connection_status != "SUCCESS":
            msg = "Unable to connect to channel %s while DUT CRDA is %s" \
                % (str(self._channel), self._dut_crda)
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        if not self._connection_expected and connection_status == "SUCCESS":
            # disconnect
            self._networking_api.wifi_disconnect(self._ssid)

            # Raise an Error
            msg = "Successfully connected to channel %s while DUT CRDA is %s" \
                % (str(self._channel), self._dut_crda)
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        # Specific case for channel 14 in Japan
        if int(self._channel) == 14 and self._dut_crda == "JP" \
                and self._standard.lower() != "b":
            # Check connection rate corresponds to B standard (11 MByte/s)
            connection_rate = self._networking_api.\
                get_wifi_connection_rate(self._dut_wlan_iface)
            self._logger.info("Connection rate: %d MB/s" % connection_rate)

            if connection_rate != self.__CONNECTION_RATE_FOR_B_STANDARD:
                msg = "Channel 14 in Japan connection rate test failed."
                msg += " connection_rate read: " + str(connection_rate)
                self._logger.error(msg)
                # Disconnect WiFi
                self._networking_api.wifi_disconnect(self._ssid)
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        # Disconnect WiFi
        if self._connection_expected:
            self._networking_api.wifi_disconnect(self._ssid)

        return Global.SUCCESS, "no_error"
    def run_test(self):
        """
        Execute the test
        """
        LabWifiBase.run_test(self)

        # Open the browser and load the url before timeout
        self._test_web_browsing(self._website_url, self._browser_type,
                                self._webpage_loading_timeout)

        return Global.SUCCESS, "No error"
Esempio n. 5
0
    def run_test(self):
        """
        Execute the test
        """
        # Call LAB_WIFI_BASE Run function
        LabWifiBase.run_test(self)
        time.sleep(self._wait_btwn_cmd)

        # Run Iperf command
        throughput = self._networking_api.iperf(self._iperf_settings)

        # Compute verdict depending on throughputs
        return compute_iperf_verdict(throughput, self._throughput_targets,
                                     self._direction)
    def run_test(self):
        """
        Execute the test
        """
        LabWifiBase.run_test(self)

        # Wifi disconnection
        self._networking_api.wifi_remove_config(self._ssid)
        self._logger.info("Waiting %s seconds" % str(self._time2wait))
        time.sleep(self._time2wait)

        # Start log monitoring
        self._networking_api.start_wifi_connection_log()

        # Try to connect with the wrong passphrase
        self._networking_api.set_wificonfiguration(
            self._ssid, self._wrong_passphrase, self._security,
            self._ip_setting, self._ip_address, self._netmask, self._gateway,
            self._dns1, self._dns2)
        self._networking_api.wifi_connect(self._ssid, False)

        # Control the connection status
        connection_status = self._networking_api.\
            get_wifi_connection_status_log(self._ssid)
        self._logger.info("Connection log read: %s" % connection_status)

        if connection_status != "FAILURE":
            msg = "Unable to retrieve connection failure information from log"
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        # Wifi disconnection
        self._networking_api.wifi_remove_config(self._ssid)
        self._logger.info("Waiting %s seconds" % str(self._time2wait))
        time.sleep(self._time2wait)

        # Now try to connect with the real passphrase
        # Start log monitoring
        self._networking_api.start_wifi_connection_log()
        self._networking_api.set_wificonfiguration(
            self._ssid, self._passphrase, self._security, self._ip_setting,
            self._ip_address, self._netmask, self._gateway, self._dns1,
            self._dns2)
        self._networking_api.wifi_connect(self._ssid, True)
        # Control the connection status
        connection_status = self._networking_api.\
            get_wifi_connection_status_log(self._ssid)
        self._logger.info("Connection log read: %s" % connection_status)

        return Global.SUCCESS, "no_error"
Esempio n. 7
0
    def run_test(self):
        """
        Execute the test
        """
        LabWifiBase.run_test(self)

        # Wait for the Wifi to sleep
        self._logger.info("Waiting %s sec for Wifi to sleep"
                          % self._time_before_wifi_sleep)
        time.sleep(self._time_before_wifi_sleep)
        self._logger.info("Wifi should have gone to sleep")

        # Checks that Wifi is well entered into sleep mode
        try:
            packet_loss = self._networking_api.ping(self._wifirouter_ip,
                                                    self._packetsize,
                                                    self._count)
        except AcsBaseException as e:
            if "Network is unreachable" in e.get_error_message():
                # Then the Exception has been raised
                # because of a ping connection failure
                packet_loss = Measure()
                packet_loss.value = 100
                packet_loss.units = "%"
            else:
                raise e

        if packet_loss.value < self._lossrate_disconnected:
            msg = "Wifi did not manage to enter sleep mode: %s packet loss" \
                % str(packet_loss.value)
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        # Wake up the screen
        self._phone_system_api.display_on()
        time.sleep(6 * self._wait_btwn_cmd)
        self._phone_system_api.display_off()

        # Check WIFI connection by pinging Wifi AP
        packet_loss = self._networking_api.ping(self._wifirouter_ip,
                                                self._packetsize, self._count)
        if packet_loss.value > self._lossrate_connection_ok:
            msg = "Wifi did not manage to wakes up: %s packet loss" \
                % str(packet_loss.value)
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        return Global.SUCCESS, "No errors"
Esempio n. 8
0
    def run_test(self):
        """
        Execute the test
        """
        LabWifiBase.run_test(self)

        # Reconnect only if needed (B2B continuous mode = True)
        if self._is_wifi_already_connected is not True:
            self._networking_api.set_wificonfiguration(
                self._ssid, self._passphrase, self._security, self._ip_setting,
                self._ip_address, self._netmask, self._gateway, self._dns1,
                self._dns2)
            self._networking_api.wifi_connect(self._ssid)

        # Check connection to the SSID
        self._networking_api.check_connection_state(self._ssid)

        # Check Wifi connection is available
        packetloss = self._networking_api.ping(self._wifirouter_ip,
                                               self._packetsize, self._packnb)

        if packetloss.value > self._lossrate:
            msg = "Fail to recover Wifi connection after enabling WiFi interface " + \
                "(ping NOK: %s%% packet loss)" % str(packetloss.value)
            self._logger.error(msg)
            raise DeviceException(DeviceException.PROHIBITIVE_MEASURE, msg)

        # Forget AP SSID
        self._networking_api.wifi_remove_config(self._ssid)
        self._is_wifi_already_connected = False
        time.sleep(self.WAITING_TIME)

        # Check if SSID is remembered
        connected_wifi_list = self._networking_api.list_connected_wifi()
        if self._ssid in connected_wifi_list:
            msg = "WiFi is connected to %s network and it shouldn't!" % self._ssid
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        # Confirm connection is still possible
        self._networking_api.set_wificonfiguration(
            self._ssid, self._passphrase, self._security, self._ip_setting,
            self._ip_address, self._netmask, self._gateway, self._dns1,
            self._dns2)
        self._networking_api.wifi_connect(self._ssid, True)
        self._is_wifi_already_connected = True

        return Global.SUCCESS, "No errors"
    def run_test(self):
        """
        Execute the test
        """
        LabWifiBase.run_test(self)

        # Enable Wifi
        self._networking_api.set_wifi_power("on")
        time.sleep(self._registration_waiting_time)

        # Ping Wifi server
        self.__ping_server(self._wifirouter_ip, "Wifi network")

        # Disable Wifi
        self._networking_api.set_wifi_power("off")
        time.sleep(self._registration_waiting_time)

        # Ping Live server
        self.__ping_server(self._live_server, "Cellular network")

        return Global.SUCCESS, "No errors"
Esempio n. 10
0
    def run_test(self):
        """
        Execute the test
        """
        LabWifiBase.run_test(self)

        # Ensure the AP configuration is correct and connect the DUT to the AP
        if not self.__1st_iteration:
            if self._bandwidth == "40":
                # Restore the Bandwidth to 40 MHz
                self._set_ap_bandwidth('40', False)
            if self._wifi_mimo:
                # Restore MIMO activation on AP
                self._set_ap_mimo(True, False)
        else:
            self.__1st_iteration = False

        # Connect the DUT to AP with connection check if specific feature(s) is(are) enabled (40MHz, MIMO)
        self._wifi_connect_dut()

        # Run the FTP tranfer with the parameters extracted from the XML TC file
        ftp_result = self._launch_ftp_transfer()

        # Retrieve the FTP throughput
        throughput = re.findall(self._FTP_THROUGHTPUT_PARSING_PATTERN,
                                ftp_result[1])
        if len(throughput) > 0:
            throughput = int(throughput[0])
        else:
            throughput = -1

        # If enhanced features (like 40MHz and/or MIMO) are activated,
        # we need to compare throughput without these features
        self._check_enhanced_features(throughput)

        # Disconnect DUT from AP
        self._networking_api.wifi_disconnect(self._ssid)

        return ftp_result
Esempio n. 11
0
    def run_test(self):
        """
        Execute the test
        """
        LabWifiBase.run_test(self)

        # Disable SSID
        self._ns.init()
        try:
            self._ns.disable_wireless()
        finally:
            self._ns.release()

        # Check Wifi is lost
        try:
            packetloss = self._networking_api.ping(self._wifirouter_ip,
                                                   self._packetsize,
                                                   self._packnb,
                                                   source_address=self.__dut_ip_adr)
        except AcsBaseException as e:
            if "Network is unreachable" in e.get_error_message():
                # Then the Exception has been raised
                # because of a ping connection failure
                packetloss = Measure()
                packetloss.value = 100
                packetloss.units = "%"
            else:
                self._logger.error("Ping command fails: " + e.get_error_message())
                raise e
        if packetloss.value < self._lossrate_disconnected:
            msg = "Wifi connection still established (ping OK)"
            self._logger.error(msg)
            raise DeviceException(DeviceException.PROHIBITIVE_MEASURE, msg)

        # Enable SSID
        self._ns.init()
        try:
            self._ns.enable_wireless()
        finally:
            self._ns.release()
        init_timer = time.time()
        ping_continue = True
        while ping_continue:
            self._logger.debug("Wait " + str(self._wifi_reconnection_time) + "s to reconnect before ping")
            time.sleep(self._wifi_reconnection_time)

            # Check Wifi connection is back
            try:
                packetloss = self._networking_api.ping(self._wifirouter_ip,
                                                   self._packetsize, self._packnb)
            except AcsBaseException as e:
                if "Network is unreachable" in e.get_error_message():
                    packetloss = Measure()
                    packetloss.value = 100
                    packetloss.units = "%"
                else:
                    self._logger.error("Ping command fails: " + e.get_error_message())
                    raise e
            if packetloss.value > self._lossrate:
                msg = "Fail to recover Wifi connection after loss of coverage " \
                      + "(ping NOK: %s%% packet loss)" % str(packetloss.value)
                self._logger.warning(msg)
                if (time.time() - init_timer) > 180:
                    self._logger.error("Reconnection time > 3min")
                    raise DeviceException(DeviceException.PROHIBITIVE_MEASURE, msg)
            else:
                ping_continue = False

        return Global.SUCCESS, "No errors"
Esempio n. 12
0
    def run_test(self):
        """
        Execute the test
        """
        LabWifiBase.run_test(self)

        # Put display on and off to avoid scan failure.
        self._phone_system_api.display_on()
        time.sleep(self._wait_btwn_cmd)
        self._phone_system_api.display_off()

        self._logger.info("Ping direction : " + self._direction)

        for ip_to_ping in self._all_ip_to_ping:
            if self._direction == "UL":
                # ping from DUT to Server
                self._logger.info("Ping address " + str(ip_to_ping) +
                                  " with " + str(self._count) +
                                  " packets of " + str(self._packetsize) +
                                  " bytes...")

                packet_loss = self._networking_api.ping(
                    ip_to_ping,
                    self._packetsize,
                    self._count,
                    source_address=self._dut_ip)

            elif self._direction == "DL":
                # ping from Server to DUT
                self._logger.info("Ping address " + str(ip_to_ping) +
                                  " with " + str(self._count) +
                                  " packets of " + str(self._packetsize) +
                                  " bytes...")

                packet_loss = self._computer.ping(ip_to_ping, self._packetsize,
                                                  self._count)

            else:
                msg = "%s is not a valid xfer direction" % self._direction
                self._logger.error(msg)
                raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                         msg)

            msg = "Measured Packet Loss: %.0f%s (Target: %.0f%s)" \
                % (packet_loss.value, packet_loss.units,
                   self._target_ping_packet_loss_rate, packet_loss.units)
            self._logger.info(msg)

            # Compute verdict depending on % of packet loss
            if not self._key_exchange_should_fail:
                if packet_loss.value > self._target_ping_packet_loss_rate:
                    msg = "Ping packet loss is not acceptable [%s]" \
                        % str(packet_loss.value)
                    self._logger.error(msg)
                    raise DeviceException(DeviceException.OPERATION_FAILED,
                                          msg)
            else:
                if ip_to_ping != '0.0.0.0':
                    if packet_loss.value < 100:
                        msg = "Ping packet loss is too low [%s]" \
                            % str(packet_loss.value)
                        self._logger.error(msg)
                        raise DeviceException(DeviceException.OPERATION_FAILED,
                                              msg)

            if self._waiting_time > 0:
                self._logger.info("Waiting for %s sec" %
                                  str(self._waiting_time))
                time.sleep(self._waiting_time)

        return Global.SUCCESS, "No errors"
    def run_test(self):
        """
        Execute the test
        """
        LabWifiBase.run_test(self)

        # push a script that will run the test in adb disconnected mode
        self._networking_api.usb_tether(self._wifi_off, self._unplug_usb,
                                        self._use_flight_mode)

        # Disconnect ADB
        self._device.disconnect_board()
        self._disconnected = True

        time.sleep(10)

        start_time = time.time()

        # Tethering should have now started on DUT, wait for USB interface to come up
        # pylint: disable=W0612
        ip, self._hotspot_ip = self._computer.dhclient(
            self._computer.get_usb_interface())

        # USB is now tethered

        # remove temporarily existing route for the same network
        self._destination, self._netmask, self._iface = \
            self._computer.change_route(self._network, self._hotspot_ip)
        self._changedroute = True

        # Ping the Access Point behind the tethered USB hotspot
        packet_loss = self._computer.ping(self._wifirouter_ip,
                                          self._packetsize, self._count)
        self._logger.info("Packet loss: %s%s" %
                          (packet_loss.value, packet_loss.units))
        if packet_loss.value > self._target_ping_packet_loss_rate:
            msg = "Could not ping AP through interface usb0"
            self._logger.error(msg)
            time.sleep(90)  # need to wait for the DUT script to end
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        # wait for up to 60 seconds after starting DUT script
        sleep_time = 60 - (time.time() - start_time)
        if sleep_time > 0:
            time.sleep(sleep_time)

        if self._unplug_usb:
            self._io_card.usb_host_pc_connector(False)
            self._unplugged = True
            time.sleep(10)
            start_time = time.time()

            # try to ping again, this should fail
            packet_loss = self._computer.ping(self._wifirouter_ip,
                                              self._packetsize, self._count)
            self._logger.info("Packet loss: %s%s" %
                              (packet_loss.value, packet_loss.units))
            if packet_loss.value != 100:
                msg = "Ping AP through interface usb0 successful after USB unplugged"
                self._logger.error(msg)
                time.sleep(60)  # need to wait for the DUT script to end
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)

            # plug USB
            self._io_card.usb_host_pc_connector(True)
            self._unplugged = False
            # wait x seconds
            time.sleep(self._device.get_usb_sleep_duration())

            # wait for DUT to complete script...
            sleep_time = 30 - (time.time() - start_time)
            if sleep_time > 0:
                time.sleep(sleep_time)

            # wait for USB interface to come up, this should fail !
            try:
                self._computer.dhclient(self._computer.get_usb_interface())
                msg = "Interface usb0 incorrectly still tethered"
                self._logger.error(msg)
                time.sleep(30)  # need to wait for the DUT script to end
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)
            except TestEquipmentException as e:
                if not "Could not get IP address" in str(e):
                    raise

        elif not self._use_flight_mode or self._wifi_off:

            # wait for DUT to activate flight_mode/turn off wifi...
            start_time = time.time()

            # try to ping again, this should fail
            packet_loss = self._computer.ping(self._wifirouter_ip,
                                              self._packetsize, self._count)
            self._logger.info("Packet loss: %s%s" %
                              (packet_loss.value, packet_loss.units))
            if packet_loss.value != 100:
                msg = "Ping AP through interface usb0 successful"
                if self._wifi_off:
                    msg += " after turning wifi off"
                else:
                    msg += " after enabling flight mode"
                self._logger.error(msg)
                time.sleep(60)  # need to wait for the DUT script to end
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)

            # wait for DUT to deactivate flight_mode/turn on wifi...
            sleep_time = 30 - (time.time() - start_time)
            if sleep_time > 0:
                time.sleep(sleep_time)

            # Ping the Access Point
            packet_loss = self._computer.ping(self._wifirouter_ip,
                                              self._packetsize, self._count)
            self._logger.info("Packet loss: %s%s" %
                              (packet_loss.value, packet_loss.units))
            if packet_loss.value > self._target_ping_packet_loss_rate:
                msg = "Could not ping AP through interface usb0"
                self._logger.error(msg)
                time.sleep(30)  # need to wait for the DUT script to end
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        # wait 30 seconds more for DUT to deactivate tethering
        time.sleep(30)

        self._device.connect_board()
        self._disconnected = False

        if self._changedroute:
            # restore original route
            self._computer.restore_route(self._network, self._hotspot_ip,
                                         self._destination, self._netmask,
                                         self._iface)
            self._changedroute = False

        return Global.SUCCESS, "No error"
Esempio n. 14
0
    def run_test(self):
        """
        Execute the test
        """
        LabWifiBase.run_test(self)

        self._networking_api.check_connection_state(self._ssid)

        if self._direction == "DL":
            msg = "FTP transfer " + str(self._direction) + " for " + str(
                self._dlfilename) + "..."
            filename = self._dlfilename

        elif self._direction == "UL":
            msg = "FTP transfer " + str(self._direction) + " for " + str(
                self._ulfilename) + "..."
            filename = self._ulfilename
        else:
            msg = "%s is not a known xfer direction" % self._direction
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        self._logger.info(msg)

        task_id = self._networking_api.start_ftp_xfer(
            self._direction, self._ftp_ip_address, self._ftp_username,
            self._ftp_password, filename, self._device.get_ftpdir_path())

        start = time.time()

        # trigger DFS on AP while FTP Transfer is being done.
        self._trigger_dfs()
        # check that DUT was able to connect after DFS trigger
        self._networking_api.check_connection_state(self._ssid)
        # Check FTP transfer is still ongoing
        ftp_status = self._networking_api.get_ftp_xfer_status()

        if ftp_status != self._networking_api.FTP_TRANSFERRING:
            if self._networking_api.is_ftp_xfer_success(
                    filename, self._direction, task_id):
                msg = "File has already been transferred. Please use a bigger file for this test!"
                # End the transfer
                self._networking_api.stop_ftp_xfer(task_id)
                self._logger.error(msg)
                raise AcsConfigException(AcsConfigException.OPERATION_FAILED,
                                         msg)
            else:
                msg = "FTP transfer STOPS while switching channel, ftp status=%s. " % str(
                    ftp_status)
                # End the transfer
                self._networking_api.stop_ftp_xfer(task_id)
                self._logger.error(msg)
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        # Wait for the FTP transfer to end.
        while start + self._xfer_timeout > time.time(
        ) and ftp_status == self._networking_api.FTP_TRANSFERRING:
            time.sleep(5)
            ftp_status = self._networking_api.get_ftp_xfer_status()

        # Does Timeout occur?
        if ftp_status == self._networking_api.FTP_TRANSFERRING:
            # End the transfer
            self._networking_api.stop_ftp_xfer(task_id)

            msg = "FTP Transfer timeout. Please use a smaller file or increase the timeout value"
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        # Control that the FTP transfer was success
        if not self._networking_api.is_ftp_xfer_success(
                self._dlfilename, self._direction, task_id):
            # End the transfer
            self._networking_api.stop_ftp_xfer(task_id)

            msg = "FTP transfer FAILS"
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        return Global.SUCCESS, "No errors"
    def run_test(self):
        """
        Execute the test
        """
        LabWifiBase.run_test(self)

        # Reconnect only if needed (B2B continuous mode = True)
        if self._is_wifi_already_connected is not True:
            self._networking_api.set_wificonfiguration(self._ssid,
                                                       self._passphrase,
                                                       self._security,
                                                       self._ip_setting,
                                                       self._ip_address,
                                                       self._netmask,
                                                       self._gateway,
                                                       self._dns1,
                                                       self._dns2)
            self._networking_api.wifi_connect(self._ssid)

        # Check Wifi connection is available
        packetloss = self._networking_api.ping(self._wifirouter_ip,
                                               self._packetsize,
                                               self._packnb)

        if packetloss.value > self._lossrate:
            msg = "Fail to recover Wifi connection after enabling wifi interface " + \
                "(ping NOK: %s%% packet loss)" % str(packetloss.value)
            self._logger.error(msg)
            raise DeviceException(DeviceException.PROHIBITIVE_MEASURE, msg)

        # Disable Wifi interface
        self.__set_wifi_off()
        time.sleep(self._wifi_switchoff_time)

        # Enable Wifi interface
        self.__set_wifi_on()
        time.sleep(self._wifi_switchon_time)

        # Check connection to the SSID
        self._networking_api.check_connection_state(self._ssid)

        # Check Wifi connection is back
        packetloss = self._networking_api.ping(self._wifirouter_ip,
                                               self._packetsize,
                                               self._packnb)

        if packetloss.value > self._lossrate:
            msg = "Fail to recover Wifi connection after enabling wifi interface " \
                  + "(ping NOK: %s%% packet loss)" % str(packetloss.value)
            self._logger.error(msg)
            raise DeviceException(DeviceException.PROHIBITIVE_MEASURE, msg)

        # Forget AP SSID
        self._networking_api.wifi_remove_config(self._ssid)

        if self._hidden:
            # SSID not broadcasted. Check that the SSID disappears from the list.
            self._logger.info("Waiting %d seconds for SSID to disappear from scan list"
                              % self._waiting_check_time)
            time.sleep(self._waiting_check_time)

            # Check AP is well forgotten and no connection is made on it
            all_network_list = self._networking_api.list_ssids()

            if self._ssid in all_network_list:
                msg = "SSID %s is unexpectedly present in the list" % str(self._ssid)
                self._logger.error(msg)
                raise DeviceException(DeviceException.PROHIBITIVE_MEASURE, msg)
        else:
            # SSID broadcasted. Check that the Connection is not established.
            connected_network_list = self._networking_api.list_connected_wifi()

            if self._ssid in connected_network_list:
                msg = "DUT is unexpectedly connected to %s " % str(self._ssid)
                self._logger.error(msg)
                raise DeviceException(DeviceException.PROHIBITIVE_MEASURE, msg)

        self._is_wifi_already_connected = False

        return Global.SUCCESS, "No errors"
Esempio n. 16
0
    def run_test(self):
        """
        Execute the test
        """
        # pylint: disable=E1101
        LabWifiBase.run_test(self)
        # monitor wifi connection time if requested
        mean = -1
        if self._monitor_connection_time and self.get_b2b_iteration(
        ) == self._current_iteration_num:
            # This is the last iteration of back to back test
            # compute standard deviation, mean and verdict
            mean = float(numpy.mean(self._connection_time_list))
            std_deviation = float(numpy.std(self._connection_time_list))
            compute_verdict(self._expected_connection_time, self._tolerance,
                            mean, std_deviation, self._logger)

        # Switch OFF the AP if the TC associated parameter is enabled
        if self._restart_ap_radio:
            # Forget the SSID
            self._networking_api.wifi_remove_config(self._ssid)

            # Disable radio
            self._ns.init()
            self._ns.disable_wireless()

            # Restart the DUT wifi interface
            self._networking_api.set_wifi_power("off")
            time.sleep(self._wait_btwn_cmd)
            self._networking_api.set_wifi_power("on")
            time.sleep(self._wait_btwn_cmd)

            # Register to the "out of range" network
            if str(self._wrong_passphrase).lower() == 'none':
                self._networking_api.set_wificonfiguration(
                    self._ssid, self._passphrase, self._security,
                    self._ip_setting, self._ip_address, self._netmask,
                    self._gateway, self._dns1, self._dns2)
            else:
                self._networking_api.set_wificonfiguration(
                    self._ssid, self._wrong_passphrase, self._security,
                    self._ip_setting, self._ip_address, self._netmask,
                    self._gateway, self._dns1, self._dns2)
            self._networking_api.set_autoconnect_mode(self._ssid,
                                                      AUTO_CONNECT_STATE.on)

        # Restart the Wifi interface if required
        if self._restart_dut == "INTERFACE":
            # Power cycle the Wifi interface
            self._networking_api.set_wifi_power("off")
            time.sleep(self._wait_btwn_cmd)
            self._networking_api.set_wifi_power("on")
            time.sleep(self._wait_btwn_cmd)
        elif self._restart_dut == "PHONE":
            # Power cycle the phone
            self._device.reboot()

        # Switch ON the AP if the TC associated parameter is enabled
        if self._restart_ap_radio:
            # enable_wireless includes a time sleep
            self._ns.enable_wireless()
            self._ns.release()

        if self._restart_dut == "INTERFACE" \
                or self._restart_dut == "PHONE" \
                or self._restart_ap_radio \
                or self._mac_filter != "OFF" \
                or str(self._wrong_passphrase).lower() != 'none':
            if str(self._wrong_passphrase).lower() == 'none' and \
                    not self._key_exchange_should_fail:
                # Wait for the connection to establish
                self._networking_api.check_connection_state(self._ssid)
            else:
                # Wait for the connection to try to establish
                self._logger.debug(
                    "Waiting for the connection list to be updated")
                self._phone_system_api.display_on()
                time.sleep(30)
                self._phone_system_api.display_off()

        # MAC address filter management
        if self._mac_filter != "OFF":
            if self._mac_filter_parameter != "OFF":
                self._networking_api.wifi_disconnect(self._ssid)
            self._add_mac_filter_to_ap()
            # Try to reconnect DUT
            self._networking_api.wifi_connect(self._ssid, False)
            try:
                self._networking_api.check_connection_state(self._ssid, 20)
            except AcsBaseException as e:
                if not self._dut_in_mac_filter or \
                        e.get_generic_error_message() != DeviceException.TIMEOUT_REACHED:
                    raise

        # List connected SSIDs to check if the right ssid is connected
        connected_wifi_list = self._networking_api.list_connected_wifi()

        if str(self._wrong_passphrase).lower() == 'none' and \
                not self._key_exchange_should_fail and \
                not self._dut_in_mac_filter:
            if self._ssid in connected_wifi_list:
                result = "Wifi connected to network %s with correct password." % str(
                    self._ssid)
                if mean > 0:
                    result += " Mean connection time is %2.2f sec" % mean

                if self._ip_setting_enable:
                    if (self._ip_address ==
                            self._networking_api.get_wifi_ip_address()):
                        result += "Static ip successfully set."
                    else:
                        msg = "obtained ip address is different from the " + \
                            "static ip address"
                        self._logger.error(msg)
                        raise DeviceException(DeviceException.OPERATION_FAILED,
                                              msg)
            else:
                msg = "Wifi did not connect to network " \
                    + "[%s] with correct password. " % str(self._ssid)
                self._logger.error(msg)
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        else:
            if self._ssid not in connected_wifi_list:
                result = "Wifi not connected to network " \
                    + "%s" % str(self._ssid)
                if str(self._wrong_passphrase).lower() != 'none' or \
                        self._key_exchange_should_fail:
                    result += ", with wrong password"
                if self._dut_in_mac_filter:
                    result += ", MAC add filtered"
            else:
                msg = "Wifi connected to network " \
                    + "[%s]" % str(self._ssid)
                if str(self._wrong_passphrase).lower() != 'none' or \
                        self._key_exchange_should_fail:
                    msg += ", with wrong password"
                if self._dut_in_mac_filter:
                    msg += ", MAC add filtered"
                self._logger.error(msg)
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        if self._mac_filter != "OFF":
            if self._mac_filter_parameter != "OFF":
                self._networking_api.wifi_disconnect(self._ssid)
            # Remove MAC filter
            self._remove_mac_filter_on_ap()
            # Connect DUT
            self._networking_api.wifi_connect(self._ssid)

        return Global.SUCCESS, result
Esempio n. 17
0
    def run_test(self):
        """
        Execute the test
        """
        LabWifiBase.run_test(self)

        if self._wifi_off > 0:
            # WiFi interface OFF setup
            self.__compute_test_duration("WIFI_OFF")
            self._networking_api.\
                measure_wifi_turns_off_duration("async_init",
                                                self._wifi_interface,
                                                duration=self._tduration)

        # Unplug the USB cable if necessary
        if self._usb_pluggedin.lower() == "false":
            # We have to disable S3 in order to keep DUT active when unplugged
            self._sleep_mode_api.init("s0i3")

            self._device.disconnect_board()
            self._usb_connected_status = False
            self._io_card.usb_host_pc_connector(False)

        if self._scan > 0:
            # WiFi scan test
            self.__run_scan_test(False)

        elif self._scan == -1:
            # PERIODIC scan (every 40s for the first 5min then is every 5min)
            self.__run_periodic_scan_test()

        elif self._wifi_off > 0:
            # Wifi OFF test
            self._logger.info("Sleep %d sec" % self._tduration)
            time.sleep(self._tduration)

        elif self._scan == 0 and self._wifi_off == 0 and self._tduration > 0:
            # No scan test
            self.__run_scan_test(True)

        else:
            msg = "Unhandled test scenario"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.PROHIBITIVE_BEHAVIOR,
                                     msg)

        # Plug the USB cable back if necessary
        if self._usb_pluggedin.lower() == "false":
            self._io_card.usb_host_pc_connector(True)
            self._device.connect_board()
            self._usb_connected_status = True

            # Enable S3
            self._sleep_mode_api.clear()

        if self._wifi_off > 0:
            # WiFi interface OFF teardown
            self._networking_api.\
                measure_wifi_turns_off_duration("async_result",
                                                self._wifi_interface,
                                                expected_duration=self._wifi_off * 60,
                                                tolerance=self._tolerance)

        return Global.SUCCESS, "No errors"
    def run_test(self):
        """
        Execute the test
        """
        LabWifiBase.run_test(self)

        # Change AP security type
        # Initiate connection to the equipment
        self._ns.init()
        try:
            # Configure the equipment
            self._ns.set_wifi_config(self._ssid,
                                     self._hidden,
                                     self._standard,
                                     self._security_2,
                                     self._passphrase_2,
                                     self._channel,
                                     self._dtim,
                                     self._beacon,
                                     self._wmm,
                                     self._bandwidth,
                                     self._wifi_mimo,
                                     self._radiusip,
                                     self._radiusport,
                                     self._radiussecret)
        finally:
            # Close the connection to AP
            self._ns.release()

        self._logger.debug("Wait %ss for automatic disconnection" % self.WAIT_FOR_DISCONNECTION)
        time.sleep(self.WAIT_FOR_DISCONNECTION)

        # Ping to validate DUT is not connected
        packet_loss = self._networking_api.ping(self._wifi_server_ip_address, self.PING_PACKET_SIZE, self.PING_PACKET_COUNT,
                                                blocking=False)
        if packet_loss.value < 100 and packet_loss.value != -1:
            msg = "Ping packet loss is not acceptable [%s] - DUT should be disconnected" % str(packet_loss.value)
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        # Connect with good credentials
        self._networking_api.clean_all_data_connections()
        time.sleep(self._wait_btwn_cmd)
        self._networking_api.set_wificonfiguration(self._ssid,
                                                   self._passphrase_2,
                                                   self._security_2,
                                                   self._ip_setting,
                                                   self._ip_address,
                                                   self._netmask,
                                                   self._gateway,
                                                   self._dns1,
                                                   self._dns2)

        time.sleep(self._wait_btwn_cmd)
        self._networking_api.wifi_connect(self._ssid)

        # Ping to validate DUT is connected
        time.sleep(self._wait_btwn_cmd)
        packet_loss = self._networking_api.ping(self._wifi_server_ip_address, self.PING_PACKET_SIZE, self.PING_PACKET_COUNT)
        if packet_loss.value > 0:
            msg = "Ping packet loss is not acceptable [%s] - DUT should be connected" % str(packet_loss.value)
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        return Global.SUCCESS, "no_error"