def set_up(self): """ Initialize the test """ # Configure and connect wifi to the AP LabWifiBase.set_up(self) # Get local computer to run dhclient self._computer = self._em.get_computer("COMPUTER1") # Check that USBInterface parameter is filled in BenchConfig # This is required to request for an DHCP client renew if not self._computer.get_usb_interface(): msg = "USBInterface parameter is not filled in COMPUTER1" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, msg) # Initialize USB Tethering to disable self._networking_api.stop_usb_tethering(unplug=True) # Disconnect from Bench network self._computer.disconnect_from_bench_network() # Test that we cannot establish a connection to the bench network self._test_server_unreachable(self._wifi_server_ip_address) return Global.SUCCESS, "No error"
def set_up(self): """ Initialize the test """ LabWifiBase.set_up(self) # disconnect wifi as LAB_WIFI_BASE connects it self._networking_api.wifi_disconnect_all() time.sleep(self._wait_btwn_cmd) # Initiate connection to the equipment self._ns.init() # turn off dhcp and clean params in any case self._ns.set_dhcp("off") # then check if it has to be turned on if self._dhcp_enabled in ("True", "TRUE"): self._ns.set_dhcp("on", self._low_excluded_addr, self._high_excluded_addr, self._dhcp_subnet, self._dhcp_subnet_mask, self._dhcp_lease, self._dhcp_gateway_address) # Close the connection to AP self._ns.release() # Connect the DUT on the Wifi network self._networking_api.wifi_connect(self._ssid, True) return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ LabWifiBase.set_up(self) # Control testcase parameter if str(self._time2wait).isdigit(): self._time2wait = int(self._time2wait) else: msg = "TIME_BETWEEN_TESTS is missing or wrong: %s" \ % str(self._time2wait) self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # Control that the security is not OPEN if str(self._security).upper() in ["NONE", "OPEN"]: msg = "WIFI_SECURITY UseCase parameter should not be " + \ "undefined nor OPEN: %s" % str(self._security) self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # Generate a corrupted passphrase if self._security == "EAP-WPA" or self._security == "EAP-WPA2": self._wrong_passphrase = self._eap_method + "-" \ + self._phase2_auth + "_" + self._corrupt(self._eap_user) \ + "_" + self._corrupt(self._eap_password) + "_" \ + self._corrupt(self._certificat_name) + "_" \ + str(self._mandatory_cert) else: self._wrong_passphrase = self._corrupt(self._passphrase) return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ LabWifiBase.set_up(self) self._set_up() return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ # pylint: disable=E1101 LabWifiBase.set_up(self) # Enable Wifi autoconnect on our SSID self._networking_api.\ set_autoconnect_mode(self._ssid, self._uecmd_types.AUTO_CONNECT_STATE.on) # Wait 3 sec minimun after connect if self._wait_btwn_cmd <= 3: time.sleep(3) else: time.sleep(self._wait_btwn_cmd) # Checks connection using Ping packetloss = self._networking_api.ping(self._wifirouter_ip, self._packetsize, self._packnb) if packetloss.value > self._lossrate: msg = "Ping command fails (%s%% loss)" % str(packetloss.value) self._logger.error(msg) raise DeviceException(DeviceException.PROHIBITIVE_MEASURE, msg) self._is_wifi_already_connected = True return Global.SUCCESS, "No errors"
def set_up(self): """ Setup the test """ LabWifiBase.set_up(self) # Check if the two security are different, otherwise the test is useless if self._security == self._security_2: msg = "The two securities given are identical : %s ! They must be different " % str(self._security_2) self._logger.error(msg) raise AcsConfigException(AcsConfigException.OPERATION_FAILED, msg) return Global.SUCCESS, "no_error"
def set_up(self): """ Initialize the test """ LabWifiBase.set_up(self) LabWifiKPIBase.set_up(self) # Control REF_CONNECTION_TIME value if self._time_target < 0: msg = "Wrong parameter for REF_CONNECTION_TIME: read value %f" % self._time_target self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ LabWifiBase.set_up(self) # disconnect wifi as LAB_WIFI_BASE connects it self._networking_api.wifi_disconnect_all() time.sleep(self._wait_btwn_cmd) # Initiate connection to the equipment self._ns.init() # turn off dhcp and clean params in any case self._ns.set_dhcp("off") # then check if it has to be turned on if self._dhcp_enabled in ("True", "TRUE"): self._ns.set_dhcp("on", self._low_excluded_addr, self._high_excluded_addr, self._dhcp_subnet, self._dhcp_subnet_mask, self._lease, self._dhcp_gateway_address) # Close the connection to AP self._ns.release() self._sleep_mode_api.init(self._sleep_mode) # Connect the DUT on the Wifi network self._networking_api.wifi_connect(self._ssid, True, True) time.sleep(5) self._dut_ip = "0.0.0.0" bad_ip_timeout = 15 while (self._dut_ip == "0.0.0.0") and (bad_ip_timeout > 0): self._dut_ip = self._networking_api.get_wifi_ip_address() time.sleep(1) bad_ip_timeout -= 1 if self._dut_ip == "0.0.0.0": msg = "Can't obtain a valid IP address (%s)" % self._dut_ip self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) # set Wifi Sleep Policy to "never" self._networking_api.set_wifi_sleep_policy(self._networking_api.WIFI_SLEEP_POLICY["NEVER"]) self._logger.info("Setting wifi policy to never") return Global.SUCCESS, "no errors"
def set_up(self): """ Initialize the test """ # pylint: disable=E1101 LabWifiBase.set_up(self) # Checks connection using Ping packetloss = self._networking_api.ping(self._wifirouter_ip, self._packetsize, self._packnb) if packetloss.value > self._lossrate: msg = "Ping command fails (%s%% loss)" % str(packetloss.value) self._logger.error(msg) raise DeviceException(DeviceException.PROHIBITIVE_MEASURE, msg) self._is_wifi_already_connected = True return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ # pylint: disable=E1101 LabWifiBase.set_up(self) # Retrieve DUT ip address self.__dut_ip_adr = self._networking_api.get_wifi_ip_address(self._use_ipv6) # Checks connection using Ping packetloss = self._networking_api.ping(self._wifirouter_ip, self._packetsize, self._packnb, source_address=self.__dut_ip_adr) if packetloss.value > self._lossrate: msg = "Ping command fails (%s%% loss)" % str(packetloss.value) self._logger.error(msg) raise DeviceException(DeviceException.PROHIBITIVE_MEASURE, msg) return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ LabWifiBase.set_up(self) self._dut_ip = self._networking_api.get_wifi_ip_address(self._use_ipv6) if self._direction == "DL": self._all_ip_to_ping = [self._dut_ip] if not self._use_ipv6: # With IPv6,we already have it from LAB_WIFI_BASE self._computer = self._em.get_computer("COMPUTER1") else: if self._use_ipv6: self._all_ip_to_ping = self._computer.get_ipv6_addresses() else: remote_ip = self._wifirouter_ip self._all_ip_to_ping = [remote_ip] return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ LabWifiBase.set_up(self) # Recall current screen timeout self._current_screen_timeout = self._phone_system_api.get_screen_timeout( ) # Set the screen timeout to be sure that the screen will on # *15 because the minimum timeout is 1: 1*15 = 15s which is the minimum screen timeout time.sleep(self._wait_btwn_cmd) if self._webpage_loading_timeout > 0: self._phone_system_api.set_screen_timeout( self._webpage_loading_timeout * 15) # Wakes up the phone time.sleep(self._wait_btwn_cmd) self._phone_system_api.wake_screen() return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ LabWifiBase.set_up(self) # Get the time to wait for wifi to disconnect all network self._time_before_wifi_sleep = self._device.get_time_before_wifi_sleep() # Set WIFI sleep policy to "when screen turns off" self._previous_wifi_sleep_policy = self._networking_api.\ get_wifi_sleep_policy() if self._previous_wifi_sleep_policy != \ self._networking_api.WIFI_SLEEP_POLICY["WHEN_SCREEN_OFF"]: self._networking_api.\ set_wifi_sleep_policy(self._networking_api. WIFI_SLEEP_POLICY["WHEN_SCREEN_OFF"]) # Set screen timeout to a short value self._previous_screen_timeout = self._phone_system_api.get_screen_timeout() if self._previous_screen_timeout != self._screen_timeout: self._phone_system_api.set_screen_timeout(self._screen_timeout) # Remove the potential screen lock ON 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 IP connection is bad: %s packet loss" \ % str(packet_loss.value) self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) # Set the Wifi power saving mode to ON self._networking_api.set_wifi_power_saving_mode("on") return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ LabWifiBase.set_up(self) # Check if cellular live server is valid if self._live_server in [None, "", "NONE"]: msg = "live cellular server is missing" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # Disable Wifi self._networking_api.set_wifi_power("off") # Enable Cellular Data transfer self._networking_api.activate_pdp_context() time.sleep(self._wait_btwn_cmd) # Check cellular connection self.__ping_server(self._live_server, "Cellular network") return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ # store original flight mode self._original_flight_mode = self._networking_api.get_flight_mode() time.sleep(self._wait_btwn_cmd) if self._original_flight_mode != self._use_flight_mode: self._networking_api.set_flight_mode(self._use_flight_mode) time.sleep(self._wait_btwn_cmd) # Configure and connect wifi to the AP LabWifiBase.set_up(self) # Get local computer to run dhclient self._computer = self._em.get_computer("COMPUTER1") # Get access point subnet to add its route to tethered interface self._network = re.sub(r'([0-9]+\.[0-9]+\.[0-9]+).*', r'\1.0', self._wifirouter_ip) return Global.SUCCESS, "No error"
def set_up(self): """ Initialize the test """ LabWifiBase.set_up(self) # Check input testcase parameters self.__check_input_tcparameter() # Retrieve the expected wifi behavior depending on the input params self._scan, self._wifi_off, self._tduration, desc = \ ConfigsParser("Wifi_Sleep_Policies").\ parse_wifi_sleep_policies(self._device.get_phone_model(), self._connected, self._display_state, self._keep_wifi_on, self._usb_pluggedin, self._ssid_list_empty) if self._scan == 0 \ and self._wifi_off == 0 \ and self._tduration == 0: msg = "No Wifi sleep policy found in Wifi_Sleep_Policies.XML" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if desc: self._logger.info("TestCase to run: %s" % desc) self._logger.debug("Scan period (s): %d" % self._scan) self._logger.debug("Time to WiFi turn off (min): %d" % self._wifi_off) self._logger.debug("Recommended test duration (s): %d" % self._tduration) # Initialize the Sniffer equipment self._sp_sniffer = self._em.get_sniffer("WIFI_SNIFFER1") # Apply WIFI_CONNECTED initial condition if self._connected.lower() == "false": self._networking_api.wifi_remove_config('all') # Apply REMEMBERED_SSID_LIST_EMPTY initial condition if self._ssid_list_empty.lower() == "false": # Create non existing WiFi network in the known network list self._networking_api.set_wificonfiguration( self.FAKE_SSID, None, "OPEN") # Non consistent case elif self._ssid_list_empty.lower() == "true": self._logger.warning( "TC is requested with WiFi CONNECTED," + " whereas REMEMBERED_SSID_LIST has to be EMPTY. " + "Test will be run CONNECTED " + "and REMEMBERED_SSID_LIST_EMPTY is ignored.") # Apply KEEP_WIFI_ON_DURING_SLEEP initial condition if self._keep_wifi_on.lower() == "always": policy = self._networking_api.WIFI_SLEEP_POLICY["NEVER"] elif self._keep_wifi_on.lower() == "only_when_plugged_in": policy = \ self._networking_api.WIFI_SLEEP_POLICY["NEVER_WHILE_PLUGGED"] else: # "never" policy = self._networking_api.WIFI_SLEEP_POLICY["WHEN_SCREEN_OFF"] self._networking_api.set_wifi_sleep_policy(policy) # Retrieve WiFi MAC Address self._wifi_mac = self._networking_api.get_interface_mac_addr("wifi") # Unlock the WiFi power saving mode self._networking_api.set_wifi_power_saving_mode(1) # Apply display initial condition if self._display_state == "OFF": self._original_screen_timeout = \ self._phone_system_api.get_screen_timeout() # Set display off timeout to its minimal value self._phone_system_api.set_screen_timeout(self.SCREEN_TIMEOUT) time.sleep(self.SCREEN_TIMEOUT) # Go back to idle screen and turn screen off self._phone_system_api.display_on() self._phone_system_api.set_phone_lock(0) self._networking_api.wifi_menu_settings(False) self._phone_system_api.set_phone_lock(1) self._phone_system_api.display_off() else: # case if self._display_state == "ON_OUT_WIFI_MENU" is_in = False if self._display_state == "ON_IN_WIFI_MENU": is_in = True # Prevent screen back-light to turn off self._phone_system_api.display_on() time.sleep(self._wait_btwn_cmd) # Unlock the device self._phone_system_api.set_phone_lock(0) time.sleep(self._wait_btwn_cmd) # Open or exit WiFi settings menu self._networking_api.wifi_menu_settings(is_in) return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ # Call LAB_WIFI_BASE set_up function LabWifiBase.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._standard, self._security, protocole, self._bandwidth) # Overwrite target values with those read in TC parameter if self._target_ul is not None and self._target_ul != "": self._throughput_targets.ul_target.set(float(self._target_ul), ThroughputMeasure.KBPS_UNIT) if self._failure_ul is not None and self._failure_ul != "": self._throughput_targets.ul_failure.set( float(self._failure_ul), ThroughputMeasure.KBPS_UNIT) if self._target_dl is not None and self._target_dl != "": self._throughput_targets.dl_target.set(float(self._target_dl), ThroughputMeasure.KBPS_UNIT) if self._failure_dl is not None and self._failure_dl != "": self._throughput_targets.dl_failure.set( float(self._failure_dl), ThroughputMeasure.KBPS_UNIT) if self._direction not in ("both", "up", "down"): msg = "%s is not a valid DIRECTION." self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) self._iperf_settings.update({"direction": self._direction}) if self._computer is not None: self._iperf_settings.update({"computer": self._computer}) dut_ip_address = str(self._networking_api.get_wifi_ip_address()) if self._direction == 'down': # Downlink: connect from host to DUT, get DUT IP address. self._iperf_settings.update({"server_ip_address": dut_ip_address}) elif self._computer is not None: # Uplink/both: connect from DUT to host, get computer IP address. # if computer is None or localhost, use WIFI_SERVER from Bench_Config ip = self._computer.get_host_on_test_network() if ip not in ("localhost", "127.0.0.1"): self._iperf_settings.update({"server_ip_address": ip}) # On windows DUT platform, we must set the outbound address # (because ethernet and wlan connections are connected at the same time # and to the same network) self._iperf_settings.update({"bind_host": dut_ip_address}) if self._tune_options == 1: # Set Iperf settings depending on the expected throughput self._iperf_settings.update( get_iperf_configuration(self._throughput_targets)) # Overwrite Iperf settings with iperf options read in TC parameter self._iperf_settings.update(parse_iperf_options(self._iperf_options)) return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ LabWifiBase.set_up(self) # Control RESTART_DUT TC parameter if self._restart_dut not in ["OFF", "PHONE", "INTERFACE"]: msg = "Wrong value for RESTART_DUT: %s" % self._restart_dut self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # MAC address filter management if self._mac_filter != "OFF": # Retrieve DUT MAC address dut_mac = self._networking_api.get_interface_mac_addr() if self._mac_filter == "DUT": self._mac_filter = dut_mac elif self._mac_filter == "!DUT": # Create a MAC address different from DUT one last_char = dut_mac[-1:] new_char = last_char while new_char == last_char: new_char = ramdom_choice(hexdigits) self._mac_filter = dut_mac[:-1] + new_char if self._mac_filter == dut_mac: self._dut_in_mac_filter = True if self._mac_filter_parameter not in [ "OFF", "DISCONNECTED", "DISCONNECTED_WAIT_DISABLE" ]: msg = "Wrong value for MAC_FILTER_PARAMETER: %s" % self._mac_filter_parameter self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if str(self._expected_connection_time).upper() in [ "NONE", "", "0", "NO" ]: self._monitor_connection_time = False elif str(self._expected_connection_time).isdigit() and int( self._expected_connection_time) > 0: self._monitor_connection_time = True self._expected_connection_time = int( self._expected_connection_time) else: msg = "Wrong parameter for REF_CONNECTION_TIME: read value %s" % str( self._expected_connection_time) self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # Update back to back iteration and the wifi connection time list if self._monitor_connection_time: msg = "DUT connected in %d seconds" % self._connection_time self._logger.info(msg) self._current_iteration_num += 1 if self._connection_time != -1: self._connection_time_list.append(self._connection_time) else: self._logger.warning("unable to measure connection time") return Global.SUCCESS, "no_error"