Exemple #1
0
 def delete_route(self, net_ip_addr):
     """
     Delete an IP route
     :type net_ip_addr: str
     :param net_ip_addr: IP address of the route
     :rtype: str
     :return: The command return
     """
     # Check OS platform
     os_str = platform.system().upper()
     if os_str == 'LINUX':
         # Linux:
         msg = "get_net_info_list: Not implemented for Linux platform"
         raise AcsBaseException(AcsBaseException.FEATURE_NOT_IMPLEMENTED,
                                msg)
     # Prepare command
     args = shlex.split("route DELETE %s" % net_ip_addr)
     try:
         # Debug log
         msg = "route DELETE %s" % net_ip_addr
         self.get_logger().debug(msg)
         p, q = run_local_command(args, False)
         data = p.communicate()
         # Use code page 860 to convert read bytes from windows console,
         # then normalize chars and convert them to utf-8 (ignore unknown symbols)
         strdata = unicodedata.normalize('NFKD',
                                         data[0].decode('cp860')).encode(
                                             'ascii', 'ignore')
         return strdata
     except Exception as error:
         msg = "delete_route: %s" % str(error)
         raise AcsBaseException(AcsBaseException.OPERATION_FAILED, msg)
Exemple #2
0
 def __connect_via_gpib(self):
     """
     Connect to equipment via GPIB
     """
     if "GPIBBoardId" in self.__args.keys():
         board_id = int(self.__args["GPIBBoardId"])
     else:
         raise AcsBaseException(AcsBaseException.INVALID_PARAMETER,
                                "The parameter 'GPIBBoardId' is required for configuring GPIB connection")
     if "GPIBAddress" in self.__args.keys():
         gpib_addr = int(self.__args["GPIBAddress"])
     else:
         raise AcsBaseException(AcsBaseException.INVALID_PARAMETER,
                                "The parameter 'GPIBAddress' is required for configuring GPIB connection")
     try:
         # Initialize GPIB connection to the equipment
         handle = pyvisa.GpibInstrument(gpib_addr, board_id)
         # Update handle value
         self._set_handle(handle)
     except (visaexception.VisaIOError,
             visaexception.VisaIOWarning,
             visaexception.VisaTypeError) as ex:
         msg = "Connection via GPIB failed. "
         msg += str(ex)
         self.get_logger().error(msg)
         raise TestEquipmentException(TestEquipmentException.VISA_LIBRARY_ERROR, msg)
Exemple #3
0
    def set_reject_call_mode(self, state, reason):
        # TODO: dgonza4x STORY 195 [QCTV][+7] Automate CSFB...
        """
        Enable or disable the reject call functionality
        from the network.

        :param state: reject call mode. Can be "OFF" or "ON"
        :type state: str

        :param reason: Integer representing the call rejection reason.
        :type reason: int
        """
        local_state = str(state).upper()
        if local_state not in ("ON", "OFF"):
            raise AcsBaseException(
                AcsBaseException.INVALID_PARAMETER,
                "Incorrect reject call mode. Must be 'ON' or 'OFF'")

        local_reason = str(reason)
        if not local_reason.isdigit():
            raise AcsBaseException(
                AcsBaseException.INVALID_PARAMETER,
                "Incorrect reject reason. Must be an integer.")

        # set reject mode
        self.get_root().send_command("CALL:PPRocedure:CSETup:REJect " +
                                     local_state)
        # set reject reason
        self.get_root().send_command("CALL:PPRocedure:CSETup:REJect:CCCause " +
                                     local_reason)
Exemple #4
0
def blocked(output, direct_exit=False):
    """ Raise an exception and report a BLOCKED status
    """
    EXEC_SCRIPT_CTX["OUTPUT"] = TCNAME + " # " + output + " --> BLOCKED"
    print_log("WARNING", EXEC_SCRIPT_CTX["OUTPUT"])
    ex = AcsBaseException(EXEC_SCRIPT_CTX["OUTPUT"])
    ex._error_code = BLOCKED
    EXEC_SCRIPT_CTX["VERDICT"] = BLOCKED
    finalStep(direct_exit=direct_exit)
    PL.Pupdr().Output.appendOutput("", None)
    raise ex
    def __init__(self, generic_error_msg, specific_msg=None):
        """
        Initializes this instance.

        :type generic_error_msg: str
        :param generic_error_msg: this object's generic error message.
        :type specific_msg: str
        :param specific_msg: specific additional error message.
            Optional parameter, defaults to C{None}.
        """
        AcsBaseException.__init__(self, generic_error_msg, specific_msg)
        self._error_code = self._BLOCKED
Exemple #6
0
    def get_interface_from_list(self, if_name):
        """
        Parse Window command: "route print" return,
        and return searched Interface
        :type if_name: String
        :param if_name: name of the interface to search

        :rtype: dict
        :return: if_list is a of dict(if_number,mac_address)
        """
        # Check OS platform
        os_str = platform.system().upper()
        if os_str == 'LINUX':
            # Linux:
            msg = "get_interface_list: Not implemented for Linux platform"
            raise AcsBaseException(AcsBaseException.FEATURE_NOT_IMPLEMENTED,
                                   msg)
            # Prepare command
        args = shlex.split("route print")
        try:
            p, q = run_local_command(args, False)
            data = p.communicate()
            # Use code page 860 to convert read bytes from windows console,
            # then normalize chars and convert them to utf-8 (ignore unknown symbols)
            strdata = unicodedata.normalize('NFKD',
                                            data[0].decode('cp860')).encode(
                                                'ascii', 'ignore')
            # Parse following str data to extract IF numbers and its MAC addresses (ex: out_tupple=(13,9c-8e-99-dd-d5-97))
            # "===========================================================================\n"
            # "Interface List\n"
            # " 13...9c 8e 99 dd d5 97 ......Intel(R) 82579LM Gigabit Network Connection\n"
            if_strdata = [
                elem.strip(" ") for elem in strdata.split(
                    "==========================================================================="
                )[1].split("\n") if match("^[0-9]", elem.strip(" "))
            ]
            if_list = {}
            for line in if_strdata:
                data = [str(elem.strip(" ")) for elem in line.split("...")][:2]
                # Stop parsing when get " 1..........."
                if data[1] != "":
                    if if_name in line:
                        if_list[data[0]] = data[1].replace(" ", "-").upper()
                else:
                    break
                    # Debug
            msg = "Interface found: %s" % str(if_list)
            self.get_logger().debug(msg)
            return if_list
        except Exception as error:
            msg = "get_interface_from_list: %s" % str(error)
            raise AcsBaseException(AcsBaseException.OPERATION_FAILED, msg)
Exemple #7
0
    def __init__(self, generic_error_msg, specific_msg=None):
        """
        Initializes this instance.

        :type generic_error_msg: str
        :param generic_error_msg: this object's generic error message.
        :type specific_msg: str
        :param specific_msg: specific additional error message.
            Optional parameter, defaults to C{None}.
        """
        AcsBaseException.__init__(self, generic_error_msg, specific_msg)
        # This exception family is (in most cases) non DUT related so do not fail on it
        self._error_code = self._BLOCKED
Exemple #8
0
    def __connect_via_tcpip(self):
        """
        Connect to equipment via TCPIP
        """
        if "TcpIpAddress" in self.__args.keys():
            ip_addr = str(self.__args["TcpIpAddress"])
        else:
            raise AcsBaseException(AcsBaseException.INVALID_PARAMETER,
                                   "The parameter 'TcpIpAddress' is required for configuring TCP/IP connection")
        board_id = ""
        if "TcpIpBoardId" in self.__args.keys():
            board_id = str(self.__args["TcpIpBoardId"])
        device_name = "INST0"
        if "TcpIpDeviceName" in self.__args.keys():
            device_name = str(self.__args["TcpIpDeviceName"])

        try:
            # Initialize TCP/IP connection to the equipment
            resource_name = "TCPIP%s::%s::%s::INSTR" % (board_id, ip_addr, device_name)
            self.get_logger().debug("TCPIP ressource name: %s" % resource_name)
            handle = pyvisa.Instrument(resource_name)
            handle.timeout = 10000

            # Update handle value
            self._set_handle(handle)
        except (visaexception.VisaIOError,
                visaexception.VisaIOWarning,
                visaexception.VisaTypeError) as ex:
            msg = "Connection via TCP/IP failed. "
            msg += str(ex)
            self.get_logger().error(msg)
            raise TestEquipmentException(TestEquipmentException.VISA_LIBRARY_ERROR, msg)
    def do_sms_test(self, ns):
        """
        Test for category b devices: Send an SMS

        :type ns: str
        :param ns: NS1 or NS2

        :rtype: Verdict, message
        """
        if ns not in ["NS1", "NS2"]:
            raise AcsBaseException(
                AcsBaseException.INVALID_PARAMETER,
                "Wrong Network simulator param, should be NS1 or NS2")
        if "NS1" in ns:
            ns_messaging = self._ns1_messaging
            ns_data = self._ns1_data
        else:
            ns_messaging = self._ns2_messaging
            ns_data = self._ns2_data

        # Wake up screen
        self._phone_system_api.wake_screen()

        # Check Data Connection State => PDP_ACTIVE before timeout
        ns_data.check_data_connection_state("PDP_ACTIVE",
                                            self._registration_timeout, False)

        # Mobile Terminated / Mobile Originated SMS
        (result_verdict, result_message) = self._send_sms(ns_messaging)
        result_message += " (%s). " % ns
        self._logger.info(result_message)

        return result_verdict, result_message
Exemple #10
0
 def wait_proper_lte_camp(self):
     """
     Wait for the DUT to camp on the LTE cell, and checks it gets a correct
     IP address.
     """
     # Check Data Connection State => CON before timeout
     self._ns_lte_data.check_data_connection_state(
         "CON",
         self._registration_timeout,
         blocking=True,
         cell_id=self._ns_lte_cell_id)
     # Check registration state is connected using
     # registrationTimeout from Device_Catalog.xml (Non blocking
     # for this test if function isn't implemented on CDK)
     self._modem_api.check_cdk_registration_bfor_timeout(
         self._registration_timeout)
     # Check that DUT is registered on the good RAT
     self._modem_api.check_network_type_before_timeout(
         self._ns_lte_data.get_network_type(), self._registration_timeout)
     ip_address = self._networking_api.get_interface_ipv4_address(
         self._interface)
     if ip_address != self._ns_lte_ip_dut:
         raise AcsBaseException(
             AcsBaseException.PROHIBITIVE_BEHAVIOR,
             "Wrong IP address: %s should be %s" %
             (ip_address, self._ns_lte_ip_dut))
Exemple #11
0
 def get_score(
     self,
     stat_type="MEDIAN"
 ):  #This method will override the method at the end of itreation
     IApplication.get_score(self, stat_type)
     msg = "Partially Automated - Unable to parse final result,Check webxprt_result folder for screenshot "
     raise AcsBaseException("", msg)
    def run(self, context):
        """
        Runs the test step

        :type context: TestStepContext
        :param context: test case context
        """

        DeviceTestStepBase.run(self, context)

        is_speech_call_supported = str_to_bool(
            self._device.config["isSpeechCallSupported"])
        is_sms_supported = str_to_bool(self._device.config["isSmsSupported"])

        if is_speech_call_supported:
            self._voice_call_api.dial(self._pars.destination_number, False)
            time.sleep(15)
            self._voice_call_api.release()
        else:
            if is_sms_supported:
                sms = context.get_info(self._pars.sms)
                sms.send_sms()
                (status, msg) = sms.get_sms()
                self._logger.info(msg)
                if status == Global.FAILURE:
                    raise DeviceException(DeviceException.SMS_EXCEPTION, msg)
            else:
                packet_loss = self._networking_api.ping(
                    self._pars.destination_ip, 32, 1)
                if packet_loss.value > 0:
                    raise AcsBaseException(
                        AcsBaseException.OPERATION_FAILED,
                        "Packet lost greater than zero (value=%.0f%%)" %
                        packet_loss.value)
Exemple #13
0
 def get_score(
     self,
     stat_type="MEDIAN"
 ):  #This method will override the method at the end of itreation
     IApplication.get_score(self, stat_type)
     msg = "Partially Automated-Unable to fetch score.Check BxBenchPCCG_result folder for screenshot "
     raise AcsBaseException("", msg)
Exemple #14
0
def int_to_bcd(int_number):
    """
    Convert a int number to a BCD format

    :param int_number: number in int or a string that represents an int number without sign (+-)
    :type int_number: str | int
    :return: bcd_number
    :rtype: int
    """
    binary_dict = {
        '0': "0000",
        '1': "0001",
        '2': "0010",
        '3': "0011",
        '4': "0100",
        '5': "0101",
        '6': "0110",
        '7': "0111",
        '8': "1000",
        '9': "1001",
        'None': ""
    }
    bcd_number = ""
    for i in str(int_number):
        try:
            bcd_number += binary_dict[i]
        except KeyError:
            raise AcsBaseException(
                AcsBaseException.INVALID_PARAMETER,
                "The number \"%s\" to be converted to BCD contains "
                "other char than digits <0..9>" % (str(int_number)))
    return int(bcd_number, 2)
Exemple #15
0
    def wait_for_audio_state(self, state, timeout):
        """
        Waits to reach a voice call state until a timeout.

        :type state: UECmd.AUDIO_STATE
        :param state: expected state (see UECmd.AUDIO_STATE)

        :type timeout: int
        :param timeout: maximum time to wait in seconds

        :return: None
        """
        self._logger.info(
            "Waiting for %s state before %d seconds...", state, timeout)
        time_count = 0
        read_state = "UNKNOWN"
        state_reached = False

        while (state_reached == False) and time_count <= timeout:
            time_count += 1
            read_state = self.get_audio_state()
            self._logger.info("State is %s !" % (str(read_state)))

            if read_state == state:
                self._logger.info("State %s has been reached!" % (str(state)))
                state_reached = True

        if not state_reached:
            err_msg = "Did not reach %s state" % (str(state))
            raise AcsBaseException(
                AcsBaseException.TIMEOUT_REACHED,
                err_msg)
Exemple #16
0
 def include_calling_party_number(self, state):
     """
     Sets whether to include the calling party number information record.
     :type state: str
     :param state: If "on" the calling party number parameters is sent to
         the mobile station. If "no" the calling party number parameters is not
         sent to the mobile station.
     :raise exception: AcsBaseException if the parameter is neither on or
         off.
     """
     self.get_logger().info("Setting inclusion of calling party info to:"
                            " %s" % state)
     # Storing the GPIB command name.
     gpib_command = "CALL:CPNumber:INCLusion"
     # Checking if the input is the in expected range.
     if state.upper() == "ON":
         gpib_parameter = "INCL"
         self.get_logger().info("The calling party number parameters will"
                                " be sent to the DUT")
     elif state.upper() == "OFF":
         gpib_parameter = "EXCL"
         self.get_logger().info("The calling party number parameters won't"
                                " be sent to the DUT")
     else:
         # Otherwise raise an exception.
         raise AcsBaseException(
             AcsBaseException.INVALID_PARAMETER,
             "Wrong parameter passed to the"
             " \"include_calling_party_number\""
             " method should be on or off is: %s" % gpib_parameter)
     self.get_logger().debug("Sending the following GPIB command %s %s" %
                             (gpib_command, gpib_parameter))
     # Sending the GPIB Command to the equipment.
     self.get_root().send_command("%s %s" % (gpib_command, gpib_parameter))
Exemple #17
0
    def _get_module_and_class_names(self, name=None):
        """
        Returns the names of the Agent module and class
        that handles method call for the given domain C{name}.

        :type name: str
        :param name: the domain name. Possible values:
            - Networking
            - Connectivity
            - WifiConnectivity
            - ...

        :rtype: tuple
        :return: the module name and the class name as tuple.

        :raise AcsBaseException: If the parameter name is not a valid key of
        the __MODULES_AND_CLASSES_NAME dictionary
        """
        if name in self.__MODULES_AND_CLASSES_NAME:
            # if the "name" parameter is part of the __MODULES_AND_CLASSES_NAME
            # dictionary keys.
            return self.__MODULES_AND_CLASSES_NAME[name]
        elif name is None:
            # if no parameter was passed to the method.
            return self._module_name, self._class_name
        else:
            # if the passed "name" parameter is not a key of the
            # __MODULES_AND_CLASSES_NAME dictionary.
            raise AcsBaseException(
                AcsBaseException.INVALID_PARAMETER,
                "The \"name\" parameter must be a \
                                   valid key of the \
                                   \"__MODULES_AND_CLASSES_NAME\" \
                                   dictionary")
Exemple #18
0
 def set_calling_party_number(self, number):
     """
     Sets the ASCII representation of the calling party number.
     The value is included in the SETUP message to the called mobile
     station when INCLude is selected by CALL:CPNumber:INCLusion.
     It is displayed on the called mobile station's screen when "ALLowed"
     is selected by CALL:CPNumber:PRESentation[:INDicator].
     :type number: str
     :param number: Range: 0 to 20 characters, each character from the set
     of 0123456789abc*# .
     :raise AcsBaseException: if the number passed as parameter is not in
     the expected range.
     """
     self.get_logger().info("Setting the calling party phone number to:"
                            " %s" % number)
     # Storing the GPIB command name.
     gpib_command = "CALL:CPNumber"
     # Checking if the input is in the expected range.
     regular_exp = re.compile('^[0-9abc*#]{0,20}$')
     if not regular_exp.match(number):
         raise AcsBaseException(
             AcsBaseException.INVALID_PARAMETER,
             "Wrong parameter passed to the"
             " \"set_calling_party_number\" method"
             " should be 0 to 20 characters, each"
             " character from the set of"
             " 0123456789abc*# , is: %s" % number)
     self.get_logger().info("Sending the following GPIB command %s %s" %
                            (gpib_command, number))
     # Sending the GPIB Command to the equipment.
     self.get_root().send_command("%s \'%s\'" % (gpib_command, number))
Exemple #19
0
    def delete_host_file(self, file_name):
        """
        Delete a file on the host computer. This can apply to external media storage
        (plugged on USB for example)

        :type file_name: str
        :param file_name: file name on host, eg : /media/storage/file.bin
        """
        # Check OS platform
        os_str = platform.system().upper()

        if os_str != 'LINUX':
            msg = "delete file on host : Not implemented for OS %s" % os_str
            raise AcsBaseException(AcsBaseException.FEATURE_NOT_IMPLEMENTED,
                                   msg)
        else:
            # Now remove file
            cmd = "rm -rf %s" % str(file_name)
            output = self.run_cmd(cmd)
            std_output = output["std"]
            err_output = output["err"]

            if err_output != "" and std_output == "":
                raise TestEquipmentException(
                    TestEquipmentException.OPERATION_FAILED, err_output)

        output = "%s %s" % (std_output, err_output) if (
            err_output and err_output) else (err_output or err_output)

        return output
    def set_bt_power(self, mode):
        """
        Sets the Bluetooth power.

        :type mode: str or int
        :param mode: can be ('on', '1', 1, STATE_ON) to enable
                            ('off', '0', 0, STATE_OFF) to disable

        :return: None
        """
        # function = "TurnOnOffBTByUI"
        function = "QuickTurnOnOffBTByUI"
        # function = "TurnOnOffBluetoothFromNetworkAdapter"
        # Get the method and class name of the UEcommand on the embedded side
        args = "action="
        module_name, class_name = self._get_module_and_class_names("UIBT")
        # module_name, class_name = self._get_module_and_class_names("BluetoothConnectivity")
        if mode == 'on' or mode == "1" or mode == 1 or mode == 'STATE_ON':
            args += "TurnOn"
        elif mode == 'off' or mode == "0" or mode == 0 or mode == 'STATE_OFF':
            args += "TurnOff"
        else:
            raise AcsBaseException(AcsBaseException.INVALID_PARAMETER,
                                   "<mode> in set_bt_power(%s)", mode)

        # Launch the UEcmd on the embedded side
        self._internal_uecmd_exec(module_name, class_name, function, args, 120)
Exemple #21
0
 def set_eutran_neighbor_cell(self, earfcn, include_bandwidth, bandwidth,
                              include_priority, priority, thresh_hight,
                              include_thresh_low, thresh_low,
                              include_qrxlevmin, qrxlevmin):
     """
     Sets the EUTRAN neighbor cells of the current GERAN cell.
     :param earfcn: list of the earfcn of each cell. Range 0 to 65535
     :type earfcn: list
     :param include_bandwidth: list of the bandwidth inclusion state of each
     cell. Range 0|1
     :type include_bandwidth: list
     """
     nb_of_cells = 0
     # Create list of all the parameters.
     par = [
         earfcn, include_bandwidth, bandwidth, include_priority, priority,
         thresh_hight, include_thresh_low, thresh_low, include_qrxlevmin,
         qrxlevmin
     ]
     gpib = "CALL:EUTR:TABL "
     cells = []
     # Each parameters should be a list and all list should have the same
     # length.
     for i in par:
         if not isinstance(i, list):
             raise AcsBaseException(
                 AcsBaseException.INVALID_PARAMETER,
                 "All parameters should be lists: %s" % i)
         nb_of_cells = len(earfcn)
         if len(i) != nb_of_cells:
             raise AcsBaseException(
                 AcsBaseException.INVALID_PARAMETER,
                 "All parameters should have the same"
                 " length")
     # Loop for parsing each parameter for a given cell.
     for cell_nb in range(nb_of_cells):
         # Loop creating a comma separated str of the values
         # corresponding to the cell j.
         params = ",".join([str(i[cell_nb]) for i in par])
         cells.append(params)
     # Joining all the cells parameters into a comma separated str.
     gpib_parm = ",".join(cells)
     # Sending the GPIB Command to the netWork simulator.
     self.get_logger().info("Adding EUTRAN neighbor cell to the current"
                            " GERAN cell.")
     self._visa.send_command(gpib + gpib_parm)
Exemple #22
0
    def run(self, context):
        """
        Create a random file

        :type context: TestStepContext
        :param context: test case context
        """
        TestStepBase.run(self, context)

        destination_path = self._pars.destination_path  # Destination path
        if destination_path == '[TEMP]':
            destination_path = tempfile.mkdtemp()
        if self._pars.rand_file_size_min is not None:
            if self._pars.rand_file_size_min >= self._pars.rand_file_size:
                self._logger.error(
                    "{0}:  RAND_FILE_SIZE_MIN of {1} cannot be <= to RAND_FILE_SIZE, which is = {2}"
                    .format(self._pars.id, self._pars.rand_file_size_min,
                            self._pars.rand_file_size))
                msg = "{0}:  RAND_FILE_SIZE_MIN of {1} cannot be <= to RAND_FILE_SIZE, which is = {2}".format(
                    self._pars.id, self._pars.rand_file_size_min,
                    self._pars.rand_file_size)
                raise AcsBaseException(AcsBaseException.INVALID_PARAMETER, msg)
            else:
                rand_file_size_min = self._pars.rand_file_size_min
        else:
            rand_file_size_min = 0
        if rand_file_size_min > 0:
            rand_file_size = int(
                random.randrange(rand_file_size_min,
                                 self._pars.rand_file_size + 1))
        else:
            rand_file_size = self._pars.rand_file_size
        rand_file_seed = self._pars.rand_file_seed
        rand_file_name = self._pars.rand_file_name

        self._logger.debug(
            "%s:  rand_file_size = %d, rand_file_seed = %d, rand_file_name = %s "
            % (self._pars.id, rand_file_size, rand_file_seed, rand_file_name))

        file_path = os.path.join(destination_path, rand_file_name)

        try:
            # Create the file
            self.create_rand_bin_file(file_path=file_path,
                                      file_size_mb=rand_file_size,
                                      seed=rand_file_seed)
        except Exception as e:
            raise AcsToolException(AcsToolException.DEFAULT_ERROR_CODE, str(e))

        # Check the file was created
        if os.path.exists(file_path):
            self._logger.info("{0}:  Created {1} to {2}".format(
                self._pars.id, rand_file_name, destination_path))
            context.set_info(self._pars.ctx_destination_path, file_path)
        else:
            msg = "{0}:  Failed to create {1} to {2}".format(
                self._pars.id, rand_file_name, destination_path)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
Exemple #23
0
 def store_instance(self, name, obj):
     """
     store an instance with a given name as key
     """
     self.__logger.warning("OVERMIND store OBJECT %s" % (name))
     if self.__ref_dico.has_key(name):
         msg = self.__LOG_TAG + "key %s already exist in known object" % name
         self.__logger.error(msg)
         raise AcsBaseException(AcsBaseException.OPERATION_FAILED, msg)
     # store a weak reference to avoid locking object
     self.__ref_dico[name] = weakref.proxy(obj)
    def do_ratsel_main_test(self, ns):
        """
        RAT selection Main test: depending on device capability (speech, sms),
        perform a voice call or an SMS send.

        :type ns: str
        :param ns: NS1 or NS2
        :rtype: Verdict, message
        """
        verdict = Global.SUCCESS
        output = "No Error"

        if ns not in ["NS1", "NS2"]:
            raise AcsBaseException(
                AcsBaseException.INVALID_PARAMETER,
                "Wrong Network simulator param, should be NS1 or NS2")

        # Category a: CS speech call is supported
        if self._speechcall_supported:
            # Wake up screen
            self._phone_system_api.wake_screen()
            self._logger.info("")
            self._logger.info(
                "*** Speech call is supported by device, test %s VC" %
                self._vc_type)
            # wait for 5 second
            self._logger.info("")
            self._logger.info("*** Waiting for 5 seconds ...")
            time.sleep(5)
            (verdict, output) = self.do_vc_test(ns)

        # Category b: CS speech call is not supported but SMS is supported
        elif not self._speechcall_supported and self._sms_supported:
            # Wake up screen
            self._phone_system_api.wake_screen()
            self._logger.info("")
            self._logger.info(
                "*** Speech call is not is supported by device, but SMS is supported, test %s SMS"
                % self._sms_type)
            # wait for 5 second
            self._logger.info("")
            self._logger.info("*** Waiting for 5 seconds ...")
            time.sleep(5)
            (verdict, output) = self.do_sms_test(ns)

        # Category c: CS speech call and SMS are not supported
        else:
            self._logger.info("")
            self._logger.info(
                "*** Device doesn't support speech call nor SMS, do nothing else"
            )

        return verdict, output
Exemple #25
0
 def add_route(self, net_ip_addr, ip_mask, gateway_ip_addr, if_number):
     """
     Add an IP route.
     :type net_ip_addr: str
     :param net_ip_addr: IP address of the route
     :type ip_mask: str
     :param ip_mask: IP Mask of the route (ex: "255.255.255.0")
     :type gateway_ip_addr: str
     :param gateway_ip_addr: IP address of the Gateway
     :type if_number: str
     :param if_number: Network Interface number of the Gateway (ex: "17")
     :rtype: str
     :return: The command return
     """
     # Check OS platform
     os_str = platform.system().upper()
     if os_str == 'LINUX':
         # Linux:
         msg = "get_net_info_list: Not implemented for Linux platform"
         raise AcsBaseException(AcsBaseException.FEATURE_NOT_IMPLEMENTED,
                                msg)
     # Prepare command
     args = shlex.split("route ADD %s MASK %s %s IF %s" %
                        (net_ip_addr, ip_mask, gateway_ip_addr, if_number))
     try:
         # Debug log
         msg = "route ADD %s MASK %s %s IF %s" \
               % (net_ip_addr, ip_mask, gateway_ip_addr, if_number)
         self.get_logger().debug(msg)
         p, q = run_local_command(args, False)
         data = p.communicate()
         # Use code page 860 to convert read bytes from windows console,
         # then normalize chars and convert them to utf-8 (ignore unknown symbols)
         strdata = unicodedata.normalize('NFKD',
                                         data[0].decode('cp860')).encode(
                                             'ascii', 'ignore')
         return strdata
     except Exception as error:
         msg = "add_route: %s" % str(error)
         raise AcsBaseException(AcsBaseException.OPERATION_FAILED, msg)
Exemple #26
0
    def get_instance(self, name, raise_error=True):
        """
        get an instance by its stored name
        """
        if raise_error:
            if name not in self.__ref_dico.keys():
                msg = self.__LOG_TAG + "key %s does not exist" % name
                self.__logger.error(msg)
                raise AcsBaseException(AcsBaseException.OPERATION_FAILED, msg)

        a = self.__ref_dico.get(name)
        self.__logger.debug("OVERMIND get OBJECT %s" % (name))
        return a
    def set_cells_technology(self, cells_tech):
        """
        Sets cells technology used by the equipment

        :type cells_tech: List[str]
        :param cells_tech: List of cell technology (2G|GSM, 3G|WCDMA, TDSCDMA, 4G|LTE)
        """
        if len(cells_tech) == 1:
            cell_tech = cells_tech[0]
            if cell_tech in ["3G", "WCDMA"]:
                self._use_cell_3g()
            elif cell_tech in ["2G", "GSM"]:
                self._use_cell_2g()
            else:
                error_msg = "Wrong value for Cell tech {0} (Possible values: 4G|LTE)"
                raise AcsBaseException(AcsBaseException.INVALID_PARAMETER,
                                       error_msg)
        else:
            error_msg = "Only one cell can be set on CMW500 ({0} given)".format(
                len(cells_tech))
            raise AcsBaseException(AcsBaseException.INVALID_PARAMETER,
                                   error_msg)
    def _go_to_idle_state(self, ns, timeout=None):
        """
        :type ns_messaging: IMessaging3G
        :param ns_messaging: network simulator messaging
        :type timeout: int
        :param timeout: timeout to reach idle state
        :rtype: Verdict, message
        """
        if ns not in ["NS1", "NS2"]:
            raise AcsBaseException(
                AcsBaseException.INVALID_PARAMETER,
                "Wrong Network simulator param, should be NS1 or NS2")

        if timeout is None:
            timeout = self._registration_timeout

        if "NS1" in ns:
            ns_data = self._ns1_data
            ns_cell_tech = self._ns1_cell_tech
        else:
            ns_data = self._ns2_data
            ns_cell_tech = self._ns2_cell_tech

        msg = "Go to Idle state before %s seconds..." % str(timeout)
        self._logger.info(msg)

        start_time = time.time()
        while (time.time() - start_time) <= timeout:
            if "3G" in ns_cell_tech:
                if "PDP_ACTIVE" in str(ns_data.get_data_connection_status(
                )) and "idle" in str(ns_data.get_rrc_states()).lower():
                    msg = "DUT reach IDLE mode (%s) in %ds. " % (
                        ns, time.time() - start_time)
                    self._logger.info(msg)
                    return Global.SUCCESS, msg

            elif "PDP_ACTIVE" in str(
                    ns_data.get_data_connection_status()) or "ATTACHED" in str(
                        ns_data.get_data_connection_status()):
                msg = "DUT reach IDLE mode (%s) in %ds. " % (ns, time.time() -
                                                             start_time)
                self._logger.info(msg)
                return Global.SUCCESS, msg

            # Wait for 1 s
            time.sleep(1)

        # Timeout as been reach, fail to reach Idle state.
        msg = "DUT Failed to reach IDLE mode (%s) in %ds. " % (ns, timeout)
        self._logger.error(msg)
        return Global.FAILURE, msg
Exemple #29
0
    def configure_ims(self, bench_config):
        """
        Applies IMS configuration provided in the Bench Config
        :type bench_config: BenchConfigParameters
        :param bench_config: Bench config parameters
        """
        # Check if IMS virtual network is running
        ims_vn_status = self._visa.query("IMSVNSTAT? " + str(self._vnid))
        # If yes stop it to configure it
        if ims_vn_status == "RUNNING":
            self._visa.send_command("IMSSTOPVN " + str(self._vnid))
        # Retrieve IMS configuration for Anritsu MD8475A from bench config
        ims_network_params = bench_config.get_parameters("IMS_NETWORK")
        available_params = ims_network_params.get_dict()

        if "IMS_CONFIGURATION" in available_params:
            ims_config_file = ims_network_params.get_param_value(
                "IMS_CONFIGURATION")
            ims_config_file = os.path.join(os.getcwd(), Paths.EXECUTION_CONFIG,
                                           ims_config_file)
            # Parse IMS configuration YAML file to retrieve IMS configuration for Anritsu MD8475A
            ims_generator = ImsConfigGenerator(ims_config_file, None,
                                               ("Anritsu parameters", ),
                                               self._logger)
            ims_generator.load_parameters()
            ims_config_list = ims_generator.document["Anritsu parameters"]
            for key in ims_config_list:
                value = ims_config_list[key]
                # Check if configuration file is correctly filled (it shall have the same field as AnritsuM8475A._IMS_CONFIG_GPIB keys)
                if key not in AnritsuM8475A._IMS_CONFIG_GPIB:
                    AcsBaseException(
                        AcsBaseException.INVALID_PARAMETER,
                        "%s Anritsu MD8475A configuration file is not in the good format, please update it"
                        % ims_config_file)
                # Remove all unneeded user
                if key == "User List":
                    pass
                    # GPIB does not work, if it works one day uncomment it


#                     nb_user = self._visa.query(AnritsuM8475A._IMS_CONFIG_GPIB[key], True)
#                     while nb_user >= 1:
#                         self._visa.send_command("IMSCSCFUSERSLISTDEL " + str(nb_user))
#                         nb_user -= 1
                else:
                    # Apply configuration
                    gpib_cmd = AnritsuM8475A._IMS_CONFIG_GPIB[key] + str(
                        self._vnid) + "," + str(value)
                    self._visa.send_command(gpib_cmd)
Exemple #30
0
 def __init__(self, root, cell_name="A"):
     """
     Constructor
     :type root: weakref
     :param root: a weak reference on the root class (Agilent6621A)
     """
     IData4G.__init__(self)
     self.__root = root
     self.__cell_name = cell_name
     if self.__cell_name is "A":
         self.__id = 1
     elif self.__cell_name is "B":
         self.__id = 2
     else:
         raise AcsBaseException(AcsBaseException.INVALID_PARAMETER,
                 "Parameter \"%s\" is not valid for Data4g" % str(cell_name))