def set_up(self): """ Initialize the test """ LiveWifiBase.set_up(self) if str(self._expected_connection_time).upper() in ["NONE", "", "0", "NO"]: self._monitor_connection_time = False elif str(self._expected_connection_time).isdigit() and int(self._expected_connection_time) > 0: self._monitor_connection_time = True self._expected_connection_time = int(self._expected_connection_time) else: msg = "Wrong parameter for REF_CONNECTION_TIME: read value %s" % str(self._expected_connection_time) self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # Update back to back iteration and the wifi connection time list if self._monitor_connection_time: msg = "DUT connected in %d seconds" % self._connection_time self._logger.info(msg) self._current_iteration_num += 1 if self._connection_time != -1: self._connection_time_list.append(self._connection_time) else: self._logger.warning("unable to measure connection time") return Global.SUCCESS, "No errors"
def __init__(self, tc_name, global_config): """ Constructor """ # Call LiveBTBase init function LiveBTBase.__init__(self, tc_name, global_config) LiveWifiBase.__init__(self, tc_name, global_config) self._audio_file = str(self._tc_parameters.get_param_value("AUDIO_FILE")) self._duration = str(self._tc_parameters.get_param_value("DURATION")) self._a2dp_activity = str(self._tc_parameters.get_param_value("A2DP_ACTIVITY")).upper() self._wifi_activity = str(self._tc_parameters.get_param_value("WIFI_ACTIVITY")).upper() if self._wifi_activity == "WIFI_WEB_BROWSING": self._wifi_url = str(self._tc_parameters.get_param_value("URL_TO_BROWSE")) elif self._wifi_activity == "WIFI_FTP_DOWNLOAD": self._ftp_remote_file = str(self._tc_parameters.get_param_value("FTP_REMOTE_FILE")) self._timeout = 300 self._bt_headset = self._em.get_bluetooth_headset("BT_HEADSET") self._bt_headset_addr = None self._thread_wifi_activity = None self._thread_a2dp_activity = None self._queue = Queue.Queue()
def run_test(self): """ Execute the CTS test Compute result based on CTS xml result output :rtype: tuple :return: ACS verdict and msg output """ LiveWifiBase.run_test(self) cts_results = {} result = Global.SUCCESS for test_cmd_line in self._test_cmd_lines.split(";"): test_cmd_line = "%s %s" % (self._cts_exec_path, test_cmd_line.strip()) result, output = internal_shell_exec(test_cmd_line, self._test_timeout) # pylint: disable=W0212 if result != Global.SUCCESS: return Global.FAILURE, output else: self._logger.debug("CTS - run_test completed") for root, _, filenames in os.walk(self._cts_path): for file_ in filenames: if CTS_RESULT_FILENAME in file_: cts_results = self._extract_cts_results_from_cts_report(os.path.join(root, file_), cts_results, publishInExternalReport=True) acs_cts_results = os.path.join(self._device.get_report_tree().get_report_path(), "cts_results") if not os.path.exists(acs_cts_results): os.makedirs(acs_cts_results) self._logger.info("Move CTS results into ACS result dir") shutil.move(root, acs_cts_results) result, output = self._compute_cts_results(cts_results) return result, output
def tear_down(self): """ Finish the test and clear environment """ # Call LiveWifiBase tear_down function LiveWifiBase.tear_down(self) # Stop audio a2dp_switch_music_state(self._bt_api, self._bt_headset, BtAudioCmd.STOP) # Unpair device from BT Headset a2dp_unpair_headset(self._bt_api, self._bt_headset) # Clear OPP transfer opp_terminate(self._device, self._phone2) # Turn Off BT Adapters self._bt_api.set_bt_power(0) self._bt_api2.set_bt_power(0) # Delete sent file if self._dut_state == "DUT_CLIENT": self._bt_api2.bt_opp_init(self._opp_local_file) else: self._bt_api.bt_opp_init(self._opp_local_file) return Global.SUCCESS, "No errors"
def __init__(self, tc_name, global_config): """ Constructor """ LiveWifiBase.__init__(self, tc_name, global_config) # Get TC Parameters self._packetsize = \ int(self._tc_parameters.get_param_value("PACKET_SIZE")) self._count = int(self._tc_parameters.get_param_value("PACKET_COUNT")) self._target_ping_packet_loss_rate = \ float(self._tc_parameters.get_param_value("TARGET_PACKET_LOSS_RATE")) self._connection_time_list = list() self._current_iteration_num = 0 self._expected_connection_time = str(self._tc_parameters.get_param_value("REF_CONNECTION_TIME")) self._tolerance = str(self._tc_parameters.get_param_value("TOLERANCE")) if re.match(r'\d+\.?\d*', self._tolerance) is not None: self._tolerance = float(self._tolerance) / 100 else: self._tolerance = self.DEFAULT_TOLERANCE self._logger.warning("Tolerance not found, set to default value") self._logger.debug("Tolerance set to %2.2f%%" % (self._tolerance * 100))
def __init__(self, tc_name, global_config): """ Constructor """ LiveWifiBase.__init__(self, tc_name, global_config) self._disconnected = False self._unplugged = False self._test_usb_disconnect = str_to_bool_ex(self._tc_parameters.get_param_value("TEST_USB_DISCONNECT"))
def __init__(self, tc_name, global_config): """ Constructor """ # Call LiveBTBase init function LiveBTBase.__init__(self, tc_name, global_config) LiveWifiBase.__init__(self, tc_name, global_config) self._wifi_ip = self._wifirouter.get_param_value("IP") self._bt_headset = self._em.get_bluetooth_headset("BT_HEADSET")
def tear_down(self): """ End and dispose the test """ LiveWifiBase.tear_down(self) # Set the screen timeout to default time.sleep(self._wait_btwn_cmd) self._phonesystem_api.set_screen_timeout(self._current_screen_timeout) return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ LiveBTBase.set_up(self) LiveWifiBase.set_up(self) # Connect BT to Headset a2dp_pair_connect_to_headset(self._bt_api, self._bt_headset) return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ LiveWifiBase.run_test(self) seq_string = "" #Take a screenshot and pull on host self._screenshot_path = self._image_api.take_screenshot_and_pull_on_host( self._image_filename, os.getcwd()) self._screenshot_state = True #Launch record on host self._audio_recorder_api.pc_audio_record_start( self._host_record_file, self._host_record_device) self._flag_record = True #Tap on play button self._logger.info("Play the video...") self._image_api.touch_template_on_screen( self._screenshot_path, self._dic_image[self._play_picture]) self._logger.info("Waiting for the audio to complete...") time.sleep(self._length + self._wait_btwn_cmd) #Stop record self._audio_recorder_api.pc_audio_record_stop() self._logger.info("Audio record saved at " + self._host_record_file) self._flag_record = False self._logger.info("Apply FFT on WAV file for extract frequency.") freq = AudioCheck.fft_on_wav_file(self._host_record_file) self._logger.info( "Replace remarkable frequency by note and extract sequence.") seq = AudioCheck.extract_sequence(freq) #Create str with sequence for i in seq: seq_string = seq_string + i + " " if self._sequence in seq_string: verdict = Global.SUCCESS msg = "No errors" else: verdict = Global.FAILURE msg = "Play and record sound are not identical." return verdict, msg
def run_test(self): """ Execute the test """ # Call LIVE_WIFI_BASE Run function LiveWifiBase.run_test(self) time.sleep(self._wait_btwn_cmd) # Run Iperf command throughput = self._networking_api.iperf(self._iperf_settings) # Compute verdict depending on throughputs return compute_iperf_verdict(throughput, self._throughput_targets, self._direction)
def tear_down(self): """ End and dispose the test :rtype: tuple :return: ACS verdict and msg output """ LiveWifiBase.tear_down(self) # Release UI api if self._ui_api is not None and self._ui_api.isInitialized: self._ui_api.release() return Global.SUCCESS, "No errors"
def tear_down(self): """ Finish the test and clear environment """ # Call LiveWifiBase base tear_down function LiveWifiBase.tear_down(self) # Disable BT a2dp_unpair_headset(self._bt_api, self._bt_headset) time.sleep(self._wait_btwn_cmd) self._bt_api.set_bt_power(0) return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ LiveWifiBase.run_test(self) # monitor wifi connection time if requested mean = -1 if self._monitor_connection_time and self.get_b2b_iteration() == self._current_iteration_num: # This is the last iteration of back to back test # compute standard deviation, mean and verdict mean = float(numpy.mean(self._connection_time_list)) std_deviation = float(numpy.std(self._connection_time_list)) compute_verdict(self._expected_connection_time, self._tolerance, mean, std_deviation, self._logger) # init values self._error.Code = Global.FAILURE self._error.Msg = "ping failed" if self._wrong_passphrase is not None: self._error.Code = Global.SUCCESS self._error.Msg = "OK - Connection failed with wrong password, ping not needed!" else: time.sleep(self._wait_btwn_cmd) self._logger.info("Ping address " + str(self._server_ip_address) + " with " + str(self._count) + " packets of " + str(self._packetsize) + " bytes...") source_address = self._networking_api.get_wifi_ip_address() packet_loss = self._networking_api.\ ping(self._server_ip_address, self._packetsize, self._count, source_address=source_address) # Compute verdict depending on % of packet loss if packet_loss.value > self._target_ping_packet_loss_rate: self._error.Code = Global.FAILURE else: self._error.Code = Global.SUCCESS self._error.Msg = "Measured Packet Loss: %.0f%s (Target: %.0f%s)."\ % (packet_loss.value, packet_loss.units, self._target_ping_packet_loss_rate, packet_loss.units) if mean > 0: self._error.Msg += " Mean connection time is %2.2f sec" % mean return self._error.Code, self._error.Msg
def tear_down(self): """ Finish the test and clear environment """ # Call UseCase base tear_down function LiveWifiBase.tear_down(self) # Stop audio a2dp_switch_music_state(self._bt_api, self._bt_headset, BtAudioCmd.STOP) # Unpair device from BT Headset a2dp_unpair_headset(self._bt_api, self._bt_headset) # Disable BT self._bt_api.set_bt_power(0) return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ LiveWifiBase.run_test(self) # Open the browser and load the url before timeout (self._error.Code, self._error.Msg) = \ self._networking_api.open_web_browser(self._website_url, self._browser_type, self._webpage_loading_timeout) # Close the browser time.sleep(self._webpage_loading_timeout) self._networking_api.close_web_browser(self._browser_type) return self._error.Code, self._error.Msg
def __init__(self, tc_name, global_config): """ Constructor """ # Call LiveBTBase init function LiveDualPhoneBTBase.__init__(self, tc_name, global_config) LiveWifiBase.__init__(self, tc_name, global_config) self._duration = str(self._tc_parameters.get_param_value("DURATION")) self._dut_state = str(self._tc_parameters.get_param_value("DUT_STATE")) self._opp_local_file = str(self._tc_parameters.get_param_value("OPP_LOCAL_FILE")) self._wifi_activity = str(self._tc_parameters.get_param_value("WIFI_ACTIVITY")) if self._wifi_activity == "WIFI_FTP_DOWNLOAD": self._ftp_remote_file = str(self._tc_parameters.get_param_value("FTP_REMOTE_FILE")) self._bt_headset = None self._bt_headset_addr = None
def __init__(self, tc_name, global_config): LiveWifiBase.__init__(self, tc_name, global_config) # Get TC Parameters self._iperf_options = \ self._tc_parameters.get_param_value("IPERF_OPTIONS") self._direction = self._tc_parameters.get_param_value("DIRECTION") if self._direction is None or self._direction == "": self._direction = 'both' else: self._direction = self._direction.lower() mode = self._tc_parameters.get_param_value("IPERF_MODE") if mode is None or mode == "": mode = "single" else: mode = mode.lower() self._tune_options = self._tc_parameters.\ get_param_value("IPERF_TUNE_OPTIONS") if self._tune_options in (None, 1, '1', 'on', 'ON'): self._tune_options = 1 else: self._tune_options = 0 self._target_ul = self._tc_parameters.get_param_value("TARGET_UL") self._failure_ul = self._tc_parameters.get_param_value("FAILURE_UL") self._target_dl = self._tc_parameters.get_param_value("TARGET_DL") self._failure_dl = self._tc_parameters.get_param_value("FAILURE_DL") # Get computer type self._computer = self._tc_parameters.get_param_value("COMPUTER") if self._computer == "": self._computer = None # Load computer equipment if self._computer is not None: self._computer = self._em.get_computer(self._computer) self._throughput_targets = None self._iperf_settings = { "server_ip_address": self._server_ip_address, "mode": mode }
def set_up(self): """ Initialize the test """ LiveWifiBase.set_up(self) if self._test_usb_disconnect is None: msg = "invalid TC parameter [TEST_USB_DISCONNECT: %s]. Please use true/false value." \ % self._tc_parameters.get_param_value("TEST_USB_DISCONNECT") self._logger.error(msg) raise DeviceException(DeviceException.INVALID_PARAMETER, msg) # Initialize USB tethering status to "disable" self._networking_api.stop_usb_tethering(unplug=True) # Checks that USB Tethering is disabled self._networking_api.check_usb_tethering_state(False) return Global.SUCCESS, "No error"
def tear_down(self): """ End and dispose the test """ # Handle reconnection in case of crash during a disconnected period if self._disconnected: UseCaseBase.tear_down(self) if self._unplugged: self._io_card.usb_host_pc_connector(True) self._unplugged = False self._device.connect_board() self._disconnected = False LiveWifiBase.tear_down(self) # Reset USB tethering status to "disable" self._networking_api.stop_usb_tethering(unplug=True) return Global.SUCCESS, "No error"
def __init__(self, tc_name, global_config): """ Constructor """ LiveWifiBase.__init__(self, tc_name, global_config) # Get TC Parameters self._direction = self._tc_parameters.get_param_value("DIRECTION") # Read the DL_FILE value from UseCase xml Parameter self._dlfilename = os.path.join( self._ftp_path, self._tc_parameters.get_param_value("DL_FILE", "")) # Read the UL_FILE value from UseCase xml Parameter self._ulfilename = os.path.join( self._ftp_path, self._tc_parameters.get_param_value("UL_FILE", "")) self._xfer_timeout = \ int(self._tc_parameters.get_param_value("XFER_TIMEOUT")) # Intended to test connection failure with wrong passphrase. self._wrong_passphrase = None
def set_up(self): """ Initialize the test """ LiveDualPhoneBTBase.set_up(self) self._bt_headset = self._em.get_bluetooth_headset("BT_HEADSET") self._bt_headset_addr = self._bt_headset.get_bdaddress() if self._wifi_activity == "WIFI_FTP_DOWNLOAD": LiveWifiBase.set_up(self) else: self._networking_api.set_wifi_power(0) if not str(self._duration).isdigit(): msg = "Bad value on duration parameter : %s" % self._duration self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) self._duration = int(self._duration) 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) if self._wifi_activity not in ["WIFI_FTP_DOWNLOAD", "WIFI_SWITCH_SCAN_CONNECT"]: msg = "Unknown WiFi activity : %s" % self._wifi_activity self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) # Configure OPP transfer opp_init_configure(self._device, self._phone2) # Connect to BT Headset a2dp_pair_connect_to_headset(self._bt_api, self._bt_headset) # Launch audio a2dp_switch_music_state(self._bt_api, self._bt_headset, BtAudioCmd.PLAY) return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ LiveBTBase.set_up(self) LiveWifiBase.set_up(self) self._bt_headset_addr = self._bt_headset.get_bdaddress() if not str(self._duration).isdigit(): msg = "Bad value on duration parameter : %s" % self._duration self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) self._duration = int(self._duration) # Connect to BT Headset a2dp_pair_connect_to_headset(self._bt_api, self._bt_headset) # Launch audio a2dp_switch_music_state(self._bt_api, self._bt_headset, BtAudioCmd.PLAY) return Global.SUCCESS, "No errors"
def set_up(self): """ Initialize the test """ LiveWifiBase.set_up(self) # Recall current screen timeout self._current_screen_timeout = self._phonesystem_api.get_screen_timeout( ) # Set the screen timeout to be sure that the screen will on # *15 because the minimum timeout is 1: 1*15 = 15s which is the minimum screen timeout time.sleep(self._wait_btwn_cmd) if self._webpage_loading_timeout > 0: self._phonesystem_api.set_screen_timeout( self._webpage_loading_timeout * 15) # Wakes up the phone time.sleep(self._wait_btwn_cmd) self._phonesystem_api.wake_screen() return Global.SUCCESS, "No errors"
def __init__(self, tc_name, global_config): """ Constructor """ LiveWifiBase.__init__(self, tc_name, global_config) # Get TC Parameters self._cts_path = self._tc_parameters.get_param_value("CTS_PATH") self._cts_media_path = self._tc_parameters.get_param_value("CTS_MEDIA_PATH") self._cts_result_comparison = self._tc_parameters.get_param_value("CTS_REPORT_COMPARISON_PATH") self._test_cmd_lines = self._tc_parameters.get_param_value("TEST_CMD_LINES") self._test_timeout = self._tc_parameters.get_param_value("TEST_TIMEOUT", default_cast_type=float) self._ui_api = self._device.get_uecmd("Ui") self._ui_api.set_global_config(global_config) self._misc_api = self._device.get_uecmd("PhoneSystem") self._system_api = self._device.get_uecmd("System") self._app_api = self._device.get_uecmd("AppMgmt") # Add a secondary report self.__tc_report = SecondaryTestReport(self._device.get_report_tree().get_report_path()) self._cts_exec_path = ""
def __init__(self, tc_name, global_config): """ Constructor """ LiveWifiBase.__init__(self, tc_name, global_config) # Get TC Parameters self._browser_type = \ str(self._tc_parameters.get_param_value("BROWSER_TYPE")).lower() self._website_url = str( self._tc_parameters.get_param_value("WEBSITE_URL")) self._webpage_loading_timeout = \ int(self._tc_parameters.get_param_value("TIMEOUT")) if self._website_url.upper() in ["", "NONE"]: # In case of empty WEBSITE_URL TC parameter, use the IP server in the bench config self._website_url = self._server_ip_address # Get UECmdLayer self._phonesystem_api = self._device.get_uecmd("PhoneSystem") # Store current screen timeout (default to 15s in case of failure) self._current_screen_timeout = 15
def __init__(self, tc_name, global_config): """ Constructor """ # Call LiveBTBase init function LiveDualPhoneBTBase.__init__(self, tc_name, global_config) LiveWifiBase.__init__(self, tc_name, global_config) # Read COMPONENT_USE from test case xml file self._component_use = str( self._tc_parameters.get_param_value("COMPONENT_USE")) # Read DUT_STATE from test case xml file self._dut_state = str(self._tc_parameters.get_param_value("DUT_STATE")) # Read OPP_LOCAL_FILE from test case xml file self._opp_local_file = str( self._tc_parameters.get_param_value("OPP_LOCAL_FILE")) # Initialize data self._thread_opp_transfer = None self._thread_scan_bt = None self._thread_scan_wifi = None self._queue = Queue.Queue()
def run_test(self): """ Execute the test """ LiveWifiBase.run_test(self) # Start USB Tethering self._networking_api.start_usb_tethering(unplug=True) # Control that USB Tethering starts well self._networking_api.check_usb_tethering_state(True) if self._test_usb_disconnect: # Disconnect ADB self._device.disconnect_board() self._disconnected = True # Unplug USB self._io_card.usb_host_pc_connector(False) self._unplugged = True # Wait some time USB cable unplugged time.sleep(5) # plug USB self._io_card.usb_host_pc_connector(True) self._unplugged = False # Reconnect ADB self._device.connect_board() self._disconnected = False else: # Disable USB Tethering self._networking_api.stop_usb_tethering(unplug=True) # Control that USB Tethering stops well self._networking_api.check_usb_tethering_state(False) return Global.SUCCESS, "No error"
def run_test(self): """ Execute the test """ LiveWifiBase.run_test(self) time.sleep(self._wait_btwn_cmd) if self._direction == "DL": self._logger.info("FTP transfer " + str(self._direction) + " for " + str(self._dlfilename) + "...") result = self._networking_api.\ ftp_xfer(self._uecmd_types.XFER_DIRECTIONS.DL, # pylint: disable=E1101 self._server_ip_address, self._username, self._password, self._dlfilename, self._xfer_timeout, self._device.get_ftpdir_path()) elif self._direction == "UL": self._logger.info("FTP transfer " + str(self._direction) + " for " + str(self._ulfilename) + "...") result = self._networking_api.\ ftp_xfer(self._uecmd_types.XFER_DIRECTIONS.UL, # pylint: disable=E1101 self._server_ip_address, self._username, self._password, self._ulfilename, self._xfer_timeout, self._device.get_ftpdir_path()) else: self._error.Msg = "%s is not a known xfer direction" % self._direction raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, self._error.Msg) return result
def set_up(self): """ Initialize the test :rtype: tuple :return: ACS verdict and msg output """ verdict = Global.SUCCESS msg = "" LiveWifiBase.set_up(self) if self._test_timeout is None: return (Global.FAILURE, "You need to specify a " "TESTS_TIMEOUT value.") if self._cts_path is None: return (Global.FAILURE, "You need to specify a " "CTS_PATH value.") if self._test_cmd_lines is None: return (Global.FAILURE, "You need to specify a " "TEST_PACKAGES_NAMES value.") if self._cts_media_path is None: self._logger.info("No media specified for CTS tests") if self._cts_result_comparison is None: self._logger.info("No comparison will be done with previous CTS run") full_path = "" if HttpDownloaderUtil.is_http_uri(self._cts_path): # Test is available thru URL => download it localy result, full_path = self._download_file(self._cts_path) else: result, full_path = self._get_file_path(self._cts_path) if result != Global.SUCCESS: verdict = result msg = "Cannot get the cts version from %s" % self._cts_path else: self._cts_path = full_path # Set cts directory path # can be a path to a dir or a zip file # in both case, resulting filename will be a directory cts_exec_found = False fileName, fileExtension = os.path.splitext(self._cts_path) if fileExtension.lower() == ".zip": zip_file = zipfile.ZipFile(self._cts_path, "r") zip_file.extractall(fileName) zip_file.close() else: fileName = self._cts_path # cts path should be a dir if os.path.isdir(fileName): self._cts_path = fileName for root, _, file_names in os.walk(self._cts_path): for file_ in file_names: if file_ == CTS_EXEC_FILENAME: self._cts_exec_path = os.path.join(root, file_) os.chmod(self._cts_exec_path, stat.S_IRWXU) cts_exec_found = True if not cts_exec_found: verdict, msg = Global.FAILURE, "Cannot find the CTS executable binary" else: # clean up old previous results for root, _, file_names in os.walk(self._cts_path): for file_ in file_names: if CTS_RESULT_FILENAME in file_: shutil.rmtree(root) # Initialize UI api self._ui_api.init() # setup the board if it has not been done previously verdict, msg = self._setup_device_for_cts() return verdict, msg