コード例 #1
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LIVE_WIFI_TETHERING_BASE Init function
        LiveWifiTetheringBase.__init__(self, tc_name, global_config)

        # Get TC Parameters
        self._direction = self._tc_parameters.get_param_value("DIRECTION")
        if self._direction is None:
            self._direction = 'both'
        else:
            self._direction = self._direction.lower()

        self._iperf_options = \
            self._tc_parameters.get_param_value("IPERF_OPTIONS")

        mode = self._tc_parameters.get_param_value("IPERF_MODE")
        if mode is None:
            mode = "single"
        else:
            mode = mode.lower()

        self._iperf_settings = {"mode": mode}

        self._throughput_targets = None
        self._server_ip_address = None
コード例 #2
0
    def __init__(self, tc_name, global_config):  # pylint: disable=W0231
        """
        Constructor
        """
        # Call USECASE BASE Init function
        LiveWifiTetheringBase.__init__(self, tc_name, global_config)  # pylint: disable=W0233

        # Get host spot configuration according HOTSPOT_SSID_BASENAME
        self._hotspot_ssid_basename = \
            str(self._tc_parameters.get_param_value("HOTSPOT_SSID_BASENAME"))

        # Get host spot configuration according HOTSPOT_SECURITIES
        self._hotspot_securities = \
            str(self._tc_parameters.get_param_value("HOTSPOT_SECURITIES"))
        self._hotspot_securities = self._hotspot_securities.split("|")

        # Get UECmdLayer
        self._networking_api = self._device.get_uecmd("Networking")

        # Get PHONE2
        self._networking_api2 = None
        self._phone2 = DeviceManager().get_device("PHONE2")
        if self._phone2 is not None:
            self._networking_api2 = self._phone2.get_uecmd("Networking")

        # init original wifi power status for phone1
        self._original_wifi_power_status = 0
        # init original flight mode for phone1
        self._original_flight_mode = 0
        self._interface_ip = None

        self._hotspot_ext_interface = \
            str(self._dut_config.get("hotspotExtInterface"))

        # Read the number of pings to do
        self._nb_pings = self._tc_parameters.get_param_value("PACKET_COUNT")

        # Read the data size of a packet
        self._packet_size = self._tc_parameters.get_param_value("PACKET_SIZE")

        # Get target % of received packet for ping
        self._target_ping_packet_loss_rate = \
            float(self._tc_parameters.get_param_value("TARGET_PACKET_LOSS_RATE"))

        self._waiting_time = \
            int(self._tc_parameters.get_param_value("DELAY_AFTER_PING"))

        # Get the IP server to ping
        self._server_ip = self._tc_parameters.\
            get_param_value("SERVER_TO_PING")
        self._server_2_ping = None

        # Set BT prerequisite (set ON, set OFF or nothing) for FIT BT/WIFI tests
        self._bt_fit_used, self._bt_wished_value = LiveWifiTetheringBase._get_bt_fit_config(
            self)
        # Instantiate generic UECmd
        self._localconnectivity_api = self._device.get_uecmd(
            "LocalConnectivity")
        self._bt_initial_state = 'STATE_ON'
コード例 #3
0
    def run_test(self):
        """
        Execute the test
        """
        # Call LIVE_WIFI_TETHERING_BASE Run function
        LiveWifiTetheringBase.run_test(self)

        # 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)
コード例 #4
0
    def set_up(self):
        """
        Initialize the test
        """
        # Call LIVE_WIFI_TETHERING_BASE set_up function
        LiveWifiTetheringBase.set_up(self)

        if '-u' in self._iperf_options:
            protocole = "UDP"
        else:
            protocole = "TCP"

        # Read the throughput targets
        self._throughput_targets = ConfigsParser("Wifi_Throughput_Targets").\
            parse_wifi_targets(self._device.get_phone_model(),
                               self._hotspot_standard,
                               self._hotspot_security, protocole)

        if self._direction == 'down':
            self._server_ip_address = self._networking_api. \
                get_interface_ipv4_address(self._hotspot_ext_interface)
        else:
            if self._wifi_interface is not None:
                self._server_ip_address = self._interface_ip
            else:
                self._server_ip_address = self._networking_api2.get_wifi_ip_address()
        self._iperf_settings.update({"server_ip_address": self._server_ip_address})

        if self._direction is not None:
            self._iperf_settings.update({"direction": self._direction})
        if self._networking_api2 is not None:
            self._iperf_settings.update({"networking_api2": self._networking_api2})
        elif self._computer is not None:
            self._iperf_settings.update({"computer": self._computer})

        # Overwrite Iperf settings with iperf options read in TC parameter
        self._iperf_settings.update(parse_iperf_options(self._iperf_options))

        # Add optional interface to poll
        self._iperf_settings.update({'interface': self._dut_config.get("hotspotExtInterface")})

        return Global.SUCCESS, "No errors"
コード例 #5
0
    def tear_down(self):
        """
        End and dispose the test
        """
        LiveWifiTetheringBase.tear_down(self)

        if self._networking_api2 is not None:
            # disconnect from hotspot for Phone2
            time.sleep(self._wait_btwn_cmd)
            self._networking_api2.wifi_remove_config("all")

            # set wifi power off for phone2
            time.sleep(self._wait_btwn_cmd)
            self._networking_api2.set_wifi_power("off")

        # disable Portable wifi hotspot for Phone1
        time.sleep(self._wait_btwn_cmd)
        self._networking_api.set_wifi_hotspot("off")

        return Global.SUCCESS, "No error"
コード例 #6
0
    def set_up(self):
        """
        Initialize the test
        """
        LiveWifiTetheringBase.set_up(self)

        if str(self._server_ip) in ["None", ""] or self._flight_mode:
            # Get the IP of the softAP wifi interface
            self._server_2_ping = self._networking_api.\
                get_interface_ipv4_address(self._hotspot_ext_interface)

            if str(self._server_ip) not in ["None", ""] \
                    and self._flight_mode:
                # Display a warning because the given parameter cannot be used
                self._logger.warning("IP server set as parameter is " +
                                     "ignored, as test is run in flight " +
                                     "mode. Using SoftAP IP instead " +
                                     "(%s)" % self._server_2_ping)
        else:
            self._server_2_ping = self._server_ip

        return Global.SUCCESS, "No error"
コード例 #7
0
    def run_test(self):
        """
        Execute the test
        """
        LiveWifiTetheringBase.run_test(self)

        time.sleep(2)

        if self._computer is not None:
            # ping phone1 from remote computer's wifi interface
            packet_loss = self._computer.ping(self._server_2_ping,
                                              self._packet_size, self._nb_pings)
        else:
            # ping phone1 from phone2
            packet_loss = self._networking_api2.ping(self._server_2_ping,
                                                     self._packet_size, self._nb_pings)

        self._error.Code = Global.SUCCESS
        self._error.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(self._error.Msg)

        # Compute verdict depending on % of packet loss
        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)

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

        return self._error.Code, self._error.Msg
コード例 #8
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call LIVE_WIFI_TETHERING_BASE Init function
        LiveWifiTetheringBase.__init__(self, tc_name, global_config)

        # Read the number of pings to do
        self._nb_pings = self._tc_parameters.get_param_value("PACKET_COUNT")

        # Read the data size of a packet
        self._packet_size = self._tc_parameters.get_param_value("PACKET_SIZE")

        # Get target % of received packet for ping
        self._target_ping_packet_loss_rate = \
            float(self._tc_parameters.get_param_value("TARGET_PACKET_LOSS_RATE"))

        self._waiting_time = \
            int(self._tc_parameters.get_param_value("DELAY_AFTER_PING"))

        # Get the IP server to ping
        self._server_ip = self._tc_parameters.\
            get_param_value("SERVER_TO_PING")
        self._server_2_ping = None