def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ DeviceTestStepBase.run(self, context) is_speech_call_supported = str_to_bool( self._device.config["isSpeechCallSupported"]) is_sms_supported = str_to_bool(self._device.config["isSmsSupported"]) if is_speech_call_supported: self._voice_call_api.dial(self._pars.destination_number, False) time.sleep(15) self._voice_call_api.release() else: if is_sms_supported: sms = context.get_info(self._pars.sms) sms.send_sms() (status, msg) = sms.get_sms() self._logger.info(msg) if status == Global.FAILURE: raise DeviceException(DeviceException.SMS_EXCEPTION, msg) else: packet_loss = self._networking_api.ping( self._pars.destination_ip, 32, 1) if packet_loss.value > 0: raise AcsBaseException( AcsBaseException.OPERATION_FAILED, "Packet lost greater than zero (value=%.0f%%)" % packet_loss.value)
def __init__(self, tc_name, global_config): """ Constructor """ # Call UseCaseBase initializer UseCaseBase.__init__(self, tc_name, global_config) # Initialize required parameters self._initial_flight_mode_state = None # Read parameters and convert them to their final type self._check_bt = \ str(self._tc_parameters.get_param_value("CHECK_BT")) self._check_bt = str_to_bool(self._check_bt) self._check_nfc = \ str(self._tc_parameters.get_param_value("CHECK_NFC")) self._check_nfc = str_to_bool(self._check_nfc) self._check_wlan = \ str(self._tc_parameters.get_param_value("CHECK_WLAN")) self._check_wlan = str_to_bool(self._check_wlan) self._check_gps = \ str(self._tc_parameters.get_param_value("CHECK_GPS")) self._check_gps = str_to_bool(self._check_gps) # Arbitrary value for timeout in seconds self._radio_activation_timeout = 40 # Instantiate UE Command categories self._networking_api = self._device.get_uecmd("Networking") self._connectivity_api = self._device.get_uecmd("LocalConnectivity") self._phonesystem_api = self._device.get_uecmd("PhoneSystem") self._location_api = self._device.get_uecmd("Location")
def __check_tc_parameters(self): """ Check validity of TC parameters """ # pylint: disable=R0912 self._bt_tethering_deactivation_test = \ str_to_bool(str(self._bt_tethering_deactivation_test)) self._lola_test = str_to_bool(str(self._lola_test)) if self._nap_or_pan_test in ["PAN", "PANU", "PAN-U"]: self._nap_or_pan_test = "PAN-U" if self._nap_or_pan_test not in ["NAP", "PAN-U"]: msg = "Wrong TC parameter NAP_OR_PAN_TEST" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if self._pairing_initiator not in ["PHONE1", "PHONE2"]: msg = "Wrong TC parameter PAIRING_INITIATOR" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if self._who_disconnect in ["PAN", "PANU", "PAN-U"]: self._who_disconnect = "PAN-U" if self._who_disconnect not in ["NAP", "PAN-U"]: msg = "Wrong TC parameter WHO_DISCONNECT" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if self._who_restarts_bt in ["PAN", "PANU", "PAN-U"]: self._who_restarts_bt = "PAN-U" if self._who_restarts_bt not in ["NONE", "NAP", "PAN-U"]: msg = "Wrong TC parameter WHO_RESTARTS_BT_BEFORE_TEST" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if self._connection_to_share not in ["CELLULAR", "WIFI"]: msg = "Wrong TC parameter CONNECTION_TO_SHARE" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if self._connection_to_share == "WIFI" \ and self._wifi_access_point == "": msg = "TC parameter WIFI_ACCESS_POINT not defined" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if self._server_to_ping == "" \ and self._connection_to_share == "CELLULAR": msg = "TC parameter SERVER_TO_PING not defined" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if not self._packet_count.isdigit(): msg = "Wrong TC parameter PACKET_COUNT" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if not self._packet_size.isdigit(): msg = "Wrong TC parameter PACKET_SIZE" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if not is_number(self._target_packet_loss_rate): msg = "Wrong TC parameter TARGET_PACKET_LOSS_RATE" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) else: self._target_packet_loss_rate = \ float(self._target_packet_loss_rate)
def auto_setup(self): """ Perform an auto setup depending of the option you set in bench configuration """ # CHECK WHAT TYPE IS THE PARAM READ FRO MBENCH CONFIG ################### PARAMS LINK TO THE IMAGE QUALITY ######################### auto_focus = str_to_bool( self.__bench_params.get_param_value("SetupPerformAutoFocus", "false")) nuc = str_to_bool( self.__bench_params.get_param_value( "SetupPerformNonUniformityCorrection", "false")) pal_color = self.__bench_params.get_param_value( "SetupSetImagePalette", "") ################### PARAMS LINK TO THE TEMPERATURE MEASUREMENT ######################### objt_emmisvity = self.__bench_params.get_param_value("Emissivity", "") objt_reflected_tmp = self.__bench_params.get_param_value( "ReflectedTemperature", "") distance_target = self.__bench_params.get_param_value( "DistanceOfTheTarget", "") # atmospheric parameters atmos_temp = self.__bench_params.get_param_value( "AtmosphericTemperature", "") atmos_humidity = self.__bench_params.get_param_value( "AtmosphericHumidity", "") atmos_trans = self.__bench_params.get_param_value( "AtmosphericTransmission", "") # external optic parameters ext_opt_temp = self.__bench_params.get_param_value( "ExternalOpticTemperature", "") ext_opt_trans = self.__bench_params.get_param_value( "ExternalOpticTransmission", "") # do all the action here to let python crash if there was an error in params above self.set_image_object_params(objt_emmisvity, objt_reflected_tmp, distance_target) self.set_atmospheric_params(atmos_temp, atmos_humidity, atmos_trans) self.set_external_optic_params(ext_opt_temp, ext_opt_trans) # compare with True to be sure that the var is boolean if auto_focus == True: self.perform_auto_focus() if nuc == True: self.perform_nuc() if type(pal_color) is str and pal_color != "": self.set_palette(pal_color)
def __init__(self, tc_name, global_config): """ Constructor """ # Call UseCase base Init function UseCaseBase.__init__(self, tc_name, global_config) # Read callSetupTimeout from Phone_Catalog.xml self._call_setup_time = \ int(self._dut_config.get("callSetupTimeout")) # Get TC Parameters self._target_sim = int( self._tc_parameters.get_param_value("TARGET_SIM")) self._restore_initial = \ str_to_bool(self._tc_parameters.get_param_value("RESTORE_INITIAL")) # Get UECmdLayer self._modem_api = self._device.get_uecmd("Modem") self._phone_system = self._device.get_uecmd("PhoneSystem") self._networking_api = self._device.get_uecmd("Networking") self._initial_target_sim = None self._initial_pdp_context_status = None
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ DeviceTestStepBase.run(self, context) self._logger.info(self._pars.id + ": Run") socwatch_enabling = DeviceManager().get_device_config("PHONE1").get( "enableSocwatch", "False") if not str_to_bool(socwatch_enabling): self._logger.info("No Socwatch informations needed") context.set_info(self._pars.need_install, 0) return _, version = self._device.run_cmd( 'adb shell find /system/lib/modules /lib/modules/ -iname socwatch*.ko 2&> /dev/null | grep -o -e "[0-9]_[0-9]"', 5) if not version: self._logger.info("No Socwatch version found on the device") context.set_info(self._pars.need_install, 0) return version = version.splitlines()[0] self._logger.debug("socwatch version catched: %s" % version) context.set_info(self._pars.package, "socwatch_" + version + ".tgz") context.set_info(self._pars.need_install, 1) self._logger.info(self._pars.id + ": Done")
def set_up(self): """ Initialize the test """ UseCaseBase.set_up(self) # Check mandatory parameter if self._channel is None or int(self._channel) <= 0: msg = "CHANNEL TC parameter is not defined: " + str(self._channel) self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # Specific case for channel 14 in Japan if int(self._channel) == 14 and self._dut_crda == "JP" \ and self._standard.lower() != "b" \ and not self._connection_expected: # this case is prohibited msg = "For Channel 14 in Japan, " msg += "TC parameter CONNECTION_EXPECTED should be set to True" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # Set AP CRDA self._set_ap_generic_crda(self._channel) # Call LabWifiBase setup without connection LabWifiBase.set_up_without_connect(self) self._connection_expected = str_to_bool(str(self._connection_expected)) # Set DUT regulatory domain self._networking_api.set_regulatorydomain(self._dut_crda, self._dut_wlan_iface) time.sleep(self._wait_btwn_cmd) return Global.SUCCESS, "no_error"
def __init__(self, tc_name, global_config): """ Initializes this instance. """ # Run the inherited '__init__' method UseCaseBase.__init__(self, tc_name, global_config) # retrieve SIM card UE commands self.sim_card_api = self._device.get_uecmd("SimCard") # retrieve Networking UE commands self.networking_api = self._device.get_uecmd("Networking") # retrieve Modem UE commands self.__modem_api = self._device.get_uecmd("Modem") # retrieve testcase parameters self.__puk_code = self._tc_parameters.get_param_value("PUKCode") self.__default_pin = self._tc_parameters.get_param_value( "defaultPINCode") self.__new_pin = self._tc_parameters.get_param_value("NEW_PIN") self.__check_after_reboot = \ str_to_bool(self._tc_parameters.get_param_value("DOUBLE_CHECK_AFTER_REBOOT")) if not is_pin_valid(self.__new_pin): raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, "NEW_PIN testcase parameter is incorrect : it must " "be a number containing 4 to 8 digits.")
def parse_catalog_file(self, catalog_file): """ Parse catalog and validate regarding loaded xml schema (if any) Return it as a dictionary :type catalog_file: string :param catalog_file: Catalog file to parse :rtype: dict :return: Dictionary containing catalog elements """ parameter_dictionary = {} # Validate and parse the xml file parameter_catalog_etree = self.validate_catalog_file(catalog_file) if parameter_catalog_etree: for parameter_node in parameter_catalog_etree.getroot(): # Get the parameter name if PARAMETER_NAME_TAG in parameter_node.attrib: parameter_name = parameter_node.attrib[PARAMETER_NAME_TAG] parameter_dictionary[parameter_name] = {} for parameter_children in parameter_node: # Get all element of the parameter node if OVERRIDE_ATTRIB not in parameter_children.attrib: parameter_dictionary[parameter_name][ parameter_children. tag] = parameter_children.text else: parameter_dictionary[parameter_name][parameter_children.tag] = \ (str_to_bool(parameter_children.attrib[OVERRIDE_ATTRIB]), parameter_children.text) return parameter_dictionary
def __init__(self, tc_name, global_config): """ Constructor """ LabMobilityLte3gsmBase.__init__(self, tc_name, global_config) # Get LTE server parameters for ping self._server = \ global_config.benchConfig.get_parameters("LAB_LTE_SERVER") self._server_ip_address = self._server.get_param_value("IP") self._username = self._server.get_param_value("username") self._password = self._server.get_param_value("password") # Read GSM from testcase xml parameters self._back_and_forth = \ str_to_bool(self._tc_parameters.get_param_value("BACK_AND_FORTH", "FALSE")) # Read CRESEL_LIMIT_POWER from testcase xml parameters self._cresel_limit_power = \ float(self._tc_parameters.get_param_value("CRESEL_LIMIT_POWER")) # Read CRESEL_POWER from testcase xml parameters self._cresel_power = \ float(self._tc_parameters.get_param_value("CRESEL_POWER")) # Read DECREMENTATION_STEP_POWER from testcase xml parameters self._decrementation_step_power = \ int(self._tc_parameters.get_param_value("DECREMENTATION_STEP_POWER")) # Read DECREMENTATION_STEP_TIMER from testcase xml parameters self._decrementation_step_timer = \ int(self._tc_parameters.get_param_value("DECREMENTATION_STEP_TIMER")) # 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")) # Read SMS_TEXT from testcase xml file self._sms_text = self._tc_parameters.get_param_value( "SMS_TEXT", "aaaabbbbbcccc") # Read PHONE_NUMBER from testcase xml parameters self._phone_number = \ str(self._tc_parameters.get_param_value("PHONE_NUMBER", "0675529935")) if self._phone_number.upper() == "[PHONE_NUMBER]": self._phone_number = str(self._device.get_phone_number()) # Instantiate Messaging UECmd for SMS UseCases self._messaging_api = self._device.get_uecmd("SmsMessaging") # init wanted registration parameters to a value that self._wanted_reg_state = "None" self._ns_lte_cell_service = "None" self._ns_neighbour_power = self._ns_3gsm_cell_power self._ns_camped_power = self._ns_lte_cell_power_rf1
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ DeviceTestStepBase.run(self, context) chromeInstall = DeviceManager().get_device_config("PHONE1").get( "ChromeInstall", "False") if not str_to_bool(chromeInstall): self._logger.info("No Chrome installation asked") return timeout_60 = 60 timeout_5 = 5 self._device.run_cmd("adb root", timeout_5) self._device.run_cmd("adb disable-verity", timeout_60) self._device.reboot() self._device.run_cmd("adb root", timeout_5) self._device.run_cmd("adb remount", timeout_60) _, output = self._device.run_cmd( "adb shell pm list package | grep -i chrome", timeout_60) if output: package_name = output.splitlines()[0] self._logger.debug("chrome package name: %s" % package_name.split(':')[-1]) _, output = self._device.run_cmd( "adb shell pm dump %s |grep Path" % package_name.split(':')[-1], timeout_60) package_path = output.splitlines()[0] self._logger.debug("chrome package path: %s" % package_path.split('=')[-1]) self._device.run_cmd( 'adb shell rm -rf %s' % package_path.split('=')[-1], timeout_5) self._device.reboot() _, output = self._device.run_cmd( "adb shell pm list package | grep -i chrome", timeout_60) if output and "chrome" in output: self._logger.warning("Failed to uninstall Chrome application") else: self._logger.info( "Chrome application successfully uninstalled ") else: self._logger.info("Chrome not yet installed") InstallApp.run(self, context) # Grant runtime permissions to chrome _, output = self._device.run_cmd( "adb shell pm list package | grep -i chrome", timeout_60) if output: chrome_package_name = output.splitlines()[0].split(':')[-1] # grant runtime permissions to chrome self._device.grant_runtime_permissions(chrome_package_name)
def __check_tc_parameters(self): """ Check validity of TC parameters """ self._bt_tethering_deactivation_test = \ str_to_bool(str(self._bt_tethering_deactivation_test)) self._lola_test = str_to_bool(str(self._lola_test)) if self._nap_or_pan_test in ["PAN", "PANU", "PAN-U"]: self._nap_or_pan_test = "PAN-U" if self._nap_or_pan_test not in ["NAP", "PAN-U"]: msg = "Wrong TC parameter NAP_OR_PAN_TEST" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if self._pairing_initiator not in ["PHONE1", "PHONE2"]: msg = "Wrong TC parameter PAIRING_INITIATOR" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if self._who_disconnect in ["PAN", "PANU", "PAN-U"]: self._who_disconnect = "PAN-U" if self._who_disconnect not in ["NAP", "PAN-U"]: msg = "Wrong TC parameter WHO_DISCONNECT" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if self._who_restarts_bt in ["PAN", "PANU", "PAN-U"]: self._who_restarts_bt = "PAN-U" if self._who_restarts_bt not in ["NONE", "NAP", "PAN-U"]: msg = "Wrong TC parameter WHO_RESTARTS_BT_BEFORE_TEST" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if not self._packet_count.isdigit(): msg = "Wrong TC parameter PACKET_COUNT" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if not self._packet_size.isdigit(): msg = "Wrong TC parameter PACKET_SIZE" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if not is_number(self._target_packet_loss_rate): msg = "Wrong TC parameter TARGET_PACKET_LOSS_RATE" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) else: self._target_packet_loss_rate = \ float(self._target_packet_loss_rate)
def __init__(self, tc_name, global_config): """ Constructor """ # Call LAB_EM_BASE Init function EmUsecaseBase.__init__(self, tc_name, global_config) # Read CHARGER_TYPE from TC parameters self._charger_type = self._tc_parameters.get_param_value( "CHARGER_TYPE", "SDP") # Read idle state during the over or under voltage condition from TC parameters self._idle_state_during_test = str_to_bool( self._tc_parameters.get_param_value("IDLE_STATE")) # Read idle duration from TC parameters self._idle_duration = int( self._tc_parameters.get_param_value("IDLE_DURATION")) # Read over voltage duration from TC parameters self._test_voltage_duration = int( self._tc_parameters.get_param_value("TEST_VOLTAGE_DURATION")) # Read Vusb value from ConfigFile parameters self._vusb = float(self._tc_parameters.get_param_value("VUSB_NORMAL")) self._vusb_test_voltage = float( self._tc_parameters.get_param_value("VUSB_TEST")) self._em_targets = self._target_file.parse_energy_management_targets( "LAB_EM_USB_TEST_VOLTAGE", self._tc_parameters.get_params_as_dict(), self._device.get_phone_model()) # load targets in order to measure iteration self._em_meas_verdict.load_target(self._em_targets, self.tcd_to_test) # Set initial value for setting Power Supply VBATT: # - VoltageLevel = VBATT self.em_core_module.eqp_init_state["BATT"][ "VoltageLevel"] = self.em_core_module.vbatt # - VoltageLevel = VUSB if self._vusb_test_voltage > self._vusb: self.em_core_module.get_eq_emulated_charger( ).set_voltage_protection_level(self._vusb_test_voltage + 4) else: self.em_core_module.get_eq_emulated_charger( ).set_voltage_protection_level(self._vusb + 4) self.em_core_module.eqp_init_state["USB"][ "VoltageLevel"] = self.em_core_module.vusb # - Delay to wait for scheduled commands if self._idle_state_during_test: self._scheduled_timer_1 = self._test_voltage_duration + self._idle_duration else: self._scheduled_timer_1 = self._test_voltage_duration self._scheduled_timer_2 = self._scheduled_timer_1 + self._test_voltage_duration
def __init__(self, tc_name, global_config): """ Constructor """ # Call LAB_EM_BASE Init function EmUsecaseBase.__init__(self, tc_name, global_config) # Initialize variables self._after_shutdown_time = 0 self._before_shutdown_time = 0 # Read battery type from TC parameters self._battery_type = self._tc_parameters.get_param_value("BATTERY_TYPE", self.phone_info["BATTERY"]["BATTID_TYPE"]) # Read shutdown type from TC parameters self._shutdown_type = self._tc_parameters.get_param_value("SHUTDOWN_TYPE") # Read UNPLUG_CHARGER_WHILE_SHUTDOWN from TC parameters self._unplug_charger_while_shutdown = str_to_bool( self._tc_parameters.get_param_value("UNPLUG_CHARGER_WHILE_SHUTDOWN")) # Read PRESS_PWR_BUTTON_TIME from TC parameters self._press_pwr_button_time = float(self._tc_parameters.get_param_value("PRESS_PWR_BUTTON_TIME")) # Read CHARGER_TYPE from TC parameters self._charger_type = \ str(self._tc_parameters.get_param_value("CHARGER_TYPE")) # Call ConfigsParser to parse Energy_Management self._em_targets = self._target_file.parse_energy_management_targets( "LAB_EM_GRACEFUL_SHUTDOWN", self._tc_parameters.get_params_as_dict(), self._device.get_phone_model()) # load targets in order to measure iteration self._em_meas_verdict.load_target(self._em_targets) # Redefine initial value for setting USBDIO: # - BatteryType = ANALOG self.em_core_module.io_card_init_state["BatteryType"] = self._battery_type # - Battery = True (inserted) self.em_core_module.io_card_init_state["Battery"] = True # - Platform = True (ON) self.em_core_module.io_card_init_state["Platform"] = "ON" # - USBChargerType = USB_HOST_PC self.em_core_module.io_card_init_state["USBChargerType"] = self._io_card.SDP # - USBCharger = False (removed) self.em_core_module.io_card_init_state["USBCharger"] = True # - BatteryTemperature = BATTERY_TEMPERATURE self.em_core_module.io_card_init_state["BatteryTemperature"] = 25 # Set initial value for setting Power Supply VBATT: # - VoltageLevel = VBATT self.em_core_module.eqp_init_state["BATT"]["VoltageLevel"] = self.em_core_module.vbatt
def __init__(self, tc_name, global_config): """ Constructor """ # Call LAB_EM_BASE Init function EmUsecaseBase.__init__(self, tc_name, global_config) self._scu_charging_hi_voltage = float( self._tc_parameters.get_param_value("SCU_CHARGING_HI_VOLTAGE")) self._cos_charging_hi_voltage = float( self._tc_parameters.get_param_value("COS_CHARGING_HI_VOLTAGE")) self._mos_charging_lo_voltage = float( self._tc_parameters.get_param_value("MOS_CHARGING_LO_VOLTAGE")) self._ext_ps = str_to_bool( str(self._tc_parameters.get_param_value("EXT_PS"))) # Read VBATT from TC parameters self._charger = self._tc_parameters.get_param_value("CHARGER_TYPE") # Call ConfigsParser to parse Energy_Management self._em_targets = self._target_file.parse_energy_management_targets( "LAB_EM_COS_CHARGING", self._tc_parameters.get_params_as_dict(), self._device.get_phone_model()) # load targets in order to measure iteration self._em_meas_verdict.load_target(self._em_targets) # Redefine initial value for setting USBDIO: # - BatteryType = ANALOG self.em_core_module.io_card_init_state[ "BatteryType"] = self.phone_info["BATTERY"]["BATTID_TYPE"] # - Battery = False (removed) self.em_core_module.io_card_init_state["Battery"] = True # - Platform = False (OFF) self.em_core_module.io_card_init_state["Platform"] = "OFF" # - USBChargerType = DCP self.em_core_module.io_card_init_state[ "USBChargerType"] = self._charger # - USBCharger = True (inserted) self.em_core_module.io_card_init_state["USBCharger"] = False # - BatteryTemperature = 25 self.em_core_module.io_card_init_state["BatteryTemperature"] = 25 # Set initial value for setting Power Supply VBATT: # - VoltageLevel = VBATT self.em_core_module.eqp_init_state["BATT"][ "VoltageLevel"] = self._scu_charging_hi_voltage # VBATT and VUSB power supplies self.em_core_module.pwrs_vbatt = self._em.get_power_supply("BATT") if self.em_core_module.ps_properties["USB"] is not None: self.em_core_module.pwrs_vusb = self._em.get_power_supply("USB")
def __init__(self, tc_name, global_config): """ Constructor """ # Call LAB_LTE_BASE Init function LabLteBase.__init__(self, tc_name, global_config) # Read mode from test case xml file self._switch_mode = self._tc_parameters.get_param_value("SWITCH_MODE") # Read the IP version from test case xml file self._ip_version = self._tc_parameters.get_param_value( "IP_VERSION", "IPV4") # Read the IP version from test case xml file self._retry_different_ip_version = str_to_bool( self._tc_parameters.get_param_value("RETRY_ALTERNATIVE_VERSION", "False")) if self._retry_different_ip_version: if self._ip_version == "IPV4": self._alternate_ip_version = "IPV6" self._logger.info("The alternative IP version is V6 ") elif self._ip_version == "IPV6": self._alternate_ip_version = "IPV4" self._logger.info("the alternative IP version is V4") else: self._logger.error( "Alternate only if IP version is V4 or V6 and not in DUAL MODE" ) # 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")) # Read the network registration timeout self._network_reg_timeout = self._tc_parameters.get_param_value( "NETWORK_REG_TIMEOUT", 0, int) if self._network_reg_timeout == 0: self._network_reg_timeout = self._registration_timeout # Instantiate Phone On/OFF utilities self.phoneonoff_util = PhoneOnOff(self._networking_api, self._device, self._logger) # Instantiate the IP version self._nw_ip_version = ""
def __init__(self, tc_name, global_config): LabNfcBase.__init__(self, tc_name, global_config) # starting height self.__starting_Z = self._tc_parameters.get_param_value("STARTING_Z") if self.__starting_Z is None: self.__starting_Z = 0 else: self.__starting_Z = int(self.__starting_Z) # ending height self.__max_Z = self._tc_parameters.get_param_value("MAX_Z") if self.__max_Z is None: self.__max_Z = 0 else: self.__max_Z = int(self.__max_Z) # test max Z or not self.__is_max_z = str_to_bool( self._tc_parameters.get_param_value("FOUND_MAX_Z")) # position of the testing square self.__right_up_corner_position = str( self._tc_parameters.get_param_value("RIGHT_UP_CORNER")).split("x") self.__starting_X = int(self.__right_up_corner_position[0]) self.__starting_Y = int(self.__right_up_corner_position[1]) # get the resolution self.__resolution = int( self._tc_parameters.get_param_value("RESOLUTION")) # output file self.__result_file_name = self._tc_parameters.get_param_value( "RESULT_FILE_NAME") self.__result_file_handler = open( os.path.join(self._saving_directory, self.__result_file_name), 'w') # get the antenna position nfc_antenna_position = self._device.get_config("NfcAntennaPosition", "").split(',') if len(nfc_antenna_position) == 2 and is_number( nfc_antenna_position[0]) and is_number( nfc_antenna_position[1]): self._x_antenna = int(nfc_antenna_position[0]) self._y_antenna = int(nfc_antenna_position[1]) else: self._x_antenna = 0 self._y_antenna = 0
def set_up(self): """ Set up the test configuration """ # Call use case base Setup function LabWcdmaVcBase.set_up(self) # Update the attribute indicated whether phone number # is an emergency number in ril.ecclist self._is_emergency_number = \ str_to_bool(self._is_emergency_number_param) # Check the phone number, ensuring that it is not # a number corresponding to a "real" emergency number # on the LIVE network # Retrieve the list of emergency numbers from the DUT as str emergency_numbers_string = self._device.get_property_value( LabWcdmaFlightmodeEmVc.EMERGENCY_NUMBER_PROPERTY_NAME) # Split the str to a list emergency_numbers = emergency_numbers_string.split(",") # Make sure the provided Phone Number parameter is not present # in the list of emergency numbers if self._phone_number in emergency_numbers: # Otherwise create an error message message = "Provided parameter PHONE_NUMBER [%s] as a value \ that corresponds to a real emergency number on the LIVE \ network [list: (%s)]. The test will not be executed." % ( self._phone_number, emergency_numbers_string) # Raise an exception raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, message) # Store the list of emergency numbers from RIL so that we can # restore it later self._initial_emergency_numbers = emergency_numbers_string # Update the list of RIL Emergency Numbers in UE Command categories # Make the 'addition' of 2 tuples by using a single-element tuples # using the (<element>,) notation. # This needs only to be done if the provided phone number shall # be considered to be an Emergency number. if self._is_emergency_number: UECmdTypes.EMERGENCY_NUMBERS_LIST = \ self._initial_ue_command_em_number + (self._phone_number,) return Global.SUCCESS, "No errors"
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ DeviceTestStepBase.run(self, context) self._logger.info("Getting the current battery capacity...") device_plug = self._device_manager.get_device_config(self._pars.device).get("OnBattery", "False") self._logger.info("device plugged on battery: %s" % device_plug) if device_plug is not None and not str_to_bool(device_plug): self._logger.warning("Device plugged on Power Supply and in Low battery mode, can't wait charging") return current_level = self.get_current_battery_level() if current_level < self._low_threshold: self._logger.info("Low battery level detected... ({}%)".format(current_level)) if 'status' in self._battery_infos and int(self._battery_infos['status']) == 2: self._logger.info("Battery is charging...") while current_level < self._required_level: if 'status' in self._battery_infos and int(self._battery_infos['status']) == 2: self._logger.info("Waiting for required ({0}%) battery level... ({1}% reached)" .format(self._required_level, current_level)) time.sleep(60) current_level = self.get_current_battery_level() else: raise DeviceException(DeviceException.INVALID_DEVICE_STATE, "Battery isn't charging or battery service unreachable.") cmd_user = "******" status, output = self._device.run_cmd(cmd_user, self._device.get_uecmd_timeout(), force_execution=True, wait_for_response=True, silent_mode=True) # if the device started with battlow, we have reboot to flush this state: if "battlow" in output: self._device.reboot() else: raise DeviceException(DeviceException.INVALID_DEVICE_STATE, "Battery isn't charging or battery service unreachable.") self._logger.debug(self.ts_verdict_msg)
def set_up(self): """ Initialize this test. """ # Call inherited method UseCaseBase.set_up(self) # Read registrationTimeout from Device_Catalog.xml self._registration_timeout = \ int(self._dut_config.get("registrationTimeout")) # Read network type parameter expected_nw_type = self._tc_parameters.get_param_value( "EXPECTED_NETWORK_TYPE") if expected_nw_type not in ("", None): self._expected_nw_type = expected_nw_type else: raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, "Invalid parameter value for 'EXPECTED_NETWORK_TYPE': <%s>." % str(expected_nw_type)) # Read preferred network type parameter preferred_nw_type = self._tc_parameters.get_param_value( "PREFERRED_NETWORK_TYPE") if preferred_nw_type not in ("", None): self._preferred_nw_type = preferred_nw_type else: raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, "Invalid parameter value for 'PREFERRED_NETWORK_TYPE': <%s>." % str(preferred_nw_type)) # Read the fail on error parameter fail_on_error = self._tc_parameters.get_param_value("FAIL_ON_ERROR") if fail_on_error not in ("", None): self._fail_on_error = str_to_bool(fail_on_error) # Backup the initial preferred network type value self._logger.debug("Backup initial value of preferred network type ...") self._initial_preferred_nw_type_int = self._dut_config.get("defaultPreferredNetwork") # Force the DUT to use a Network self._configure_preferred_network_type(self._preferred_nw_type) # Tell ACS that everythin was OK return Global.SUCCESS, "No errors."
def __init__(self, tc_name, global_config): """ Constructor """ # Call UseCase base Init function LiveCellularBase.__init__(self, tc_name, global_config) # Initialize attributes self._check_serving_cell_failed = False self._found_one_non_empty_neighbor = False # Remember whether we have to check the serving cell or not check_serving_cell = self._tc_parameters.get_param_value( "CHECK_SERVING_CELL") self._check_serving_cell = str_to_bool(check_serving_cell) # Remember whether we have to check the neighboring cells or not check_neighboring_cells = self._tc_parameters.get_param_value( "CHECK_NEIGHBORING_CELLS") self._check_neighboring_cells = str_to_bool(check_neighboring_cells) # Instantiate Networking UE Command category self._networking_api = self._device.get_uecmd("Networking")
def __init__(self, tc_name, global_config): """ Constructor """ LabMobilityLte3gsmBase.__init__(self, tc_name, global_config) # Get LTE server parameters for ping self._server = \ global_config.benchConfig.get_parameters("LAB_LTE_SERVER") self._server_ip_address = self._server.get_param_value("IP") self._username = self._server.get_param_value("username") self._password = self._server.get_param_value("password") # Read GSM from testcase xml parameters self._back_and_forth = \ str_to_bool(self._tc_parameters.get_param_value("BACK_AND_FORTH", "FALSE")) # Read CRESEL_LIMIT_POWER from testcase xml parameters self._cresel_limit_power = \ float(self._tc_parameters.get_param_value("CRESEL_LIMIT_POWER")) # Read CRESEL_POWER from testcase xml parameters self._cresel_power = \ float(self._tc_parameters.get_param_value("CRESEL_POWER")) # Read DECREMENTATION_STEP_POWER from testcase xml parameters self._decrementation_step_power = \ int(self._tc_parameters.get_param_value("DECREMENTATION_STEP_POWER")) # Read DECREMENTATION_STEP_TIMER from testcase xml parameters self._decrementation_step_timer = \ int(self._tc_parameters.get_param_value("DECREMENTATION_STEP_TIMER")) # 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")) # init wanted registration parameters to a value that self._wanted_reg_state = "None" self._ns_lte_cell_service = "None" self._ns_neighbour_power = self._ns_lte_cell_power_rf1 self._ns_camped_power = self._ns_3gsm_cell_power
def __init__(self, tc_name, global_config): """ Constructor """ # Call LAB_TDSCDMA_BASE Init function LabTdscdmaBase.__init__(self, tc_name, global_config) # Read mode from test case xml file (str) self._switch_mode = self._tc_parameters.get_param_value( "SWITCH_MODE", "softshutdown") # Read PDP Activation from test case xml file self._pdp_activation = str_to_bool( self._tc_parameters.get_param_value("PDP_ACTIVATION", "false")) # Instantiate Phone On/OFF utilities self.phoneonoff_util = PhoneOnOff(self._networking_api, self._device, self._logger)
def __init__(self, tc_name, global_config): """ Constructor """ UseCaseBase.__init__(self, tc_name, global_config) # Get MAC Address to use during the test self._expected_mac_address = str(self._tc_parameters.get_param_value("DUT_MAC_ADDRESS")) # Genuine MAC address self._start_mac_address = None self._is_random_mac = False self._isConnectionNeeded = str_to_bool(self._tc_parameters.get_param_value("WIFI_CNX_NEEDED")) if self._isConnectionNeeded: default_ap = "CONFIGURABLE_AP1" self._current_ap = str(self._tc_parameters.get_param_value( "CONFIGURABLE_AP_TO_USE", default_value=default_ap)) if self._current_ap == "": self._current_ap = default_ap self._logger.info('Using access point "%s"' % self._current_ap) self._configurable_ap = global_config.benchConfig.\ get_parameters(self._current_ap) self._ssid = self._configurable_ap.get_param_value("SSID") if self._configurable_ap.\ get_param_value("Model") == "AP_CONTROLLER" \ and self._configurable_ap.\ get_param_value("APC_IP", "") != "": self._wifirouter_ip = self._configurable_ap.\ get_param_value("APC_IP") else: self._wifirouter_ip = \ self._configurable_ap.get_param_value("IP") # Get WIFI Router configuration according WIFI SECURITY self._security = self._tc_parameters.get_param_value("WIFI_SECURITY") # initial wifi equipment self._ns = self._em.get_configurable_ap(self._current_ap) self._dut_wlan_iface = str(self._dut_config.get("wlanInterface")) self._phonesystem_api = None self._networking_api = None self._bt_api = None
def get_sim_lock_state(self): """ Retrieve the current SIM lock system state, as displayed in "Settings -> Security -> Set up SIM card lock" menu. :rtype: bool :return: C{True} if the SIM lock system is enabled, C{False} otherwise """ method = "isSimLockSystemEnabled" output = self._internal_exec_v2(self.__module_name, method, is_system=True) # retrieve state from output if output is None or "enabled" not in output: raise DeviceException(DeviceException.OPERATION_FAILED, "Unable to retrieve SIM lock system state") return str_to_bool(output["enabled"])
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ DeviceTestStepBase.run(self, context) self._logger.info(self._pars.id + ": Run") # Delete all previous csv files saved into socwatch folder self._device.run_cmd('adb shell rm %s/*.csv' % self._pars.install_path, timeout=5) socwatch_enabling = DeviceManager().get_device_config("PHONE1").get( "enableSocwatch", "False") if not str_to_bool(socwatch_enabling): self._logger.info("No Socwatch informations needed") return self._device.run_cmd('adb shell chmod 0755 %s/socwatch_run.sh' % self._pars.install_path, timeout=5) socperf_driver = self._device.get_socperf_driver() #Extract socwatch driver _, socwatch_driver = self._device.run_cmd( 'adb shell find /lib/modules/ -name socwatch*.ko | grep -o -e "socwatch[0-9]_[0-9].ko"', 5) socwatch_driver = socwatch_driver.splitlines()[0] self._logger.debug("socwatch driver catched: %s" % socwatch_driver) args = "{0} {1} {2} {3} {4} {5}".format( socperf_driver, socwatch_driver, self._pars.feature, self._pars.duration, self._pars.delay, self._pars.result_filename) self._device.run_cmd('adb shell cd %s; nohup sh socwatch_run.sh %s' % (self._pars.install_path, args), timeout=1, force_execution=True, wait_for_response=False) self._logger.info(self._pars.id + ": Done")
def init_param_2g_burst(self): """ describe advanced parameter to configure a 2G burst using slots """ active_slot = [] separator = "" slots_conf = { "DL_STATE": "", "DL_VALUE": "", "UL_STATE": "", "UL_VALUE": "" } # get used slot that is at true from Testcase parameter for slot_nbr in range(8): name = ("USE_SLOT_%s" % slot_nbr) use_slot = self.__tc_params.get_param_value(name) if use_slot is not None: if str_to_bool(use_slot): active_slot.append(slot_nbr) # configure slots for value in range(8): if value in active_slot: name = "SLOT_%s_PCL" % str(value) slots_conf["DL_STATE"] += ("%sON" % separator) slots_conf["UL_STATE"] += ("%sON" % separator) # Read SLOT_x_PCL from test case xml file # make the uc crash if tc parameter is not numeric pcl_configuration = int(self.__tc_params.get_param_value(name)) slots_conf["DL_VALUE"] += ("%s0" % separator) slots_conf["UL_VALUE"] += "%s%s" % (separator, str(pcl_configuration)) separator = "," else: slots_conf["DL_STATE"] += ("%sOFF" % separator) slots_conf["UL_STATE"] += ("%sOFF" % separator) slots_conf["DL_VALUE"] += ("%s0" % separator) slots_conf["UL_VALUE"] += ("%s0" % separator) separator = "," self.__slots_conf = slots_conf
def __init__(self, tc_name, global_config): """ Constructor """ # Call UseCase base Init function UseCaseBase.__init__(self, tc_name, global_config) # Get TC Parameters self._launcher_name = self._tc_parameters.get_param_value( "LAUNCHER_NAME") self._open_chooser = str_to_bool( self._tc_parameters.get_param_value("OPEN_CHOOSER", "False")) # Get UECmdLayer self._system_api = self._device.get_uecmd("System") self._initial_package_state = None
def get_value(self, key, default_value=None, default_cast_type=str): """ Return the value of the given device config name The type of the value can be checked before assignment A default value can be given in case the config name does not exist :type key: string :param key: name of the property value to retrieve :type default_value: object :param default_value: default_value of the property :type default_cast_type: type object :param default_cast_type: type to cast (int, str, list ...) By default cast into str type. :rtype: string or type of default_cast_type :return: config value """ value = self.get(key, default_value) # In case the config value is not None, trying to cast the value if value is not None: # Cast the value to the given type # Stripping is done to suppress end and start spaces of values try: if default_cast_type == "str_to_bool": value = str_to_bool(str(value).strip()) elif default_cast_type == "str_to_dict": value = str_to_dict(str(value)) else: value = default_cast_type(value) except ValueError: LOGGER_FWK.debug( "Cannot convert {0} to {1}, return {2}".format( key, default_cast_type, default_value)) value = default_value # Store new value # TODO: do not store the value for now because of side effects, need to see if it's expected behavior # self[key] = value return value
def __init__(self, tc_name, global_config): """ Constructor """ # Call UseCaseBase init function UseCaseBase.__init__(self, tc_name, global_config) # Get FLIGHT_MODE_ENABLED from parameters self._is_flight_mode_enabled = str_to_bool(self._tc_parameters.get_param_value("FLIGHT_MODE_ENABLED")) # Get UECmdLayer self._networking_api = self._device.get_uecmd("Networking") self._initial_flight_mode_state = None self._expected_flight_mode_state = None self._expected_flight_mode_state_str = "" self._current_flight_mode_state = None self._current_flight_mode_state_str = ""