コード例 #1
0
    def __init__(self, name, model, eqt_params, bench_params):
        """
        Constructor
        """
        # Initialize class parent
        ISniffer.__init__(self)
        EquipmentBase.__init__(self, name, model, eqt_params)

        computer = str(bench_params.get_param_value("Computer"))
        # NOTE: import here to avoid circular dependency on
        # EquipmentManager if imported at top level
        from acs_test_scripts.Equipment.EquipmentManager import EquipmentManager
        self._em = EquipmentManager()
        self._computer = self._em.get_computer(computer)

        self._ssh_process = None
        self._ssh_queue = None
        self._local_out = ""
        self._sniff_ongoing = False
        self._wifi_interface = bench_params.get_param_value("Interface", "")
        if self._wifi_interface == "":
            self._wifi_interface = self._computer.get_wifi_interface()

        self._sniffer_tool_checked = False
        self._sniffer_cmd = "NOT_YET_DEFINED"
コード例 #2
0
    def run(self, context):
        """
        Disable a network interface on the host pc

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

        # Get parameters
        self._hostpc = EquipmentManager().get_computer(eqt_name="COMPUTER1")
        self._interface = self._pars.interface

        # Bring down the specified network interface
        if 'Linux' in self._hostpc.get_os():
            primaryAddress = str(self._hostpc.get_eqt_dict().get_param_value(
                "IP", ""))
            username = str(self._hostpc.get_eqt_dict().get_param_value(
                "username", ""))

            if os.system('ssh {0}@{1} ifconfig {2} down'.format(
                    username, primaryAddress, self._interface)) != 0:
                msg = "Failed to bring the {0} network interface up".format(
                    self._interface)
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        else:
            if os.system(
                    'netsh interface set interface name="{0}" admin="disabled"'
                    .format(self._interface)) != 0:
                msg = "Failed to bring the {0} network interface down".format(
                    self._interface)
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)
コード例 #3
0
ファイル: WiredHeadset.py プロジェクト: zenghui0-0/tempfile
    def __init__(self, name, model, eqt_params, bench_params):
        """
        Constructor
        :type name: str
        :param name: the bench configuration name of the equipment
        :type model: str
        :param model: the model of the equipment
        :type eqt_params: dict
        :param eqt_params: the dictionary containing equipment parameters
        """
        EquipmentBase.__init__(self, name, model, eqt_params)
        IHeadset.__init__(self)
        self.__wired_headset = None
        self.__headphone = None
        self._bench_params = bench_params

        # NOTE: import here to avoid circular dependency on
        # EquipmentManager if imported at top level
        from acs_test_scripts.Equipment.EquipmentManager import EquipmentManager
        self._em = EquipmentManager()
        self._io_card = self._em.get_io_card("IO_CARD")

        if ((self._bench_params.has_parameter("wired_headset")) and
            (self._bench_params.get_param_value("wired_headset") != "")):
            self.__wired_headset = \
                int(self._bench_params.get_param_value("wired_headset"))

        if ((self._bench_params.has_parameter("headphone"))
                and (self._bench_params.get_param_value("headphone") != "")):
            self.__headphone = \
                int(self._bench_params.get_param_value("headphone"))

        if self._io_card is None:
            self._logger.info("No IO card instance")
コード例 #4
0
ファイル: RunIperf.py プロジェクト: zenghui0-0/tempfile
 def __init__(self, tc_conf, global_conf, ts_conf, factory):
     DeviceTestStepBase.__init__(self, tc_conf, global_conf, ts_conf, factory)
     self.server_object = None
     self.networking_api = self._device.get_uecmd("Networking")
     self.svr_networking_api = None
     self.equip_mgr = EquipmentManager()
     self.device_mgr = DeviceManager()
     self._iperf_settings = None
コード例 #5
0
ファイル: InstallApp.py プロジェクト: zenghui0-0/tempfile
 def __init__(self, tc_conf, global_conf, ts_conf, factory):
     """
     Initialize test step
     """
     DeviceTestStepBase.__init__(self, tc_conf, global_conf, ts_conf, factory)
     self._system_api = self._device.get_uecmd("System")
     self._app_api = self._device.get_uecmd("AppMgmt")
     self._equipment_manager = EquipmentManager()
     self._application = AndroidApplication(logger=self._logger)
コード例 #6
0
def get_three_way_cutter():
    if os.environ.get(NOSERUNNER):
        from testlib.common.map import DeviceMap
        mapObj = DeviceMap()
        three_way_cutter = mapObj.getValue("three_way_cutter")
        print "[info]---get three way cutter by map.conf:", three_way_cutter
    else:
        from acs_test_scripts.Equipment.EquipmentManager import EquipmentManager
        io_card = EquipmentManager().get_io_cards()["IO_CARD"]
        three_way_cutter = io_card.get_bench_params().get_param_value("ThreeChargingModeSwitchCutter")
        print "[info]---get three way cutter by Bench:", three_way_cutter
    return ThreeWayCutter(three_way_cutter)
コード例 #7
0
ファイル: power_supply.py プロジェクト: zenghui0-0/tempfile
def get_power_supply_obj():
    if os.environ.get(NOSERUNNER):
        from testlib.common.map import DeviceMap
        mapObj = DeviceMap()
        power_supply_port = mapObj.getValue("power_supply")
        print "[info]---get power supply port by map.conf:", power_supply_port
    else:
        from acs_test_scripts.Equipment.EquipmentManager import EquipmentManager
        io_card = EquipmentManager().get_io_cards()["IO_CARD"]
        power_supply_port = io_card.get_bench_params().get_param_value("DaXin")
        print "[info]---get power supply port by Bench:", power_supply_port
    return PowerSupply(power_supply_port)
コード例 #8
0
ファイル: RsCmw500.py プロジェクト: zenghui0-0/tempfile
    def __init__(self, name, model, eqt_params, bench_params):
        """
        Constructor
        :type name: str
        :param name: the bench configuration name of the equipment
        :type model: str
        :param model: the model of the equipment
        :type eqt_params: dict
        :param eqt_params: the dictionary containing equipment parameters
        :type bench_params: BenchConfigParameters
        :param bench_params: the dictionary containing equipment bench parameters
        """
        # Initialize class parent
        ICellNetSim.__init__(self)
        VisaEquipmentBase.__init__(self, name, model, eqt_params, bench_params)

        # Initialize attributes
        self.__name = name
        self.__model = model
        self.__eqt_params = eqt_params
        self.__handle = None
        self.__cells = []
        # Get a reference of equipment manager
        self._em = EM()
        self._status = None
コード例 #9
0
    def run(self, context):
        """
        Connect USB tethering

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

        # Start the USB tether to get a virtual ethernet connection from phone
        self._hostpc = EquipmentManager().get_computer(eqt_name="COMPUTER1")
        self._timeout = self._pars.time_out_sec

        netAPI = self._device.get_uecmd("Networking")

        usb_tethering_start_time = time.time()
        usb_tethering_unavailable = False
        while (time.time() - usb_tethering_start_time < self._timeout) and usb_tethering_unavailable == False:
            time.sleep(1)

            try:
                netAPI.stop_usb_tethering(unplug=True)
                usb_tethering_unavailable = True
            except Exception, e:
                usb_tethering_unavailable = False
                msg = "Failed to stop the USB tether on the device: {0}. Retry to stop USB tether after 1 second".format(e)
                self._logger.info(msg)
コード例 #10
0
class EnableNetworkInterfaceHost(TestStepBase):
    """
    Implements a Test Step to enable a network interface on the host pc
    """

    def run(self, context):
        """
        Enable a network interface on the host pc

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

        # Get parameters
        self._hostpc = EquipmentManager().get_computer(eqt_name="COMPUTER1")
        self._timeout = self._pars.dhcp_timeout_sec
        self._interface = self._pars.interface

        # Bring up the specified network interface
        if 'Linux' in self._hostpc.get_os():
            primaryAddress =  str(self._hostpc.get_eqt_dict().get_param_value("IP", ""))
            username =  str(self._hostpc.get_eqt_dict().get_param_value("username", ""))

            if os.system('ssh {0}@{1} ifconfig {2} up'.format(username, primaryAddress, self._interface)) != 0:
                msg = "Failed to bring the {0} network interface up".format(self._interface)
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)

            # Configure the tethered network interface on the host using DHCP
            network_interface_start_time = time.time()
            network_interface_available = False
            while (time.time() - network_interface_start_time < self._timeout) and network_interface_available == False:
                time.sleep(1)

                try:
                    self._hostpc.dhclient(self._interface)
                    network_interface_available = True
                except Exception, e:
                    network_interface_available = False
                    msg = "Failed to allocate IP address to {0} : {1}".format(self._interface, e)
                    self._logger.info(msg)

            if network_interface_available == False:
                msg = "DHCP time out occurred while allocating IP address to {0}. Aborting TestStep execution".format(self._interface)
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        else:
コード例 #11
0
ファイル: BroxtonDevice.py プロジェクト: zenghui0-0/tempfile
    def __init__(self, config, logger):
        """
        Constructor

        :type  phone_name: string
        :param phone_name: Name of the current phone(e.g. PHONE1)
        """

        IntelDeviceBase.__init__(self, config, logger)

        self._cellular_network_interface = self.get_config("cellularNetworkInterface", "rmnet0")

        self._em = EquipmentManager()
        iocard = self.get_config("IoCard", "IO_CARD", str)
        self._io_card = self._em.get_io_card(iocard)
        self._usb_recovery_ongoing = False
        self.prevent_usb_plug = 5
コード例 #12
0
    def __init__(self, device):
        """
        Initializes this instance.

        :type device: Device
        :param device: The DUT
        """
        self.__device = device
        self._logger = device.get_logger()
        self._touch_screen_event_file = device.get_touchsreen_event_file()
        self._global_config = None
        self._dut_config = None
        self._execution_config_path = None
        self._additionnals = None
        self._arguments = None
        self._application_uri = None
        self._path_ref = None
        self._path_base = None
        self._phonesystem = device.get_uecmd("PhoneSystem")
        self._networking = device.get_uecmd("Networking")
        self._display = device.get_uecmd("Display")
        self._keyevent = device.get_uecmd("KeyEvent")
        self._system_api = device.get_uecmd("System")
        self._app_api = device.get_uecmd("AppMgmt")
        self._results = {}
        self.is_lower_better = True
        self._benchmark_name = self.__class__.__name__.lower()
        result_folder = "%s_result" % self._benchmark_name
        report_dir = self._get_report_tree()
        report_dir.create_subfolder(result_folder)
        self._result_file = None
        self._run_no = 0
        self.__report_path = report_dir.get_subfolder_path(result_folder)
        equipment_mgmt = EquipmentManager()
        self.io_cards = equipment_mgmt.get_io_cards()
        self.io_cards = equipment_mgmt.get_io_cards()
        self.hard_reboot = False
        self._additionnals = None
        self._sysdebug_apis = None
        self._need_restart = False
        for key in self.io_cards.keys():
            if "IO_CARD" in key and self.io_cards[key] is not None:
                self.hard_reboot = True
                self.io_card = self.io_cards[key]
                break
コード例 #13
0
ファイル: P2pSupplicant.py プロジェクト: zenghui0-0/tempfile
    def __init__(self, name, model, eqt_params, bench_params):
        """
        Constructor
        """
        IP2pSupplicant.__init__(self)
        EquipmentBase.__init__(self, name, model, eqt_params)
        computer = str(bench_params.get_param_value("Computer"))
        # NOTE: import here to avoid circular dependency on
        # EquipmentManager if imported at top level
        from acs_test_scripts.Equipment.EquipmentManager import EquipmentManager
        self._em = EquipmentManager()
        self._computer = self._em.get_computer(computer)
        self._p2psupplicant_ongoing = False

        # Get binary and cofiguration file path
        self._wpa_supplicant_bin = posixpath.realpath(
            eqt_params[model]["Binary"])
        self._wpa_p2p_conf = posixpath.realpath(
            eqt_params[model]["Configuration"])
コード例 #14
0
    def _download_crashtooluploader(self):
        """
        Download CrashToolUploader from official url and return the destination path.

        :return: path to CrashToolUploader. In case of errors returns an empty string
        """
        crashtooluploader_path = ""
        try:
            art_mgr = EquipmentManager().get_artifact_manager(
                "ARTIFACT_MANAGER")
            crashtooluploader_path = art_mgr.get_artifact(
                self.CRASHTOOLUPLOADER_NAME, self.CRASHTOOLUPLOADER_URI)
        except Exception as artmgr_exception:
            self.logger.debug("Unable to download {0} ! ({1})".format(
                self.CRASHTOOLUPLOADER_NAME, str(artmgr_exception)))
            self.logger.debug("Use crashtooluploader from {0} !".format(
                self.CRASHTOOLUPLOADER_DEFAULT_PATH))
            crashtooluploader_path = self.CRASHTOOLUPLOADER_DEFAULT_PATH
        return crashtooluploader_path
コード例 #15
0
    def __init__(self, name, model, eqt_params, bench_params):
        """
        Constructor
        """
        IP2pClient.__init__(self)
        EquipmentBase.__init__(self, name, model, eqt_params)
        computer = str(bench_params.get_param_value("Computer"))
        # NOTE: import here to avoid circular dependency on
        # EquipmentManager if imported at top level
        from acs_test_scripts.Equipment.EquipmentManager import EquipmentManager
        self._em = EquipmentManager()
        self._computer = self._em.get_computer(computer)
        self._lan_interface = ""
        self._p2pclient_ongoing = False

        # Get binary file path
        self._wpa_cli_bin = posixpath.realpath(eqt_params[model]["Binary"])

        self._logger = self.get_logger()
コード例 #16
0
def get_relay_obj():
    if os.environ.get(NOSERUNNER) is None:
        from acs_test_scripts.Equipment.EquipmentManager import EquipmentManager
        io_card = EquipmentManager().get_io_cards()["IO_CARD"]
        return NomalRelay08ACS(io_card)
    else:
        from testlib.common.map import DeviceMap
        mapObj = DeviceMap()
        usb_relay = mapObj.getValue("cutter_relay")
        power_relay = mapObj.getValue("power_relay")
        return NomalRelay(usb_relay, power_relay)
コード例 #17
0
    def check_and_recover_usb_tether(self,
                                     path='www.google.com',
                                     numRetries=5):
        """
        If the USB tether has gone down, attempt to recover it before continuing

        :type path: str
        :param path: Remote path to be used for connection test

        :type numRetries: int
        :param numRetries: the number of times to retry

        :return: None
        """
        hostpc = EquipmentManager().get_computer(eqt_name="COMPUTER1")
        try:
            time.sleep(1)
            urllib.urlopen(path).read()
        except Exception:
            for i in range(1, numRetries + 1):
                try:
                    self._logger.debug(
                        "USB tether connection went down. Attempting to recover..."
                    )
                    time.sleep(1)
                    self._netAPI.start_usb_tethering(unplug=True)
                    if 'linux' in os.sys.platform:
                        usbInterface = 'usb0'
                        hostpc.dhclient(usbInterface)
                except Exception, e:
                    if i == numRetries:
                        msg = "Failed to recover the USB tether: {0}".format(e)
                        raise DeviceException(DeviceException.OPERATION_FAILED,
                                              msg)
                    else:
                        self._logger.debug(
                            'Attempt %d to recover USB tether failed. Trying again...'
                            .format(i))
コード例 #18
0
ファイル: UseCaseBase.py プロジェクト: zenghui0-0/tempfile
    def __init__(self, tc_conf, global_config):
        """
        Constructor
        """
        TestStepEngine.__init__(self, tc_conf, global_config)

        # Get Device Instance
        self._device = DeviceManager().get_device("PHONE1")
        self._dut_config = DeviceManager().get_device_config("PHONE1")

        self._device.inject_device_log("i", "ACS_TESTCASE",
                                       "INIT: %s" % self._name)
        # Get a reference of equipment manager
        self._em = EquipmentManager()

        # Get IO card instance. Default value is 'IO_CARD'
        io_card_name = self._dut_config.get("IoCard", "IO_CARD")
        self._io_card = self._em.get_io_card(io_card_name)

        # Get Global TC Parameters
        self._wait_btwn_cmd = float(self._dut_config.get("waitBetweenCmd"))

        # UECmd type
        self._uecmd_types = UECmdTypes
コード例 #19
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """

        # Call UseCase base Init function
        UseCaseBase.__init__(self, tc_name, global_config)

        # Read mode from test case xml file (str)
        self._switch_mode = self._tc_parameters.get_param_value(
            "SWITCH_MODE", "softshutdown")

        # Read registrationTimeout from Device_Catalog.xml
        self._registration_timeout = \
            int(self._dut_config.get("registrationTimeout"))

        # Read CELLULAR_NETWORK parameters from BenchConfig.xml
        self._network = \
            global_config.benchConfig.get_parameters("CELLULAR_NETWORK")
        self._apn = self._network.get_param_value("APN")
        self._ssid = self._network.get_param_value("SSID")

        # Retrieve valid bench name for 2G capability
        self._bench_name = get_nw_sim_bench_name("2G", global_config,
                                                 self._logger)

        # Read NETWORK_SIMULATOR from BenchConfig.xml
        self._ns_node = \
            global_config.benchConfig.get_parameters(self._bench_name)

        # Read Band from test case xml file (str)
        self._band = self._tc_parameters.get_param_value("CELL_BAND")

        # Read BCH_ARFCN from test case xml file
        self._bch_arfcn = int(self._tc_parameters.get_param_value("BCH_ARFCN"))

        # Read CELL_SERVICE from test case xml file
        self._cell_service = \
            str(self._tc_parameters.get_param_value("CELL_SERVICE"))

        # Read CELL_POWER from test case xml file
        self._cell_power = \
            int(self._tc_parameters.get_param_value("CELL_POWER"))

        # Read Mobile Country Code (MCC) from test case xml file
        self._mcc = \
            int(self._tc_parameters.get_param_value("MCC"))

        # Read Mobile Network Code (MNC) from test case xml file
        self._mnc = \
            int(self._tc_parameters.get_param_value("MNC"))

        # Read PDP Activation from test case xml file
        self._pdp_activation = str_to_bool(
            self._tc_parameters.get_param_value("PDP_ACTIVATION"))

        # Instantiate the network simulator
        eqt_man = EM()
        self._ns = eqt_man.get_cellular_network_simulator(self._bench_name)
        self._ns_cell_2g = self._ns.get_cell_2g()
        self._ns_data_2g = self._ns_cell_2g.get_data()

        # Instantiate generic UECmd for camp
        self._modem_api = self._device.get_uecmd("Modem")

        # Instantiate generic UECmd for camp
        self._networking_api = self._device.get_uecmd("Networking")

        # retrieve SIM card UE commands
        self.sim_card_api = self._device.get_uecmd("SimCard")
        self._sim_states = self.sim_card_api.POSSIBLE_SIM_STATES

        # Instantiate Phone On/OFF utilities
        self.phoneonoff_util = PhoneOnOff(self._networking_api, self._device,
                                          self._logger)

        # init wanted registration parameters to a value that
        # will make the uecmd that used it to raise an error
        self._wanted_reg_state = "None"
コード例 #20
0
 def create_equipment_manager(self):
     """
     Returns an equipment manager
     """
     return EquipmentManager()
コード例 #21
0
ファイル: BroxtonDevice.py プロジェクト: zenghui0-0/tempfile
class BroxtonDevice(IntelDeviceBase):

    """
        Cherrytrail platform implementation
    """
    VIDEO_DECODER_ERROR_MESSAGES = [
         "DUMMY: This message should be replaced with an appropriate one"
        #"OMXVideoDecoder: Decoder returned DECODE_MEMORY_FAIL",
        #"OMXVideoDecoder: Decoder returned DECODE_FAIL",
        #"OMXVideoDecoder: Decoder returned DECODE_DRIVER_FAIL",
        #"VideoDecoder: endDecodingFrame failed. status",
        #"VideoDecoder: Reference frame 8 is missing for current frame 4"
    ]

    VIDEO_ENCODER_ERROR_MESSAGES = [
        "DUMMY: This message should be replaced with an appropriate one"
        #"OMXVideoEncoder: Failed to encode frame"
    ]

    GFX_ERROR_MESSAGES = [
        "DUMMY: This message should be replaced with an appropriate one"
        #"RGXSendCommandRaw failed to acquire CCB slot.",
        #"PVRSRV_ERROR_OUT_OF_MEMORY"
    ]

    VIDEO_ENHANCER_ERROR_MESSAGES = [
        "DUMMY: This message should be replaced with an appropriate one"
        #"pvr_drv_video: vsp_context_flush_cmdbuf fails with 'Bad address' at vendor/intel/hardware/psb_video/src/vsp_cmdbuf.c",
        #"KERNEL: [drm:vsp_submit_cmdbuf] *ERROR* The VSP is hang abnormally!",
        #"VPPWorker: vaEndPicture failed",
        #"VPPProcThread: process error",
        #"[drm:psb_fence_lockup] *ERROR* VSP timeout (probable lockup) detected, reset vsp",
        #"[drm:psb_fence_lockup] *ERROR* fence sequence is %d"
    ]

    CAMERA_HAL_START_MESSAGES = [
        "Camera_HAL: atom_preview_enabled"
    ]

    AUDIO_STREAMING_START_MESSAGES = [
        "AudioIntelHAL: startStream: output stream"
    ]

    VIDEO_DECODER_START_MESSAGES = [
        "DUMMY: This message should be replaced with an appropriate one"
        #"OMXCodec: [OMX.Intel.VideoDecoder.AVC] video dimensions are"
    ]

    GFX_START_MESSAGES = [
        "DUMMY: This message should be replaced with an appropriate one"
        #"OpenGLRenderer: Enabling debug mode 0"
    ]

    DISPLAY_ERROR_MESSAGES = [
        "DUMMY: This message should be replaced with an appropriate one"
        #"[drm:mdfld_dsi_send_dcs] *ERROR* DBI FIFO timeout, drop frame",
        #"[drm:psb_vsync_set_ioctl] *ERROR* fail to get vsync on pipe %d, ret %d",
        #"[drm:_Flip_Overlay] *ERROR* _Flip_Overlay: overlay %d is disabled"
    ]

    BLUETOOTH_ERROR_MESSAGES = [
        "DUMMY: This message should be replaced with an appropriate one"
        #"ERROR : timer_thread: tick delayed > %d slots (%d,%d) -- cpu overload"
    ]

    APP_START_MESSAGES = [
        "ActivityManager: Start proc {0} for activity {0}/.{1}"
    ]

    #1200 x 1920
    GOOGLE_CAMERA_TOUCHCMDS_12X19 = {
        'change_camera': [740, 1545],
        'select_settings': [1150, 1555],
        'select_mode': [600, 965],
        'select_video': [165, 1105],
        'select_imgae': [165, 965]
    }

    #1200 x 1920
    INTEL_CAMERA_TOUCHCMDS_12X19 = {
        'change_camera': [1135, 40],
        'select_mode': [1135, 1800],
        'select_video': [1105, 1545],
        'select_imgae': [1105, 1330],
        'select_burst': [1105, 1465],
    }

    # overrides boot modes, defined in parent class
    BOOT_STATES = {"MOS": "unknown",
                   "ROS": "recovery",
                   "COS": "charger"}

    def __init__(self, config, logger):
        """
        Constructor

        :type  phone_name: string
        :param phone_name: Name of the current phone(e.g. PHONE1)
        """

        IntelDeviceBase.__init__(self, config, logger)

        self._cellular_network_interface = self.get_config("cellularNetworkInterface", "rmnet0")

        self._em = EquipmentManager()
        iocard = self.get_config("IoCard", "IO_CARD", str)
        self._io_card = self._em.get_io_card(iocard)
        self._usb_recovery_ongoing = False
        self.prevent_usb_plug = 5

    def switch_on(self, boot_timeout=None, settledown_duration=None,
                  simple_switch_mode=False):
        """
        Switch ON the device
        This can be done either via the power supply
        or via IO card

        :param boot_timeout: Total time to wait for booting
        :type boot_timeout: int

        :param settledown_duration: Time to wait until start to count \
                                    for timeout,
                                    Period during which the device must \
                                    have started.
        :type settledown_duration: int

        :param simple_switch_mode: a C{boolean} indicating whether we want
        to perform a simple switch on.
        :type simple_switch_mode: bool

        :rtype: list
        :return: Output status and output log
        """
        self.prevent_usb_plug = 5 # Hack to avoid usb plug/unplug on the first get_boot_mode calls

        (return_code, return_message) = IntelDeviceBase.switch_on(self, boot_timeout,
                                                                  settledown_duration,
                                                                  simple_switch_mode)
        if return_code == Global.SUCCESS:
            if self._embedded_log:
                # Initialize embedded log mechanism for MODEM if required
                self._embedded_log.start("MODEM")

        return return_code, return_message

    def get_cellular_network_interface(self):
        """
        Return the ip interface of celluar network

        this interface can be obtain from the command "busybox ifconfig"
        :rtype: str
        :return: telephony ip interface
        """
        return self._cellular_network_interface

    def get_video_decoder_error_messages(self):
        """
        Get log messages for video decoder error
        :type None
        :param None
        :rtype : List
        :return : List of video decoder error messages
        """

        return self.VIDEO_DECODER_ERROR_MESSAGES

    def get_gfx_error_messages(self):
        """
        Get log messages for gfx error
        :type None
        :param None
        :rtype : List
        :return : List of video encoder error messages
        """

        return self.GFX_ERROR_MESSAGES

    def get_video_encoder_error_messages(self):
        """
        Get log messages for video encoder error
        :type None
        :param None
        :rtype : List
        :return : List of video encoder error messages
        """

        return self.VIDEO_ENCODER_ERROR_MESSAGES

    def get_video_enhancer_error_messages(self):
        """
        Get log messages for video enhancer error
        :type None
        :param None
        :rtype : List
        :return : List of video enhancer error messages
        """

        return self.VIDEO_ENHANCER_ERROR_MESSAGES

    def get_camera_start_messages(self):
        """
        Get log messages for camera start
        :type : None
        :param : None
        :rtype : List
        :return : List of camera start messages
        """

        return self.CAMERA_HAL_START_MESSAGES

    def get_audio_playback_start_messages(self):
        """
        Get log messages for audio playback start
        :type : None
        :param : None
        :rtype : List
        :return : List of audio playback start messages
        """

        return self.AUDIO_STREAMING_START_MESSAGES

    def get_video_decoder_start_messages(self):
        """
        Get log messages for video decoder start
        :type : None
        :param : None
        :rtype : List
        :return : List of video decoder start messages
        """

        return self.VIDEO_DECODER_START_MESSAGES

    def get_gfx_start_messages(self):
        """
        Get log messages for gfx start
        :type : None
        :param : None
        :rtype : List
        :return : List of gfx start messages
        """

        return self.GFX_START_MESSAGES

    def get_display_error_messages(self):
        """
        Get log messages for display error
        :type None
        :param None
        :rtype : List
        :return : List of display error messages
        """
        return self.DISPLAY_ERROR_MESSAGES

    def get_bluetooth_error_messages(self):
        """
        Get log messages for display error
        :type None
        :param None
        :rtype : List
        :return : List of bluetooth error messages
        """

        return self.BLUETOOTH_ERROR_MESSAGES

    def get_app_start_messages(self, package_name=None, app_name=None):
        """
        Get log messages for app start
        :type : package_name
        :param : Name of the package
        :type : app_name
        :param : Name of the app
        :rtype : List
        :return : List of app start messages
        """

        return_messages = []
        for start_msg in self.APP_START_MESSAGES:
            return_messages.append(start_msg.format(package_name, app_name))

        return return_messages

    def get_camera_touchcmds(self, target_name=None):
        """
        Get coordinates for camera app
        :type : target_name
        :param : Name of the target camera app
        :rtype : List
        :return : List of coordinates
        """

        _phone_system = self.get_uecmd("PhoneSystem")
        _phone_resolution = _phone_system.get_screen_resolution()
        _disp_width = _phone_resolution.split('x', 1)[0]
        _disp_height = _phone_resolution.split('x', 1)[1]

        _touchCmds = None
        _status = Global.SUCCESS

        if target_name == 'intel' and _disp_width == '1200':
            _touchCmds = self.INTEL_CAMERA_TOUCHCMDS_12X19
        elif target_name == 'google' and _disp_width == '1200':
            _touchCmds = self.GOOGLE_CAMERA_TOUCHCMDS_12X19
        else:
            self._logger.error('Camera API: Display resolution {0}x{1} is not supported in Broxton for now.'.format(_disp_width, _disp_height))
            _status = Global.FAILURE

        return _status, _touchCmds

    def usb_unplug(self):
        """
        unplug usb

        :rtype: bool
        :return: usb state : True if it could be unplugged, else False
        """
        if self._io_card:
            # Unplug USB
            self._io_card.usb_host_pc_connector(False)
            # Unplug wall charger only if it is AC_CHGR
            if self.get_default_wall_charger() == self._io_card.AC_CHGR:
                self._io_card.wall_charger_connector(False)
            return True
        return False

    def usb_plug(self):
        """
        plug usb

        :rtype: bool
        :return: usb state : True if it could be plugged, else False
        """
        if self._io_card:
            # Plug wall charger only if it is AC_CHGR
            if self.get_default_wall_charger() == self._io_card.AC_CHGR:
                # Plug wall charger
                self._io_card.wall_charger_connector(True)
            # Plug USB
            self._io_card.usb_host_pc_connector(True)
            return True
        return False

    def get_boot_mode(self):
        """
        get the boot mode from adb

        :rtype: string
        :return: device state : MOS, ROS, POS, DNX, COS or UNKNOWN
        """

        # Hack to avoid usb unplug/replug at the beginning of boot
        if self.prevent_usb_plug > 0:
            self.prevent_usb_plug -= 1
            time.sleep(5)
            return "UNKNOWN"

        return IntelDeviceBase.get_boot_mode(self)

    def _wait_board_is_ready(self, boot_timeout=None, settledown_duration=None):
        """
        Wait until device is ready to be used

        :type boot_timeout: int
        :param boot_timeout: max time in seconds to wait for device

        :type settledown_duration: int
        :param settledown_duration: fixed time waited if requested after boot procedure

        :rtype: int
        :return: Device status - ready to be used (boot procedure OK) or NOT (Global.SUCCESS, Global.FAILURE)

        :rtype: str
        :return: error message
        """
        if boot_timeout is None:
            # Timeout for total boot duration
            boot_timeout = self.get_boot_timeout()

        # By default we do wait settledown_duration after the boot procedure only if required by the user
        # if user needs a settledown duration after boot procedure it shall be set to a value (not None)

        # Loop while boot time not exceeded & read device state
        timer = 0
        status = Global.FAILURE
        return_code = Global.FAILURE
        return_message = ""

        usbReplugRetries = self.get_config("usbReplugRetries", 0, int)
        if usbReplugRetries:
            wait_device_timeout = boot_timeout / (usbReplugRetries+1)
            if wait_device_timeout > 20:
                wait_device_timeout -= 10 # for the sleep between unplug and replug
        else:
            wait_device_timeout = boot_timeout

        while status == Global.FAILURE and timer < boot_timeout:
            # pylint: disable=W0702
            # at this method, the device is not yet available
            # we can have unexpected behavior on run_cmd
            # agree to catch all exception
            t_0 = time.time()
            try:
                # Break when Global.SUCCESS

                if not self._use_adb_over_ethernet:
                    status, status_msg = self.run_cmd("adb wait-for-device", wait_device_timeout, force_execution=True)
                    # Check output status and send debug log
                    if status == Global.SUCCESS:
                        self.get_logger().info("Device booted")
                    else:
                        msg = "No boot mode state returned"
                        if status_msg is not None:
                            msg = msg + ", error message: %s" % str(status_msg)
                        self.get_logger().debug(msg)

                        if usbReplugRetries:
                            self.recover_usb(usbReplugRetries)

                # FIXME: the adb connection should be handle outside the check, because this method should only
                # check availability as its name indicate
                elif self._check_ethernet_connection_is_available():
                    status = Global.SUCCESS

            except (KeyboardInterrupt, SystemExit):
                raise
            except Exception as error:
                # Inform user of the exception
                self.get_logger().debug("Exception while booting the device : %s", str(error))
                # Wait 1 seconds to avoid relaunching the command multiple times
                time.sleep(1)

            t_1 = time.time()
            timer += t_1 - t_0

        if timer < boot_timeout and status == Global.SUCCESS:
            return_code, return_message = self._finalize_os_boot(timer, boot_timeout, settledown_duration)
        else:
            # Device still not booted
            # Device not connected or adb connection issue
            return_message = "Device has failed to boot after %d seconds! " % boot_timeout
            return_message += "Device not detected or adb connection issue"
            self.get_logger().warning(return_message)

        return return_code, return_message


    def reboot(self, mode="MOS", wait_for_transition=True,
               transition_timeout=None, skip_failure=False,
               wait_settledown_duration=False):
        """
        Perform a SOFTWARE reboot on the device.
        By default will bring you to MOS and connect acs once MOS is seen.
        this reboot require that you are in a state where adb or fastboot command can be run.

        :type mode: str or list
        :param mode: mode to reboot in, support MOS, COS, POS, ROS. It can be a list of these modes
               (ie ("COS","MOS"))
               .. warning:: it is not always possible to reboot in a mode from another mode
                eg: not possible to switch from ROS to COS

        :type wait_for_transition: bool
        :param wait_for_transition: if set to true,
                                    it will wait until the wanted mode is reached

        :type transition_timeout: int
        :param transition_timeout: timeout for reaching the wanted mode
                                    by default will be equal to boot timeout set on
                                    device catalog

        :type skip_failure: bool
        :param skip_failure: skip the failure, avoiding raising exception, using
                                this option block the returned value when it is equal to False

        :type wait_settledown_duration: bool
        :param wait_settledown_duration: if set to True, it will wait settleDownDuration seconds
                                          after reboot for Main OS only.

        :rtype: bool
        :return: return True if reboot action succeed depending of the option used, False otherwise
                 - if wait_for_transition not used, it will return True if the reboot action has been seen
                   by the device
                 - if wait_for_transition used , it will return True if the reboot action has been seen
                   by the device and the wanted reboot mode reached.
        """

        # TODO : REMOVEME
        # This is a workaround for BXT because the device is too unstable now
        # So we do not run adb reboot, but we force shutdown with USB unplugged and then press the power button

        if mode == "MOS":
            self.hard_shutdown(wait_for_board_off=False)
            return self.switch_on(simple_switch_mode=True)[0] == Global.SUCCESS
        else:
            return IntelDeviceBase.reboot(self, mode, wait_for_transition, transition_timeout, skip_failure, wait_settledown_duration)

    def enable_adb_root(self):
        """
        Switch adb to adb root
        :rtype: boolean
        :return: true if root is successfully set, false otherwise
        """

        usbReplugRetries = self.get_config("usbReplugRetries", 0, int)

        self.get_logger().info("Adb root requested, enabling it ...")
        end_time = time.time() + self._adb_root_timeout

        result, output = self.run_cmd("adb root", self._adb_root_cmd_timeout, force_execution=True)
        while time.time() < end_time and output.find("already running as root") == -1:
            time.sleep(1)
            if usbReplugRetries and result != Global.SUCCESS:
                self._recover_usb_no_connect(1)
            if self._use_adb_over_ethernet:
                # reconnect device, as "adb root" reset adb socket
                self._phone_handle.adb_ethernet_start(self._ip_address, self._adb_port,
                                                      self._adb_connect_retries_nb, self._adb_connect_timeout)
            result, output = self.run_cmd("adb root", self._adb_root_cmd_timeout, force_execution=True)

        # adb root should be enabled, now we wait for some time and then try to recover usb if needed
        time.sleep(1)
        self._recover_usb_no_connect(1)

        return result == Global.SUCCESS and output.find("already running as root") != -1

    def _run_adb_cmd(self, cmd, timeout, silent_mode=False, wait_for_response=True, cancel=None):
        """
        Execute the input adb command and return the result message
        If the timeout is reached, return an exception

        :type  cmd: string
        :param cmd: cmd to be run
        :type  timeout: integer
        :param timeout: Script execution timeout in sec
        :type  cancel: Cancel
        :param cancel: a Cancel object that can be used to stop execution, before completion or timeout(default None)

        :return: Execution status & output string
        :rtype: Integer & String
        """
        result, msg = IntelDeviceBase._run_adb_cmd(self, cmd, timeout, silent_mode, wait_for_response, cancel)

        # if both the command and adb wait-for-device fail, try to unplug/replug usb several times
        # and try the command again if successful
        if result != Global.SUCCESS:
            usbReplugRetries = self.get_config("usbReplugRetries", 0, int)
            if usbReplugRetries and self.recover_usb(usbReplugRetries):
                result, msg = IntelDeviceBase._run_adb_cmd(self, cmd, timeout, silent_mode, wait_for_response, cancel)
        return result, msg

    def _connect_adb(self, tcp_connect_retries_nb=None, adb_connect_retries_nb=None):
        """
        Connect ADB though USB or ETHERNET, ensure adb root connection if set
        :param tcp_connection_retry_nb: allow to override retry nb
        :param adb_connection_retry_nb:  allow to override retry nb
        :rtype: bool, str
        :return: status of ADB connection and status message
        """

        usbReplugRetries = self.get_config("usbReplugRetries", 0, int)
        if usbReplugRetries:
            self.recover_usb(usbReplugRetries)

        return IntelDeviceBase._connect_adb(self, tcp_connect_retries_nb, adb_connect_retries_nb)

    def _recover_usb_no_connect(self, retries=1):
        """
        Try to recover usb by unpluging and repluging it
        and then return the status of last wait-for-device command
        :rtype: str
        :return: status of wait-for-device command
        """
        try_nb = retries
        status, _ = self.run_cmd("adb wait-for-device", 3, force_execution=True)
        while try_nb > 0 and status != Global.SUCCESS:
            try_nb -= 1
            if self.usb_unplug():
                time.sleep(5)
            if self.usb_plug():
                status, _ = self.run_cmd("adb wait-for-device", 10, force_execution=True)
        return status

    def recover_usb(self, retries=1):
        """
        Try to recover usb by unpluging and repluging it
        and then return usb status (based on adb wait-for-device
        :param tcp_connection_retry_nb: allow to override retry nb
        :param adb_connection_retry_nb:  allow to override retry nb
        :rtype: bool, str
        :return: status of ADB connection and status message
        """
        # If we are already trying to recover usb, do nothing (deadock prevention)
        if self._usb_recovery_ongoing:
            return False

        # If usb plug is prevented, return after 10 seconds
        if self.prevent_usb_plug > 0:
            self.prevent_usb_plug -= 1
            time.sleep(10)
            return False

        self._usb_recovery_ongoing = True # lock
        status = self._recover_usb_no_connect(retries)

        # if the device was recovered but still not reconnected to fwk, reconnect it
        if status == Global.SUCCESS and not self.is_available() and not self._connection_lock.locked():
            self.connect_board()
        self._usb_recovery_ongoing = False # release the lock
        return status == Global.SUCCESS

    def soft_shutdown(self, wait_for_board_off=False):
        """"
        Perform a soft shutdown and wait for the device is off

        :type wait_for_board_off: boolean
        :param wait_for_board_off: Wait for device is off or not after soft shutdown

        :rtype: boolean
        :return: If device is off or not
        """

        # Soft shutdown does not work on BXT yet
        return self.hard_shutdown(False)
コード例 #22
0
ファイル: WiredHeadset.py プロジェクト: zenghui0-0/tempfile
class WiredHeadset(EquipmentBase, IHeadset):
    """
    Class that implements WiredHeadset equipment
    """
    def __init__(self, name, model, eqt_params, bench_params):
        """
        Constructor
        :type name: str
        :param name: the bench configuration name of the equipment
        :type model: str
        :param model: the model of the equipment
        :type eqt_params: dict
        :param eqt_params: the dictionary containing equipment parameters
        """
        EquipmentBase.__init__(self, name, model, eqt_params)
        IHeadset.__init__(self)
        self.__wired_headset = None
        self.__headphone = None
        self._bench_params = bench_params

        # NOTE: import here to avoid circular dependency on
        # EquipmentManager if imported at top level
        from acs_test_scripts.Equipment.EquipmentManager import EquipmentManager
        self._em = EquipmentManager()
        self._io_card = self._em.get_io_card("IO_CARD")

        if ((self._bench_params.has_parameter("wired_headset")) and
            (self._bench_params.get_param_value("wired_headset") != "")):
            self.__wired_headset = \
                int(self._bench_params.get_param_value("wired_headset"))

        if ((self._bench_params.has_parameter("headphone"))
                and (self._bench_params.get_param_value("headphone") != "")):
            self.__headphone = \
                int(self._bench_params.get_param_value("headphone"))

        if self._io_card is None:
            self._logger.info("No IO card instance")

    def plug_whs(self):
        """
        Plug the wired headset
        :rtype: None
        """
        if self._io_card is None:
            self._logger.info("No IO card instance")
        else:
            self._logger.info("Plug wired headset")
            self._io_card.enable_line(self.__wired_headset)

    def unplug_whs(self):
        """
        Unplug the wired headset
        :rtype: None
        """
        if self._io_card is None:
            self._logger.info("No IO card instance")
        else:
            self._logger.info("Unplug wired headset")
            self._io_card.disable_line(self.__wired_headset)

    def plug_headphone(self):
        """
        Plug the headphone
        :rtype: None
        """
        if self._io_card is None:
            self._logger.info("No IO card instance")
        else:
            self._logger.info("Plug headphone")
            self._io_card.enable_line(self.__headphone)

    def unplug_headphone(self):
        """
        Unplug the headphone
        :rtype: None
        """
        if self._io_card is None:
            self._logger.info("No IO card instance")
        else:
            self._logger.info("Unplug headphone")
            self._io_card.disable_line(self.__headphone)
コード例 #23
0
class GenericSniffer(EquipmentBase, ISniffer):
    def __init__(self, name, model, eqt_params, bench_params):
        """
        Constructor
        """
        # Initialize class parent
        ISniffer.__init__(self)
        EquipmentBase.__init__(self, name, model, eqt_params)

        computer = str(bench_params.get_param_value("Computer"))
        # NOTE: import here to avoid circular dependency on
        # EquipmentManager if imported at top level
        from acs_test_scripts.Equipment.EquipmentManager import EquipmentManager
        self._em = EquipmentManager()
        self._computer = self._em.get_computer(computer)

        self._ssh_process = None
        self._ssh_queue = None
        self._local_out = ""
        self._sniff_ongoing = False
        self._wifi_interface = bench_params.get_param_value("Interface", "")
        if self._wifi_interface == "":
            self._wifi_interface = self._computer.get_wifi_interface()

        self._sniffer_tool_checked = False
        self._sniffer_cmd = "NOT_YET_DEFINED"

    def init(self):
        """
        Initializes the equipment and establishes the connection.
        """
        self.get_logger().info("init")

        # Open connection to sniffer
        self._computer.init(True)

        # Check Sniffer binary tool existence
        self._check_sniffer_tool(self._sniffer_cmd)

        # End all potential ongoing sniffer traces
        self._computer.run_cmd("killall %s" % self._sniffer_cmd)
        self._sniff_ongoing = False

    def release(self):
        """
        Releases equipment resources and close connection.
        """
        self.get_logger().info("release")
        self._computer.release()

    def get_capture_file(self, log_file_name):
        """
        get the capture file and save it
        in the current _Report directory without stopping the capture
        :type log_filename: str
        :param log_filename: pathname of the output capture file
        """
        self._computer.copy_file_in_local_path(self._remote_out, log_file_name)

    def _check_sniffer_tool(self, binary_to_check):
        """
        Check that binary_to_check command is installed on the host computer

        :type binary_to_check: str
        :param binary_to_check: Binary cmd to check if available on the Computer
        """
        if not self._sniffer_tool_checked:

            if self._computer.get_model() == "LOCAL_COMPUTER" \
                    and self._computer.get_os() == self._computer.WINDOWS:
                msg = "Sniffer must be installed on a LOCAL or REMOTE Linux computer"
                self._logger.error(msg)
                raise TestEquipmentException(
                    TestEquipmentException.FEATURE_NOT_IMPLEMENTED, msg)

            out = self._computer.run_cmd("which %s" % binary_to_check)
            if ("/%s" % binary_to_check) not in out["std"]:
                msg = "%s is not available on %s" % (binary_to_check,
                                                     self._computer.get_name())
                self._logger.error(msg)
                raise TestEquipmentException(
                    TestEquipmentException.FEATURE_NOT_IMPLEMENTED, msg)

            self._sniffer_tool_checked = True

    def _build_sniffer_cmd(self,
                           save_sniff_in_ascii=False,
                           dut_mac_addr="",
                           ssid="",
                           filter_option="-R"):
        """
        Build the sniff command

        :type save_sniff_in_ascii: boolean
        :param save_sniff_in_ascii: enable ascii format for sniff logs

        :type dut_mac_addr: str
        :param dut_mac_addr: mac address to filter on

        :type ssid: str
        :param ssid: ssid address to filter on

        :type filter: str
        :param filter: special option for filter (-R or -Y)
        """
        sniff = "%s -i%s -s0 " % (self._sniffer_cmd, self._wifi_interface)

        # Build the sniff_filter
        if dut_mac_addr or ssid:
            sniff_filter = ""
            if dut_mac_addr:
                sniff_filter += 'wlan.addr==%s' % dut_mac_addr
            if dut_mac_addr and ssid:
                sniff_filter += " || "
            if ssid:
                sniff_filter += '(wlan.fc.type_subtype==0x08 && wlan_mgt.ssid=="%s")' % ssid
            sniff += '%s "%s" ' % (filter_option, sniff_filter)

        if save_sniff_in_ascii:
            sniff += '-V > %s' % self._remote_out
        else:
            sniff += "-w%s" % self._remote_out

        return sniff
コード例 #24
0
    def set_up(self):
        """
        Initialize the test

        :rtype: tuple
        :return: ACS verdict and msg output
        """
        verdict = Global.SUCCESS
        msg = ""

        UseCaseBase.set_up(self)

        if self._its_package_name is None:
            return (Global.FAILURE, "You need to specify a ITS_NAME value.")

        if self._artifactory_uri is None:
            self._logger.info("Default artifactory path will be used")

        if self._test_timeout is None:
            self._test_timeout = 360000
            self._logger.info("Default test timeout will be used: %s.",
                              self._test_timeout)

        art_mgr = EquipmentManager().get_artifact_manager("ARTIFACT_MANAGER")

        # Download ITS package
        self._ITS_path = art_mgr.get_artifact(self._its_package_name,
                                              self._artifactory_uri)

        # Check if zipfile or local cache
        fileName, fileExtension = os.path.splitext(self._ITS_path)
        if fileExtension.lower() == ".zip":
            # Unzip CTS package
            self._ITS_path = art_mgr.unzip_artifact(self._ITS_path)
            self._logger.debug("Unzip with ArtifactoryManager in: %s",
                               self._ITS_path)

        #Set python path for the subprocesses created for the actual tests
        os.environ['PYTHONPATH'] = os.path.join(
            self._ITS_path, 'android-cts-verifier/CameraITS/pymodules')
        #Set the path for this python script
        sys.path.append(
            os.path.join(self._ITS_path,
                         'android-cts-verifier/CameraITS/pymodules'))

        #Install CTSVerifier and set permissions.
        self._logger.info("Installing CtsVerifier.apk")
        cmd = [
            'adb', 'install',
            os.path.join(self._ITS_path,
                         'android-cts-verifier/CtsVerifier.apk')
        ]
        subprocess.call(cmd, stdout=self.devnull, stderr=self.devnull)
        self._logger.info("Granting permissions for CtsVerifier")
        cmd = [
            'adb', 'shell', 'pm', 'grant',
            'com.android.cts.verifier android.permission.CAMERA'
        ]
        subprocess.call(cmd, stdout=self.devnull, stderr=self.devnull)
        self._logger.info("starting CtsVerifier")
        cmd = [
            'adb', 'shell', 'am', 'start',
            'com.android.cts.verifier/.camera.its.ItsTestActivity'
        ]
        subprocess.call(cmd, stdout=self.devnull, stderr=self.devnull)

        #turn on stay awake on the device
        cmd = ['adb', 'shell', 'svc', 'power', 'stayon', 'usb']
        subprocess.call(cmd, stdout=self.devnull, stderr=self.devnull)

        #Find out how many cams the device has
        import its.device
        its_session = its.device.ItsSession()
        self.camids = its_session.get_camera_ids()

        #build a dictionary with lists of tests.
        self.testroot = os.path.join(self._ITS_path,
                                     'android-cts-verifier/CameraITS/tests')
        for s in self._scenes:
            self._tests[s] = []
            files = os.listdir(os.path.join(self.testroot, s))
            for f in files:
                if f[-3:] == '.py':
                    self._tests[s].append(f)

        return verdict, msg
コード例 #25
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """

        # Call UseCase base Init function
        UseCaseBase.__init__(self, tc_name, global_config)
        # Read mode from test case xml file (str)
        self._switch_mode = self._tc_parameters.get_param_value(
            "SWITCH_MODE", "softshutdown")

        # Read registrationTimeout from Device_Catalog.xml
        self._registration_timeout = \
            int(self._dut_config.get("registrationTimeout"))

        # Read CELLULAR_NETWORK parameters from BenchConfig.xml
        self._network = \
            global_config.benchConfig.get_parameters("CELLULAR_NETWORK")
        self._apn = self._network.get_param_value("APN")
        self._ssid = self._network.get_param_value("SSID")

        # Retrieve valid bench name for 3G capability
        self._bench_name = get_nw_sim_bench_name("3G", global_config,
                                                 self._logger)
        # bench_name should be either NETWORK_SIMULATOR1 or NETWORK_SIMULATOR2
        # In both cases, we need to retrieve the NS number (position in the bench config, either 1 or 2)
        self._ns_number = int(self._bench_name[-1])

        # Read NETWORK_SIMULATOR from BenchConfig.xml
        self._ns_node = \
            global_config.benchConfig.get_parameters(self._bench_name)

        # Retrieve the model of the equipment
        self._ns_model = self._ns_node.get_param_value("Model")

        # Read Band from test case xml file (str)
        self._band = self._tc_parameters.get_param_value("CELL_BAND")

        # NS_CELL_REL
        self._ns_cell_rel = 7

        # Read BCH_ARFCN from test case xml file
        self._dl_uarfcn = int(self._tc_parameters.get_param_value("DL_UARFCN"))

        # Read CELL_SERVICE from test case xml file
        self._cell_service = \
            str(self._tc_parameters.get_param_value("CELL_SERVICE"))

        # Read CELL_POWER from test case xml file
        self._cell_power = \
            int(self._tc_parameters.get_param_value("CELL_POWER"))

        # Read Mobile Country Code (MCC) from test case xml file
        self._mcc = \
            int(self._tc_parameters.get_param_value("MCC"))

        # Read Mobile Network Code (MNC) from test case xml file
        self._mnc = \
            int(self._tc_parameters.get_param_value("MNC"))

        # Read PDP Activation from test case xml file
        self._pdp_activation = str_to_bool(
            self._tc_parameters.get_param_value("PDP_ACTIVATION"))

        # Instantiate the network simulator
        eqt_man = EM()
        self._ns = eqt_man.get_cellular_network_simulator(self._bench_name)
        self._ns_cell_3g = self._ns.get_cell_3g()
        self._ns_data_3g = self._ns_cell_3g.get_data()

        # Instantiate generic UECmd for camp
        self._modem_api = self._device.get_uecmd("Modem")

        # Instantiate generic UECmd for camp
        self._networking_api = self._device.get_uecmd("Networking")

        # Instantiate Phone On/OFF utilities
        self.phoneonoff_util = PhoneOnOff(self._networking_api, self._device,
                                          self._logger)

        # init wanted registration parameters to a value that
        # will make the uecmd that used it to raise an error
        self._wanted_reg_state = "None"
コード例 #26
0
ファイル: P2pSupplicant.py プロジェクト: zenghui0-0/tempfile
class P2pSupplicant(EquipmentBase, IP2pSupplicant):
    """
    Implementation of P2P Client interface
    """
    def __init__(self, name, model, eqt_params, bench_params):
        """
        Constructor
        """
        IP2pSupplicant.__init__(self)
        EquipmentBase.__init__(self, name, model, eqt_params)
        computer = str(bench_params.get_param_value("Computer"))
        # NOTE: import here to avoid circular dependency on
        # EquipmentManager if imported at top level
        from acs_test_scripts.Equipment.EquipmentManager import EquipmentManager
        self._em = EquipmentManager()
        self._computer = self._em.get_computer(computer)
        self._p2psupplicant_ongoing = False

        # Get binary and cofiguration file path
        self._wpa_supplicant_bin = posixpath.realpath(
            eqt_params[model]["Binary"])
        self._wpa_p2p_conf = posixpath.realpath(
            eqt_params[model]["Configuration"])

    def start(self, lan_interface):
        """
        Start the P2P Supplicant
        :type lan_interface: str
        :param lan_interface: Lan interface to use
        """
        if self._p2psupplicant_ongoing:
            msg = "Cannot start 2 P2P Supplicant in the same time"
            self.get_logger().error(msg)
            raise TestEquipmentException(
                TestEquipmentException.OPERATION_FAILED, msg)

        self._logger.debug("start_P2P supplicant")

        self._computer.init()
        self._computer.run_cmd("killall wpa_supplicant", 1)

        # Check WPA_Cli existence
        self._computer.check_command("wpa_supplicant")

        # remove the old temporary files
        self._computer.run_cmd("rm -rf /var/run/wpa_supplicant/wlan2")

        self._logger.debug("start wpa_supplicant")

        wpaoutput = self._computer.run_cmd("%s -Dnl80211 -c%s -i %s -dt &> /dev/null &" \
                                           % (self._wpa_supplicant_bin, self._wpa_p2p_conf, lan_interface), 2)
        wpaoutput = wpaoutput["std"]

        if "Failed to initialize wpa_supplicant" in wpaoutput:
            msg = "Failed to initialize "
            self._logger.error(msg)
            raise TestEquipmentException(
                TestEquipmentException.OPERATION_FAILED, msg)

        self._p2psupplicant_ongoing = True

    def stop(self):
        """
        Stop the P2P Supplicant
        """
        if not self._p2psupplicant_ongoing:
            self._logger.warning("P2P Supplicant not started")
            return

        self._logger.debug("Stop P2P Supplicant")

        # clean the supplicant environment
        self._computer.run_cmd("killall wpa_supplicant")
        self._computer.run_cmd("rm -rf /var/run/wpa_supplicant/wlan2")

        self._logger.info("P2P release")
        self._computer.release()

        self._p2psupplicant_ongoing = False
コード例 #27
0
ファイル: RunIperf.py プロジェクト: zenghui0-0/tempfile
class RunIperf(DeviceTestStepBase):
    def __init__(self, tc_conf, global_conf, ts_conf, factory):
        DeviceTestStepBase.__init__(self, tc_conf, global_conf, ts_conf, factory)
        self.server_object = None
        self.networking_api = self._device.get_uecmd("Networking")
        self.svr_networking_api = None
        self.equip_mgr = EquipmentManager()
        self.device_mgr = DeviceManager()
        self._iperf_settings = None

    def run(self, context):
        """
        Runs the test step

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

        runtime_seconds = self._pars.duration * 60
        server_address = "none"
        if self._pars.iperf_protocol == "tcp":
            port_num = 5001
        else:
            port_num = 5009

        # prepare setup the IPERF test.
        self._iperf_settings = {"duration": runtime_seconds,
                                "protocol": self._pars.iperf_protocol,
                                "port_number": port_num,
                                "direction": self._pars.direction,
                                "parallel_thread": self._pars.nr_of_threads}

        bench_config = self._global_conf.benchConfig.get_dict()
        if self._pars.server_name not in bench_config.keys():
            # the indicated equipment or phone is NOT declared in the current bench config
            raise Exception("")

        # check in the bench config what is the kind of given server
        eqt_param = self._global_conf.benchConfig.get_parameters(self._pars.server_name)
        eqt_param_dict = eqt_param.get_dict()
        if "Model" in eqt_param_dict.keys():
            # server is an equipment
            eqt_param_dict = eqt_param.get_param_value("Model")
            if "REMOTE_COMPUTER" in eqt_param_dict:
                # remote computer, get the IP parameter
                server_address = eqt_param.get_param_value("IP")
                self._iperf_settings["computer"] = self.equip_mgr.get_computer(self._pars.server_name)
            elif "COMPUTER" in eqt_param_dict:
                # local computer, nothing to do
                pass
            elif "RS_CMW500" in eqt_param_dict:
                # equipment with Iperf embedded, get the IP_Lan1 parameter
                server_address = eqt_param.get_param_value("IP_Lan1")
                self._iperf_settings["equipment_api"] = \
                    self.equip_mgr.get_cellular_network_simulator().get_cell_4g().get_data()
        else:
            # server is a phone
            phone = self.device_mgr.get_device(self._pars.server_name)
            networking_api2 = phone.get_uecmd("Networking")
            self._iperf_settings["networking_api2"] = networking_api2
            if self._pars.server_net_interface is not None:
                server_address = networking_api2.get_interface_ipv4_address(self._pars.server_net_interface)
            else:
                self._logger.warning("No Server net interface provided. Use the DUT net interface")
                server_address = networking_api2.get_interface_ipv4_address(self._pars.net_interface)

        time.sleep(5)
        dut_ip_address = get_dut_ipv4_address(self.networking_api, self._pars.net_interface)
        if self._pars.direction in ("down", "both"):
            self._iperf_settings["server_ip_address"] = dut_ip_address
            self._iperf_settings["bind_host"] = server_address
        else:
            self._iperf_settings["server_ip_address"] = server_address
            self._iperf_settings["bind_host"] = dut_ip_address

        self._logger.info("RunIperf: starting")

        self._logger.info("IPERF parameters:")
        self._logger.info("  server addr: " + server_address)
        self._logger.info("  duration: %d sec" % runtime_seconds)
        self._logger.info("  direction: " + self._pars.direction)
        self._logger.info("  port: %d" % port_num)

        if self._pars.window_size.lower() != "compute":
            self._iperf_settings["server_window_size"] = self._pars.window_size
            self._iperf_settings["client_window_size"] = self._pars.window_size
        if self._pars.no_delay:
            self._iperf_settings["no_delay"] = ''
        if self._pars.iperf_options.lower() != "none":
            self._iperf_settings["extra_options"] = self._pars.iperf_options

        # Run Iperf command
        IperfHandler = IperfExecutionHandler(self._iperf_settings, self._device.get_uecmd("Networking"))
        throughput = IperfHandler.iperf()

        context.set_nested_info([self._pars.measured_throughput, "UL_VALUE"], throughput.ul_throughput.value)
        context.set_nested_info([self._pars.measured_throughput, "DL_VALUE"], throughput.dl_throughput.value)
        context.set_nested_info([self._pars.measured_throughput, "UL_UNITS"], throughput.ul_throughput.unit)
        context.set_nested_info([self._pars.measured_throughput, "DL_UNITS"], throughput.dl_throughput.unit)

        self._logger.info("Start iperf client: finished")
コード例 #28
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """

        # Call UseCase base Init function
        UseCaseBase.__init__(self, tc_name, global_config)

        # Read registrationTimeout from Device_Catalog.xml
        self._registration_timeout = \
            int(self._dut_config.get("registrationTimeout"))

        # Read CELLULAR_NETWORK parameters from BenchConfig.xml
        self._network = \
            global_config.benchConfig.get_parameters("CELLULAR_NETWORK")
        self._apn = self._network.get_param_value("APN")
        self._ssid = self._network.get_param_value("SSID")

        # Retrieve valid bench name for 2G capability
        self._bench_name = get_nw_sim_bench_name("2G", global_config, self._logger)

        # Read NETWORK_SIMULATOR from BenchConfig.xml
        self._ns_node = \
            global_config.benchConfig.get_parameters(self._bench_name)

        # Read the CELL_BAND value from UseCase xml Parameter
        self._band_name = self._tc_parameters.get_param_value("CELL_BAND")

        # Read the CELL_POWER value from UseCase xml Parameter
        self._cell_power = \
            int(self._tc_parameters.get_param_value("CELL_POWER"))

        # Read the BCH_ARFCN value from UseCase xml Parameter
        self._bch_arfcn = \
            int(self._tc_parameters.get_param_value("BCH_ARFCN"))

        # Read the PDTCH_ARFCN value from UseCase xml Parameter
        self._pdtch_arfcn = \
            int(self._tc_parameters.get_param_value("PDTCH_ARFCN"))

        # Read the DATA_CODING_SCHEME from UseCase xml Parameter
        self._data_coding_sheme = \
            str(self._tc_parameters.get_param_value("DATA_CODING_SCHEME"))

        # Read the SMS_TEXT from UseCase xml Parameter
        self._sms_text = self._tc_parameters.get_param_value("SMS_TEXT")

        # Read the SMS_TRANSFER_TIMEOUT from UseCase xml Parameter
        self._sms_transfer_timeout = \
            int(self._tc_parameters.get_param_value("SMS_TRANSFER_TIMEOUT"))

        # Get number of bits per character set
        dcs = DataCodingScheme(self._data_coding_sheme)
        dcs.decode()

        self._nb_bits_per_char = dcs.compute_character_size()

        character_set = dcs.get_character_set()

        if character_set == "7BITS":
            self._content_type = "CTEX"
        else:
            self._content_type = "CDAT"

        # Instantiate Messaging UECmd for SMS UseCases
        self._messaging_api = self._device.get_uecmd("SmsMessaging")

        # Instantiate Modem UECmd for checking phone registration
        self._modem_api = self._device.get_uecmd("Modem")

        # Create cellular network simulator
        eqt_man = EM()
        self._ns = eqt_man.get_cellular_network_simulator(self._bench_name)
        self._ns_cell_2g = self._ns.get_cell_2g()
        self._ns_messaging_2g = self._ns_cell_2g.get_messaging()
        self._ns_data_2g = self._ns_cell_2g.get_data()

        # Instantiate generic UECmd for camp
        self._networking_api = self._device.get_uecmd("Networking")
コード例 #29
0
ファイル: InstallApp.py プロジェクト: zenghui0-0/tempfile
class InstallApp(DeviceTestStepBase):

    """
    Install a device application on device
    """

    def __init__(self, tc_conf, global_conf, ts_conf, factory):
        """
        Initialize test step
        """
        DeviceTestStepBase.__init__(self, tc_conf, global_conf, ts_conf, factory)
        self._system_api = self._device.get_uecmd("System")
        self._app_api = self._device.get_uecmd("AppMgmt")
        self._equipment_manager = EquipmentManager()
        self._application = AndroidApplication(logger=self._logger)

    def run(self, context):
        """
        Runs the test step

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

        if not os.path.isfile(self._pars.file_path):
            error_msg = "File {0} does not exists!".format(self._pars.file_path)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg)
        self._application.set_application(self._pars.file_path)
        installing_same_version = self._compare_application_versions()
        # Backup only if a version is installed and is different from the one to install and user requested backup
        if self._pars.backup:
            if not installing_same_version:
                backup_folder = os.path.abspath(os.path.join(Paths.EXECUTION_CONFIG, "Backup"))
                if not os.path.exists(backup_folder):
                    os.makedirs(backup_folder)
                app_location = self._app_api.get_path_of_device_app(self._application.get_package_name())
                if not app_location:
                    self._logger.warning("No application backup done: application is not installed")
                else:
                    backup_file = os.path.join(backup_folder,
                                               os.path.basename(app_location))
                    verdict, msg = self._app_api.backup_app(backup_file, app_location, self._pars.timeout)
                    if verdict != Global.SUCCESS:
                        self._logger.warning("No application backup done: {0}".format(msg))
                    else:
                        self._logger.info("Backup of application done to {0}".format(backup_file))
                    context.set_info(self._pars.backup_file_path, backup_file)
            else:
                self._logger.warning("No application backup done: same version already installed")

        # Sign only if user requested it and installing application
        if self._pars.sign and not installing_same_version:
            app_path = self._sign_app()
            self._logger.info("Signing application done")
        else:
            app_path = self._pars.file_path

        # Install only if not installed or installed version is different from the one to install
        if not installing_same_version:
            allow_downgrade = False
            # parameter is optional
            if self._pars.allow_downgrade is not None:
                allow_downgrade = self._pars.allow_downgrade
            verdict, msg = self._app_api.install_device_app(app_path=app_path,
                                                            timeout=self._pars.timeout,
                                                            allow_downgrade=allow_downgrade)
            if verdict != Global.SUCCESS:
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)
            else:
                msg = "Application {0} installation done".format(os.path.basename(
                    app_path))
                self.ts_verdict_msg = msg
                self._logger.info(msg)
        else:
            msg = "No application installation done: same version already installed"
            self.ts_verdict_msg = msg
            self._logger.warning(msg)

    def _compare_application_versions(self):
        """
            Compare application given by user with application already installed on device
        :return: bool result of the comparison
        """
        new_version = self._application.get_package_version_name()
        installed_version = self._device.get_apk_version(self._application.get_package_name())
        return new_version == installed_version

    def _sign_app(self):
        """
         Sign application using key pointed by user in benchconfig

        :return: path of the signed application
        """
        if self._pars.sign_key_path:
            signing_key = self._pars.sign_key_path
        else:
            signing_key = self._device.get_config("appSigningKey", "")
        if not signing_key:
            error_msg = "appSigningKey parameter is not present in Device Catalog nor in Bench Config"
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg)
        signing_key_1 = "{0}.{1}".format(signing_key, "pk8")
        signing_key_2 = "{0}.{1}".format(signing_key, "x509.pem")
        # Use Artifact manager for non local key files
        if not os.path.isfile(os.path.abspath(signing_key_1)) and not os.path.isfile(os.path.abspath(signing_key_2)):
            artifact_manager = self._equipment_manager.get_artifact_manager("ARTIFACT_MANAGER")
            if not artifact_manager:
                error_msg = "ArtifactManager equipment is not present in the BenchConfig file"
                raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg)
            artifact_manager.get_artifact(artifact_name=signing_key_1, transfer_timeout=10)
            local_artifact = artifact_manager.get_artifact(artifact_name=signing_key_2, transfer_timeout=10)
            signing_key_folder = os.path.dirname(local_artifact)
        else:
            signing_key_folder = os.path.dirname(signing_key)
        signing_key_name = os.path.basename(signing_key)
        signing_tmp_folder = tempfile.mkdtemp()
        signed_app = os.path.join(signing_tmp_folder, os.path.basename(self._pars.file_path))
        if signing_key_folder and signing_key_name and signed_app:
            status, status_msg = self._app_api.sign_device_app(self._pars.file_path,
                                                               signing_key_folder,
                                                               signing_key_name,
                                                               signed_app, 5)
            if status != Global.SUCCESS:
                raise AcsToolException(AcsToolException.OPERATION_FAILED, status_msg)
        else:
            error_msg = "Invalid signing data among key folder:{0}, key name:{1}, key application:{2}".format(
                signing_key_folder, signing_key_name, signed_app)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg)

        return signed_app
コード例 #30
0
ファイル: USBRly08.py プロジェクト: zenghui0-0/tempfile
    def init(self):
        """
        Initializes the equipment. The equipment is ready to use
        """
        self.get_logger().info("USBRly08 Initialization")

        # In case of multi IOcards connected to one PC,
        # best practise is to serialize IOCard. the 1st IOCard controls
        # USB power of the 2nd.
        # This architecture ensures comport numbers are fixed

        # if that IOCard is slave of a previous one
        # First is to power on USB using relay from Master IOCard
        if ((self.__bench_params.has_parameter("IOCard_master")) and
           (self.__bench_params.get_param_value("IOCard_master") != "")):
            mcard_name = \
                str(self.__bench_params.get_param_value("IOCard_master"))

            # Get the ID of the Master card's relay to control
            #  power of slave card
            if ((self.__bench_params.has_parameter("RelayOnOffMasterCard")) and
               (self.__bench_params.get_param_value("RelayOnOffMasterCard") != "")):
                rel_power_card = \
                    int(self.__bench_params.get_param_value("RelayOnOffMasterCard"))
            else:
                msg = "RelayOnOffMasterCard is not defined."
                self.get_logger().error(msg)
                raise TestEquipmentException(TestEquipmentException.SPECIFIC_EQT_ERROR, msg)

            # instantiate master IOCard
            # NOTE: import here to avoid circular dependency on
            # EquipmentManager if imported at top level
            from acs_test_scripts.Equipment.EquipmentManager import EquipmentManager
            eqm = EquipmentManager()
            mcard = eqm.get_io_card(mcard_name)

            # Power ON USB wire of that IOCard
            mcard.enable_line(rel_power_card)

            # Wait for the OS to enumerate the new connected IOCard
            time.sleep(3)

        # Be careful to get wiring table before setting default relay states
        if ((self.get_bench_params().has_parameter("WiringTable")) and
           (self.__bench_params.get_param_value("WiringTable") != "")):
            self.__wiring_table = \
                int(self.get_bench_params().get_param_value("WiringTable"), 2)

            self.get_logger().info("Set Wiring Table settings to %s",
                                   self.__wiring_table)

        # Get the ID of the relay for USB host PC plug/unplug if exists or filled
        if ((self.get_bench_params().has_parameter("UsbHostPcConnect")) and
           (self.__bench_params.get_param_value("UsbHostPcConnect") != "")):
            self.__usb_host_pc_connect_relay = \
                int(self.__bench_params.get_param_value("UsbHostPcConnect"))

        # Get the ID of the relay controlling the lamp if exists or filled
        if ((self.get_bench_params().has_parameter("Lamp")) and
           (self.__bench_params.get_param_value("Lamp") != "")):
            self.__lamp_relay = \
                int(self.__bench_params.get_param_value("Lamp"))

        # Get the ID of the relay for USB host PC plug/unplug if exists or filled
        if ((self.get_bench_params().has_parameter("UsbHostPcPowerMinus")) and
           (self.__bench_params.get_param_value("UsbHostPcPowerMinus") != "")):
            self.__usb_host_pc_power_minus = \
                int(self.__bench_params.get_param_value("UsbHostPcPowerMinus"))

        # Get the ID of the relay for USB host PC plug/unplug if exists or filled
        if ((self.get_bench_params().has_parameter("UsbHostPcDataPlus")) and
           (self.__bench_params.get_param_value("UsbHostPcDataPlus") != "")):
            self.__usb_host_pc_data_plus = \
                int(self.__bench_params.get_param_value("UsbHostPcDataPlus"))

        # Get the ID of the relay for USB host PC plug/unplug if exists or filled
        if ((self.get_bench_params().has_parameter("UsbHostPcDataMinus")) and
           (self.__bench_params.get_param_value("UsbHostPcDataMinus") != "")):
            self.__usb_host_pc_data_minus = \
                int(self.__bench_params.get_param_value("UsbHostPcDataMinus"))

        # Get the ID of the relay for wall charger plug/unplug if exists or filled
        if ((self.get_bench_params().has_parameter("WallCharger")) and
           (self.__bench_params.get_param_value("WallCharger") != "")):
            self.__wall_charger_relay = \
                int(self.__bench_params.get_param_value("WallCharger"))

        # Get the ID of the relay for wireless charger plug/unplug if exists or filled
        if ((self.get_bench_params().has_parameter("WirelessCharger")) and
           (self.__bench_params.get_param_value("WirelessCharger") != "")):
            self.__wireless_charger_relay = \
                int(self.__bench_params.get_param_value("WirelessCharger"))

        # Get the ID of the relay for switching ON/OFF the board if exits or filled
        if ((self.get_bench_params().has_parameter("SwitchOnOff")) and
           (self.__bench_params.get_param_value("SwitchOnOff") != "")):
            self.__switch_on_off_relay = \
                int(self.__bench_params.get_param_value("SwitchOnOff"))
            self.PHONE_BUTTON[self.PWR_BUTTON] = self.__switch_on_off_relay

        # Get the ID of the relay for linking power supply to the device
        if ((self.get_bench_params().has_parameter("PowerSupply")) and
           (self.__bench_params.get_param_value("PowerSupply") != "")):
            self.__power_supply_relay = \
                int(self.__bench_params.get_param_value("PowerSupply"))
            if ((self.get_bench_params().has_parameter("PowerSupplySenseShunt")) and
               (self.__bench_params.get_param_value("PowerSupplySenseShunt") != "")):
                self.__ps_sense_shunt_relay = \
                    int(self.__bench_params.get_param_value("PowerSupplySenseShunt"))

        # Get the ID of the relay linked to the button to enable provisioning
        # mode on the device (may be volum up/down, home, ...)
        if ((self.get_bench_params().has_parameter("ProvisioningMode")) and
           (self.__bench_params.get_param_value("ProvisioningMode") != "")):
            self.__provisioning_mode = \
                int(self.__bench_params.get_param_value("ProvisioningMode"))

        # Get the ID of the relay for volume up, volume down
        for key in self.BUTTON_LIST:
            # Convert Button key to known key from IO Card.
            # i.e. : VOLUME_UP => VolumeUp
            relay_key = str(key).title().replace('_', '')

            if self.get_bench_params().has_parameter(relay_key):
                relay_id = int(self.__bench_params.get_param_value(relay_key))
                if relay_id:
                    self.PHONE_BUTTON[key] = relay_id

        # check if DisposeDisabled is set, must be done before write
        if (self.get_bench_params().has_parameter("DisposeDisabled") and
           (self.__bench_params.get_param_value("DisposeDisabled").lower() == "true")):
            self.get_logger().info("dispose_serial disabled")
            W.SetParam(self, "DisposeDisabled", "true")

        if self.get_bench_params().has_parameter("DefaultStates"):
            if self.__bench_params.get_param_value("DefaultStates") != "":
                self.__default_states = int(self.get_bench_params().get_param_value("DefaultStates"), 2)
                self.get_logger().info("Set Default State settings to %s", self.__default_states)
                W.SetRelayStates(self, self.__default_states)
            else:
                self.get_logger().info("io_card relay status remains unchanged")
        else:
            W.SetRelayStates(self, self.__default_states)

        # Get the ID of the relay for the status display and connect it if exist
        if ((self.get_bench_params().has_parameter("TestStatusDisplayConnect")) and
           (self.__bench_params.get_param_value("TestStatusDisplayConnect") != "")):
            self.__test_status_display_connect_relay = \
                int(self.__bench_params.get_param_value("TestStatusDisplayConnect"))
            # enable display status because we found the parameter in the bench config
            self.get_logger().info("Setting bench state display to RUNNING...")
            self.enable_line(self.__test_status_display_connect_relay)

        # Get the ID of the relay for USB OTG switch (USB device / USB Host mode)
        if ((self.get_bench_params().has_parameter("UsbOtgSwitch")) and
           (self.__bench_params.get_param_value("UsbOtgSwitch") != "")):
            self.get_logger().info("UsbOtgSwitch found in bench params")
            self.__usb_otg_type_relay = \
                int(self.__bench_params.get_param_value("UsbOtgSwitch"))