Exemplo n.º 1
0
    def __send_sms(self):
        """
        Sends a SMS with this test's parameters.

        :raise DeviceException: if the SMS sending was not
            successful.
        """

        # Clear old SMS (Non blocking for this test if function isn't
        # implemented on CDK)
        time.sleep(self._wait_btwn_cmd)
        self._messaging_api.delete_all_sms()

        # Send SMS to equipment using SMS parameters :
        # - SMS_TEXT
        # - DESTINATION_NUMBER
        time.sleep(self._wait_btwn_cmd)
        sms_sent = SmsMessage(self._message, self._destination_number)

        # register on intent to receive incoming sms
        self._messaging_api.register_for_sms_reception()

        self._messaging_api.send_sms(self._destination_number, self._message)

        # Get received sms
        sms_received = self._messaging_api.wait_for_incoming_sms(
            self._sms_transfer_timeout)

        # Compare sent and received SMS (Text,
        # Destination number)
        (_result_verdict,
         result_message) = compute_sms_equals(sms_sent, sms_received)

        self._logger.info(result_message)
Exemplo n.º 2
0
    def run_test(self):
        """
        Runs the test.
        """
        # Call inherited run_test method which will ensure IMS registration
        # Ugly temporary solution before implementing something
        # better using test steps.
        if self._perform_ims_registration:
            LiveLteImsReg.run_test(self)
        else:
            UseCaseBase.run_test(self)

        # Clear old SMS (Non blocking for this test if function isn't
        # implemented on CDK)
        time.sleep(self._wait_btwn_cmd)
        self._sms_api.delete_all_sms()

        time.sleep(self._wait_btwn_cmd)

        sms_sent = SmsMessage(self._message, self._destination_number)

        # register on intent to receive incoming sms
        self._sms_api.register_for_sms_reception()

        # Send SMS to equipment using SMS parameters :
        # - SMS_TEXT
        # - DESTINATION_NUMBER
        self._sms_api.send_sms(self._destination_number,
                               self._message)

        # Get received sms
        sms_received = self._sms_api.wait_for_incoming_sms(self._sms_transfer_timeout)

        # Compare sent and received SMS (Text,
        # Destination number)
        (result_verdict, result_message) = \
            compute_sms_equals(sms_sent, sms_received)

        self._logger.info(result_message)

        # Because in case of failure the IMS stack may have crashed
        # we need to double-check the IMS registration status.
        in_service_status = ImsRegistrationStatus.in_service()
        registration_status = self._get_registration_status()
        self._logger.info("Registation status: %s (%d)" % (
            str(registration_status),
            registration_status.as_int()))
        # Compute the verdict
        if str(registration_status) != str(in_service_status):
            result_message = "IMS stack has crashed or IMS registration is lost."
            self._logger.error(result_message)
            result_verdict = Global.FAILURE

        # Return the test result
        return (result_verdict, result_message)
Exemplo n.º 3
0
    def _send_sms(self, ns_messaging):
        """
        Send sms from equipment or DUT

        :type ns_messaging: IMessaging3G
        :param ns_messaging: network simulator messaging

        :rtype: Verdict, message
        """
        nb_segments = \
            compute_sms_segments(self._sms_text, self._nb_bits_per_char)

        if "MT" in self._sms_type:
            # [SEND MT SMS DIRECTLY BY EQUIPMENT]

            # register on intent to receive incoming sms
            self._messaging_api.register_for_sms_reception()

            # Construct SMS
            sms_sent = SmsMessage(self._sms_text, self._sms_sender, "GSM")

            # Configure the type of the message to send CUSTOM TEXT.
            ns_messaging.select_sms_content(self._content_type)

            # Set the custom text message to send, using SMS_TEXT parameter
            if self._content_type == "CTEX":
                ns_messaging.set_custom_sms_text(self._sms_text)
            elif self._content_type == "CDAT":
                ns_messaging.set_custom_sms_data(self._sms_text)

            # Send MT SMS to CDK using SMS parameters :
            # - SMS_TEXT
            ns_messaging.send_sms()

            # Check sms acknowledged by network simulator
            ns_messaging.check_sms_state('ACK', self._sms_transfer_timeout)
        else:
            # [SEND MO SMS BY DUT]

            # Construct SMS
            sms_sent = SmsMessage(self._sms_text, self._sms_sender, "GSM")

            self._messaging_api.send_sms(self._sms_sender, self._sms_text)

        # Get received sms
        sms_received = self._messaging_api.wait_for_incoming_sms(
            self._sms_transfer_timeout)

        # Compare sent and received SMS (Text,
        # Destination number)
        (result_verdict, result_message) = \
            compute_sms_equals(sms_sent, sms_received)

        return result_verdict, result_message
Exemplo n.º 4
0
    def run_test(self):
        """

        Execute the test
        """

        # Call the LabLteBase run_test function
        LabLteBase.run_test(self)
        self._messaging_api.delete_all_sms()

        if self._sms_direction == "MT":
            sms_sent = SmsMessage(self._sms_text, self._incoming_number, "PSD")

            # register on intent to receive incoming sms
            self._messaging_api.register_for_sms_reception()

            # set custom sms text to equipment
            time.sleep(self._wait_btwn_cmd)
            self._messaging_4g.set_custom_sms_text(self._sms_text)

            # Send sms over sgs
            self._messaging_4g.send_sms_over_sgs()

            # get sms received
            sms_received = self._messaging_api.wait_for_incoming_sms(
                self._sms_transfer_timeout)
        elif self._sms_direction == "MO":
            # TODO: SMS MO PS is not yet supported by the platform
            # BZ:112539
            raise DeviceException(
                DeviceException.FEATURE_NOT_AVAILABLE,
                "SMS MO PS is not yet supported by the platform")

        else:
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER,
                                     "SMS_DIRECTION should be Only MO or MT")

        # Compare sent and received SMS (Text, Destination number)
        (result_verdict, result_message) = \
            compute_sms_equals(sms_sent, sms_received)

        self._logger.info(result_message)

        return result_verdict, result_message
Exemplo n.º 5
0
    def run_test(self):
        """
        Execute the test
        """
        # Call UseCase base Run function
        LiveMessagingBase.run_test(self)

        # Clear old SMS (Non blocking for this test if function isn't
        # implemented on CDK)
        time.sleep(self._wait_btwn_cmd)
        self._sms_api.delete_all_sms()

        time.sleep(self._wait_btwn_cmd)

        sms_sent = SmsMessage(self._message, self._destination_number)

        # register on intent to receive incoming sms
        self._sms_api.register_for_sms_reception()

        # Send SMS to equipment using SMS parameters :
        # - SMS_TEXT
        # - DESTINATION_NUMBER
        self._sms_api.send_sms(self._destination_number, self._message)

        # Get received sms
        sms_received = self._sms_api.wait_for_incoming_sms(
            self._sms_transfer_timeout)

        # Compare sent and received SMS (Text,
        # Destination number)
        (result_verdict, result_message) = \
            compute_sms_equals(sms_sent, sms_received)

        self._logger.info(result_message)

        # Check the DUT is camped on a compatible network with the selected
        # preferred network.
        if self._network_pref is not None:
            self._modem_api.check_rat_with_pref_network(
                self._network_pref, self._registration_timeout)

        return result_verdict, result_message
Exemplo n.º 6
0
    def run_test(self):
        """

        Execute the test
        """

        # Call the LAB_WCDMA_SMS_PS_BASE run_test function
        LabWcdmaSmsPsBase.run_test(self)

        # Calculate how many SMS will be sent to equipment
        time.sleep(self._wait_btwn_cmd)
        nb_segments = compute_sms_segments(
            self._sms_text, self._nb_bits_per_char)

        sms_sent = SmsMessage(self._sms_text, self._destination_number, "PSD")

        # register on intent to receive incoming sms
        self._messaging_api.register_for_sms_reception()

        if nb_segments > 1:
            # [SEND MO SMS PROCESS]

            # Activate loopback on equipment
            self._ns_messaging_3g.set_sms_mo_loopback_state("ON")

            # Enable message queuing
            self._ns_messaging_3g.set_sms_message_queuing_state("ON")

            # Send SMS to equipment using SMS parameters :
            # - SMS_TEXT
            # - DESTINATION_NUMBER
            # Also ask the UE Command to use synchronization
            time.sleep(self._wait_btwn_cmd)
            self._messaging_api.send_sms(
                self._destination_number,
                self._sms_text,
                True)

            # Wait all incoming sms from DUT to Network Simulator
            self._ns_messaging_3g.check_sms_delivery_state(sms_sent, nb_segments,
                                                           self._sms_transfer_timeout)

            # Read all messages in the queue
            self._ns_messaging_3g.read_all_received_sms()

        else:
            # [SEND SMS DIRECTLY BY EQUIPMENT]

            # Configure the type of the message to send CUSTOM TEXT.
            self._ns_messaging_3g.select_sms_content(self._content_type)

            # Set the custom text message to send, using SMS_TEXT parameter
            if self._content_type == "CTEX":
                self._ns_messaging_3g.set_custom_sms_text(self._sms_text)
            elif self._content_type == "CDAT":
                self._ns_messaging_3g.set_custom_sms_data(self._sms_text)

            # Send SMS to CDK using SMS parameters :
            # - SMS_TEXT
            self._ns_messaging_3g.send_sms()

            # Check sms acknowledged by network simulator
            self._ns_messaging_3g.check_sms_state(
                'ACK', self._sms_transfer_timeout)

        # get sms received
        sms_received = self._messaging_api.wait_for_incoming_sms(self._sms_transfer_timeout)

        # Compare sent and received SMS (Text,
        # Destination number)
        (result_verdict, result_message) = \
            compute_sms_equals(sms_sent, sms_received)

        self._logger.info(result_message)

        return result_verdict, result_message
Exemplo n.º 7
0
    def run_test(self):
        """
        Execute the test
        """
        # Call UseCase base Run function
        LiveMessagingBase.run_test(self)

        # Clear old SMS (Non blocking for this test if function isn't
        # implemented on CDK)
        time.sleep(self._wait_btwn_cmd)
        self._sms_api.delete_all_sms()

        # Enable cellular data
        self._logger.info("Activate PDP Context")
        self._networking_api.activate_pdp_context()

        time.sleep(self._wait_btwn_cmd)

        sms_sent = SmsMessage(self._message, self._destination_number)

        # Start the FTP data transfer
        self._dl_id = self._launch_ftp_data_transfer()

        # Check the status of the FTP connection
        status = self._ftp_api.get_ftp_status(self._dl_id)

        # If the transfer is not working some exceptions
        if str(status) <> "transferring":
            # If the transfer is not established raised an exception
            if str(status) in ("notrunning", "transfer failed"):
                message = "FTP transfer failed / not started: %s" % str(status)
                raise DeviceException(DeviceException.CONNECTION_LOST, message)

            # If the transfer status is 'connecting'
            # additionally wait for the connection to be established
            elif str(status) == "connecting":
                self._logger.info(
                    "FTP transfer not started yet. STATUS is CONNECTING")
                time.sleep(self._wait_btwn_cmd)
                if str(status) == "connecting":
                    message = "FTP transfer status is CONNECTING for a too long time"
                    raise DeviceException(DeviceException.CONNECTION_LOST,
                                          message)

            # If the FTP data transfer is finished already
            # the transferred file length chosen is too short
            else:
                message = "FTP transfer finished before SMS has been sent"
                self._logger.error(message)
                raise AcsConfigException(
                    AcsConfigException.INVALID_TEST_CASE_FILE, message)

        # If the FTP data transfer is on going start the SMS sending procedures
        # If the FTP data transfer status is "transferring"
        else:

            # register on intent to receive incoming sms
            self._sms_api.register_for_sms_reception()

            # Send SMS to equipment using SMS parameters :
            # - SMS_TEXT
            # - DESTINATION_NUMBER
            self._sms_api.send_sms(self._destination_number, self._message)

            # Get received sms
            sms_received = self._sms_api.wait_for_incoming_sms(
                self._sms_transfer_timeout)

            # Compare sent and received SMS (Text,
            # Destination number)
            (result_verdict, result_message) = \
                compute_sms_equals(sms_sent, sms_received)

            self._logger.info(result_message)

            final_transfer_status = str(
                self._ftp_api.get_ftp_status(self._dl_id))
            while final_transfer_status <> "transfer successful":
                if str(final_transfer_status) in ("transfer successful",
                                                  "transferring"):
                    time.sleep(self._wait_btwn_cmd)
                else:
                    message = "FTP transfer failed after SMS sent: %s" % str(
                        final_transfer_status)
                    raise DeviceException(DeviceException.CONNECTION_LOST,
                                          message)
                final_transfer_status = str(
                    self._ftp_api.get_ftp_status(self._dl_id))

            if final_transfer_status == "transfer successful":
                message = "FTP transfer finished successfully"
                self._logger.info(message)
                result_message = result_message + ". " + message

        return result_verdict, result_message
Exemplo n.º 8
0
    def check_sms_delivery_state(self, sms_sent, nb_sms, timeout_per_sms=0):
        """
        Check if all SMS sent have been received before timeout_per_sms * nb_sms
        seconds.
        :type sms_sent: SmsMessage object
        :param sms_sent: sent SMS to be checked
        :type nb_sms: integer
        :param nb_sms: number of SMS to be delivered
        :type timeout_per_sms: integer
        :param timeout_per_sms: timeout per SMS. If timeout is 0, only one test
        is performed
        :raise TestEquipmentException: if one or more expected SMS have not been received
        before timeout*nb_sms seconds.
        """
        log = True
        all_received = False

        timeout = timeout_per_sms * nb_sms

        # Check if the expected number of SMS is reached
        while timeout > 0:
            if int(
                    self._visa.query(
                        "CALL:SMService:PTPoint:MORiginated:COUNt?",
                        log)) == int(nb_sms):
                all_received = True
                break
            time.sleep(1)
            timeout -= 1

        if not all_received:
            error_msg = "SMS not received : waited %d seconds for %d SMS." % \
                (timeout, nb_sms)
            self._logger.error(error_msg)
            raise TestEquipmentException(TestEquipmentException.SMS_EXCEPTION,
                                         error_msg)

        # Check if the content of the received SMS
        sms_message = ""
        sms_destination = ""
        sms_transportation = ""

        # Get SMS from Equipment
        nb_sms = int(
            self._visa.query("CALL:SMService:PTPoint:MORiginated:COUNt?", log))
        for _ in range(nb_sms):
            message_tmp = str(
                self._visa.query("CALL:SMService:PTPoint:MORiginated:TEXT?",
                                 log)).replace("\"", "")
            sms_destination = str(
                self._visa.query(
                    "CALL:SMService:PTPoint:MORiginated:DESTination?",
                    log)).replace("\"", "")
            sms_transportation = self._visa.query(
                "CALL:SMService:PTPoint:MORiginated:TRANsport?", log)
            sms_message += message_tmp
            self._visa.write("CALL:SMService:PTPoint:MORiginated:QUEue:NEXT")

        sms_received = SmsMessage(sms_message, sms_destination,
                                  sms_transportation)
        (result_verdict, result_message) = \
            compute_sms_equals(sms_sent, sms_received, check_transportation=True)

        self._logger.info(result_message)
        if result_verdict == Global.FAILURE:
            raise TestEquipmentException(TestEquipmentException.SMS_EXCEPTION,
                                         result_message)

        return result_verdict, result_message
Exemplo n.º 9
0
    def run_test(self):
        """
        Execute the test
        """

        # Call the LAB_GSM_SMS_CS_BASE run_test function
        LabGsmSmsCsBase.run_test(self)

        # Send sms_amount_to_send SMS to sim card.
        for i in xrange(1, self._sms_amount_to_send):

            if(self._nb_segments > 1):
                # [SEND MO SMS PROCESS]
                # Activate loopback on equipment
                self._ns_messaging_2g.set_sms_mo_loopback_state("ON")

                # Enable message queuing
                self._ns_messaging_2g.set_sms_message_queuing_state("ON")

                # Send SMS to equipment using SMS parameters :
                # - SMS_TEXT
                # - DESTINATION_NUMBER
                # Also ask the UE Command to use synchronization
                self._messaging_api.send_sms(
                    self._destination_number,
                    self._sms_text,
                    True)

                # Wait all incoming sms from DUT to Network Simulator
                self._ns_messaging_2g.\
                check_sms_delivery_state(self.sms_sent,
                                         self._nb_segments,
                                         self._sms_transfer_timeout)

                # Read all messages in the queue
                self._ns_messaging_2g.read_all_received_sms()

            else:

                # retrieve instance in order to get sent messages
                self._ns_messaging_2g.\
                        select_sms_content(self._content_type)

                if(self._content_type == "CTEX"):
                    self._ns_messaging_2g.\
                        set_custom_sms_text(self._sms_text)
                elif (self._content_type == "CDAT"):
                    self._ns_messaging_2g.\
                        set_custom_sms_data(self._sms_text)

                # Send SMS to CDK using SMS parameters :
                # - SMS_TEXT
                self.sms_sent.send_sms()

                # Check sms acknowledged by network simulator
                self._ns_messaging_2g.check_sms_state(
                    'ACK', self._sms_transfer_timeout)

            # get sms received
            sms_received = self._messaging_api.wait_for_incoming_sms(self._sms_transfer_timeout)

            # Compare sent and received SMS (Text,
            # Destination number)
            (result_verdict, result_message) = \
                compute_sms_equals(self.sms_sent, sms_received)

            if result_verdict == Global.FAILURE:
                self._logger.error(result_message)
                # Exit loop
                break

        return result_verdict, result_message
Exemplo n.º 10
0
    def run_test(self):
        """
        Runs the test.
        """
        # Call inherited run_test method which will ensure IMS registration
        # Ugly temporary solution before implementing something
        # better using test steps.
        if self._perform_ims_registration:
            LiveLteImsReg.run_test(self)
        else:
            UseCaseBase.run_test(self)

        # Clear old SMS (Non blocking for this test if function isn't
        # implemented on CDK)
        time.sleep(self._wait_btwn_cmd)
        self._sms_api.delete_all_sms()

        time.sleep(self._wait_btwn_cmd)

        sms_sent = SmsMessage(self._message, self._destination_number)

        # Start the FTP data transfer
        self._dl_id = self._launch_ftp_data_transfer()

        # Check the status of the FTP connection
        status = self._ftp_api.get_ftp_status(self._dl_id)

        # If the transfer is not working some exceptions
        if str(status) <> "transferring":
            # If the transfer is not established raised an exception
            if str(status) in ("notrunning", "transfer failed"):
                message = "FTP transfer failed / not started: %s" % str(status)
                raise DeviceException(DeviceException.CONNECTION_LOST, message)

            # If the transfer status is 'connecting'
            # additionally wait for the connection to be established
            elif str(status) == "connecting":
                self._logger.info(
                    "FTP transfer not started yet. STATUS is CONNECTING")
                time.sleep(self._wait_btwn_cmd)
                if str(status) == "connecting":
                    message = "FTP transfer status is CONNECTING for a too long time"
                    raise DeviceException(DeviceException.CONNECTION_LOST,
                                          message)

            # If the FTP data transfer is finished already
            # the transferred file length chosen is too short
            else:
                message = "FTP transfer finished before SMS has been sent"
                self._logger.error(message)
                raise AcsConfigException(
                    AcsConfigException.INVALID_TEST_CASE_FILE, message)

        # If the FTP data transfer is on going start the SMS sending procedures
        # If the FTP data transfer status is "transferring"
        else:

            # register on intent to receive incoming sms
            self._sms_api.register_for_sms_reception()

            # Send SMS to equipment using SMS parameters :
            # - SMS_TEXT
            # - DESTINATION_NUMBER
            self._sms_api.send_sms(self._destination_number, self._message)

            # Get received sms
            sms_received = self._sms_api.wait_for_incoming_sms(
                self._sms_transfer_timeout)

            # Compare sent and received SMS (Text,
            # Destination number)
            (result_verdict, result_message) = \
                compute_sms_equals(sms_sent, sms_received)

            self._logger.info(result_message)

            final_transfer_status = str(
                self._ftp_api.get_ftp_status(self._dl_id))
            while final_transfer_status <> "transfer successful":
                if str(final_transfer_status) in ("transfer successful",
                                                  "transferring"):
                    time.sleep(self._wait_btwn_cmd)
                else:
                    message = "FTP transfer failed after SMS sent: %s" % str(
                        final_transfer_status)
                    raise DeviceException(DeviceException.CONNECTION_LOST,
                                          message)
                final_transfer_status = str(
                    self._ftp_api.get_ftp_status(self._dl_id))

            if final_transfer_status == "transfer successful":
                message = "FTP transfer finished successfully"
                self._logger.info(message)
                result_message = result_message + ". " + message

        # Because in case of failure the IMS stack may have crashed
        # we need to double-check the IMS registration status.
        in_service_status = ImsRegistrationStatus.in_service()
        registration_status = self._get_registration_status()
        self._logger.info(
            "Registation status: %s (%d)" %
            (str(registration_status), registration_status.as_int()))
        # Compute the verdict
        if str(registration_status) != str(in_service_status):
            result_message = "IMS stack has crashed or IMS registration is lost."
            self._logger.error(result_message)
            result_verdict = Global.FAILURE

        # Return the test result
        return (result_verdict, result_message)