Exemplo n.º 1
0
    def convert_parameter_value(self,
                                tc_param_value,
                                tc_param_name,
                                default_cast_type=str):
        """
        convert value according to a cast type

        This function returns the value of a parameter.

        :type tc_param_value: string
        :param tc_param_value: value to convert

        :type default_cast_type: type object
        :param default_cast_type: type to cast (int, str, list ...)
        By default cast into str type.

        :rtype: depends on default_cast_type
        :return: test case parameter value
        """
        if default_cast_type == "str_to_bool":
            if Utils.is_bool(str(tc_param_value)):
                tc_param_value = Utils.str_to_bool(str(tc_param_value))
            else:
                self._logger.warning(
                    "%s='%s', invalid value in campaign for test %s" %
                    (tc_param_name, tc_param_value, self._name))
                tc_param_value = None
        elif default_cast_type is int or default_cast_type is float:
            if Utils.is_number(str(tc_param_value)):
                tc_param_value = default_cast_type(str(tc_param_value))
            else:
                tc_param_value = None
        else:
            tc_param_value = default_cast_type(tc_param_value)
        return tc_param_value
Exemplo n.º 2
0
    def _get_ucase_class_from_ucase(self, ucase):
        """
        This function gets the use case class from the use case name.

        :type   ucase: string
        :param  ucase: use case name

        :rtype:     object
        :return:    use case class
        """

        if not self._ucase_catalogs:
            error_msg = "No use case catalog has been found!"
            raise AcsConfigException(AcsConfigException.FILE_NOT_FOUND,
                                     error_msg)

        ucase_dic = self._ucase_catalogs.get(ucase)

        if not ucase_dic:
            error_msg = "Use case {0} not found in UC catalog!".format(ucase)
            raise AcsConfigException(AcsConfigException.XML_PARSING_ERROR,
                                     error_msg)

        # Presence of ClassName element is already checked by CatalogParser using xsd
        ucase_class_name = ucase_dic.get(CatalogParser.CLASSNAME_ELEM)
        ucase_class = Utils.get_class(ucase_class_name)
        return ucase_class
Exemplo n.º 3
0
    def run(self, context):
        """
        Display an image given in parameter on host screen using Tkinter
        """
        TestStepBase.run(self, context)

        host_screen = Util.str_to_bool(
            DeviceManager().get_device_config("PHONE1").get(
                "DisplayScreenAvailable", "False"))
        if host_screen is not None and host_screen:
            # On windows, Tk main window must be instanciated here, otherwise
            # an exception will be raise.
            if platform.system() == "Windows":
                self.__root = Tkinter.Tk()
                self.__root.attributes("-fullscreen", True)

            wthread = Thread(target=self.__start_tk_thread)
            wthread.start()

            wthread.join(0.2)
            while not self.__root.attributes("-fullscreen"):
                wthread.join(0.1)

            self._logger.debug("Tk main window loaded")
            wimgthread = Thread(target=self.__show_tk_img)
            wimgthread.start()

            context.set_info("DisplayImageOnHost_Event", self.__event)
        else:
            self._logger.info(
                "Host screen not available, nothing will be displayed")
Exemplo n.º 4
0
 def _extract_cts_results_summary(self, cts_result_file_path):
     """
     Extract summary report data from CTS XML report:
     <Summary failed="0" notExecuted="0" timeout="0" pass="******" />
     :return:
     """
     verdict = Global.SUCCESS
     msg = ""
     try:
         tree = et.parse(cts_result_file_path)
         self._logger.debug("CTS - Parsing of the CTS report XML file completed")
     except et.XMLSyntaxError:
         error_msg = "CTS report file: " + str(cts_result_file_path) + \
                     "- parsing-reading issue (exception= " + str(Utils.format_exception_info()) + ")"
         raise AcsToolException(AcsToolException.XML_PARSING_ERROR, error_msg)
     summary = tree.find('Summary')
     if summary is not None:
         failed_t = int(summary.get("failed"))
         not_executed_t = int(summary.get("notExecuted"))
         timeout_t = int(summary.get("timeout"))
         passed_t = int(summary.get("pass"))
         msg = "CTS results Summary: failed=%s notExecuted=%s timeout=%s pass=%s"\
               %(failed_t, not_executed_t, timeout_t, passed_t)
         if (failed_t + not_executed_t + timeout_t) > 0:
             verdict = Global.FAILURE
     else:
         verdict = Global.FAILURE
         msg = "Summary section was not found in CTS result XML file: %s" %cts_result_file_path
     return verdict, msg
Exemplo n.º 5
0
    def _load_bench_conf(self):
        """
        Loads The Bench Configuration from its XML representation into a dict

        """
        self._bench_conf = AttributeDict()

        # New way of defining device parameters == as defined in the device catalog
        try:
            self._bench_tree_node = etree.parse(self.bench_conf_filename)
        except XMLParsingErrors:
            _error("Corrupted file {0}: {1}".format(
                self.bench_conf_filename,
                Utils.get_exception_info()[1]))

        node = self.bench_device_node
        if node is not None and len(node) > 0:
            # To load proper device config, need to get device model name
            device_conf = self.device_conf
            if device_conf:
                self._device_model_name = device_conf.get("DeviceModel")
            if self._device_model_name in ('', "", None, 'multi'):
                self._device_model_name = node[0].get("deviceModel")

            conf = self._parse_bench_node(node[0])
            if conf:
                self._bench_conf.update(conf)
Exemplo n.º 6
0
    def _start_logging(self):
        """
        Starts logging required by ACS for UECmd response
        :return: None
        """
        remote_app_serial_number = ""

        # Start logging thread required for UECmd response
        file_path = ""
        if self.write_logcat_enabled or self._device.get_config(
                "writeAcsLogcat", "False", "str_to_bool"):
            timestamp = Util.get_timestamp()
            if remote_app_serial_number not in ["", None]:
                file_name = "%s_%s_%s_logcat.log" % (
                    self.get_phone_model(),
                    re.sub(':', '_', remote_app_serial_number),
                    timestamp,
                )
            else:
                file_name = "%s_%s_logcat.log" % (
                    self.get_phone_model(),
                    timestamp,
                )

            file_path = os.path.join(
                self._device.get_report_tree().get_subfolder_path(
                    subfolder_name="LOGCAT",
                    device_name=self.get_phone_model()), file_name)

        self.__log_file_name = file_path
        self._device_logger.set_output_file(self.__log_file_name)

        self._device_logger.start()
Exemplo n.º 7
0
    def init(self):
        """
        Initializes the equipment. The equipment is ready to use.
            - Load equipment driver
            - Connection to the equipment is established
            - Show equipment informations
            - Reset equipment
        """
        self.get_logger().info("Initialization")
        # Loads the driver
        self.load_driver()

        serial_number = self.get_bench_params().get_param_value(
            "serialNumber", "")
        if serial_number not in [None, ""]:
            serial_number = int(
                self.get_bench_params().get_param_value("serialNumber"))

        # get if we use external power supply as charger
        self._use_ext_ps = self.get_bench_params().get_param_value(
            "ExtPowerSupplyAsCharger", False)
        if type(self._use_ext_ps) is str:
            self._use_ext_ps = Util.str_to_bool(self._use_ext_ps)

        # Tries to connect to equipment
        self.__device_index = W.Connect(self, serial_number)
        if self.__device_index == -1:
            raise TestEquipmentException(
                TestEquipmentException.CONNECTION_ERROR,
                "Failed to connect to %s" % self.get_name())
        W.ShowInfo(self)
        W.Reset(self)
        self.battery_connector(False, self.BAT_INVALID)
Exemplo n.º 8
0
 def parse(self):
     try:
         parsed_doc = et.parse(self.__script)
         self.__doc = parsed_doc.getroot()
     except et.XMLSyntaxError:
         _, error_msg, _ = Utils.get_exception_info()
         raise AcsConfigException(AcsConfigException.XML_PARSING_ERROR, error_msg)
     return self.__parse_cmds(self.__doc)
Exemplo n.º 9
0
 def _extract_cts_results_for_bulk_tcr_upload(self, cts_result_file_path):
     """
     This function will extract CTS results from default XML into acceptable
     TCR for bulk results upload
     :return:
      payload - results structure to be uploaded into TCR as bulk update
     """
     verdict = Global.SUCCESS
     msg = ""
     payload = []
     rt = {}
     try:
         tree = et.parse(cts_result_file_path)
         self._logger.debug("CTS - Parsing of the CTS report XML file completed")
     except et.XMLSyntaxError:
         error_msg = "CTS report file: " + str(cts_result_file_path) + \
                     "- parsing-reading issue (exception= " + str(Utils.format_exception_info()) + ")"
         raise AcsToolException(AcsToolException.XML_PARSING_ERROR, error_msg)
     package_list = tree.getroot().xpath("//TestPackage")
     for package in package_list:
         self._logger.debug("CTS - Packages results processing")
         package_name = package.get('appPackageName')
         if package_name is not None:
             rt['useCase'] = package_name
         test_case = ""
         element = package.find("TestSuite")
         while element is not None:
             test_case += '.' + element.get('name')
             element = element.find("TestSuite")
         tcs = package.xpath(".//TestCase")
         for tc_node in tcs:
             tc_name = tc_node.get('name')
             if tc_name is not None:
                 tests = tc_node.xpath(".//Test")
                 for test_node in tests:
                     test_name = test_node.get('name')
                     if test_name is not None:
                         test_name = '.' + tc_name + '.' + test_name
                         result = test_node.get('result')
                         if result == "pass":
                             result = Verdict.PASS
                         elif result == "fail":
                             result = Verdict.FAIL
                         elif result == "timeout":
                             result = Verdict.INTERRUPTED
                         elif result == "notExecuted":
                             result = "NA"
                         rt['verdict'] = result
                         rt['testCase'] = package_name + test_case + test_name
                         payload.append(copy.deepcopy(rt))
     nr_elem = len(payload)
     if nr_elem == 0:
         msg = "Calculated CTS bulk upload payload is empty. Was this an empty CTS test plan execution?"
         verdict = Global.FAILURE
     else:
         msg = "calculated CTS bulk upload payload contains %s elements"% nr_elem
         LiveReporting.instance().create_bulk_tc(payload)
     return verdict, msg
Exemplo n.º 10
0
def display_acs_version(option, opt_str, value, parser):
    """
    :param option:
    :param opt_str:
    :param value:
    :param parser:
    :return:
    """
    print "ACS " + Util.get_acs_release_version()
    sys.exit(0)
Exemplo n.º 11
0
 def get_ucase_class(self):
     """
     This function returns usecase class if present.
     """
     ucase_class = None
     ucase_class_node = self.get_testcase_property(USECASE_CLASS_NAME_NODE,
                                                   None)
     if ucase_class_node is not None:
         ucase_class = Utils.get_class(ucase_class_node)
     return ucase_class
Exemplo n.º 12
0
 def _init_logger(self):
     """
     Initializes the logger.
     """
     log_port = int(self._device_config.get("logPort", "8003"))
     self._device_logger = Win8Logger(self._device_ip, log_port)
     time = Util.get_timestamp()
     file_name = self.get_phone_model() + "_" + str(log_port) + time + "_win8.log"
     file_path = path.join(self.get_report_tree().get_report_path(),
                           file_name)
     self._device_logger.set_output_file(file_path)
Exemplo n.º 13
0
 def _parse_campaign_file_path(self, campaign_file_path):
     # XML parser parses the campaign config file
     try:
         return et.parse(campaign_file_path)
     except et.XMLSyntaxError:
         _, error_msg, _ = Utils.get_exception_info()
         self._logger.error(
             "Campaign file is corrupted : parsing-reading issue in {0}".
             format(campaign_file_path))
         raise AcsConfigException(AcsConfigException.XML_PARSING_ERROR,
                                  error_msg)
Exemplo n.º 14
0
    def install_device_executable(self, bin_path, destination, timeout=0):
        """
        Install a binary as device executable file

        :type bin_path: str
        :param bin_path: file to be installed

        :type  destination: str
        :param destination: destination on device

        :type  timeout: int
        :param timeout: operation timeout

        :rtype: tuple (bool, str)
        :return: Output status and output log
        """
        status = Util.Global.FAILURE
        status_msg = "Undefined error while pushing binary on device"
        binary_filename = os.path.basename(bin_path)

        if os.path.isfile(bin_path):
            if destination is not None:
                # Initialize timeout if not set
                if not timeout:
                    timeout = Util.compute_timeout_from_file_size(
                        bin_path, self._device.min_file_install_timeout)

                # Build chmod commands
                dest_path = posixpath.join(destination, binary_filename)
                bin_chmod_cmd = "chmod +x {0}".format(dest_path)
                # Push the binary file
                self._logger.info("Pushing %s -> %s ..." %
                                  (str(bin_path), str(dest_path)))
                # status, status_msg = self._run_cmd_and_check_failure(bin_push_cmd, timeout)
                status, status_msg = self._device.push(bin_path, destination,
                                                       timeout)

                if status == Util.Global.SUCCESS:
                    # Modify access right on the binary file
                    status, status_msg = self._run_cmd_and_check_failure(
                        bin_chmod_cmd, timeout)
                    if status == Util.Global.SUCCESS:
                        status_msg = "Binary has been successfully installed on the device!"
            else:
                status_msg = "Impossible to push %s, no destination given" % (
                    str(bin_path), )
        else:
            status_msg = "Impossible to install, no file given"

        return status, status_msg
Exemplo n.º 15
0
    def find_report_file(self):
        """
        This function will search for the ACS Report XML file inside ACS Report
        folder provided as input

        :rtype: string
        :return: Report file found if found in input Report folder
        """
        for root, dirnames, filenames in os.walk(self.failed_folder_path):
            for filename in filenames:
                if filename.endswith(".xml"):
                    filename = os.path.join(root, filename)
                    if Util.is_report_file(filename):
                        return filename
        return ""
Exemplo n.º 16
0
    def run(self, context):
        """
        Close image Tkinter viewer
        """
        TestStepBase.run(self, context)

        host_screen = Util.str_to_bool(
            DeviceManager().get_device_config("PHONE1").get(
                "DisplayScreenAvailable", "False"))
        if host_screen is not None and host_screen:
            event = context.get_info("DisplayImageOnHost_Event")
            event.set()
        else:
            self._logger.info(
                "Host screen not available, nothing will be closed")
Exemplo n.º 17
0
 def get_action_nodes(self):
     """
     Returns the list of all I{ACTION} XML nodes.
     :rtype: NodeList
     :return: the list of all I{ACTION} XML nodes
     """
     ui_seq = None
     actions = []
     try:
         ui_seq = et.parse(self.__script)
     except et.XMLSyntaxError:
         _, error_msg, _ = Utils.get_exception_info()
         raise AcsConfigException(AcsConfigException.XML_PARSING_ERROR, error_msg)
     actions = ui_seq.xpath("//ACTION")
     return actions
Exemplo n.º 18
0
 def __init__(self):
     super(ExtendedDebugModule, self).__init__()
     self._retrieve_dmesg = None
     self._retrieve_anr_traces = None
     self._retrieve_tombstone = None
     self._retrieve_logcat = None
     self._only_for_failed_tests = None
     self._retrieve_data = None
     self._device_id = Util.AcsConstants.NOT_AVAILABLE
     self._verdict = Util.Verdict()
     self.result_folder_path = None
     self.result_file_name = None
     self.anrs_number = None
     self.tombs_number = None
     self.tombs_list = None
     self.tc_verdict = None
Exemplo n.º 19
0
    def _load_device_conf(self):
        """
        Loads The Device Configuration from its XML representation into a dict

        """
        try:
            self._device_tree_node = etree.parse(self.device_conf_filename)
        except XMLParsingErrors:
            _error("Corrupted file {0}: {1}".format(
                self.device_conf_filename,
                Utils.get_exception_info()[1]))

        self._parse_device_node()
        self._device_schema = self.extract_schema(
            self.device_root_node,
            schema_folder=Paths.FWK_DEVICE_MODELS_CATALOG,
            file_only=False)
Exemplo n.º 20
0
    def create_report_folder(self):
        """
        Create report folder path from either a path specified by report_path
        or by creating one by computing timestamp, campaign and hw variant name.
        """
        if not self.__campaign_report_path:
            # Initialize the report path

            # Create the report folder for the current campaign
            if self._report_path is None:
                # No path specified (from ACS cmd line)
                # We are going to generate one report folder name
                # Adding timestamp
                campaign_folder_name = Util.get_timestamp()

                if self._hw_variant_name:
                    # Adding hw variant
                    campaign_folder_name += "_" + self._hw_variant_name

                if self._campaign_name:
                    # Adding current campaign name
                    campaign_name = os.path.splitext(
                        os.path.basename(self._campaign_name))[0]
                    campaign_folder_name += "_" + campaign_name

                campaign_report_path = os.path.join(os.getcwd(),
                                                    Folders.REPORTS,
                                                    campaign_folder_name)
            else:
                # Path specified (from ACS cmd line
                # Use it!
                campaign_report_path = self._report_path

            index = 1
            campaign_report_path_orig = campaign_report_path
            while os.path.exists(campaign_report_path):
                # Increment the folder name until it does not exists
                campaign_report_path = campaign_report_path_orig + "_" + str(
                    index)
                index += 1
            os.makedirs(campaign_report_path)
            self._logger.info("Campaign report path is %s" %
                              campaign_report_path)
            # Store the path of the folder
            self.__campaign_report_path = campaign_report_path
Exemplo n.º 21
0
    def pid_of(self, process_name):
        """
        Get the pid of a process by its name.

        :rtype: str
        :return: the pid of the process or empty str if process as not been found.
        """
        cmd = "pidof " + str(process_name)
        cmd = self._internal_exec(cmd)

        self._logger.info("Getting the pid of the process with name: %s" %
                          process_name)
        (_result, pid) = Util.internal_shell_exec(cmd, 10)
        if not pid.isdigit() and not pid == "":
            raise DeviceException(DeviceException.INTERNAL_EXEC_ERROR,
                                  "The pid should be a int. Is: %s" % str(pid))
        self._logger.debug("PID of %s is: %s" % (process_name, pid))
        return pid
Exemplo n.º 22
0
    def run_cts(self):
        '''
        This function will deal with running CTS
        '''

        current_time = time.time()
        test_cmd_line = "%s %s" % (self._cts_exec_path, self._test_cmd_lines)
        result, output = Utils.internal_shell_exec(test_cmd_line,
                                                   self._test_timeout)
        if result != Global.SUCCESS:
            return Global.FAILURE
        for root, _, filenames in os.walk(self._cts_path):
            for file_ in filenames:
                if CTS_RESULT_FILENAME in file_:
                    cts_results = os.path.join(root, file_)
                    left_time = time.time() - current_time
                    self._test_timeout = self._test_timeout - left_time
                    xml_file = open(cts_results, 'r')
                    xml_cont = xml_file.read()
                    xml_file.close()
                    if 'result="notExecuted"' in xml_cont:
                        if self._test_timeout > 0:
                            self._test_cmd_lines = CTS_CONTINUE_SESSION_COMMAND
                            self._logger.debug("CTS - Not Executed retry")
                            self.run_cts()
                    elif 'result="fail"' in xml_cont:
                        if self._test_timeout > 600 and self._test_failed_retry_no > 0:
                            self._test_failed_retry_no -= 1
                            x_res = os.path.join(
                                os.path.dirname(cts_results),
                                'backup_cts_res_' +
                                str(self._test_failed_retry_no))
                            shutil.copyfile(cts_results, x_res)
                            xml_cont = xml_cont.replace('result="fail"', \
                                                        'result="notExecuted"')
                            xml_file = open(cts_results, 'w')
                            xml_file.write(xml_cont)
                            xml_file.close()
                            #self.motc_library.reboot_device()
                            self._test_cmd_lines = CTS_CONTINUE_SESSION_COMMAND
                            self._logger.debug("CTS - Failed retry:%s" %
                                               self._test_failed_retry_no)
                            self.run_cts()
Exemplo n.º 23
0
    def _init_bench_info_node(self):
        """
        Initialize the DeviceInfo Node with theses values:

        DeviceInfo:
            - Bench Name (hostname)
            - Bench user
            - Bench IP
            - Bench OS
            - ACS Version (host)

        :rtype: None
        """

        # Create the <BenchInfo> element
        self.bench_info = etree.SubElement(self.document, "BenchInfo")

        # Create the <BenchName> node for hostInfo
        bench_name = etree.SubElement(self.bench_info, "BenchName")
        # Set BenchName value
        bench_name.text = clean_xml_text(self.__get_bench_name())

        # Create the <BenchUser> node for hostInfo
        bench_user = etree.SubElement(self.bench_info, "BenchUser")
        # Set BenchUser value
        bench_user.text = clean_xml_text(self.__get_bench_user())

        # Create the <BenchIp> node for hostInfo
        bench_ip = etree.SubElement(self.bench_info, "BenchIp")
        # Set BenchIp value
        bench_ip.text = self.__get_bench_ip()

        # Create the <BenchOs> node for hostInfo
        bench_os = etree.SubElement(self.bench_info, "BenchOs")
        # Set BenchName value
        bench_os.text = self.__get_bench_os()

        # Create the <AcsVersion> node for hostInfo
        acs_version = etree.SubElement(self.bench_info, "AcsVersion")
        # Set AcsVersion value
        acs_version.text = Util.get_acs_release_version()
Exemplo n.º 24
0
    def run(self, context):
        """
        Generic method to run MediaPlayer test steps
        """
        TestStepBase.run(self, context)

        host_screen = Util.str_to_bool(
            DeviceManager().get_device_config("PHONE1").get(
                "DisplayScreenAvailable", "False"))
        if host_screen is not None and host_screen:
            from acs_test_scripts.Lib.EM.VideoPlayback import MediaPlayer as MediaPlayer

            self._media_player = context.get_info(self._pars.instance_name)
            if self._media_player is None:
                self._media_player = MediaPlayer()
                context.set_info(self._pars.instance_name, self._media_player)

            self._run()
        else:
            self._logger.info(
                "Host screen not available, nothing will be displayed")
Exemplo n.º 25
0
    def run(self, context):
        """
        Runs the test step

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

        # Looks for the key in the campaign configuration file.
        value = Utils.get_config_value(
            DeviceManager().get_global_config().campaignConfig,
            "Campaign Config", self._pars.key)
        if value is None:
            self._logger.info(
                "{0}:  Value found for {1} in campaign config was None, storing the default value of {2} instead"
                .format(self._pars.id, self._pars.key,
                        self._pars.default_value))
            value = self._pars.default_value
        # Write value to the context so that it can be used by other TestSteps.
        context.set_info(self._pars.param_value, value)
Exemplo n.º 26
0
    def __is_stock_msg_app_running(self):
        """
        Checks id the stock messaging application is running.
        :rtype: boolean
        :return: True if the application is running False otherwise.
        """
        result_key = "isMessagingAppRunning"

        self._logger.info("Check if stock messaging is running.")

        function = "checkIfMmsStockAppIsRunning"

        output = self._internal_exec_v2(self._mms_module,
                                        function,
                                        is_system=True)

        if result_key not in output:
            raise AcsToolException(
                AcsToolException.INVALID_PARAMETER,
                "output key %s not found : %s" % (result_key, str(output)))
        # Convert result to bool.
        result = Util.str_to_bool(output[result_key])
        return result
Exemplo n.º 27
0
    def install_device_app(self, app_path, timeout=0, allow_downgrade=False):
        """
        Install a device application

        :type app_path: str
        :param app_path: file to be installed

        :type  timeout: int
        :param timeout: operation timeout

        :type  allow_downgrade: bool
        :param allow_downgrade: allow the downgrade of application

        :rtype: tuple (bool, str)
        :return: Output status and output log
        """
        status = Util.Global.FAILURE
        status_msg = "Undefined error while installing application on device"
        cmd_options = "-r"
        if allow_downgrade:
            cmd_options += " -d"

        if os.path.isfile(app_path):
            # Define the timeout from the file size
            if not timeout:
                timeout = Util.compute_timeout_from_file_size(
                    app_path, self._device.min_file_install_timeout)

            self._logger.info("Installing {0} ...".format(app_path))
            cmd = 'adb install {0} "{1}"'.format(cmd_options, app_path)
            status, status_msg = self._run_cmd_and_check_failure(cmd, timeout)
        else:
            status_msg = "Impossible to install {0}, file does not exist".format(
                app_path)

        return status, status_msg
Exemplo n.º 28
0
class ACBP(IIOCard, DllLoader):
    """
    Class ACBP: implementation of UsbDIO prototype
    """
    # Defining possible usb devices (Usb host, DCP, ...)
    SUPPORTED_DEVICE_TYPE = [IIOCard.USB_HOST_PC, IIOCard.SDP]

    LINES = Util.enum(
        'battery',  # ctrl00 on=inserted / off=removed
        'usb_5v_gnd',  # ctrl01
        'usb_dp_dm_id',  # ctrl02
        'batt_id_ctrl3',  # ctrl03
        'batt_id_ctrl4',  # ctrl04
        'batt_id_ctrl5',  # ctrl05
        'temp_value_ctrl6',  # ctrl06
        'temp_value_ctrl7',  # ctrl07
        'usb_charger',  # ctrl08 on=CP / off=DP
        'batt_id_glitch',  # ctrl09 on=start the glitch
        #       off= rearm
        'batt_id_glitch_duration',  # ctrl10 on=5p2ms / off=165us
        'sim_card',  # ctrl11 on=insertion
        #       off=removal
        'button_ctrl12',  # ctrl12 on=close connection
        #       off=open connection
        'usb_charger_select',  # ctrl13 on=DC source / off=USBPC source
        'digital_battery_protocol',  # ctrl14 on=logical 0 / off=logical 1
        'supply1_switch',  # ctrl15 on=SDcard Vss1 / off=AC charger
        'temp_value_ctrl16',  # ctrl16
        'sd_card',  # ctrl17 on=insertion / off=removal
        'usb_switch_select',  # ctrl18 on=USB accessories | USB Host PC
        #       off=USB charger
        'usb_switch_select2',  # ctrl19 on=USB Host PC
        #       off=USB accessories
        # (depends on ',usb_switch_select',)
        'button_ctrl20',  # ctrl20 on=close connection
        #       off=open connection
        'button_ctrl21',  # ctrl21 on=close connection
        #       off=open connection
        'button_ctrl22',  # ctrl22 on=close connection
        #       off=open connection
        'button_ctrl23',  # ctrl23 on=close connection
        #       off=open connection
        'button_ctrl24',  # ctrl24 on=close connection
        #       off=open connection
        'button_ctrl25',  # ctrl25 on=close connection
        #       off=open connection
        'button_ctrl26',  # ctrl26 on=close connection
        #       off=open connection
        'power_supply1_ac_charger'  # ctrl27 depends on 'supply1_switch'
    )

    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: dict
        :param bench_params: the dictionary containing equipment bench parameters
        """
        IIOCard.__init__(self)
        DllLoader.__init__(self, name, model, eqt_params)
        self.__bench_params = bench_params
        self.__device_index = -1
        self.__wall_charger = None

    def get_bench_params(self):
        """
        :rtype: bench configuration
        :return: the bench configuration dictionary of the equipment
        """
        return self.__bench_params

    def get_dev_idx(self):
        """
        :rtype: integer
        :return: the index of the device
        """
        return self.__device_index

    def init(self):
        """
        Initializes the equipment. The equipment is ready to use.
            - Load equipment driver
            - Connection to the equipment is established
            - Show equipment informations
            - Reset equipment
        """
        self.get_logger().info("Initialization")
        # Loads the driver
        self.load_driver()

        serial_number = None
        if self.get_bench_params().has_parameter("serialNumber"):
            serial_number = \
                int(self.get_bench_params().get_param_value("serialNumber"))

        # Tries to connect to equipment
        self.__device_index = W.Connect(self, serial_number)
        if self.__device_index == -1:
            raise TestEquipmentException(
                TestEquipmentException.CONNECTION_ERROR,
                "Failed to connect to %s" % self.get_name())
        W.ShowInfo(self)
        W.Reset(self)

    def release(self):
        """
        Releases all resources allocated to equipment
        """
        self.get_logger().info("Release")
        self.unload_driver()
        self.__device_index = -1

    def reset(self):
        """
        Reset the IO card to default states
        """
        self._logger.warning("reset method is not implemented !")

    def usb_connector(self, plug):
        """
        Handles USB connector connection and disconnection
        :type plug: boolean
        :param plug: action to be done:
            - True  => plug currently selected USB device
            - False => unplug currently selected USB device
        """
        if plug:
            self.get_logger().info("Plug USB")
            W.Enable(self, self.LINES.usb_5v_gnd)
        else:
            self.get_logger().info("Unplug USB")
            W.Disable(self, self.LINES.usb_dp_dm_id)

        time.sleep(0.2)

        if plug:
            W.Enable(self, self.LINES.usb_dp_dm_id)
            # Waiting for enumeration
            time.sleep(3)
        else:
            W.Disable(self, self.LINES.usb_5v_gnd)

    def usb_device_selector(self, usb_device):
        """
        Handles USB device selection
        :param usb_device: USB device to select:
            - "USB_HOST_PC" -> USB Host PC (ACS, FW/SW Updates)
        """
        self.get_logger().info("Select USB device: %s", usb_device)

        if usb_device == ACBP.USB_HOST_PC:
            W.Enable(self, self.LINES.usb_switch_select)
            W.Disable(self, self.LINES.usb_switch_select2)
        else:
            raise TestEquipmentException(
                TestEquipmentException.INVALID_PARAMETER,
                "Unknown USB device: %s!" % usb_device)

    def simulate_insertion(self, device_type):
        """
        Do a cable insertion (usb or other)
        If this function is called twice then it will unplug then plug again instead of doing nothing.
        :type device_type: str
        :param device_type: cable device to select. Possible values:
            - "USB_HOST_PC": USB Host PC (ACS, FW/SW Updates)
        """
        self.get_logger().info("Select cable type: %s", device_type)

        if device_type == self.USB_HOST_PC:
            # remove usb
            self.usb_connector(False)
            # switch to wanted usb
            self.usb_device_selector(device_type)
            # plug usb
            self.usb_connector(True)
        else:
            raise TestEquipmentException(
                TestEquipmentException.INVALID_PARAMETER,
                "Unknown USB device: %s!" % device_type)

    def usb_host_pc_connector(self, plug):
        """
        Handles USB connector connection and disconnection of USB host PC device
        :type plug: boolean
        :param plug: action to be done
            - True  => plug USB to host PC
            - False => unplug USB from host PC

        :rtype:None
        """
        # Select USB host PC device
        self.usb_device_selector(ACBP.USB_HOST_PC)
        # Plug or unplug USB
        self.usb_connector(plug)
        return True

    def press_power_button(self, duration):
        """
        Presses power button.
        Allow to simulate special behavior on the board like S3 mode.
        :type duration: float
        :param duration: time while the power button is pressed
            The value should be superior than 0 seconds
        """
        self.get_logger().info("Press power button during %f second(s)",
                               duration)

        W.Enable(self, self.LINES.button_ctrl12)
        time.sleep(duration)
        W.Disable(self, self.LINES.button_ctrl12)

    def load_specific_dut_config(self, dut_name):
        """
        Configure different setting on your io card related to dut name,
        This is useful in multi device campaign.
        The setting will depending of your current dut name and what you declared on
        benchconfig.

        :type dut_name: str
        :param dut_name: phone name

        .. warning:: not functional for this io card, put only for compatibility reason
        """
        self.get_logger().warning(
            "load_specific_dut_config: NOT implemented for ACBP")

    def set_default_battery_type(self, batt_type):
        """
        set default battery type.
        all function that play with battery type will take this value if the type is omitted.

        :type batt_type: str
        :param batt_type: default battery type supported by the device
        """
        self.get_logger().warning(
            "set_default_battery_type: NOT implemented for ACBP")

    def get_default_battery_type(self):
        """
        get default battery type.

        :rtype: str
        :return: default battery type
                  return None if not set
        """
        self.get_logger().warning(
            "get_default_battery_type: NOT implemented for ACBP")

    def set_default_wall_charger(self, device_default_charger):
        """
        set default wall charger.

        :type device_default_charger: str
        :param device_default_charger: default wall charger supported by the device
        """
        self.get_logger().warning(
            "set_default_wall_charger: NOT implemented for ACBP")

    def get_default_wall_charger(self):
        """
        get default wall charger.

        :rtype: str
        :return: default wall charger supported by the device
                  return None if not set
        """
        self.get_logger().warning(
            "get_default_wall_charger: NOT implemented for ACBP")
Exemplo n.º 29
0
    """
    Super class in order to create set_logger accessor
    """
    def set_logger(self, logger):
        """
        Set logger accessor
        """
        self._logger = logger


if __name__ == "__main__":
    bench_config = "bench_config_conformance"
    equipment_catalog = "Equipment_Catalog"
    global_config = Util.Dictionary(attribute1='benchConfig',
                                    attribute2='deviceConfig',
                                    attribute3='campaignConfig',
                                    attribute4='equipmentCatalog',
                                    attribute5='campaignReportTree')
    global_config.benchConfig = {}
    global_config.deviceConfig = {}
    global_config.campaignConfig = {}
    global_config.equipmentCatalog = {}
    global_config.campaignReportTree = None
    flash_file_path = None

    file_parsing_manager = FileParsingManager(bench_config, equipment_catalog,
                                              global_config)
    file_parsing_manager.parse_bench_config()

    bench_name = "CONFIGURABLE_AP1"
    equipment_model = "AP_CONTROLLER"
Exemplo n.º 30
0
class ACBT(ACBE):

    """
    Class ACBT: implementation of enhanced ACB for tablet
    """

    # Defining possible usb devices (Usb host, DCP, ...)
    SUPPORTED_DEVICE_TYPE = [ACBE.DCP, ACBE.CDP, ACBE.USB_HOST_PC,
                             ACBE.SDP, ACBE.AC_CHGR, ACBE.WALL_CHARGER]

    LINES = Util.enum('battery',  # ctrl00 on=inserted / off=removed
                      'usb_5v_gnd',  # ctrl01
                      'usb_dp_dm_id',  # ctrl02
                      'batt_id_ctrl3',  # ctrl03
                      'batt_id_ctrl4',  # ctrl04
                      'batt_id_ctrl5',  # ctrl05
                      'temp_value_ctrl6',  # ctrl06
                      'temp_value_ctrl7',  # ctrl07
                      'usb_charger',  # ctrl08 on=CP / off=DP
                      'batt_id_glitch',  # ctrl09 on=start the glitch
                                        #       off= rearm
                      'batt_id_glitch_duration',  # ctrl10 on=5p2ms / off=165us
                      'sim_card',  # ctrl11 on=insertion
                                        #       off=removal
                      'button_ctrl12',  # ctrl12 on=close connection
                                        #       off=open connection
                      'usb_charger_select',  # ctrl13 on=DC source / off=USBPC source
                      'digital_battery_protocol',  # ctrl14 on=logical 0 / off=logical 1
                      'supply1_switch',  # ctrl15 on=SDcard Vss1 / off=AC charger
                      'temp_value_ctrl16',  # ctrl16
                      'sd_card',  # ctrl17 on=insertion / off=removal
                      'usb_switch_select',  # ctrl18 on=USB accessories | USB Host PC
                                        #       off=USB charger
                      'usb_switch_select2',  # ctrl19 on=USB Host PC
                                        #       off=USB accessories
                                        # (depends on ',usb_switch_select',)
                      'button_ctrl20',  # ctrl20 volume down
                      'button_ctrl21',  # ctrl21 volume up

                      'button_ctrl22',  # ctrl22 on=close connection
                                        #       off=open connection
                      'button_ctrl23',  # ctrl23 on=close connection
                                        #       off=open connection
                      'button_ctrl24',  # ctrl24 on=close connection
                                        #       off=open connection
                      'button_ctrl25',  # ctrl25 on=close connection
                                        #       off=open connection
                      'button_ctrl26',  # ctrl26 on=close connection
                                        #       off=open connection
                      'power_supply1_ac_charger',  # ctrl27 depends on 'supply1_switch'
                      'OTG_ctrl28',  # ctrl28
                      'OTG_ctrl29',  # ctrl29
                      'OTG_ctrl30'  # ctrl30
                      )

    ACCESSORY_TO_ACB = {
        ACBE.SDP: [  # SDP
            (True, LINES.usb_charger),  # ctrl08
            (True, LINES.usb_switch_select),  # ctrl18
            (False, LINES.usb_switch_select2)],  # ctrl19
        ACBE.DCP: [  # DCP
            (False, LINES.usb_charger),  # ctrl08
            (False, LINES.usb_switch_select),  # ctrl18
            (False, LINES.usb_switch_select2)],  # ctrl19
        ACBE.CDP: [  # CDP
            (True, LINES.usb_charger),  # ctrll08
            (True, LINES.usb_switch_select),  # ctrl18
            (True, LINES.usb_switch_select2),  # ctrl19
            # ID in normal mode
            (False, LINES.OTG_ctrl28),  # ctrl28
            (True, LINES.OTG_ctrl29),  # ctrl29
            (False, LINES.OTG_ctrl30)],  # ctrl30
        ACBE.OTG: [  # OTG
            (False, LINES.usb_charger),  # ctrl08
            (True, LINES.usb_switch_select),  # ctrl18
            (True, LINES.usb_switch_select2),  # ctrl19
            (False, LINES.OTG_ctrl28),  # ctrl28
            (True, LINES.OTG_ctrl29),  # ctrl29
            (False, LINES.OTG_ctrl30)],  # ctrl30
        ACBE.EXTERNAL_PS_ON: [
            (True, LINES.usb_charger_select)],  # ctrl01
        ACBE.EXTERNAL_PS_OFF: [
            (False, LINES.usb_charger_select)],  # ctrl01
        ACBE.AC_CHGR_ON: [
            (False, LINES.usb_charger_select, 1)],  # ctrl13
        ACBE.AC_CHGR_OFF: [
            (True, LINES.usb_charger_select, 1)]  # ctrl13
            }

    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: dict
        :param bench_params: the dictionary containing equipment bench parameters
        """
        ACBE.__init__(self, name, model, eqt_params, bench_params)

    def init(self):
        """
        Initializes the equipment. The equipment is ready to use.
            - connect sense & force of the alim in order to avoid
            overprotection
        """
        ACBE.init(self)
        W.Enable(self, self.LINES.usb_charger_select)  # ctrl13
        self.usb_connector(False)

    def battery_connector(self, plug, battery_type="DEFAULT"):
        """
        Handles battery insertion / removal
        :type plug: boolean
        :param plug: action to be done:
            - True  => insert battery
            - False => remove battery
        :type battery_type: str
        :param battery_type: battery to plug
        """
        if plug:
            self.get_logger().info("Battery insertion")
            # Insert battery
            W.Disable(self, self.LINES.power_supply1_ac_charger)  # ctrl27
            time.sleep(0.3)
            W.Enable(self, self.LINES.battery)  # ctrl00
            W.Enable(self, self.LINES.supply1_switch)  # ctrl15
            time.sleep(0.3)
            W.Enable(self, self.LINES.power_supply1_ac_charger)  # ctrl27
            W.Disable(self, self.LINES.button_ctrl12)  # ctrl12
            time.sleep(0.3)
            W.Disable(self, self.LINES.button_ctrl12)  # ctrl12
            # work around for bench batt id bug
            self.set_battery_type(battery_type)
        else:
            self.get_logger().info("Battery removal")
            # remove battery
            W.Disable(self, self.LINES.power_supply1_ac_charger)  # ctrl27
            time.sleep(0.3)
            W.Disable(self, self.LINES.battery)  # ctrl00
            W.Enable(self, self.LINES.supply1_switch)  # ctrl15
            # work around for bench batt id bug
            self.set_battery_type(self.BAT_INVALID)

    def ac_charger_connector(self, plug):
        """
        handle AC charger insertion.
        :type plug: boolean
        :param plug: action to be done:
            - True  => insert charger
            - False => remove charger
        """
        if plug:
            self.get_logger().info("Plug AC CHGR")
            if not self._acb_com_cmd_list(self.ACCESSORY_TO_ACB[self.AC_CHGR_ON]):
                self._logger.debug("ac_charger_connector: already plug")
        else:
            self.get_logger().info("Unplug AC CHGR")
            if self._acb_com_cmd_list(self.ACCESSORY_TO_ACB[self.AC_CHGR_OFF]):
                if self._use_ext_ps:
                    self.ext_supply_connector(False)
            else:
                self._logger.debug("ac_charger_connector: already unplug")

    def ext_supply_connector(self, plug):
        """
        Handles external power supply connection and disconnection
        :type plug: boolean
        :param plug: action to be done:
            - True  => plug external power supply
            - False => unplug external power supply
        """
        self.get_logger().warning("Plug external power supply NOT implemented for ACBT")

    def reset(self):
        """
        Reset the IO card to default states
        """
        self.ac_charger_connector(False)
        self.usb_connector(False)
        self.battery_connector(False)
        self.battery_temperature(25)