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 _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 """ fastbootcmds_flash_file_list = [] if len(flash_file_list) > 0: for flash_file in flash_file_list: _, fileExtension = os.path.splitext(flash_file) if os.path.isfile(flash_file) and (fileExtension.lower() == ".xml"): self._logger.info("FastbootTool: Flash file %s exists" % str(flash_file)) fastbootcmds_flash_file_list.append(flash_file) else: err_msg = "FastbootTool: No suitable flash file (.xml file should be used) or " + \ "flash file does not exist: %s" % str(flash_file) self._logger.error(err_msg) raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, err_msg) else: err_msg = "FastbootTool: No file to flash" self._logger.error(err_msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, err_msg) return fastbootcmds_flash_file_list
def set_up(self): """ Initialize the test. """ # Run UC base run_test UseCaseBase.set_up(self) # Check the send command before going any further if self._cmd_str is None: message = "Invalid parameter value: %s for parameter '%s'." % (str( self._cmd_str), "RUN_CMD") self._logger.error(message) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, message) # Check the expected result str before going any further if self._expected_result is None: message = "Invalid parameter value: %s for parameter '%s'." % (str( self._expected_result), "EXPECTED_RESULT") self._logger.error(message) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, message) # Check the test execution timeout before going any further if self._test_timeout is None: message = "Invalid parameter value: %s for parameter '%s'." % (str( self._test_timeout), "EXECUTION_TIMEOUT") self._logger.error(message) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, message) # Return the status return Global.SUCCESS, "No error."
def __init__(self, tc_name, global_config): """ Constructor """ LiveBTBase.__init__(self, tc_name, global_config) # Get TC Parameters # Read DEVICE_BT_ADDRESS from test case xml file or BenchConfig self._device_to_search = \ str(self._tc_parameters.get_param_value("DEVICE_TO_SEARCH")) if self._device_to_search.lower() in ["none", ""]: # Then search for the BT MAC address into the BenchConfig bench_bt_device = global_config.benchConfig\ .get_parameters("BT_DEVICE") if bench_bt_device is not None: if str(bench_bt_device.get_param_value("MacAddress")).lower()\ not in ["none", "", "00:00:00:00:00:00"]: self._device_to_search = str( bench_bt_device.get_param_value("MacAddress")) else: msg = "No BD addr defined in the TC and/or in bench_config" self._logger.error(msg) raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, msg) else: msg = "No BD address defined in the TC and/or in bench_config" self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
def _set_up(self): """ Initialize the test """ # Checking parameters data if self._first_freq is None or (self._channel.isdigit() and int(self._channel) == 0): msg = "First frequency not found." self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if self._second_freq is None or (self._second_channel.isdigit() and int(self._second_channel) == 0): msg = "Second frequency not found." self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if self._nbr_beacon_to_wait.lower() in ["", "none"]: msg = "NBR_BEACON_TO_WAIT parameter missing or set to none." self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) if self._dfs_mode.lower() in ["on", "enabled", "1"]: self._dfs_mode = "enable" else: msg = "_dfs_mode parameter missing or set to none." self._dfs_mode = "disable" self._logger.warning(msg) if self._beacon is None: self._beacon = self._ns.get_beacon_period() self._networking_api.set_autoconnect_mode(self._ssid, AUTO_CONNECT_STATE.on) # pylint: disable=E1101
def __load_event(self, event, rawevent): """ Load a single event in the dictionary """ cmd = "" for line in rawevent.splitlines(): data = line.split(" ") if len(data) == 0: continue if len(data) != 3: raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, "Bad format of action : '%s'" % str(data)) try: key = int(data[0], 16) action = int(data[1], 16) value = int(data[2], 16) except ValueError as exp: raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, "Bad format of action : '%s' (%s)" % (str(data), str(exp))) cmd = "%ssendevent %s %d %d %d\n" % ( cmd, self._touch_screen_event_file, key, action, value) self.__events[event] = cmd
def set_up(self): """ Initialize the test """ # Call UseCase base Setup function UseCaseBase.set_up(self) # Open camera self.__camera_api.launch_camera(self.__camera) time.sleep(self._wait_btwn_cmd) # Check save directory if self.__save_directory is None: error_msg = "Save directory is not set, please update the TC" self.get_logger().error(error_msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg) # check camera flash mode if self.__camera_flash_mode is None: error_msg = "Flash mode is not set, please update the TC" self.get_logger().error(error_msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg) # take picture without flash ref_picture_file = self.__camera_api.take_picture(self.__save_directory) time.sleep(self._wait_btwn_cmd) # download picture taken from the DUT self.__local_ref_picture_file = self.__camera_api.download_media_file(ref_picture_file, self.__save_folder) time.sleep(self._wait_btwn_cmd) return (Global.SUCCESS, "No errors")
def parse_campaign(self, campaign_file): """ Parses the given C{GTester} campaign file and updates the C{commands} property. :type campaign_file: str :param campaign_file: the path to the campaign_file """ # Initialize a variable that will hold all the # lines from the campaign file. command_lines = None try: # Open the file in read mode with open(campaign_file, 'r') as file_object: # As the GTester campaign files are rather small, # we can allow ourselves to store all the lines # of the file at the same time in a variable without # risking memory issues. command_lines = file_object.readlines() # Catch possible IO Error except IOError as io_error: message = "I/O error({0}): {1}".format(io_error.errno, io_error.strerror) raise AcsConfigException(AcsConfigException.OPERATION_FAILED, message) # Catch other kind of error/exceptions # (errors/exceptions possibly raised by 'realines' are not documented) except: raise AcsConfigException( AcsConfigException.OPERATION_FAILED, "Could not parse the campaign file (%s)." % str(campaign_file)) # Parse the retrieved lines self.parse_lines(command_lines)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ BtBase.run(self, context) if not isinstance(self._pars.timeout, int): msg = "Error parameter TIMEOUT is not integer : %s" % str( type(self._pars.timeout)) self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) full_path = posixpath.join(self._device.multimedia_path, self._pars.filename) if self._pars.action_control == "START_PLAYER": self._api.start_a2dp_media_player(full_path, self._pars.timeout) elif self._pars.action_control == "STOP_PLAYER": self._api.stop_a2dp_media_player() elif self._pars.action_control in [ "PLAY", "PAUSE", "STOP", "NEXT_TRACK", "PREVIOUS_TRACK", "VOLUMEDOWN", "VOLUMEUP" ]: self._api.control_a2dp_media_player(self._pars.action_control) else: msg = "Error parameter ACTION_CONTROL is unknown : %s" % str( self._pars.action_control) self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
def setup(self, flash_mode, screen_mode, camera_name): """ set camera preferences @type flash_mode: string @param flash_mode: mode of flash (on, off or auto) @type screen_mode: string @param screen_mode: mode of screen (WideScreen or Standard) @type camera_name: string @param camera_name: name of the camera """ self._logger.info("Camera setup begin") if camera_name not in ("camera2", "camera"): self._logger.error("Invalid camera name:%s" % camera_name) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Wrong camera app name") self._logger.info("Flash Mode is set to is %s" % flash_mode) self._logger.info("Screen mode is set to %s" % screen_mode) self._get_camera_name(camera_name) if (self.__camera_name is None) or (self.__camera_name == ""): msg_str = "There is no camera name, probably no camera app neither. Please, check both" raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg_str) self.__flash_mode = flash_mode self.__screen_mode = screen_mode self.__configure() self._logger.info("Camera setup end")
def toggle_burst_mode(self): """ """ if self.touchCmds is None: self._logger.error( "Display resolution {0}x{1} is not supported.".format( self.disp_width, self.disp_height)) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Display resolution is not supported.") if self.camera_package == "com.intel.camera22": self._keyevent_api.tap_on_screen( self.touchCmds['select_options'][0], self.touchCmds['select_options'][1]) time.sleep(2) self._keyevent_api.tap_on_screen(self.touchCmds['select_burst'][0], self.touchCmds['select_burst'][1]) time.sleep(2) self._keyevent_api.tap_on_screen( self.touchCmds['select_fast_type'][0], self.touchCmds['select_fast_type'][1]) time.sleep(2) else: self._logger.error( "Selected camera app, {0}, is not supported.".format( self.camera_app)) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "Selected camera_app is not supported. ")
def start(self): """ Start application """ test_dic = self.__test_dic[self.__version] if self._arguments not in test_dic.keys(): raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, "Test %s not in dictionnary for %s" % (self._arguments, self.__version)) self.__test_name = test_dic[self._arguments] if self.__version == "glbenchmark21": self.__drive_version = self.__drive21 elif self.__version == "glbenchmark27": self.__drive_version = self.__drive27 elif self.__version == "glbenchmark25": self.__drive_version = self.__drive25 else: raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, "%s version is not supported in ACS" % self.__version) if "pro" in self.__test_name.lower(): self.__regex_test_result = "Pro:\s*\d*\s*frames\s*\((?P<result>[\d*.]*)\s*FPS\)" IAndroidPackage.start(self)
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 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_data_connection = True else: # To prevent b2b iterations self._use_data_connection = False # 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 data connection if self._use_data_connection: self._enable_data_connection() # 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 set_up(self): """ Initialize the test """ LabHspaBase.set_up(self) if self._ftp_direction not in ["UL", "DL"]: self._error.Msg = "%s is not a known xfer direction" % self._ftp_direction raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, self._error.Msg) if self._measurement_duration is None: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "MEASUREMENT_DURATION should be int") if self._xfer_timeout is None: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "XFER_TIMEOUT should be int") if self._call_duration is None: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "CALL_DURATION should be int") if (self._measurement_duration + self._wait_time_before_measure) > self._call_duration: raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, "call_duration should be always greater than" "MEASUREMENT_DURATION+%d (measurement start after %d seconds ftp starts)" % (self._wait_time_before_measure, self._wait_time_before_measure)) return Global.SUCCESS, self._error.Msg
def set_up(self): """ Initialize the test """ LabWifiBase.set_up(self) # Control testcase parameter if str(self._time2wait).isdigit(): self._time2wait = int(self._time2wait) else: msg = "TIME_BETWEEN_TESTS is missing or wrong: %s" \ % str(self._time2wait) self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # Control that the security is not OPEN if str(self._security).upper() in ["NONE", "OPEN"]: msg = "WIFI_SECURITY UseCase parameter should not be " + \ "undefined nor OPEN: %s" % str(self._security) self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # Generate a corrupted passphrase if self._security == "EAP-WPA" or self._security == "EAP-WPA2": self._wrong_passphrase = self._eap_method + "-" \ + self._phase2_auth + "_" + self._corrupt(self._eap_user) \ + "_" + self._corrupt(self._eap_password) + "_" \ + self._corrupt(self._certificat_name) + "_" \ + str(self._mandatory_cert) else: self._wrong_passphrase = self._corrupt(self._passphrase) return Global.SUCCESS, "No errors"
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ self._logger.info(self._pars.id + ": Run") if self._file_type == "MP4": option_file_type = "video/mp4" elif self._file_type == "3GP": option_file_type = "video/3gp" elif self._file_type == "ALL": option_file_type = "video/*" elif self._file_type is None: err_msg = "No File type specified" raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, err_msg) else: err_msg = "File type unsupported" raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, err_msg) # Play Music cmd = 'adb shell am start -a android.intent.action.VIEW -d ' \ 'file://' + str(self._file_path) + ' -t ' + str(option_file_type) (status, output) = self._device.run_cmd(cmd, 50) if status != Global.SUCCESS: self._logger.error(output) raise DeviceException(DeviceException.OPERATION_FAILED, output)
def set_up(self): """ Validating the test parameters. """ # Calling Base Class SetUp method LiveDualPhoneVcBase.set_up(self) # Checking phone Idle State parameter if not self._screen_state: message = "%s '%s' %s '%s'" % ( "Invalid parameter value (or missing parameter)", str(self._screen_state), "for parameter", "STATE") raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, message) # Check the MT call Test Scenario parameter ''' Possible values for scenario defined: CALL_IDLE_SCREEN, DL_AFT_ANS, DL_BEF_ANS, DR_AFT_ANS, DR_BEF_ANS ''' if not self._action: message = "%s '%s' %s '%s'" % ( "Invalid parameter value (or missing parameter)", str(self._action), "for parameter", "ACTION") raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, message) return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test: """ EmUsecaseBase.set_up(self) # Call ConfigsParser to parse Energy_Management self._em_targets = self._target_file.parse_energy_management_targets( "LAB_EM_PS_TURN_OFF_DURING_BOOT", 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) # check parameter turn off way if self._turn_off_way not in ["HARDWARE_SHUTDOWN", "EMERGENCY_SHUTDOWN", "BATTERY_REMOVAL"]: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "The parameter TURN_OFF_WAY '%s' is not a valid way to turn off the board" % self._turn_off_way) # check parameter first turn off timing if self._first_turn_off_timing > 45: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, "The parameter FIRST_TURN_OFF_TIMING '%s'" % self._first_turn_off_timing + " shall be under 45s or the test will be done after booting") return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test. """ # Run UC base set_up step UseCaseBase.set_up(self) # Check the duration before going any further if self._duration is None: message = "Invalid parameter value: %s for parameter '%s'." % (str( self._duration), "DURATION") self._logger.error(message) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, message) # Check the time where to control IPC residency before going any further if self._time_period is None: message = "Invalid parameter value: %s for parameter '%s'." % (str( self._time_period), "TIME_PERIOD") self._logger.error(message) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, message) # Check target percentage of time period where to control IPC residency before going any further if self._target_rate is None: message = "Invalid parameter value: %s for parameter '%s'." % (str( self._target_rate), "TARGET_RATE") self._logger.error(message) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, message) self._initial_screen_timeout = self._phonesystem_api.get_screen_timeout( ) return Global.SUCCESS, "No error"
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ TestStepBase.run(self, context) inputs = context.get_info(self._pars.input) for input in inputs: values = numpy.array(input).astype(numpy.float) if self._pars.method: if self._pars.method.lower() == "median": context.set_info(self._pars.result, numpy.median(values)) elif self._pars.method.lower() == "average": context.set_info(self._pars.result, numpy.average(values)) elif self._pars.method.lower() == "max": context.set_info(self._pars.result, numpy.max(values)) elif self._pars.method.lower() == "min": context.set_info(self._pars.result, numpy.min(values)) else: raise AcsConfigException( AcsConfigException.READ_PARAMETER_ERROR, "Compute method not known") else: raise AcsConfigException(AcsConfigException.READ_PARAMETER_ERROR, "Method parameter has to be set")
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ TestStepBase.run(self, context) self._logger.info("PlayAudioOnHost: Run") audio_file_path = self._pars.audio_file_path duration = self._pars.duration self._logger.info(duration) # Check if audio file path is valid if not os.path.isfile(audio_file_path): msg = "Audio file not found: " + audio_file_path raise AcsConfigException(AcsConfigException.OPERATION_FAILED, msg) # Check if wav file if not audio_file_path.lower().endswith('.wav'): msg = "Please use a PCM encoded WAV file" raise AcsConfigException(AcsConfigException.OPERATION_FAILED, msg) self._audio_host_api.pc_audio_playback_start(audio_file_path, None, True) # Play duration in seconds time.sleep(duration) self._audio_host_api.pc_audio_playback_stop() self._logger.info("PlayAudioOnHost: Done")
def initialize_local_profile(self, phone_sip_address, password=None): """ Initialize local profile :type phone_sip_address: str :param phone_sip_address: sip account name with server address in 'sip_account_name@sip_server' format :return: None :raise: AcsConfigException """ # Check phone_sip_address in correctly format phone_sip_address_split = re.split('\@', phone_sip_address) if len(phone_sip_address_split) != 2: raise AcsConfigException(AcsConfigException.OPERATION_FAILED, "Phone SIP address is not in user_name@sip_server format") if phone_sip_address_split[0] == "": raise AcsConfigException(AcsConfigException.OPERATION_FAILED, "Not user name in phone SIP address") if phone_sip_address_split[1] == "": raise AcsConfigException(AcsConfigException.OPERATION_FAILED, "Not sip server name in phone SIP address") sip_user_name = phone_sip_address_split[0] sip_server = phone_sip_address_split[1] self._logger.info("Set local SIP profile with %s address", phone_sip_address) function = "setLocalProfile" cmd_args = " --es sipUserName %s --es sipDomainServer %s" \ % (sip_user_name, sip_server) if password: cmd_args += " --es sipPassword %s" % password self._internal_exec_v2(self._sipcall_module, function, cmd_args, is_system=True)
def _check_flash_tool_availability(self): """ Check if Dediprog Flash Tool is installed over current ACS bench :rtype: str :return: string containing flash tool name to use for flash execution """ cmd_name = "" # Check the dediprog flash tool installation over ACS bench if platform.system() == "Windows": cmd_name = "dpcmd" else: cmd_name = "flashrom" flash_tool_cmd_path = CommandLine.which(cmd_name) if flash_tool_cmd_path is None: error_msg = "DEDIPROG: Check if DEDIPROG is installed on ACS bench (Command %s not found !)" % cmd_name if platform.system() == "Windows": error_msg += " - Check also if DEDIPROG folder is referenced on ACS bench in PATH environment variable" self._logger.error(error_msg) raise AcsConfigException(AcsConfigException.EXTERNAL_LIBRARY_ERROR, error_msg) else: # DEDIPROG software is installed try: # Try to launch DEDIPROG flash tool # Analyze for LINUX and WINDOWS, return code to see if DEDIPROG flash tool is launchable if platform.system() == "Windows": cmd = cmd_name + " -d" else: cmd = cmd_name + " --version" return_code, return_message = internal_shell_exec( cmd, 1, silent_mode=True) except Exception as ex: err_msg = "DEDIPROG: Flash tool (%s) execution issue over ACS bench - error: %s" % ( cmd, str(ex)) self._logger.error(err_msg) raise AcsConfigException( AcsConfigException.EXTERNAL_LIBRARY_ERROR, err_msg) if return_code == 0: # DEDIPROG flash tool is installed and available # Print the flash tool version self._logger.info( "DEDIPROG: Flash tool is installed and running over ACS bench - version : %s" % str(return_message)) else: # DEDIPROG flash tool issue when launching it err_msg = "DEDIPROG: Flash tool (command= %s) execution issue over ACS bench - " % (cmd) + \ " - error: %s" % (str(return_message)) self._logger.error(err_msg) raise AcsConfigException( AcsConfigException.EXTERNAL_LIBRARY_ERROR, err_msg) return cmd_name
def _extract_flash_file(self, flash_file): """ Extract flash file path to use with flash tools :type flash_file: str :param flash_file: path to flash file given by user :rtype: str :return: flash file path to use with flash tools """ # Check we have the correct flash file entry point for ACS filename, file_extension = os.path.splitext(flash_file) # First unzip flash file if needed if zipfile.is_zipfile(flash_file): try: zip_file = zipfile.ZipFile(flash_file, "r") self._logger.info("FlashManager: unzip flash file (%s)" % flash_file) zip_file.extractall(filename) zip_file.close() flash_file_to_use = flash_file except Exception as ex: err_msg = "FlashManager: 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("FlashManager: untar flash file (%s)" % flash_file) tar_file.extractall(filename) tar_file.close() flash_file_to_use = flash_file except Exception as ex: err_msg = "FlashManager: Flash input file %s, untar issue, error : %s" % ( flash_file, str(ex)) self._logger.error(err_msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, err_msg) elif file_extension.lower() == ".xml" or file_extension.lower( ) == ".bin": if os.path.isfile(flash_file): self._logger.info("FlashManager: Flash file %s exists" % flash_file) flash_file_to_use = flash_file else: err_msg = "FlashManager: Flash file %s not found!" % flash_file self._logger.error(err_msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, err_msg) else: err_msg = "FlashManager: Flash file %s format is not suitable (.xml, .bin or .zip file should be used)" \ % str(flash_file) self._logger.error(err_msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, err_msg) return flash_file_to_use
def set_up(self): """ Initialize the test """ # Call UseCase base Setup function UseCaseBase.set_up(self) # Check record duration if self.__record_duration <= 0: error_msg = "Please update TC and set a record duration that is > 0 milliseconds" raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg) # Check save directory if self.__save_directory in (None, ""): error_msg = "Please update TC and set a saving directory" raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg) # Open camera self.__camera_api.launch_camera(self.__camera) time.sleep(self._wait_btwn_cmd) self.__camera_opened = True return (Global.SUCCESS, "No errors")
def _provide_ipc_box_acces_rights(self): """ Grant access rights in 2 folders of the device under test where the IPCbox tool files will be pushed. :raises AcsConfigException: In case one of the access rights adb commands will fail an exception will be raised. """ # Installing IPC tool on the device under test # Assign executable rights to /system/bin folder (response, output) = self._device.run_cmd("adb shell chmod 777 /system/bin/*", self._test_timeout, force_execution=True) # Check if the adb command was properly sent if output <> "": self._logger.error( "The adb command for guaranteeing access rights failed") raise AcsConfigException( AcsConfigException.OPERATION_FAILED, "The adb command for guaranteeing access rights failed") # Assign executable rights to /etc/ipcbox folder (response, output) = self._device.run_cmd("adb shell chmod 777 /etc/ipcbox/*", self._test_timeout, force_execution=True) if output <> "": self._logger.error( "The adb command for guaranteeing access rights failed") raise AcsConfigException( AcsConfigException.OPERATION_FAILED, "The adb command for guaranteeing access rights failed")
def drive(self): """ Drive the application """ self._logger.info("++ drive") cmd = "rm -rf %s" % self.result_file_name self.adb_shell(cmd, 2) # To show the list of Icestorm tests command = ["DPAD_DOWN", "ENTER"] self._keyevent.scenario(command, 2.0) time.sleep(1) test_to_run = self._arguments time.sleep(5) if len(test_to_run) == 0: msg = "TC ARGUMENTS value is empty.(Possible values are : RUN_UNLIMITED, RUN_EXTREME, RUN_ICESTORM)" raise AcsConfigException(msg) time.sleep(5) if test_to_run == "RUN_EXTREME": command = ["DPAD_DOWN", "DPAD_DOWN", "ENTER"] self._keyevent.scenario(command, 2.0) elif test_to_run == "RUN_UNLIMITED": command = ["DPAD_DOWN", "ENTER"] self._keyevent.scenario(command, 2.0) elif test_to_run == "RUN_ICESTORM": command = ["DPAD_DOWN", "DPAD_DOWN", "DPAD_DOWN", "ENTER"] self._keyevent.scenario(command, 2.0) else: msg = "TC ARGUMENTS value is invalid.(Possible values are : RUN_UNLIMITED, RUN_EXTREME, RUN_ICESTORM)" raise AcsConfigException(msg)
def _check_flash_tools(self): """ Check the different flash tools availability """ if self._allow_flashing_bios: # We want to flash device bios if self._bios_flash_tool in self.BIOS_FLASH_TOOL_LIST.iterkeys(): # bios flash tool is supported by ACS FlashManager # Create bios_flash_tool instance # Set a correct voltage value for dediprog # For the moment, DEDIPROG is the only available Bios Flash Tool, voltage value is mandatory self._biosFlashObject = self.BIOS_FLASH_TOOL_LIST[self._bios_flash_tool](self._logger, self._voltage) else: raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, "FlashManager: BIOS flash (%s) " "tool not supported by ACS" % self._bios_flash_tool) # if BIOS flash tool present when bios flashing requested or no bios flashing requested # => Test OS flash tool presence if self._os_flash_tool in self.OS_FLASH_TOOL_LIST.iterkeys(): # os flash tool is supported by ACS FlashManager # Create os_flash_tool instance self._osFlashObject = self.OS_FLASH_TOOL_LIST[self._os_flash_tool](self._logger) # Update flash_user_data attribute with information from module self._osFlashObject.flash_user_data = self._flash_user_data self._osFlashObject.flash_options = self._flash_options else: raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, "FlashManager: OS flash tool (%s) not supported by ACS" % self._os_flash_tool)
def get_param_value(self, key, default_value=None, attribute="value"): """ Returns the value associated to a given key. If key isn't present, raise an AcsConfigException. :type key: string :param key: parameter's name. :type default_value: String :param default_value: Default value if parameter is not present :type attribute: String :param attribute: the key attribute where the value is read from, by default it will read "value" attribute :rtype: string :return: parameter's value. """ try: param = None param = self.__dict[key] return param[attribute] except Exception: # pylint: disable=W0703 if default_value is not None: return default_value elif param is None: raise AcsConfigException( AcsConfigException.DATA_STORAGE_ERROR, "Bad parameter's name (%s)." % (str(key))) else: raise AcsConfigException( AcsConfigException.DATA_STORAGE_ERROR, "No attribute [%s] value found for parameter %s." % (str(attribute), str(key)))