Exemple #1
0
    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"))
Exemple #2
0
def init_ctx(global_dict, logger, global_config):
    # VERDICT GLOBALS
    global_dict["VERDICT"] = Global.FAILURE
    global_dict["OUTPUT"] = ""
    global_dict["FAILURE"] = Global.FAILURE
    global_dict["SUCCESS"] = Global.SUCCESS

    # LOG GLOBALS
    global_dict["PRINT_DEBUG"] = logger.debug
    global_dict["PRINT_INFO"] = logger.info
    global_dict["PRINT_ERROR"] = logger.error
    global_dict["PRINT_WARNING"] = logger.warning

    # DEVICE GLOBALS
    device = DeviceManager().get_device(AcsConstants.DEFAULT_DEVICE_NAME)
    global_dict["DEVICE_MANAGER"] = DeviceManager()
    global_dict["DEVICE"] = device
    global_dict["DEVICE_LOGGER"] = device.get_device_logger()

    # EQUIPMENT GLOBALS
    global_dict["EQUIPMENT_MANAGER"] = EquipmentManager()
    io_card_name = device.config.get("IoCard", "IO_CARD")
    global_dict["IO_CARD"] = EquipmentManager().get_io_card(io_card_name)

    # REPORT GLOBALS
    global_dict["REPORT_PATH"] = device.get_report_tree().get_report_path()
    global_dict["ACS_REPORT_FILE_PATH"] = device.get_report_tree(
    ).report_file_path

    # ACS GLOBALS
    global_dict["PATH_MANAGER"] = Paths
    global_dict["LOCAL_EXEC"] = internal_shell_exec
    global_dict["BENCH_CONFIG"] = global_config.benchConfig
    global_dict["EXECUTION_CONFIG_PATH"] = path.abspath(Paths.EXECUTION_CONFIG)
    global_dict["CREDENTIALS"] = global_config.credentials
    def connect_board(self):
        """
        Open connection to the board
        """
        # Connect to the board
        self.get_logger().info("Connecting the board...")
        self._is_phone_connected = True
        self.get_logger().info("*** Connected!")

        # Retrieve/update device properties
        DeviceManager().update_device_properties(self.whoami().get('device'))

        return self._is_phone_connected
Exemple #4
0
    def finalize(self):
        """
        Clear all remaining objects created by the test
        """
        self._logger.debug("")
        self._logger.debug("%s: Finalize" % self._name)
        self._logger.debug("")

        # Finalize all instantiated UECommands for all instantiated devices
        for device in DeviceManager().get_all_devices():
            if device.uecommands:
                device.inject_device_log("i", "ACS_TESTCASE", "FINALIZE: %s" % self._name)
                for _, uecmd_object in device.uecommands.iteritems():
                    if uecmd_object:
                        uecmd_object.finalize()
                device.uecommands = {}
        return Global.SUCCESS, AcsConstants.NO_ERRORS
Exemple #5
0
    def __write_report_info(self):
        """
        Writes the updated information of the device into the Test Report

        - SwRelease
        - DeviceId
        - Imei
        - ModelNumber
        - FwVersion
        - BasebandVersion
        - KernelVersion
        - AcsAgentVersion
        - Device Properties file

        :rtype: None
        """
        try:
            # Retrieve all device properties
            prop_list = DeviceManager().get_device_properties(
                Util.AcsConstants.DEFAULT_DEVICE_NAME)

            # Create device info report files
            self.__test_report.build_deviceinfo_file(prop_list)

            # Update DeviceInfo node in campaign result file
            device_properties = self.__test_case_manager.get_device_instance(
            ).get_device_info()
            self.__test_report.update_device_info_node(device_properties)

            # Update FlashInfo node in campaign result file
            flash_device_properties = self.__test_case_manager.get_device_instance(
            ).flash_device_properties
            self.__test_report.update_flash_info_node(flash_device_properties)

        except (KeyboardInterrupt, SystemExit):
            raise

        except Exception as e:  # pylint: disable=W0703
            self.__logger.warning(
                "Error occured when writing report info ! (%s)" % str(e))
Exemple #6
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:
            msg = ("{0}:  Value found for {1} in campaign config was None, " +
                   "storing the default value of {2} instead")
            self._logger.info(msg.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)
    def _setup(self, **kwargs):
        """
            This function initializes all global variables used in acs execution.
            It parses the arguments given to CampaignEngine,
            parses XML files associated & read the campaign content
            for the TestCaseManager to execute.

            :param device_name: Device model under test.
            :type device_name: str

            :param serial_number: Device id or serial number of the DUT.
            :type serial_number: str

            :param campaign_name: Campaign xml file to execute.
            :type campaign_name: str

            :param campaign_relative_path: Campaign relative path.
            :type campaign_relative_path: str

            :param bench_config: Bench Config file to use.
            :type bench_config: str

            :param device_parameters: List of device parameters to override default values in Device_Catalog.
            :type device_parameters: list

            :param flash_file_path: Flash file full path.
            :type flash_file_path: str

            :param random_mode: Enable random mode if your campaign is configured to run random TC.
            :type random_mode: bool

            :param user_email: Valid user email.
            :type user_email: str

            :param credentials: Credentials in User:Password format.
            :type credentials: str

            :rtype: bool
            :return: True if setup is correctly done, else False
        """

        status = None

        device_name = kwargs["device_name"]
        serial_number = kwargs["serial_number"]
        campaign_name = kwargs["campaign_name"]
        campaign_relative_path = kwargs["campaign_relative_path"]
        device_parameters = kwargs["device_parameter_list"]
        random_mode = kwargs["random_mode"]
        user_email = kwargs["user_email"]
        credentials = kwargs["credentials"]
        log_level_param = kwargs["log_level"]

        # In case the uuid is not set, generate it to ensure that the campaign has an id
        # This id is used for reporting purpose
        self.__logger.info('Checking metacampaign UUID integrity...')
        metacampaign_uuid = kwargs["metacampaign_uuid"]
        valid_uuid = is_uuid4(metacampaign_uuid)
        if not valid_uuid:
            self.__logger.warning("Metacampaign UUID is empty or not a valid UUID4; a new one is generated ...")
        metacampaign_uuid = metacampaign_uuid if valid_uuid else str(uuid.uuid4())
        self.__logger.info("Metacampaign UUID is {0}".format(metacampaign_uuid))

        self.__init_configuration(**kwargs)

        # Init Campaign report path
        self.__init_report_path(campaign_name)
        # Instantiate a live reporting interface
        campaign_name = os.path.splitext(os.path.basename(campaign_name))[0]
        self.__init_live_reporting(campaign_name,
                                   metacampaign_uuid,
                                   user_email,
                                   kwargs.get("live_reporting_plugin"))

        self.__stop_on_critical_failure = Util.str_to_bool(
            self.__global_config.campaignConfig.get("stopCampaignOnCriticalFailure", "False"))
        self.__stop_on_first_failure = Util.str_to_bool(
            self.__global_config.campaignConfig.get("stopCampaignOnFirstFailure", "False"))

        # Provide the global configuration for equipment manager and device manager
        # They will use it to retrieve or set values in it.
        EquipmentManager().set_global_config(self.__global_config)
        DeviceManager().set_global_config(self.__global_config)

        # Initialize equipments necessary to control DUT (io card, power supply, usb hub)
        EquipmentManager().initialize()

        # Read serial number if given as ACS command line
        if serial_number not in ["", None]:
            # Priority to serialNumber from --sr parameter
            device_parameters.append("serialNumber=%s" % str(serial_number))
        # Load the device
        device = DeviceManager().load(device_name, device_parameters)[Util.AcsConstants.DEFAULT_DEVICE_NAME]
        # store the device config file
        device_conf_list = []
        for dev in DeviceManager().get_all_devices():
            device_config_file = dev.get_config("DeviceConfigPath")
            if device_config_file:
                device_conf_list.append(device_config_file)
        self._campaign_elements.update({"devices": device_conf_list})

        # Init the logger
        self.__init_logger(device.hw_variant_name, serial_number, self.campaign_report_path, metacampaign_uuid)

        self.__logger.info('Checking acs version : %s' % str(Util.get_acs_release_version()))

        if self.__test_case_conf_list:
            if random_mode:
                self.__test_case_conf_list = self.__randomize_test_cases(self.__test_case_conf_list)
            # Parse parameter catalog
            parameter_catalog_parser = ParameterCatalogParser()
            self.__global_config.__setattr__("parameterConfig", parameter_catalog_parser.parse_catalog_folder())

            # Retrieve MTBF custom parameter to align logging level between the console and the log file
            is_logging_level_aligned = Util.str_to_bool(
                self.__global_config.campaignConfig.get("isLoggingLevelAligned", "False"))
            # Set log level according to global_config file content
            if log_level_param:
                logging_level = log_level_param
            else:
                logging_level = self.__global_config.campaignConfig.get("loggingLevel", "DEBUG")
            ACSLogging.set_log_level(logging_level, is_logging_level_aligned)

            # Set campaign_type when it exists
            campaign_type = self.__global_config.campaignConfig.get("CampaignType")

            # Set credentials
            self.__global_config.__setattr__("credentials", credentials)

            # Init reports
            self.__init_reports(self.campaign_report_path,
                                device_name, campaign_name, campaign_relative_path,
                                campaign_type, user_email, metacampaign_uuid)

            # Creates Test case Manager object
            self.__test_case_manager = TestCaseManager(self.__test_report,
                                                       live_reporting_interface=self._live_reporting_interface)

            # Setup Test Case Manager
            tcm_stop_execution = self.__test_case_manager.setup(self.__global_config,
                                                                self.__debug_report,
                                                                self.__test_case_conf_list[0].do_device_connection)
            status = tcm_stop_execution
        else:
            status = AcsBaseException.NO_TEST

        return status
Exemple #8
0
class UseCaseBase(TestStepEngine):
    """
    Base class for all use case implementation
    """
    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"))

    def _run_test_steps(self, path, optional_step=True):
        return TestStepEngine._run_test_steps(self, path, optional_step=True)

    def initialize(self):
        verdict, msg = TestStepEngine.initialize(self)
        self._device.inject_device_log("i", "ACS_TESTCASE",
                                       "INITIALIZE: %s" % self._name)
        return verdict, msg

    def set_up(self):
        """
        Initialize the test
        """
        verdict, msg = TestStepEngine.set_up(self)
        self._device.inject_device_log("i", "ACS_TESTCASE",
                                       "SETUP: %s" % self._name)
        return verdict, msg

    def run_test(self):
        """
        Execute the test
        """
        verdict, msg = TestStepEngine.run_test(self)
        self._device.inject_device_log("i", "ACS_TESTCASE",
                                       "RUNTEST: %s" % self._name)
        return verdict, msg

    def tear_down(self):
        """
        End and dispose the test
        """
        verdict, msg = TestStepEngine.tear_down(self)
        self._device.inject_device_log("i", "ACS_TESTCASE",
                                       "TEARDOWN: %s" % self._name)
        return verdict, msg

    def finalize(self):
        verdict, msg = TestStepEngine.finalize(self)
        self._device.inject_device_log("i", "ACS_TESTCASE",
                                       "FINALIZE: %s" % self._name)
        return verdict, msg
Exemple #9
0
 def create_device_config(self, device_id):
     """
     Returns a device config object
     """
     return DeviceManager().get_device_config(device_id)
Exemple #10
0
 def create_device(self, device_id):
     """
     Returns a device
     """
     return DeviceManager().get_device(device_id)