Exemplo n.º 1
0
class AFFuTeBase(TestStepBase):
    """
    Base class for interaction with AFFuTe python framework
    """

    def __init__(self, tc_conf, global_conf, ts_conf, factory):
        TestStepBase.__init__(self, tc_conf, global_conf, ts_conf, factory)
        self._audio_fwk_api = AFFuTe()

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

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

        self._audio_fwk_api.server_address = (self._pars.server_address,
                                              int(self._pars.server_port))

        # Initialize AFFuTE
        self._audio_fwk_api.connect_fwk()
        self._audio_fwk_api.initialize_fwk()
Exemplo n.º 2
0
    def run_test(self):
        """
        Execute the test
        """
        # Call LabAudioVcBase Run Test function
        LabAudioWcdmaVcBase.run_test(self)

        # Initiate a MO voice call
        if self._vc_type == "MO":

            # Dial using phone number
            self._logger.info("Calling %s ..." % self._phone_number)
            self._voicecall_api.dial(self._phone_number)

            # Check call status before callSetupTimeout (NS)
            self._vc_3g.check_call_connected(self._call_setup_time,
                                             blocking=False)

            # Check call status before callSetupTimeout (DUT)
            self._voicecall_api.wait_for_state(
                self._uecmd_types.VOICE_CALL_STATE.ACTIVE,  # pylint: disable=E1101
                self._call_setup_time)

        else:
            # Initiate a MT voice call
            self._vc_3g.mt_originate_call()
            # pylint: disable=E1101
            # Check call status is incoming before callSetupTimeout
            self._voicecall_api.wait_for_state(
                self._uecmd_types.VOICE_CALL_STATE.INCOMING,
                self._call_setup_time)

            # Answer incoming call
            self._voicecall_api.answer()

            # Check call status before callSetupTimeout (NS)
            self._vc_3g.check_call_connected(self._call_setup_time,
                                             blocking=False)

            # Check call status before callSetupTimeout (DUT)
            self._voicecall_api.wait_for_state(
                self._uecmd_types.VOICE_CALL_STATE.ACTIVE,
                self._call_setup_time)

        start_time = time.localtime()

        # Configure Audio output to headset (jack)
        time.sleep(self._wait_btwn_cmd)
        self._phonesystem_api.switch_audio_output("headset")

        # Set Voice Call Volume
        self._system_api.adjust_specified_stream_volume(
            "VoiceCall", self._call_stream_volume_dut)

        if self._elapsed_time > 0:
            self._elapsed_time = 0

        self._logger.info(
            "Start verifying audio routing - Call duration = %d s" %
            self._call_duration)

        while self._elapsed_time < self._call_duration:

            # Scenario 1: The audio analyzer is an equipment (RS UPV here)
            if self._audio_analyzer_node.get_param_value("Model") in "RS_UPV":

                # Load UPV setup for DL path
                self._audio_analyzer.load_configuration(
                    self._name, str(self._ns_node.get_param_value("Model")),
                    self._aa_ref_file_path, self._codec_type, "DL")

                # Perform audio routing verification for DL path first
                self._logger.info("Verify audio routing in DL")
                self._audio_analyzer.start_single_measurement()

                # Wait for the measurement to end
                self._audio_analyzer.wait_for_sweep_state("sweep_waiting")

                # Transfer the result of the measurement to ACS host
                self._audio_analyzer.store_data_list(
                    self._aa_trace_file_path_dl, self._host_trace_file_path_dl,
                    "SWEep")

                # Get the dynamic range indicator for DL audio path
                res_dl = AudioUtil.get_rms_from_sweep(
                    AudioUtil.get_sweep_trace(self._host_trace_file_path_dl),
                    self._logger)

                # Load UPV setup for UL path
                self._audio_analyzer.load_configuration(
                    self._name, str(self._ns_node.get_param_value("Model")),
                    self._aa_ref_file_path, self._codec_type, "UL")

                # Perform audio routing verification for UL path
                self._logger.info("Verify audio routing in UL")
                self._audio_analyzer.start_single_measurement()

                # Wait for the measurement to end
                self._audio_analyzer.wait_for_sweep_state("sweep_waiting")

                # Transfer the result of the measurement to ACS host
                self._audio_analyzer.store_data_list(
                    self._aa_trace_file_path_ul, self._host_trace_file_path_ul,
                    "SWEep")

                # Get the dynamic range indicator for UL audio path
                res_ul = AudioUtil.get_rms_from_sweep(
                    AudioUtil.get_sweep_trace(self._host_trace_file_path_ul),
                    self._logger)

                if res_dl > self._dynamic_threshold and res_ul > self._dynamic_threshold:
                    self._error.Msg = "Audio correctly routed in both DL and UL - " + \
                                      "Dynamic indicator : DL = %f / UL = %f" % (res_dl, res_ul)
                    self._logger.info(self._error.Msg)
                    self._result_verdict = Global.SUCCESS
                elif res_dl < self._dynamic_threshold and res_ul > self._dynamic_threshold:
                    self._error.Msg = "Audio routing error in DL - " + \
                                      "Dynamic indicator : DL = %f / UL = %f" % (res_dl, res_ul)
                    self._logger.error(self._error.Msg)
                    self._result_verdict = Global.FAILURE
                elif res_ul < self._dynamic_threshold and res_dl > self._dynamic_threshold:
                    self._error.Msg = "Audio routing error in UL - " + \
                                      "Dynamic indicator : DL = %f / UL = %f" % (res_dl, res_ul)
                    self._logger.error(self._error.Msg)
                    self._result_verdict = Global.FAILURE
                else:
                    self._error.Msg = "Audio routing error in both DL and UL - " + \
                                      "Dynamic indicator : DL = %f / UL = %f" % (res_dl, res_ul)
                    self._logger.error(self._error.Msg)
                    self._result_verdict = Global.FAILURE

                if self._keep_record:
                    # Update the name of the trace file, in case of back-to-back and KEEP_RECORD = true
                    self._host_trace_file_path_dl = self._host_trace_file_path_dl.strip(self._host_trace_file_path_dl.split('_')[-1]) + \
                                                 str(self._tc_parameters.get_b2b_iteration() - self._tc_iteration_count + 1) \
                                                 + ".trc"
                    self._host_trace_file_path_ul = self._host_trace_file_path_ul.strip(self._host_trace_file_path_ul.split('_')[-1]) + \
                                                 str(self._tc_parameters.get_b2b_iteration() - self._tc_iteration_count + 1) \
                                                 + ".trc"
                else:
                    os.remove(self._host_trace_file_path_dl)
                    os.remove(self._host_trace_file_path_ul)

                self._tc_iteration_count -= 1

            # Scenario 2: The audio analyzer is an external python framework
            elif self._audio_analyzer_node.get_param_value(
                    "Model") in "AUDIO_FRAMEWORK":
                [self._result_verdict,
                 self._error.Msg] = AudioFramework.start_audio_routing(
                     self._audio_framework,
                     self._ref_file,
                     self._audio_framework_timeout,
                     wait_for_timeout=1)

            if self._result_verdict is Global.FAILURE:
                break

            # Wait for the next measurement to be made while checking the CSV call is still active
            self._vc_3g.is_voice_call_connected(self._wait_between_measure)

            # Get elapsed time since call establishment in s
            self._elapsed_time = self.__get_elapsed_time(
                start_time, time.localtime())
            self._logger.info(
                "Time elapsed since the beginning of the call: %d s" %
                self._elapsed_time)

        # Release the call
        self._vc_3g.voice_call_network_release()

        try:
            # Check call is released (NS)
            self._vc_3g.check_call_idle(self._registration_timeout,
                                        blocking=False)

            # Check call is released (CDK)
            self._voicecall_api.wait_for_state(
                self._uecmd_types.VOICE_CALL_STATE.NOCALL,  # pylint: disable=E1101
                self._call_setup_time)

        except AcsBaseException as acs_exception:
            self._logger.warning("Call release fail:" + str(acs_exception))

        return self._result_verdict, self._error.Msg
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """

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

        # Set parameters default values
        self._module_id = None
        self._cur_date_time = None
        self._host_deg_file_path = None
        self._result_verdict = None
        self._pesq_result = None
        self._host_ref_file_path = None
        self._error_msg = None
        self._wideband = None

        # 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")

        # Read callSetupTimeout from Device_Catalog.xml
        self._call_setup_time = int(self._dut_config.get("callSetupTimeout"))

        # Read NETWORK_SIMULATOR1 parameters from BenchConfig.xml
        self._ns_node = global_config.benchConfig.get_parameters(
            "NETWORK_SIMULATOR1")

        # Read AUDIO_ANALYZER parameters from BenchConfig.xml
        self._audio_analyzer_node = \
            global_config.benchConfig.get_parameters("AUDIO_ANALYZER")

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

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

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

        # Read CODEC from test case xml file
        self._codec = str(self._tc_parameters.get_param_value("CODEC"))
        if 'WB' in self._codec:
            self._codec_type = "WB"
        elif 'NB' in self._codec:
            self._codec_type = "NB"

        # Read VC_TYPE from test case xml file
        self._vc_type = str(self._tc_parameters.get_param_value("VC_TYPE"))

        # Read AUDIO_FILE from test case xml file
        self._ref_file = str(self._tc_parameters.get_param_value("AUDIO_FILE"))

        # Create cellular network simulator and retrieve 3G APIs
        self._ns = self._em.get_cellular_network_simulator("NETWORK_SIMULATOR1")
        self._ns_3g = self._ns.get_cell_3g()
        self._vc_3g = self._ns_3g.get_voice_call()

        if self._audio_analyzer_node.get_param_value("Model") in "RS_UPV":
            # Create audio analyzer
            self._audio_analyzer = self._em.get_audio_analyzer("AUDIO_ANALYZER")
            self._ns_speech_source = "SPEECH_OUTPUT"

        elif self._audio_analyzer_node.get_param_value("Model") in "AUDIO_FRAMEWORK":
            # Create an AudioFramework object
            self._audio_framework = AudioFramework()
            self._audio_framework.server_address = (self._audio_analyzer_node.get_param_value("IP"),
                                                    int(self._audio_analyzer_node.get_param_value("server_port")))
            self._audio_framework.logger = self._logger
            self._audio_framework_timeout = 8
            self._ns_speech_source = "ECHO"

        # Instantiate generic UECmd for voiceCall Ucs
        self._modem_api = self._device.get_uecmd("Modem")
        self._networking_api = self._device.get_uecmd("Networking")
        self._voicecall_api = self._device.get_uecmd("VoiceCall")
        self._phonesystem_api = self._device.get_uecmd("PhoneSystem")
        self._system_api = self._device.get_uecmd("System")
        self._audioalgocontroller_api = self._device.get_uecmd("AudioAlgoController")

        # Read Keep Record value from test case xml file (str)
        self._keep_record = str_to_bool(self._tc_parameters.get_param_value("KEEP_RECORD"))

        # Get the current date time for degraded audio file name
        self._cur_date_time = time.strftime('%Y%m%d_%H%M%S', time.localtime())

        # Read ConfPath from AUDIO_ANALYZER BenchConfig.xml
        self._aa_conf_path = os.path.join(
            str(self._audio_analyzer_node.get_param_value("ConfPath")))

        # Read DestPath from AUDIO_ANALYZER BenchConfig.xml
        self._aa_dest_path = os.path.join(
            str(self._audio_analyzer_node.get_param_value("DestPath")))

        # Only Audio Quality TCs require a specific audio test file
        if "AQ" in self._name:

            # Construct reference audio file path on bench computer
            self._host_ref_file_path = os.path.join(self._aa_conf_path,
                                                    self._ref_file)

            # Construct degraded audio file path on bench computer
            if "SWITCH" in self._name:
                self._host_deg_file_path = os.path.join(self._aa_conf_path,
                                                        self._name.split('\\')[-1].split('-')[0] + "-" +
                                                        self._name.split('\\')[-1].split('-')[1] + "-" +
                                                        str(self._tc_parameters.get_ucase_name()) + "_" +
                                                        self._cur_date_time + ".wav")
            else:
                self._host_deg_file_path = os.path.join(self._aa_conf_path,
                                                        self._name.split('\\')[-1].split('-')[0] + "-" +
                                                        str(self._tc_parameters.get_ucase_name()) + "_" +
                                                        self._cur_date_time + ".wav")

                # Construct reference audio file path on UPV
                self._aa_ref_file_path = os.path.join(self._aa_dest_path,
                                                      self._ref_file)

                # Construct degraded audio file path on UPV
                self._aa_deg_file_path = os.path.join(self._aa_dest_path,
                                                      "voice_degraded_upv.wav")

                self._option = None

        else:
            # Audio generator signal is handled by UPV
            self._aa_ref_file_path = None

            self._option = "DL"
    def set_up(self):
        """
        Set up the test configuration
        """

        # Call UseCaseBase Setup function
        UseCaseBase.set_up(self)

        # Connect to cellular network simulator
        self._ns.init()

        # Set the equipment application format WCDMA
        self._ns.switch_app_format("WCDMA")

        if self._audio_analyzer_node.get_param_value("Model") in "RS_UPV":
            # Connect to audio analyzer
            self._audio_analyzer.init()

            if self._aa_ref_file_path:
                # Copy audio test file to UPV
                self._audio_analyzer.copy_to_upv(self._host_ref_file_path,
                                                 self._aa_ref_file_path)

            # Load setup on UPV
            self._audio_analyzer.load_configuration(
                self._name,
                str(self._ns_node.get_param_value("Model")),
                self._aa_ref_file_path,
                self._codec_type,
                self._option)

            if not os.path.exists(os.path.join(self._aa_conf_path, "UPV_traces")):
                os.mkdir(os.path.join(self._aa_conf_path, "UPV_traces"))

        elif self._audio_analyzer_node.get_param_value("Model") in "AUDIO_FRAMEWORK":
            AudioFramework.initialize_fwk(self._audio_framework)

        # Perform Full Preset
        self._ns.perform_full_preset()

        # Set paging service to AMR VOICE
        self._ns.get_cell_3g().set_cell_service(self._cell_service)

        # Set cell off
        self._ns_3g.set_cell_off()

        # Set Cell Band UARFCN (downlink) using Band and DlUarfcn
        self._ns.get_cell_3g().set_band_and_dl_arfcn(str(self._band), self._dl_uarfcn)

        # Set voice call output
        self._vc_3g.set_speech_configuration(self._ns_speech_source)

        # Set cell on
        self._ns_3g.set_cell_on()

        # Adapt attachment procedure to CIRCUIT or PACKET
        if self._cell_service == "CIRCUIT":
            # Check phone registration on equipment before given CAMP_TIMEOUT
            # (in loop compare every second the IMSI returned by the simulator
            # and IMSI read on CDK until comparison is true or timeout expired)
            dut_imsi = \
                self._modem_api.get_imsi(self._registration_timeout)

            RegUtil.check_dut_registration_before_timeout(self._ns.get_cell_3g(),
                                                          self._networking_api,
                                                          self._logger,
                                                          dut_imsi,
                                                          self._registration_timeout)
            self._networking_api.deactivate_pdp_context()

        else:
            # Set the APN
            time.sleep(self._wait_btwn_cmd)
            self._logger.info("Setting APN " + str(self._apn) + "...")
            self._networking_api.set_apn(self._ssid, self._apn)

            # Activate PDP context
            time.sleep(self._wait_btwn_cmd)
            self._logger.info("Active PDP Context...")
            self._networking_api.activate_pdp_context(self._ssid, check=False)

            # Check Data Connection State => ATTACHED before timeout
            RegUtil.check_dut_data_connection_state_before_timeout("PDP_ACTIVE",
                                                                   self._ns.get_cell_3g(),
                                                                   self._networking_api,
                                                                   self._logger,
                                                                   self._registration_timeout,
                                                                   flightmode_cycle=True,
                                                                   blocking=False)

        # Check registration status before registrationTimeout (CDK)
        self._modem_api.check_cdk_registration_bfor_timeout(self._registration_timeout)

        # Release any previous call (Robustness)
        self._voicecall_api.release()

        # Set voice codec using CODEC parameter
        self._vc_3g.set_audio_codec(self._codec)

        return Global.SUCCESS, "No errors"
Exemplo n.º 5
0
 def __init__(self, tc_conf, global_conf, ts_conf, factory):
     TestStepBase.__init__(self, tc_conf, global_conf, ts_conf, factory)
     self._audio_fwk_api = AFFuTe()