def set_ssp_mode(self, mode="on"): """ Sets Simple Secure Pairing mode to enable/disable it and force device to use Legacy Pairing mode instead. :type iface: str :param iface: bluetooth interface (hci0, hci1, etc.) :type mode: str :param mode: SSP mode: "off" => disabled, "on" => enabled :return None """ cmd = "hciconfig " + self._device.get_config("btIface", "hci0") + " sspmode " if mode == "off": self._logger.info("Disable bluetooth SSP mode") cmd += "0" elif mode == "on": self._logger.info("Enable bluetooth SSP mode") cmd += "1" else: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Mode <%s> is not valid!" % str(mode)) status, output = self._internal_exec(cmd, 3)
def set_up(self): """ Initialize the test """ # in setup board should be on EmUsecaseBase.set_up(self) if self.__cable_type != self._io_card.USB_HOST_PC: if not self.em_core_module.is_host_connection_available_when_charger_plug( self.__cable_type, keep_charger_if_data=True): msg = "Data is necessary to perform the test, not data is seen when we plug %s" % self.__charger_to_use self._logger.error(msg) raise AcsConfigException(AcsConfigException.OPERATION_FAILED, msg) # Update Battery Information em_info = self.update_battery_info() if self.em_core_module.is_batt_capacity_below_target( em_info, self.em_core_module.batt_min_capacity): # charge part self.em_core_module.monitor_charging( self.em_core_module.batt_min_capacity, self.em_core_module.charge_time, self.__em_meas_tab) return (Global.SUCCESS, "No errors")
def disconnect_tethering(who_disconnect, nap_api, panu_api, nap_addr, panu_addr): """ Disconnect Tethering connection :type who_disconnect: String :param who_disconnect: "PAN-U" or "NAP" device to initiate disconnection :type nap_api: LocalConnectivity API Object :param nap_api: API to control BT on NAP device :type panu_api: LocalConnectivity API Object :param panu_api: API to control BT on PAN-User device :type nap_addr: String :param nap_addr: BT Address of the Network Access Point :type panu_addr: String :param panu_addr: BT Address of the Network PAN-User device """ # Disconnect Bluetooth PAN profile if who_disconnect == "PAN-U": panu_api.disconnect_bt_device(nap_addr, BtProfile.PAN) elif who_disconnect == "NAP": nap_api.disconnect_bt_device(panu_addr, BtProfile.PAN) else: msg = "who_disconnect is not valid: " + str(who_disconnect) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
def _edit_skip_wizard(self, wizard_value, camera, cam_settings, root_node): """ edit skip wizard when camera is launch :rtype: boolean :return: True if a modification was done, False otherwise """ # parse all quality option for this board modification_done = False # I dont handle dictionary key missing error, let's python crash instead wizard_setting_name = "SKIP_WIZARD" wizard_extra = "SKIP_WIZARD_EXTRA_SETTING" # main cam settings cam_element = cam_settings.get(wizard_setting_name) if cam_element is not None: # get the skip wizard from the config file new_value = cam_element["option_value"].get(wizard_value) if new_value is None: error = " camera %s %s setting option does not contains value %s in camera module file" % ( camera, cam_element.get("option_name"), wizard_value) self.logger.error(error) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error) if self._edit_settings(root_node, cam_element, new_value) == True: modification_done = True # edit extra settings extra_cam_element = cam_settings.get(wizard_extra) if extra_cam_element is not None: modification_done = self._edit_wizard_custom_settings( root_node, extra_cam_element) else: self.logger.warning( "fail to get configuration info from prefs_setting_option_names.%s module for %s" % (camera, wizard_setting_name)) return modification_done
def _configure_rssi(self): """ Configure the RSSI to be in the good range """ rssi_check = False if self._standard in AcsWifiFrequencies.WIFI_STANDARD_5G: power_values = Cisco1250.POWER_VALUES_5G else: power_values = Cisco1250.POWER_VALUES_2G # Initiate connection to the equipment self._ns.init() try: # Configure power on AP for power in power_values: self._ns.set_wifi_power(self._standard, power) time.sleep(3.0) # Check WiFi RSSI - require between -40dBm and -45dBm self._rssi_value = self._networking_api.get_wifi_rssi( self._ssid) if self._rssi_value <= self.RSSI_MAX_VALUE and self._rssi_value >= self.RSSI_MIN_VALUE: self._logger.debug("Check RSSI : %s - Power used : %s" % (self._rssi_value, power)) rssi_check = True break finally: # Close the connection to AP self._ns.release() if not rssi_check: # Bad RSSI configuration, raise an exception msg = "Bad RSSI to run the test : %sdBm - require between %sdBm and %sdBm" % ( self._rssi_value, self.RSSI_MIN_VALUE, self.RSSI_MAX_VALUE) self._logger.error(msg) raise AcsConfigException(AcsConfigException.OPERATION_FAILED, msg)
def _stop_remaining_activity(self, iteration, responder_api): """ If Responder is NOT discoverable Stop "wait_for_pair" activity on Responder Return None """ if self._ini_list[iteration].strip().lower() == "phone1": discovmode = self._discov_mode2.upper() elif self._ini_list[iteration].strip().lower() == "phone2": discovmode = self._discov_mode1.upper() else: msg = "Initiator value <%s> is not valid" % self._ini_list[ iteration].strip() self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if discovmode == "NOT_DISCOV": if not responder_api.wait_for_pairing_canceled(): msg = "Pairing canceled status not received" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) return
def set_up(self): """ Set up the test configuration """ # Call use case base Setup function UseCaseBase.set_up(self) # Enable flight mode if needed if self._use_flightmode == "true": self._networking_api.set_flight_mode("on") # Check that io card is present if self._io_card is None: # We need to unplug/plug the device with iocard error_msg = "This use case requires io card to be executed !" raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, error_msg) # Ensure to not have any previous lock self._phonesystem_api.clear_pwr_lock() self._sleep_mode_api.init(self._sleep_mode, self._settle_time, self._audio_file) return Global.SUCCESS, "No errors"
def set_gps_power(self, mode): """ Sets the GPS power to on/off. :type mode: str or int or boolean :param mode: can be ('on', '1', 1, True) to enable ('off', '0', 0, False) to disable :return: None """ current_mode = self.get_gps_power_status() if mode in ("on", "1", 1, True): if current_mode == 1: warning_msg = "gps Power is already on" self._logger.info(warning_msg) return else: mode = 1 elif mode in ("off", "0", 0, False): if current_mode == 0: warning_msg = "gps Power is already off" self._logger.info(warning_msg) return else: mode = 0 else: message = "Invalid parameter value for 'mode': %s" % mode raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, message) # Set the gps power mode function = "setGpsPower" cmd_args = "--ei mode %s" % mode self._internal_exec_v2(self._gps_module, function, cmd_args, is_system=True)
def run_script(self, script_file): """ :type script_file: str :param script_file: Script file to be used """ script_file = os.path.normpath(script_file) script_file_in_execconfig = os.path.join(self._execution_config_path, script_file) if os.path.isfile(script_file): self._logger.debug("Launching script %s" % str(script_file)) # Execute the script execfile(script_file) elif os.path.isfile(script_file_in_execconfig): self._logger.debug("Launching script %s from _ExecutionConfig" % str(script_file)) # Execute the script execfile(script_file_in_execconfig) else: raise AcsConfigException( AcsConfigException.OPERATION_FAILED, "Unable to execute script ! - %s" % str(script_file))
def __cast_param_type(param_name, param_value, param_type): """ Cast the parameter into the given type :type param_name: str :param param_name: Name of the parameter :type param_value: str :param param_value: Value of the parameter :type param_type: str :param param_type: Type of the parameter (it will be casted using CAST_TYPE_DICTIONARY) :return: casted parameter value """ try: param_value = CAST_TYPE_DICTIONARY[param_type](param_value) except (ValueError, TypeError): error_msg = "Cannot convert value of '{0}' ({1}) into '{2}' !".format( param_name, param_value, param_type) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg) return param_value
def get_file_size(self, target): """ Get file size. :type target: str :param target: the file path to get size :rtype: int :return: the file size in block size 1 :raise AcsBaseException in case of wrong usage """ size = None cmd = "ls -lrt %s | awk '{print $5}'" % target status, output = self._internal_exec(cmd) if status: # in case of someone use this method to get folder size, raise ex if len(str(output).split()) > 1: msg = "get_file_size method should be used to get FILE size, check input parameter" raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) size = int(output.split()[0]) return size
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ TestStepBase.run(self, context) assert self._pars.operator in [self.ADD, self.SUBTRACT, self.MULTIPLY, self.DIVIDE], \ "Operator value is invalid (it should have been checked by the framework)" first_value = float(self._pars.first) second_value = float(self._pars.second) if self._pars.operator == self.ADD: self._result = first_value + second_value elif self._pars.operator == self.SUBTRACT: self._result = first_value - second_value elif self._pars.operator == self.MULTIPLY: self._result = first_value * second_value elif self._pars.operator == self.DIVIDE: if second_value == 0: msg = "Second value = 0 ! Division by 0 is not possible" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) else: self._result = first_value / second_value context.set_info(self._pars.save_result_as, str(self._result)) self.ts_verdict_msg = "VERDICT: %s stored as {0}".format( self._result) % self._pars.save_result_as self._logger.debug(self.ts_verdict_msg)
def __check_cnt_parameters(self): """ Checks all connection parameters """ if not self._device1_channel: msg = "undefined CHANNEL." self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if (int(self._device1_channel) not in AcsWifiFrequencies.WIFI_CHANNELS_FREQUENCIES_5G) \ and (int(self._device1_channel) not in AcsWifiFrequencies.WIFI_CHANNELS_FREQUENCIES_2G): msg = "Unknown CHANNEL " + self._device1_channel self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if not self._device2_channel: msg = "undefined CHANNEL." self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if (int(self._device2_channel) not in AcsWifiFrequencies.WIFI_CHANNELS_FREQUENCIES_5G) \ and (int(self._device2_channel) not in AcsWifiFrequencies.WIFI_CHANNELS_FREQUENCIES_2G): msg = "Unknown CHANNEL " + self._device2_channel self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if not str(self._device1_go).isdigit(): msg = "device 1 invalid go." self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) self._device1_go = int(str(self._device1_go)) if not str(self._device2_go).isdigit(): msg = "device 2 invalid go." self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) self._device2_go = int(str(self._device2_go))
def set_up(self): """ Set up the test configuration """ # We won't use LabWcdmaSmsCsBase SetUp, because we don't want PDP active # for this CS test case. # log in acs logs self._logger.info("") self._logger.info("%s: Setup", self._name) self._logger.info("") # Connect to equipment self._ns.init() # Set the equipment Application Format = "WCDMA" self._ns.switch_app_format("WCDMA") # Perform full preset self._ns.perform_full_preset() # Deactivate HSUPA and HSDPA capabilities self._ns_data_3g.set_edch_cell_capability("OFF") self._ns_data_3g.set_hsdpa_cell_capability("OFF") # Set cell off self._ns_cell_3g.set_cell_off() # Set cell power using CELL_POWER value self._ns_cell_3g.set_cell_power(self._cell_power) self._ns_cell_3g.set_bch_update_page_state("AUTO") self._ns_cell_3g.set_drx_cycle(self._drx_cycle_length_cn) self._ns_cell_3g.set_drx_cycle_utran(self._drx_cycle_length_utran) self._ns_cell_3g.set_ctch_allocation_period( self._ctch_allocation_period) # Set cell on self._ns_cell_3g.set_cell_on() # Check registration status before time out using # registrationTimeout value from Device_Catalog.xml time.sleep(self._wait_btwn_cmd) dut_imsi = self._modem_api.get_imsi(self._registration_timeout) RegUtil.check_dut_registration_before_timeout( self._ns_cell_3g, self._networking_api, self._logger, dut_imsi, self._registration_timeout) # We should makesure data is disable for this use case self._logger.info("Deactivation of the PDP Context") self._networking_api.deactivate_pdp_context(self._ssid) # Check Data Connection State => PDP Active before timeout self._ns_data_3g.check_data_connection_state( "ATTACHED", self._registration_timeout, blocking=False) # Check registration state is connected using # registrationTimeout from Device_Catalog.xml (Non blocking # for this test if function isn't implemented on CDK) time.sleep(self._wait_btwn_cmd) self._modem_api.check_cdk_registration_bfor_timeout( self._registration_timeout) # Set sender address using DESTINATION_NUMBER on Network simulator self._ns_messaging_3g.set_sms_sender_address( self._sms_cb_destination_number) self._ns_messaging_3g.set_cell_broadcast_message_identifier( self._cell_broadcast_message_identifier, self._cell_broadcast_message) self._ns_messaging_3g.set_cell_broadcast_message_repetition_period( self._repetition_period) self._ns_messaging_3g.select_cell_broadcast_message_content( self._content_type, self._cell_broadcast_message) self._ns_messaging_3g.set_cell_broadcast_message_update_number( self._update_number, self._cell_broadcast_message) if self._content_type == "CTEX": self._ns_messaging_3g.set_custom_cell_broadcast_text_message( self._custom_cell_broadcast_text_message, self._cell_broadcast_message) elif self._content_type == "CDAT": self._ns_messaging_3g.set_custom_cell_broadcast_data_string( self._custom_cell_broadcast_text_message, self._cell_broadcast_message) if self._vc_type not in ("MO", "MT"): raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, "Invalid voice call type") # Release any previous call (Robustness) self._voicecall_api.release() # Establish voice call if self._vc_type == "MO": # Dial using a dummy hard-coded phone number self._logger.info("Calling distant party...") self._voicecall_api.dial(self._distant_number) elif self._vc_type == "MT": # Initiate VoiceCall to CDK self._vc_3g.mt_originate_call() # pylint: disable=E1101 # Check call status is incoming before callSetupTimeout self._voicecall_api.wait_for_state( self._uecmd_types.VOICE_CALL_STATE.INCOMING, self._call_setup_time) # Answer incoming call self._voicecall_api.answer() # Check call status before callSetupTimeout (NS) self._vc_3g.check_call_connected(self._call_setup_time) # Check call status before callSetupTimeout (CDK) self._voicecall_api.wait_for_state( self._uecmd_types.VOICE_CALL_STATE.ACTIVE, # pylint: disable=E1101 self._call_setup_time) return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ LiveDualPhoneBTBase.set_up(self) if self._dut_state not in ["DUT_CLIENT", "DUT_SERVER"]: msg = "DUT state configuration unknown - DUT should be client or server" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # defines NAP / PAN-User roles if self._nap_or_pan_test == "NAP": self._nap_api = self._bt_api self._nap_addr = self._phone1_addr self._panu_api = self._bt_api2 self._panu_addr = self._phone2_addr self._wifi_api = self._networking_api self._panu_net_api = self._networking_api2 elif self._nap_or_pan_test == "PAN": self._nap_api = self._bt_api2 self._nap_addr = self._phone2_addr self._panu_api = self._bt_api self._panu_addr = self._phone1_addr self._wifi_api = self._networking_api2 self._panu_net_api = self._networking_api else: raise AcsConfigException(AcsConfigException.INVALID_TEST_CASE_FILE, "You did not provide a valid value for the NAP_OR_PAN_TEST parameter. It must pe NAP or PAN.") # Handle External connection (WIFI or CELLULAR) self._bluetooth_connectivity_obj.handle_external_connection(self._connection_to_share, self._wifi_api, self.__global_config, self._wifi_access_point) time.sleep(self._wait_btwn_cmd) #initialize phone for PAN if self._interleave_search is False: self._bluetooth_connectivity_obj.search_for_device_until_found(self._panu_api, self._nap_api, self._nap_addr, self._must_find) elif self._interleave_search is True: self._bluetooth_connectivity_obj.search_for_device_interleave(self._panu_api, self._nap_api, self._nap_addr, self._must_find) # Pair the DUT with the device self._bluetooth_connectivity_obj.try_until_paired(self._panu_api, self._nap_api, self._panu_addr, self._nap_addr, self._replyval, self._accept_connection) # # 4) Set tethering power to on, PAN connect # PAN connect the devices # Enable BT tethering #check devices are truly paired self._bluetooth_connectivity_obj.check_paired(self._panu_api, self._nap_addr) self._nap_api.set_bt_tethering_power("on") time.sleep(self._wait_btwn_cmd) #connect PAN way self._panu_api.connect_bt_device(self._nap_addr, BtProfile.PAN) time.sleep(self._wait_btwn_cmd) #check profiles are connected keep_going = True self._start_time = time.time() while keep_going: self._status = self._panu_api.get_bt_connection_state(self._nap_addr, BtProfile.PAN) keep_going = self._bluetooth_connectivity_obj._keep_going(self._status, self._start_time, self._timeout) self._bluetooth_connectivity_obj._raise_error_if_fail_when_profiles_not_connected(self._status, self._fail_if) result, output = Global.SUCCESS, "" return result, output
def _check_flash_files(self, flash_file_list): """ Check flash file compatibility with flash tool :type flash_file_list: list :param flash_file_list: list of flash file (absolute paths) :rtype: list :return: folder path (absolute path) containing all flash files """ flash_file_folder = "" folder_flash_path = None if len(flash_file_list) > 0: for flash_file in flash_file_list: filename, file_extension = os.path.splitext(flash_file) if flash_file.endswith((".tgz", ".zip")): if zipfile.is_zipfile(flash_file): try: zip_file = zipfile.ZipFile(flash_file, "r") self._logger.info( "AndroidEmulatorFlashTool: unzip flash file (%s)" % flash_file) zip_file.extractall(filename) zip_file.close() except Exception as ex: err_msg = "AndroidEmulatorFlashTool: Flash input file %s, unzip issue, error : %s" % ( flash_file, str(ex)) self._logger.error(err_msg) raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, err_msg) elif tarfile.is_tarfile(flash_file): try: tar_file = tarfile.open(flash_file, "r") self._logger.info( "AndroidEmulatorFlashTool: untar flash file (%s)" % flash_file) tar_file.extractall(filename) tar_file.close() except Exception as ex: err_msg = "AndroidEmulatorFlashTool: Flash input file %s, untar issue, error : %s" % ( flash_file, str(ex)) self._logger.error(err_msg) raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, err_msg) else: err_msg = "AndroidEmulatorFlashTool: Not a valid archive" raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, err_msg) # Check availability of image folder, the android and emulator executables. # Also give all permisions to the folder. flash_file_folder = "".join(filename) os.system("chmod -R 777 %s" % flash_file_folder) for subdir, dirs, files in os.walk(flash_file_folder): for dir in dirs: if ((dir == "x86") or (dir == "armeabi-v7a")) and ("system-images" in subdir): self.path_to_image = os.path.join(subdir, dir) os.environ['DIR_PATH'] = self.path_to_image break for file in files: if (file == "android"): self.path_to_android = os.path.join( subdir, file) #self._logger.info("The 'android' tool is located here: ", path_to_android) os.chmod(self.path_to_android, 0755) # Search for all files that contain emulator but are not .jpg or .html files # Example emulator, emulator-x86, emulator64-arm ... if fnmatch.fnmatch( file, 'emulator*') and not fnmatch.fnmatch( file, 'emulator*.*'): path_to_generic = os.path.join(subdir, file) if (file == 'emulator'): self.path_to_emulator = path_to_generic os.environ[ 'EMULATOR_PATH'] = self.path_to_emulator else: err_msg = "AndroidEmulatorFlashTool: flash file format is not suitable (should be .tgz) for file %s" % str( flash_file) self._logger.warning(err_msg) if not self.path_to_android or not self.path_to_emulator: err_msg = "AndroidEmulatorFlashTool: android or emulator not found in the archive" raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, err_msg) else: folder_flash_path = flash_file_folder return folder_flash_path
def set_up(self): """ Initialize the test """ # Call LabPwrMeasBase base Setup function EmUsecaseBase.set_up(self) # first turn off board for a while to allow it to cool down if self.__media_player is None: self._logger.warning( "no media was set to be launched on the HOST side, no media will be play during video capture" ) else: if not os.path.exists(self.__host_media): error_msg = "The video %s you want to play on the host side does not exist" % self.__host_media self._logger.error(error_msg) raise AcsConfigException(AcsConfigException.FILE_NOT_FOUND, error_msg) # check that logs you want to parse exist: stop_tag = "TEST_IF_COOLING_INTENT_EXIST-" + time.strftime( "-%Y-%m-%d_%Hh%M.%S") self.__parser_api.inject_tag(stop_tag) cooling_intents = self.__parser_api.find_txt_between_tag( self.__parser_api.PUPDR_MISC_TAG.get("MAIN_BOOT"), stop_tag, self.__parser_api.THERMAL_TAG.get("COOLING_INTENT"), raise_error=False) if len(cooling_intents) <= 0: # it means that cooling intent does not exist, we cant do the test error_msg = "No thermal throttling/de-throttling message has been seen since last boot, check if thermal service is working on your DUT or an update of the thermal parser may be necessary" self._logger.error(error_msg) raise DeviceException(DeviceException.OPERATION_FAILED, error_msg) ####################################### SETUP CAMERAS ########################################### if self.__temp_camera is not None: # init camera connection self.__temp_camera.init() self.__temp_camera.delete_all_pictures() # clean video storage self.__video_record_api.clean_video_storage() # Update Battery Information ####################################### CHARGE BOARD ########################################### em_info = self.update_battery_info() if self.em_core_module.is_batt_capacity_below_target( em_info, self.em_core_module.batt_min_capacity): # charge part self.em_core_module.monitor_charging( self.em_core_module.batt_min_capacity, self.em_core_module.charge_time, self.__em_meas_tab) ####################################### COOLDOWN BOARD ########################################### self.phonesystem_api.set_screen_timeout(3600) self.__video_capture_mod.setup() self._device.switch_off() # remove any cable after this self._io_card.remove_cable("ALL") if self.__temp_camera is not None: # do the thermal camera setting during the off phase to let the board cool down self._setup_camera() # wait a given time to let the board cool down self._monitor_board_temp(self.__cooldown, self.__start_temp) else: # wait a given time to let the board cool down wait_time = self.__cooldown + 15 self._logger.info( "waiting %ss+15s to let the board cool down while it should be OFF" % str(self.__cooldown)) time.sleep(wait_time) # turn on board and launch every load self._device.switch_on() # this measurement is done only for debugging purpose self.em_api.get_thermal_sensor_info() # start all environment load self.__load_module.start_load() if self.__temp_camera is not None: # collect a ref temperature before starting the test once board is on cam_meas = self.__temp_camera.get_measurement_from_box() self.__temp_meas_tab.add_dict_measurement(cam_meas) self.__temp_meas_tab.add_measurement([ self.get_time_tuple(), (self._em_cst.COMMENTS, "Setup: Temperature just before starting the test") ]) self.__temp_meas_tab.switch_to_next_meas() return Global.SUCCESS, "No errors"
def set_up(self): """ Setup for the test case """ # Call set_up of use case base UseCaseBase.set_up(self) # Check if we have the second phone available if self._phone2 is None: # We are using this multi UC with only one phone error_msg = \ "This use case requires two phones to be executed !" self._logger.error(error_msg) raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, error_msg) # Boot the other phone (the DUT is already booted) if not self._phone2.is_available(): DeviceManager().boot_device("PHONE2") if self._default_sim == "SIM2": #Setting the sim to Default (verdict, msg) = self._setDefaultSecondSim() else: (verdict, msg) = self._setDefaultSim() time.sleep(10) self._absolute_path_on_dut = "".join( [self._device.multimedia_path, self._ftp_file_basename]) # Delete the FTP download file on the DUT self._delete_file_if_exists(self._absolute_path_on_dut) # Disable flight mode self._networking_api.set_flight_mode("off") time.sleep(self._wait_btwn_cmd) if self._mms_type.lower() == "picture": # Checks if the attachment file exist. self._phonesystem_api.check_file_exist(self._attachment_file) # Kill the messaging application. self._kill_messaging_app() time.sleep(self._wait_btwn_cmd) # There is a preferred network to set, backup initial, then set configured one if self._network_pref is not None: self._initial_pref_network = self._dut_config.get( "defaultPreferredNetwork") time.sleep(self._wait_btwn_cmd) if self._networking_api.is_preferred_network_type_valid( self._network_pref): # Setting the DUT preferred network type to the one specified # in the TC. self._networking_api.set_preferred_network_type( self._network_pref) time.sleep(self._wait_btwn_cmd) # Check the DUT is camped on a compatible network with the selected # preferred network. self._modem_api.check_rat_with_pref_network( self._network_pref, self._registration_timeout) time.sleep(self._wait_btwn_cmd) else: raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, "Unknown network type: %s" % self._network_pref) return verdict, msg
def _sendmms(self, queue): lock = threading.Lock() lock.acquire() try: time_to_receive_mms = None time_to_send_mms = None time_waited = 0 # Max number of iteration done while waiting for the screen to turn off. # Used to prevent endless loops. max_time_waited = 200 # Clear all SMS and MMS. self._mms_api.delete_all_messages() # Wait for the screen to turn off. while self._phonesystem_api.get_screen_status() \ and time_waited < max_time_waited: time.sleep(5) time_waited += 5 self._logger.info("Waited %s seconds for the screen to turn off." % time_waited) # Checks if the screen turned off before a fixed timeout. if time_waited >= max_time_waited: raise DeviceException( DeviceException.TIMEOUT_REACHED, "The screen did not turned off in %s." % max_time_waited) # Wake up the phone screen. time.sleep(self._wait_btwn_cmd) self._logger.info("Turning the screen on.") self._phonesystem_api.set_phone_lock("off") self._phonesystem_api.wake_screen() self._phonesystem_api.set_phone_lock(0) # register on intent to receive incoming mms self._mms_api2.register_for_mms_reception() # Build the MMS. time.sleep(self._wait_btwn_cmd) self._mms_api.send_mms(self._mms_type, self._destination_number, self._mms_subject, self._message, self._attachment_file, self._repeat_count) time.sleep(self._wait_btwn_cmd) # Waiting for the MMS to be send. sent_time = self._mms_api.check_mms_sent(self._destination_number, self._send_mms_timeout) # Waiting on incoming message. reception_date = self._mms_api2.wait_for_incoming_mms( self._received_mms_timeout, self._destination_number) # Logging the time taken to receive the MMS. time_to_receive_mms = float(reception_date) - float(sent_time) self._logger.info("The MMS has been received in %s seconds." % time_to_receive_mms) # Compare the sent and received MMS. self._mms_api.request_remote_send_received_mms_compare( self._mms_type) except Exception as inst: self._error.Code = Global.FAILURE queue.put(self._error.Code) self._logger.info(inst) raise AcsConfigException(AcsConfigException.OPERATION_FAILED, "Exception : %s" % inst) finally: #lock is released lock.release() print("the awake for ftp") print(self.awake) queue.put(Global.SUCCESS)
def set_up(self): """ Initialize the test """ LiveDualPhoneBTBase.set_up(self) # Check BT addresses validity if not NetworkingUtil.is_valid_mac_address(self._phone1_addr): msg = "Wrong MAC address for PHONE1 [%s]" % self._phone1_addr raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if not NetworkingUtil.is_valid_mac_address(self._phone2_addr): msg = "Wrong MAC address for PHONE2 [%s]" % self._phone2_addr raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # Set sender/receiver APIs and varialbes if self._direction.upper() == "UL": self._sender_api = self._bt_api self._sender_add = self._phone1_addr self._sender_device = self._device self._sender_phonesys_api = self._phonesystem_api self._receiver_api = self._bt_api2 self._receiver_add = self._phone2_addr self._receiver_device = self._phone2 self._receiver_phonesys_api = self._phonesystem2_api self._fullpath_filename = self._multimedia_path1 + "/" \ + self._filename self._filesize = self._phonesystem_api.\ get_file_size(self._fullpath_filename) elif self._direction.upper() == "DL": self._sender_api = self._bt_api2 self._sender_add = self._phone2_addr self._sender_device = self._phone2 self._sender_phonesys_api = self._phonesystem2_api self._receiver_api = self._bt_api self._receiver_add = self._phone1_addr self._receiver_device = self._device self._receiver_phonesys_api = self._phonesystem_api self._fullpath_filename = self._multimedia_path2 + "/" \ + self._filename self._filesize = self._phonesystem2_api.\ get_file_size(self._fullpath_filename) else: msg = "Invalid DIRECTION parameter [%s]" % self._direction self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # Control the existence of the file to send and get the file size \ # in order to determine the timeout duration if self._filesize < 0: msg = "Filesize is not accessible. " \ + "File is probably missing on TX device" self._logger.error(msg) raise AcsConfigException(AcsConfigException.FEATURE_NOT_AVAILABLE, msg) self._timeout = int( self._filesize / self.BT_OPP_SPEED_FOR_TIMEOUT) + 20 # Set receiver discoverable by sender self._receiver_api.set_bt_discoverable("connectable", 0) # First Scan devices around to speed-up run_test self._sender_api.bt_scan_devices() # unlock screen and set display ON # Mandatory prior to use bt_opp_send_file UECmd self._sender_phonesys_api.display_on() self._sender_phonesys_api.set_phone_lock(0) return Global.SUCCESS, "No errors"
def __init__(self, tc_name, global_config): """ Constructor """ # Added Messaging management LabMobilityBase.__init__(self, tc_name, global_config) # Read NS1_CELL_TECH from test case xml file (In str) self._ns1_cell_tech = \ str(self._tc_parameters.get_param_value("NS1_CELL_TECH")) # Read NS2_CELL_TECH from test case xml file (In str) self._ns2_cell_tech = \ str(self._tc_parameters.get_param_value("NS2_CELL_TECH")) # Read NS1_CELL_BAND from test case xml file (In str) self._ns1_cell_band = str(self._tc_parameters.get_param_value("NS1_CELL_BAND")) # Read NS2_CELL_BAND from test case xml file (In str) self._ns2_cell_band = str(self._tc_parameters.get_param_value("NS2_CELL_BAND")) # NS1_CELL_REL self._ns1_cell_rel = 7 # NS2_CELL_REL self._ns2_cell_rel = 7 # Set APIs instances for NS1 if self._ns1_cell_tech == "2G": self._ns1_cell = self._ns1.get_cell_2g() self._ns1_vc = self._ns1_cell.get_voice_call() self._ns1_data = self._ns1_cell.get_data() self._ns1_messaging = self._ns1_cell.get_messaging() elif self._ns1_cell_tech == "3G": self._ns1_cell = self._ns1.get_cell_3g() self._ns1_vc = self._ns1_cell.get_voice_call() self._ns1_data = self._ns1_cell.get_data() self._ns1_messaging = self._ns1_cell.get_messaging() else: self._error.Msg = "Unknown Cell Radio Access Technology" raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, self._error.Msg) # Set APIs instances for NS2 if self._ns2_cell_tech == "2G": self._ns2_cell = self._ns2.get_cell_2g() self._ns2_vc = self._ns2_cell.get_voice_call() self._ns2_data = self._ns2_cell.get_data() self._ns2_messaging = self._ns2_cell.get_messaging() elif self._ns2_cell_tech == "3G": self._ns2_cell = self._ns2.get_cell_3g() self._ns2_vc = self._ns2_cell.get_voice_call() self._ns2_data = self._ns2_cell.get_data() self._ns2_messaging = self._ns2_cell.get_messaging() else: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Unknown Cell Radio Access Technology") # Read CATEGORY from testcase xml parameters self._category = \ str(self._tc_parameters.get_param_value("CATEGORY", "WCDMA")) # Read fast dormancy parameter self._ns1_fast_dormancy = \ self._ns1_node.get_param_value("Fast_Dormancy", "disable") self._ns2_fast_dormancy = \ self._ns2_node.get_param_value("Fast_Dormancy", "disable")
def set_up(self): """ Initialize the test """ UseCaseBase.set_up(self) return_code = Global.SUCCESS return_msg = "No errors" # Disable flight mode self._networking_api.set_flight_mode("off") # Configure Modem Trace # Special treatment required for Saltbay 7160 and MOFD 7160 # Temporary solution as only high and critical issues are accepted on imin_legacy # Retrieve platform properties hardware_config_cmd = "adb shell getprop ro.product.name" (return_code, output) = self._device.run_cmd(hardware_config_cmd, 10, force_execution=True) if (return_code is Global.FAILURE): return_msg = "Command %s has failed" % hardware_config_cmd raise AcsConfigException(AcsConfigException.OPERATION_FAILED, return_msg) # Check if the platform is pf450cl or MOFD 7160 if ("pf450cl" in output): self._var_platform_pf450cl = True self._var_modem_7160 = True else: # Retrieve software properties software_config_cmd = "adb shell getprop ro.swconf.info" (return_code, output) = self._device.run_cmd(software_config_cmd, 10, force_execution=True) if (return_code is Global.FAILURE): return_msg = "Command %s has failed" % software_config_cmd raise AcsConfigException(AcsConfigException.OPERATION_FAILED, return_msg) # Platform under test is a MOFD 7160 if ("V1_7160" in output): self._var_modem_7160 = True if ( self._var_modem_7160 is True): if (self._var_platform_pf450cl is True): self._configure_modem_trace1 = "adb shell %s" % self._configure_modem_trace1 (return_code, output) = self._device.run_cmd(self._configure_modem_trace1, 10, force_execution=True) if (return_code is Global.FAILURE): return_msg = "Command %s has failed" % self._configure_modem_trace1 raise AcsConfigException(AcsConfigException.OPERATION_FAILED, return_msg) self._configure_modem_trace2 = "adb shell %s" % self._configure_modem_trace2 (return_code, output) = self._device.run_cmd(self._configure_modem_trace2, 10, force_execution=True) if (return_code is Global.FAILURE): return_msg = "Command %s has failed" % self._configure_modem_trace2 raise AcsConfigException(AcsConfigException.OPERATION_FAILED, return_msg) time.sleep(1) self._configure_modem_trace3 = "adb shell %s" % self._configure_modem_trace3 (return_code, output) = self._device.run_cmd(self._configure_modem_trace3, 10, force_execution=True) if (return_code is Global.FAILURE): return_msg = "Command %s has failed" % self._configure_modem_trace3 raise AcsConfigException(AcsConfigException.OPERATION_FAILED, return_msg) time.sleep(2) (return_code, output) = self._device.run_cmd("adb shell echo 'configure_trace_modem -d -t5 SUCCESS. Your board needs a HARDWARE reboot'", 10, force_execution=True) else: # Configure modem trace for all other platforms self._modem_api.configure_modem_trace(self._hsi_speed, self._trace_level) # Wait a while time.sleep(self._wait_btwn_cmd) # Enable Flight Mode self._logger.info("Now enabling Flight Mode for modem reset purpose") self._networking_api.set_flight_mode("on") # Wait a while time.sleep(30) # Disable Flight Mode self._logger.info("Disable Flight Mode.") self._networking_api.set_flight_mode("off") # Wait a while time.sleep(self._wait_btwn_cmd) # Transform as enum element log_location = self._bplog_loc[self._log_location.upper()] # Wait a while to ensure MTS is up time.sleep(60) self._modem_api.activate_modem_trace(log_location, self._file_size_option) return return_code, return_msg
def set_up(self): """ Initialize the test """ # Call LabPwrMeasBase base Setup function EmUsecaseBase.set_up(self) # reset the ref value self.__ref_temp = None # check that media exist if self.__media_player is None: self._logger.warning("no media was set to be launched on the HOST side, no media will be play during video capture") else: if not os.path.exists(self.__host_media): error_msg = "The video %s you want to play on the host side does not exist" % self.__host_media self._logger.error(error_msg) raise AcsConfigException(AcsConfigException.FILE_NOT_FOUND, error_msg) # clean video storage self.__video_record_api.clean_video_storage() # init camera connection self.__temp_camera.init() self.__temp_camera.delete_all_pictures() # Update Battery Information em_info = self.update_battery_info() if self.em_core_module.is_batt_capacity_below_target(em_info, self.em_core_module.batt_min_capacity): # charge part self.em_core_module.monitor_charging(self.em_core_module.batt_min_capacity, self.em_core_module.charge_time, self.__em_meas_tab) self.__video_capture_mod.setup() self.phonesystem_api.set_screen_timeout(3600) self._device.switch_off() # remove any cable after this self._io_card.remove_cable("ALL") # do the thermal camera setting during the off phase to let the board cooldown self._setup_camera() # wait a given time to let the board cool down start_temp_seen = False wait_time = self.__cooldown + 15 self._logger.info("waiting at most %ss+15s to let the board cool down below %s degree" % (str(self.__cooldown), str(self.__start_temp))) start_time = time.time() while time.time() - start_time < wait_time: cam_meas = self.__temp_camera.get_measurement_from_box() try: self.__temp_meas_tab.add_dict_measurement(cam_meas) self.__temp_meas_tab.add_measurement([self.get_time_tuple(), (self._em_cst.COMMENTS, "Setup: cooling down the board")]) self.__temp_meas_tab.switch_to_next_meas() except Exception as e: msg = "error happen when filling temperature value in file: %s" % str(e) self._logger.error(msg) if cam_meas["MAXT"][0] <= self.__start_temp: self._logger.info("the MAX temperature seen is %s, test can continue " % str(cam_meas["MAXT"])) # take a ref picture pic_path = self.__temp_camera.take_picture("ref_phone_off") self.__temp_camera.pull_picture(pic_path, self.__pic_folder) start_temp_seen = True self.__ref_temp = cam_meas["MAXT"][0] break if not start_temp_seen: cam_meas = self.__temp_camera.get_measurement_from_box() pic_path = self.__temp_camera.take_picture("pic_temp_after_cooldown_fail") self.__temp_camera.pull_picture(pic_path, self.__pic_folder) error_msg = "The board fail to cool down below %s degree after spending %ss in OFF state, the last temperature seen was %s degree" % (self.__start_temp, self.__cooldown, str(cam_meas["MAXT"])) self._logger.error(error_msg) self._device.switch_on() raise DeviceException(DeviceException.INVALID_DEVICE_STATE, error_msg) # turn on board and launch every load self._device.switch_on() self.em_api.get_thermal_sensor_info() # start all environment load self.__load_module.start_load() # start HOST Video if not self.__media_player is None: self.__media_player.play(self.__host_media, self.__host_monitor) # media may take time to start start_time = time.time() while time.time() - start_time < 10: time.sleep(1) if self.__media_player.is_playing(): break if not self.__media_player.is_playing(): error_msg = "Fail to start the video playback on the HOST side" self._logger.error(error_msg) raise AcsBaseException(AcsBaseException.OPERATION_FAILED, error_msg) # collect a ref temperature before starting the test once board is on cam_meas = self.__temp_camera.get_measurement_from_box() self.__temp_meas_tab.add_dict_measurement(cam_meas) self.__temp_meas_tab.add_measurement([self.get_time_tuple(), (self._em_cst.COMMENTS, "Setup: Temperature just before starting the test")]) self.__temp_meas_tab.switch_to_next_meas() # start video recording self.phonesystem_api.wake_screen() self.phonesystem_api.set_phone_lock(False) raw_video_filename, _ = self.__video_capture_mod.start_recording() # Check if the video file exist if not self.__video_record_api.check_video_exist(raw_video_filename): self._logger.error("Recording fail to start, retry again") raw_video_filename, _ = self.__video_capture_mod.start_recording() # Check if the video file exist if not self.__video_record_api.check_video_exist(raw_video_filename): screen_path = self._device.screenshot(filename=os.path.join(self.__pic_folder, "camera_record_fail.png")) error_msg = "Fail to see the raw video file generated during the record, it seems that the video record may has not started." if screen_path is not None: error_msg += "\nPlease check the screenshot at %s." % screen_path self._logger.error(error_msg) raise DeviceException(DeviceException.FILE_SYSTEM_ERROR, error_msg) return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ # Call UseCase base Setup function UseCaseBase.set_up(self) # Check value of FILENAME parameter if self._audio_filename == "" or is_number(self._audio_filename): error_msg = "The parameter FILENAME must a string containing the local audio file or an url !" self.get_logger().error(error_msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg) # Check if needed to enable data for audio streaming if self._audio_filename.startswith("http://"): self._use_wifi_connection = True elif self._audio_filename.startswith("https://"): error_msg = "Please use a non secured http format to your urls." raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg) # Check value of VOLUME parameter if self._multimedia_volume < 0 or self._multimedia_volume > 100: error_msg = "The parameter VOLUME must be an integer between 0 and 100 !" self.get_logger().error(error_msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg) # FILENAME is an url, enable wifi if self._use_wifi_connection: self._connect_to_wifi() # also set the use_artifactory parameter to false. self._use_artifactory=False # If the artifactory parameter is set, then get the file form artifactory # and set self._audio_filename to the correct file pushed on the device if self._use_artifactory: self._retrieve_file_from_artifactory() # Get audio file duration audio_file_duration = self._multimedia_api.get_media_file_duration(self._audio_filename) # Check value of DURATION parameter if self._audio_duration == "": self.get_logger().warning("The parameter DURATION is empty! The whole audio file will be played.") self._audio_duration = audio_file_duration # Add a delay to make sure the use case play whole the file self._audio_duration += 5 elif self._audio_duration <= 0: error_msg = "The parameter DURATION must be an integer strictly upper than 0 !" self.get_logger().error(error_msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg) else: if self._audio_duration > audio_file_duration: self.get_logger().warning("The parameter DURATION is upper than audio file duration ! " "The whole audio file will be played.") self._audio_duration = audio_file_duration # Add a delay to make sure the use case play whole the file self._audio_duration += 5 # Disable device lock screen self._phonesystem_api.disable_lockscreen(True) # Set phone to keep the device display on and wake it up self._phonesystem_api.display_on() self._phonesystem_api.wake_screen() return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ # Call LabMobility3gsmBase Run function LabMobility3gsmBase.run_test(self) # Initialize local variables used for Handovers ns1_vc = self._ns1_vc ns2_vc = self._ns2_vc nb_success_hand = 0 ns1_cell = self._ns1_cell ns1_data = self._ns1_data ns2_cell = self._ns2_cell ns2_data = self._ns2_data # Check Data Connection State => PDP_ACTIVE before timeout RegUtil.check_dut_data_connection_state_before_timeout( "PDP_ACTIVE", ns1_cell, self._networking_api, self._logger, self._registration_timeout, flightmode_cycle=True, blocking=False) # Check registration state is connected using # registrationTimeout from Device_Catalog.xml self._modem_api.check_cdk_registration_bfor_timeout( self._registration_timeout) # Check that DUT is registered on the good RAT self._modem_api.check_network_type_before_timeout( ns1_data.get_network_type(), self._registration_timeout) # Set cell on ns2_cell.set_cell_on() # Perform try catch in order to catch errors during the for iteration. # If this try catch isn't done here and a crash appears during the for # iteration, the Tear Down will be called without recording Use Case # verdict and maybe 1 or more succeeded handovers. try: # For iteration 0 to HANDOVER_NUMBER: while nb_success_hand != self._jump_num: # Start an ftp tranfer self._ftp_task_id = \ self._networking_api.start_ftp_xfer( self._ftp_direction, self._server_ip_address, self._server_username, self._server_password, self._ftp_filename, self._device.get_ftpdir_path()) # wait 20 seconds for ensure that transfer is established self._logger.info( "Wait 20 seconds for ensure that transfer is established") time.sleep(20) # Check that operator gave a valid Voice call number # Perform MO voice call on NS1 if self._is_phone_number_checked: if self._phone_number is None: self._logger.warning( "Operator Phone Number cannot be used to perform a voice call \ due to invalid test parameter value (Phone Number %s)" % (str( self._tc_parameters.get_param_value( "PHONE_NUMBER")))) else: self._voicecall_api.dial(self._phone_number) else: # Raise an error message as no valid phone number has been set by the operator self._error.Msg = "Phone number has no valid value (%s) so voice call can not be performed" % \ self._phone_number self._logger.error(self._error.Msg) raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, self._error.Msg) # Check call state "CONNECTED" before callSetupTimeout seconds ns1_vc.check_call_connected(self._call_setup_time, blocking=False) # Check data state "TRANSFERRING" before timeout ns1_data.check_data_connection_transferring( self._check_data_transfer_state_timeout) # Perform handover using 60 seconds timeout ns1_cell.execute_external_handover() self._logger.info("Wait 60 seconds for ensure that" + " external handover is done") time.sleep(60) # Switch NS1 and NS2 network simulators # (when the handover finishes, the roles are reversed) tmp_cell = ns1_cell tmp_data = ns1_data ns1_cell = ns2_cell ns1_data = ns2_data ns2_cell = tmp_cell ns2_data = tmp_data tmp_vc = ns1_vc ns1_vc = ns2_vc ns2_vc = tmp_vc # Check data state "TRANSFERRING" before timeout ns1_data.check_data_connection_transferring( self._check_data_transfer_state_timeout, False, blocking=False) # Check call state "CONNECTED" before timeout to validate handover ns1_vc.check_call_connected( self._check_voice_call_state_timeout, blocking=False) # Get RAT from Equipment network_type = ns1_data.get_network_type() # Check that DUT is registered on the good RAT self._modem_api.check_network_type_before_timeout( network_type, self._registration_timeout) # Increment number of succeeded handovers nb_success_hand += 1 # Stop ftp transfer self._networking_api.stop_ftp_xfer(self._ftp_task_id) # Release the voice call ns1_vc.voice_call_network_release() # End For # Catch a possible exception except TestEquipmentException as ex: msg = "The handover number %d failed " % (nb_success_hand + 1) msg += "(%d succeeded handovers on %d)." \ % (nb_success_hand, self._jump_num) self._logger.error(msg) raise TestEquipmentException( TestEquipmentException.PROHIBITIVE_BEHAVIOR, "Exception during handover process: %s (%s)" % (ex.get_error_message(), msg)) except AcsBaseException as ex: # if nb_success_hand < self._jump_num # raise an exception # else only log the error if nb_success_hand < self._jump_num: msg = "The handover number %d failed " % (nb_success_hand + 1) msg += "(%d succeeded handovers on %d)." \ % (nb_success_hand, self._jump_num) self._logger.error(msg) raise DeviceException( DeviceException.PROHIBITIVE_BEHAVIOR, "Exception during handover due to board: %s (%s)" % (ex.get_error_message(), msg)) else: # log error as a warning, but no Usecase exception # is raised because the purpose of the Usecase has been reached self._logger.warning(ex.get_error_message()) finally: # Stop ftp tranfer if an error occurs self._networking_api.stop_ftp_xfer(self._ftp_task_id) # Compute final verdict msg = "%d handovers done." % nb_success_hand return Global.SUCCESS, msg
def set_up(self): """ Initialize the test """ UseCaseBase.set_up(self) # Clear all data connections self._networking_api.clean_all_data_connections() time.sleep(self._wait_btwn_cmd) # Connect to equipment self._ns.init() # Set the equipment application format GSM/GPRS self._ns.switch_app_format("GSM/GPRS") # Perform a full preset self._ns.perform_full_preset() # Set cell off self._ns_cell_2g.set_cell_off() # Set serving cell to EGPRS self._ns_cell_2g.set_cell_service("EGPRS") # Set Frequency points using frequency list # Set Amplitude Offset correction using offset list # Turning amplitude offset state to ON self._ns.configure_amplitude_offset_table() # Set the equipment IP address 1 self._ns.set_ip4_lan_address(self._ns_IP_Lan1) # Set the equipment IP_Lan2 to the equipment self._ns.set_ip4_lan_address2(self._ns_IP_Lan2) # Set the equipment subnet mask self._ns.set_ip4_subnet_mask(self._ns_Subnet_Mask) # Set the equipment default gateway self._ns.set_ip4_default_gateway(self._ns_Default_Gateway) # Set the DUT IP address 1 self._ns_data_2g.set_dut_ip_address(1, self._ns_DUT_IP_Address) # Set the DUT DNS1 self._ns_data_2g.set_dut_primary_dns(self._ns_DNS1) # Set the DUT DNS2 self._ns_data_2g.set_dut_secondary_dns(self._ns_DNS2) # Set Cell Power using CELL_POWER parameter self._ns_cell_2g.set_cell_power(self._cell_power) # Set VOICE_CODER_RATE self._ns_voice_call_2g.set_audio_codec(self._voice_coder_rate) # Set connection type to auto self._ns_data_2g.set_connection_type("AUTO") # Set Cell Band using CELL_BAND parameter self._ns_cell_2g.set_band(self._band_name) # Set Broadcast Channel Arfcn using BCH_ARFCN parameter self._ns_cell_2g.set_bcch_arfcn(self._bch_arfcn) # Set PDTCH Arfcn using PDTCH_ARFCN parameter self._ns_cell_2g.set_pdtch_arfcn(self._pdtch_arfcn) # Set the multislot configuration self._ns_data_2g.set_multislot_config(self._multislot) # Set the downlink and uplink Modulation Coding Schema # (DL_MCS and UL_MCS) self._ns_data_2g.set_pdtch_modulation_coding_scheme( self._dl_mcs, self._ul_mcs) # Set the Puncturing Modulation Coding Schema (PS_MCS) self._ns_data_2g.set_pdtch_puncturing_scheme(self._ps_mcs) # Set DTM state to ON self._ns_cell_2g.set_dtm_state("ON") # Set cell on self._ns_cell_2g.set_cell_on() # Check Data Connection State => ATTACHED before timeout RegUtil.check_dut_data_connection_state_before_timeout( "ATTACHED", self._ns_cell_2g, self._networking_api, self._logger, self._registration_timeout) # Check registration state is connected using # registrationTimeout from Device_Catalog.xml (Non blocking # for this test if function isn't implemented on CDK) self._modem_api.check_cdk_registration_bfor_timeout( self._registration_timeout) # Get RAT from Equipment network_type = self._ns_data_2g.get_network_type() # Check that DUT is registered on the good RAT self._modem_api.check_network_type_before_timeout( network_type, self._registration_timeout) # Set the APN time.sleep(self._wait_btwn_cmd) self._logger.info("Setting APN " + str(self._apn) + "...") self._networking_api.set_apn(self._ssid, self._apn) # Activate PDP context time.sleep(self._wait_btwn_cmd) self._logger.info("Active PDP Context...") self._networking_api.activate_pdp_context(self._ssid) # Check Data Connection State => PDP Active before timeout self._ns_data_2g.check_data_connection_state( "PDP_ACTIVE", self._registration_timeout) # Check that operator gave a valid Voice call number # Perform MO voice call on active network simulator if self._phone_number is None: # Raise an error message as no valid phone number has been set by the operator self._error.Msg = "Phone number has no valid value" self._logger.error(self._error.Msg) raise AcsConfigException(AcsConfigException.PROHIBITIVE_BEHAVIOR, self._error.Msg) return Global.SUCCESS, "No errors"
def init(self, flash_input): """ Module Initialization :param flash_input: The Flash input(s) :type flash_input: str .. note:: Flash input(s) are either the blankphone;fastboot images filenames or the fastboot only When passing both blankphone and fastboot, always pass the blankphone first separated with semi-colon **/path/to/blankphone.json;/path/to/fastboot.json** :return: The initialization verdict :rtype: int """ verdict = Global.SUCCESS def update_global_config(): """ For now, pupdr_common is based on exec script Update globals with fake exec script in order to make this code retro compliant """ self._globals["EXEC_UC"] = AttributeDict() fake_tc_params = AttributeDict() fake_tc_params._attrs_override = {"TcExpectedResult": ""} fake_tc_params.get_name = lambda: "FLASH_UC" self._globals["EXEC_UC"]._tc_parameters = fake_tc_params init_ctx(self._globals, self.logger, self.global_conf) # in order to hack pupdr common update_global_config() pupdr.init(self._globals) if not flash_input: raise AcsConfigException("No flash files provided") else: self._flash_input = flash_input self._modem_flash = self.configuration.get_value( "MODEM_FLASH", True, "str_to_bool") if self._modem_flash: pupdr.TEST = "PUPDR FLASH MODULE - " else: pupdr.TEST = "PUPDR FLASH MODULE (no modem) - " self.logger.info("Flash({0})".format(flash_input)) # pupdr.FLASH_FILES = flash_input self._flash_files = flash_input.split(";") if not self._flash_files: raise AcsConfigException("Nothing to flash") else: # check all entries are present on disk and of proper format flash_file_check_passed = True for flash_file in self._flash_files: if not os.path.isfile(flash_file): flash_file_check_passed = False self.logger.error( "Flash file {0} not present on disk".format( flash_file)) if not any(flash_file_type in os.path.basename(flash_file) for flash_file_type in ("blankphone", "fastboot", "ota", "firmware", "provisioning")): # check directory name in case flash.xml is passed if not any(flash_file_type in os.path.basename( os.path.dirname(flash_file)) for flash_file_type in ("blankphone", "fastboot", "ota")): flash_file_check_passed = False self.logger.error( "Flash file {0} is neither of blankphone, " "fastboot nor ota type".format(flash_file)) if not flash_file_check_passed: raise AcsConfigException( "Flash files are not present or of bad type") self.extract_flash_file_info() # $ Deactivate MOS init pupdr.NOMOS = True pupdr.setup() self.update_device_flash_properties() return verdict
def __init__(self, tc_name, global_config): """ Constructor """ # Call LAB_EM_BASE Init function EmUsecaseBase.__init__(self, tc_name, global_config) # Read VBATT from TC parameters self._vbatt_full = float( self._tc_parameters.get_param_value("VBATT_FULL")) # Initialize flash attributes self._flash_fail = False self._flash_file_path = None self._flash_timeout = None self._flash_max_retry = None self._setup_path = None self._wpa_certificate_file = None # read the path of the fake build with fake IFWI if self._tc_parameters.get_param_value("FAKE_BUILD_PATH") != "": self._fake_build_path = self._tc_parameters.get_param_value( "FAKE_BUILD_PATH") else: raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, "missing fake build for flash") # Call ConfigsParser to parse Energy_Management self._em_targets = self._target_file.parse_energy_management_targets( "LAB_EM_SAFE_PARAMETER", 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 = 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"] = "DCP" # - USBCharger = False (removed) self.em_core_module.io_card_init_state["USBCharger"] = False # - 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 # VBATT and VUSB power supplies self.em_core_module.pwrs_vbatt = self._em.get_power_supply("BATT") self.em_core_module.pwrs_vusb = self._em.get_power_supply("USB") # - Delay to wait for scheduled commands self._scheduled_timer_1 = \ int(self._em_targets["MSIC_REGISTER_SIGNED"]["scheduled_time"]) self._scheduled_timer_2 = \ int(self._em_targets["MSIC_REGISTER_UNSIGNED"]["scheduled_time"])
def native_video_record(self, video_path, camera_name, camera, quality, flash_mode, color_effect, white_balance, dvs, noise_reduction): """ Start the video record :type video_path: str :param video_path: Path to video file to play :type camera_name: str :param camera_name: which camera app to use :type camera: str :param camera: which camera to user, could be front or back :type quality: str :param quality: quality of the record, could be high, high1080p and etc :type flash_mode: str :param flash_mode: flash mode on or off :type color_effect: str :param color_effect: which color effect to apply, could be mono, auto and etc :type white_balance: str :param white_balance: white balance setting, could be auto or etc :type dvs: str :param dvs: dvs set to true or false :type noise_reduction: str :param noise_reduction: enable noise reduction, could be on or off :rtype: String :return: The created video filename """ self._logger.info("Start video recording ...") # cleanup the record directory self._logger.info("Delete old video files") self._exec("adb shell rm " + video_path + "*.mp4 ") video_file_name = video_path + camera + "_" + quality \ + "_" + white_balance + "_" + color_effect + "_" + flash_mode \ + "_" + dvs + "_" + noise_reduction + ".mp4" # Initial values camera_id = "0" if camera == "back": camera_id = "0" elif camera == "front": camera_id = "1" else: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "camera can only be front or back") # Define intent action to use for video recording camera_launcher_intent = "adb shell am start " if camera_name == "camera": # Rename into the right camera name for google camera camera_name = "gallery3d" camera_launcher_intent += "-a %s -n %s" % \ (self._google_video_camera_action, self._google_video_camera_component) elif camera_name == "camera2": cmd = "grep camera2 /data/system/packages.list"\ "|grep -v 'tests'|grep -v 'android'|sed 's/[[:space:]]\+/ /g' |cut -d' ' -f1" camera = self._exec("adb shell %s || echo nok" % cmd) if camera != "nok": self._intel_video_camera_component = camera + "/.VideoCamera" camera_launcher_intent += "-a %s -n %s" % \ (self._intel_video_camera_action, self._intel_video_camera_component) else: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Unknown camera name '%s' !" % camera_name) # create a global conf file self._logger.info("Create camera preference files ...") config_path = "/data/data/com.android." + camera_name + "/shared_prefs/" global_config_file_name = \ "com.android." + camera_name + "_preferences.xml" camera_config_file_name = \ "com.android." + camera_name + "_preferences_" + camera_id + ".xml" global_conf = etree.Element('map') etree.ElementTree(global_conf) etree.SubElement(global_conf, 'string', name='pref_camera_recordlocation_key').text = "1" etree.SubElement(global_conf, 'string', name='pref_camera_jpegquality_key').text = "superfine" etree.SubElement(global_conf, 'string', name='pref_camera_id_key').text = camera_id etree.SubElement(global_conf, 'boolean', name='has-editor-image/*', value="true") etree.SubElement(global_conf, 'boolean', name='pref_camera_first_use_hint_shown_key', value="false") etree.SubElement(global_conf, 'boolean', name='pref_video_first_use_hint_shown_key', value="false") etree.SubElement(global_conf, 'int', name='pref_version_key', value=self._video_camera_pref_version_key) etree.SubElement(global_conf, 'int', name='cache-up-to-date', value="1") etree.SubElement(global_conf, 'int', name='editor-update-image/*', value="1") app_conf_file = open(global_config_file_name, "w") app_conf_file.writelines(etree.tostring(global_conf, pretty_print=True, xml_declaration=True, encoding='utf-8')) app_conf_file.close() # Change quality to DUT "language", now in default camera # there is only 3 options, can add more else here if more options been add in this camera if quality == "1080p": qual_key = "6" elif quality == "720p": qual_key = "5" elif quality == "480p": qual_key = "4" else: qual_key = quality camera_conf = etree.Element('map') etree.ElementTree(camera_conf) etree.SubElement(camera_conf, 'int', name='pref_local_version_key', value="2") if camera_id == "0": etree.SubElement(camera_conf, 'string', name='pref_camera_whitebalance_key').text = white_balance etree.SubElement(camera_conf, 'string', name='pref_camera_video_flashmode_key').text = flash_mode etree.SubElement(camera_conf, 'string', name='pref_video_quality_key').text = qual_key etree.SubElement(camera_conf, 'string', name='pref_camera_temporal_noise_reduction_key').text = noise_reduction etree.SubElement(camera_conf, 'string', name='pref_camera_coloreffect_key').text = color_effect etree.SubElement(camera_conf, 'string', name='pref_camera_picturesize_key').text = "3264x2448" etree.SubElement(camera_conf, 'string', name='pref_camera_dvs_key').text = dvs else: etree.SubElement(camera_conf, 'string', name='pref_camera_antibanding_key').text = "50hz" etree.SubElement(camera_conf, 'string', name='pref_video_quality_key').text = quality etree.SubElement(camera_conf, 'string', name='pref_camera_picturesize_key').text = "1280x960" camera_conf_file = open(camera_config_file_name, "w") camera_conf_file.writelines(etree.tostring(camera_conf, pretty_print=True, xml_declaration=True, encoding='utf-8')) camera_conf_file.close() # push it to phone self._logger.info("Upload preference files ...") self._device.push(global_config_file_name, os.path.join(config_path, global_config_file_name), 1000) self._device.push(camera_config_file_name, os.path.join(config_path, camera_config_file_name), 1000) try: os.unlink(global_config_file_name) os.unlink(camera_config_file_name) except (IOError, OSError): self._logger.exception("Exception while deleting files: `{0}` & `{1}`".format(global_config_file_name, camera_config_file_name)) time.sleep(1) # am start the video camera self._logger.info("Launch camera %s ..." % str(camera_name)) self._exec(camera_launcher_intent) time.sleep(1) # start the recording by pressing the camera key self._logger.info("Start recording ...") self._exec("adb shell input keyevent 27") return video_file_name
def _check_flash_files(self, flash_file_list): """ Check flash file compatibility with flash tool :type flash_file_list: list :param flash_file_list: list of flash file (absolute paths) :rtype: list :return: list of valid flash file (absolute paths) for current flash tool """ fte2_flash_files_arg = "" if len(flash_file_list) > 1: for flash_file in flash_file_list: if os.path.isfile(flash_file): filename, file_extension = os.path.splitext(flash_file) if ".fls" in file_extension.lower(): if not os.path.isfile(flash_file): err_msg = "FTE2: Flash file %s not found !" % ( str(flash_file)) self._logger.error(err_msg) raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, err_msg) # Build a single arg line with all files fte2_flash_files_arg += flash_file + " " else: err_msg = "FTE2: No suitable flash file %s (.fls list or single zip file should be used)" % \ str(flash_file) raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, err_msg) else: err_msg = "FTE2: flash file %s does not exist: %s" % str( flash_file) raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, err_msg) elif len(flash_file_list) == 1: # If only one file given, should be a zip flash_file = flash_file_list[0] filename, file_extension = os.path.splitext(flash_file) if ".zip" in file_extension.lower(): self._logger.debug("FTE2: Checking integrity of flash file") file_ok = self.__check_zip_file_integrity(flash_file) if not os.path.isfile(flash_file) or not file_ok: err_msg = "FTE2: Flash file archive %s not found or corrupted !" % ( str(flash_file)) self._logger.error(err_msg) raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, err_msg) # Build a list of fls files to flash from zip file given self._logger.debug( "FTE2: Building files list from zip archive") fte2_flash_files_arg = self.__build_list_from_zip(flash_file) else: err_msg = "FTE2: No suitable flash file %s (.fls list or zip file should be used)" % str( flash_file) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, err_msg) else: err_msg = "FTE2: No file to flash" raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, err_msg) return fte2_flash_files_arg