def __init__(self, tc_name, global_config): """ Constructor """ # Call LTE base Init function LabLteBase.__init__(self, tc_name, global_config) # SMS direction (MO or MT) self._sms_direction = self._tc_parameters.get_param_value( "SMS_DIRECTION") # SMS type (TGPP or TGP2) self._sms_type = self._tc_parameters.get_param_value( "SMS_TYPE", "TGPP") # SMS core text self._sms_core_text = self._tc_parameters.get_param_value("SMS_TEXT") # Timeout to expect SMS to be received or sent self._sms_timeout = \ int(self._tc_parameters.get_param_value("SMS_TIMEOUT","0")) # self._destination_number = \ str(self._tc_parameters.get_param_value("DESTINATION_NUMBER")) if self._destination_number.upper() == "[PHONE_NUMBER]": self._destination_number = str(self._device.get_phone_number()) # Instantiate Messaging UECmd for SMS UseCases self._messaging_api = self._device.get_uecmd("SmsMessaging") # Create cellular network simulator and retrieve 3G messaging API self._messaging_4g = self._ns.get_cell_4g().get_messaging()
def tear_down(self): """ Tear down function """ # Call the inherited method LabLteBase.tear_down(self) # In case the WIFI or BT are enabled, disable them # Disable WIFI self._logger.info("Turn WIFI OFF") self._networking_api.set_wifi_power(self.STATE_OFF) time.sleep(self._wait_btwn_cmd) # Disable BT self._logger.info("Turn BT OFF") self._connectivity_api.set_bt_power(self.STATE_OFF) time.sleep(self._wait_btwn_cmd) # Set flight mode back to initial state # if flight mode has been correctly retrieved in the beginning if self._initial_flight_mode_state not in ("", None): self._logger.info("Restoring Flight Mode to its initial state.") self._networking_api.set_flight_mode( self._initial_flight_mode_state) return Global.SUCCESS, "No errors"
def set_up(self): """ Test setup """ # If WIFI is ON, turn it off if self._networking_api.get_wifi_power_status() == self.STATE_ON: self._logger.info("Turn off WIFI") # Turn off WIFI self._networking_api.set_wifi_power(self.STATE_OFF) time.sleep(self._wait_btwn_cmd) # Turn off Bluetooth self._connectivity_api.set_bt_power(self.STATE_OFF) time.sleep(self._wait_btwn_cmd) # Call LAB_LTE_BASE set_up function LabLteBase.set_up(self) # Recording initial state before starting the test self._initial_flight_mode_state = \ self._networking_api.get_flight_mode() # If DUT is not in airplane mode on, enable it if self._initial_flight_mode_state == 0: self._logger.info("Now enabling Flight Mode.") self._networking_api.set_flight_mode(self.STATE_ON) # Set Cell on self._cell_4g.set_cell_on(self._mimo) return Global.SUCCESS, "No errors"
def __init__(self, tc_name, global_config): """ Constructor """ # Call LTE base Init function LabLteBase.__init__(self, tc_name, global_config) # Read callSetupTimeout from Device_Catalog.xml self._call_setup_time = \ int(self._dut_config.get("callSetupTimeout")) self._phone_number = \ str(self._tc_parameters.get_param_value("PHONE_NUMBER")) if self._phone_number.upper() == "[PHONE_NUMBER]": self._phone_number = str(self._device.get_phone_number()) # Read CALL_DURATION from test case xml file self._call_duration = \ int(self._tc_parameters.get_param_value("CALL_DURATION")) # Read VC_TYPE from testcase xml file self._vc_type = str(self._tc_parameters.get_param_value("VC_TYPE")) # Read RELEASE_VC_SIDE from testcase xml file self._release_vc_type = str( self._tc_parameters.get_param_value("RELEASE_VC_TYPE")) # Create cellular network simulator and retrieve 4G voice call and data interfaces self._ns_voice_call_4g = self._ns.get_cell_4g().get_voice_call() # Instantiate generic UECmd for all use cases self._voice_call_api = self._device.get_uecmd("VoiceCall")
def run_test(self): """ Execute the test """ # pylint: disable=E1101 # Disable this pylint error due to Enum class VOICE_CALL_STATE # Call GSM VoiceCall base run_test function LabLteBase.run_test(self) # Release any previous call (Robustness) self._voice_call_api.release() # Perform MT voice call if requested by the test if self._vc_type == "MT": # Trigger MT call from the call box self._ns_voice_call_4g.mt_originate_call() # Wait for state "incoming" before callSetupTimeout seconds self._voice_call_api.wait_for_state( self._uecmd_types.VOICE_CALL_STATE.INCOMING, self._call_setup_time) # Answer to that call on the DUT self._voice_call_api.answerIMS() # Otherwise perform a MO call else: # Dial using PHONE_NUMBER parameter self._voice_call_api.dial(self._phone_number) # Check call state "CONNECTED" before callSetupTimeout seconds self._ns_voice_call_4g.check_call_connected(self._call_setup_time) # Wait for state "active" before callSetupTimeout seconds self._voice_call_api.wait_for_state( self._uecmd_types.VOICE_CALL_STATE.ACTIVE, self._call_setup_time) # Check call is connected for CALL_DURATION seconds self._ns_voice_call_4g.is_voice_call_connected(self._call_duration) # Perform Network release of the voice call if requested by the test if self._vc_type == "NR": self._ns_voice_call_4g.voice_call_network_release() # Otherwise do a Mobile Release else: # Mobile Release call self._voice_call_api.release() # Check voice call state is "released" self._logger.info("Wait 5 sec to check VC is released on Callbox") time.sleep(5) self._ns_voice_call_4g.is_voice_call_idle() # Check voice call state is "no_call" on DUT time.sleep(self._wait_btwn_cmd) self._voice_call_api.wait_for_state( self._uecmd_types.VOICE_CALL_STATE.NOCALL, self._call_setup_time) # pylint: enable=E1101 return (Global.SUCCESS, "No errors")
def set_up(self): """ Set up the test configuration """ # Call LAB_LTE_BASE set_up function LabLteBase.set_up(self) # Set Cell on self._cell_4g.set_cell_on(self._mimo) # Phone has to see the cell off! self._modem_api.check_cdk_no_registration_bfor_timeout( self._registration_timeout) # Flight mode deactivation self._networking_api.set_flight_mode("off") # Check registration state is connected using # registrationTimeout from Device_Catalog.xml self._logger.info("Check network registration status is %s on DUT" % (self._wanted_reg_state)) self._modem_api.check_cdk_state_bfor_timeout( self._wanted_reg_state, self._registration_timeout) # Set APN for LTE and/or IMS depending on protocol IPv4 or IPv6 self._set_apn_for_lte_and_ims() # Enable Data Usage time.sleep(self._wait_btwn_cmd) self._networking_api.activate_pdp_context() # Get RAT from Equipment network_type = self._data_4g.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) # Check IMS connection state status = self._data_4g.check_ims_connection_state( "REG", self._registration_timeout) if status == False: raise DeviceException(DeviceException.INVALID_DEVICE_STATE, "Failed to reach IMS registration") # Wait 15 seconds after registration before sending first SMS time.sleep(15) # Initialize counter to be append to sms_text in order to # differenciate the different SMS sent in B2B mode self._counter = 0 return (Global.SUCCESS, "No errors")
def run_test(self): """ Execute the test """ # pylint: disable=E1101 # Disable this pylint error due to Enum # Call LAB_LTE_BASE run_test function LabLteBase.run_test(self) # Increment counter self._counter += 1 # Append counter value to SMS core text to create a different SMS for each loop self._sms_text = self._sms_core_text + str(self._counter) self._sms = SmsUtil.SmsMessage(self._sms_text, self._destination_number, "") # Clear old SMS on phone self._messaging_api.delete_all_sms() if self._sms_direction == "MO": # Send SMS to equipment using SMS parameters : # - SMS_TEXT # - PHONE_NUMBER time.sleep(self._wait_btwn_cmd) self._messaging_api.send_sms(self._sms.sender, self._sms.message) # Retrieve the MO SMS received On Network Simulator self._sms_received = self._messaging_4g.retrieve_sms_over_ims( self._sms_timeout) # Force sender number because this info can't be retrieved from Network Simulator self._sms_received.sender = self._destination_number elif self._sms_direction == "MT": # register on intent to receive incoming sms self._messaging_api.register_for_sms_reception() # Configure the type of the message to send CUSTOM TEXT. self._messaging_4g.set_sms_over_ims_type(self._sms_type) self._messaging_4g.set_custom_sms_over_ims_text(self._sms_text) # Send SMS to CDK using SMS parameters : # - SMS_TEXT self._messaging_4g.send_sms_over_ims() # Check sms acknowledged by network simulator if not self._messaging_4g.check_sms_over_ims_delivery( self._sms_timeout): msg = "SMS over IMS not acknowledged by NW" self._logger.info(msg) # Return message and exit test case return Global.FAILURE, msg # Retrieve the MT SMS received On DUT self._sms_received = self._messaging_api.wait_for_incoming_sms( self._sms_timeout) else: # Log that SMS_DIRECTION is not declared in Xml msg = "Test Not available. Please make sure to specify SMS DIRECTION MO/MT " self._logger.info(msg) # Return message and quit the method return Global.FAILURE, msg # Compare sent and received SMS (Text, Phone number) (result_verdict, result_message) = \ SmsUtil.compute_sms_equals(self._sms, self._sms_received) # Print SMS test status self._logger.info(result_message) # Perform 10 MO ping of 32 byte if SMS is successful if result_verdict == Global.SUCCESS: # Compute packet loss value packet_loss = self._networking_api.ping(self._server_ip_address, 32, 10) # Compute verdict depending on % of packet loss if packet_loss.value > 0: self.result_verdict = Global.FAILURE else: self.result_verdict = Global.SUCCESS self.result_message = "Measured Packet Loss: %.0f%s (Target: %.0f%s)" \ % (packet_loss.value, packet_loss.units, 0, # no packet loss expected packet_loss.units) return result_verdict, result_message
def run_test(self): """ Execute the test """ # Call LAB_LTE_BASE run_test function LabLteBase.run_test(self) # Clear the logcat buffer self.__clear_logcat() # Phone has to see the cell off! self._modem_api.check_cdk_state_bfor_timeout("unregistered", self._camp_timeout) # Deactivate airplane mode self._logger.info("Flight Mode was active, deactivating it now.") self._networking_api.set_flight_mode(self.STATE_OFF) # Check registration state is connected using # registrationTimeout from Device_Catalog.xml self._logger.info("Check network registration status is %s on DUT" % self._wanted_reg_state) self._modem_api.check_cdk_state_bfor_timeout( self._wanted_reg_state, self._registration_timeout) # Set APN for LTE and/or IMS depending on protocol IPv4 or IPv6 self._set_apn_for_lte_and_ims() # Activate PDP context time.sleep(self._wait_btwn_cmd) self._logger.info("Active PDP Context...") self._networking_api.activate_pdp_context(self._ssid, False) # Check data connection state is "CON" self._data_4g.check_data_connection_state("CON", self._camp_timeout, blocking=False, cell_id=self._cell_id) # Get RAT from Equipment network_type = self._data_4g.get_network_type() # Check that DUT is registered on the good RAT self._modem_api.check_network_type_before_timeout( network_type, self._camp_timeout) # Analize in the logcat the CWS response after DUT registration self._logger.info("Checking CWS response after DUT registration.") result, output = self.__check_message_in_logcat("REGISTERED") if result == Global.FAILURE: self._logger.error(output) return Global.FAILURE, "CWS responses not found in logcat after DUT registration" else: self._logger.info( "CWS responses after DUT registration was found in logcat") # Wait between two commands sending time.sleep(self._wait_btwn_cmd) # ------------------------------------------------------------ # Perform ON/OFF for configured number of iterations self._logger.info("Perform %d ON-OFF iterations for BT or WIFI" % self._number_of_iterations) counter = 0 for counter in xrange(0, self._number_of_iterations): self._logger.info("Iteration no. %d" % (counter + 1)) # Check if the user has requested to check LTE coexistence with WIFI ON/OFF if self._check_wlan: # Check WIFI ON/OFF verdict, result_message = self.__check_wlan_procedures() if verdict == Global.FAILURE: return verdict, result_message else: # Evacuate an info message self._logger.info( "The user has decided to skip the WLAN activation/deactivation procedure" ) # Check if the user has requested to check LTE coexistence with BT ON/OFF if self._check_bt: # Check BT ON/OFF verdict, result_message = self.__check_bt_procedures() if verdict == Global.FAILURE: return verdict, result_message else: # Evacuate an info message self._logger.info( "The user has decided to skip the BT activation/deactivation procedure" ) # Increment the counter counter = counter + 1 # Wait between two commands sending time.sleep(self._wait_btwn_cmd) # Get RAT from Equipment network_type = self._data_4g.get_network_type() # Check that DUT is registered on the good RAT self._logger.info("Check that DUT is registered on the good RAT") self._modem_api.check_network_type_before_timeout( network_type, self._camp_timeout) # Wait between two commands sending time.sleep(self._wait_btwn_cmd) # Execute PING command, and compute packet loss value packet_loss = self._networking_api.\ ping(self._server_ip_address, self._packet_size, self._nb_pings) # 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) # Wait between two commands sending time.sleep(self._wait_btwn_cmd) # Enable Flight Mode self._logger.info("Now enabling Flight Mode.") self._networking_api.set_flight_mode(self.STATE_ON) # Analize in the logcat the procedure for "AIRPLANE MODE ON" result, output = self.__check_message_in_logcat("AIRPLANE MODE ON") if result == Global.FAILURE: self._logger.error(output) return Global.FAILURE, "AIRPLANE MODE ON procedure was not found in logcat" else: self._logger.info( "\"+XNRTCWS\" URC for 'AIRPLANE MODE ON' was found in logcat") return Global.SUCCESS, "No errors"
def __init__(self, tc_name, global_config): """ Constructor """ # Call LAB_LTE_BASE Init function LabLteBase.__init__(self, tc_name, global_config) # Check the cell band if self._cell_band not in range(1, 33): # Raise an exception raise AcsConfigException( AcsConfigException.INVALID_PARAMETER, "'CELL BAND' parameter not in [1,32] range") # Read the number of pings to do self._nb_pings = self._tc_parameters.get_param_value("PACKET_COUNT") # Read the data size of a packet self._packet_size = self._tc_parameters.get_param_value("PACKET_SIZE") # Get target % of received packet for ping self._target_ping_packet_loss_rate = \ float(self._tc_parameters.get_param_value("TARGET_PACKET_LOSS_RATE")) self._camp_timeout = self._registration_timeout # Read parameters and convert them to their final type self._check_bt = \ str(self._tc_parameters.get_param_value("CHECK_BT")) self._check_bt = str_to_bool(self._check_bt) self._check_wlan = \ str(self._tc_parameters.get_param_value("CHECK_WLAN")) self._check_wlan = str_to_bool(self._check_wlan) # Value for the number of iterations regarding ON-OFF procedures number_of_iterations = \ str(self._tc_parameters.get_param_value("ON_OFF_ITERATION")) if number_of_iterations.isdigit() is True: self._number_of_iterations = int(number_of_iterations) if self._number_of_iterations <= 0: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, \ "'ON_OFF_ITERARION' parameter must be a positive value > 0") else: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, \ "'ON_OFF_ITERARION' parameter must be an integer") # Time for waiting with BT or WIFI enabled time_wait_on = \ str(self._tc_parameters.get_param_value("WAIT_ON")) if time_wait_on.isdigit() is True: self._time_wait_on = int(time_wait_on) if self._number_of_iterations <= 0: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, \ "'WAIT_ON' parameter must be a positive value > 0") else: raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, \ "'WAIT_ON' parameter must be an integer") # Instantiate UE Command categories self._networking_api = self._device.get_uecmd("Networking") self._connectivity_api = self._device.get_uecmd("LocalConnectivity") # Instantiate the PhoneSystem UE Command category self._phone_system = self._device.get_uecmd("PhoneSystem") # Instantiate the modem UE commands self._modem_flashing_api = self._device.get_uecmd("ModemFlashing") # Set time variable self._time = 5